interfaces_bridge_edit.php 32.7 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1
<?php
2

Ad Schellevis's avatar
Ad Schellevis committed
3
/*
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
    Copyright (C) 2014-2015 Deciso B.V.
    Copyright (C) 2008 Ermal Luçi
    All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:

    1. Redistributions of source code must retain the above copyright notice,
       this list of conditions and the following disclaimer.

    2. Redistributions in binary form must reproduce the above copyright
       notice, this list of conditions and the following disclaimer in the
       documentation and/or other materials provided with the distribution.

    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    POSSIBILITY OF SUCH DAMAGE.
Ad Schellevis's avatar
Ad Schellevis committed
28 29
*/

30
require_once("guiconfig.inc");
31 32
require_once("system.inc");
require_once("interfaces.inc");
33
require_once("openvpn.inc");
34
require_once("unbound.inc");
35 36
require_once("services.inc");

37 38
if (!isset($config['bridges']) || !is_array($config['bridges'])) {
    $config['bridges'] = array();
39
}
40 41
if (!isset($config['bridges']['bridged']) || !is_array($config['bridges']['bridged'])) {
    $config['bridges']['bridged'] = array();
42
}
Ad Schellevis's avatar
Ad Schellevis committed
43 44 45

$a_bridges = &$config['bridges']['bridged'];

46 47 48 49 50 51
// interface list
$ifacelist = array();
foreach (get_configured_interface_with_descr() as $bif => $bdescr) {
    if (substr(get_real_interface($bif), 0, 3) != "gre") {
        $ifacelist[$bif] = $bdescr;
    }
Ad Schellevis's avatar
Ad Schellevis committed
52 53 54
}


