summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohit Mehta <mohit@vyatta.com>2010-12-01 12:27:32 -0800
committerMohit Mehta <mohit@vyatta.com>2010-12-01 12:27:32 -0800
commit6af83bb1efa5cb5208d1efa3444e2d340f7b7ca8 (patch)
tree4c6b2906b196dd5f3faf468272ff4544c001be0b
parentd31fe9f9dab6e5532918037b7b699eaff1196f06 (diff)
downloadvyatta-cfg-6af83bb1efa5cb5208d1efa3444e2d340f7b7ca8.tar.gz
vyatta-cfg-6af83bb1efa5cb5208d1efa3444e2d340f7b7ca8.zip
move general code for returning a hash of ipaddrs=>interface from Webproxy.pm
-rwxr-xr-xlib/Vyatta/Misc.pm18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/Vyatta/Misc.pm b/lib/Vyatta/Misc.pm
index 5373f7f..3e109f2 100755
--- a/lib/Vyatta/Misc.pm
+++ b/lib/Vyatta/Misc.pm
@@ -25,7 +25,7 @@ use strict;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(getInterfaces getIP getNetAddIP get_sysfs_value
- is_address_enabled is_dhcp_enabled
+ is_address_enabled is_dhcp_enabled get_ipaddr_intf_hash
isIpAddress is_ip_v4_or_v6 interface_description);
our @EXPORT_OK = qw(generate_dhclient_intf_files
getInterfacesIPadresses
@@ -35,6 +35,22 @@ use Vyatta::Config;
use Vyatta::Interface;
use NetAddr::IP;
+#
+# returns a hash of ipaddrs => interface
+#
+sub get_ipaddr_intf_hash {
+ my %config_ipaddrs = ();
+ my @lines = `ip addr show | grep 'inet '`;
+ chomp @lines;
+ foreach my $line (@lines) {
+ if ($line =~ /inet\s+([0-9.]+)\/.*\s([\w.]+)$/) {
+ $config_ipaddrs{$1} = $2;
+ }
+ }
+ return \%config_ipaddrs;
+}
+
+
sub get_sysfs_value {
my ( $intf, $name ) = @_;