From e33736282961ba3e277fa03d6cf843556b7c8b33 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 29 Jul 2009 15:17:10 -0700 Subject: Add hw_address method for use in bonding Bonding management needs easy way to find hardware address. Related to Bug 4758 (cherry picked from commit a4404bfb3c4243967a4434707213430d5c4df58e) --- lib/Vyatta/Interface.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/Vyatta') diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm index 96429c0..97ef7f7 100755 --- a/lib/Vyatta/Interface.pm +++ b/lib/Vyatta/Interface.pm @@ -222,6 +222,18 @@ sub flags { return hex($val); } +sub hw_address { + my $self = shift; + + open my $addrf, '<', "/sys/class/net/$self->{name}/address" + or return; + my $address = <$addrf>; + close $addrf; + + chomp $address if $address; + return $address; +} + sub is_broadcast { my $self = shift; return $self->flags() & IFF_BROADCAST; -- cgit v1.2.3