Project

General

Profile

Download (4.73 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-2024 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
config_init_path('bridges/bridged');
34

    
35
function bridge_inuse($num) {
36
	$a_bridges = config_get_path('bridges/bridged');
37
	$iflist = get_configured_interface_list(true);
38
	$if_config = config_get_path('interfaces');
39
	foreach ($iflist as $if) {
40
		if ($if_config[$if]['if'] == $a_bridges[$num]['bridgeif']) {
41
			return true;
42
		}
43
	}
44

    
45
	return false;
46
}
47

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

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

    
65
		write_config("Bridge deleted");
66

    
67
		header("Location: interfaces_bridge.php");
68
		exit;
69
	}
70
}
71

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

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

    
108
$i = 0;
109
$ifdescrs = get_configured_interface_with_descr();
110

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

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

    
157
<?php include("foot.inc");
(75-75/232)