jablonka.czprosek.czf

netmap

Subversion Repositories:
[/] [gen_ospf_link.pl] - Blame information for rev 27

 

Line No. Rev Author Line
11simandl#!/usr/bin/perl
2#
3# Petr Simandl, www.simandl.cz
4# v 0.0.3
5 
6#print "Content-type: text/html\n\n";
7 
8#print "<HTML><HEAD><META HTTP-EQUIV=Pragma CONTENT=no-cache></HEAD><BODY>\n";
9 
10$date = `date`;
11#print "<BR>$date\n<BR>";
12 
13#print "<pre>";
14 
15@ol_names=`cat /home/www/cgi-bin/netmap/data/jablonecka.comp`;
1627simandl#@ol_database=`/home/www/cgi-bin/ospfd_database.cgi`;
17@ol_database=`wget -q http://10.33.0.11/cgi-bin/ospfd_database.cgi -O -`;
181simandl#print @ol_names;
19 
20foreach $ol_line (@ol_names)
21{
22@ol_pole=split(";",$ol_line);
23#print "$ol_pole[0] $ol_pole[1]\n";
24}
25 
26#print "Vypis routeru s jednotlivymi linky\n";
27#print @ol_database;
28 
29@ol_routers=();
30@ol_links=();
31$ol_router="";
32$ol_link="";
33 
34#picking up routers and their links into fields ol_routers and ol_links
35foreach $ol_line (@ol_database)
36{
37 if ($ol_line =~ /Advertising/)
38 { @ol_string=split(" ",$ol_line);
39# print "\nrouter $ol_string[2]\n";
40 #storing previous router
41 if ($ol_router eq "")
42 #no previous found yet
43 {# print "prvni polozka\n";
44 }
45 else
46 {
47# print "zapis routeru\n";
48 push(@ol_routers, $ol_router );
49# print "@ol_routers\n";
50# print "@ol_links\n";
51 }
52 
53 #prefilling with IP
54 $ol_router=$ol_string[2];
55 #using netmap config to substittute names instead IPs
56 foreach $ol_name (@ol_names)
57 { @ol_name_split=split(";",$ol_name);
58 #compare IPs
59 if ("$ol_name_split[1]" eq "$ol_string[2]")
60 { #print "jsou stejne $ol_name_split[0] a $ol_string[2]\n";
61 #name found so we will store it
62 $ol_router=$ol_name_split[0];
63 }
64 }
65 if ("$ol_router" eq "$ol_string[2]")
66 { #print "Router $ol_router neni v databazi!\n";
67 }
68 
69 
70 
71# $ol_router=$ol_string[2];
72 $ol_link="";
73 }
74 
75 #looking for first (central) side of link
76 if ($ol_line =~ /Designated/)
77 { @ol_string=split(" ",$ol_line);
78# print "ifA $ol_string[5]\n";
79 $ol_link=$ol_string[5];
80 }
81 
82 #looking for second (local) side of link and storing this link into the ol_links
83 if ($ol_line =~ /Interface/)
84 { @ol_string=split(" ",$ol_line);
85# print "ifB $ol_string[5]\n";
86 #adding only second local side
87 $ol_router=$ol_router." ".$ol_string[5];
88 $ol_link=$ol_link." ".$ol_string[5];
89 push(@ol_links, $ol_link );
90 $ol_link="";
91 }
92}
93 
94#storing the last router
95#print "Posledni zapis routeru\n";
96push(@ol_routers, $ol_router );
97#print "@ol_routers\n";
98 
99 
100#print "\n\nVypis pole routeru\n";
101 
102#print "@ol_routers";
103 
104#print "\n\nVypis pole linku\n";
105#print "@ol_links";
106 
107####################################################
108 
109#print "\n\nVypis pole linku redukovanych\n";
110 
111#kicking links with same begin and end
112@ol_links_reduced=();
113 
114foreach $ol_line (@ol_links)
115{ @ol_string=split(" ",$ol_line);
116 if ("$ol_string[0]" eq "$ol_string[1]")
117 { #print "jsou stejne $ol_string[0] a $ol_string[1]\n";
118 }
119 else
120 {
121 push(@ol_links_reduced, $ol_line );
122 #print "added $ol_line\n";
123 }
124 
125}
126 
127 
128#print "@ol_links_reduced";
129 
130#prvni cast linku je vzdy designated
131#seradit podle prvni casti linku
132#roztridit do skupin podle prvni casti linku
133#pokud chceme -zatim nedelat - tak ve skupine vybrat nejmensi ip a vlozit ho za designated
134#stale mame dvojice linku
135#jdeme v seznamu routeru ol_routers a pekne v seznamu ol_links zamenime hlavni IP routeru za IP jeho rozhrani
136 
137#print "\n\nVytvareni jmennych linku\n";
138 
139#going through all links and fill router names into links instead of interface IPs
140@ol_links_named=();
141foreach $ol_link (@ol_links_reduced)
142{ @ol_ips=split(" ",$ol_link);
143# print "$ol_link";
144 #initially we fill both sides of link with real IPs
145 $ol_ipa=$ol_ips[0];
146 $ol_ipb=$ol_ips[1];
147 foreach $ol_router_line (@ol_routers)
148 { @ol_router_ifaces=split(" ",$ol_router_line);
149 $ol_router_name=shift(@ol_router_ifaces);
150 #print "$ol_router_name ma @ol_router_ifaces\n";
151 foreach $ol_iface (@ol_router_ifaces)
152 { #print "$ol_iface\n";
153 if ("$ol_iface" eq "$ol_ips[0]")
154 { $ol_ipa=$ol_router_name;
155 }
156 if ("$ol_iface" eq "$ol_ips[1]")
157 { $ol_ipb=$ol_router_name;
158 }
159 }
160 }
161 #
162 push(@ol_links_named, $ol_ipa." ".$ol_ipb );
163}
164 
165#print "\n\n@ol_links_named\n";
166foreach $ol_link (@ol_links_named)
167{ @ol_name=split(" ",$ol_link);
168 print "92;$ol_name[0];$ol_name[1];\n";
169}
170 
171 
172 
173#print "</pre></BODY></HTML>";
174 
175exit

Powered by WebSVN 2.2.1