55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    // read form data
    if (!empty($a_bridges[$_GET['id']])) {
        $id = $_GET['id'];
    }
    // copy fields 1-on-1
    $copy_fields = array('descr', 'bridgeif', 'maxaddr', 'timeout', 'maxage','fwdelay', 'hellotime', 'priority', 'proto', 'holdcnt', 'span');
    foreach ($copy_fields as $fieldname) {
        if (isset($a_bridges[$id][$fieldname])) {
            $pconfig[$fieldname] = $a_bridges[$id][$fieldname];
        } else {
            $pconfig[$fieldname] = null;
        }
    }
    // bool fields
    $pconfig['enablestp'] = isset($a_bridges[$id]['enablestp']);

    // simple array fields
    $array_fields = array('members', 'stp', 'edge', 'autoedge', 'ptp', 'autoptp', 'static', 'private');
    foreach ($array_fields as $fieldname) {
        if (!empty($a_bridges[$id][$fieldname])) {
            $pconfig[$fieldname] = explode(',', $a_bridges[$id][$fieldname]);
        } else {
            $pconfig[$fieldname] = array();
        }
    }

    // array key/value sets
    if (!empty($a_bridges[$id]['ifpriority'])) {
        foreach (explode(",", $a_bridges[$id]['ifpriority']) as $cfg) {
            list ($key, $value)  = explode(":", $cfg);
            $pconfig['ifpriority_'.$key] = $value;
        }
    }
    if (!empty($a_bridges[$id]['ifpathcost'])) {
        foreach (explode(",", $a_bridges[$id]['ifpathcost']) as $cfg) {
            list ($key, $value)  = explode(":", $cfg);
            $pconfig['ifpathcost_'.$key] = $value;
        }
    }
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // save / validate formdata
    if (!empty($a_bridges[$_POST['id']])) {
        $id = $_POST['id'];
    }

    $input_errors = array();
    $pconfig = $_POST;

    /* input validation */
    $reqdfields = explode(" ", "members");
    $reqdfieldsn = array(gettext("Member Interfaces"));

    do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);

    if (!empty($pconfig['maxage']) && !is_numeric($pconfig['maxage'])) {
        $input_errors[] = gettext("Maxage needs to be an integer between 6 and 40.");
    }
    if (!empty($pconfig['maxaddr']) && !is_numeric($pconfig['maxaddr'])) {
        $input_errors[] = gettext("Maxaddr needs to be an integer.");
    }
    if (!empty($pconfig['timeout']) && !is_numeric($pconfig['timeout'])) {
        $input_errors[] = gettext("Timeout needs to be an integer.");
    }
    if (!empty($pconfig['fwdelay']) && !is_numeric($pconfig['fwdelay'])) {
        $input_errors[] = gettext("Forward Delay needs to be an integer between 4 and 30.");
    }
    if (!empty($pconfig['hellotime']) && !is_numeric($pconfig['hellotime'])) {
        $input_errors[] = gettext("Hello time for STP needs to be an integer between 1 and 2.");
    }
    if (!empty($pconfig['priority']) && !is_numeric($pconfig['priority'])) {
        $input_errors[] = gettext("Priority for STP needs to be an integer between 0 and 61440.");
    }
    if (!empty($pconfig['holdcnt']) && !is_numeric($pconfig['holdcnt'])) {
        $input_errors[] = gettext("Transmit Hold Count for STP needs to be an integer between 1 and 10.");
    }
    foreach ($ifacelist as $ifn => $ifdescr) {
        if (!empty($pconfig['ifpriority_'.$ifn]) && !is_numeric($pconfig['ifpriority_'.$ifn])) {
            $input_errors[] = sprintf(gettext("%s interface priority for STP needs to be an integer between 0 and 240."), $ifdescr);
        }
        if (!empty($pconfig['ifpathcost_'.$ifn]) && !is_numeric($pconfig['ifpathcost_'.$ifn])) {
            $input_errors[] = sprintf(gettext("%s interface path cost for STP needs to be an integer between 1 and 200000000."), $ifdescr);
        }
    }

    if (is_array($pconfig['members'])) {
        foreach($pconfig['members'] as $ifmembers) {
            if (empty($config['interfaces'][$ifmembers])) {
                $input_errors[] = gettext("A member interface passed does not exist in configuration");
            }
            if (!empty($config['interfaces'][$ifmembers]['wireless']['mode']) && $config['interfaces'][$ifmembers]['wireless']['mode'] != "hostap") {
                $input_errors[] = gettext("Bridging a wireless interface is only possible in hostap mode.");
            }
            if ($pconfig['span'] != "none" && $pconfig['span'] == $ifmembers) {
                $input_errors[] = gettext("Span interface cannot be part of the bridge. Remove the span interface from bridge members to continue.");
            }
        }
    }

    if (count($input_errors) == 0) {
        $bridge = array();
        $bridge['enablestp'] = !empty($pconfig['enablestp']);
        // 1 on 1 copy
        $copy_fields = array('descr', 'maxaddr', 'timeout', 'bridgeif', 'maxage','fwdelay', 'hellotime', 'priority', 'proto', 'holdcnt');
        foreach ($copy_fields as $fieldname) {
            if (isset($pconfig[$fieldname]) && $pconfig[$fieldname] != "") {
                $bridge[$fieldname] = $pconfig[$fieldname];
            } else {
                $bridge[$fieldname] = null;
            }
        }
        if ($pconfig['span'] != "none") {
            $bridge['span'] = $pconfig['span'];
        }
        // simple array fields
        $array_fields = array('members', 'stp', 'edge', 'autoedge', 'ptp', 'autoptp', 'static', 'private');
        foreach ($array_fields as $fieldname) {
            if(!empty($pconfig[$fieldname])) {
                $bridge[$fieldname] = implode(',', $pconfig[$fieldname]);
            }
        }
        // array key/value sets
        $bridge['ifpriority'] = "";
        $bridge['ifpathcost'] = "";
        foreach ($ifacelist as $ifn => $ifdescr) {
          if (isset($pconfig['ifpriority_'.$ifn]) && $pconfig['ifpriority_'.$ifn] != "") {
              if (!empty($bridge['ifpriority'])) {
                  $bridge['ifpriority'] .= ',';
              }
              $bridge['ifpriority'] .= $ifn.":".$pconfig['ifpriority_'.$ifn];
          }
          if (isset($pconfig['ifpathcost_'.$ifn]) && $pconfig['ifpathcost_'.$ifn] != "") {
              if (!empty($bridge['ifpathcost'])) {
                  $bridge['ifpathcost'] .= ',';
              }
              $bridge['ifpathcost'] .= $ifn.":".$pconfig['ifpathcost_'.$ifn];
          }
        }

        interface_bridge_configure($bridge);
        if ($bridge['bridgeif'] == "" || !stristr($bridge['bridgeif'], "bridge")) {
            $input_errors[] = gettext("Error occurred creating interface, please retry.");
        } else {
            if (isset($id)) {
                $a_bridges[$id] = $bridge;
            } else {
                $a_bridges[] = $bridge;
            }
            write_config();
            $confif = convert_real_interface_to_friendly_interface_name($bridge['bridgeif']);
            if ($confif <> "") {
                interface_configure($confif);
            }
208
            header(url_safe('Location: /interfaces_bridge.php'));
209 210 211
            exit;
        }
    }
