Project

General

Profile

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