jablonka.czprosek.czf

netmap

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

 

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;
1928simandl@ol_basiclinks=`cat /home/www/cgi-bin/netmap/data/jablonecka.link.basic | grep ^00`;
201simandl 
21foreach $ol_line (@ol_names)
22{
23@ol_pole=split(";",$ol_line);
24#print "$ol_pole[0] $ol_pole[1]\n";
25}
26 
27#print "Vypis routeru s jednotlivymi linky\n";
28#print @ol_database;
29 
30@ol_routers=();
31@ol_links=();
32$ol_router="";
33$ol_link="";
34 
35#picking up routers and their links into fields ol_routers and ol_links
36foreach $ol_line (@ol_database)
37{
38 if ($ol_line =~ /Advertising/)
39 { @ol_string=split(" ",$ol_line);
40# print "\nrouter $ol_string[2]\n";
41 #storing previous router
42 if ($ol_router eq "")
43 #no previous found yet
44 {# print "prvni polozka\n";
45 }
46 else
47 {
48# print "zapis routeru\n";
49 push(@ol_routers, $ol_router );
50# print "@ol_routers\n";
51# print "@ol_links\n";
52 }
53 
54 #prefilling with IP
55 $ol_router=$ol_string[2];
56 #using netmap config to substittute names instead IPs
57 foreach $ol_name (@ol_names)
58 { @ol_name_split=split(";",$ol_name);
59 #compare IPs
60 if ("$ol_name_split[1]" eq "$ol_string[2]")
61 { #print "jsou stejne $ol_name_split[0] a $ol_string[2]\n";
62 #name found so we will store it
63 $ol_router=$ol_name_split[0];
64 }
65 }
66 if ("$ol_router" eq "$ol_string[2]")
67 { #print "Router $ol_router neni v databazi!\n";
68 }
69 
70 
71 
72# $ol_router=$ol_string[2];
73 $ol_link="";
74 }
75 
76 #looking for first (central) side of link
77 if ($ol_line =~ /Designated/)
78 { @ol_string=split(" ",$ol_line);
79# print "ifA $ol_string[5]\n";
80 $ol_link=$ol_string[5];
81 }
82 
83 #looking for second (local) side of link and storing this link into the ol_links
84 if ($ol_line =~ /Interface/)
85 { @ol_string=split(" ",$ol_line);
86# print "ifB $ol_string[5]\n";
87 #adding only second local side
88 $ol_router=$ol_router." ".$ol_string[5];
89 $ol_link=$ol_link." ".$ol_string[5];
90 push(@ol_links, $ol_link );
91 $ol_link="";
92 }
93}
94 
95#storing the last router
96#print "Posledni zapis routeru\n";
97push(@ol_routers, $ol_router );
98#print "@ol_routers\n";
99 
100 
101#print "\n\nVypis pole routeru\n";
102 
103#print "@ol_routers";
104 
105#print "\n\nVypis pole linku\n";
106#print "@ol_links";
107 
108####################################################
109 
110#print "\n\nVypis pole linku redukovanych\n";
111 
112#kicking links with same begin and end
113@ol_links_reduced=();
114 
115foreach $ol_line (@ol_links)
116{ @ol_string=split(" ",$ol_line);
117 if ("$ol_string[0]" eq "$ol_string[1]")
118 { #print "jsou stejne $ol_string[0] a $ol_string[1]\n";
119 }
120 else
121 {
122 push(@ol_links_reduced, $ol_line );
123 #print "added $ol_line\n";
124 }
125 
126}
127 
128 
129#print "@ol_links_reduced";
130 
131#prvni cast linku je vzdy designated
132#seradit podle prvni casti linku
133#roztridit do skupin podle prvni casti linku
134#pokud chceme -zatim nedelat - tak ve skupine vybrat nejmensi ip a vlozit ho za designated
135#stale mame dvojice linku
136#jdeme v seznamu routeru ol_routers a pekne v seznamu ol_links zamenime hlavni IP routeru za IP jeho rozhrani
137 
138#print "\n\nVytvareni jmennych linku\n";
139 
140#going through all links and fill router names into links instead of interface IPs
141@ol_links_named=();
142foreach $ol_link (@ol_links_reduced)
143{ @ol_ips=split(" ",$ol_link);
144# print "$ol_link";
145 #initially we fill both sides of link with real IPs
146 $ol_ipa=$ol_ips[0];
147 $ol_ipb=$ol_ips[1];
148 foreach $ol_router_line (@ol_routers)
149 { @ol_router_ifaces=split(" ",$ol_router_line);
150 $ol_router_name=shift(@ol_router_ifaces);
151 #print "$ol_router_name ma @ol_router_ifaces\n";
152 foreach $ol_iface (@ol_router_ifaces)
153 { #print "$ol_iface\n";
154 if ("$ol_iface" eq "$ol_ips[0]")
155 { $ol_ipa=$ol_router_name;
156 }
157 if ("$ol_iface" eq "$ol_ips[1]")
158 { $ol_ipb=$ol_router_name;
159 }
160 }
161 }
162 #
163 push(@ol_links_named, $ol_ipa." ".$ol_ipb );
164}
165 
16628simandl#now we will look into basic link file and all not found basic links (00) will be drawn in red color
167foreach $ol_linkb (@ol_basiclinks)
168{ @ol_nameb=split(/;/,$ol_linkb);
169 @ol_nameb = sort (@ol_nameb);
170 $ol_ispresent=0;
171 #print $ol_name[3];
172 
173 foreach $ol_linko (@ol_links_named)
174 { @ol_nameo=split(" ",$ol_linko);
175 @ol_nameo = sort (@ol_nameo);
176 if (("$ol_nameo[0]" eq "$ol_nameb[2]") && ("$ol_nameo[1]" eq "$ol_nameb[3]"))
177 { $ol_ispresent=1;
178# print "92;$ol_nameo[0];$ol_nameo[1];\n";
179 
180 };
181 };
182 if ($ol_ispresent)
183 { print "92;$ol_nameb[2];$ol_nameb[3];\n";}
184 else
185 { print "82;$ol_nameb[2];$ol_nameb[3];\n";}
1861simandl}
187 
188#print "</pre></BODY></HTML>";
189 
190exit

Powered by WebSVN 2.2.1