Ad Schellevis's avatar
Ad Schellevis committed
212 213
}

214
legacy_html_escape_form_data($pconfig);
Ad Schellevis's avatar
Ad Schellevis committed
215 216 217
include("head.inc");
?>

Ad Schellevis's avatar
Ad Schellevis committed
218
<body>
Ad Schellevis's avatar
Ad Schellevis committed
219
<script type="text/javascript">
220 221 222 223 224 225 226
$(document).ready(function() {
  // advanced options
  $("#show_advanced").click(function(){
      $(".act_show_advanced").show();
      $("#show_advanced_opt").hide();
  });
});
Ad Schellevis's avatar
Ad Schellevis committed
227 228 229
</script>

<?php include("fbegin.inc"); ?>
230 231 232 233 234 235 236 237
  <section class="page-content-main">
    <div class="container-fluid">
      <div class="row">
        <?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
        <section class="col-xs-12">
          <form method="post" name="iform" id="iform">
            <div class="tab-content content-box col-xs-12 __mb">
              <div class="table-responsive">
238
                <table class="table table-striped opnsense_standard_table_form">
239 240 241 242 243
                  <thead>
                    <tr>
                      <td width="22%"><strong><?=gettext("Bridge configuration");?></strong></td>
                      <td width="78%" align="right">
                        <small><?=gettext("full help"); ?> </small>
Fabian Franz's avatar
Fabian Franz committed
244
                        <i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page" type="button"></i>
245 246 247 248 249 250 251 252 253 254 255
                        &nbsp;
                      </td>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <td><a id="help_for_members" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Member interfaces"); ?></td>
                      <td>
                        <select name="members[]" multiple="multiple" class="selectpicker" data-size="5" data-live-search="true">
<?php
                        foreach ($ifacelist as $ifn => $ifinfo):?>
Fabian Franz's avatar
Fabian Franz committed
256
                            <option value="<?=$ifn;?>" <?=!empty($pconfig['members']) && in_array($ifn, $pconfig['members']) ? 'selected="selected"' : "";?>>
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
                                <?=$ifinfo;?>
                            </option>
<?php
                        endforeach;?>
                        </select>
                        <div class="hidden" for="help_for_members">
                          <?=gettext("Interfaces participating in the bridge."); ?>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_descr" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Description"); ?></td>
                      <td>
                        <input type="text" name="descr" value="<?=$pconfig['descr'];?>" />
                        <div class="hidden" for="help_for_descr">
                          <?=gettext("You may enter a description here for your reference (not parsed).");?>
                        </div>
                      </td>
                    </tr>
                    <tr id="show_advanced_opt">
                      <td></td>
                      <td>
                        <input type="button" id="show_advanced" class="btn btn-xs btn-default" value="<?=gettext("Show advanced options"); ?>" />
                      </td>
                    </tr>
                  </tbody>
                </table>
              </div>
            </div>
            <!-- Advanced / RSTP/STP -->
            <div class="tab-content content-box col-xs-12 __mb act_show_advanced" style="display:none">
              <div class="table-responsive">
                <table class="table table-striped">
                  <thead>
                    <tr>
                      <td colspan="2"><strong><?=gettext("Spanning Tree Protocol");?> (<?=gettext("RSTP/STP"); ?>)</strong></td>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <td width="22%"><a id="help_for_enablestp" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Enable");?></td>
                      <td width="78%">
