[1978] | 1 | #!/usr/bin/perl
|
---|
| 2 | $|++;
|
---|
| 3 | require "conf.inc"
|
---|
| 4 | or die "Did you run conf2inc.pl > conf.inc ??";
|
---|
| 5 |
|
---|
| 6 | # Make a reverse mapping..
|
---|
| 7 | my %ips = ();
|
---|
| 8 |
|
---|
[1985] | 9 | foreach my $node (sort keys %$VAR1) {
|
---|
[1978] | 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 |
|
---|
[1985] | 33 | foreach my $node (sort keys %$VAR1) {
|
---|
| 34 | my $vals = $VAR1->{$node};
|
---|
[1978] | 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};
|
---|
[1985] | 40 | print qq| <iface\tid="$iface"\n|;
|
---|
[1978] | 41 |
|
---|
| 42 | if ($v->{TYPE} =~ m/wireless/i) {
|
---|
| 43 | my $ssid = "ERROR!";
|
---|
| 44 | if ($v->{MODE} =~ m/master/i) {
|
---|
[1985] | 45 | print qq|\t\tchannel="$v->{CHANNEL}"\n|;
|
---|
[1978] | 46 | $ssid = $v->{ESSID};
|
---|
[1985] | 47 | print "\t\tmaster\n";
|
---|
[1978] | 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 | };
|
---|
[1985] | 58 | print qq|\t\tssid="$ssid"\n|;
|
---|
[1978] | 59 | }
|
---|
| 60 | if ($v->{DHCP} =~ m/(\d+)\-(\d+)/) {
|
---|
| 61 | my $x = $2 - $1;
|
---|
[1985] | 62 | print qq|\t\tdhcp="$x"\n|;
|
---|
[1978] | 63 | };
|
---|
[1985] | 64 | print "\t\t>\n";
|
---|
[1978] | 65 | print qq| </iface>\n|;
|
---|
| 66 | }
|
---|
| 67 | print qq|</node>\n|;
|
---|
| 68 | };
|
---|