Project

General

Profile

Download (6.3 KB) Statistics
| Branch: | Tag: | Revision:
1 648ec0c2 Ermal Luçi
<?php
2
/* $Id$ */
3
/*
4
	interfaces_bridge.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
	pfSense_BUILDER_BINARIES:	/bin/rm
33
	pfSense_MODULE:	interfaces_assign
34
*/
35 648ec0c2 Ermal Luçi
36 ea9828af Ermal Lu?i
##|+PRIV
37
##|*IDENT=page-interfaces-bridge
38
##|*NAME=Interfaces: Bridge page
39
##|*DESCR=Allow access to the 'Interfaces: Bridge' page.
40
##|*MATCH=interfaces_bridge.php*
41
##|-PRIV
42
43 648ec0c2 Ermal Luçi
require("guiconfig.inc");
44
45 3134528d Ermal Luçi
if (!is_array($config['bridges']['bridged']))
46
	$config['bridges']['bridged'] = array();
47 648ec0c2 Ermal Luçi
48 3134528d Ermal Luçi
$a_bridges = &$config['bridges']['bridged'] ;
49 648ec0c2 Ermal Luçi
50 9c17db74 Erik Fonnesbeck
function bridge_inuse($num) {
51 c059940b Erik Fonnesbeck
	global $config, $a_bridges;
52 648ec0c2 Ermal Luçi
53
	$iflist = get_configured_interface_list(false, true);
54
	foreach ($iflist as $if) {
55 9c17db74 Erik Fonnesbeck
		if ($config['interfaces'][$if]['if'] == $a_bridges[$num]['bridgeif'])
56 648ec0c2 Ermal Luçi
			return true;
57
	}
58
59
	return false;
60
}
61
62
if ($_GET['act'] == "del") {
63 0e22dda5 Ermal
	if (!isset($_GET['id']))
64 b3f0b2e1 Phil Davis
		$input_errors[] = gettext("Wrong parameters supplied");
65 0e22dda5 Ermal
	else if (empty($a_bridges[$_GET['id']]))
66 b3f0b2e1 Phil Davis
		$input_errors[] = gettext("Wrong index supplied");
67 648ec0c2 Ermal Luçi
	/* check if still in use */
68 0e22dda5 Ermal
	else if (bridge_inuse($_GET['id'])) {
69 9cdd5a84 Carlos Eduardo Ramos
		$input_errors[] = gettext("This bridge cannot be deleted because it is assigned as an interface.");
70 648ec0c2 Ermal Luçi
	} else {
71 a5303b6e Chris Buechler
		if (!does_interface_exist($a_bridges[$_GET['id']]['bridgeif'])) {
72
			log_error("Bridge interface does not exist, skipping ifconfig destroy.");
73
		} else {
74
			mwexec("/sbin/ifconfig " . $a_bridges[$_GET['id']]['bridgeif'] . " destroy");
75
		}
76
		
77 648ec0c2 Ermal Luçi
		unset($a_bridges[$_GET['id']]);
78
79
		write_config();
80
81
		header("Location: interfaces_bridge.php");
82
		exit;
83
	}
84
}
85
86
87 9cdd5a84 Carlos Eduardo Ramos
$pgtitle = array(gettext("Interfaces"),gettext("Bridge"));
88 b32dd0a6 jim-p
$shortcut_section = "interfaces";
89 648ec0c2 Ermal Luçi
include("head.inc");
90
91
?>
92
93
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
94
<?php include("fbegin.inc"); ?>
95
<?php if ($input_errors) print_input_errors($input_errors); ?>
96 7c9aa7dd Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="interfaces bridge">
97 648ec0c2 Ermal Luçi
  <tr><td>
98
<?php
99
	$tab_array = array();
100 9cdd5a84 Carlos Eduardo Ramos
	$tab_array[0] = array(gettext("Interface assignments"), false, "interfaces_assign.php");
101
	$tab_array[1] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
102
	$tab_array[2] = array(gettext("Wireless"), false, "interfaces_wireless.php");
