repo: resdb action: commit revision: path_from: revision_from: 2a9c494477ed1d88f97b8b8db98a841c74159b1f: path_to: revision_to:
commit 2a9c494477ed1d88f97b8b8db98a841c74159b1f Author: ivoDate: Thu Jun 10 00:15:51 2010 +0200 Added bgp graph scripts diff --git a/doc/ucis.ano/bgp_graph/bgp_path_list_bird.php b/doc/ucis.ano/bgp_graph/bgp_path_list_bird.php new file mode 100755 index 0000000000000000000000000000000000000000..6ef71c7f5d170f07fb9e6be40fe959787754b0bc --- /dev/null +++ b/doc/ucis.ano/bgp_graph/bgp_path_list_bird.php @@ -0,0 +1,20 @@ +#!/usr/bin/php + 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"); +} diff --git a/doc/ucis.ano/bgp_graph/bgp_path_list_bird.sh b/doc/ucis.ano/bgp_graph/bgp_path_list_bird.sh new file mode 100755 index 0000000000000000000000000000000000000000..747f01752e789cab1b022ab25f2ff6e322b7bf0b --- /dev/null +++ b/doc/ucis.ano/bgp_graph/bgp_path_list_bird.sh @@ -0,0 +1,3 @@ +#!/bin/sh +LOCALNODE=0 +echo "show route all" | birdc | grep -F "BGP.as_path:" | sed "s/^\tBGP.as_path: \([0-9 ]*\)$/$LOCALNODE \1/" | sort -u diff --git a/doc/ucis.ano/bgp_graph/bgp_path_list_quagga.php b/doc/ucis.ano/bgp_graph/bgp_path_list_quagga.php new file mode 100755 index 0000000000000000000000000000000000000000..240dcf3f2b7ddd01f048ddb4d0c4393c48a5635d --- /dev/null +++ b/doc/ucis.ano/bgp_graph/bgp_path_list_quagga.php @@ -0,0 +1,16 @@ +#!/usr/bin/php +') === FALSE) break; + seekto($file, ' '); + $endofsection = FALSE; + $path = $mynode; + while (!feof($file)) { + if (seekto($file, '<') === FALSE) break; + switch (fread($file, 4)) { + case 'asn>': break; + case '/seg': $endofsection = TRUE; break; + default: die('unknown tag at '.(ftell($file)-4)); + } + if ($endofsection) break; + $asn = seekto($file, ''); + $path .= ' '.$asn; + } + if (in_array($path, $paths)) continue; + $paths[] = $path; + print($path."\n"); +} + +function seekto($f, $str) { + $part = ''; + $i = 0; + $len = strlen($str); + while ($i < $len && !feof($f)) { + $c = fgetc($f); + if ($c === FALSE) return FALSE; + if ($c == $str[$i]) { + $i++; + } else { + if ($i) { + $i = 0; + $part = ''; + } + $part .= $c; + } + } + return $part; +} diff --git a/doc/ucis.ano/bgp_graph/path_list_to_dot.php b/doc/ucis.ano/bgp_graph/path_list_to_dot.php new file mode 100755 index 0000000000000000000000000000000000000000..d198331cc77949c0da4851a36c9ee8581eaf2cdc --- /dev/null +++ b/doc/ucis.ano/bgp_graph/path_list_to_dot.php @@ -0,0 +1,31 @@ +#!/usr/bin/php + $links) { + foreach ($links as $link => $dummy) { + if (isset($nodes[$node][$link]) && isset($nodes[$link][$node])) unset($nodes[$link][$node]); + } +} + +print("graph BGP_nodes {\n"); +foreach ($nodes as $node => $links) { + foreach ($links as $link => $dummy) { + print("\t".$node.' -- '.$link.";\n"); + } +} +print('}'); diff --git a/doc/ucis.ano/bgp_graph/path_list_to_xml.php b/doc/ucis.ano/bgp_graph/path_list_to_xml.php new file mode 100755 index 0000000000000000000000000000000000000000..d9df7f6d7a85ac295069556d4985e39e89e32ed8 --- /dev/null +++ b/doc/ucis.ano/bgp_graph/path_list_to_xml.php @@ -0,0 +1,17 @@ +#!/usr/bin/php +'."\n"); + $prevnode = $node; + } +} diff --git a/doc/ucis.ano/bgp_graph/process_xml.sh b/doc/ucis.ano/bgp_graph/process_xml.sh new file mode 100755 index 0000000000000000000000000000000000000000..dec83dd657f61e22bd84d73d0475cf3c72f626ce --- /dev/null +++ b/doc/ucis.ano/bgp_graph/process_xml.sh @@ -0,0 +1,6 @@ +#!/bin/sh +for file in ./xml/* +do + echo "Processing $file" + ./bgp_path_list_xml.php < "$file" > data/`basename "$file"` +done
-----END OF PAGE-----