summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@vyatta.com>2010-03-24 17:13:11 -0700
committerStig Thormodsrud <stig@vyatta.com>2010-03-24 17:13:11 -0700
commita4b59a1aaa10c4f78b5d854aa884decb17b8aea9 (patch)
treed556d32de2cfae95e1be161b005ce4cf89c8849a /lib
parent7a9f88c587187ece112e47d7c4d077e44a6afe8a (diff)
parent327ea4113cea590f4d2c33bb430421158ebf51fa (diff)
downloadvyatta-cfg-a4b59a1aaa10c4f78b5d854aa884decb17b8aea9.tar.gz
vyatta-cfg-a4b59a1aaa10c4f78b5d854aa884decb17b8aea9.zip
Merge branch 'larkspur' of http://git.vyatta.com/vyatta-cfg into larkspur
Diffstat (limited to 'lib')
-rwxr-xr-xlib/Vyatta/ConfigLoad.pm3
-rwxr-xr-xlib/Vyatta/Interface.pm56
-rwxr-xr-xlib/Vyatta/Misc.pm10
3 files changed, 46 insertions, 23 deletions
diff --git a/lib/Vyatta/ConfigLoad.pm b/lib/Vyatta/ConfigLoad.pm
index 44c1089..627b361 100755
--- a/lib/Vyatta/ConfigLoad.pm
+++ b/lib/Vyatta/ConfigLoad.pm
@@ -315,7 +315,8 @@ sub findSetNodes {
$active_cfg->setLevel(join ' ', @active_path);
my @active_nodes = $active_cfg->listOrigNodes();
my %active_hash = map { $_ => 1 } @active_nodes;
- if (defined($active_hash{'node.val'})) {
+ my $nref = $active_cfg->parseTmplAll(join ' ', @active_path);
+ if (defined($nref->{type}) and !defined($nref->{tag})) {
# we are at a leaf node.
findSetValues($new_ref, \@active_path);
return;
diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm
index 19dff4a..b7473dc 100755
--- a/lib/Vyatta/Interface.pm
+++ b/lib/Vyatta/Interface.pm
@@ -84,25 +84,44 @@ sub interface_types {
return @types;
}
-# Read pppoe config to fine associated ethernet for ppp device
-sub find_pppoe {
+# Read ppp config to fine associated interface for ppp device
+sub _ppp_intf {
my $dev = shift;
- my $eth;
+ my $intf;
- open (my $pppoe, '<', "/etc/ppp/peers/$dev")
+ open (my $ppp, '<', "/etc/ppp/peers/$dev")
or return; # no such device
- while (<$pppoe>) {
+ while (<$ppp>) {
chomp;
# looking for line like:
# pty "/usr/sbin/pppoe -m 1412 -I eth1"
- next unless /^pty .*(eth\d+)"/;
- $eth = $1;
+ next unless /^pty\s.*-I\s*(\w+)"/;
+ $intf = $1;
last;
}
- close($pppoe);
+ close $ppp;
- return $eth;
+ return $intf;
+}
+
+# Go path hunting to find ppp device
+sub _ppp_path {
+ my ($intf, $type, $id) = @_;
+ my $config = new Vyatta::Config;
+
+ if ($type eq 'pppoe') {
+ my $path = "interfaces ethernet $intf pppoe $id";
+ return $path if $config->exists($path);
+ }
+
+ my $adsl = "interfaces adsl $intf pvc";
+ foreach my $pvc ($config->listNodes($adsl)) {
+ my $path = "$adsl $pvc $type $id";
+ return $path if $config->exists($path);
+ }
+
+ return;
}
# new interface description object
@@ -115,17 +134,20 @@ 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);
+ # Special case for ppp devices
+ if ($name =~ /^(pppo[ae])(\d+)/) {
+ my $type = $1;
+ my $id = $2;
+ my $intf = _ppp_intf($name);
+ return unless $intf;
- return unless $eth;
+ my $path = _ppp_path($intf, $type, $id);
+ return unless $path;
my $self = {
name => $name,
- type => 'pppoe',
- path => "interfaces ethernet $eth pppoe $n",
+ type => $type,
+ path => $path,
dev => $name,
};
bless $self, $class;
@@ -234,7 +256,7 @@ sub using_dhcp {
sub bridge_grp {
my $self = shift;
my $config = new Vyatta::Config;
-
+
$config->setLevel( $self->{path} );
return $config->returnValue("bridge-group bridge");
}
diff --git a/lib/Vyatta/Misc.pm b/lib/Vyatta/Misc.pm
index d666ea9..94c0c05 100755
--- a/lib/Vyatta/Misc.pm
+++ b/lib/Vyatta/Misc.pm
@@ -62,7 +62,7 @@ sub is_dhcp_enabled {
return 1 if ( $addr && $addr eq "dhcp" );
}
- # return undef
+ return;
}
# check if any non-dhcp addresses configured
@@ -77,7 +77,7 @@ sub is_address_enabled {
return 1 if ( $addr && $addr ne 'dhcp' );
}
- # return undefined (ie false)
+ return;
}
# return dhclient related files for interface
@@ -186,7 +186,7 @@ sub getNetAddrIP {
return $ip;
}
- # default return of undefined (ie false)
+ return;
}
sub is_ip_v4_or_v6 {
@@ -207,7 +207,7 @@ sub is_ip_v4_or_v6 {
return 6;
}
- # default return of undefined (ie false)
+ return;
}
sub isIpAddress {
@@ -269,7 +269,7 @@ sub isIPinInterfaces {
return 1 if ( is_ip_in_list( $ip_addr, getIP($name) ) );
}
- # false (undef)
+ return; # false (undef)
}
sub isClusteringEnabled {