jablonka.czprosek.czf

netmap

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

 

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

Powered by WebSVN 2.2.1