Project

General

Profile

Download (17.9 KB) Statistics
| Branch: | Tag: | Revision:
1 ef88e1e1 Renato Botelho
<?php
2 5b237745 Scott Ullrich
/*
3
	interfaces_assign.php
4
	part of m0n0wall (http://m0n0.ch/wall)
5
	Written by Jim McBeath based on existing m0n0wall files
6 ef88e1e1 Renato Botelho
7 94a77286 Scott Ullrich
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
8 5b237745 Scott Ullrich
	All rights reserved.
9 ef88e1e1 Renato Botelho
10 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12 ef88e1e1 Renato Botelho
13 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15 ef88e1e1 Renato Botelho
16 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19 ef88e1e1 Renato Botelho
20 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31 7ac5a4cb Scott Ullrich
/*
32
	pfSense_BUILDER_BINARIES:	/bin/rm
33
	pfSense_MODULE:	interfaces
34
*/
35 5b237745 Scott Ullrich
36 6b07c15a Matthew Grooms
##|+PRIV
37
##|*IDENT=page-interfaces-assignnetworkports
38
##|*NAME=Interfaces: Assign network ports page
39
##|*DESCR=Allow access to the 'Interfaces: Assign network ports' page.
40
##|*MATCH=interfaces_assign.php*
41
##|-PRIV
42
43 8cc6876f groo
$pgtitle = array(gettext("Interfaces"),gettext("Assign network ports"));
44 b32dd0a6 jim-p
$shortcut_section = "interfaces";
45 af1e2031 jim-p
46 5b237745 Scott Ullrich
require("guiconfig.inc");
47 5a7d827b sullrich
require("functions.inc");
48
require("filter.inc");
49
require("shaper.inc");
50
require("ipsec.inc");
51
require("vpn.inc");
52 4c86a165 sullrich
require("captiveportal.inc");
53 6e6233d0 sullrich
require("rrd.inc");
54 5b237745 Scott Ullrich
55
/*
56
	In this file, "port" refers to the physical port name,
57
	while "interface" refers to LAN, WAN, or OPTn.
58
*/
59
60
/* get list without VLAN interfaces */
61
$portlist = get_interface_list();
62
63 7c53bc7b Erik Fonnesbeck
/* add wireless clone interfaces */
64
if (is_array($config['wireless']['clone']) && count($config['wireless']['clone'])) {
65
	foreach ($config['wireless']['clone'] as $clone) {
66
		$portlist[$clone['cloneif']] = $clone;
67
		$portlist[$clone['cloneif']]['iswlclone'] = true;
68
	}
69
}
70
71 5b237745 Scott Ullrich
/* add VLAN interfaces */
72
if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
73
	foreach ($config['vlans']['vlan'] as $vlan) {
74 d59557dc Ermal Luçi
		$portlist[$vlan['vlanif']] = $vlan;
75
		$portlist[$vlan['vlanif']]['isvlan'] = true;
76 5b237745 Scott Ullrich
	}
