summaryrefslogtreecommitdiff
path: root/lib/Vyatta/Misc.pm
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2010-03-29 16:12:04 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2010-03-29 16:12:04 -0700
commitb9f112c2be89b472e3733cd081777be45b1c6ac7 (patch)
tree606ea60f4d054b414ebb2ced9fd67d972353ff1b /lib/Vyatta/Misc.pm
parentdcafde062d6ac92edbfd0472a31f13e87b6d698c (diff)
downloadvyatta-cfg-b9f112c2be89b472e3733cd081777be45b1c6ac7.tar.gz
vyatta-cfg-b9f112c2be89b472e3733cd081777be45b1c6ac7.zip
Allow reading interface description outside config mode
The Interface() object doesn't work for PPP in operational mode. So split out interface_description routine.
Diffstat (limited to 'lib/Vyatta/Misc.pm')
-rwxr-xr-xlib/Vyatta/Misc.pm15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Vyatta/Misc.pm b/lib/Vyatta/Misc.pm
index 94c0c05..44c0459 100755
--- a/lib/Vyatta/Misc.pm
+++ b/lib/Vyatta/Misc.pm
@@ -26,7 +26,7 @@ require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(getInterfaces getIP getNetAddIP get_sysfs_value
is_address_enabled is_dhcp_enabled
- isIpAddress is_ip_v4_or_v6);
+ isIpAddress is_ip_v4_or_v6 interface_description);
our @EXPORT_OK = qw(generate_dhclient_intf_files
getInterfacesIPadresses
getPortRuleString);
@@ -404,4 +404,17 @@ sub getPortRuleString {
return ( $rule_str, undef );
}
+sub interface_description {
+ my $name = shift;
+
+ open my $ifalias, '<', "/sys/class/net/$name/ifalias"
+ or return;
+
+ my $description = <$ifalias>;
+ close $ifalias;
+ chomp $description if $description;
+
+ return $description;
+}
+
1;