summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2010-02-09 20:59:33 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2010-02-09 20:59:33 -0800
commit1330126be80eb0056a21dae7b0763f2b981e6e9d (patch)
treeacf6b2e8a339af0a0c5e64e4c82f71d8a31f21e8
parent242d3138f5ab34de27a12ad8605aba3f58526afb (diff)
downloadvyatta-cfg-1330126be80eb0056a21dae7b0763f2b981e6e9d.tar.gz
vyatta-cfg-1330126be80eb0056a21dae7b0763f2b981e6e9d.zip
Add preliminary support for pppoe devices
QoS needs to be able to convert from device name back to path in the config hierarchy. This is is a first step.
-rwxr-xr-xlib/Vyatta/Interface.pm51
1 files changed, 43 insertions, 8 deletions
diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm
index 513f686..1231786 100755
--- a/lib/Vyatta/Interface.pm
+++ b/lib/Vyatta/Interface.pm
@@ -24,12 +24,12 @@ use warnings;
use Vyatta::Config;
use Vyatta::Misc;
use base 'Exporter';
-our @EXPORT = qw(IFF_UP IFF_BROADCAST IFF_DEBUG IFF_LOOPBACK
+our @EXPORT = qw(IFF_UP IFF_BROADCAST IFF_DEBUG IFF_LOOPBACK
IFF_POINTOPOINT IFF_RUNNING IFF_NOARP
IFF_PROMISC IFF_MULTICAST);
-use constant {
+use constant {
IFF_UP => 0x1, # interface is up
IFF_BROADCAST => 0x2, # broadcast address valid
IFF_DEBUG => 0x4, # turn on debugging
@@ -58,7 +58,7 @@ use constant {
my %net_prefix = (
'^adsl[\d]+$' => { path => 'adsl',
vif => 'vif', },
- '^bond[\d]+$' => { path => 'bonding',
+ '^bond[\d]+$' => { path => 'bonding',
vif => 'vif', },
'^br[\d]+$' => { path => 'bridge',
vif => 'vif' },
@@ -69,7 +69,7 @@ my %net_prefix = (
vif => 'vif', },
'^vtun[\d]+$' => { path => 'openvpn' },
'^wan[\d]+$' => { path => 'serial',
- vif => ( 'cisco-hdlc vif', 'ppp vif',
+ vif => ( 'cisco-hdlc vif', 'ppp vif',
'frame-relay vif' ), },
'^tun[\d]+$' => { path => 'tunnel' },
'^wlm[\d]+$' => { path => 'wireless-modem' },
@@ -78,12 +78,33 @@ my %net_prefix = (
'^wlan[\d]+$' => { path => 'wireless', vif => 'vif' },
);
-# get list of interface types
+# get list of interface types (missing PPP)
sub interface_types {
my @types = map { $net_prefix{$_}{path} } keys %net_prefix;
return @types;
}
+# Read pppoe config to fine associated ethernet for ppp device
+sub find_pppoe {
+ my $n = shift;
+ my $eth;
+
+ open (my $pppoe, '<', "/etc/ppp/peers/pppoe$n")
+ or return; # no such device
+
+ while (<$pppoe>) {
+ chomp;
+ # looking for line like:
+ # pty "/usr/sbin/pppoe -m 1412 -I eth1"
+ next unless /^pty .*(eth\d+)"/;
+ $eth = $1;
+ last;
+ }
+ close($pppoe);
+
+ return $eth;
+}
+
# new interface description object
sub new {
my $that = shift;
@@ -116,7 +137,7 @@ sub new {
my $path = "interfaces $type $dev";
$path .= " $vifpath $vif" if $vif;
- my $self = {
+ my $self = {
name => $name,
type => $type,
path => $path,
@@ -128,6 +149,22 @@ 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
}
@@ -202,8 +239,6 @@ sub address {
return Vyatta::Misc::getIP($self->{name}, $type);
}
-# return
-
sub exists {
my $self = shift;