annotate doc/ucis.ano/bgp_graph/bgp_path_list_bird.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 d44b9afb4a25
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 $mynode = 64766;
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
4
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
5 $fds = NULL;
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
6 $proc = proc_open('birdc', array(0 => array('pipe','r'), 1 => array('pipe','w'), 2 => STDERR), $fds);
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
7 fwrite($fds[0], "show route all\n");
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
8 fclose($fds[0]);
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
9 $paths = array();
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
10
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
11 while (!feof($fds[1])) {
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
12 $line = stream_get_line($fds[1], 1024, "\n");
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
13 if ($line === NULL || $line === FALSE) break;
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
14 if (!strlen($line) || $line[0] != "\t") continue;
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
15 if (substr($line, 0, 14) != "\tBGP.as_path: ") continue;
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
16 $path = substr($line, 14);
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
17 if (in_array($path, $paths)) continue;
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
18 $paths[] = $path;
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
19 print($mynode.' '.$path."\n");
4dbe5bf653bb Added bgp graph scripts
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
20 }