diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/Vyatta/Interface.pm | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm index 200cad8..a11b7c2 100755 --- a/lib/Vyatta/Interface.pm +++ b/lib/Vyatta/Interface.pm @@ -78,7 +78,7 @@ my %net_prefix = ( '^wlan[\d]+$' => { path => 'wireless', vif => 'vif' }, ); -# get list of interface types (missing PPP) +# get list of interface types (only used in usage function) sub interface_types { my @types = map { $net_prefix{$_}{path} } keys %net_prefix; return @types; @@ -86,10 +86,10 @@ sub interface_types { # Read pppoe config to fine associated ethernet for ppp device sub find_pppoe { - my $n = shift; + my $dev = shift; my $eth; - open (my $pppoe, '<', "/etc/ppp/peers/pppoe$n") + open (my $pppoe, '<', "/etc/ppp/peers/$dev") or return; # no such device while (<$pppoe>) { @@ -115,6 +115,23 @@ sub new { # need argument to constructor return unless $name; + # Special case for pppoe devices + if ($name =~ /^pppoe(\d+)/) { + my $n = $1; + my $eth = find_pppoe($name); + + return unless $eth; + + my $self = { + name => $name, + type => 'pppoe', + path => "interfaces ethernet $eth pppoe $n", + dev => $name, + }; + bless $self, $class; + return $self; + } + # Strip off vif from name if ( $name =~ m/(\w+)\.(\d+)/ ) { $dev = $1; @@ -149,24 +166,6 @@ sub new { return $self; } - # Special case for pppoe - if ($dev =~ /^ppp(\d+)/) { - my $n = $1; - my $eth = find_pppoe($n); - - if ($eth) { - my $self = { - name => $name, - type => 'pppoe', - path => "interfaces ethernet $eth pppoe $n", - dev => $dev, - vif => $vif, - }; - bless $self, $class; - return $self; - } - } - return; # nothing } |