summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlib/Vyatta/Interface.pm8
-rwxr-xr-xlib/Vyatta/Misc.pm15
2 files changed, 15 insertions, 8 deletions
diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm
index b7473dc..432fe33 100755
--- a/lib/Vyatta/Interface.pm
+++ b/lib/Vyatta/Interface.pm
@@ -352,13 +352,7 @@ sub running {
sub description {
my $self = shift;
- open my $ifalias, '<', "/sys/class/net/$self->{name}/ifalias"
- or return;
- my $description = <$ifalias>;
- close $ifalias;
- chomp $description if $description;
-
- return $description;
+ return interface_description($self->{name});
}
1;
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;