| 1 |
648ec0c2
|
Ermal Luçi
|
<?php
|
| 2 |
|
|
/* $Id$ */
|
| 3 |
|
|
/*
|
| 4 |
|
|
interfaces_bridge.php
|
| 5 |
|
|
|
| 6 |
e395ef5d
|
Ermal Luçi
|
Copyright (C) 2008 Ermal Lu?i
|
| 7 |
648ec0c2
|
Ermal Luçi
|
All rights reserved.
|
| 8 |
|
|
|
| 9 |
|
|
Redistribution and use in source and binary forms, with or without
|
| 10 |
|
|
modification, are permitted provided that the following conditions are met:
|
| 11 |
|
|
|
| 12 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
| 13 |
|
|
this list of conditions and the following disclaimer.
|
| 14 |
|
|
|
| 15 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
| 16 |
|
|
notice, this list of conditions and the following disclaimer in the
|
| 17 |
|
|
documentation and/or other materials provided with the distribution.
|
| 18 |
|
|
|
| 19 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
| 20 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
| 21 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
| 22 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
| 23 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
| 24 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
| 25 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
| 26 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
| 27 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
| 28 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
| 29 |
|
|
*/
|
| 30 |
|
|
|
| 31 |
|
|
require("guiconfig.inc");
|
| 32 |
|
|
|
| 33 |
3134528d
|
Ermal Luçi
|
if (!is_array($config['bridges']['bridged']))
|
| 34 |
|
|
$config['bridges']['bridged'] = array();
|
| 35 |
648ec0c2
|
Ermal Luçi
|
|
| 36 |
3134528d
|
Ermal Luçi
|
$a_bridges = &$config['bridges']['bridged'] ;
|
| 37 |
648ec0c2
|
Ermal Luçi
|
|
| 38 |
|
|
function bridge_inuse($num) {
|
| 39 |
|
|
global $config;
|
| 40 |
|
|
|
| 41 |
|
|
$iflist = get_configured_interface_list(false, true);
|
| 42 |
|
|
foreach ($iflist as $if) {
|
| 43 |
2eedb548
|
Ermal Luçi
|
if ($config['interfaces'][$if]['if'] == $a_bridges[$num]['bridgeif'])
|
| 44 |
648ec0c2
|
Ermal Luçi
|
return true;
|
| 45 |
|
|
}
|
| 46 |
|
|
|
| 47 |
|
|
return false;
|
| 48 |
|
|
}
|
| 49 |
|
|
|
| 50 |
|
|
if ($_GET['act'] == "del") {
|
| 51 |
|
|
/* check if still in use */
|
| 52 |
|
|
if (bridge_inuse($_GET['id'])) {
|
| 53 |
|
|
$input_errors[] = "This bridge TUNNEL cannot be deleted because it is still being used as an interface.";
|
| 54 |
|
|
} else {
|
| 55 |
|
|
mwexec("/sbin/ifconfig " . $a_bridges[$_GET['id']]['bridgeif'] . " destroy");
|
| 56 |
|
|
unset($a_bridges[$_GET['id']]);
|
| 57 |
|
|
|
| 58 |
|
|
write_config();
|
| 59 |
|
|
|
| 60 |
|
|
header("Location: interfaces_bridge.php");
|
| 61 |
|
|
exit;
|
| 62 |
|
|
}
|
| 63 |
|
|
}
|
| 64 |
|
|
|
| 65 |
|
|
|
| 66 |
|
|
$pgtitle = array("Interfaces","Bridge");
|
| 67 |
|
|
include("head.inc");
|
| 68 |
|
|
|
| 69 |
|
|
?>
|
| 70 |
|
|
|
| 71 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
| 72 |
|
|
<?php include("fbegin.inc"); ?>
|
| 73 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
| 74 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
| 75 |
|
|
<tr><td>
|
| 76 |
|
|
<?php
|
| 77 |
|
|
$tab_array = array();
|
| 78 |
|
|
$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
|
| 79 |
|
|
$tab_array[1] = array("VLANs", false, "interfaces_vlan.php");
|
| 80 |
|
|
$tab_array[2] = array("PPP", false, "interfaces_ppp.php");
|
| 81 |
|
|
$tab_array[3] = array("GRE", false, "interfaces_gre.php");
|
| 82 |
|
|
$tab_array[4] = array("GIF", false, "interfaces_gif.php");
|
| 83 |
|
|
$tab_array[5] = array("Bridges", true, "interfaces_bridge.php");
|
| 84 |
417cba65
|
Ermal Luçi
|
$tab_array[6] = array("LAGG", false, "interfaces_lagg.php");
|
| 85 |
648ec0c2
|
Ermal Luçi
|
display_top_tabs($tab_array);
|
| 86 |
|
|
?>
|
| 87 |
|
|
</td></tr>
|
| 88 |
|
|
<tr>
|
| 89 |
|
|
<td>
|
| 90 |
|
|
<div id="mainarea">
|
| 91 |
|
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
| 92 |
|
|
<tr>
|
| 93 |
|
|
<td width="20%" class="listhdrr">Interface</td>
|
| 94 |
|
|
<td width="20%" class="listhdrr">Members</td>
|
| 95 |
|
|
<td width="50%" class="listhdr">Description</td>
|
| 96 |
|
|
<td width="10%" class="list"></td>
|
| 97 |
|
|
</tr>
|
| 98 |
4bd1d5eb
|
Ermal Luçi
|
<?php $i = 0; $ifdescrs = get_configured_interface_with_descr();
|
| 99 |
|
|
foreach ($a_bridges as $bridge): ?>
|
| 100 |
648ec0c2
|
Ermal Luçi
|
<tr>
|
| 101 |
|
|
<td class="listlr">
|
| 102 |
|
|
<?=htmlspecialchars(strtoupper($bridge['bridgeif']));?>
|
| 103 |
|
|
</td>
|
| 104 |
|
|
<td class="listr">
|
| 105 |
4bd1d5eb
|
Ermal Luçi
|
<? $members = explode(',', $bridge['members']);
|
| 106 |
|
|
$j = 0;
|
| 107 |
|
|
foreach ($members as $member) {
|
| 108 |
|
|
if (isset($ifdescrs[$member])) {
|
| 109 |
|
|
echo $ifdescrs[$member];
|
| 110 |
|
|
$j++;
|
| 111 |
|
|
}
|
| 112 |
|
|
if ($j > 1)
|
| 113 |
|
|
echo ", ";
|
| 114 |
|
|
}
|
| 115 |
|
|
?>
|
| 116 |
648ec0c2
|
Ermal Luçi
|
</td>
|
| 117 |
|
|
<td class="listbg">
|
| 118 |
|
|
<?=htmlspecialchars($bridge['descr']);?>
|
| 119 |
|
|
</td>
|
| 120 |
|
|
<td valign="middle" nowrap class="list"> <a href="interfaces_bridge_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
|
| 121 |
|
|
<a href="interfaces_bridge.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this bridge tunnel?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
|
| 122 |
|
|
</tr>
|
| 123 |
|
|
<?php $i++; endforeach; ?>
|
| 124 |
|
|
<tr>
|
| 125 |
|
|
<td class="list" colspan="3"> </td>
|
| 126 |
|
|
<td class="list"> <a href="interfaces_bridge_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
| 127 |
|
|
</tr>
|
| 128 |
|
|
<tr>
|
| 129 |
|
|
<td colspan="3" class="list"><p class="vexpl"><span class="red"><strong>
|
| 130 |
|
|
Note:<br>
|
| 131 |
|
|
</strong></span>
|
| 132 |
|
|
Something meaningful here.
|
| 133 |
|
|
</td>
|
| 134 |
|
|
<td class="list"> </td>
|
| 135 |
|
|
</tr>
|
| 136 |
|
|
</table>
|
| 137 |
|
|
</div>
|
| 138 |
|
|
</td>
|
| 139 |
|
|
</tr>
|
| 140 |
|
|
</table>
|
| 141 |
|
|
<?php include("fend.inc"); ?>
|
| 142 |
|
|
</body>
|
| 143 |
|
|
</html>
|