28
|
1 #!/usr/bin/php |
|
2 <?php |
|
3 $mynode = 64766; |
|
4 |
|
5 $fds = NULL; |
|
6 $proc = proc_open('birdc', array(0 => array('pipe','r'), 1 => array('pipe','w'), 2 => STDERR), $fds); |
|
7 fwrite($fds[0], "show route all\n"); |
|
8 fclose($fds[0]); |
|
9 $paths = array(); |
|
10 |
|
11 while (!feof($fds[1])) { |
|
12 $line = stream_get_line($fds[1], 1024, "\n"); |
|
13 if ($line === NULL || $line === FALSE) break; |
|
14 if (!strlen($line) || $line[0] != "\t") continue; |
|
15 if (substr($line, 0, 14) != "\tBGP.as_path: ") continue; |
|
16 $path = substr($line, 14); |
|
17 if (in_array($path, $paths)) continue; |
|
18 $paths[] = $path; |
|
19 print($mynode.' '.$path."\n"); |
|
20 } |