Project

General

Profile

Download (4.73 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 a68f7a3d Luiz Otavio O Souza
 * Copyright (c) 2014-2024 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 63d6bb4f Marcos Mendoza
config_init_path('bridges/bridged');
34 648ec0c2 Ermal Luçi
35 9c17db74 Erik Fonnesbeck
function bridge_inuse($num) {
36 63d6bb4f Marcos Mendoza
	$a_bridges = config_get_path('bridges/bridged');
37 80fe8369 Phil Davis
	$iflist = get_configured_interface_list(true);
38 63d6bb4f Marcos Mendoza
	$if_config = config_get_path('interfaces');
39 648ec0c2 Ermal Luçi
	foreach ($iflist as $if) {
40 63d6bb4f Marcos Mendoza
		if ($if_config[$if]['if'] == $a_bridges[$num]['bridgeif']) {
41 648ec0c2 Ermal Luçi
			return true;
42 2af86dda Phil Davis
		}
43 648ec0c2 Ermal Luçi
	}
44
45
	return false;
46
}
47
48 c5ae2b4d Steve Beaver
if ($_POST['act'] == "del") {
49
	if (!isset($_POST['id'])) {
50 b3f0b2e1 Phil Davis
		$input_errors[] = gettext("Wrong parameters supplied");
51 63d6bb4f Marcos Mendoza
	} else if (empty(config_get_path("bridges/bridged/{$_POST['id']}"))) {
52 b3f0b2e1 Phil Davis
		$input_errors[] = gettext("Wrong index supplied");
53 648ec0c2 Ermal Luçi
	/* check if still in use */
54 c5ae2b4d Steve Beaver
	} else if (bridge_inuse($_POST['id'])) {
55 9cdd5a84 Carlos Eduardo Ramos
		$input_errors[] = gettext("This bridge cannot be deleted because it is assigned as an interface.");
56 648ec0c2 Ermal Luçi
	} else {
57 63d6bb4f Marcos Mendoza
		if (!does_interface_exist(config_get_path("bridges/bridged/{$_POST['id']}/bridgeif"))) {
58 a5303b6e Chris Buechler
			log_error("Bridge interface does not exist, skipping ifconfig destroy.");
59
		} else {
60 63d6bb4f Marcos Mendoza
			pfSense_interface_destroy(config_get_path("bridges/bridged/{$_POST['id']}/bridgeif"));
61 a5303b6e Chris Buechler
		}
62 34998435 sbeaver
63 63d6bb4f Marcos Mendoza
		config_del_path("bridges/bridged/{$_POST['id']}");
64 648ec0c2 Ermal Luçi
65 e85ae672 Renato Botelho do Couto
		write_config("Bridge deleted");
66 648ec0c2 Ermal Luçi
67
		header("Location: interfaces_bridge.php");
68
		exit;
69
	}
70
}
71
72 26b4bef8 k-paulius
$pgtitle = array(gettext("Interfaces"), gettext("Bridges"));
73 b32dd0a6 jim-p
$shortcut_section = "interfaces";
74 648ec0c2 Ermal Luçi
include("head.inc");
75 aa82505e Phil Davis
if ($input_errors) {
76
	print_input_errors($input_errors);
77
}
78 648ec0c2 Ermal Luçi
79 34998435 sbeaver
$tab_array = array();
80 26b4bef8 k-paulius
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
81 461f8fd1 sbeaver
$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 26b4bef8 k-paulius
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
87
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
88 461f8fd1 sbeaver
$tab_array[] = array(gettext("Bridges"), true, "interfaces_bridge.php");
89 26b4bef8 k-paulius
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
90 34998435 sbeaver
display_top_tabs($tab_array);
91 648ec0c2 Ermal Luçi
?>
92 060ed238 Stephen Beaver
<div class="panel panel-default">
93 70dc5cd6 Phil Davis
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Bridge Interfaces')?></h2></div>
94 060ed238 Stephen Beaver
	<div class="panel-body">
95
		<div class="table-responsive">
96 1c10ce97 PiBa-NL
			<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
97 060ed238 Stephen Beaver
				<thead>
98
					<tr>
99 70dc5cd6 Phil Davis
						<th><?=gettext("Interface"); ?></th>
100
						<th><?=gettext("Members"); ?></th>
101
						<th><?=gettext("Description"); ?></th>
102
						<th><?=gettext("Actions"); ?></th>
103 060ed238 Stephen Beaver
					</tr>
104
				</thead>
105
				<tbody>
106 648ec0c2 Ermal Luçi
<?php
107 34998435 sbeaver
108
$i = 0;
109
$ifdescrs = get_configured_interface_with_descr();
110
111 4b9165e5 Marcos Mendoza
foreach (config_get_path('bridges/bridged', []) as $bridge) {
112 648ec0c2 Ermal Luçi
?>
113 060ed238 Stephen Beaver
					<tr>
114
						<td>
115
							<?=htmlspecialchars(strtoupper($bridge['bridgeif']))?>
116
						</td>
117
						<td>
118 34998435 sbeaver
<?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 aa82505e Phil Davis
		if ($j > 0 && $j < count($members)) {
127 34998435 sbeaver
			echo ", ";
128 aa82505e Phil Davis
		}
129 34998435 sbeaver
	}
130
?>
131 060ed238 Stephen Beaver
						</td>
132
						<td>
133
							<?=htmlspecialchars($bridge['descr'])?>
134
						</td>
135
						<td>
136 e0cb987c Marcos Mendoza
							<a class="fa-solid fa-pencil"	title="<?=gettext('Edit interface bridge')?>"	href="interfaces_bridge_edit.php?id=<?=$i?>"></a>
137 c1d304b3 Marcos Mendoza
							<a class="fa-solid fa-trash-can"	title="<?=gettext('Delete interface bridge')?>"	href="interfaces_bridge.php?act=del&amp;id=<?=$i?>" usepost></a>
138 060ed238 Stephen Beaver
						</td>
139
					</tr>
140 34998435 sbeaver
<?php
141
	$i++;
142
}
143
?>
144 060ed238 Stephen Beaver
				</tbody>
145
			</table>
146
		</div>
147
	</div>
148 34998435 sbeaver
</div>
149
150 060ed238 Stephen Beaver
<nav class="action-buttons">
151 4401107f Steve Beaver
	<a href="interfaces_bridge_edit.php" class="btn btn-success btn-sm">
152 e0cb987c Marcos Mendoza
		<i class="fa-solid fa-plus icon-embed-btn"></i>
153 060ed238 Stephen Beaver
		<?=gettext("Add")?>
154
	</a>
155
</nav>
156
157 d9cfc587 heper
<?php include("foot.inc");