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