diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/ucis.ano/bgp_graph/bgp_path_list_bird.php	Thu Jun 10 00:15:51 2010 +0200
@@ -0,0 +1,20 @@
+#!/usr/bin/php
+<?php
+$mynode = 64766;
+
+$fds = NULL;
+$proc = proc_open('birdc', array(0 => array('pipe','r'), 1 => array('pipe','w'), 2 => STDERR), $fds);
+fwrite($fds[0], "show route all\n");
+fclose($fds[0]);
+$paths = array();
+
+while (!feof($fds[1])) {
+	$line = stream_get_line($fds[1], 1024, "\n");
+	if ($line === NULL || $line === FALSE) break;
+	if (!strlen($line) || $line[0] != "\t") continue;
+	if (substr($line, 0, 14) != "\tBGP.as_path: ") continue;
+	$path = substr($line, 14);
+	if (in_array($path, $paths)) continue;
+	$paths[] = $path;
+	print($mynode.' '.$path."\n");
+}