103
	$tab_array[3] = array(gettext("VLANs"), false, "interfaces_vlan.php");
104
	$tab_array[4] = array(gettext("QinQs"), false, "interfaces_qinq.php");
105
	$tab_array[5] = array(gettext("PPPs"), false, "interfaces_ppps.php");
106
	$tab_array[6] = array(gettext("GRE"), false, "interfaces_gre.php");
107
	$tab_array[7] = array(gettext("GIF"), false, "interfaces_gif.php");
108
	$tab_array[8] = array(gettext("Bridges"), true, "interfaces_bridge.php");
109
	$tab_array[9] = array(gettext("LAGG"), false, "interfaces_lagg.php");
110 648ec0c2 Ermal Luçi
	display_top_tabs($tab_array);
111
?>
112
  </td></tr>
113
  <tr>
114
    <td>
115
	<div id="mainarea">
116 7c9aa7dd Colin Fleming
	<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
117 648ec0c2 Ermal Luçi
                <tr>
118 9cdd5a84 Carlos Eduardo Ramos
                  <td width="20%" class="listhdrr"><?=gettext("Interface"); ?></td>
119
                  <td width="20%" class="listhdrr"><?=gettext("Members"); ?></td>
120
                  <td width="50%" class="listhdr"><?=gettext("Description"); ?></td>
121 648ec0c2 Ermal Luçi
                  <td width="10%" class="list"></td>
122
				</tr>
123 4bd1d5eb Ermal Luçi
			  <?php $i = 0; $ifdescrs = get_configured_interface_with_descr();
124
					foreach ($a_bridges as $bridge): ?>
125 fd22be34 Ermal Lu?i
                <tr  ondblclick="document.location='interfaces_bridge_edit.php?id=<?=$i;?>'">
126 648ec0c2 Ermal Luçi
                  <td class="listlr">
127
					<?=htmlspecialchars(strtoupper($bridge['bridgeif']));?>
128
                  </td>
129
                  <td class="listr">
130 a3381369 Colin Fleming
					<?php $members = explode(',', $bridge['members']);
131 4bd1d5eb Ermal Luçi
					$j = 0;
132
					foreach ($members as $member) {
133
						if (isset($ifdescrs[$member])) {
134
							echo $ifdescrs[$member];
135
							$j++;
136
						}
137 ca59a45f Chris Buechler
						if ($j > 0 && $j < count($members))
138 4bd1d5eb Ermal Luçi
							echo ", ";
139
					}
140
					?>
141 648ec0c2 Ermal Luçi
                  </td>
142
                  <td class="listbg">
143
                    <?=htmlspecialchars($bridge['descr']);?>&nbsp;
144
                  </td>
145 7c9aa7dd Colin Fleming
                  <td valign="middle" class="list nowrap"> <a href="interfaces_bridge_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="edit" /></a>
146
                     &nbsp;<a href="interfaces_bridge.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this bridge?"); ?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete" /></a></td>
147 648ec0c2 Ermal Luçi
				</tr>
148
			  <?php $i++; endforeach; ?>
149
                <tr>
150
                  <td class="list" colspan="3">&nbsp;</td>
151 7c9aa7dd Colin Fleming
                  <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" alt="add" /></a></td>
152 648ec0c2 Ermal Luçi
				</tr>
153
				<tr>
154
				<td colspan="3" class="list"><p class="vexpl"><span class="red"><strong>
155 1d7ba683 ayvis
				  <?=gettext("Note:"); ?><br />
156 648ec0c2 Ermal Luçi
				  </strong></span>
157 7c9aa7dd Colin Fleming
				  <?=gettext("Here you can configure bridging of interfaces."); ?></p>
158 648ec0c2 Ermal Luçi
				  </td>
159
				<td class="list">&nbsp;</td>
160
				</tr>
161
              </table>
162
	      </div>
163
	</td>
164
	</tr>
165
</table>
166
<?php include("fend.inc"); ?>
167
</body>
168
</html>