Project

General

Profile

Download (4.7 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-2025 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
function bridge_inuse($num) {
34
	$a_bridges = config_get_path('bridges/bridged', []);
35
	$iflist = get_configured_interface_list(true);
36
	$if_config = config_get_path('interfaces', []);
37
	foreach ($iflist as $if) {
38
		if ($if_config[$if]['if'] == $a_bridges[$num]['bridgeif']) {
39
			return true;
40
		}
41
	}
42

    
43
	return false;
44
}
45

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

    
61
		config_del_path("bridges/bridged/{$_POST['id']}");
62

    
63
		write_config("Bridge deleted");
64

    
65
		header("Location: interfaces_bridge.php");
66
		exit;
67
	}
68
}
69

    
70
$pgtitle = array(gettext("Interfaces"), gettext("Bridges"));
71
$shortcut_section = "interfaces";
72
include("head.inc");
73
if ($input_errors) {
74
	print_input_errors($input_errors);
75
}
76

    
77
$tab_array = array();
78
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
79
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
80
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
81
$tab_array[] = array(gettext("VLANs"), false, "interfaces_vlan.php");
82
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
83
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
84
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
85
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
86
$tab_array[] = array(gettext("Bridges"), true, "interfaces_bridge.php");
87
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
88
display_top_tabs($tab_array);
89
?>
90
<div class="panel panel-default">
91
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Bridge Interfaces')?></h2></div>
92
	<div class="panel-body">
93
		<div class="table-responsive">
94
			<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
95
				<thead>
96
					<tr>
97
						<th><?=gettext("Interface"); ?></th>
98
						<th><?=gettext("Members"); ?></th>
99
						<th><?=gettext("Description"); ?></th>
100
						<th><?=gettext("Actions"); ?></th>
101
					</tr>
102
				</thead>
103
				<tbody>
104
<?php
105

    
106
$i = 0;
107
$ifdescrs = get_configured_interface_with_descr();
108

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

    
148
<nav class="action-buttons">
149
	<a href="interfaces_bridge_edit.php" class="btn btn-success btn-sm">
150
		<i class="fa-solid fa-plus icon-embed-btn"></i>
151
		<?=gettext("Add")?>
152
	</a>
153
</nav>
154

    
155
<?php include("foot.inc");
(75-75/233)