77
}
78
79 38738505 Ermal Luçi
/* add Bridge interfaces */
80 b47c94bd Ermal Luçi
if (is_array($config['bridges']['bridged']) && count($config['bridges']['bridged'])) {
81 ef88e1e1 Renato Botelho
	foreach ($config['bridges']['bridged'] as $bridge) {
82
		$portlist[$bridge['bridgeif']] = $bridge;
83
		$portlist[$bridge['bridgeif']]['isbridge'] = true;
84
	}
85 38738505 Ermal Luçi
}
86
87
/* add GIF interfaces */
88
if (is_array($config['gifs']['gif']) && count($config['gifs']['gif'])) {
89 ef88e1e1 Renato Botelho
	foreach ($config['gifs']['gif'] as $gif) {
90
		$portlist[$gif['gifif']] = $gif;
91
		$portlist[$gif['gifif']]['isgif'] = true;
92
	}
93 38738505 Ermal Luçi
}
94
95
/* add GRE interfaces */
96
if (is_array($config['gres']['gre']) && count($config['gres']['gre'])) {
97 ef88e1e1 Renato Botelho
	foreach ($config['gres']['gre'] as $gre) {
98
		$portlist[$gre['greif']] = $gre;
99
		$portlist[$gre['greif']]['isgre'] = true;
100
	}
101 38738505 Ermal Luçi
}
102
103 dbdd08af Ermal Luçi
/* add LAGG interfaces */
104 c720925c Ermal Luçi
if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) {
105 ef88e1e1 Renato Botelho
	foreach ($config['laggs']['lagg'] as $lagg) {
106
		$portlist[$lagg['laggif']] = $lagg;
107
		$portlist[$lagg['laggif']]['islagg'] = true;
108 dbdd08af Ermal Luçi
		/* LAGG members cannot be assigned */
109
		$lagifs = explode(',', $lagg['members']);
110
		foreach ($lagifs as $lagif)
111
			if (isset($portlist[$lagif]))
112
				unset($portlist[$lagif]);
113 ef88e1e1 Renato Botelho
	}
114 c720925c Ermal Luçi
}
115
116 265188ea Ermal Lu?i
/* add QinQ interfaces */
117
if (is_array($config['qinqs']['qinqentry']) && count($config['qinqs']['qinqentry'])) {
118 ef88e1e1 Renato Botelho
	foreach ($config['qinqs']['qinqentry'] as $qinq) {
119
		$portlist["vlan{$qinq['tag']}"]['descr'] = "VLAN {$qinq['tag']}";
120
		$portlist["vlan{$qinq['tag']}"]['isqinq'] = true;
121
		/* QinQ members */
122
		$qinqifs = explode(' ', $qinq['members']);
123
		foreach ($qinqifs as $qinqif) {
124
			$portlist["vlan{$qinq['tag']}_{$qinqif}"]['descr'] = "QinQ {$qinqif}";
125
			$portlist["vlan{$qinq['tag']}_{$qinqif}"]['isqinq'] = true;
126
		}
127
	}
128 265188ea Ermal Lu?i
}
129 c720925c Ermal Luçi
130 860c4e80 Chris Buechler
/* add PPP interfaces */
131
if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) {
132 611ae852 Ermal
	foreach ($config['ppps']['ppp'] as $pppid => $ppp) {
133 99c26d44 gnhb
		$portname = $ppp['if'];
134 860c4e80 Chris Buechler
		$portlist[$portname] = $ppp;
135
		$portlist[$portname]['isppp'] = true;
136 3f2ef8d7 gnhb
		$ports_base = basename($ppp['ports']);
137 42809b4a gnhb
		if (isset($ppp['descr']))
138 99c26d44 gnhb
			$portlist[$portname]['descr'] = strtoupper($ppp['if']). "({$ports_base}) - {$ppp['descr']}";
139 00b702cc gnhb
		else if (isset($ppp['username']))
140 99c26d44 gnhb
			$portlist[$portname]['descr'] = strtoupper($ppp['if']). "({$ports_base}) - {$ppp['username']}";
141 42809b4a gnhb
		else
142 99c26d44 gnhb
			$portlist[$portname]['descr'] = strtoupper($ppp['if']). "({$ports_base})";
143 860c4e80 Chris Buechler
	}
144
}
145
146 144fbff2 jim-p
$ovpn_descrs = array();
147
if (is_array($config['openvpn'])) {
148
	if (is_array($config['openvpn']['openvpn-server']))
149
		foreach ($config['openvpn']['openvpn-server'] as $s)
150
			$ovpn_descrs[$s['vpnid']] = $s['description'];
151
	if (is_array($config['openvpn']['openvpn-client']))
152
		foreach ($config['openvpn']['openvpn-client'] as $c)
153
			$ovpn_descrs[$c['vpnid']] = $c['description'];
154
}
155
156 d59557dc Ermal Luçi
if ($_POST['apply']) {
157 ca4acbcd Scott Ullrich
	if (file_exists("/var/run/interface_mismatch_reboot_needed")) {
158 eef52225 jim-p
		system_reboot();
159 ca4acbcd Scott Ullrich
		$rebootingnow = true;
160
	} else {
161 d59557dc Ermal Luçi
		write_config();
162
163
		$retval = 0;
164
		$retval = filter_configure();
165 0027de0a Ermal Lu?i
		$savemsg = get_std_save_message($retval);
166 d59557dc Ermal Luçi
167
		if (stristr($retval, "error") <> true)
168
			$savemsg = get_std_save_message($retval);
169
		else
170
			$savemsg = $retval;
171
	}
172
173
} else if ($_POST) {
174 5b237745 Scott Ullrich
175
	unset($input_errors);
176
177
	/* input validation */
178
179
	/* Build a list of the port names so we can see how the interfaces map */
180
	$portifmap = array();
181
	foreach ($portlist as $portname => $portinfo)
182
		$portifmap[$portname] = array();
183
184
	/* Go through the list of ports selected by the user,
185 ef88e1e1 Renato Botelho
	build a list of port-to-interface mappings in portifmap */
186 5b237745 Scott Ullrich
	foreach ($_POST as $ifname => $ifport) {
187
		if (($ifname == 'lan') || ($ifname == 'wan') || (substr($ifname, 0, 3) == 'opt'))
188
			$portifmap[$ifport][] = strtoupper($ifname);
189
	}
190
191
	/* Deliver error message for any port with more than one assignment */
192
	foreach ($portifmap as $portname => $ifnames) {
193
		if (count($ifnames) > 1) {
194 ddc55e12 Erik Fonnesbeck
			$errstr = sprintf(gettext('Port %1$s '.
195
				' was assigned to %2$s' .
196
				' interfaces:'), $portname, count($ifnames));
197 ef88e1e1 Renato Botelho
198 5b237745 Scott Ullrich
			foreach ($portifmap[$portname] as $ifn)
199
				$errstr .= " " . $ifn;
200 ef88e1e1 Renato Botelho
201 5b237745 Scott Ullrich
			$input_errors[] = $errstr;
202 95540233 Renato Botelho
		} else if (count($ifnames) == 1 && preg_match('/^bridge[0-9]/', $portname) && is_array($config['bridges']['bridged']) && count($config['bridges']['bridged'])) {
203
			foreach ($config['bridges']['bridged'] as $bridge) {
204
				if ($bridge['bridgeif'] != $portname)
205
					continue;
206
207
				$members = explode(",", strtoupper($bridge['members']));
208
				foreach ($members as $member) {
209
					if ($member == $ifnames[0]) {
210
						$input_errors[] = sprintf(gettext("You cannot set port %s to interface %s because this interface is a member of %s."), $portname, $member, $portname);
211
						break;
212
					}
213
				}
214
			}
215 5b237745 Scott Ullrich
		}
216
	}
217
218 66bcba1b Ermal
	if (is_array($config['vlans']['vlan'])) {
219
		foreach ($config['vlans']['vlan'] as $vlan) {
220
			if (does_interface_exist($vlan['if']) == false)
221
				$input_errors[] = "Vlan parent interface {$vlan['if']} does not exist anymore so vlan id {$vlan['tag']} cannot be created please fix the issue before continuing.";
222
		}
223
	}
224 5b237745 Scott Ullrich
225
	if (!$input_errors) {
226
		/* No errors detected, so update the config */
227
		foreach ($_POST as $ifname => $ifport) {
228 ef88e1e1 Renato Botelho
229
			if (($ifname == 'lan') || ($ifname == 'wan') || (substr($ifname, 0, 3) == 'opt')) {
230
231 5b237745 Scott Ullrich
				if (!is_array($ifport)) {
232 e7bfa231 Ermal Lu?i
					$reloadif = false;
233 44088ce8 Ermal Lu?i
					if (!empty($config['interfaces'][$ifname]['if']) && $config['interfaces'][$ifname]['if'] <> $ifport) {
234
						interface_bring_down($ifname);
235 e7bfa231 Ermal Lu?i
						/* Mark this to be reconfigured in any case. */
236
						$reloadif = true;
237 44088ce8 Ermal Lu?i
					}
238 5b237745 Scott Ullrich
					$config['interfaces'][$ifname]['if'] = $ifport;
239 99c26d44 gnhb
					if (isset($portlist[$ifport]['isppp']))
240 c86e8f76 gnhb
						$config['interfaces'][$ifname]['ipaddr'] = $portlist[$ifport]['type'];
241 ef88e1e1 Renato Botelho
242 5b237745 Scott Ullrich
					/* check for wireless interfaces, set or clear ['wireless'] */
243 94a77286 Scott Ullrich
					if (preg_match($g['wireless_regex'], $ifport)) {
244 5b237745 Scott Ullrich
						if (!is_array($config['interfaces'][$ifname]['wireless']))
245
							$config['interfaces'][$ifname]['wireless'] = array();
246
					} else {
247
						unset($config['interfaces'][$ifname]['wireless']);
248
					}
249 ef88e1e1 Renato Botelho
250 d59557dc Ermal Luçi
					/* make sure there is a descr for all interfaces */
251
					if (!isset($config['interfaces'][$ifname]['descr']))
252
						$config['interfaces'][$ifname]['descr'] = strtoupper($ifname);
253 ef88e1e1 Renato Botelho
254 b13efb03 Erik Fonnesbeck
					if ($reloadif == true) {
255
						if (preg_match($g['wireless_regex'], $ifport))
256
							interface_sync_wireless_clones($config['interfaces'][$ifname], false);
257 e7bfa231 Ermal Lu?i
						/* Reload all for the interface. */
258
						interface_configure($ifname, true);
259 b13efb03 Erik Fonnesbeck
					}
260 5b237745 Scott Ullrich
				}
261
			}
262
		}
263 ef88e1e1 Renato Botelho
264 5b237745 Scott Ullrich
		write_config();
265 ef88e1e1 Renato Botelho
266 6e6233d0 sullrich
		enable_rrd_graphing();
267 5b237745 Scott Ullrich
	}
268
}
269
270
if ($_GET['act'] == "del") {
271
	$id = $_GET['id'];
272 3c43a344 Scott Ullrich
273 48f23632 Ermal
	if (link_interface_to_group($id))
274
		$input_errors[] = gettext("The interface is part of a group. Please remove it from the group to continue");
275
	else if (link_interface_to_bridge($id))
276 8cc6876f groo
		$input_errors[] = gettext("The interface is part of a bridge. Please remove it from the bridge to continue");
277 c6bacfe5 Ermal Luçi
	else if (link_interface_to_gre($id))
278 8cc6876f groo
		$input_errors[] = gettext("The interface is part of a gre tunnel. Please delete the tunnel to continue");
279 c6bacfe5 Ermal Luçi
	else if (link_interface_to_gif($id))
280 8cc6876f groo
		$input_errors[] = gettext("The interface is part of a gif tunnel. Please delete the tunnel to continue");
281 1723f72d Ermal Luçi
	else {
282
		unset($config['interfaces'][$id]['enable']);
283 fa4a331f Ermal
		$realid = get_real_interface($id);
284 1723f72d Ermal Luçi
		interface_bring_down($id);   /* down the interface */
285 ef88e1e1 Renato Botelho
286 1723f72d Ermal Luçi
		unset($config['interfaces'][$id]);	/* delete the specified OPTn or LAN*/
287
288 198ac406 jim-p
		if (is_array($config['dhcpd']) && is_array($config['dhcpd'][$id])) {
289
			unset($config['dhcpd'][$id]);
290
			services_dhcpd_configure();
291 1723f72d Ermal Luçi
		}
292 c3bc7432 Ermal Luçi
293 05855d1d Ermal
		if (count($config['filter']['rule']) > 0) {
294 c86e8f76 gnhb
			foreach ($config['filter']['rule'] as $x => $rule) {
295
				if($rule['interface'] == $id)
296
					unset($config['filter']['rule'][$x]);
297 e27d0494 Ermal
			}
298 ef88e1e1 Renato Botelho
		}
299 c86e8f76 gnhb
		if (is_array($config['nat']['rule']) && count($config['nat']['rule']) > 0) {
300
			foreach ($config['nat']['rule'] as $x => $rule) {
301
				if($rule['interface'] == $id)
302
					unset($config['nat']['rule'][$x]['interface']);
303 e27d0494 Ermal
			}
304 ef88e1e1 Renato Botelho
		}
305 c3bc7432 Ermal Luçi
306 1723f72d Ermal Luçi
		write_config();
307 ef88e1e1 Renato Botelho
308 b3a07b12 sullrich
		/* If we are in firewall/routing mode (not single interface)
309
		 * then ensure that we are not running DHCP on the wan which
310
		 * will make a lot of ISP's unhappy.
311
		 */
312 b8778031 lgcosta
		if($config['interfaces']['lan'] && $config['dhcpd']['wan']) {
313 ef88e1e1 Renato Botelho
			unset($config['dhcpd']['wan']);
314 1723f72d Ermal Luçi
		}
315 7850de1c Ermal Lu?i
316 fa4a331f Ermal
		link_interface_to_vlans($realid, "update");
317 ef88e1e1 Renato Botelho
318 8cc6876f groo
		$savemsg = gettext("Interface has been deleted.");
319 1723f72d Ermal Luçi
	}
320 5b237745 Scott Ullrich
}
321
322 65c5cec3 Ermal
if ($_GET['act'] == "add" && (count($config['interfaces']) < count($portlist))) {
323 5b237745 Scott Ullrich
	/* find next free optional interface number */
324 bda86e8f Scott Ullrich
	if(!$config['interfaces']['lan']) {
325 8cc6876f groo
		$newifname = gettext("lan");
326
		$descr = gettext("LAN");
327 0d21552c Scott Ullrich
		$config['interfaces'][$newifname] = array();
328 d59557dc Ermal Luçi
		$config['interfaces'][$newifname]['descr'] = $descr;
329 bda86e8f Scott Ullrich
	} else {
330 8a648100 Ermal Luçi
		for ($i = 1; $i <= count($config['interfaces']); $i++) {
331
			if (!$config['interfaces']["opt{$i}"])
332
				break;
333
		}
334 bda86e8f Scott Ullrich
		$newifname = 'opt' . $i;
335 01b8a2ff Renato Botelho
		$descr = "OPT" . $i;
336 0d21552c Scott Ullrich
		$config['interfaces'][$newifname] = array();
337 d59557dc Ermal Luçi
		$config['interfaces'][$newifname]['descr'] = $descr;
338 bda86e8f Scott Ullrich
	}
339 cec4323f Erik Fonnesbeck
340 88bc2760 Erik Fonnesbeck
	uksort($config['interfaces'], "compare_interface_friendly_names");
341 cec4323f Erik Fonnesbeck
342 5b237745 Scott Ullrich
	/* Find an unused port for this interface */
343
	foreach ($portlist as $portname => $portinfo) {
344
		$portused = false;
345
		foreach ($config['interfaces'] as $ifname => $ifdata) {
346
			if ($ifdata['if'] == $portname) {
347
				$portused = true;
348
				break;
349
			}
350
		}
351
		if (!$portused) {
352
			$config['interfaces'][$newifname]['if'] = $portname;
353 8f0289e7 Erik Fonnesbeck
			if (preg_match($g['wireless_regex'], $portname)) {
354 5b237745 Scott Ullrich
				$config['interfaces'][$newifname]['wireless'] = array();
355 8f0289e7 Erik Fonnesbeck
				interface_sync_wireless_clones($config['interfaces'][$newifname], false);
356
			}
357 5b237745 Scott Ullrich
			break;
358
		}
359
	}
360 ef88e1e1 Renato Botelho
361
	/* XXX: Do not remove this. */
362
	mwexec("/bin/rm -f /tmp/config.cache");
363 d59557dc Ermal Luçi
364 5b237745 Scott Ullrich
	write_config();
365 093a01b0 Scott Ullrich
366 8cc6876f groo
	$savemsg = gettext("Interface has been added.");
367 21eebbb0 Scott Ullrich
368 65c5cec3 Ermal
} else if ($_GET['act'] == "add")
369
	$input_errors[] = "No more interfaces available to be assigned.";
