Project

General

Profile

Download (4.87 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 34998435 sbeaver
	pfSense_MODULE: interfaces_assign
34 7ac5a4cb Scott Ullrich
*/
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 2af86dda Phil Davis
if (!is_array($config['bridges']['bridged'])) {
46 3134528d Ermal Luçi
	$config['bridges']['bridged'] = array();
47 2af86dda Phil Davis
}
48 648ec0c2 Ermal Luçi
49 3134528d Ermal Luçi
$a_bridges = &$config['bridges']['bridged'] ;
50 648ec0c2 Ermal Luçi
51 9c17db74 Erik Fonnesbeck
function bridge_inuse($num) {
52 c059940b Erik Fonnesbeck
	global $config, $a_bridges;
53 648ec0c2 Ermal Luçi
54
	$iflist = get_configured_interface_list(false, true);
55 461f8fd1 sbeaver
56 648ec0c2 Ermal Luçi
	foreach ($iflist as $if) {
57 2af86dda Phil Davis
		if ($config['interfaces'][$if]['if'] == $a_bridges[$num]['bridgeif']) {
58 648ec0c2 Ermal Luçi
			return true;
59 2af86dda Phil Davis
		}
60 648ec0c2 Ermal Luçi
	}
61
62
	return false;
63
}
64
65
if ($_GET['act'] == "del") {
66 2af86dda Phil Davis
	if (!isset($_GET['id'])) {
67 b3f0b2e1 Phil Davis
		$input_errors[] = gettext("Wrong parameters supplied");
68 2af86dda Phil Davis
	} else if (empty($a_bridges[$_GET['id']])) {
69 b3f0b2e1 Phil Davis
		$input_errors[] = gettext("Wrong index supplied");
70 648ec0c2 Ermal Luçi
	/* check if still in use */
71 2af86dda Phil Davis
	} else if (bridge_inuse($_GET['id'])) {
72 9cdd5a84 Carlos Eduardo Ramos
		$input_errors[] = gettext("This bridge cannot be deleted because it is assigned as an interface.");
73 648ec0c2 Ermal Luçi
	} else {
74 a5303b6e Chris Buechler
		if (!does_interface_exist($a_bridges[$_GET['id']]['bridgeif'])) {
75
			log_error("Bridge interface does not exist, skipping ifconfig destroy.");
76
		} else {
77
			mwexec("/sbin/ifconfig " . $a_bridges[$_GET['id']]['bridgeif'] . " destroy");
78
		}
79 34998435 sbeaver
80 648ec0c2 Ermal Luçi
		unset($a_bridges[$_GET['id']]);
81
82
		write_config();
83
84
		header("Location: interfaces_bridge.php");
85
		exit;
86
	}
87
}
88
89 9cdd5a84 Carlos Eduardo Ramos
$pgtitle = array(gettext("Interfaces"),gettext("Bridge"));
90 b32dd0a6 jim-p
$shortcut_section = "interfaces";
91 648ec0c2 Ermal Luçi
include("head.inc");
92 34998435 sbeaver
if ($input_errors)
93
	print_input_errors($input_errors); ?>
94 648ec0c2 Ermal Luçi
95 34998435 sbeaver
<?php
96
$tab_array = array();
97 461f8fd1 sbeaver
$tab_array[] = array(gettext("Interface assignments"), false, "interfaces_assign.php");
98
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
99
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
100
$tab_array[] = array(gettext("VLANs"), false, "interfaces_vlan.php");
101
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
102
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
103
$tab_array[] = array(gettext("GRE"), false, "interfaces_gre.php");
104
$tab_array[] = array(gettext("GIF"), false, "interfaces_gif.php");
105
$tab_array[] = array(gettext("Bridges"), true, "interfaces_bridge.php");
106
$tab_array[] = array(gettext("LAGG"), false, "interfaces_lagg.php");
107 34998435 sbeaver
display_top_tabs($tab_array);
108 648ec0c2 Ermal Luçi
?>
109
110 34998435 sbeaver
<div class="table-responsive">
111
	<table class="table table-striped table-hover table-condensed">
112
		<thead>
113
			<tr>
114
			  <th><?=gettext("Interface"); ?></th>
115
			  <th><?=gettext("Members"); ?></th>
116
			  <th><?=gettext("Description"); ?></th>
117
			  <th></th>
118
			</tr>
119
		</thead>
120
		<tbody>
121 648ec0c2 Ermal Luçi
<?php
122 34998435 sbeaver
123
$i = 0;
124
$ifdescrs = get_configured_interface_with_descr();
125
126
foreach ($a_bridges as $bridge) {
127 648ec0c2 Ermal Luçi
?>
128 461f8fd1 sbeaver
			<tr>
129
				<td>
130 34998435 sbeaver
					<?=htmlspecialchars(strtoupper($bridge['bridgeif']))?>
131
				</td>
132
				<td>
133
<?php
134
	$members = explode(',', $bridge['members']);
135
	$j = 0;
136
	foreach ($members as $member) {
137
		if (isset($ifdescrs[$member])) {
138
			echo $ifdescrs[$member];
139
			$j++;
140
		}
141
		if ($j > 0 && $j < count($members))
142
			echo ", ";
143
	}
144
?>
145
				</td>
146
				<td>
147 77d42518 sbeaver
					<?=htmlspecialchars($bridge['descr'])?>
148 34998435 sbeaver
				</td>
149
				<td>
150 77d42518 sbeaver
					<a href="interfaces_bridge_edit.php?id=<?=$i?>" class="btn btn-default btn-xs"><?=gettext("Edit")?></a>
151
					<a href="interfaces_bridge.php?act=del&amp;id=<?=$i?>" class="btn btn-danger btn-xs"><?=gettext("Delete")?></a>
152 34998435 sbeaver
				</td>
153
			</tr>
154
<?php
155
	$i++;
156
}
157
?>
158
		</tbody>
159
	</table>
160
161 cf46aed2 sbeaver
	<nav class="action-buttons">
162
		<a href="interfaces_bridge_edit.php" class="btn btn-success"><?=gettext("Add")?></a>
163
	</nav>
164 34998435 sbeaver
165
</div>
166
167
<?php include("foot.inc");