Project

General

Profile

Download (4.67 KB) Statistics
| Branch: | Tag: | Revision:
1 648ec0c2 Ermal Luçi
<?php
2
/*
3 c5d81585 Renato Botelho
 * interfaces_bridge.php
4 b9043cdc Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 38809d47 Renato Botelho do Couto
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8 0284d79e jim-p
 * Copyright (c) 2014-2020 Rubicon Communications, LLC (Netgate)
9 c5d81585 Renato Botelho
 * All rights reserved.
10 b9043cdc Stephen Beaver
 *
11 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
12
 * you may not use this file except in compliance with the License.
13
 * You may obtain a copy of the License at
14 b9043cdc Stephen Beaver
 *
15 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
16 b9043cdc Stephen Beaver
 *
17 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
18
 * distributed under the License is distributed on an "AS IS" BASIS,
19
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
 * See the License for the specific language governing permissions and
21
 * limitations under the License.
22 b9043cdc Stephen Beaver
 */
23 648ec0c2 Ermal Luçi
24 ea9828af Ermal Lu?i
##|+PRIV
25
##|*IDENT=page-interfaces-bridge
26 5230f468 jim-p
##|*NAME=Interfaces: Bridge
27 ea9828af Ermal Lu?i
##|*DESCR=Allow access to the 'Interfaces: Bridge' page.
28
##|*MATCH=interfaces_bridge.php*
29
##|-PRIV
30
31 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
32 648ec0c2 Ermal Luçi
33 c6c398c6 jim-p
init_config_arr(array('bridges', 'bridged'));
34
$a_bridges = &$config['bridges']['bridged'];
35 648ec0c2 Ermal Luçi
36 9c17db74 Erik Fonnesbeck
function bridge_inuse($num) {
37 c059940b Erik Fonnesbeck
	global $config, $a_bridges;
38 648ec0c2 Ermal Luçi
39 80fe8369 Phil Davis
	$iflist = get_configured_interface_list(true);
40 461f8fd1 sbeaver
41 648ec0c2 Ermal Luçi
	foreach ($iflist as $if) {
42 2af86dda Phil Davis
		if ($config['interfaces'][$if]['if'] == $a_bridges[$num]['bridgeif']) {
43 648ec0c2 Ermal Luçi
			return true;
44 2af86dda Phil Davis
		}
45 648ec0c2 Ermal Luçi
	}
46
47
	return false;
48
}
49
50 c5ae2b4d Steve Beaver
if ($_POST['act'] == "del") {
51
	if (!isset($_POST['id'])) {
52 b3f0b2e1 Phil Davis
		$input_errors[] = gettext("Wrong parameters supplied");
53 c5ae2b4d Steve Beaver
	} else if (empty($a_bridges[$_POST['id']])) {
54 b3f0b2e1 Phil Davis
		$input_errors[] = gettext("Wrong index supplied");
55 648ec0c2 Ermal Luçi
	/* check if still in use */
56 c5ae2b4d Steve Beaver
	} else if (bridge_inuse($_POST['id'])) {
57 9cdd5a84 Carlos Eduardo Ramos
		$input_errors[] = gettext("This bridge cannot be deleted because it is assigned as an interface.");
58 648ec0c2 Ermal Luçi
	} else {
59 c5ae2b4d Steve Beaver
		if (!does_interface_exist($a_bridges[$_POST['id']]['bridgeif'])) {
60 a5303b6e Chris Buechler
			log_error("Bridge interface does not exist, skipping ifconfig destroy.");
61
		} else {
62 c5ae2b4d Steve Beaver
			pfSense_interface_destroy($a_bridges[$_POST['id']]['bridgeif']);
63 a5303b6e Chris Buechler
		}
64 34998435 sbeaver
65 c5ae2b4d Steve Beaver
		unset($a_bridges[$_POST['id']]);
66 648ec0c2 Ermal Luçi
67 e85ae672 Renato Botelho do Couto
		write_config("Bridge deleted");
68 648ec0c2 Ermal Luçi
69
		header("Location: interfaces_bridge.php");
70
		exit;
71
	}
72
}
73
74 26b4bef8 k-paulius
$pgtitle = array(gettext("Interfaces"), gettext("Bridges"));
75 b32dd0a6 jim-p
$shortcut_section = "interfaces";
76 648ec0c2 Ermal Luçi
include("head.inc");
77 aa82505e Phil Davis
if ($input_errors) {
78
	print_input_errors($input_errors);
79
}
80 648ec0c2 Ermal Luçi
81 34998435 sbeaver
$tab_array = array();
82 26b4bef8 k-paulius
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
83 461f8fd1 sbeaver
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
84
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
85
$tab_array[] = array(gettext("VLANs"), false, "interfaces_vlan.php");
86
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
87
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
88 26b4bef8 k-paulius
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
89
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
90 b6ea9c61 Viktor G
$tab_array[] = array(gettext("VXLANs"), false, "interfaces_vxlan.php");
91 461f8fd1 sbeaver
$tab_array[] = array(gettext("Bridges"), true, "interfaces_bridge.php");
92 26b4bef8 k-paulius
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
93 34998435 sbeaver
display_top_tabs($tab_array);
94 648ec0c2 Ermal Luçi
?>
95 060ed238 Stephen Beaver
<div class="panel panel-default">
96 70dc5cd6 Phil Davis
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Bridge Interfaces')?></h2></div>
97 060ed238 Stephen Beaver
	<div class="panel-body">