370 5b237745 Scott Ullrich
371 7f43ca88 Scott Ullrich
include("head.inc");
372
373 ef88e1e1 Renato Botelho
if(file_exists("/var/run/interface_mismatch_reboot_needed"))
374 ca4acbcd Scott Ullrich
	if ($_POST) {
375 ef88e1e1 Renato Botelho
		if($rebootingnow)
376 ca4acbcd Scott Ullrich
			$savemsg = gettext("The system is now rebooting.  Please wait.");
377
		else
378
			$savemsg = gettext("Reboot is needed. Please apply the settings in order to reboot.");
379
	} else {
380 8cc6876f groo
		$savemsg = gettext("Interface mismatch detected.  Please resolve the mismatch and click Save.  The firewall will reboot afterwards.");
381 ca4acbcd Scott Ullrich
	}
382 5b237745 Scott Ullrich
?>
383 6eb47218 Scott Ullrich
384
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
385 5b237745 Scott Ullrich
<?php include("fbegin.inc"); ?>
386 a2dab9bc Bill Marquette
387 5b237745 Scott Ullrich
<form action="interfaces_assign.php" method="post" name="iform" id="iform">
388 f2cb6a9f Scott Ullrich
389 d59557dc Ermal Luçi
<?php if (file_exists("/tmp/reload_interfaces")): ?><p>
390 e2ad8d0e Colin Fleming
	<?php print_info_box_np(gettext("The interface configuration has been changed.<br>You must apply the changes in order for them to take effect."));?><br/></p>
