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 |
ce77a9c4
|
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 |
6c07db48
|
Phil Davis
|
$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 |
6c07db48
|
Phil Davis
|
$descr = sprintf(gettext('VLAN %1$s on %2$s'), $portinfo['tag'], $portinfo['if']);
|
60 |
2af86dda
|
Phil Davis
|
if ($portinfo['descr']) {
|
61 |
1c4b1636
|
Renato Botelho
|
$descr .= " (" . $portinfo['descr'] . ")";
|
62 |
2af86dda
|
Phil Davis
|
}
|
63 |
1c4b1636
|
Renato Botelho
|
} elseif ($portinfo['iswlclone']) {
|
64 |
|
|
$descr = $portinfo['cloneif'];
|
65 |
2af86dda
|
Phil Davis
|
if ($portinfo['descr']) {
|
66 |
1c4b1636
|
Renato Botelho
|
$descr .= " (" . $portinfo['descr'] . ")";
|
67 |
2af86dda
|
Phil Davis
|
}
|
68 |
1c4b1636
|
Renato Botelho
|
} elseif ($portinfo['isppp']) {
|
69 |
|
|
$descr = $portinfo['descr'];
|
70 |
|
|
} elseif ($portinfo['isbridge']) {
|
71 |
|
|
$descr = strtoupper($portinfo['bridgeif']);
|
72 |
2af86dda
|
Phil Davis
|
if ($portinfo['descr']) {
|
73 |
1c4b1636
|
Renato Botelho
|
$descr .= " (" . $portinfo['descr'] . ")";
|
74 |
2af86dda
|
Phil Davis
|
}
|
75 |
1c4b1636
|
Renato Botelho
|
} elseif ($portinfo['isgre']) {
|
76 |
|
|
$descr = "GRE {$portinfo['remote-addr']}";
|
77 |
2af86dda
|
Phil Davis
|
if ($portinfo['descr']) {
|
78 |
1c4b1636
|
Renato Botelho
|
$descr .= " (" . $portinfo['descr'] . ")";
|
79 |
2af86dda
|
Phil Davis
|
}
|
80 |
1c4b1636
|
Renato Botelho
|
} elseif ($portinfo['isgif']) {
|
81 |
|
|
$descr = "GIF {$portinfo['remote-addr']}";
|
82 |
2af86dda
|
Phil Davis
|
if ($portinfo['descr']) {
|
83 |
1c4b1636
|
Renato Botelho
|
$descr .= " (" . $portinfo['descr'] . ")";
|
84 |
2af86dda
|
Phil Davis
|
}
|
85 |
1c4b1636
|
Renato Botelho
|
} elseif ($portinfo['islagg']) {
|
86 |
|
|
$descr = strtoupper($portinfo['laggif']);
|
87 |
2af86dda
|
Phil Davis
|
if ($portinfo['descr']) {
|
88 |
1c4b1636
|
Renato Botelho
|
$descr .= " (" . $portinfo['descr'] . ")";
|
89 |
2af86dda
|
Phil Davis
|
}
|
90 |
1c4b1636
|
Renato Botelho
|
} elseif ($portinfo['isqinq']) {
|
91 |
6c07db48
|
Phil Davis
|
$descr = $portinfo['descr'];
|
92 |
1c4b1636
|
Renato Botelho
|
} elseif (substr($portname, 0, 4) == 'ovpn') {
|
93 |
|
|
$descr = $portname . " (" . $ovpn_descrs[substr($portname, 5)] . ")";
|
94 |
2af86dda
|
Phil Davis
|
} else {
|
95 |
1c4b1636
|
Renato Botelho
|
$descr = $portname . " (" . $portinfo['mac'] . ")";
|
96 |
2af86dda
|
Phil Davis
|
}
|
97 |
1c4b1636
|
Renato Botelho
|
|
98 |
|
|
return htmlspecialchars($descr);
|
99 |
|
|
}
|
100 |
|
|
|
101 |
5b237745
|
Scott Ullrich
|
/*
|
102 |
|
|
In this file, "port" refers to the physical port name,
|
103 |
|
|
while "interface" refers to LAN, WAN, or OPTn.
|
104 |
|
|
*/
|
105 |
|
|
|
106 |
|
|
/* get list without VLAN interfaces */
|
107 |
|
|
$portlist = get_interface_list();
|
108 |
|
|
|
109 |
7c53bc7b
|
Erik Fonnesbeck
|
/* add wireless clone interfaces */
|
110 |
|
|
if (is_array($config['wireless']['clone']) && count($config['wireless']['clone'])) {
|
111 |
|
|
foreach ($config['wireless']['clone'] as $clone) {
|
112 |
|
|
$portlist[$clone['cloneif']] = $clone;
|
113 |
|
|
$portlist[$clone['cloneif']]['iswlclone'] = true;
|
114 |
|
|
}
|
115 |
|
|
}
|
116 |
|
|
|
117 |
5b237745
|
Scott Ullrich
|
/* add VLAN interfaces */
|
118 |
|
|
if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
|
119 |
|
|
foreach ($config['vlans']['vlan'] as $vlan) {
|
120 |
d59557dc
|
Ermal Luçi
|
$portlist[$vlan['vlanif']] = $vlan;
|
121 |
|
|
$portlist[$vlan['vlanif']]['isvlan'] = true;
|
122 |
5b237745
|
Scott Ullrich
|
}
|
123 |
|
|
}
|
124 |
|
|
|
125 |
38738505
|
Ermal Luçi
|
/* add Bridge interfaces */
|
126 |
b47c94bd
|
Ermal Luçi
|
if (is_array($config['bridges']['bridged']) && count($config['bridges']['bridged'])) {
|
127 |
ef88e1e1
|
Renato Botelho
|
foreach ($config['bridges']['bridged'] as $bridge) {
|
128 |
|
|
$portlist[$bridge['bridgeif']] = $bridge;
|
129 |
|
|
$portlist[$bridge['bridgeif']]['isbridge'] = true;
|
130 |
|
|
}
|
131 |
38738505
|
Ermal Luçi
|
}
|
132 |
|
|
|
133 |
|
|
/* add GIF interfaces */
|
134 |
|
|
if (is_array($config['gifs']['gif']) && count($config['gifs']['gif'])) {
|
135 |
ef88e1e1
|
Renato Botelho
|
foreach ($config['gifs']['gif'] as $gif) {
|
136 |
|
|
$portlist[$gif['gifif']] = $gif;
|
137 |
|
|
$portlist[$gif['gifif']]['isgif'] = true;
|
138 |
|
|
}
|
139 |
38738505
|
Ermal Luçi
|
}
|
140 |
|
|
|
141 |
|
|
/* add GRE interfaces */
|
142 |
|
|
if (is_array($config['gres']['gre']) && count($config['gres']['gre'])) {
|
143 |
ef88e1e1
|
Renato Botelho
|
foreach ($config['gres']['gre'] as $gre) {
|
144 |
|
|
$portlist[$gre['greif']] = $gre;
|
145 |
|
|
$portlist[$gre['greif']]['isgre'] = true;
|
146 |
|
|
}
|
147 |
38738505
|
Ermal Luçi
|
}
|
148 |
|
|
|
149 |
dbdd08af
|
Ermal Luçi
|
/* add LAGG interfaces */
|
150 |
c720925c
|
Ermal Luçi
|
if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) {
|
151 |
ef88e1e1
|
Renato Botelho
|
foreach ($config['laggs']['lagg'] as $lagg) {
|
152 |
|
|
$portlist[$lagg['laggif']] = $lagg;
|
153 |
|
|
$portlist[$lagg['laggif']]['islagg'] = true;
|
154 |
dbdd08af
|
Ermal Luçi
|
/* LAGG members cannot be assigned */
|
155 |
|
|
$lagifs = explode(',', $lagg['members']);
|
156 |
2af86dda
|
Phil Davis
|
foreach ($lagifs as $lagif) {
|
157 |
|
|
if (isset($portlist[$lagif])) {
|
158 |
dbdd08af
|
Ermal Luçi
|
unset($portlist[$lagif]);
|
159 |
2af86dda
|
Phil Davis
|
}
|
160 |
|
|
}
|
161 |
ef88e1e1
|
Renato Botelho
|
}
|
162 |
c720925c
|
Ermal Luçi
|
}
|
163 |
|
|
|
164 |
265188ea
|
Ermal Lu?i
|
/* add QinQ interfaces */
|
165 |
|
|
if (is_array($config['qinqs']['qinqentry']) && count($config['qinqs']['qinqentry'])) {
|
166 |
ef88e1e1
|
Renato Botelho
|
foreach ($config['qinqs']['qinqentry'] as $qinq) {
|
167 |
|
|
$portlist["vlan{$qinq['tag']}"]['descr'] = "VLAN {$qinq['tag']}";
|
168 |
|
|
$portlist["vlan{$qinq['tag']}"]['isqinq'] = true;
|
169 |
|
|
/* QinQ members */
|
170 |
|
|
$qinqifs = explode(' ', $qinq['members']);
|
171 |
|
|
foreach ($qinqifs as $qinqif) {
|
172 |
|
|
$portlist["vlan{$qinq['tag']}_{$qinqif}"]['descr'] = "QinQ {$qinqif}";
|
173 |
|
|
$portlist["vlan{$qinq['tag']}_{$qinqif}"]['isqinq'] = true;
|
174 |
|
|
}
|
175 |
|
|
}
|
176 |
265188ea
|
Ermal Lu?i
|
}
|
177 |
c720925c
|
Ermal Luçi
|
|
178 |
860c4e80
|
Chris Buechler
|
/* add PPP interfaces */
|
179 |
|
|
if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) {
|
180 |
611ae852
|
Ermal
|
foreach ($config['ppps']['ppp'] as $pppid => $ppp) {
|
181 |
99c26d44
|
gnhb
|
$portname = $ppp['if'];
|
182 |
860c4e80
|
Chris Buechler
|
$portlist[$portname] = $ppp;
|
183 |
|
|
$portlist[$portname]['isppp'] = true;
|
184 |
3f2ef8d7
|
gnhb
|
$ports_base = basename($ppp['ports']);
|
185 |
2af86dda
|
Phil Davis
|
if (isset($ppp['descr'])) {
|
186 |
99c26d44
|
gnhb
|
$portlist[$portname]['descr'] = strtoupper($ppp['if']). "({$ports_base}) - {$ppp['descr']}";
|
187 |
2af86dda
|
Phil Davis
|
} else if (isset($ppp['username'])) {
|
188 |
99c26d44
|
gnhb
|
$portlist[$portname]['descr'] = strtoupper($ppp['if']). "({$ports_base}) - {$ppp['username']}";
|
189 |
2af86dda
|
Phil Davis
|
} else {
|
190 |
99c26d44
|
gnhb
|
$portlist[$portname]['descr'] = strtoupper($ppp['if']). "({$ports_base})";
|
191 |
2af86dda
|
Phil Davis
|
}
|
192 |
860c4e80
|
Chris Buechler
|
}
|
193 |
|
|
}
|
194 |
|
|
|
195 |
144fbff2
|
jim-p
|
$ovpn_descrs = array();
|
196 |
|
|
if (is_array($config['openvpn'])) {
|
197 |
2af86dda
|
Phil Davis
|
if (is_array($config['openvpn']['openvpn-server'])) {
|
198 |
|
|
foreach ($config['openvpn']['openvpn-server'] as $s) {
|
199 |
bfa7b33e
|
doktornotor
|
$portname = "ovpns{$s['vpnid']}";
|
200 |
|
|
$portlist[$portname] = $s;
|
201 |
144fbff2
|
jim-p
|
$ovpn_descrs[$s['vpnid']] = $s['description'];
|
202 |
2af86dda
|
Phil Davis
|
}
|
203 |
|
|
}
|
204 |
|
|
if (is_array($config['openvpn']['openvpn-client'])) {
|
205 |
|
|
foreach ($config['openvpn']['openvpn-client'] as $c) {
|
206 |
bfa7b33e
|
doktornotor
|
$portname = "ovpnc{$c['vpnid']}";
|
207 |
|
|
$portlist[$portname] = $c;
|
208 |
144fbff2
|
jim-p
|
$ovpn_descrs[$c['vpnid']] = $c['description'];
|
209 |
2af86dda
|
Phil Davis
|
}
|
210 |
|
|
}
|
211 |
144fbff2
|
jim-p
|
}
|
212 |
|
|
|
213 |
ad2879b8
|
PiBa-NL
|
if (isset($_POST['add']) && isset($_POST['if_add'])) {
|
214 |
7c611a3e
|
Renato Botelho
|
/* Be sure this port is not being used */
|
215 |
|
|
$portused = false;
|
216 |
|
|
foreach ($config['interfaces'] as $ifname => $ifdata) {
|
217 |
3f6930f7
|
Phil Davis
|
if ($ifdata['if'] == $_POST['if_add']) {
|
218 |
7c611a3e
|
Renato Botelho
|
$portused = true;
|
219 |
|
|
break;
|
220 |
|
|
}
|
221 |
|
|
}
|
222 |
|
|
|
223 |
|
|
if ($portused === false) {
|
224 |
|
|
/* find next free optional interface number */
|
225 |
2af86dda
|
Phil Davis
|
if (!$config['interfaces']['lan']) {
|
226 |
7c611a3e
|
Renato Botelho
|
$newifname = gettext("lan");
|
227 |
|
|
$descr = gettext("LAN");
|
228 |
|
|
} else {
|
229 |
|
|
for ($i = 1; $i <= count($config['interfaces']); $i++) {
|
230 |
2af86dda
|
Phil Davis
|
if (!$config['interfaces']["opt{$i}"]) {
|
231 |
7c611a3e
|
Renato Botelho
|
break;
|
232 |
2af86dda
|
Phil Davis
|
}
|
233 |
7c611a3e
|
Renato Botelho
|
}
|
234 |
|
|
$newifname = 'opt' . $i;
|
235 |
|
|
$descr = "OPT" . $i;
|
236 |
|
|
}
|
237 |
|
|
|
238 |
|
|
$config['interfaces'][$newifname] = array();
|
239 |
|
|
$config['interfaces'][$newifname]['descr'] = $descr;
|
240 |
|
|
$config['interfaces'][$newifname]['if'] = $_POST['if_add'];
|
241 |
|
|
if (preg_match($g['wireless_regex'], $_POST['if_add'])) {
|
242 |
|
|
$config['interfaces'][$newifname]['wireless'] = array();
|
243 |
|
|
interface_sync_wireless_clones($config['interfaces'][$newifname], false);
|
244 |
|
|
}
|
245 |
|
|
|
246 |
|
|
uksort($config['interfaces'], "compare_interface_friendly_names");
|
247 |
|
|
|
248 |
|
|
/* XXX: Do not remove this. */
|
249 |
|
|
unlink_if_exists("{$g['tmp_path']}/config.cache");
|
250 |
|
|
|
251 |
|
|
write_config();
|
252 |
|
|
|
253 |
|
|
$savemsg = gettext("Interface has been added.");
|
254 |
|
|
}
|
255 |
|
|
|
256 |
|
|
} else if (isset($_POST['apply'])) {
|
257 |
ca4acbcd
|
Scott Ullrich
|
if (file_exists("/var/run/interface_mismatch_reboot_needed")) {
|
258 |
eef52225
|
jim-p
|
system_reboot();
|
259 |
ca4acbcd
|
Scott Ullrich
|
$rebootingnow = true;
|
260 |
|
|
} else {
|
261 |
d59557dc
|
Ermal Luçi
|
write_config();
|
262 |
|
|
|
263 |
|
|
$retval = filter_configure();
|
264 |
0027de0a
|
Ermal Lu?i
|
$savemsg = get_std_save_message($retval);
|
265 |
d59557dc
|
Ermal Luçi
|
|
266 |
2af86dda
|
Phil Davis
|
if (stristr($retval, "error") <> true) {
|
267 |
d59557dc
|
Ermal Luçi
|
$savemsg = get_std_save_message($retval);
|
268 |
2af86dda
|
Phil Davis
|
} else {
|
269 |
d59557dc
|
Ermal Luçi
|
$savemsg = $retval;
|
270 |
2af86dda
|
Phil Davis
|
}
|
271 |
d59557dc
|
Ermal Luçi
|
}
|
272 |
|
|
|
273 |
7c611a3e
|
Renato Botelho
|
} else if (isset($_POST['Submit'])) {
|
274 |
5b237745
|
Scott Ullrich
|
|
275 |
|
|
unset($input_errors);
|
276 |
|
|
|
277 |
|
|
/* input validation */
|
278 |
|
|
|
279 |
|
|
/* Build a list of the port names so we can see how the interfaces map */
|
280 |
|
|
$portifmap = array();
|
281 |
2af86dda
|
Phil Davis
|
foreach ($portlist as $portname => $portinfo) {
|
282 |
5b237745
|
Scott Ullrich
|
$portifmap[$portname] = array();
|
283 |
2af86dda
|
Phil Davis
|
}
|
284 |
5b237745
|
Scott Ullrich
|
|
285 |
|
|
/* Go through the list of ports selected by the user,
|
286 |
ef88e1e1
|
Renato Botelho
|
build a list of port-to-interface mappings in portifmap */
|
287 |
5b237745
|
Scott Ullrich
|
foreach ($_POST as $ifname => $ifport) {
|
288 |
2af86dda
|
Phil Davis
|
if (($ifname == 'lan') || ($ifname == 'wan') || (substr($ifname, 0, 3) == 'opt')) {
|
289 |
5b237745
|
Scott Ullrich
|
$portifmap[$ifport][] = strtoupper($ifname);
|
290 |
2af86dda
|
Phil Davis
|
}
|
291 |
5b237745
|
Scott Ullrich
|
}
|
292 |
|
|
|
293 |
|
|
/* Deliver error message for any port with more than one assignment */
|
294 |
|
|
foreach ($portifmap as $portname => $ifnames) {
|
295 |
|
|
if (count($ifnames) > 1) {
|
296 |
ddc55e12
|
Erik Fonnesbeck
|
$errstr = sprintf(gettext('Port %1$s '.
|
297 |
|
|
' was assigned to %2$s' .
|
298 |
|
|
' interfaces:'), $portname, count($ifnames));
|
299 |
ef88e1e1
|
Renato Botelho
|
|
300 |
2af86dda
|
Phil Davis
|
foreach ($portifmap[$portname] as $ifn) {
|
301 |
f0eef2ef
|
Phil Davis
|
$errstr .= " " . convert_friendly_interface_to_friendly_descr(strtolower($ifn)) . " (" . $ifn . ")";
|
302 |
2af86dda
|
Phil Davis
|
}
|
303 |
ef88e1e1
|
Renato Botelho
|
|
304 |
5b237745
|
Scott Ullrich
|
$input_errors[] = $errstr;
|
305 |
95540233
|
Renato Botelho
|
} else if (count($ifnames) == 1 && preg_match('/^bridge[0-9]/', $portname) && is_array($config['bridges']['bridged']) && count($config['bridges']['bridged'])) {
|
306 |
|
|
foreach ($config['bridges']['bridged'] as $bridge) {
|
307 |
2af86dda
|
Phil Davis
|
if ($bridge['bridgeif'] != $portname) {
|
308 |
95540233
|
Renato Botelho
|
continue;
|
309 |
2af86dda
|
Phil Davis
|
}
|
310 |
95540233
|
Renato Botelho
|
|
311 |
|
|
$members = explode(",", strtoupper($bridge['members']));
|
312 |
|
|
foreach ($members as $member) {
|
313 |
|
|
if ($member == $ifnames[0]) {
|
314 |
|
|
$input_errors[] = sprintf(gettext("You cannot set port %s to interface %s because this interface is a member of %s."), $portname, $member, $portname);
|
315 |
|
|
break;
|
316 |
|
|
}
|
317 |
|
|
}
|
318 |
|
|
}
|
319 |
5b237745
|
Scott Ullrich
|
}
|
320 |
|
|
}
|
321 |
|
|
|
322 |
66bcba1b
|
Ermal
|
if (is_array($config['vlans']['vlan'])) {
|
323 |
|
|
foreach ($config['vlans']['vlan'] as $vlan) {
|
324 |
2af86dda
|
Phil Davis
|
if (does_interface_exist($vlan['if']) == false) {
|
325 |
66bcba1b
|
Ermal
|
$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.";
|
326 |
2af86dda
|
Phil Davis
|
}
|
327 |
66bcba1b
|
Ermal
|
}
|
328 |
|
|
}
|
329 |
5b237745
|
Scott Ullrich
|
|
330 |
|
|
if (!$input_errors) {
|
331 |
|
|
/* No errors detected, so update the config */
|
332 |
|
|
foreach ($_POST as $ifname => $ifport) {
|
333 |
ef88e1e1
|
Renato Botelho
|
|
334 |
|
|
if (($ifname == 'lan') || ($ifname == 'wan') || (substr($ifname, 0, 3) == 'opt')) {
|
335 |
|
|
|
336 |
5b237745
|
Scott Ullrich
|
if (!is_array($ifport)) {
|
337 |
e7bfa231
|
Ermal Lu?i
|
$reloadif = false;
|
338 |
44088ce8
|
Ermal Lu?i
|
if (!empty($config['interfaces'][$ifname]['if']) && $config['interfaces'][$ifname]['if'] <> $ifport) {
|
339 |
|
|
interface_bring_down($ifname);
|
340 |
e7bfa231
|
Ermal Lu?i
|
/* Mark this to be reconfigured in any case. */
|
341 |
|
|
$reloadif = true;
|
342 |
44088ce8
|
Ermal Lu?i
|
}
|
343 |
5b237745
|
Scott Ullrich
|
$config['interfaces'][$ifname]['if'] = $ifport;
|
344 |
2af86dda
|
Phil Davis
|
if (isset($portlist[$ifport]['isppp'])) {
|
345 |
c86e8f76
|
gnhb
|
$config['interfaces'][$ifname]['ipaddr'] = $portlist[$ifport]['type'];
|
346 |
2af86dda
|
Phil Davis
|
}
|
347 |
ef88e1e1
|
Renato Botelho
|
|
348 |
0b5fc1d1
|
Ermal
|
if (substr($ifport, 0, 3) == 'gre' || substr($ifport, 0, 3) == 'gif') {
|
349 |
f3d88511
|
Renato Botelho
|
unset($config['interfaces'][$ifname]['ipaddr']);
|
350 |
|
|
unset($config['interfaces'][$ifname]['subnet']);
|
351 |
|
|
unset($config['interfaces'][$ifname]['ipaddrv6']);
|
352 |
|
|
unset($config['interfaces'][$ifname]['subnetv6']);
|
353 |
|
|
}
|
354 |
|
|
|
355 |
5b237745
|
Scott Ullrich
|
/* check for wireless interfaces, set or clear ['wireless'] */
|
356 |
94a77286
|
Scott Ullrich
|
if (preg_match($g['wireless_regex'], $ifport)) {
|
357 |
2af86dda
|
Phil Davis
|
if (!is_array($config['interfaces'][$ifname]['wireless'])) {
|
358 |
5b237745
|
Scott Ullrich
|
$config['interfaces'][$ifname]['wireless'] = array();
|
359 |
2af86dda
|
Phil Davis
|
}
|
360 |
5b237745
|
Scott Ullrich
|
} else {
|
361 |
|
|
unset($config['interfaces'][$ifname]['wireless']);
|
362 |
|
|
}
|
363 |
ef88e1e1
|
Renato Botelho
|
|
364 |
d59557dc
|
Ermal Luçi
|
/* make sure there is a descr for all interfaces */
|
365 |
2af86dda
|
Phil Davis
|
if (!isset($config['interfaces'][$ifname]['descr'])) {
|
366 |
d59557dc
|
Ermal Luçi
|
$config['interfaces'][$ifname]['descr'] = strtoupper($ifname);
|
367 |
2af86dda
|
Phil Davis
|
}
|
368 |
ef88e1e1
|
Renato Botelho
|
|
369 |
b13efb03
|
Erik Fonnesbeck
|
if ($reloadif == true) {
|
370 |
2af86dda
|
Phil Davis
|
if (preg_match($g['wireless_regex'], $ifport)) {
|
371 |
b13efb03
|
Erik Fonnesbeck
|
interface_sync_wireless_clones($config['interfaces'][$ifname], false);
|
372 |
2af86dda
|
Phil Davis
|
}
|
373 |
e7bfa231
|
Ermal Lu?i
|
/* Reload all for the interface. */
|
374 |
|
|
interface_configure($ifname, true);
|
375 |
b13efb03
|
Erik Fonnesbeck
|
}
|
376 |
5b237745
|
Scott Ullrich
|
}
|
377 |
|
|
}
|
378 |
|
|
}
|
379 |
ef88e1e1
|
Renato Botelho
|
|
380 |
5b237745
|
Scott Ullrich
|
write_config();
|
381 |
ef88e1e1
|
Renato Botelho
|
|
382 |
6e6233d0
|
sullrich
|
enable_rrd_graphing();
|
383 |
5b237745
|
Scott Ullrich
|
}
|
384 |
7c611a3e
|
Renato Botelho
|
} else {
|
385 |
|
|
unset($delbtn);
|
386 |
41ea4cf3
|
Sjon Hortensius
|
if (!empty($_POST['del']))
|
387 |
|
|
$delbtn = key($_POST['del']);
|
388 |
5b237745
|
Scott Ullrich
|
|
389 |
7c611a3e
|
Renato Botelho
|
if (isset($delbtn)) {
|
390 |
|
|
$id = $delbtn;
|
391 |
|
|
|
392 |
2af86dda
|
Phil Davis
|
if (link_interface_to_group($id)) {
|
393 |
7c611a3e
|
Renato Botelho
|
$input_errors[] = gettext("The interface is part of a group. Please remove it from the group to continue");
|
394 |
2af86dda
|
Phil Davis
|
} else if (link_interface_to_bridge($id)) {
|
395 |
7c611a3e
|
Renato Botelho
|
$input_errors[] = gettext("The interface is part of a bridge. Please remove it from the bridge to continue");
|
396 |
2af86dda
|
Phil Davis
|
} else if (link_interface_to_gre($id)) {
|
397 |
7c611a3e
|
Renato Botelho
|
$input_errors[] = gettext("The interface is part of a gre tunnel. Please delete the tunnel to continue");
|
398 |
2af86dda
|
Phil Davis
|
} else if (link_interface_to_gif($id)) {
|
399 |
7c611a3e
|
Renato Botelho
|
$input_errors[] = gettext("The interface is part of a gif tunnel. Please delete the tunnel to continue");
|
400 |
2af86dda
|
Phil Davis
|
} else {
|
401 |
7c611a3e
|
Renato Botelho
|
unset($config['interfaces'][$id]['enable']);
|
402 |
|
|
$realid = get_real_interface($id);
|
403 |
|
|
interface_bring_down($id); /* down the interface */
|
404 |
|
|
|
405 |
|
|
unset($config['interfaces'][$id]); /* delete the specified OPTn or LAN*/
|
406 |
|
|
|
407 |
|
|
if (is_array($config['dhcpd']) && is_array($config['dhcpd'][$id])) {
|
408 |
|
|
unset($config['dhcpd'][$id]);
|
409 |
|
|
services_dhcpd_configure();
|
410 |
|
|
}
|
411 |
c3bc7432
|
Ermal Luçi
|
|
412 |
7c611a3e
|
Renato Botelho
|
if (count($config['filter']['rule']) > 0) {
|
413 |
|
|
foreach ($config['filter']['rule'] as $x => $rule) {
|
414 |
2af86dda
|
Phil Davis
|
if ($rule['interface'] == $id) {
|
415 |
7c611a3e
|
Renato Botelho
|
unset($config['filter']['rule'][$x]);
|
416 |
2af86dda
|
Phil Davis
|
}
|
417 |
7c611a3e
|
Renato Botelho
|
}
|
418 |
e27d0494
|
Ermal
|
}
|
419 |
7c611a3e
|
Renato Botelho
|
if (is_array($config['nat']['rule']) && count($config['nat']['rule']) > 0) {
|
420 |
|
|
foreach ($config['nat']['rule'] as $x => $rule) {
|
421 |
2af86dda
|
Phil Davis
|
if ($rule['interface'] == $id) {
|
422 |
7c611a3e
|
Renato Botelho
|
unset($config['nat']['rule'][$x]['interface']);
|
423 |
2af86dda
|
Phil Davis
|
}
|
424 |
7c611a3e
|
Renato Botelho
|
}
|
425 |
e27d0494
|
Ermal
|
}
|
426 |
c3bc7432
|
Ermal Luçi
|
|
427 |
7c611a3e
|
Renato Botelho
|
write_config();
|
428 |
ef88e1e1
|
Renato Botelho
|
|
429 |
7c611a3e
|
Renato Botelho
|
/* If we are in firewall/routing mode (not single interface)
|
430 |
|
|
* then ensure that we are not running DHCP on the wan which
|
431 |
|
|
* will make a lot of ISP's unhappy.
|
432 |
|
|
*/
|
433 |
2af86dda
|
Phil Davis
|
if ($config['interfaces']['lan'] && $config['dhcpd']['wan']) {
|
434 |
7c611a3e
|
Renato Botelho
|
unset($config['dhcpd']['wan']);
|
435 |
|
|
}
|
436 |
7850de1c
|
Ermal Lu?i
|
|
437 |
7c611a3e
|
Renato Botelho
|
link_interface_to_vlans($realid, "update");
|
438 |
ef88e1e1
|
Renato Botelho
|
|
439 |
7c611a3e
|
Renato Botelho
|
$savemsg = gettext("Interface has been deleted.");
|
440 |
8a648100
|
Ermal Luçi
|
}
|
441 |
bda86e8f
|
Scott Ullrich
|
}
|
442 |
7c611a3e
|
Renato Botelho
|
}
|
443 |
cec4323f
|
Erik Fonnesbeck
|
|
444 |
7c611a3e
|
Renato Botelho
|
/* Create a list of unused ports */
|
445 |
|
|
$unused_portlist = array();
|
446 |
|
|
foreach ($portlist as $portname => $portinfo) {
|
447 |
|
|
$portused = false;
|
448 |
|
|
foreach ($config['interfaces'] as $ifname => $ifdata) {
|
449 |
|
|
if ($ifdata['if'] == $portname) {
|
450 |
|
|
$portused = true;
|
451 |
5b237745
|
Scott Ullrich
|
break;
|
452 |
|
|
}
|
453 |
|
|
}
|
454 |
2af86dda
|
Phil Davis
|
if ($portused === false) {
|
455 |
7c611a3e
|
Renato Botelho
|
$unused_portlist[$portname] = $portinfo;
|
456 |
2af86dda
|
Phil Davis
|
}
|
457 |
7c611a3e
|
Renato Botelho
|
}
|
458 |
5b237745
|
Scott Ullrich
|
|
459 |
7f43ca88
|
Scott Ullrich
|
include("head.inc");
|
460 |
|
|
|
461 |
2af86dda
|
Phil Davis
|
if (file_exists("/var/run/interface_mismatch_reboot_needed")) {
|
462 |
ca4acbcd
|
Scott Ullrich
|
if ($_POST) {
|
463 |
2af86dda
|
Phil Davis
|
if ($rebootingnow) {
|
464 |
ca4acbcd
|
Scott Ullrich
|
$savemsg = gettext("The system is now rebooting. Please wait.");
|
465 |
2af86dda
|
Phil Davis
|
} else {
|
466 |
ca4acbcd
|
Scott Ullrich
|
$savemsg = gettext("Reboot is needed. Please apply the settings in order to reboot.");
|
467 |
2af86dda
|
Phil Davis
|
}
|
468 |
ca4acbcd
|
Scott Ullrich
|
} else {
|
469 |
0b252f7a
|
Renato Botelho
|
$savemsg = gettext("Interface mismatch detected. Please resolve the mismatch and click 'Apply changes'. The firewall will reboot afterwards.");
|
470 |
ca4acbcd
|
Scott Ullrich
|
}
|
471 |
41ea4cf3
|
Sjon Hortensius
|
}
|
472 |
f2cb6a9f
|
Scott Ullrich
|
|
473 |
1b0e073e
|
Renato Botelho
|
if (file_exists("/tmp/reload_interfaces")) {
|
474 |
|
|
echo "<p>\n";
|
475 |
|
|
print_info_box_np(gettext("The interface configuration has been changed.<br />You must apply the changes in order for them to take effect."));
|
476 |
|
|
echo "<br /></p>\n";
|
477 |
2af86dda
|
Phil Davis
|
} elseif ($savemsg) {
|
478 |
1b0e073e
|
Renato Botelho
|
print_info_box($savemsg);
|
479 |
2af86dda
|
Phil Davis
|
}
|
480 |
1b0e073e
|
Renato Botelho
|
|
481 |
|
|
pfSense_handle_custom_code("/usr/local/pkg/interfaces_assign/pre_input_errors");
|
482 |
a4af095c
|
Renato Botelho
|
|
483 |
1b0e073e
|
Renato Botelho
|
if ($input_errors)
|
484 |
|
|
print_input_errors($input_errors);
|
485 |
f2cb6a9f
|
Scott Ullrich
|
|
486 |
41ea4cf3
|
Sjon Hortensius
|
$tab_array = array();
|
487 |
|
|
$tab_array[0] = array(gettext("Interface assignments"), true, "interfaces_assign.php");
|
488 |
|
|
$tab_array[1] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
|
489 |
|
|
$tab_array[2] = array(gettext("Wireless"), false, "interfaces_wireless.php");
|
490 |
|
|
$tab_array[3] = array(gettext("VLANs"), false, "interfaces_vlan.php");
|
491 |
|
|
$tab_array[4] = array(gettext("QinQs"), false, "interfaces_qinq.php");
|
492 |
|
|
$tab_array[5] = array(gettext("PPPs"), false, "interfaces_ppps.php");
|
493 |
|
|
$tab_array[7] = array(gettext("GRE"), false, "interfaces_gre.php");
|
494 |
|
|
$tab_array[8] = array(gettext("GIF"), false, "interfaces_gif.php");
|
495 |
|
|
$tab_array[9] = array(gettext("Bridges"), false, "interfaces_bridge.php");
|
496 |
|
|
$tab_array[10] = array(gettext("LAGG"), false, "interfaces_lagg.php");
|
497 |
|
|
display_top_tabs($tab_array);
|
498 |
1b0e073e
|
Renato Botelho
|
?>
|
499 |
41ea4cf3
|
Sjon Hortensius
|
<form action="interfaces_assign.php" method="post">
|
500 |
89f64f0f
|
Sander van Leeuwen
|
<div class="table-responsive">
|
501 |
|
|
<table class="table table-striped table-hover">
|
502 |
41ea4cf3
|
Sjon Hortensius
|
<thead>
|
503 |
|
|
<tr>
|
504 |
|
|
<th><?=gettext("Interface")?></th>
|
505 |
|
|
<th><?=gettext("Network port")?></th>
|
506 |
|
|
</tr>
|
507 |
|
|
</thead>
|
508 |
|
|
<tbody>
|
509 |
1b0e073e
|
Renato Botelho
|
<?php
|
510 |
41ea4cf3
|
Sjon Hortensius
|
foreach ($config['interfaces'] as $ifname => $iface):
|
511 |
|
|
if ($iface['descr'])
|
512 |
|
|
$ifdescr = $iface['descr'];
|
513 |
|
|
else
|
514 |
|
|
$ifdescr = strtoupper($ifname);
|
515 |
7c611a3e
|
Renato Botelho
|
?>
|
516 |
41ea4cf3
|
Sjon Hortensius
|
<tr>
|
517 |
|
|
<td><a href="/interfaces.php?if=<?=$ifname?>"><?=$ifdescr?></a></td>
|
518 |
|
|
<td>
|
519 |
|
|
<select name="<?=$ifname?>" id="<?=$ifname?>" class="form-control">
|
520 |
|
|
<?php foreach ($portlist as $portname => $portinfo):?>
|
521 |
|
|
<option value="<?=$portname?>" <?=($portname == $iface['if']) ? ' selected="selected"': ''?>>
|
522 |
|
|
<?=interface_assign_description($portinfo, $portname)?>
|
523 |
|
|
</option>
|
524 |
|
|
<?php endforeach;?>
|
525 |
|
|
</select>
|
526 |
|
|
</td>
|
527 |
|
|
<td>
|
528 |
|
|
<?php if ($ifname != 'wan'):?>
|
529 |
45d6ada5
|
Sjon Hortensius
|
<input type="submit" name="del[<?=$ifname?>]" class="btn btn-danger" value="<?=gettext("delete interface")?>"/>
|
530 |
41ea4cf3
|
Sjon Hortensius
|
<?php endif;?>
|
531 |
|
|
</td>
|
532 |
|
|
</tr>
|
533 |
|
|
<?php endforeach;
|
534 |
|
|
if (count($config['interfaces']) < count($portlist)):
|
535 |
1b0e073e
|
Renato Botelho
|
?>
|
536 |
41ea4cf3
|
Sjon Hortensius
|
<tr>
|
537 |
|
|
<th>
|
538 |
|
|
<?=gettext("Available network ports:")?>
|
539 |
|
|
</th>
|
540 |
|
|
<td>
|
541 |
|
|
<select name="if_add" id="if_add" class="form-control">
|
542 |
|
|
<?php foreach ($unused_portlist as $portname => $portinfo):?>
|
543 |
|
|
<option value="<?=$portname?>" <?=($portname == $iface['if']) ? ' selected="selected"': ''?>>
|
544 |
|
|
<?=interface_assign_description($portinfo, $portname)?>
|
545 |
|
|
</option>
|
546 |
|
|
<?php endforeach;?>
|
547 |
|
|
</select>
|
548 |
|
|
</td>
|
549 |
|
|
<td>
|
550 |
|
|
<input type="submit" name="add" title="<?=gettext("add selected interface")?>" value="add interface" class="btn btn-success" />
|
551 |
|
|
</td>
|
552 |
|
|
</tr>
|
553 |
|
|
<?php endif;?>
|
554 |
|
|
</tbody>
|
555 |
|
|
</table>
|
556 |
89f64f0f
|
Sander van Leeuwen
|
</div>
|
557 |
41ea4cf3
|
Sjon Hortensius
|
|
558 |
|
|
<input name="Submit" type="submit" class="btn btn-default" value="<?=gettext("Save")?>" /><br /><br />
|
559 |
5b237745
|
Scott Ullrich
|
</form>
|
560 |
89f64f0f
|
Sander van Leeuwen
|
|
561 |
|
|
<p class="alert alert-info"><?=gettext("Interfaces that are configured as members of a lagg(4) interface will not be shown.")?></p>
|
562 |
|
|
|
563 |
bfa7b33e
|
doktornotor
|
<?php include("foot.inc")?>
|