Handle hostnames with upper-case letters
[webmin.git] / status / iface-monitor.pl
1 # iface-monitor.pl
2 # Check if a network interface is up or down
3
4 sub get_iface_status
5 {
6 return { 'up' => -1 } if (!&foreign_check("net"));
7 &foreign_require("net", "net-lib.pl");
8 local @act = &net::active_interfaces();
9 local $a;
10 foreach $a (@act) {
11         if ($a->{'fullname'} eq $_[0]->{'iface'} &&
12             $a->{'up'}) {
13                 return { 'up' => 1 };
14                 }
15         }
16 return { 'up' => 0 };
17 }
18
19 sub show_iface_dialog
20 {
21 &foreign_require("net", "net-lib.pl");
22 local %done;
23 local @ifaces = grep { !$done{$_->{'fullname'}}++ }
24                   sort { $a->{'fullname'} cmp $b->{'fullname'} }
25                      (&net::boot_interfaces(), &net::active_interfaces());
26 print &ui_table_row($text{'iface_iface'},
27         &ui_select("iface", $_[0]->{'iface'},
28            [ map { [ $_->{'fullname'},
29                      $_->{'fullname'}.
30                      " (".&net::iface_type($_->{'fullname'}).")" ] } @ifaces]));
31 }
32
33 sub parse_iface_dialog
34 {
35 &depends_check($_[0], "net");
36 $_[0]->{'iface'} = $in{'iface'};
37 }
38