98
		<div class="table-responsive">
99 1c10ce97 PiBa-NL
			<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
100 060ed238 Stephen Beaver
				<thead>
101
					<tr>
102 70dc5cd6 Phil Davis
						<th><?=gettext("Interface"); ?></th>
103
						<th><?=gettext("Members"); ?></th>
104
						<th><?=gettext("Description"); ?></th>
105
						<th><?=gettext("Actions"); ?></th>
106 060ed238 Stephen Beaver
					</tr>
107
				</thead>
108
				<tbody>
109 648ec0c2 Ermal Luçi
<?php
110 34998435 sbeaver
111
$i = 0;
112
$ifdescrs = get_configured_interface_with_descr();
113
114
foreach ($a_bridges as $bridge) {
115 648ec0c2 Ermal Luçi
?>
116 060ed238 Stephen Beaver
					<tr>
117
						<td>
118
							<?=htmlspecialchars(strtoupper($bridge['bridgeif']))?>
119
						</td>
120
						<td>
121 34998435 sbeaver
<?php
122
	$members = explode(',', $bridge['members']);
123
	$j = 0;
124
	foreach ($members as $member) {
125
		if (isset($ifdescrs[$member])) {
126
			echo $ifdescrs[$member];
127
			$j++;
128
		}
129 aa82505e Phil Davis
		if ($j > 0 && $j < count($members)) {
130 34998435 sbeaver
			echo ", ";
131 aa82505e Phil Davis
		}
132 34998435 sbeaver
	}
133
?>
134 060ed238 Stephen Beaver
						</td>
135
						<td>
136
							<?=htmlspecialchars($bridge['descr'])?>
137
						</td>
138
						<td>
139 4401107f Steve Beaver
							<a class="fa fa-pencil"	title="<?=gettext('Edit interface bridge')?>"	href="interfaces_bridge_edit.php?id=<?=$i?>"></a>
140 c5ae2b4d Steve Beaver
							<a class="fa fa-trash"	title="<?=gettext('Delete interface bridge')?>"	href="interfaces_bridge.php?act=del&amp;id=<?=$i?>" usepost></a>
141 060ed238 Stephen Beaver
						</td>
142
					</tr>
143 34998435 sbeaver
<?php
144
	$i++;
145
}
146
?>
147 060ed238 Stephen Beaver
				</tbody>
148
			</table>
149
		</div>
150
	</div>
151 34998435 sbeaver
</div>
152
153 060ed238 Stephen Beaver
<nav class="action-buttons">
154 4401107f Steve Beaver
	<a href="interfaces_bridge_edit.php" class="btn btn-success btn-sm">
155 060ed238 Stephen Beaver
		<i class="fa fa-plus icon-embed-btn"></i>
156
		<?=gettext("Add")?>
157
	</a>
158
</nav>
159
160 d9cfc587 heper
<?php include("foot.inc");