1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
--- lib/getbgptable.pl.orig Thu Feb 6 11:25:26 2003
+++ lib/getbgptable.pl Thu Feb 6 11:43:58 2003
@@ -24,10 +24,55 @@
# ASs (all the ASs in the router BGP table)
# Finally this routine produces a text file containing the raw version of the router table
# and if required log files of both the raw router table and the normalized table.
+
+
sub get_bgp_table {
my ($parser, $command, $line) = ('', '', '');
my (@lines) = ();
+ use Socket;
+ use Net::Telnet;
+
+ if (defined($ROUTERUSERPASS)) {
+
+# TELNET module to get BGP4+ AS Path table
+
+ if ($ROUTER =~ /^JUNIPER$/i) {
+ $parser = "juniper";
+ $STATUSCODES = "*> active";
+ my $telnet_session = new Net::Telnet(
+ prompt => '/[\w().-]*[\$#]\s*$/'
+ );
+
+ $telnet_session->open($ROUTERADDR);
+ $telnet_session->login($ROUTERUSER, $ROUTERUSERPASS);
+ $telnet_session->cmd(String => "set cli screen-length 0", Timeout => 1800);
+
+ @lines = $telnet_session->cmd(String => "show route table inet6.0 all terse",
+ Timeout => 1800);
+ $telnet_session->close;
+ } else {
+ $ROUTER = "CISCO";
+ $parser = "cisco";
+ $STATUSCODES = "s suppressed, d damped, h history, * valid, > best, r RIB-failure";
+ my $telnet_session = new Net::Telnet(
+ prompt => '/[\w().-]*[\$#]\s*$/'
+ );
+
+ $telnet_session->open($ROUTERADDR);
+ $telnet_session->login($ROUTERUSER, $ROUTERUSERPASS);
+ $telnet_session->cmd(String => "terminal length 0", Timeout => 1800);
+
+ @lines = $telnet_session->cmd(String => "show bgp ipv6",
+ Timeout => 1800);
+ $telnet_session->close;
+ }
+# end TELNET module
+
+ } else {
+
+# RSH module to get BGP4+ AS Path table
+
if ($ROUTER =~ /^JUNIPER$/i) {
$parser = "juniper";
$STATUSCODES = "*> active";
@@ -58,6 +103,7 @@
push(@lines, $_);
}
close(OUTPUT);
+ }
chomp(@lines);
# Write log and for web files (raw table)
open(TXTFILE,"> $BGPTABLEFILE");
|