diff options
Diffstat (limited to 'scripts/vyatta-interfaces.pl')
-rwxr-xr-x | scripts/vyatta-interfaces.pl | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index de82edd..dd71d7a 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -195,6 +195,21 @@ sub dhcp_get_interfaces { } } } + + $config->setLevel("interfaces bridge"); + my @brs = $config->listNodes(); + foreach my $br (@brs) { + $config->setLevel("interfaces bridge $br"); + if ($config->exists("address")) { + my @addrs = $config->returnValues("address"); + foreach my $addr (@addrs) { + if (defined $addr && $addr eq "dhcp") { + push @dhcp_intfs, $br; + } + } + } + } + return @dhcp_intfs; } @@ -203,10 +218,20 @@ sub is_dhcp_enabled { my $config = new VyattaConfig; - if ($intf =~ m/(\w+)\.(\d)/) { - $config->setLevel("interfaces ethernet $1 vif $2"); + if ($intf =~ m/^eth/) { + if ($intf =~ m/(\w+)\.(\d+)/) { + $config->setLevel("interfaces ethernet $1 vif $2"); + } else { + $config->setLevel("interfaces ethernet $intf"); + } + } elsif ($intf =~ m/^br/) { + $config->setLevel("interfaces bridge $intf"); } else { - $config->setLevel("interfaces ethernet $intf"); + # + # currently we only support dhcp on ethernet + # and bridge interfaces. + # + return 0; } my @addrs = $config->returnOrigValues("address"); foreach my $addr (@addrs) { @@ -221,11 +246,17 @@ sub is_address_enabled { my $intf = shift; my $config = new VyattaConfig; - - if ($intf =~ m/(\w+)\.(\d)/) { - $config->setLevel("interfaces ethernet $1 vif $2"); + + if ($intf =~ m/^eth/) { + if ($intf =~ m/(\w+)\.(\d+)/) { + $config->setLevel("interfaces ethernet $1 vif $2"); + } else { + $config->setLevel("interfaces ethernet $intf"); + } + } elsif ($intf =~ m/^br/) { + $config->setLevel("interfaces bridge $intf"); } else { - $config->setLevel("interfaces ethernet $intf"); + die "unsupported dhcp interface [$intf]"; } my @addrs = $config->returnOrigValues("address"); foreach my $addr (@addrs) { |