Revision 87489e5c
Added by Peter Schofield over 7 years ago
src/etc/inc/interfaces_fast.inc | ||
---|---|---|
1 |
<?php |
|
2 |
/* |
|
3 |
* interfaces_fast.inc |
|
4 |
* |
|
5 |
* part of pfSense (https://www.pfsense.org) |
|
6 |
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate) (pfSense) |
|
7 |
* Copyright (c) 2017 Peter Schofield (parts of this file) |
|
8 |
* All rights reserved. |
|
9 |
* |
|
10 |
* originally based on m0n0wall (http://m0n0.ch/wall) |
|
11 |
* Copyright (c) 2004 Manuel Kasper <mk@neon1.net>. |
|
12 |
* All rights reserved. |
|
13 |
* |
|
14 |
* 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 |
* |
|
18 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
19 |
* |
|
20 |
* 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 |
* |
|
26 |
* |
|
27 |
* This file contains rewrites of several functions, from both interfaces.inc |
|
28 |
* and interfaces_assign.php. The general purpose of these rewrites is not |
|
29 |
* necessarily to be faster in and of themselves, though they may be, but to |
|
30 |
* replace functions called multiple times with a function that's called only |
|
31 |
* once. This results in a significant speedup because there are far fewer |
|
32 |
* function calls, fewer loops and suchlike. It does, however, increase memory |
|
33 |
* usage somewhat, but it shouldn't be significant in the grand scheme of things. |
|
34 |
* |
|
35 |
* |
|
36 |
* Functions in this file may not require/use parameters when called, however |
|
37 |
* in most cases they will accept parameters as per their original forms, for |
|
38 |
* consistency. |
|
39 |
|
|
40 |
*/ |
|
41 |
require_once('interfaces.inc'); |
|
42 |
/* |
|
43 |
* does_interface_exist_fast |
|
44 |
Returns an array of interfaces which exist on the system. |
|
45 |
The $interface parameter is not used, but is accepted for |
|
46 |
consistency with the function it replaces. |
|
47 |
*/ |
|
48 |
function does_interface_exist_fast($interface='', $flush = true) { |
|
49 |
global $config; |
|
50 |
|
|
51 |
$ints = get_interface_arr($flush); |
|
52 |
return array_flip($ints); |
|
53 |
} |
|
54 |
|
|
55 |
/* |
|
56 |
* convert_real_interface_to_friendly_interface_name_fast($interface): convert fxp0 -> wan, etc. |
|
57 |
Returns an array of interfaces and friendly names. |
|
58 |
*/ |
|
59 |
function convert_real_interface_to_friendly_interface_name_fast() { |
|
60 |
global $config; |
|
61 |
|
|
62 |
$out = array(); |
|
63 |
/* XXX: For speed reasons reference directly the interface array */ |
|
64 |
$ifdescrs = &$config['interfaces']; |
|
65 |
$iffriendlynames = array_keys($ifdescrs); |
|
66 |
$out = array_flip(get_real_interface_fast($iffriendlynames)); |
|
67 |
return $out; |
|
68 |
} |
|
69 |
|
|
70 |
/* |
|
71 |
* get_real_interface_fast($interfaces, ...) |
|
72 |
* Exactly the same as it's namesake, except it takes an array of interfaces and returns an array |
|
73 |
* |
|
74 |
*/ |
|
75 |
|
|
76 |
function get_real_interface_fast($interfaces = array(), $family = "all", $realv6iface = false, $flush = true) { |
|
77 |
global $config, $g; |
|
78 |
|
|
79 |
$existing_ifs = does_interface_exist_fast(); |
|
80 |
|
|
81 |
$out = array(); |
|
82 |
foreach ($interfaces as $interface) { |
|
83 |
$wanif = NULL; |
|
84 |
|
|
85 |
switch ($interface) { |
|
86 |
case "l2tp": |
|
87 |
$wanif = "l2tp"; |
|
88 |
break; |
|
89 |
case "pptp": |
|
90 |
$wanif = "pptp"; |
|
91 |
break; |
|
92 |
case "pppoe": |
|
93 |
$wanif = "pppoe"; |
|
94 |
break; |
|
95 |
case "openvpn": |
|
96 |
$wanif = "openvpn"; |
|
97 |
break; |
|
98 |
case "IPsec": |
|
99 |
case "ipsec": |
|
100 |
case "enc0": |
|
101 |
$wanif = "enc0"; |
|
102 |
break; |
|
103 |
case "ppp": |
|
104 |
$wanif = "ppp"; |
|
105 |
break; |
|
106 |
default: |
|
107 |
if (substr($interface, 0, 4) == '_vip') { |
|
108 |
$wanif = get_configured_vip_interface($interface); |
|
109 |
if (!empty($wanif)) { |
|
110 |
$wanif = get_real_interface($wanif); |
|
111 |
} |
|
112 |
break; |
|
113 |
} else if (substr($interface, 0, 5) == '_lloc') { |
|
114 |
$interface = substr($interface, 5); |
|
115 |
} else if (strstr($interface, "_vlan") || isset($existing_ifs[$interface])) { |
|
116 |
/* |
|
117 |
* If a real interface was already passed simply |
|
118 |
* pass the real interface back. This encourages |
|
119 |
* the usage of this function in more cases so that |
|
120 |
* we can combine logic for more flexibility. |
|
121 |
*/ |
|
122 |
$wanif = $interface; |
|
123 |
break; |
|
124 |
} |
|
125 |
|
|
126 |
if (empty($config['interfaces'][$interface])) { |
|
127 |
break; |
|
128 |
} |
|
129 |
|
|
130 |
$cfg = &$config['interfaces'][$interface]; |
|
131 |
|
|
132 |
if ($family == "inet6") { |
|
133 |
switch ($cfg['ipaddrv6']) { |
|
134 |
case "6rd": |
|
135 |
case "6to4": |
|
136 |
$wanif = "{$interface}_stf"; |
|
137 |
break; |
|
138 |
case 'pppoe': |
|
139 |
case 'ppp': |
|
140 |
case 'l2tp': |
|
141 |
case 'pptp': |
|
142 |
if (is_array($cfg['wireless']) || preg_match($g['wireless_regex'], $cfg['if'])) { |
|
143 |
$wanif = interface_get_wireless_clone($cfg['if']); |
|
144 |
} else { |
|
145 |
$wanif = $cfg['if']; |
|
146 |
} |
|
147 |
break; |
|
148 |
default: |
|
149 |
switch ($cfg['ipaddr']) { |
|
150 |
case 'pppoe': |
|
151 |
case 'ppp': |
|
152 |
case 'l2tp': |
|
153 |
case 'pptp': |
|
154 |
if (isset($cfg['dhcp6usev4iface']) && $realv6iface === false) { |
|
155 |
$wanif = $cfg['if']; |
|
156 |
} else { |
|
157 |
$parents = get_parent_interface($interface); |
|
158 |
if (!empty($parents[0])) { |
|
159 |
$wanif = $parents[0]; |
|
160 |
} else { |
|
161 |
$wanif = $cfg['if']; |
|
162 |
} |
|
163 |
} |
|
164 |
break; |
|
165 |
default: |
|
166 |
if (is_array($cfg['wireless']) || preg_match($g['wireless_regex'], $cfg['if'])) { |
|
167 |
$wanif = interface_get_wireless_clone($cfg['if']); |
|
168 |
} else { |
|
169 |
$wanif = $cfg['if']; |
|
170 |
} |
|
171 |
break; |
|
172 |
} |
|
173 |
break; |
|
174 |
} |
|
175 |
} else { |
|
176 |
// Wireless cloned NIC support (FreeBSD 8+) |
|
177 |
// interface name format: $parentnic_wlanparentnic# |
|
178 |
// example: ath0_wlan0 |
|
179 |
if (is_array($cfg['wireless']) || preg_match($g['wireless_regex'], $cfg['if'])) { |
|
180 |
$wanif = interface_get_wireless_clone($cfg['if']); |
|
181 |
} else { |
|
182 |
$wanif = $cfg['if']; |
|
183 |
} |
|
184 |
} |
|
185 |
break; |
|
186 |
} |
|
187 |
$out[$interface] = $wanif; |
|
188 |
} |
|
189 |
|
|
190 |
return $out; |
|
191 |
} |
|
192 |
/* |
|
193 |
* interface_assign_description_fast($portlist, $friendlyifnames) |
|
194 |
* |
|
195 |
* This function replaces the function defined in interfaces_assign.php |
|
196 |
* |
|
197 |
* I created this version of the function because in interfaces_assign.php |
|
198 |
* the interface_assign_description() function is used twice, in both cases |
|
199 |
* being called for every iteration through the array of interfaces, and |
|
200 |
* was seemingly dragging the performance of the HTML generation code down |
|
201 |
* when faced with a large number of VLAN interfaces. |
|
202 |
* |
|
203 |
* Although this function internally recreates the loop that its namesake was |
|
204 |
* called in; the fact it's only called once rather than once per interface * 2 |
|
205 |
* has resulted in a significant speed gain with a large number of optional |
|
206 |
* interfaces configured. |
|
207 |
* |
|
208 |
* $portlist is the same $portlist as defined in interfaces_assign.php, call this |
|
209 |
* function after all the optional interfaces are added to $portlist. |
|
210 |
* |
|
211 |
* $friendlyifnames is a global variable of my own making, created by calling |
|
212 |
* convert_real_interface_to_friendly_interface_name_fast() on the keys of $portlist. |
|
213 |
* |
|
214 |
* Return value of this function is an associative array of interface descriptions |
|
215 |
* indexed by the unique name of the interface. |
|
216 |
* |
|
217 |
*/ |
|
218 |
function interface_assign_description_fast($portlist, $friendlyifnames) { |
|
219 |
global $ovpn_descrs; |
|
220 |
$out = array(); |
|
221 |
$gettext = gettext('on'); |
|
222 |
foreach($portlist as $portname => $portinfo) { |
|
223 |
if ($portinfo['isvlan']) { |
|
224 |
$descr = sprintf('VLAN %1$s '.$gettext.' %2$s', $portinfo['tag'], $portinfo['if']); |
|
225 |
$iface = $friendlyifnames[$portinfo['if']]; |
|
226 |
if (isset($iface) && strlen($iface) > 0) { |
|
227 |
$descr .= " - $iface"; |
|
228 |
} |
|
229 |
if ($portinfo['descr']) { |
|
230 |
$descr .= " (" . $portinfo['descr'] . ")"; |
|
231 |
} |
|
232 |
} elseif ($portinfo['iswlclone']) { |
|
233 |
$descr = $portinfo['cloneif']; |
|
234 |
if ($portinfo['descr']) { |
|
235 |
$descr .= " (" . $portinfo['descr'] . ")"; |
|
236 |
} |
|
237 |
} elseif ($portinfo['isppp']) { |
|
238 |
$descr = $portinfo['descr']; |
|
239 |
} elseif ($portinfo['isbridge']) { |
|
240 |
$descr = strtoupper($portinfo['bridgeif']); |
|
241 |
if ($portinfo['descr']) { |
|
242 |
$descr .= " (" . $portinfo['descr'] . ")"; |
|
243 |
} |
|
244 |
} elseif ($portinfo['isgre']) { |
|
245 |
$descr = "GRE {$portinfo['remote-addr']}"; |
|
246 |
if ($portinfo['descr']) { |
|
247 |
$descr .= " (" . $portinfo['descr'] . ")"; |
|
248 |
} |
|
249 |
} elseif ($portinfo['isgif']) { |
|
250 |
$descr = "GIF {$portinfo['remote-addr']}"; |
|
251 |
if ($portinfo['descr']) { |
|
252 |
$descr .= " (" . $portinfo['descr'] . ")"; |
|
253 |
} |
|
254 |
} elseif ($portinfo['islagg']) { |
|
255 |
$descr = strtoupper($portinfo['laggif']); |
|
256 |
if ($portinfo['descr']) { |
|
257 |
$descr .= " (" . $portinfo['descr'] . ")"; |
|
258 |
} |
|
259 |
} elseif ($portinfo['isqinq']) { |
|
260 |
$descr = $portinfo['descr']; |
|
261 |
} elseif (substr($portname, 0, 4) == 'ovpn') { |
|
262 |
$descr = $portname . " (" . $ovpn_descrs[substr($portname, 5)] . ")"; |
|
263 |
} else { |
|
264 |
$descr = $portname . " (" . $portinfo['mac'] . ")"; |
|
265 |
} |
|
266 |
$out[$portname] = htmlspecialchars($descr); |
|
267 |
} |
|
268 |
return $out; |
|
269 |
} |
|
270 |
?> |
src/usr/local/www/interfaces_assign.php | ||
---|---|---|
3 | 3 |
* interfaces_assign.php |
4 | 4 |
* |
5 | 5 |
* part of pfSense (https://www.pfsense.org) |
6 |
* Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
|
|
6 |
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
|
7 | 7 |
* All rights reserved. |
8 | 8 |
* |
9 | 9 |
* originally based on m0n0wall (http://m0n0.ch/wall) |
... | ... | |
31 | 31 |
##|*MATCH=interfaces_assign.php* |
32 | 32 |
##|-PRIV |
33 | 33 |
|
34 |
//$timealla = microtime(true); |
|
35 |
|
|
34 | 36 |
$pgtitle = array(gettext("Interfaces"), gettext("Interface Assignments")); |
35 | 37 |
$shortcut_section = "interfaces"; |
36 | 38 |
|
... | ... | |
42 | 44 |
require_once("vpn.inc"); |
43 | 45 |
require_once("captiveportal.inc"); |
44 | 46 |
require_once("rrd.inc"); |
47 |
require_once("interfaces_fast.inc"); |
|
45 | 48 |
|
46 |
function interface_assign_description($portinfo, $portname) { |
|
47 |
global $ovpn_descrs; |
|
48 |
if ($portinfo['isvlan']) { |
|
49 |
$descr = sprintf(gettext('VLAN %1$s on %2$s'), $portinfo['tag'], $portinfo['if']); |
|
50 |
$iface = convert_real_interface_to_friendly_interface_name($portinfo['if']); |
|
51 |
if (isset($iface) && strlen($iface) > 0) { |
|
52 |
$descr .= " - $iface"; |
|
53 |
} |
|
54 |
if ($portinfo['descr']) { |
|
55 |
$descr .= " (" . $portinfo['descr'] . ")"; |
|
56 |
} |
|
57 |
} elseif ($portinfo['iswlclone']) { |
|
58 |
$descr = $portinfo['cloneif']; |
|
59 |
if ($portinfo['descr']) { |
|
60 |
$descr .= " (" . $portinfo['descr'] . ")"; |
|
61 |
} |
|
62 |
} elseif ($portinfo['isppp']) { |
|
63 |
$descr = $portinfo['descr']; |
|
64 |
} elseif ($portinfo['isbridge']) { |
|
65 |
$descr = strtoupper($portinfo['bridgeif']); |
|
66 |
if ($portinfo['descr']) { |
|
67 |
$descr .= " (" . $portinfo['descr'] . ")"; |
|
68 |
} |
|
69 |
} elseif ($portinfo['isgre']) { |
|
70 |
$descr = "GRE {$portinfo['remote-addr']}"; |
|
71 |
if ($portinfo['descr']) { |
|
72 |
$descr .= " (" . $portinfo['descr'] . ")"; |
|
73 |
} |
|
74 |
} elseif ($portinfo['isgif']) { |
|
75 |
$descr = "GIF {$portinfo['remote-addr']}"; |
|
76 |
if ($portinfo['descr']) { |
|
77 |
$descr .= " (" . $portinfo['descr'] . ")"; |
|
78 |
} |
|
79 |
} elseif ($portinfo['islagg']) { |
|
80 |
$descr = strtoupper($portinfo['laggif']); |
|
81 |
$descr .= " (" . $portinfo['mac'] . ")"; |
|
82 |
if ($portinfo['descr']) { |
|
83 |
$descr .= " - " . $portinfo['descr']; |
|
84 |
} |
|
85 |
} elseif ($portinfo['isqinq']) { |
|
86 |
$descr = $portinfo['descr']; |
|
87 |
} elseif (substr($portname, 0, 4) == 'ovpn') { |
|
88 |
$descr = $portname . " (" . $ovpn_descrs[substr($portname, 5)] . ")"; |
|
89 |
} else { |
|
90 |
$descr = $portname . " (" . $portinfo['mac'] . ")"; |
|
91 |
} |
|
49 |
global $friendlyifnames; |
|
92 | 50 |
|
93 |
return htmlspecialchars($descr);
|
|
94 |
}
|
|
51 |
/*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'));
|
|
95 | 53 |
|
96 | 54 |
/* |
97 | 55 |
In this file, "port" refers to the physical port name, |
... | ... | |
101 | 59 |
/* get list without VLAN interfaces */ |
102 | 60 |
$portlist = get_interface_list(); |
103 | 61 |
|
62 |
/*another *_fast function from interfaces_fast.inc. These functions are basically the same as the |
|
63 |
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 |
|
|
104 | 67 |
/* add wireless clone interfaces */ |
105 | 68 |
if (is_array($config['wireless']['clone']) && count($config['wireless']['clone'])) { |
106 | 69 |
foreach ($config['wireless']['clone'] as $clone) { |
... | ... | |
111 | 74 |
|
112 | 75 |
/* add VLAN interfaces */ |
113 | 76 |
if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) { |
77 |
//$timea = microtime(true); |
|
114 | 78 |
foreach ($config['vlans']['vlan'] as $vlan) { |
115 | 79 |
$portlist[$vlan['vlanif']] = $vlan; |
116 | 80 |
$portlist[$vlan['vlanif']]['isvlan'] = true; |
... | ... | |
142 | 106 |
} |
143 | 107 |
|
144 | 108 |
/* add LAGG interfaces */ |
145 |
$lagglist = get_lagg_interface_list(); |
|
146 |
$portlist = array_merge($portlist, $lagglist); |
|
147 |
foreach ($lagglist as $laggif => $lagg) { |
|
148 |
/* LAGG members cannot be assigned */ |
|
149 |
$laggmembers = explode(',', $lagg['members']); |
|
150 |
foreach ($laggmembers as $lagm) { |
|
151 |
if (isset($portlist[$lagm])) { |
|
152 |
unset($portlist[$lagm]); |
|
109 |
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 |
} |
|
153 | 119 |
} |
154 | 120 |
} |
155 | 121 |
} |
... | ... | |
162 | 128 |
/* QinQ members */ |
163 | 129 |
$qinqifs = explode(' ', $qinq['members']); |
164 | 130 |
foreach ($qinqifs as $qinqif) { |
165 |
$portlist["{$qinq['vlanif']}.{$qinqif}"]['descr'] = "QinQ {$qinqif} on VLAN {$qinq['tag']} on {$qinq['if']}";
|
|
166 |
$portlist["{$qinq['vlanif']}.{$qinqif}"]['isqinq'] = true;
|
|
131 |
$portlist["{$qinq['vlanif']}_{$qinqif}"]['descr'] = "QinQ {$qinqif} on VLAN {$qinq['tag']} on {$qinq['if']}";
|
|
132 |
$portlist["{$qinq['vlanif']}_{$qinqif}"]['isqinq'] = true;
|
|
167 | 133 |
} |
168 | 134 |
} |
169 | 135 |
} |
... | ... | |
203 | 169 |
} |
204 | 170 |
} |
205 | 171 |
|
172 |
|
|
173 |
$ifdescrs = interface_assign_description_fast($portlist,$friendlyifnames); |
|
174 |
|
|
206 | 175 |
if (isset($_REQUEST['add']) && isset($_REQUEST['if_add'])) { |
207 | 176 |
/* Be sure this port is not being used */ |
208 | 177 |
$portused = false; |
... | ... | |
227 | 196 |
$newifname = 'opt' . $i; |
228 | 197 |
$descr = "OPT" . $i; |
229 | 198 |
} |
230 |
|
|
199 |
|
|
231 | 200 |
$config['interfaces'][$newifname] = array(); |
232 | 201 |
$config['interfaces'][$newifname]['descr'] = $descr; |
233 | 202 |
$config['interfaces'][$newifname]['if'] = $_POST['if_add']; |
... | ... | |
236 | 205 |
interface_sync_wireless_clones($config['interfaces'][$newifname], false); |
237 | 206 |
} |
238 | 207 |
|
208 |
|
|
239 | 209 |
uksort($config['interfaces'], "compare_interface_friendly_names"); |
240 | 210 |
|
241 | 211 |
/* XXX: Do not remove this. */ |
... | ... | |
365 | 335 |
} |
366 | 336 |
} |
367 | 337 |
} |
368 |
|
|
369 | 338 |
write_config(); |
370 | 339 |
|
371 | 340 |
enable_rrd_graphing(); |
... | ... | |
441 | 410 |
|
442 | 411 |
/* Create a list of unused ports */ |
443 | 412 |
$unused_portlist = array(); |
444 |
foreach ($portlist as $portname => $portinfo) { |
|
445 |
$portused = false; |
|
446 |
foreach ($config['interfaces'] as $ifname => $ifdata) { |
|
447 |
if ($ifdata['if'] == $portname) { |
|
448 |
$portused = true; |
|
449 |
break; |
|
450 |
} |
|
451 |
} |
|
452 |
if ($portused === false) { |
|
453 |
$unused_portlist[$portname] = $portinfo; |
|
454 |
} |
|
455 |
} |
|
413 |
$portArray = array_keys($portlist); |
|
414 |
|
|
415 |
$ifaceArray = array_column($config['interfaces'],'if'); |
|
416 |
$unused = array_diff($portArray,$ifaceArray); |
|
417 |
$unused = array_flip($unused); |
|
418 |
$unused_portlist = array_intersect_key($portlist,$unused);//*/ |
|
419 |
unset($unused,$portArray,$ifaceArray); |
|
456 | 420 |
|
457 | 421 |
include("head.inc"); |
458 | 422 |
|
... | ... | |
501 | 465 |
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php"); |
502 | 466 |
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php"); |
503 | 467 |
display_top_tabs($tab_array); |
468 |
|
|
469 |
/*Generate the port select box only once. |
|
470 |
Not indenting the HTML to produce smaller code |
|
471 |
and faster page load times */ |
|
472 |
|
|
473 |
$portselect=''; |
|
474 |
foreach ($portlist as $portname => $portinfo) { |
|
475 |
$portselect.='<option value="'.$portname.'"'; |
|
476 |
$portselect.=">".$ifdescrs[$portname]."</option>\n"; |
|
477 |
} |
|
478 |
|
|
504 | 479 |
?> |
505 | 480 |
<form action="interfaces_assign.php" method="post"> |
506 | 481 |
<div class="table-responsive"> |
... | ... | |
514 | 489 |
</thead> |
515 | 490 |
<tbody> |
516 | 491 |
<?php |
492 |
$i=0; |
|
517 | 493 |
foreach ($config['interfaces'] as $ifname => $iface): |
518 | 494 |
if ($iface['descr']) { |
519 | 495 |
$ifdescr = $iface['descr']; |
... | ... | |
525 | 501 |
<td><a href="/interfaces.php?if=<?=$ifname?>"><?=$ifdescr?></a></td> |
526 | 502 |
<td> |
527 | 503 |
<select name="<?=$ifname?>" id="<?=$ifname?>" class="form-control"> |
528 |
<?php foreach ($portlist as $portname => $portinfo):?> |
|
529 |
<option value="<?=$portname?>" <?=($portname == $iface['if']) ? ' selected': ''?>> |
|
530 |
<?=interface_assign_description($portinfo, $portname)?> |
|
531 |
</option> |
|
532 |
<?php endforeach;?> |
|
504 |
<?php |
|
505 |
/*port select menu generation loop replaced with pre-prepared select menu to reduce page generation time */ |
|
506 |
echo str_replace('value="'.$iface['if'].'">','value="'.$iface['if'].'" selected>',$portselect); |
|
507 |
?> |
|
533 | 508 |
</select> |
534 | 509 |
</td> |
535 | 510 |
<td> |
536 | 511 |
<?php if ($ifname != 'wan'):?> |
537 |
<button type="submit" name="del[<?=$ifname?>]" class="btn btn-danger btn-sm" title="<?=gettext("Delete interface")?>">
|
|
512 |
<button type="submit" name="del[<?=$ifname?>]" class="btn btn-danger btn-sm" title="<?=$gettextArray['deleteif']?>">
|
|
538 | 513 |
<i class="fa fa-trash icon-embed-btn"></i> |
539 |
<?=gettext("Delete")?>
|
|
514 |
<?=$gettextArray["delete"]?>
|
|
540 | 515 |
</button> |
541 | 516 |
<?php endif;?> |
542 | 517 |
</td> |
543 | 518 |
</tr> |
544 |
<?php endforeach; |
|
519 |
<?php $i++; |
|
520 |
endforeach; |
|
545 | 521 |
if (count($config['interfaces']) < count($portlist)): |
546 | 522 |
?> |
547 | 523 |
<tr> |
... | ... | |
550 | 526 |
</th> |
551 | 527 |
<td> |
552 | 528 |
<select name="if_add" id="if_add" class="form-control"> |
553 |
<?php foreach ($unused_portlist as $portname => $portinfo):?> |
|
554 |
<option value="<?=$portname?>" <?=($portname == $iface['if']) ? ' selected': ''?>> |
|
555 |
<?=interface_assign_description($portinfo, $portname)?> |
|
556 |
</option> |
|
557 |
<?php endforeach;?> |
|
529 |
<?php |
|
530 |
/* HTML not indented to save on transmission/render time */ |
|
531 |
foreach ($unused_portlist as $portname => $portinfo):?> |
|
532 |
<option value="<?=$portname?>" <?=($portname == $iface['if']) ? ' selected': ''?>><?=$ifdescrs[$portname]?></option> |
|
533 |
<?php endforeach; |
|
534 |
?> |
|
558 | 535 |
</select> |
559 | 536 |
</td> |
560 | 537 |
<td> |
561 | 538 |
<button type="submit" name="add" title="<?=gettext("Add selected interface")?>" value="add interface" class="btn btn-success btn-sm" > |
562 | 539 |
<i class="fa fa-plus icon-embed-btn"></i> |
563 |
<?=gettext("Add")?>
|
|
540 |
<?=$gettextArray["add"]?>
|
|
564 | 541 |
</button> |
565 | 542 |
</td> |
566 | 543 |
</tr> |
src/usr/local/www/interfaces_vlan.php | ||
---|---|---|
3 | 3 |
* interfaces_vlan.php |
4 | 4 |
* |
5 | 5 |
* part of pfSense (https://www.pfsense.org) |
6 |
* Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
|
|
6 |
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
|
7 | 7 |
* All rights reserved. |
8 | 8 |
* |
9 | 9 |
* originally based on m0n0wall (http://m0n0.ch/wall) |
... | ... | |
27 | 27 |
##|*IDENT=page-interfaces-vlan |
28 | 28 |
##|*NAME=Interfaces: VLAN |
29 | 29 |
##|*DESCR=Allow access to the 'Interfaces: VLAN' page. |
30 |
##|*MATCH=interfaces_vlan.php* |
|
30 |
##|*MATCH=interfaces_vlan_new_prof.php*
|
|
31 | 31 |
##|-PRIV |
32 | 32 |
|
33 | 33 |
require_once("guiconfig.inc"); |
34 |
require_once("interfaces_fast.inc"); |
|
35 |
|
|
36 |
global $profile; |
|
34 | 37 |
|
35 | 38 |
if (!is_array($config['vlans']['vlan'])) { |
36 | 39 |
$config['vlans']['vlan'] = array(); |
37 | 40 |
} |
38 | 41 |
|
39 |
$a_vlans = &$config['vlans']['vlan']; |
|
42 |
$a_vlans = &$config['vlans']['vlan'] ;
|
|
40 | 43 |
|
41 | 44 |
if ($_POST['act'] == "del") { |
42 | 45 |
if (!isset($_POST['id'])) { |
... | ... | |
101 | 104 |
<tbody> |
102 | 105 |
<?php |
103 | 106 |
$i = 0; |
107 |
$gettext_array = array('edit'=>gettext('Edit VLAN'),'del'=>gettext('Delete VLAN')); |
|
108 |
$ifaces = convert_real_interface_to_friendly_interface_name_fast(array()); |
|
104 | 109 |
foreach ($a_vlans as $vlan) { |
105 | 110 |
?> |
106 | 111 |
<tr> |
107 | 112 |
<td> |
108 | 113 |
<?php |
109 | 114 |
printf("%s", htmlspecialchars($vlan['if'])); |
110 |
$iface = convert_real_interface_to_friendly_interface_name($vlan['if']); |
|
111 |
if (isset($iface) && strlen($iface) > 0) |
|
112 |
printf(" (%s)", htmlspecialchars($iface)); |
|
115 |
if (isset($ifaces[$vlan['if']]) && strlen($ifaces[$vlan['if']]) > 0) |
|
116 |
printf(" (%s)", htmlspecialchars($ifaces[$vlan['if']])); |
|
113 | 117 |
?> |
114 | 118 |
</td> |
115 | 119 |
<td><?=htmlspecialchars($vlan['tag']);?></td> |
116 | 120 |
<td><?=htmlspecialchars($vlan['pcp']);?></td> |
117 | 121 |
<td><?=htmlspecialchars($vlan['descr']);?></td> |
118 | 122 |
<td> |
119 |
<a class="fa fa-pencil" title="<?=gettext('Edit VLAN')?>" role="button" href="interfaces_vlan_edit.php?id=<?=$i?>" ></a>
|
|
120 |
<a class="fa fa-trash no-confirm" title="<?=gettext('Delete VLAN')?>" role="button" id="del-<?=$i?>"></a>
|
|
123 |
<a class="fa fa-pencil" title="<?=$gettext_array['edit']?>" role="button" href="interfaces_vlan_edit.php?id=<?=$i?>" ></a>
|
|
124 |
<a class="fa fa-trash no-confirm" title="<?=$gettext_array['del']?>" role="button" id="del-<?=$i?>"></a>
|
|
121 | 125 |
</td> |
122 | 126 |
</tr> |
123 | 127 |
<?php |
Also available in: Unified diff
re-adding changes made to fix bug#6400, includes fixes for bug#8222 and bug#8223 that were introduced with the initial commit of this code.
original pull request was #3868