391 b100b85d Scott Ullrich
<?php elseif($savemsg): ?>
392
	<?php print_info_box($savemsg); ?>
393 d59557dc Ermal Luçi
<?php endif; ?>
394
395 2a74593e Scott Ullrich
<?php pfSense_handle_custom_code("/usr/local/pkg/interfaces_assign/pre_input_errors"); ?>
396 f2cb6a9f Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
397
398 e2ad8d0e Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="interfaces assign">
399 94a77286 Scott Ullrich
  <tr><td class="tabnavtbl">
400 c8b8ff69 Scott Ullrich
<?php
401
	$tab_array = array();
402 5465972a Carlos Eduardo Ramos
	$tab_array[0] = array(gettext("Interface assignments"), true, "interfaces_assign.php");
403
	$tab_array[1] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
404
	$tab_array[2] = array(gettext("Wireless"), false, "interfaces_wireless.php");
405
	$tab_array[3] = array(gettext("VLANs"), false, "interfaces_vlan.php");
406
	$tab_array[4] = array(gettext("QinQs"), false, "interfaces_qinq.php");
407
	$tab_array[5] = array(gettext("PPPs"), false, "interfaces_ppps.php");
408
	$tab_array[7] = array(gettext("GRE"), false, "interfaces_gre.php");
409
	$tab_array[8] = array(gettext("GIF"), false, "interfaces_gif.php");
