1 |
648ec0c2
|
Ermal Luçi
|
<?php
|
2 |
|
|
/* $Id$ */
|
3 |
|
|
/*
|
4 |
|
|
interfaces_bridge_edit.php
|
5 |
|
|
|
6 |
ce77a9c4
|
Phil Davis
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
7 |
1d7ba683
|
ayvis
|
Copyright (C) 2008 Ermal Luçi
|
8 |
648ec0c2
|
Ermal Luçi
|
All rights reserved.
|
9 |
|
|
|
10 |
|
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
|
|
|
13 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
|
|
|
16 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
|
|
|
20 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
*/
|
31 |
7ac5a4cb
|
Scott Ullrich
|
/*
|
32 |
49c46b6a
|
sbeaver
|
pfSense_MODULE: interfaces
|
33 |
7ac5a4cb
|
Scott Ullrich
|
*/
|
34 |
648ec0c2
|
Ermal Luçi
|
|
35 |
ea9828af
|
Ermal Lu?i
|
##|+PRIV
|
36 |
|
|
##|*IDENT=page-interfaces-bridge-edit
|
37 |
|
|
##|*NAME=Interfaces: Bridge edit page
|
38 |
|
|
##|*DESCR=Allow access to the 'Interfaces: Bridge : Edit' page.
|
39 |
|
|
##|*MATCH=interfaces_bridge_edit.php*
|
40 |
|
|
##|-PRIV
|
41 |
|
|
|
42 |
648ec0c2
|
Ermal Luçi
|
require("guiconfig.inc");
|
43 |
|
|
|
44 |
3134528d
|
Ermal Luçi
|
if (!is_array($config['bridges']['bridged']))
|
45 |
|
|
$config['bridges']['bridged'] = array();
|
46 |
648ec0c2
|
Ermal Luçi
|
|
47 |
3134528d
|
Ermal Luçi
|
$a_bridges = &$config['bridges']['bridged'];
|
48 |
648ec0c2
|
Ermal Luçi
|
|
49 |
|
|
$ifacelist = get_configured_interface_with_descr();
|
50 |
79955084
|
sbeaver
|
|
51 |
d776efd8
|
Ermal
|
foreach ($ifacelist as $bif => $bdescr) {
|
52 |
2af86dda
|
Phil Davis
|
if (substr(get_real_interface($bif), 0, 3) == "gre") {
|
53 |
d776efd8
|
Ermal
|
unset($ifacelist[$bif]);
|
54 |
2af86dda
|
Phil Davis
|
}
|
55 |
d776efd8
|
Ermal
|
}
|
56 |
648ec0c2
|
Ermal Luçi
|
|
57 |
2af86dda
|
Phil Davis
|
if (is_numericint($_GET['id'])) {
|
58 |
e41ec584
|
Renato Botelho
|
$id = $_GET['id'];
|
59 |
2af86dda
|
Phil Davis
|
}
|
60 |
|
|
if (isset($_POST['id']) && is_numericint($_POST['id'])) {
|
61 |
648ec0c2
|
Ermal Luçi
|
$id = $_POST['id'];
|
62 |
2af86dda
|
Phil Davis
|
}
|
63 |
648ec0c2
|
Ermal Luçi
|
|
64 |
|
|
if (isset($id) && $a_bridges[$id]) {
|
65 |
|
|
$pconfig['enablestp'] = isset($a_bridges[$id]['enablestp']);
|
66 |
|
|
$pconfig['descr'] = $a_bridges[$id]['descr'];
|
67 |
|
|
$pconfig['bridgeif'] = $a_bridges[$id]['bridgeif'];
|
68 |
|
|
$pconfig['members'] = $a_bridges[$id]['members'];
|
69 |
|
|
$pconfig['maxaddr'] = $a_bridges[$id]['maxaddr'];
|
70 |
|
|
$pconfig['timeout'] = $a_bridges[$id]['timeout'];
|
71 |
2af86dda
|
Phil Davis
|
if ($a_bridges[$id]['static']) {
|
72 |
648ec0c2
|
Ermal Luçi
|
$pconfig['static'] = $a_bridges[$id]['static'];
|
73 |
2af86dda
|
Phil Davis
|
}
|
74 |
|
|
if ($a_bridges[$id]['private']) {
|
75 |
648ec0c2
|
Ermal Luçi
|
$pconfig['private'] = $a_bridges[$id]['private'];
|
76 |
2af86dda
|
Phil Davis
|
}
|
77 |
|
|
if (isset($a_bridges[$id]['stp'])) {
|
78 |
648ec0c2
|
Ermal Luçi
|
$pconfig['stp'] = $a_bridges[$id]['stp'];
|
79 |
2af86dda
|
Phil Davis
|
}
|
80 |
648ec0c2
|
Ermal Luçi
|
$pconfig['maxage'] = $a_bridges[$id]['maxage'];
|
81 |
|
|
$pconfig['fwdelay'] = $a_bridges[$id]['fwdelay'];
|
82 |
|
|
$pconfig['hellotime'] = $a_bridges[$id]['hellotime'];
|
83 |
|
|
$pconfig['priority'] = $a_bridges[$id]['priority'];
|
84 |
|
|
$pconfig['proto'] = $a_bridges[$id]['proto'];
|
85 |
afd825a7
|
bcyrill
|
$pconfig['holdcnt'] = $a_bridges[$id]['holdcnt'];
|
86 |
79955084
|
sbeaver
|
|
87 |
95e174f1
|
Darren Embry
|
if (!empty($a_bridges[$id]['ifpriority'])) {
|
88 |
|
|
$pconfig['ifpriority'] = explode(",", $a_bridges[$id]['ifpriority']);
|
89 |
|
|
$ifpriority = array();
|
90 |
|
|
foreach ($pconfig['ifpriority'] as $cfg) {
|
91 |
6c07db48
|
Phil Davis
|
list ($key, $value) = explode(":", $cfg);
|
92 |
95e174f1
|
Darren Embry
|
$embprioritycfg[$key] = $value;
|
93 |
|
|
foreach ($embprioritycfg as $key => $value) {
|
94 |
|
|
$ifpriority[$key] = $value;
|
95 |
|
|
}
|
96 |
|
|
}
|
97 |
|
|
$pconfig['ifpriority'] = $ifpriority;
|
98 |
648ec0c2
|
Ermal Luçi
|
}
|
99 |
79955084
|
sbeaver
|
|
100 |
95e174f1
|
Darren Embry
|
if (!empty($a_bridges[$id]['ifpathcost'])) {
|
101 |
|
|
$pconfig['ifpathcost'] = explode(",", $a_bridges[$id]['ifpathcost']);
|
102 |
|
|
$ifpathcost = array();
|
103 |
|
|
foreach ($pconfig['ifpathcost'] as $cfg) {
|
104 |
6c07db48
|
Phil Davis
|
list ($key, $value) = explode(":", $cfg);
|
105 |
95e174f1
|
Darren Embry
|
$embpathcfg[$key] = $value;
|
106 |
|
|
foreach ($embpathcfg as $key => $value) {
|
107 |
|
|
$ifpathcost[$key] = $value;
|
108 |
|
|
}
|
109 |
|
|
}
|
110 |
|
|
$pconfig['ifpathcost'] = $ifpathcost;
|
111 |
648ec0c2
|
Ermal Luçi
|
}
|
112 |
79955084
|
sbeaver
|
|
113 |
648ec0c2
|
Ermal Luçi
|
$pconfig['span'] = $a_bridges[$id]['span'];
|
114 |
2af86dda
|
Phil Davis
|
if (isset($a_bridges[$id]['edge'])) {
|
115 |
648ec0c2
|
Ermal Luçi
|
$pconfig['edge'] = $a_bridges[$id]['edge'];
|
116 |
2af86dda
|
Phil Davis
|
}
|
117 |
|
|
if (isset($a_bridges[$id]['autoedge'])) {
|
118 |
648ec0c2
|
Ermal Luçi
|
$pconfig['autoedge'] = $a_bridges[$id]['autoedge'];
|
119 |
2af86dda
|
Phil Davis
|
}
|
120 |
|
|
if (isset($a_bridges[$id]['ptp'])) {
|
121 |
648ec0c2
|
Ermal Luçi
|
$pconfig['ptp'] = $a_bridges[$id]['ptp'];
|
122 |
2af86dda
|
Phil Davis
|
}
|
123 |
|
|
if (isset($a_bridges[$id]['autoptp'])) {
|
124 |
648ec0c2
|
Ermal Luçi
|
$pconfig['autoptp'] = $a_bridges[$id]['autoptp'];
|
125 |
2af86dda
|
Phil Davis
|
}
|
126 |
648ec0c2
|
Ermal Luçi
|
}
|
127 |
|
|
|
128 |
|
|
if ($_POST) {
|
129 |
|
|
unset($input_errors);
|
130 |
|
|
$pconfig = $_POST;
|
131 |
|
|
|
132 |
|
|
/* input validation */
|
133 |
|
|
$reqdfields = explode(" ", "members");
|
134 |
eb4cf3cb
|
Neriberto C.Prado
|
$reqdfieldsn = array(gettext("Member Interfaces"));
|
135 |
648ec0c2
|
Ermal Luçi
|
|
136 |
1e9b4611
|
Renato Botelho
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
137 |
648ec0c2
|
Ermal Luçi
|
|
138 |
2af86dda
|
Phil Davis
|
if ($_POST['maxage'] && !is_numeric($_POST['maxage'])) {
|
139 |
eb4cf3cb
|
Neriberto C.Prado
|
$input_errors[] = gettext("Maxage needs to be an integer between 6 and 40.");
|
140 |
2af86dda
|
Phil Davis
|
}
|
141 |
|
|
if ($_POST['maxaddr'] && !is_numeric($_POST['maxaddr'])) {
|
142 |
eb4cf3cb
|
Neriberto C.Prado
|
$input_errors[] = gettext("Maxaddr needs to be an integer.");
|
143 |
2af86dda
|
Phil Davis
|
}
|
144 |
|
|
if ($_POST['timeout'] && !is_numeric($_POST['timeout'])) {
|
145 |
eb4cf3cb
|
Neriberto C.Prado
|
$input_errors[] = gettext("Timeout needs to be an integer.");
|
146 |
2af86dda
|
Phil Davis
|
}
|
147 |
|
|
if ($_POST['fwdelay'] && !is_numeric($_POST['fwdelay'])) {
|
148 |
eb4cf3cb
|
Neriberto C.Prado
|
$input_errors[] = gettext("Forward Delay needs to be an integer between 4 and 30.");
|
149 |
2af86dda
|
Phil Davis
|
}
|
150 |
|
|
if ($_POST['hellotime'] && !is_numeric($_POST['hellotime'])) {
|
151 |
eb4cf3cb
|
Neriberto C.Prado
|
$input_errors[] = gettext("Hello time for STP needs to be an integer between 1 and 2.");
|
152 |
2af86dda
|
Phil Davis
|
}
|
153 |
|
|
if ($_POST['priority'] && !is_numeric($_POST['priority'])) {
|
154 |
eb4cf3cb
|
Neriberto C.Prado
|
$input_errors[] = gettext("Priority for STP needs to be an integer between 0 and 61440.");
|
155 |
2af86dda
|
Phil Davis
|
}
|
156 |
|
|
if ($_POST['holdcnt'] && !is_numeric($_POST['holdcnt'])) {
|
157 |
eb4cf3cb
|
Neriberto C.Prado
|
$input_errors[] = gettext("Transmit Hold Count for STP needs to be an integer between 1 and 10.");
|
158 |
2af86dda
|
Phil Davis
|
}
|
159 |
648ec0c2
|
Ermal Luçi
|
foreach ($ifacelist as $ifn => $ifdescr) {
|
160 |
2af86dda
|
Phil Davis
|
if ($_POST[$ifn] <> "" && !is_numeric($_POST[$ifn])) {
|
161 |
eb4cf3cb
|
Neriberto C.Prado
|
$input_errors[] = "{$ifdescr} " . gettext("interface priority for STP needs to be an integer between 0 and 240.");
|
162 |
2af86dda
|
Phil Davis
|
}
|
163 |
648ec0c2
|
Ermal Luçi
|
}
|
164 |
79955084
|
sbeaver
|
|
165 |
648ec0c2
|
Ermal Luçi
|
$i = 0;
|
166 |
79955084
|
sbeaver
|
|
167 |
648ec0c2
|
Ermal Luçi
|
foreach ($ifacelist as $ifn => $ifdescr) {
|
168 |
2af86dda
|
Phil Davis
|
if ($_POST["{$ifn}{$i}"] <> "" && !is_numeric($_POST["{$ifn}{$i}"])) {
|
169 |
eb4cf3cb
|
Neriberto C.Prado
|
$input_errors[] = "{$ifdescr} " . gettext("interface path cost for STP needs to be an integer between 1 and 200000000.");
|
170 |
2af86dda
|
Phil Davis
|
}
|
171 |
648ec0c2
|
Ermal Luçi
|
$i++;
|
172 |
|
|
}
|
173 |
7a701b1e
|
Ermal Luçi
|
|
174 |
2af86dda
|
Phil Davis
|
if (!is_array($_POST['members']) || count($_POST['members']) < 1) {
|
175 |
3a292360
|
Chris Buechler
|
$input_errors[] = gettext("You must select at least one member interface for a bridge.");
|
176 |
2af86dda
|
Phil Davis
|
}
|
177 |
7a701b1e
|
Ermal Luçi
|
|
178 |
|
|
if (is_array($_POST['members'])) {
|
179 |
2af86dda
|
Phil Davis
|
foreach ($_POST['members'] as $ifmembers) {
|
180 |
|
|
if (empty($config['interfaces'][$ifmembers])) {
|
181 |
0e22dda5
|
Ermal
|
$input_errors[] = gettext("A member interface passed does not exist in configuration");
|
182 |
2af86dda
|
Phil Davis
|
}
|
183 |
7a701b1e
|
Ermal Luçi
|
if (is_array($config['interfaces'][$ifmembers]['wireless']) &&
|
184 |
2af86dda
|
Phil Davis
|
$config['interfaces'][$ifmembers]['wireless']['mode'] != "hostap") {
|
185 |
eb4cf3cb
|
Neriberto C.Prado
|
$input_errors[] = gettext("Bridging a wireless interface is only possible in hostap mode.");
|
186 |
2af86dda
|
Phil Davis
|
}
|
187 |
|
|
if ($_POST['span'] != "none" && $_POST['span'] == $ifmembers) {
|
188 |
eb4cf3cb
|
Neriberto C.Prado
|
$input_errors[] = gettext("Span interface cannot be part of the bridge. Remove the span interface from bridge members to continue.");
|
189 |
2af86dda
|
Phil Davis
|
}
|
190 |
86cb9ad1
|
Ermal Luçi
|
}
|
191 |
7a701b1e
|
Ermal Luçi
|
}
|
192 |
|
|
|
193 |
648ec0c2
|
Ermal Luçi
|
if (!$input_errors) {
|
194 |
|
|
$bridge = array();
|
195 |
|
|
$bridge['members'] = implode(',', $_POST['members']);
|
196 |
541ba27e
|
gnhb
|
$bridge['enablestp'] = $_POST['enablestp'] ? true : false;
|
197 |
648ec0c2
|
Ermal Luçi
|
$bridge['descr'] = $_POST['descr'];
|
198 |
|
|
$bridge['maxaddr'] = $_POST['maxaddr'];
|
199 |
|
|
$bridge['timeout'] = $_POST['timeout'];
|
200 |
2af86dda
|
Phil Davis
|
if ($_POST['static']) {
|
201 |
648ec0c2
|
Ermal Luçi
|
$bridge['static'] = implode(',', $_POST['static']);
|
202 |
2af86dda
|
Phil Davis
|
}
|
203 |
|
|
if ($_POST['private']) {
|
204 |
648ec0c2
|
Ermal Luçi
|
$bridge['private'] = implode(',', $_POST['private']);
|
205 |
2af86dda
|
Phil Davis
|
}
|
206 |
|
|
if (isset($_POST['stp'])) {
|
207 |
648ec0c2
|
Ermal Luçi
|
$bridge['stp'] = implode(',', $_POST['stp']);
|
208 |
2af86dda
|
Phil Davis
|
}
|
209 |
648ec0c2
|
Ermal Luçi
|
$bridge['maxage'] = $_POST['maxage'];
|
210 |
|
|
$bridge['fwdelay'] = $_POST['fwdelay'];
|
211 |
|
|
$bridge['hellotime'] = $_POST['hellotime'];
|
212 |
|
|
$bridge['priority'] = $_POST['priority'];
|
213 |
|
|
$bridge['proto'] = $_POST['proto'];
|
214 |
afd825a7
|
bcyrill
|
$bridge['holdcnt'] = $_POST['holdcnt'];
|
215 |
648ec0c2
|
Ermal Luçi
|
$i = 0;
|
216 |
|
|
$ifpriority = "";
|
217 |
|
|
$ifpathcost = "";
|
218 |
79955084
|
sbeaver
|
|
219 |
648ec0c2
|
Ermal Luçi
|
foreach ($ifacelist as $ifn => $ifdescr) {
|
220 |
|
|
if ($_POST[$ifn] <> "") {
|
221 |
2af86dda
|
Phil Davis
|
if ($i > 0) {
|
222 |
648ec0c2
|
Ermal Luçi
|
$ifpriority .= ",";
|
223 |
2af86dda
|
Phil Davis
|
}
|
224 |
648ec0c2
|
Ermal Luçi
|
$ifpriority .= $ifn.":".$_POST[$ifn];
|
225 |
|
|
}
|
226 |
95e174f1
|
Darren Embry
|
if ($_POST["{$ifn}0"] <> "") {
|
227 |
2af86dda
|
Phil Davis
|
if ($i > 0) {
|
228 |
648ec0c2
|
Ermal Luçi
|
$ifpathcost .= ",";
|
229 |
2af86dda
|
Phil Davis
|
}
|
230 |
95e174f1
|
Darren Embry
|
$ifpathcost .= $ifn.":".$_POST["{$ifn}0"];
|
231 |
648ec0c2
|
Ermal Luçi
|
}
|
232 |
|
|
$i++;
|
233 |
|
|
}
|
234 |
79955084
|
sbeaver
|
|
235 |
648ec0c2
|
Ermal Luçi
|
$bridge['ifpriority'] = $ifpriority;
|
236 |
|
|
$bridge['ifpathcost'] = $ifpathcost;
|
237 |
95e174f1
|
Darren Embry
|
|
238 |
2af86dda
|
Phil Davis
|
if ($_POST['span'] != "none") {
|
239 |
86cb9ad1
|
Ermal Luçi
|
$bridge['span'] = $_POST['span'];
|
240 |
2af86dda
|
Phil Davis
|
} else {
|
241 |
86cb9ad1
|
Ermal Luçi
|
unset($bridge['span']);
|
242 |
2af86dda
|
Phil Davis
|
}
|
243 |
|
|
if (isset($_POST['edge'])) {
|
244 |
648ec0c2
|
Ermal Luçi
|
$bridge['edge'] = implode(',', $_POST['edge']);
|
245 |
2af86dda
|
Phil Davis
|
}
|
246 |
|
|
if (isset($_POST['autoedge'])) {
|
247 |
648ec0c2
|
Ermal Luçi
|
$bridge['autoedge'] = implode(',', $_POST['autoedge']);
|
248 |
2af86dda
|
Phil Davis
|
}
|
249 |
|
|
if (isset($_POST['ptp'])) {
|
250 |
648ec0c2
|
Ermal Luçi
|
$bridge['ptp'] = implode(',', $_POST['ptp']);
|
251 |
2af86dda
|
Phil Davis
|
}
|
252 |
|
|
if (isset($_POST['autoptp'])) {
|
253 |
648ec0c2
|
Ermal Luçi
|
$bridge['autoptp'] = implode(',', $_POST['autoptp']);
|
254 |
2af86dda
|
Phil Davis
|
}
|
255 |
648ec0c2
|
Ermal Luçi
|
|
256 |
79955084
|
sbeaver
|
|
257 |
648ec0c2
|
Ermal Luçi
|
$bridge['bridgeif'] = $_POST['bridgeif'];
|
258 |
0e0002c2
|
bcyrill
|
interface_bridge_configure($bridge);
|
259 |
2af86dda
|
Phil Davis
|
if ($bridge['bridgeif'] == "" || !stristr($bridge['bridgeif'], "bridge")) {
|
260 |
ab9dc5be
|
Chris Buechler
|
$input_errors[] = gettext("Error occurred creating interface, please retry.");
|
261 |
2af86dda
|
Phil Davis
|
} else {
|
262 |
|
|
if (isset($id) && $a_bridges[$id]) {
|
263 |
c6f8c400
|
Renato Botelho
|
$a_bridges[$id] = $bridge;
|
264 |
2af86dda
|
Phil Davis
|
} else {
|
265 |
c6f8c400
|
Renato Botelho
|
$a_bridges[] = $bridge;
|
266 |
2af86dda
|
Phil Davis
|
}
|
267 |
648ec0c2
|
Ermal Luçi
|
|
268 |
c6f8c400
|
Renato Botelho
|
write_config();
|
269 |
648ec0c2
|
Ermal Luçi
|
|
270 |
5efc5b6f
|
Ermal Luçi
|
$confif = convert_real_interface_to_friendly_interface_name($bridge['bridgeif']);
|
271 |
2af86dda
|
Phil Davis
|
if ($confif <> "") {
|
272 |
c6f8c400
|
Renato Botelho
|
interface_configure($confif);
|
273 |
2af86dda
|
Phil Davis
|
}
|
274 |
5efc5b6f
|
Ermal Luçi
|
|
275 |
648ec0c2
|
Ermal Luçi
|
header("Location: interfaces_bridge.php");
|
276 |
|
|
exit;
|
277 |
|
|
}
|
278 |
|
|
}
|
279 |
|
|
}
|
280 |
|
|
|
281 |
49c46b6a
|
sbeaver
|
function build_spanport_list() {
|
282 |
|
|
global $ifacelist;
|
283 |
|
|
|
284 |
|
|
$splist = array('none' => 'None');
|
285 |
|
|
|
286 |
|
|
foreach ($ifacelist as $ifn => $ifdescr)
|
287 |
|
|
$splist[$ifn] = $ifdescr;
|
288 |
|
|
|
289 |
|
|
return($splist);
|
290 |
|
|
}
|
291 |
|
|
|
292 |
|
|
function build_member_list() {
|
293 |
|
|
global $pconfig, $ifacelist;
|
294 |
|
|
|
295 |
|
|
$memberlist = array('list' => array(),
|
296 |
|
|
'selected' => array());
|
297 |
|
|
|
298 |
|
|
$members_array = explode(',', $pconfig['members']);
|
299 |
|
|
foreach ($ifacelist as $ifn => $ifinfo) {
|
300 |
|
|
$memberlist['list'][$ifn] = $ifinfo;
|
301 |
|
|
|
302 |
|
|
if (in_array($ifn, $members_array))
|
303 |
|
|
array_push($memberlist['selected'], $ifn);
|
304 |
|
|
}
|
305 |
|
|
unset($members_array);
|
306 |
|
|
return($memberlist);
|
307 |
|
|
}
|
308 |
|
|
|
309 |
|
|
function build_port_list($selecton) {
|
310 |
|
|
global $pconfig, $ifacelist;
|
311 |
|
|
|
312 |
|
|
$portlist = array('list' => array(),
|
313 |
|
|
'selected' => array());
|
314 |
|
|
|
315 |
|
|
foreach ($ifacelist as $ifn => $ifdescr) {
|
316 |
|
|
$portlist['list'][$ifn] = $ifdescr;
|
317 |
|
|
|
318 |
|
|
if (stristr($selecton, $ifn))
|
319 |
|
|
array_push($portlist['selected'], $ifn);
|
320 |
|
|
}
|
321 |
|
|
|
322 |
|
|
return($portlist);
|
323 |
|
|
}
|
324 |
|
|
|
325 |
baca83aa
|
gnhb
|
$pgtitle = array(gettext("Interfaces"),gettext("Bridge"),gettext("Edit"));
|
326 |
b32dd0a6
|
jim-p
|
$shortcut_section = "interfaces";
|
327 |
648ec0c2
|
Ermal Luçi
|
include("head.inc");
|
328 |
|
|
|
329 |
49c46b6a
|
sbeaver
|
if ($input_errors)
|
330 |
|
|
print_input_errors($input_errors);
|
331 |
|
|
|
332 |
|
|
require('classes/Form.class.php');
|
333 |
|
|
|
334 |
|
|
$form = new Form();
|
335 |
|
|
|
336 |
|
|
$section = new Form_Section('Bridge Configuration');
|
337 |
|
|
|
338 |
|
|
$memberslist = build_member_list();
|
339 |
|
|
|
340 |
|
|
$section->addInput(new Form_Select(
|
341 |
|
|
'members',
|
342 |
|
|
'Member Interfaces',
|
343 |
|
|
$memberslist['selected'],
|
344 |
|
|
$memberslist['list'],
|
345 |
|
|
true // Allow multiples
|
346 |
|
|
))->setHelp('Interfaces participating in the bridge');
|
347 |
|
|
|
348 |
|
|
$section->addInput(new Form_Input(
|
349 |
|
|
'Descr',
|
350 |
|
|
'Description',
|
351 |
|
|
'text',
|
352 |
79955084
|
sbeaver
|
$pconfig['descr']
|
353 |
49c46b6a
|
sbeaver
|
));
|
354 |
|
|
|
355 |
|
|
$section->addInput(new Form_Checkbox(
|
356 |
|
|
'showadvanced',
|
357 |
7d876cdf
|
Sjon Hortensius
|
'Advanced',
|
358 |
49c46b6a
|
sbeaver
|
'Show advanced options',
|
359 |
|
|
$pconfig['showadvanced']
|
360 |
|
|
))->toggles('.toggle-advanced');
|
361 |
|
|
|
362 |
|
|
$form->add($section);
|
363 |
|
|
|
364 |
|
|
$section = new Form_Section('Advanced Configuration');
|
365 |
|
|
|
366 |
|
|
// Set initial toggle state manually for now
|
367 |
|
|
if($pconfig['showadvanced'])
|
368 |
|
|
$section->addClass('toggle-advanced in');
|
369 |
|
|
else
|
370 |
|
|
$section->addClass('toggle-advanced collapse');
|
371 |
|
|
|
372 |
|
|
$section->addInput(new Form_Input(
|
373 |
|
|
'maxaddr',
|
374 |
|
|
'Cache Size',
|
375 |
|
|
'text',
|
376 |
|
|
$pconfig['maxaddr']
|
377 |
|
|
))->setHelp('Set the size of the bridge address cache. The default is 100 entries');
|
378 |
|
|
|
379 |
|
|
$section->addInput(new Form_Input(
|
380 |
|
|
'timeout',
|
381 |
|
|
'Cache expire time',
|
382 |
|
|
'text',
|
383 |
|
|
$pconfig['timeout']
|
384 |
|
|
))->setHelp('Set the timeout of address cache entries to this number of seconds. If seconds is zero, then address cache entries will not be expired. The default is 240 seconds');
|
385 |
|
|
|
386 |
|
|
$section->addInput(new Form_Select(
|
387 |
|
|
'span',
|
388 |
|
|
'Span Port',
|
389 |
|
|
$pconfig['span'],
|
390 |
|
|
build_spanport_list()
|
391 |
|
|
))->setHelp('Add the interface named by interface as a span port on the bridge. Span ports transmit a copy of every frame received by the bridge.' .
|
392 |
|
|
'This is most useful for snooping a bridged network passively on another host connected to one of the span ports of the bridge. <br />' .
|
393 |
|
|
'%sThe span interface cannot be part of the bridge member interfaces.%s', ['<strong>', '</strong>']);
|
394 |
|
|
|
395 |
|
|
$edgelist = build_port_list($pconfig['edge']);
|
396 |
|
|
|
397 |
|
|
$section->addInput(new Form_Select(
|
398 |
|
|
'edge[]',
|
399 |
|
|
'Edge Ports',
|
400 |
|
|
$edgelist['selected'],
|
401 |
|
|
$edgelist['list'],
|
402 |
|
|
true
|
403 |
|
|
))->setHelp('Set interface as an edge port. An edge port connects directly to end stations and cannot create bridging loops in the network; this allows it to transition straight to forwarding.');
|
404 |
|
|
|
405 |
|
|
$edgelist = build_port_list($pconfig['autoedge']);
|
406 |
|
|
|
407 |
|
|
$section->addInput(new Form_Select(
|
408 |
|
|
'autoedge[]',
|
409 |
|
|
'Auto Edge Ports',
|
410 |
|
|
$edgelist['selected'],
|
411 |
|
|
$edgelist['list'],
|
412 |
|
|
true
|
413 |
|
|
))->setHelp('Allow interface to automatically detect edge status. This is the default for all interfaces added to a bridge.' .
|
414 |
|
|
'%sThis will disable the autoedge status of interfaces. %s', ['<strong>', '</strong>']);
|
415 |
|
|
|
416 |
|
|
$edgelist = build_port_list($pconfig['ptp']);
|
417 |
|
|
|
418 |
|
|
$section->addInput(new Form_Select(
|
419 |
|
|
'ptp',
|
420 |
|
|
'PTP Ports',
|
421 |
|
|
$edgelist['selected'],
|
422 |
|
|
$edgelist['list'],
|
423 |
|
|
true
|
424 |
|
|
))->setHelp('Set the interface as a point-to-point link. This is required for straight transitions to forwarding and should be enabled on a direct link to another RSTP-capable switch.');
|
425 |
|
|
|
426 |
|
|
$edgelist = build_port_list($pconfig['autoptp']);
|
427 |
|
|
|
428 |
|
|
$section->addInput(new Form_Select(
|
429 |
|
|
'autoptp[]',
|
430 |
|
|
'Auto PTP Ports',
|
431 |
|
|
$edgelist['selected'],
|
432 |
|
|
$edgelist['list'],
|
433 |
|
|
true
|
434 |
|
|
))->setHelp('Automatically detect the point-to-point status on interface by checking the full duplex link status. This is the default for interfaces added to the bridge.' .
|
435 |
|
|
'%sThe interfaces selected here will be removed from default autoedge status. %s', ['<strong>', '</strong>']);
|
436 |
|
|
|
437 |
|
|
$edgelist = build_port_list($pconfig['static']);
|
438 |
|
|
|
439 |
|
|
$section->addInput(new Form_Select(
|
440 |
|
|
'static[]',
|
441 |
|
|
'Sticky Ports',
|
442 |
|
|
$edgelist['selected'],
|
443 |
|
|
$edgelist['list'],
|
444 |
|
|
true
|
445 |
|
|
))->setHelp('Mark an interface as a "sticky" interface. Dynamically learned address entries are treated as static once entered into the cache. ' .
|
446 |
|
|
'Sticky entries are never aged out of the cache or replaced, even if the address is seen on a different interface.');
|
447 |
|
|
|
448 |
|
|
$edgelist = build_port_list($pconfig['private']);
|
449 |
|
|
|
450 |
|
|
$section->addInput(new Form_Select(
|
451 |
|
|
'private[]',
|
452 |
|
|
'Private Ports',
|
453 |
|
|
$edgelist['selected'],
|
454 |
|
|
$edgelist['list'],
|
455 |
|
|
true
|
456 |
|
|
))->setHelp('Mark an interface as a "private" interface. A private interface does not forward any traffic to any other port that is also a private interface. ');
|
457 |
|
|
|
458 |
|
|
// STP section
|
459 |
|
|
// ToDo: - Should disable spanning tree section when not checked
|
460 |
|
|
$section->addInput(new Form_Checkbox(
|
461 |
|
|
'enablestp',
|
462 |
|
|
'Enable RSTP/STP',
|
463 |
|
|
null,
|
464 |
|
|
$pconfig['enablestp']
|
465 |
|
|
));
|
466 |
|
|
|
467 |
|
|
// Show the spanning tree section
|
468 |
|
|
$form->add($section);
|
469 |
|
|
$section = new Form_Section('RSTP/STP');
|
470 |
|
|
if($pconfig['showadvanced'])
|
471 |
|
|
$section->addClass('toggle-advanced in');
|
472 |
|
|
else
|
473 |
|
|
$section->addClass('toggle-advanced collapse');
|
474 |
|
|
|
475 |
|
|
$section->addInput(new Form_Select(
|
476 |
|
|
'proto',
|
477 |
|
|
'Protocol',
|
478 |
|
|
$pconfig['proto'],
|
479 |
|
|
array('rstp' => 'RSTP',
|
480 |
|
|
'stp' => 'STP')
|
481 |
|
|
))->setHelp('Protocol used for spanning tree.');
|
482 |
|
|
|
483 |
|
|
$edgelist = build_port_list($pconfig['stp']);
|
484 |
|
|
|
485 |
|
|
$section->addInput(new Form_Select(
|
486 |
|
|
'stp[]',
|
487 |
|
|
'STP Interfaces',
|
488 |
|
|
$edgelist['selected'],
|
489 |
|
|
$edgelist['list'],
|
490 |
|
|
true
|
491 |
|
|
))->setHelp('Enable Spanning Tree Protocol on interface. The if_bridge(4) driver has support for the IEEE 802.1D Spanning Tree Protocol (STP).' .
|
492 |
|
|
'STP is used to detect and remove loops in a network topology.');
|
493 |
|
|
|
494 |
|
|
$section->addInput(new Form_Input(
|
495 |
|
|
'maxage',
|
496 |
|
|
'Valid time',
|
497 |
7d876cdf
|
Sjon Hortensius
|
'number',
|
498 |
|
|
$pconfig['maxage'],
|
499 |
|
|
['placeholder' => 20, 'min' => 6, 'max' => 40]
|
500 |
49c46b6a
|
sbeaver
|
))->setHelp('Set the time that a Spanning Tree Protocol configuration is valid. The default is 20 seconds. The minimum is 6 seconds and the maximum is 40 seconds.');
|
501 |
|
|
|
502 |
|
|
$section->addInput(new Form_Input(
|
503 |
|
|
'fwdelay',
|
504 |
|
|
'Forward time',
|
505 |
7d876cdf
|
Sjon Hortensius
|
'number',
|
506 |
|
|
$pconfig['fwdelay'],
|
507 |
|
|
['placeholder' => 15, 'min' => 4, 'max' => 30]
|
508 |
49c46b6a
|
sbeaver
|
))->setHelp('Set the time that must pass before an interface begins forwarding packets when Spanning Tree is enabled. The default is 15 seconds. The minimum is 4 seconds and the maximum is 30 seconds. ');
|
509 |
|
|
|
510 |
|
|
$section->addInput(new Form_Input(
|
511 |
|
|
'hellotime',
|
512 |
|
|
'Hello time',
|
513 |
7d876cdf
|
Sjon Hortensius
|
'number',
|
514 |
|
|
$pconfig['hellotime'],
|
515 |
|
|
['placeholder' => 2, 'min' => 1, 'max' => 2, 'step' => '0.1']
|
516 |
49c46b6a
|
sbeaver
|
))->setHelp('Set the time in seconds between broadcasting of Spanning Tree Protocol configuration messages. The hello time may only be changed when operating in legacy STP mode.' .
|
517 |
|
|
'The default is 2 seconds. The minimum is 1 second and the maximum is 2 seconds.');
|
518 |
|
|
|
519 |
|
|
$section->addInput(new Form_Input(
|
520 |
|
|
'priority',
|
521 |
|
|
'Priority',
|
522 |
|
|
'text',
|
523 |
7d876cdf
|
Sjon Hortensius
|
$pconfig['priority'],
|
524 |
|
|
['placeholder' => 32768, 'min' => 0, 'max' => 61440]
|
525 |
49c46b6a
|
sbeaver
|
))->setHelp('Set the bridge priority for Spanning Tree. The default is 32768. The minimum is 0 and the maximum is 61440. ');
|
526 |
|
|
|
527 |
|
|
$section->addInput(new Form_Input(
|
528 |
|
|
'holdcnt',
|
529 |
|
|
'Hold Count',
|
530 |
7d876cdf
|
Sjon Hortensius
|
'number',
|
531 |
|
|
$pconfig['holdcnt'],
|
532 |
|
|
['placeholder' => 6, 'min' => 1, 'max' => 10]
|
533 |
49c46b6a
|
sbeaver
|
))->setHelp('Set the transmit hold count for Spanning Tree. This is the number of packets transmitted before being rate limited. The default is 6. The minimum is 1 and the maximum is 10.');
|
534 |
|
|
|
535 |
|
|
foreach ($ifacelist as $ifn => $ifdescr) {
|
536 |
7d876cdf
|
Sjon Hortensius
|
$section->addInput(new Form_Input(
|
537 |
49c46b6a
|
sbeaver
|
$ifn,
|
538 |
7d876cdf
|
Sjon Hortensius
|
$ifdescr . ' Priority',
|
539 |
|
|
'number',
|
540 |
|
|
$pconfig[$ifn],
|
541 |
|
|
['placeholder' => 128, 'min' => 0, 'max' => 240, 'step' => 16]
|
542 |
|
|
))->setHelp('Set the Spanning Tree priority of interface to value. The default is 128. The minimum is 0 and the maximum is 240. Increments of 16.');
|
543 |
49c46b6a
|
sbeaver
|
}
|
544 |
|
|
|
545 |
|
|
$i = 0;
|
546 |
|
|
foreach ($ifacelist as $ifn => $ifdescr) {
|
547 |
7d876cdf
|
Sjon Hortensius
|
$section->addInput(new Form_Input(
|
548 |
49c46b6a
|
sbeaver
|
$ifn . $i,
|
549 |
7d876cdf
|
Sjon Hortensius
|
$ifdescr . ' Path cost',
|
550 |
|
|
'number',
|
551 |
|
|
$ifpathcost[$ifn],
|
552 |
|
|
[ 'placeholder' => 0, 'min' => 1, 'max' => 200000000]
|
553 |
|
|
))->setHelp('Set the Spanning Tree path cost of interface to value. The default is calculated from the link speed. '.
|
554 |
|
|
'To change a previously selected path cost back to automatic, set the cost to 0. The minimum is 1 and the maximum is 200000000.');
|
555 |
49c46b6a
|
sbeaver
|
$i++;
|
556 |
648ec0c2
|
Ermal Luçi
|
}
|
557 |
49c46b6a
|
sbeaver
|
|
558 |
|
|
$form->add($section);
|
559 |
|
|
print($form);
|
560 |
|
|
|
561 |
|
|
include("foot.inc");
|