# linux-lib.pl
# Active interface functions for all flavours of linux
-# active_interfaces()
+# active_interfaces([include-no-address])
# Returns a list of currently ifconfig'd interfaces
sub active_interfaces
{
+local ($empty) = @_;
local(@rv, @lines, $l);
&open_execute_command(IFC, "LC_ALL='' LANG='' ifconfig -a", 1, 1);
while(<IFC>) {
$l =~ /^(\S+)/; $ifc{'fullname'} = $1;
if ($l =~ /^(\S+):(\d+)/) { $ifc{'virtual'} = $2; }
if ($l =~ /inet addr:(\S+)/) { $ifc{'address'} = $1; }
- elsif (!$_[0]) { next; }
+ elsif (!$empty) { next; }
if ($l =~ /Mask:(\S+)/) { $ifc{'netmask'} = $1; }
if ($l =~ /Bcast:(\S+)/) { $ifc{'broadcast'} = $1; }
if ($l =~ /HWaddr (\S+)/) { $ifc{'ether'} = $1; }
print &ui_tabs_start(\@tabs, "mode", $in{'mode'} || $defmode, 1);
# Show interfaces that are currently active
-@act = &active_interfaces();
+@act = &active_interfaces(1);
if (!$access{'bootonly'}) {
# Table heading and links
print &ui_tabs_start_tab("mode", "active");
local $mod = &module_for_interface($a);
local %minfo = $mod ? &get_module_info($mod->{'module'}) : ( );
local @cols;
- if ($a->{'edit'} && &can_iface($a)) {
+ if ($a->{'edit'} && &can_iface($a) && $a->{'address'}) {
push(@cols,
"<a href=\"edit_aifc.cgi?idx=$a->{'index'}\">".
&html_escape($a->{'fullname'})."</a>");
$mod ? "" : " ($text{'ifcs_virtual'})").
(%minfo ? " ($minfo{'desc'})" : "").
($a->{'speed'} ? " ".$a->{'speed'} : ""));
- push(@cols, &html_escape($a->{'address'}));
- push(@cols, &html_escape($a->{'netmask'}));
+ push(@cols, &html_escape($a->{'address'}) ||
+ $text{'ifcs_noaddress'});
+ push(@cols, &html_escape($a->{'netmask'}) ||
+ $text{'ifcs_nonetmask'});
if (&supports_address6()) {
push(@cols, join("<br>\n", map { &html_escape($_) }
@{$a->{'address6'}}));
$a->{'dhcp'} ? $text{'ifcs_dhcp'} :
$a->{'address'} ? &html_escape($a->{'address'}) :
$text{'ifcs_noaddress'});
- push(@cols, $a->{'netmask'} ? &html_escape($a->{'netmask'}) :
- !$a->{'address'} ? $text{'ifcs_nonetmask'} :
- $text{'ifcs_auto'});
+ push(@cols, $a->{'bootp'} ? $text{'ifcs_bootp'} :
+ $a->{'dhcp'} ? $text{'ifcs_dhcp'} :
+ $a->{'netmask'} ? &html_escape($a->{'netmask'}) :
+ $text{'ifcs_nonetmask'});
if (&supports_address6()) {
push(@cols, $a->{'auto6'} ? $text{'ifcs_auto6'} :
join("<br>\n", map { &html_escape($_) }