410
	$tab_array[9] = array(gettext("Bridges"), false, "interfaces_bridge.php");
411
	$tab_array[10] = array(gettext("LAGG"), false, "interfaces_lagg.php");
412 c8b8ff69 Scott Ullrich
	display_top_tabs($tab_array);
413 ef88e1e1 Renato Botelho
?>
414 5b237745 Scott Ullrich
  </td></tr>
415 ef88e1e1 Renato Botelho
  <tr>
416 d732f186 Bill Marquette
    <td>
417
	<div id="mainarea">
418 e2ad8d0e Colin Fleming
        <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
419 ef88e1e1 Renato Botelho
       <tr>
420 5465972a Carlos Eduardo Ramos
	<td class="listhdrr"><?=gettext("Interface"); ?></td>
421
	<td class="listhdr"><?=gettext("Network port"); ?></td>
422 5b237745 Scott Ullrich
	<td class="list">&nbsp;</td>
423
  </tr>
424
  <?php foreach ($config['interfaces'] as $ifname => $iface):
425
  	if ($iface['descr'])
426 96302ebd Scott Ullrich
		$ifdescr = $iface['descr'];
427 5b237745 Scott Ullrich
	else
428
		$ifdescr = strtoupper($ifname);
429
	?>
430 ef88e1e1 Renato Botelho
  <tr>
