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