Fabian Franz's avatar
Fabian Franz committed
299
                        <input type="checkbox" name="enablestp" <?= !empty($pconfig['enablestp']) ? 'checked="checked"' : "";?> />
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
                        <div class="hidden" for="help_for_enablestp">
                          <?=gettext("Enable spanning tree options for this bridge."); ?>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_proto" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Protocol"); ?></td>
                      <td>
                        <select name="proto" id="proto" class="selectpicker">
                          <option value="rstp" <?=$pconfig['proto'] == "rstp" ? "selected=\"selected\"" : "";?> >
                            <?=gettext("RSTP");?>
                          </option>
                          <option value="stp" <?=$pconfig['proto'] == "stp" ? "selected=\"selected\"" : "";?> >
                            <?=gettext("STP");?>
                          </option>
                        </select>
                        <div class="hidden" for="help_for_proto">
                          <?=gettext("Protocol used for spanning tree."); ?>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_stp" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("STP interfaces"); ?></td>
                      <td>
                        <select name="stp[]" class="selectpicker" multiple="multiple" size="3" data-live-search="true">
<?php
                        foreach ($ifacelist as $ifn => $ifdescr):?>
327
                          <option value="<?= $ifn ?>" <?= !empty($pconfig['stp']) && in_array($ifn, $pconfig['stp']) ? 'selected="selected"' : '' ?> >
328 329 330 331 332 333
                              <?=$ifdescr;?>
                          </option>
<?php
                        endforeach;?>
                        </select>
                        <div class="hidden" for="help_for_stp" >
Fabian Franz's avatar
Fabian Franz committed
334
                         <?=gettext("Enable Spanning Tree Protocol on interface. The if_bridge(4) " .
335
                         "driver has support for the IEEE 802.1D Spanning Tree Protocol " .
Fabian Franz's avatar
Fabian Franz committed
336
                         "(STP). STP is used to detect and remove loops in a " .
337 338 339 340 341 342 343 344 345 346
                         "network topology."); ?>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_maxage" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Valid time"); ?> (<?=gettext("seconds"); ?>)</td>
                      <td>
                        <input name="maxage" type="text" value="<?=$pconfig['maxage'];?>" />
                        <div class="hidden" for="help_for_maxage">
                         <?=gettext("Set the time that a Spanning Tree Protocol configuration is " .
Fabian Franz's avatar
Fabian Franz committed
347
                         "valid. The default is 20 seconds. The minimum is 6 seconds and " .
348 349 350 351 352 353 354 355 356 357
                         "the maximum is 40 seconds."); ?>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_fwdelay" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Forward time"); ?> (<?=gettext("seconds"); ?>)</td>
                      <td>
                        <input name="fwdelay" type="text" value="<?=$pconfig['fwdelay'];?>" />
                        <div class="hidden" for="help_for_fwdelay">
                         <?=gettext("Set the time that must pass before an interface begins forwarding " .
Fabian Franz's avatar
Fabian Franz committed
358
                         "packets when Spanning Tree is enabled. The default is 15 seconds. The minimum is 4 seconds and the maximum is 30 seconds."); ?>
359 360 361 362 363 364 365 366
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_hellotime" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Hello time"); ?> (<?=gettext("seconds"); ?>)</td>
                      <td>
                        <input name="hellotime" type="text" value="<?=$pconfig['hellotime'];?>" />
                        <div class="hidden" for="help_for_hellotime">
