annotate doc/ucis.ano/bgp_graph/bgp_path_list_quagga.php @ 28:4dbe5bf653bb draft

Added bgp graph scripts
author ivo <ivo@UFO-Net.nl>
date Thu, 10 Jun 2010 00:15:51 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
1 #!/usr/bin/php
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
2 <?php
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
3 $sock = fsockopen('localhost', 2605);
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
4 fread($sock, 1024);
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
5 fwrite($sock, "insecure\n");
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
6 fwrite($sock, "show ip bgp paths\n");
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
7 fwrite($sock, "quit\n");
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
8 while (!feof($sock)) {
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
9 $line = stream_get_line($sock, 1024, "\r\n");
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
10 if ($line === NULL || $line === FALSE) break;
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
11 if (!strlen($line) || $line[0] != '[') continue;
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
12 $pos = strpos($line, ') ');
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
13 if ($pos === FALSE) continue;
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
14 if ($pos == strlen($line) - 2) continue;
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
15 print(substr($line, $pos+2)."\n");
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
16 }