3 # List active and boot-time interfaces
5 require './net-lib.pl';
7 $access{'ifcs'} || &error($text{'ifcs_ecannot'});
8 $allow_add = &can_create_iface() && !$noos_support_add_ifcs;
9 &ui_print_header(undef, $text{'ifcs_title'}, "");
11 # Start tabs for active/boot time interfaces
12 @tabs = ( [ "active", $text{'ifcs_now'}, "list_ifcs.cgi?mode=active" ] );
14 if (!$access{'bootonly'}) {
15 push(@tabs, [ "boot", $text{'ifcs_boot'}, "list_ifcs.cgi?mode=boot" ] );
18 print &ui_tabs_start(\@tabs, "mode", $in{'mode'} || $defmode, 1);
20 # Show interfaces that are currently active
21 @act = &active_interfaces(1);
22 if (!$access{'bootonly'}) {
23 # Table heading and links
24 print &ui_tabs_start_tab("mode", "active");
25 print $text{'ifcs_activedesc'},"<p>\n";
28 if ($access{'ifcs'} >= 2) {
29 print &ui_form_start("delete_aifcs.cgi", "post");
30 push(@links, &select_all_link("d"),
31 &select_invert_link("d") );
32 push(@tds, "width=5 valign=top");
34 push(@tds, "width=20% valign=top", "width=20% valign=top",
35 "width=20% valign=top", "width=20% valign=top");
36 push(@tds, "width=20% valign=top") if (&supports_address6());
37 push(@tds, "width=5% valign=top");
40 "<a href='edit_aifc.cgi?new=1'>$text{'ifcs_add'}</a>");
42 print &ui_links_row(\@links);
43 print &ui_columns_start([ $access{'ifcs'} >= 2 ? ( "" ) : ( ),
48 &supports_address6() ?
49 ( $text{'ifcs_ip6'} ) : ( ),
50 $text{'ifcs_status'} ], 100, 0, \@tds);
52 # Show table of interfaces
53 @act = sort iface_sort @act;
55 next if ($access{'hide'} && # skip hidden
56 (!$a->{'edit'} || !&can_iface($a)));
57 local $mod = &module_for_interface($a);
58 local %minfo = $mod ? &get_module_info($mod->{'module'}) : ( );
60 if ($a->{'edit'} && &can_iface($a) && $a->{'address'}) {
62 "<a href=\"edit_aifc.cgi?idx=$a->{'index'}\">".
63 &html_escape($a->{'fullname'})."</a>");
65 elsif (!$a->{'edit'} && $mod) {
67 "<a href=\"mod_aifc.cgi?idx=$a->{'index'}\">".
68 &html_escape($a->{'fullname'})."</a>");
71 push(@cols, &html_escape($a->{'fullname'}));
73 if ($a->{'virtual'} ne "") {
74 $cols[0] = " ".$cols[0];
76 if (%minfo && $minfo{'dir'} eq 'virtual-server') {
78 $minfo{'desc'} = $text{'index_vmin'};
80 push(@cols, &iface_type($a->{'name'}).
81 ($a->{'virtual'} eq "" ||
82 $mod ? "" : " ($text{'ifcs_virtual'})").
83 (%minfo ? " ($minfo{'desc'})" : "").
84 ($a->{'speed'} ? " ".$a->{'speed'} : ""));
85 push(@cols, &html_escape($a->{'address'}) ||
86 $text{'ifcs_noaddress'});
87 push(@cols, &html_escape($a->{'netmask'}) ||
88 $text{'ifcs_nonetmask'});
89 if (&supports_address6()) {
90 push(@cols, join("<br>\n", map { &html_escape($_) }
91 @{$a->{'address6'}}));
93 push(@cols, $a->{'up'} ? $text{'ifcs_up'} :
94 "<font color=#ff0000>$text{'ifcs_down'}</font>");
95 if ($a->{'edit'} && &can_iface($a)) {
96 print &ui_checked_columns_row(\@cols, \@tds, "d",
100 print &ui_columns_row([ "", @cols ], \@tds);
103 print &ui_columns_end();
104 print &ui_links_row(\@links);
105 if ($access{'ifcs'} >= 2) {
106 print &ui_form_end([ [ "delete", $text{'index_delete1'} ] ]);
108 print &ui_tabs_end_tab();
111 # Show interfaces that get activated at boot
112 print &ui_tabs_start_tab("mode", "boot");
113 print $text{'ifcs_bootdesc'},"<p>\n";
114 print &ui_form_start("delete_bifcs.cgi", "post");
115 @links = ( &select_all_link("b", 1),
116 &select_invert_link("b", 1) );
118 push(@links, "<a href='edit_bifc.cgi?new=1'>$text{'ifcs_add'}</a>");
119 if (defined(&supports_bonding) && &supports_bonding()) {
120 push(@links, "<a href='edit_bifc.cgi?new=1&bond=1'>".
121 "$text{'bonding_add'}</a>");
123 if (defined(&supports_vlans) && &supports_vlans()) {
124 push(@links, "<a href='edit_bifc.cgi?new=1&vlan=1'>".
125 "$text{'vlan_add'}</a>");
128 if ($allow_add && defined(&supports_bridges) && &supports_bridges()) {
129 push(@links, "<a href='edit_bifc.cgi?new=1&bridge=1'>".
130 "$text{'ifcs_badd'}</a>");
132 if ($allow_add && defined(&supports_ranges) && &supports_ranges()) {
133 push(@links, "<a href='edit_range.cgi?new=1'>$text{'ifcs_radd'}</a>");
135 print &ui_links_row(\@links);
136 @tds = ( "width=5 valign=top", "width=20% valign=top", "width=20% valign=top",
137 "width=20% valign=top", "width=20% valign=top" );
138 push(@tds, "width=20% valign=top xxx") if (&supports_address6());
139 push(@tds, "width=5% valign=top");
140 print &ui_columns_start([ "",
145 &supports_address6() ? ( $text{'ifcs_ip6'} ) : ( ),
146 $text{'ifcs_act'} ], 100, 0, \@tds);
148 @boot = &boot_interfaces();
149 @boot = sort iface_sort @boot;
151 local $can = $a->{'edit'} && &can_iface($a);
152 next if ($access{'hide'} && !$can); # skip hidden
155 if ($a->{'range'} ne "") {
156 # A range of addresses
157 local $rng = &text('ifcs_range', $a->{'range'});
158 if ($can && ($gconfig{'os_type'} eq 'debian-linux') && &has_command("")) {
159 $link = "edit_bifc.cgi?idx=$a->{'index'}";
160 if(&iface_type($a->{'name'}) eq 'Bonded'){
161 $link = $link . "&bond=1";
162 } elsif (&iface_type($a->{'name'}) =~ /^(.*) (VLAN)$/) {
163 $link = $link . "&vlan=1";
165 push(@cols, "<a href='$link'" . &html_escape($a->{'fullname'})."</a>");
168 $link = "edit_bifc.cgi?idx=$a->{'index'}";
169 push(@cols, "<a href='$link'" . &html_escape($a->{'fullname'})."</a>");
172 push(@cols, &html_escape($rng));
174 push(@cols, &iface_type($a->{'name'}));
175 push(@cols, "$a->{'start'} - $a->{'end'}");
176 if (&supports_address6()) {
177 # IPv6 not possible for ranges
180 splice(@mytds, 3, 2, "colspan=2 width=40% valign=top");
183 # A normal single interface
184 local $mod = &module_for_interface($a);
185 local %minfo = $mod ? &get_module_info($mod->{'module'}) : ( );
187 $link = "edit_bifc.cgi?idx=$a->{'index'}";
188 if(&iface_type($a->{'name'}) eq 'Bonded'){
189 $link = $link . "&bond=1";
190 } elsif (&iface_type($a->{'name'}) =~ /^(.*) (VLAN)$/) {
191 $link = $link . "&vlan=1";
193 push(@cols, "<a href='$link'>"
194 .&html_escape($a->{'fullname'})."</a>");
197 push(@cols, &html_escape($a->{'fullname'}));
199 if ($a->{'virtual'} ne "") {
200 $cols[0] = " ".$cols[0];
202 if (%minfo && $minfo{'dir'} eq 'virtual-server') {
204 $minfo{'desc'} = $text{'index_vmin'};
206 push(@cols, &iface_type($a->{'name'}).
207 ($a->{'virtual'} eq "" ||
208 $mod ? "" : " ($text{'ifcs_virtual'})").
209 (%minfo ? " ($minfo{'desc'})" : ""));
210 push(@cols, $a->{'bootp'} ? $text{'ifcs_bootp'} :
211 $a->{'dhcp'} ? $text{'ifcs_dhcp'} :
212 $a->{'address'} ? &html_escape($a->{'address'}) :
213 $text{'ifcs_noaddress'});
214 push(@cols, $a->{'bootp'} ? $text{'ifcs_bootp'} :
215 $a->{'dhcp'} ? $text{'ifcs_dhcp'} :
216 $a->{'netmask'} ? &html_escape($a->{'netmask'}) :
217 $text{'ifcs_nonetmask'});
218 if (&supports_address6()) {
219 push(@cols, $a->{'auto6'} ? $text{'ifcs_auto6'} :
220 join("<br>\n", map { &html_escape($_) }
221 @{$a->{'address6'}}));
224 push(@cols, $a->{'up'} ? $text{'yes'} : $text{'no'});
226 print &ui_checked_columns_row(\@cols, \@mytds, "b",
230 print &ui_columns_row([ "", @cols ], \@tds);
233 print &ui_columns_end();
234 print &ui_links_row(\@links);
235 print &ui_form_end([ [ "delete", $text{'index_delete2'} ],
236 [ "deleteapply", $text{'index_delete3'} ],
238 [ "apply", $text{'index_apply2'} ] ]);
239 print &ui_tabs_end_tab();
241 print &ui_tabs_end(1);
243 &ui_print_footer("", $text{'index_return'});
247 return $a->{'name'} cmp $b->{'name'} if ($a->{'name'} cmp $b->{'name'});
248 return $a->{'virtual'} eq '' ? -1 :
249 $b->{'virtual'} eq '' ? 1 : $a->{'virtual'} <=> $b->{'virtual'};