Fabian Franz's avatar
Fabian Franz committed
367 368
                         <?=gettext("Set the time between broadcasting of Spanning Tree Protocol configuration messages. The hello time may only be changed when " .
                         "operating in legacy STP mode. The default is 2 seconds. The minimum is 1 second and the maximum is 2 seconds."); ?>
369 370 371 372 373 374 375 376
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_priority" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Priority"); ?></td>
                      <td>
                        <input name="priority" type="text" value="<?=$pconfig['priority'];?>" />
                        <div class="hidden" for="help_for_priority">
Fabian Franz's avatar
Fabian Franz committed
377
                         <?=gettext("Set the bridge priority for Spanning Tree. The default is 32768. " .
378 379 380 381 382 383 384 385 386
                         "The minimum is 0 and the maximum is 61440."); ?>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_holdcnt" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Hold count"); ?></td>
                      <td>
                        <input name="holdcnt" type="text" value="<?=$pconfig['holdcnt'];?>" />
                        <div class="hidden" for="help_for_holdcnt">
Fabian Franz's avatar
Fabian Franz committed
387 388 389
                         <?=gettext("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."); ?>
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_intf_priority" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Priority"); ?></td>
                      <td>
                        <table class="table table-striped table-condensed">
<?php
                        foreach ($ifacelist as $ifn => $ifdescr):?>
                          <tr>
                            <td><?=$ifdescr;?></td>
                            <td>
                                <input name="ifpriority_<?=$ifn;?>" type="text" value="<?=isset($pconfig['ifpriority_'.$ifn]) ? $pconfig['ifpriority_'.$ifn] : "";?>" />
                            </td>
                          </tr>
<?php
                        endforeach;?>
                        </table>
                        <div class="hidden" for="help_for_intf_priority">
Fabian Franz's avatar
Fabian Franz committed
409 410
                         <?=gettext("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."); ?>
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_intf_pathcost" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Path cost"); ?></td>
                      <td>
                        <table class="table table-striped table-condensed">
<?php
                        foreach ($ifacelist as $ifn => $ifdescr):?>
                          <tr>
                            <td><?=$ifdescr;?></td>
                            <td>
                                <input name="ifpathcost_<?=$ifn;?>" type="text" value="<?=isset($pconfig['ifpathcost_'.$ifn]) ? $pconfig['ifpathcost_'.$ifn] : "";?>" />
                            </td>
                          </tr>
<?php
                        endforeach;?>
                        </table>
                        <div class="hidden" for="help_for_intf_pathcost">
Fabian Franz's avatar
Fabian Franz committed
430 431
                         <?=gettext("Set the Spanning Tree path cost of interface to value. The " .
                         "default is calculated from the link speed. To change a previously selected path cost back to automatic, set the cost to 0. ".
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
                         "The minimum is 1 and the maximum is 200000000."); ?>
                        </div>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </div>
            </div>
            <!-- Advanced options-->
            <div class="tab-content content-box col-xs-12 __mb act_show_advanced" style="display:none">
              <div class="table-responsive">
                <table class="table table-striped">
                  <thead>
                    <tr>
                      <td colspan="2"><strong><?=gettext("Advanced options");?></strong></td>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <td width="22%"><a id="help_for_maxaddr" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Cache size"); ?> (<?=gettext("entries"); ?>)</td>
                      <td width="78%">
                        <input name="maxaddr" type="text" value="<?=$pconfig['maxaddr'];?>" />
                      <div class="hidden" for="help_for_maxaddr">
Fabian Franz's avatar
Fabian Franz committed
455
                        <?=gettext("Set the size of the bridge address cache to size. The default is .100 entries."); ?>
456 457 458 459 460 461 462 463
                      </span>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_timeout" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Cache entry expire time"); ?> (<?=gettext("seconds"); ?>)</td>
                      <td>
                        <input name="timeout" type="text" value="<?=$pconfig['timeout'];?>" />
                        <div class="hidden" for="help_for_timeout">