431 e2ad8d0e Colin Fleming
	<td class="listlr" valign="middle"><strong><u><span onclick="location.href='/interfaces.php?if=<?=$ifname;?>'" style="cursor: pointer;"><?=$ifdescr;?></span></u></strong></td>
432 5b237745 Scott Ullrich
	  <td valign="middle" class="listr">
433 e2ad8d0e Colin Fleming
		<select onchange="javascript:jQuery('#savediv').show();" name="<?=$ifname;?>" id="<?=$ifname;?>">
434 5b237745 Scott Ullrich
		  <?php foreach ($portlist as $portname => $portinfo): ?>
435 e2ad8d0e Colin Fleming
			<option  value="<?=$portname;?>"  <?php if ($portname == $iface['if']) echo " selected=\"selected\"";?>>
436 99c26d44 gnhb
				<?php if ($portinfo['isvlan']) {
437 ddc55e12 Erik Fonnesbeck
					$descr = sprintf(gettext('VLAN %1$s on %2$s'),$portinfo['tag'],$portinfo['if']);
438 91a5b98a gnhb
				if ($portinfo['descr'])
439 e3feac4e Scott Ullrich
					$descr .= " (" . $portinfo['descr'] . ")";
440 91a5b98a gnhb
					echo htmlspecialchars($descr);
441
				} elseif ($portinfo['iswlclone']) {
442
					$descr = $portinfo['cloneif'];
443
					if ($portinfo['descr'])
444
						$descr .= " (" . $portinfo['descr'] . ")";
445
					echo htmlspecialchars($descr);
446
				} elseif ($portinfo['isppp']) {
447
					echo htmlspecialchars($portinfo['descr']);
448
				} elseif ($portinfo['isbridge']) {
449
					$descr = strtoupper($portinfo['bridgeif']);
450
					if ($portinfo['descr'])
451
						$descr .= " (" . $portinfo['descr'] . ")";
452
					echo htmlspecialchars($descr);
453
				} elseif ($portinfo['isgre']) {
454
					$descr = "GRE {$portinfo['remote-addr']}";
455
					if ($portinfo['descr'])
456
						$descr .= " (" . $portinfo['descr'] . ")";
457
					echo htmlspecialchars($descr);
458
				} elseif ($portinfo['isgif']) {
459 40b0c024 Ermal
					$descr = "GIF {$portinfo['remote-addr']}";
460 91a5b98a gnhb
					if ($portinfo['descr'])
461
						$descr .= " (" . $portinfo['descr'] . ")";
462
					echo htmlspecialchars($descr);
463
				} elseif ($portinfo['islagg']) {
464
					$descr = strtoupper($portinfo['laggif']);
465
					if ($portinfo['descr'])
466
						$descr .= " (" . $portinfo['descr'] . ")";
467
					echo htmlspecialchars($descr);
468
				} elseif ($portinfo['isqinq']) {
469
					echo htmlspecialchars($portinfo['descr']);
470 144fbff2 jim-p
				} elseif (substr($portname, 0, 4) == 'ovpn') {
471 7f078046 jim-p
					echo htmlspecialchars($portname . " (" . $ovpn_descrs[substr($portname, 5)] . ")");
472 91a5b98a gnhb
				} else
