1 |
ef88e1e1
|
Renato Botelho
|
<?php
|
2 |
5b237745
|
Scott Ullrich
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* interfaces_assign.php
|
4 |
092e7a96
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
81299b5c
|
Renato Botelho
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
8 |
191cb31d
|
Stephen Beaver
|
*
|
9 |
c5d81585
|
Renato Botelho
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
10 |
|
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11 |
|
|
* Written by Jim McBeath based on existing m0n0wall files
|
12 |
|
|
* All rights reserved.
|
13 |
092e7a96
|
Stephen Beaver
|
*
|
14 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
15 |
|
|
* you may not use this file except in compliance with the License.
|
16 |
|
|
* You may obtain a copy of the License at
|
17 |
092e7a96
|
Stephen Beaver
|
*
|
18 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
19 |
092e7a96
|
Stephen Beaver
|
*
|
20 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
21 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
22 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
23 |
|
|
* See the License for the specific language governing permissions and
|
24 |
|
|
* limitations under the License.
|
25 |
092e7a96
|
Stephen Beaver
|
*/
|
26 |
5b237745
|
Scott Ullrich
|
|
27 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
28 |
|
|
##|*IDENT=page-interfaces-assignnetworkports
|
29 |
26b4bef8
|
k-paulius
|
##|*NAME=Interfaces: Interface Assignments
|
30 |
|
|
##|*DESCR=Allow access to the 'Interfaces: Interface Assignments' page.
|
31 |
6b07c15a
|
Matthew Grooms
|
##|*MATCH=interfaces_assign.php*
|
32 |
|
|
##|-PRIV
|
33 |
|
|
|
34 |
26b4bef8
|
k-paulius
|
$pgtitle = array(gettext("Interfaces"), gettext("Interface Assignments"));
|
35 |
b32dd0a6
|
jim-p
|
$shortcut_section = "interfaces";
|
36 |
af1e2031
|
jim-p
|
|
37 |
c81ef6e2
|
Phil Davis
|
require_once("guiconfig.inc");
|
38 |
|
|
require_once("functions.inc");
|
39 |
f6339216
|
jim-p
|
require_once("filter.inc");
|
40 |
c81ef6e2
|
Phil Davis
|
require_once("shaper.inc");
|
41 |
|
|
require_once("ipsec.inc");
|
42 |
|
|
require_once("vpn.inc");
|
43 |
|
|
require_once("captiveportal.inc");
|
44 |
1b34f8a7
|
Ermal
|
require_once("rrd.inc");
|
45 |
5b237745
|
Scott Ullrich
|
|
46 |
1c4b1636
|
Renato Botelho
|
function interface_assign_description($portinfo, $portname) {
|
47 |
d4b9bc5a
|
Phil Davis
|
global $ovpn_descrs;
|
48 |
1c4b1636
|
Renato Botelho
|
if ($portinfo['isvlan']) {
|
49 |
6c07db48
|
Phil Davis
|
$descr = sprintf(gettext('VLAN %1$s on %2$s'), $portinfo['tag'], $portinfo['if']);
|
50 |
9fcc7581
|
Luiz Otavio O Souza
|
$iface = convert_real_interface_to_friendly_interface_name($portinfo['if']);
|
51 |
|
|
if (isset($iface) && strlen($iface) > 0) {
|
52 |
|
|
$descr .= " - $iface";
|
53 |
|
|
}
|
54 |
2af86dda
|
Phil Davis
|
if ($portinfo['descr']) {
|
55 |
1c4b1636
|
Renato Botelho
|
$descr .= " (" . $portinfo['descr'] . ")";
|
56 |
2af86dda
|
Phil Davis
|
}
|
57 |
1c4b1636
|
Renato Botelho
|
} elseif ($portinfo['iswlclone']) {
|
58 |
|
|
$descr = $portinfo['cloneif'];
|
59 |
2af86dda
|
Phil Davis
|
if ($portinfo['descr']) {
|
60 |
1c4b1636
|
Renato Botelho
|
$descr .= " (" . $portinfo['descr'] . ")";
|
61 |
2af86dda
|
Phil Davis
|
}
|
62 |
1c4b1636
|
Renato Botelho
|
} elseif ($portinfo['isppp']) {
|
63 |
|
|
$descr = $portinfo['descr'];
|
64 |
|
|
} elseif ($portinfo['isbridge']) {
|
65 |
|
|
$descr = strtoupper($portinfo['bridgeif']);
|
66 |
2af86dda
|
Phil Davis
|
if ($portinfo['descr']) {
|
67 |
1c4b1636
|
Renato Botelho
|
$descr .= " (" . $portinfo['descr'] . ")";
|
68 |
2af86dda
|
Phil Davis
|
}
|
69 |
1c4b1636
|
Renato Botelho
|
} elseif ($portinfo['isgre']) {
|
70 |
|
|
$descr = "GRE {$portinfo['remote-addr']}";
|
71 |
2af86dda
|
Phil Davis
|
if ($portinfo['descr']) {
|
72 |
1c4b1636
|
Renato Botelho
|
$descr .= " (" . $portinfo['descr'] . ")";
|
73 |
2af86dda
|
Phil Davis
|
}
|
74 |
1c4b1636
|
Renato Botelho
|
} elseif ($portinfo['isgif']) {
|
75 |
|
|
$descr = "GIF {$portinfo['remote-addr']}";
|
76 |
2af86dda
|
Phil Davis
|
if ($portinfo['descr']) {
|
77 |
1c4b1636
|
Renato Botelho
|
$descr .= " (" . $portinfo['descr'] . ")";
|
78 |
2af86dda
|
Phil Davis
|
}
|
79 |
1c4b1636
|
Renato Botelho
|
} elseif ($portinfo['islagg']) {
|
80 |
|
|
$descr = strtoupper($portinfo['laggif']);
|
81 |
2af86dda
|
Phil Davis
|
if ($portinfo['descr']) {
|
82 |
1c4b1636
|
Renato Botelho
|
$descr .= " (" . $portinfo['descr'] . ")";
|
83 |
2af86dda
|
Phil Davis
|
}
|
84 |
1c4b1636
|
Renato Botelho
|
} elseif ($portinfo['isqinq']) {
|
85 |
6c07db48
|
Phil Davis
|
$descr = $portinfo['descr'];
|
86 |
1c4b1636
|
Renato Botelho
|
} elseif (substr($portname, 0, 4) == 'ovpn') {
|
87 |
|
|
$descr = $portname . " (" . $ovpn_descrs[substr($portname, 5)] . ")";
|
88 |
2af86dda
|
Phil Davis
|
} else {
|
89 |
1c4b1636
|
Renato Botelho
|
$descr = $portname . " (" . $portinfo['mac'] . ")";
|
90 |
2af86dda
|
Phil Davis
|
}
|
91 |
1c4b1636
|
Renato Botelho
|
|
92 |
|
|
return htmlspecialchars($descr);
|
93 |
|
|
}
|
94 |
|
|
|
95 |
5b237745
|
Scott Ullrich
|
/*
|
96 |
|
|
In this file, "port" refers to the physical port name,
|
97 |
|
|
while "interface" refers to LAN, WAN, or OPTn.
|
98 |
|
|
*/
|
99 |
|
|
|
100 |
|
|
/* get list without VLAN interfaces */
|
101 |
|
|
$portlist = get_interface_list();
|
102 |
|
|
|
103 |
7c53bc7b
|
Erik Fonnesbeck
|
/* add wireless clone interfaces */
|
104 |
|
|
if (is_array($config['wireless']['clone']) && count($config['wireless']['clone'])) {
|
105 |
|
|
foreach ($config['wireless']['clone'] as $clone) {
|
106 |
|
|
$portlist[$clone['cloneif']] = $clone;
|
107 |
|
|
$portlist[$clone['cloneif']]['iswlclone'] = true;
|
108 |
|
|
}
|
109 |
|
|
}
|
110 |
|
|
|
111 |
5b237745
|
Scott Ullrich
|
/* add VLAN interfaces */
|
112 |
|
|
if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
|
113 |
|
|
foreach ($config['vlans']['vlan'] as $vlan) {
|
114 |
d59557dc
|
Ermal Luçi
|
$portlist[$vlan['vlanif']] = $vlan;
|
115 |
|
|
$portlist[$vlan['vlanif']]['isvlan'] = true;
|
116 |
5b237745
|
Scott Ullrich
|
}
|
117 |
|
|
}
|
118 |
|
|
|
119 |
38738505
|
Ermal Luçi
|
/* add Bridge interfaces */
|
120 |
b47c94bd
|
Ermal Luçi
|
if (is_array($config['bridges']['bridged']) && count($config['bridges']['bridged'])) {
|
121 |
ef88e1e1
|
Renato Botelho
|
foreach ($config['bridges']['bridged'] as $bridge) {
|
122 |
|
|
$portlist[$bridge['bridgeif']] = $bridge;
|
123 |
|
|
$portlist[$bridge['bridgeif']]['isbridge'] = true;
|
124 |
|
|
}
|
125 |
38738505
|
Ermal Luçi
|
}
|
126 |
|
|
|
127 |
|
|
/* add GIF interfaces */
|
128 |
|
|
if (is_array($config['gifs']['gif']) && count($config['gifs']['gif'])) {
|
129 |
ef88e1e1
|
Renato Botelho
|
foreach ($config['gifs']['gif'] as $gif) {
|
130 |
|
|
$portlist[$gif['gifif']] = $gif;
|
131 |
|
|
$portlist[$gif['gifif']]['isgif'] = true;
|
132 |
|
|
}
|
133 |
38738505
|
Ermal Luçi
|
}
|
134 |
|
|
|
135 |
|
|
/* add GRE interfaces */
|
136 |
|
|
if (is_array($config['gres']['gre']) && count($config['gres']['gre'])) {
|
137 |
ef88e1e1
|
Renato Botelho
|
foreach ($config['gres']['gre'] as $gre) {
|
138 |
|
|
$portlist[$gre['greif']] = $gre;
|
139 |
|
|
$portlist[$gre['greif']]['isgre'] = true;
|
140 |
|
|
}
|
141 |
38738505
|
Ermal Luçi
|
}
|
142 |
|
|
|
143 |
dbdd08af
|
Ermal Luçi
|
/* add LAGG interfaces */
|
144 |
c720925c
|
Ermal Luçi
|
if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) {
|
145 |
ef88e1e1
|
Renato Botelho
|
foreach ($config['laggs']['lagg'] as $lagg) {
|
146 |
|
|
$portlist[$lagg['laggif']] = $lagg;
|
147 |
|
|
$portlist[$lagg['laggif']]['islagg'] = true;
|
148 |
dbdd08af
|
Ermal Luçi
|
/* LAGG members cannot be assigned */
|
149 |
|
|
$lagifs = explode(',', $lagg['members']);
|
150 |
2af86dda
|
Phil Davis
|
foreach ($lagifs as $lagif) {
|
151 |
|
|
if (isset($portlist[$lagif])) {
|
152 |
dbdd08af
|
Ermal Luçi
|
unset($portlist[$lagif]);
|
153 |
2af86dda
|
Phil Davis
|
}
|
154 |
|
|
}
|
155 |
ef88e1e1
|
Renato Botelho
|
}
|
156 |
c720925c
|
Ermal Luçi
|
}
|
157 |
|
|
|
158 |
265188ea
|
Ermal Lu?i
|
/* add QinQ interfaces */
|
159 |
|
|
if (is_array($config['qinqs']['qinqentry']) && count($config['qinqs']['qinqentry'])) {
|
160 |
ef88e1e1
|
Renato Botelho
|
foreach ($config['qinqs']['qinqentry'] as $qinq) {
|
161 |
1322ee22
|
Chris Rowe
|
$portlist["{$qinq['vlanif']}"]['descr'] = "VLAN {$qinq['tag']} on {$qinq['if']}";
|
162 |
|
|
$portlist["{$qinq['vlanif']}"]['isqinq'] = true;
|
163 |
ef88e1e1
|
Renato Botelho
|
/* QinQ members */
|
164 |
|
|
$qinqifs = explode(' ', $qinq['members']);
|
165 |
|
|
foreach ($qinqifs as $qinqif) {
|
166 |
1322ee22
|
Chris Rowe
|
$portlist["{$qinq['vlanif']}_{$qinqif}"]['descr'] = "QinQ {$qinqif} on VLAN {$qinq['tag']} on {$qinq['if']}";
|
167 |
|
|
$portlist["{$qinq['vlanif']}_{$qinqif}"]['isqinq'] = true;
|
168 |
ef88e1e1
|
Renato Botelho
|
}
|
169 |
|
|
}
|
170 |
265188ea
|
Ermal Lu?i
|
}
|
171 |
c720925c
|
Ermal Luçi
|
|
172 |
860c4e80
|
Chris Buechler
|
/* add PPP interfaces */
|
173 |
|
|
if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) {
|
174 |
611ae852
|
Ermal
|
foreach ($config['ppps']['ppp'] as $pppid => $ppp) {
|
175 |
99c26d44
|
gnhb
|
$portname = $ppp['if'];
|
176 |
860c4e80
|
Chris Buechler
|
$portlist[$portname] = $ppp;
|
177 |
|
|
$portlist[$portname]['isppp'] = true;
|
178 |
3f2ef8d7
|
gnhb
|
$ports_base = basename($ppp['ports']);
|
179 |
2af86dda
|
Phil Davis
|
if (isset($ppp['descr'])) {
|
180 |
99c26d44
|
gnhb
|
$portlist[$portname]['descr'] = strtoupper($ppp['if']). "({$ports_base}) - {$ppp['descr']}";
|
181 |
2af86dda
|
Phil Davis
|
} else if (isset($ppp['username'])) {
|
182 |
99c26d44
|
gnhb
|
$portlist[$portname]['descr'] = strtoupper($ppp['if']). "({$ports_base}) - {$ppp['username']}";
|
183 |
2af86dda
|
Phil Davis
|
} else {
|
184 |
99c26d44
|
gnhb
|
$portlist[$portname]['descr'] = strtoupper($ppp['if']). "({$ports_base})";
|
185 |
2af86dda
|
Phil Davis
|
}
|
186 |
860c4e80
|
Chris Buechler
|
}
|
187 |
|
|
}
|
188 |
|
|
|
189 |
144fbff2
|
jim-p
|
$ovpn_descrs = array();
|
190 |
|
|
if (is_array($config['openvpn'])) {
|
191 |
2af86dda
|
Phil Davis
|
if (is_array($config['openvpn']['openvpn-server'])) {
|
192 |
|
|
foreach ($config['openvpn']['openvpn-server'] as $s) {
|
193 |
bfa7b33e
|
doktornotor
|
$portname = "ovpns{$s['vpnid']}";
|
194 |
|
|
$portlist[$portname] = $s;
|
195 |
144fbff2
|
jim-p
|
$ovpn_descrs[$s['vpnid']] = $s['description'];
|
196 |
2af86dda
|
Phil Davis
|
}
|
197 |
|
|
}
|
198 |
|
|
if (is_array($config['openvpn']['openvpn-client'])) {
|
199 |
|
|
foreach ($config['openvpn']['openvpn-client'] as $c) {
|
200 |
bfa7b33e
|
doktornotor
|
$portname = "ovpnc{$c['vpnid']}";
|
201 |
|
|
$portlist[$portname] = $c;
|
202 |
144fbff2
|
jim-p
|
$ovpn_descrs[$c['vpnid']] = $c['description'];
|
203 |
2af86dda
|
Phil Davis
|
}
|
204 |
|
|
}
|
205 |
144fbff2
|
jim-p
|
}
|
206 |
|
|
|
207 |
4401107f
|
Steve Beaver
|
if (isset($_REQUEST['add']) && isset($_REQUEST['if_add'])) {
|
208 |
7c611a3e
|
Renato Botelho
|
/* Be sure this port is not being used */
|
209 |
|
|
$portused = false;
|
210 |
|
|
foreach ($config['interfaces'] as $ifname => $ifdata) {
|
211 |
4401107f
|
Steve Beaver
|
if ($ifdata['if'] == $_REQUEST['if_add']) {
|
212 |
7c611a3e
|
Renato Botelho
|
$portused = true;
|
213 |
|
|
break;
|
214 |
|
|
}
|
215 |
|
|
}
|
216 |
|
|
|
217 |
|
|
if ($portused === false) {
|
218 |
|
|
/* find next free optional interface number */
|
219 |
2af86dda
|
Phil Davis
|
if (!$config['interfaces']['lan']) {
|
220 |
7c611a3e
|
Renato Botelho
|
$newifname = gettext("lan");
|
221 |
|
|
$descr = gettext("LAN");
|
222 |
|
|
} else {
|
223 |
|
|
for ($i = 1; $i <= count($config['interfaces']); $i++) {
|
224 |
2af86dda
|
Phil Davis
|
if (!$config['interfaces']["opt{$i}"]) {
|
225 |
7c611a3e
|
Renato Botelho
|
break;
|
226 |
2af86dda
|
Phil Davis
|
}
|
227 |
7c611a3e
|
Renato Botelho
|
}
|
228 |
|
|
$newifname = 'opt' . $i;
|
229 |
|
|
$descr = "OPT" . $i;
|
230 |
|
|
}
|
231 |
|
|
|
232 |
|
|
$config['interfaces'][$newifname] = array();
|
233 |
|
|
$config['interfaces'][$newifname]['descr'] = $descr;
|
234 |
|
|
$config['interfaces'][$newifname]['if'] = $_POST['if_add'];
|
235 |
|
|
if (preg_match($g['wireless_regex'], $_POST['if_add'])) {
|
236 |
|
|
$config['interfaces'][$newifname]['wireless'] = array();
|
237 |
|
|
interface_sync_wireless_clones($config['interfaces'][$newifname], false);
|
238 |
|
|
}
|
239 |
|
|
|
240 |
|
|
uksort($config['interfaces'], "compare_interface_friendly_names");
|
241 |
|
|
|
242 |
|
|
/* XXX: Do not remove this. */
|
243 |
|
|
unlink_if_exists("{$g['tmp_path']}/config.cache");
|
244 |
|
|
|
245 |
|
|
write_config();
|
246 |
|
|
|
247 |
44c42356
|
Phil Davis
|
$action_msg = gettext("Interface has been added.");
|
248 |
c8532336
|
Phil Davis
|
$class = "success";
|
249 |
7c611a3e
|
Renato Botelho
|
}
|
250 |
|
|
|
251 |
|
|
} else if (isset($_POST['apply'])) {
|
252 |
ca4acbcd
|
Scott Ullrich
|
if (file_exists("/var/run/interface_mismatch_reboot_needed")) {
|
253 |
eef52225
|
jim-p
|
system_reboot();
|
254 |
ca4acbcd
|
Scott Ullrich
|
$rebootingnow = true;
|
255 |
|
|
} else {
|
256 |
d59557dc
|
Ermal Luçi
|
write_config();
|
257 |
|
|
|
258 |
44c42356
|
Phil Davis
|
$changes_applied = true;
|
259 |
|
|
$retval = 0;
|
260 |
|
|
$retval |= filter_configure();
|
261 |
d59557dc
|
Ermal Luçi
|
}
|
262 |
|
|
|
263 |
7c611a3e
|
Renato Botelho
|
} else if (isset($_POST['Submit'])) {
|
264 |
5b237745
|
Scott Ullrich
|
|
265 |
|
|
unset($input_errors);
|
266 |
|
|
|
267 |
|
|
/* input validation */
|
268 |
|
|
|
269 |
|
|
/* Build a list of the port names so we can see how the interfaces map */
|
270 |
|
|
$portifmap = array();
|
271 |
2af86dda
|
Phil Davis
|
foreach ($portlist as $portname => $portinfo) {
|
272 |
5b237745
|
Scott Ullrich
|
$portifmap[$portname] = array();
|
273 |
2af86dda
|
Phil Davis
|
}
|
274 |
5b237745
|
Scott Ullrich
|
|
275 |
|
|
/* Go through the list of ports selected by the user,
|
276 |
ef88e1e1
|
Renato Botelho
|
build a list of port-to-interface mappings in portifmap */
|
277 |
5b237745
|
Scott Ullrich
|
foreach ($_POST as $ifname => $ifport) {
|
278 |
2af86dda
|
Phil Davis
|
if (($ifname == 'lan') || ($ifname == 'wan') || (substr($ifname, 0, 3) == 'opt')) {
|
279 |
5b237745
|
Scott Ullrich
|
$portifmap[$ifport][] = strtoupper($ifname);
|
280 |
2af86dda
|
Phil Davis
|
}
|
281 |
5b237745
|
Scott Ullrich
|
}
|
282 |
|
|
|
283 |
|
|
/* Deliver error message for any port with more than one assignment */
|
284 |
|
|
foreach ($portifmap as $portname => $ifnames) {
|
285 |
|
|
if (count($ifnames) > 1) {
|
286 |
ddc55e12
|
Erik Fonnesbeck
|
$errstr = sprintf(gettext('Port %1$s '.
|
287 |
|
|
' was assigned to %2$s' .
|
288 |
|
|
' interfaces:'), $portname, count($ifnames));
|
289 |
ef88e1e1
|
Renato Botelho
|
|
290 |
2af86dda
|
Phil Davis
|
foreach ($portifmap[$portname] as $ifn) {
|
291 |
f0eef2ef
|
Phil Davis
|
$errstr .= " " . convert_friendly_interface_to_friendly_descr(strtolower($ifn)) . " (" . $ifn . ")";
|
292 |
2af86dda
|
Phil Davis
|
}
|
293 |
ef88e1e1
|
Renato Botelho
|
|
294 |
5b237745
|
Scott Ullrich
|
$input_errors[] = $errstr;
|
295 |
95540233
|
Renato Botelho
|
} else if (count($ifnames) == 1 && preg_match('/^bridge[0-9]/', $portname) && is_array($config['bridges']['bridged']) && count($config['bridges']['bridged'])) {
|
296 |
|
|
foreach ($config['bridges']['bridged'] as $bridge) {
|
297 |
2af86dda
|
Phil Davis
|
if ($bridge['bridgeif'] != $portname) {
|
298 |
95540233
|
Renato Botelho
|
continue;
|
299 |
2af86dda
|
Phil Davis
|
}
|
300 |
95540233
|
Renato Botelho
|
|
301 |
|
|
$members = explode(",", strtoupper($bridge['members']));
|
302 |
|
|
foreach ($members as $member) {
|
303 |
|
|
if ($member == $ifnames[0]) {
|
304 |
45654aa0
|
NOYB
|
$input_errors[] = sprintf(gettext('Cannot set port %1$s to interface %2$s because this interface is a member of %3$s.'), $portname, $member, $portname);
|
305 |
95540233
|
Renato Botelho
|
break;
|
306 |
|
|
}
|
307 |
|
|
}
|
308 |
|
|
}
|
309 |
5b237745
|
Scott Ullrich
|
}
|
310 |
|
|
}
|
311 |
|
|
|
312 |
66bcba1b
|
Ermal
|
if (is_array($config['vlans']['vlan'])) {
|
313 |
|
|
foreach ($config['vlans']['vlan'] as $vlan) {
|
314 |
2af86dda
|
Phil Davis
|
if (does_interface_exist($vlan['if']) == false) {
|
315 |
0fc3de67
|
Phil Davis
|
$input_errors[] = sprintf(gettext('Vlan parent interface %1$s does not exist anymore so vlan id %2$s cannot be created please fix the issue before continuing.'), $vlan['if'], $vlan['tag']);
|
316 |
2af86dda
|
Phil Davis
|
}
|
317 |
66bcba1b
|
Ermal
|
}
|
318 |
|
|
}
|
319 |
5b237745
|
Scott Ullrich
|
|
320 |
|
|
if (!$input_errors) {
|
321 |
|
|
/* No errors detected, so update the config */
|
322 |
|
|
foreach ($_POST as $ifname => $ifport) {
|
323 |
ef88e1e1
|
Renato Botelho
|
|
324 |
|
|
if (($ifname == 'lan') || ($ifname == 'wan') || (substr($ifname, 0, 3) == 'opt')) {
|
325 |
|
|
|
326 |
5b237745
|
Scott Ullrich
|
if (!is_array($ifport)) {
|
327 |
e7bfa231
|
Ermal Lu?i
|
$reloadif = false;
|
328 |
44088ce8
|
Ermal Lu?i
|
if (!empty($config['interfaces'][$ifname]['if']) && $config['interfaces'][$ifname]['if'] <> $ifport) {
|
329 |
|
|
interface_bring_down($ifname);
|
330 |
e7bfa231
|
Ermal Lu?i
|
/* Mark this to be reconfigured in any case. */
|
331 |
|
|
$reloadif = true;
|
332 |
44088ce8
|
Ermal Lu?i
|
}
|
333 |
5b237745
|
Scott Ullrich
|
$config['interfaces'][$ifname]['if'] = $ifport;
|
334 |
2af86dda
|
Phil Davis
|
if (isset($portlist[$ifport]['isppp'])) {
|
335 |
c86e8f76
|
gnhb
|
$config['interfaces'][$ifname]['ipaddr'] = $portlist[$ifport]['type'];
|
336 |
2af86dda
|
Phil Davis
|
}
|
337 |
ef88e1e1
|
Renato Botelho
|
|
338 |
0b5fc1d1
|
Ermal
|
if (substr($ifport, 0, 3) == 'gre' || substr($ifport, 0, 3) == 'gif') {
|
339 |
f3d88511
|
Renato Botelho
|
unset($config['interfaces'][$ifname]['ipaddr']);
|
340 |
|
|
unset($config['interfaces'][$ifname]['subnet']);
|
341 |
|
|
unset($config['interfaces'][$ifname]['ipaddrv6']);
|
342 |
|
|
unset($config['interfaces'][$ifname]['subnetv6']);
|
343 |
|
|
}
|
344 |
|
|
|
345 |
5b237745
|
Scott Ullrich
|
/* check for wireless interfaces, set or clear ['wireless'] */
|
346 |
94a77286
|
Scott Ullrich
|
if (preg_match($g['wireless_regex'], $ifport)) {
|
347 |
2af86dda
|
Phil Davis
|
if (!is_array($config['interfaces'][$ifname]['wireless'])) {
|
348 |
5b237745
|
Scott Ullrich
|
$config['interfaces'][$ifname]['wireless'] = array();
|
349 |
2af86dda
|
Phil Davis
|
}
|
350 |
5b237745
|
Scott Ullrich
|
} else {
|
351 |
|
|
unset($config['interfaces'][$ifname]['wireless']);
|
352 |
|
|
}
|
353 |
ef88e1e1
|
Renato Botelho
|
|
354 |
d59557dc
|
Ermal Luçi
|
/* make sure there is a descr for all interfaces */
|
355 |
2af86dda
|
Phil Davis
|
if (!isset($config['interfaces'][$ifname]['descr'])) {
|
356 |
d59557dc
|
Ermal Luçi
|
$config['interfaces'][$ifname]['descr'] = strtoupper($ifname);
|
357 |
2af86dda
|
Phil Davis
|
}
|
358 |
ef88e1e1
|
Renato Botelho
|
|
359 |
b13efb03
|
Erik Fonnesbeck
|
if ($reloadif == true) {
|
360 |
2af86dda
|
Phil Davis
|
if (preg_match($g['wireless_regex'], $ifport)) {
|
361 |
b13efb03
|
Erik Fonnesbeck
|
interface_sync_wireless_clones($config['interfaces'][$ifname], false);
|
362 |
2af86dda
|
Phil Davis
|
}
|
363 |
e7bfa231
|
Ermal Lu?i
|
/* Reload all for the interface. */
|
364 |
|
|
interface_configure($ifname, true);
|
365 |
b13efb03
|
Erik Fonnesbeck
|
}
|
366 |
5b237745
|
Scott Ullrich
|
}
|
367 |
|
|
}
|
368 |
|
|
}
|
369 |
ef88e1e1
|
Renato Botelho
|
|
370 |
5b237745
|
Scott Ullrich
|
write_config();
|
371 |
ef88e1e1
|
Renato Botelho
|
|
372 |
6e6233d0
|
sullrich
|
enable_rrd_graphing();
|
373 |
5b237745
|
Scott Ullrich
|
}
|
374 |
7c611a3e
|
Renato Botelho
|
} else {
|
375 |
|
|
unset($delbtn);
|
376 |
aa82505e
|
Phil Davis
|
if (!empty($_POST['del'])) {
|
377 |
41ea4cf3
|
Sjon Hortensius
|
$delbtn = key($_POST['del']);
|
378 |
aa82505e
|
Phil Davis
|
}
|
379 |
5b237745
|
Scott Ullrich
|
|
380 |
7c611a3e
|
Renato Botelho
|
if (isset($delbtn)) {
|
381 |
|
|
$id = $delbtn;
|
382 |
|
|
|
383 |
2af86dda
|
Phil Davis
|
if (link_interface_to_group($id)) {
|
384 |
7c611a3e
|
Renato Botelho
|
$input_errors[] = gettext("The interface is part of a group. Please remove it from the group to continue");
|
385 |
2af86dda
|
Phil Davis
|
} else if (link_interface_to_bridge($id)) {
|
386 |
7c611a3e
|
Renato Botelho
|
$input_errors[] = gettext("The interface is part of a bridge. Please remove it from the bridge to continue");
|
387 |
2af86dda
|
Phil Davis
|
} else if (link_interface_to_gre($id)) {
|
388 |
7c611a3e
|
Renato Botelho
|
$input_errors[] = gettext("The interface is part of a gre tunnel. Please delete the tunnel to continue");
|
389 |
2af86dda
|
Phil Davis
|
} else if (link_interface_to_gif($id)) {
|
390 |
7c611a3e
|
Renato Botelho
|
$input_errors[] = gettext("The interface is part of a gif tunnel. Please delete the tunnel to continue");
|
391 |
85ea9d46
|
Steve Beaver
|
} else if (interface_has_queue($id)) {
|
392 |
9267c6c9
|
Steve Beaver
|
$input_errors[] = gettext("The interface has a traffic shaper queue configured.\nPlease remove all queues on the interface to continue.");
|
393 |
2af86dda
|
Phil Davis
|
} else {
|
394 |
7c611a3e
|
Renato Botelho
|
unset($config['interfaces'][$id]['enable']);
|
395 |
|
|
$realid = get_real_interface($id);
|
396 |
|
|
interface_bring_down($id); /* down the interface */
|
397 |
|
|
|
398 |
|
|
unset($config['interfaces'][$id]); /* delete the specified OPTn or LAN*/
|
399 |
|
|
|
400 |
|
|
if (is_array($config['dhcpd']) && is_array($config['dhcpd'][$id])) {
|
401 |
|
|
unset($config['dhcpd'][$id]);
|
402 |
6756052b
|
NewEraCracker
|
services_dhcpd_configure('inet');
|
403 |
7c611a3e
|
Renato Botelho
|
}
|
404 |
c3bc7432
|
Ermal Luçi
|
|
405 |
ff3f0016
|
Chris Buechler
|
if (is_array($config['dhcpdv6']) && is_array($config['dhcpdv6'][$id])) {
|
406 |
|
|
unset($config['dhcpdv6'][$id]);
|
407 |
6756052b
|
NewEraCracker
|
services_dhcpd_configure('inet6');
|
408 |
ff3f0016
|
Chris Buechler
|
}
|
409 |
|
|
|
410 |
7c611a3e
|
Renato Botelho
|
if (count($config['filter']['rule']) > 0) {
|
411 |
|
|
foreach ($config['filter']['rule'] as $x => $rule) {
|
412 |
2af86dda
|
Phil Davis
|
if ($rule['interface'] == $id) {
|
413 |
7c611a3e
|
Renato Botelho
|
unset($config['filter']['rule'][$x]);
|
414 |
2af86dda
|
Phil Davis
|
}
|
415 |
7c611a3e
|
Renato Botelho
|
}
|
416 |
e27d0494
|
Ermal
|
}
|
417 |
7c611a3e
|
Renato Botelho
|
if (is_array($config['nat']['rule']) && count($config['nat']['rule']) > 0) {
|
418 |
|
|
foreach ($config['nat']['rule'] as $x => $rule) {
|
419 |
2af86dda
|
Phil Davis
|
if ($rule['interface'] == $id) {
|
420 |
7c611a3e
|
Renato Botelho
|
unset($config['nat']['rule'][$x]['interface']);
|
421 |
2af86dda
|
Phil Davis
|
}
|
422 |
7c611a3e
|
Renato Botelho
|
}
|
423 |
e27d0494
|
Ermal
|
}
|
424 |
c3bc7432
|
Ermal Luçi
|
|
425 |
7c611a3e
|
Renato Botelho
|
write_config();
|
426 |
ef88e1e1
|
Renato Botelho
|
|
427 |
7c611a3e
|
Renato Botelho
|
/* If we are in firewall/routing mode (not single interface)
|
428 |
|
|
* then ensure that we are not running DHCP on the wan which
|
429 |
|
|
* will make a lot of ISP's unhappy.
|
430 |
|
|
*/
|
431 |
2af86dda
|
Phil Davis
|
if ($config['interfaces']['lan'] && $config['dhcpd']['wan']) {
|
432 |
7c611a3e
|
Renato Botelho
|
unset($config['dhcpd']['wan']);
|
433 |
|
|
}
|
434 |
7850de1c
|
Ermal Lu?i
|
|
435 |
7c611a3e
|
Renato Botelho
|
link_interface_to_vlans($realid, "update");
|
436 |
ef88e1e1
|
Renato Botelho
|
|
437 |
44c42356
|
Phil Davis
|
$action_msg = gettext("Interface has been deleted.");
|
438 |
c8532336
|
Phil Davis
|
$class = "success";
|
439 |
8a648100
|
Ermal Luçi
|
}
|
440 |
bda86e8f
|
Scott Ullrich
|
}
|
441 |
7c611a3e
|
Renato Botelho
|
}
|
442 |
cec4323f
|
Erik Fonnesbeck
|
|
443 |
7c611a3e
|
Renato Botelho
|
/* Create a list of unused ports */
|
444 |
|
|
$unused_portlist = array();
|
445 |
|
|
foreach ($portlist as $portname => $portinfo) {
|
446 |
|
|
$portused = false;
|
447 |
|
|
foreach ($config['interfaces'] as $ifname => $ifdata) {
|
448 |
|
|
if ($ifdata['if'] == $portname) {
|
449 |
|
|
$portused = true;
|
450 |
5b237745
|
Scott Ullrich
|
break;
|
451 |
|
|
}
|
452 |
|
|
}
|
453 |
2af86dda
|
Phil Davis
|
if ($portused === false) {
|
454 |
7c611a3e
|
Renato Botelho
|
$unused_portlist[$portname] = $portinfo;
|
455 |
2af86dda
|
Phil Davis
|
}
|
456 |
7c611a3e
|
Renato Botelho
|
}
|
457 |
5b237745
|
Scott Ullrich
|
|
458 |
7f43ca88
|
Scott Ullrich
|
include("head.inc");
|
459 |
|
|
|
460 |
2af86dda
|
Phil Davis
|
if (file_exists("/var/run/interface_mismatch_reboot_needed")) {
|
461 |
ca4acbcd
|
Scott Ullrich
|
if ($_POST) {
|
462 |
2af86dda
|
Phil Davis
|
if ($rebootingnow) {
|
463 |
44c42356
|
Phil Davis
|
$action_msg = gettext("The system is now rebooting. Please wait.");
|
464 |
c8532336
|
Phil Davis
|
$class = "success";
|
465 |
2af86dda
|
Phil Davis
|
} else {
|
466 |
21c18c3d
|
Phil Davis
|
$applymsg = gettext("Reboot is needed. Please apply the settings in order to reboot.");
|
467 |
c8532336
|
Phil Davis
|
$class = "warning";
|
468 |
2af86dda
|
Phil Davis
|
}
|
469 |
ca4acbcd
|
Scott Ullrich
|
} else {
|
470 |
44c42356
|
Phil Davis
|
$action_msg = gettext("Interface mismatch detected. Please resolve the mismatch, save and then click 'Apply Changes'. The firewall will reboot afterwards.");
|
471 |
c8532336
|
Phil Davis
|
$class = "warning";
|
472 |
ca4acbcd
|
Scott Ullrich
|
}
|
473 |
41ea4cf3
|
Sjon Hortensius
|
}
|
474 |
f2cb6a9f
|
Scott Ullrich
|
|
475 |
1b0e073e
|
Renato Botelho
|
if (file_exists("/tmp/reload_interfaces")) {
|
476 |
|
|
echo "<p>\n";
|
477 |
45654aa0
|
NOYB
|
print_apply_box(gettext("The interface configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
|
478 |
1b0e073e
|
Renato Botelho
|
echo "<br /></p>\n";
|
479 |
21c18c3d
|
Phil Davis
|
} elseif ($applymsg) {
|
480 |
|
|
print_apply_box($applymsg);
|
481 |
44c42356
|
Phil Davis
|
} elseif ($action_msg) {
|
482 |
|
|
print_info_box($action_msg, $class);
|
483 |
|
|
} elseif ($changes_applied) {
|
484 |
|
|
print_apply_result_box($retval);
|
485 |
2af86dda
|
Phil Davis
|
}
|
486 |
1b0e073e
|
Renato Botelho
|
|
487 |
|
|
pfSense_handle_custom_code("/usr/local/pkg/interfaces_assign/pre_input_errors");
|
488 |
a4af095c
|
Renato Botelho
|
|
489 |
aa82505e
|
Phil Davis
|
if ($input_errors) {
|
490 |
1b0e073e
|
Renato Botelho
|
print_input_errors($input_errors);
|
491 |
aa82505e
|
Phil Davis
|
}
|
492 |
f2cb6a9f
|
Scott Ullrich
|
|
493 |
41ea4cf3
|
Sjon Hortensius
|
$tab_array = array();
|
494 |
26b4bef8
|
k-paulius
|
$tab_array[] = array(gettext("Interface Assignments"), true, "interfaces_assign.php");
|
495 |
50e6c063
|
Renato Botelho
|
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
|
496 |
|
|
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
|
497 |
|
|
$tab_array[] = array(gettext("VLANs"), false, "interfaces_vlan.php");
|
498 |
|
|
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
|
499 |
|
|
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
|
500 |
26b4bef8
|
k-paulius
|
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
|
501 |
|
|
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
|
502 |
50e6c063
|
Renato Botelho
|
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
|
503 |
26b4bef8
|
k-paulius
|
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
|
504 |
41ea4cf3
|
Sjon Hortensius
|
display_top_tabs($tab_array);
|
505 |
1b0e073e
|
Renato Botelho
|
?>
|
506 |
41ea4cf3
|
Sjon Hortensius
|
<form action="interfaces_assign.php" method="post">
|
507 |
89f64f0f
|
Sander van Leeuwen
|
<div class="table-responsive">
|
508 |
|
|
<table class="table table-striped table-hover">
|
509 |
41ea4cf3
|
Sjon Hortensius
|
<thead>
|
510 |
|
|
<tr>
|
511 |
|
|
<th><?=gettext("Interface")?></th>
|
512 |
|
|
<th><?=gettext("Network port")?></th>
|
513 |
290566ed
|
NOYB
|
<th> </th>
|
514 |
41ea4cf3
|
Sjon Hortensius
|
</tr>
|
515 |
|
|
</thead>
|
516 |
|
|
<tbody>
|
517 |
1b0e073e
|
Renato Botelho
|
<?php
|
518 |
41ea4cf3
|
Sjon Hortensius
|
foreach ($config['interfaces'] as $ifname => $iface):
|
519 |
aa82505e
|
Phil Davis
|
if ($iface['descr']) {
|
520 |
41ea4cf3
|
Sjon Hortensius
|
$ifdescr = $iface['descr'];
|
521 |
aa82505e
|
Phil Davis
|
} else {
|
522 |
41ea4cf3
|
Sjon Hortensius
|
$ifdescr = strtoupper($ifname);
|
523 |
aa82505e
|
Phil Davis
|
}
|
524 |
7c611a3e
|
Renato Botelho
|
?>
|
525 |
41ea4cf3
|
Sjon Hortensius
|
<tr>
|
526 |
4401107f
|
Steve Beaver
|
<td><a href="/interfaces.php?if=<?=$ifname?>"><?=$ifdescr?></a></td>
|
527 |
41ea4cf3
|
Sjon Hortensius
|
<td>
|
528 |
|
|
<select name="<?=$ifname?>" id="<?=$ifname?>" class="form-control">
|
529 |
|
|
<?php foreach ($portlist as $portname => $portinfo):?>
|
530 |
c4b60a9a
|
Colin Fleming
|
<option value="<?=$portname?>" <?=($portname == $iface['if']) ? ' selected': ''?>>
|
531 |
41ea4cf3
|
Sjon Hortensius
|
<?=interface_assign_description($portinfo, $portname)?>
|
532 |
|
|
</option>
|
533 |
|
|
<?php endforeach;?>
|
534 |
|
|
</select>
|
535 |
|
|
</td>
|
536 |
|
|
<td>
|
537 |
|
|
<?php if ($ifname != 'wan'):?>
|
538 |
4419e274
|
Stephen Beaver
|
<button type="submit" name="del[<?=$ifname?>]" class="btn btn-danger btn-sm" title="<?=gettext("Delete interface")?>">
|
539 |
|
|
<i class="fa fa-trash icon-embed-btn"></i>
|
540 |
6a667f30
|
Stephen Beaver
|
<?=gettext("Delete")?>
|
541 |
4419e274
|
Stephen Beaver
|
</button>
|
542 |
41ea4cf3
|
Sjon Hortensius
|
<?php endif;?>
|
543 |
|
|
</td>
|
544 |
|
|
</tr>
|
545 |
|
|
<?php endforeach;
|
546 |
|
|
if (count($config['interfaces']) < count($portlist)):
|
547 |
1b0e073e
|
Renato Botelho
|
?>
|
548 |
41ea4cf3
|
Sjon Hortensius
|
<tr>
|
549 |
|
|
<th>
|
550 |
|
|
<?=gettext("Available network ports:")?>
|
551 |
|
|
</th>
|
552 |
|
|
<td>
|
553 |
|
|
<select name="if_add" id="if_add" class="form-control">
|
554 |
|
|
<?php foreach ($unused_portlist as $portname => $portinfo):?>
|
555 |
c4b60a9a
|
Colin Fleming
|
<option value="<?=$portname?>" <?=($portname == $iface['if']) ? ' selected': ''?>>
|
556 |
41ea4cf3
|
Sjon Hortensius
|
<?=interface_assign_description($portinfo, $portname)?>
|
557 |
|
|
</option>
|
558 |
|
|
<?php endforeach;?>
|
559 |
|
|
</select>
|
560 |
|
|
</td>
|
561 |
|
|
<td>
|
562 |
4419e274
|
Stephen Beaver
|
<button type="submit" name="add" title="<?=gettext("Add selected interface")?>" value="add interface" class="btn btn-success btn-sm" >
|
563 |
|
|
<i class="fa fa-plus icon-embed-btn"></i>
|
564 |
6a667f30
|
Stephen Beaver
|
<?=gettext("Add")?>
|
565 |
4419e274
|
Stephen Beaver
|
</button>
|
566 |
41ea4cf3
|
Sjon Hortensius
|
</td>
|
567 |
|
|
</tr>
|
568 |
|
|
<?php endif;?>
|
569 |
|
|
</tbody>
|
570 |
|
|
</table>
|
571 |
89f64f0f
|
Sander van Leeuwen
|
</div>
|
572 |
41ea4cf3
|
Sjon Hortensius
|
|
573 |
27d6a45b
|
jim-p
|
<button name="Submit" type="submit" class="btn btn-primary" value="<?=gettext('Save')?>"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
|
574 |
5b237745
|
Scott Ullrich
|
</form>
|
575 |
4419e274
|
Stephen Beaver
|
<br />
|
576 |
7c945f74
|
k-paulius
|
|
577 |
|
|
<?php
|
578 |
481db4fe
|
jim-p
|
print_info_box(gettext("Interfaces that are configured as members of a lagg(4) interface will not be shown.") .
|
579 |
|
|
'<br/><br/>' .
|
580 |
|
|
gettext("Wireless interfaces must be created on the Wireless tab before they can be assigned."), 'info', false);
|
581 |
7c945f74
|
k-paulius
|
?>
|
582 |
89f64f0f
|
Sander van Leeuwen
|
|
583 |
bfa7b33e
|
doktornotor
|
<?php include("foot.inc")?>
|