Fabian Franz's avatar
Fabian Franz committed
464
                         <?=gettext("Set the timeout of address cache entries to this number of seconds. If " .
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
                         "seconds is zero, then address cache entries will not be expired. " .
                         "The default is 240 seconds."); ?>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_span" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Span port"); ?></td>
                      <td>
                        <select name="span" class="selectpicker" data-live-search="true">
                          <option value="none"><?=gettext("None"); ?></option>
<?php
                          foreach ($ifacelist as $ifn => $ifdescr):?>
                          <option value="<?=$ifn;?>" <?=$ifn == $pconfig['span'] ? "selected=\"selected\"" : "";?>>
                            <?=$ifdescr;?>
                          </option>
<?php
                          endforeach;?>
                        </select>
                        <div class="hidden" for="help_for_span">
                         <?=gettext("Add the interface named by interface as a span port on the " .
Fabian Franz's avatar
Fabian Franz committed
485 486
                         "bridge. Span ports transmit a copy of every frame received by " .
                         "the bridge. This is most useful for snooping a bridged network " .
487 488 489 490 491 492 493 494 495 496 497 498 499
                         "passively on another host connected to one of the span ports of " .
                         "the bridge."); ?><br/>
                         <span class="text-warning"><strong><?=gettext("Note:"); ?><br /></strong></span>
                         <?=gettext("The span interface cannot be part of the bridge member interfaces."); ?>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_edge" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Edge ports"); ?></td>
                      <td>
                        <select name="edge[]" class="selectpicker" multiple="multiple" size="3" data-live-search="true">
<?php
                          foreach ($ifacelist as $ifn => $ifdescr):?>
500
                          <option value="<?=$ifn;?>" <?=!empty($pconfig['edge']) && in_array($ifn, $pconfig['edge']) ? "selected=\"selected\"" : "";?>>
501 502 503 504 505 506
                            <?=$ifdescr;?>
                          </option>
<?php
                          endforeach;?>
                        </select>
                        <div class="hidden" for="help_for_edge">
Fabian Franz's avatar
Fabian Franz committed
507
                          <?=gettext("Set interface as an edge port. An edge port connects directly to " .
508 509 510 511 512 513 514 515 516 517 518
                          "end stations and cannot create bridging loops in the network; this " .
                          "allows it to transition straight to forwarding."); ?>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_autoedge" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Auto Edge ports"); ?></td>
                      <td>
                        <select name="autoedge[]" class="selectpicker" multiple="multiple" size="3" data-live-search="true">
<?php
                          foreach ($ifacelist as $ifn => $ifdescr):?>
519
                          <option value="<?=$ifn;?>" <?=!empty($pconfig['autoedge']) && in_array($ifn, $pconfig['autoedge']) ? "selected=\"selected\"" : "";?>>
520 521 522 523 524 525
                            <?=$ifdescr;?>
                          </option>
<?php
                          endforeach;?>
                        </select>
                        <div class="hidden" for="help_for_autoedge">
Fabian Franz's avatar
Fabian Franz committed
526
                          <?=gettext("Allow interface to automatically detect edge status. This is the " .
527 528 529 530 531 532 533 534 535 536 537 538
                            "default for all interfaces added to a bridge."); ?><br/>
                            <span class="text-warning"><strong><?=gettext("Note:"); ?><br /></strong></span>
                            <?=gettext("This will disable the autoedge status of interfaces."); ?>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_ptp" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("PTP ports"); ?></td>
                      <td>
                        <select name="ptp[]" class="selectpicker" multiple="multiple" size="3" data-live-search="true">
<?php
                          foreach ($ifacelist as $ifn => $ifdescr):?>
Fabian Franz's avatar
Fabian Franz committed
539
                          <option value="<?=$ifn;?>" <?=!empty($pconfig['ptp']) && in_array($ifn, $pconfig['ptp']) ? 'selected="selected"' : "";?>>
540 541 542 543 544 545
                            <?=$ifdescr;?>
                          </option>
<?php
                          endforeach;?>
                        </select>
                        <div class="hidden" for="help_for_ptp">
