source: genesis/tools/inc2minimal.pl@ 2271

Last change on this file since 2271 was 1985, checked in by dirkx, 21 years ago

Tweaks so that java reads it

File size: 1.6 KB
Line 
1#!/usr/bin/perl
2$|++;
3require "conf.inc"
4 or die "Did you run conf2inc.pl > conf.inc ??";
5
6# Make a reverse mapping..
7my %ips = ();
8
9foreach my $node (sort keys %$VAR1) {
10 foreach my $iface (keys %{ $VAR1->{$node}->{ifaces} }) {
11 my $v = $VAR1->{$node}->{ifaces}->{$iface};
12 next unless defined $v->{IP};
13 $ip = $v->{IP};
14 die "IP of $node:$iface malformed ($ip)"
15 unless $ip =~ m/([\d\.]+)\/(\d+)/;
16 $pip = $1;
17 $mask = $2;
18
19 my %info=();
20 if ($iface =~ m/([^:]+):(.*)/) {
21 my ($a,$b)=($1,$2);
22 %info = %{$VAR1->{$node}->{ifaces}->{$a}};
23 };
24 foreach my $k (keys(%{$v})) {
25 $info{ $k } = $v->{$k};
26 };
27
28 $ips{ $pip } = \%info;
29 # print "$node $iface $pip $info{ESSID}\n";
30 }
31}
32
33foreach my $node (sort keys %$VAR1) {
34 my $vals = $VAR1->{$node};
35 print qq|<node id="$node" ip="$vals->{master_ip}>
36 <location>$vals->{location}</location>
37|;
38 foreach my $iface (sort keys(%{$vals->{ifaces}})) {
39 my $v = $vals->{ifaces}->{$iface};
40 print qq| <iface\tid="$iface"\n|;
41
42 if ($v->{TYPE} =~ m/wireless/i) {
43 my $ssid = "ERROR!";
44 if ($v->{MODE} =~ m/master/i) {
45 print qq|\t\tchannel="$v->{CHANNEL}"\n|;
46 $ssid = $v->{ESSID};
47 print "\t\tmaster\n";
48 } else {
49 # Channel vollows; ESSID is
50 # that of the peer.
51 my $pip = $v->{POINT_TO_POINT};
52 if (defined $ips{ $pip }) {
53 $ssid = $ips{$pip}->{ESSID};
54 } else {
55 $ssid = 'undefined ('.$pip.')';
56 }
57 };
58 print qq|\t\tssid="$ssid"\n|;
59 }
60 if ($v->{DHCP} =~ m/(\d+)\-(\d+)/) {
61 my $x = $2 - $1;
62 print qq|\t\tdhcp="$x"\n|;
63 };
64 print "\t\t>\n";
65 print qq| </iface>\n|;
66 }
67 print qq|</node>\n|;
68};
Note: See TracBrowser for help on using the repository browser.