diff --git a/mxstartup2mxconfig b/mxstartup2mxconfig index 0cb7244..3ef4259 100755 --- a/mxstartup2mxconfig +++ b/mxstartup2mxconfig @@ -112,6 +112,7 @@ sub parse_ips { my %ports = (); my $ip = "-"; my $_todest = undef; + my $addressprefix; if(/\{(\S+)\}(\S+)/) { # extract device "{device}ip[d:t][..]" $device = $1; @@ -126,17 +127,23 @@ sub parse_ips { if($_ =~ /(\S+)\:(\S+)/) { $_todest = $2; $_ = $1; + } + + if (/(\S+)\/(\S+)/) { + $_=$1; + $addressprefix=$2; } else { - $_todest = $_; + $addressprefix=20; } - + if("$_" eq "-") { $_ = $fullhostname; } - if("$_todest" eq "-") { - $_todest = $fullhostname; + unless (defined $_todest) { + $_todest=$_; } + # printf "ip = $_\n"; # printf "todest = $_todest\n"; @@ -144,7 +151,7 @@ sub parse_ips { $ip = inet_ntoa(scalar gethostbyname($_)); $_todest = inet_ntoa(scalar gethostbyname($_todest)); - $H->{$ip} = { device => $device, ports => {%ports}, todest => $_todest } unless($ip eq "-"); + $H->{$ip} = { device => $device, addressprefix => $addressprefix, ports => {%ports}, todest => $_todest }; } return $H; @@ -195,7 +202,7 @@ sub print_ips_cfg { if("$ip" ne "$hostip") { print SCRIPT qq(# ip $i\n); print SCRIPT qq(MX_IP_ADDRESS[$i]="$ip"\n); - print SCRIPT qq(MX_IP_ADDRESSPREFIX[$i]="20"\n); + print SCRIPT qq(MX_IP_ADDRESSPREFIX[$i]="$H->{$ip}->{addressprefix}"\n); print SCRIPT qq(MX_IP_BROADCAST[$i]="141.14.31.255"\n); print SCRIPT qq(MX_IP_DEVICE[$i]="$H->{$ip}->{device}"\n); $i++;