473
					echo htmlspecialchars($portname . " (" . $portinfo['mac'] . ")");
474 c86e8f76 gnhb
			?></option>
475 265188ea Ermal Lu?i
		<?php endforeach; ?>
476
	</select>
477
	</td>
478
	<td valign="middle" class="list">
479 b0d756ba Scott Ullrich
		  <?php if ($ifname != 'wan'): ?>
480 e2ad8d0e Colin Fleming
		  <a href="interfaces_assign.php?act=del&amp;id=<?=$ifname;?>" onclick="return confirm('<?=gettext("Do you really want to delete this interface?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete interface"); ?>" width="17" height="17" border="0" alt="delete" /></a>
481 5b237745 Scott Ullrich
		  <?php endif; ?>
482
		</td>
483
  </tr>
484
  <?php endforeach; ?>
485
  <?php if (count($config['interfaces']) < count($portlist)): ?>
486
  <tr>
487
	<td class="list" colspan="2"></td>
488 e2ad8d0e Colin Fleming
	<td class="list nowrap">
489
	<a href="interfaces_assign.php?act=add"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title=<?=gettext("add interface"); ?> width="17" height="17" border="0" alt="add" /></a>
490 5b237745 Scott Ullrich
	</td>
491
  </tr>
492
  <?php else: ?>
493
  <tr>
494
	<td class="list" colspan="3" height="10"></td>
495
  </tr>
496
  <?php endif; ?>
497
</table>
498 d732f186 Bill Marquette
</div>
499 0d21552c Scott Ullrich
<br/>
500 e2ad8d0e Colin Fleming
<div id='savediv' <?php if (empty($_GET['act'])) echo "style='display:none;'"; ?>>
501
	<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" /><br/><br/>
502 46d8071e Scott Ullrich
</div>
503 94a77286 Scott Ullrich
<ul>
504 036371d2 jim-p
	<li><span class="vexpl"><?=gettext("Interfaces that are configured as members of a lagg(4) interface will not be shown."); ?></span></li>
505 31b85492 jim-p
</ul>
506
</td>
507
</tr>
508 5b237745 Scott Ullrich
</table>
509
</form>
510
<?php include("fend.inc"); ?>
511 c8b8ff69 Scott Ullrich
</body>
512
</html>