Fabian Franz's avatar
Fabian Franz committed
546
                         <?=gettext("Set the interface as a point-to-point link. This is required for " .
547 548 549 550 551 552 553 554 555 556 557
                         "straight transitions to forwarding and should be enabled on a " .
                         "direct link to another RSTP-capable switch."); ?>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_autoptp" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Auto PTP ports"); ?></td>
                      <td>
                        <select name="autoptp[]" class="selectpicker" multiple="multiple" size="3" data-live-search="true">
<?php
                          foreach ($ifacelist as $ifn => $ifdescr):?>
Fabian Franz's avatar
Fabian Franz committed
558
                          <option value="<?=$ifn;?>" <?=!empty($pconfig['autoptp']) && in_array($ifn, $pconfig['autoptp']) ? 'selected="selected"' : "";?>>
559 560 561 562 563 564 565
                            <?=$ifdescr;?>
                          </option>
<?php
                          endforeach;?>
                        </select>
                        <div class="hidden" for="help_for_autoptp">
                         <?=gettext("Automatically detect the point-to-point status on interface by " .
Fabian Franz's avatar
Fabian Franz committed
566
                         "checking the full duplex link status. This is the default for " .
567 568 569 570 571 572 573 574 575 576 577 578
                         "interfaces added to the bridge."); ?><br/>
                         <span class="text-warning"><strong><?=gettext("Note:"); ?><br /></strong></span>
                         <?=gettext("The interfaces selected here will be removed from default autoedge status."); ?>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_static" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Sticky ports"); ?></td>
                      <td>
                        <select name="static[]" class="selectpicker" multiple="multiple" size="3" data-live-search="true">
<?php
                          foreach ($ifacelist as $ifn => $ifdescr):?>
579
                          <option value="<?=$ifn;?>" <?=!empty($pconfig['static']) && in_array($ifn, $pconfig['static']) ? "selected=\"selected\"" : "";?>>
580 581 582 583 584 585
                            <?=$ifdescr;?>
                          </option>
<?php
                          endforeach;?>
                        </select>
                        <div class="hidden" for="help_for_static">
Fabian Franz's avatar
Fabian Franz committed
586 587 588
                          <?=gettext('Mark an interface as a "sticky" interface. Dynamically learned ' .
                          "address entries are treated as static once entered into the cache. " .
                          "Sticky entries are never aged out of the cache or " .
589 590 591 592 593 594 595 596 597 598
                          "replaced, even if the address is seen on a different interface."); ?>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><a id="help_for_private" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Private ports"); ?></td>
                      <td>
                        <select name="private[]" class="selectpicker" multiple="multiple" size="3" data-live-search="true">
<?php
                          foreach ($ifacelist as $ifn => $ifdescr):?>
599
                          <option value="<?=$ifn;?>" <?=!empty($pconfig['private']) && in_array($ifn, $pconfig['private']) ? "selected=\"selected\"" : "";?>>
600 601 602 603 604 605
                            <?=$ifdescr;?>
                          </option>
<?php
                          endforeach;?>
                        </select>
                        <div class="hidden" for="help_for_private">
Fabian Franz's avatar
Fabian Franz committed
606
                          <?=gettext('Mark an interface as a "private" interface. A private interface does not forward any traffic to any other port that is also ' .
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639
                          "a private interface."); ?>
                        </div>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </div>
            </div>
            <!-- Advanced / RSTP/STP -->
            <div class="tab-content content-box col-xs-12 __mb">
              <div class="table-responsive">
                <table class="table table-striped">
                  <tbody>
                    <tr>
                      <td width="22%" valign="top">&nbsp;</td>
                      <td width="78%">
                        <input type="hidden" name="bridgeif" value="<?=$pconfig['bridgeif']; ?>" />
                        <input name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
                        <input type="button" class="btn btn-default" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces_bridge.php');?>'" />
<?php if (isset($id)): ?>
                        <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
<?php endif; ?>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </div>
            </div>
          </form>
        </section>
      </div>
    </div>
  </section>
640
<?php include("foot.inc"); ?>