Project

General

Profile

Download (4.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * interfaces_bridge.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2023 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * 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
 *
15
 * http://www.apache.org/licenses/LICENSE-2.0
16
 *
17
 * 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
 */
23

    
24
##|+PRIV
25
##|*IDENT=page-interfaces-bridge
26
##|*NAME=Interfaces: Bridge
27
##|*DESCR=Allow access to the 'Interfaces: Bridge' page.
28
##|*MATCH=interfaces_bridge.php*
29
##|-PRIV
30

    
31
require_once("guiconfig.inc");
32

    
33
init_config_arr(array('bridges', 'bridged'));
34
$a_bridges = &$config['bridges']['bridged'];
35

    
36
function bridge_inuse($num) {
37
	global $config, $a_bridges;
38

    
39
	$iflist = get_configured_interface_list(true);
40

    
41
	foreach ($iflist as $if) {
42
		if ($config['interfaces'][$if]['if'] == $a_bridges[$num]['bridgeif']) {
43
			return true;
44
		}
45
	}
46

    
47
	return false;
48
}
49

    
50
if ($_POST['act'] == "del") {
51
	if (!isset($_POST['id'])) {
52
		$input_errors[] = gettext("Wrong parameters supplied");
53
	} else if (empty($a_bridges[$_POST['id']])) {
54
		$input_errors[] = gettext("Wrong index supplied");
55
	/* check if still in use */
56
	} else if (bridge_inuse($_POST['id'])) {
57
		$input_errors[] = gettext("This bridge cannot be deleted because it is assigned as an interface.");
58
	} else {
59
		if (!does_interface_exist($a_bridges[$_POST['id']]['bridgeif'])) {
60
			log_error("Bridge interface does not exist, skipping ifconfig destroy.");
61
		} else {
62
			pfSense_interface_destroy($a_bridges[$_POST['id']]['bridgeif']);
63
		}
64

    
65
		unset($a_bridges[$_POST['id']]);
66

    
67
		write_config("Bridge deleted");
68

    
69
		header("Location: interfaces_bridge.php");
70
		exit;
71
	}
72
}
73

    
74
$pgtitle = array(gettext("Interfaces"), gettext("Bridges"));
75
$shortcut_section = "interfaces";
76
include("head.inc");
77
if ($input_errors) {
78
	print_input_errors($input_errors);
79
}
80

    
81
$tab_array = array();
82
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
83
$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
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
89
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
90
$tab_array[] = array(gettext("Bridges"), true, "interfaces_bridge.php");
91
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
92
display_top_tabs($tab_array);
93
?>
94
<div class="panel panel-default">
95
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Bridge Interfaces')?></h2></div>
96
	<div class="panel-body">
97
		<div class="table-responsive">
98
			<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
99
				<thead>
100
					<tr>
101
						<th><?=gettext("Interface"); ?></th>
102
						<th><?=gettext("Members"); ?></th>
103
						<th><?=gettext("Description"); ?></th>
104
						<th><?=gettext("Actions"); ?></th>
105
					</tr>
106
				</thead>
107
				<tbody>
108
<?php
109

    
110
$i = 0;
111
$ifdescrs = get_configured_interface_with_descr();
112

    
113
foreach ($a_bridges as $bridge) {
114
?>
115
					<tr>
116
						<td>
117
							<?=htmlspecialchars(strtoupper($bridge['bridgeif']))?>
118
						</td>
119
						<td>
120
<?php
121
	$members = explode(',', $bridge['members']);
122
	$j = 0;
123
	foreach ($members as $member) {
124
		if (isset($ifdescrs[$member])) {
125
			echo $ifdescrs[$member];
126
			$j++;
127
		}
128
		if ($j > 0 && $j < count($members)) {
129
			echo ", ";
130
		}
131
	}
132
?>
133
						</td>
134
						<td>
135
							<?=htmlspecialchars($bridge['descr'])?>
136
						</td>
137
						<td>
138
							<a class="fa fa-pencil"	title="<?=gettext('Edit interface bridge')?>"	href="interfaces_bridge_edit.php?id=<?=$i?>"></a>
139
							<a class="fa fa-trash"	title="<?=gettext('Delete interface bridge')?>"	href="interfaces_bridge.php?act=del&amp;id=<?=$i?>" usepost></a>
140
						</td>
141
					</tr>
142
<?php
143
	$i++;
144
}
145
?>
146
				</tbody>
147
			</table>
148
		</div>
149
	</div>
150
</div>
151

    
152
<nav class="action-buttons">
153
	<a href="interfaces_bridge_edit.php" class="btn btn-success btn-sm">
154
		<i class="fa fa-plus icon-embed-btn"></i>
155
		<?=gettext("Add")?>
156
	</a>
157
</nav>
158

    
159
<?php include("foot.inc");
(73-73/228)