diff options
author | Olivier Blin <oblin@mandriva.com> | 2008-05-20 16:52:07 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.com> | 2008-05-20 16:52:07 +0000 |
commit | 7e92563551f4c4e2c1d7dbb4e5ad0b3a0a523a8f (patch) | |
tree | e0bc21af2a16930683647dda206af00dd5cf3df8 /lib/network/tools.pm | |
parent | 9eb6f8cf86f1442b31d2ec9c88e18267097a3c61 (diff) | |
download | drakx-net-7e92563551f4c4e2c1d7dbb4e5ad0b3a0a523a8f.tar drakx-net-7e92563551f4c4e2c1d7dbb4e5ad0b3a0a523a8f.tar.gz drakx-net-7e92563551f4c4e2c1d7dbb4e5ad0b3a0a523a8f.tar.bz2 drakx-net-7e92563551f4c4e2c1d7dbb4e5ad0b3a0a523a8f.tar.xz drakx-net-7e92563551f4c4e2c1d7dbb4e5ad0b3a0a523a8f.zip |
find gateway address for ptp connections with only one interface route (like hso devices)
Diffstat (limited to 'lib/network/tools.pm')
-rw-r--r-- | lib/network/tools.pm | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/network/tools.pm b/lib/network/tools.pm index efa38f9..1b49572 100644 --- a/lib/network/tools.pm +++ b/lib/network/tools.pm @@ -189,7 +189,8 @@ sub get_interface_status { my ($intf) = @_; $intf = get_real_interface($intf); my $routes = get_routes(); - return $routes->{$intf}{network}, $routes->{$intf}{network} eq '0.0.0.0' && $routes->{$intf}{gateway}; + return $routes->{$intf}{network}, + $routes->{$intf}{network} eq '0.0.0.0' && ($routes->{$intf}{gateway} || get_interface_ptp_address($intf)); } #- returns (gateway_interface, interface is up, gateway address, dns server address) @@ -243,6 +244,16 @@ sub get_interface_ip_address { $net->{ifcfg}{$interface}{IPADDR}; } +sub get_interface_ptp_address { + my ($interface) = @_; + my ($flags, $_link, $addrs) = `/sbin/ip addr show dev $interface`; + $flags =~ /\bPOINTOPOINT\b/ or return; + my ($peer) = $addrs =~ /peer\s+([\d.]+)/; + return $peer if $peer; + my ($addr) = $addrs =~ /inet\s+([\d.]+)/; + return $addr if $addr; +} + sub host_hex_to_dotted { my ($address) = @_; inet_ntoa(pack('N', unpack('L', pack('H8', $address)))); |