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 |
b8f91b7c
|
Luiz Souza
|
* Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
8 |
b9043cdc
|
Stephen Beaver
|
*
|
9 |
b12ea3fb
|
Renato Botelho
|
* 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 |
b9043cdc
|
Stephen Beaver
|
*
|
13 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
14 |
b9043cdc
|
Stephen Beaver
|
*
|
15 |
b12ea3fb
|
Renato Botelho
|
* 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 |
b9043cdc
|
Stephen Beaver
|
*/
|
21 |
648ec0c2
|
Ermal Luçi
|
|
22 |
ea9828af
|
Ermal Lu?i
|
##|+PRIV
|
23 |
|
|
##|*IDENT=page-interfaces-bridge
|
24 |
5230f468
|
jim-p
|
##|*NAME=Interfaces: Bridge
|
25 |
ea9828af
|
Ermal Lu?i
|
##|*DESCR=Allow access to the 'Interfaces: Bridge' page.
|
26 |
|
|
##|*MATCH=interfaces_bridge.php*
|
27 |
|
|
##|-PRIV
|
28 |
|
|
|
29 |
c81ef6e2
|
Phil Davis
|
require_once("guiconfig.inc");
|
30 |
648ec0c2
|
Ermal Luçi
|
|
31 |
6f331d22
|
Stephen Jones
|
if (!is_array($config['bridges'])) {
|
32 |
|
|
$config['bridges'] = array();
|
33 |
|
|
}
|
34 |
|
|
|
35 |
2af86dda
|
Phil Davis
|
if (!is_array($config['bridges']['bridged'])) {
|
36 |
3134528d
|
Ermal Luçi
|
$config['bridges']['bridged'] = array();
|
37 |
2af86dda
|
Phil Davis
|
}
|
38 |
648ec0c2
|
Ermal Luçi
|
|
39 |
3134528d
|
Ermal Luçi
|
$a_bridges = &$config['bridges']['bridged'] ;
|
40 |
648ec0c2
|
Ermal Luçi
|
|
41 |
9c17db74
|
Erik Fonnesbeck
|
function bridge_inuse($num) {
|
42 |
c059940b
|
Erik Fonnesbeck
|
global $config, $a_bridges;
|
43 |
648ec0c2
|
Ermal Luçi
|
|
44 |
80fe8369
|
Phil Davis
|
$iflist = get_configured_interface_list(true);
|
45 |
461f8fd1
|
sbeaver
|
|
46 |
648ec0c2
|
Ermal Luçi
|
foreach ($iflist as $if) {
|
47 |
2af86dda
|
Phil Davis
|
if ($config['interfaces'][$if]['if'] == $a_bridges[$num]['bridgeif']) {
|
48 |
648ec0c2
|
Ermal Luçi
|
return true;
|
49 |
2af86dda
|
Phil Davis
|
}
|
50 |
648ec0c2
|
Ermal Luçi
|
}
|
51 |
|
|
|
52 |
|
|
return false;
|
53 |
|
|
}
|
54 |
|
|
|
55 |
c5ae2b4d
|
Steve Beaver
|
if ($_POST['act'] == "del") {
|
56 |
|
|
if (!isset($_POST['id'])) {
|
57 |
b3f0b2e1
|
Phil Davis
|
$input_errors[] = gettext("Wrong parameters supplied");
|
58 |
c5ae2b4d
|
Steve Beaver
|
} else if (empty($a_bridges[$_POST['id']])) {
|
59 |
b3f0b2e1
|
Phil Davis
|
$input_errors[] = gettext("Wrong index supplied");
|
60 |
648ec0c2
|
Ermal Luçi
|
/* check if still in use */
|
61 |
c5ae2b4d
|
Steve Beaver
|
} else if (bridge_inuse($_POST['id'])) {
|
62 |
9cdd5a84
|
Carlos Eduardo Ramos
|
$input_errors[] = gettext("This bridge cannot be deleted because it is assigned as an interface.");
|
63 |
648ec0c2
|
Ermal Luçi
|
} else {
|
64 |
c5ae2b4d
|
Steve Beaver
|
if (!does_interface_exist($a_bridges[$_POST['id']]['bridgeif'])) {
|
65 |
a5303b6e
|
Chris Buechler
|
log_error("Bridge interface does not exist, skipping ifconfig destroy.");
|
66 |
|
|
} else {
|
67 |
c5ae2b4d
|
Steve Beaver
|
pfSense_interface_destroy($a_bridges[$_POST['id']]['bridgeif']);
|
68 |
a5303b6e
|
Chris Buechler
|
}
|
69 |
34998435
|
sbeaver
|
|
70 |
c5ae2b4d
|
Steve Beaver
|
unset($a_bridges[$_POST['id']]);
|
71 |
648ec0c2
|
Ermal Luçi
|
|
72 |
|
|
write_config();
|
73 |
|
|
|
74 |
|
|
header("Location: interfaces_bridge.php");
|
75 |
|
|
exit;
|
76 |
|
|
}
|
77 |
|
|
}
|
78 |
|
|
|
79 |
26b4bef8
|
k-paulius
|
$pgtitle = array(gettext("Interfaces"), gettext("Bridges"));
|
80 |
b32dd0a6
|
jim-p
|
$shortcut_section = "interfaces";
|
81 |
648ec0c2
|
Ermal Luçi
|
include("head.inc");
|
82 |
aa82505e
|
Phil Davis
|
if ($input_errors) {
|
83 |
|
|
print_input_errors($input_errors);
|
84 |
|
|
}
|
85 |
648ec0c2
|
Ermal Luçi
|
|
86 |
34998435
|
sbeaver
|
$tab_array = array();
|
87 |
26b4bef8
|
k-paulius
|
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
|
88 |
461f8fd1
|
sbeaver
|
$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 |
26b4bef8
|
k-paulius
|
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
|
94 |
|
|
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
|
95 |
461f8fd1
|
sbeaver
|
$tab_array[] = array(gettext("Bridges"), true, "interfaces_bridge.php");
|
96 |
26b4bef8
|
k-paulius
|
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
|
97 |
34998435
|
sbeaver
|
display_top_tabs($tab_array);
|
98 |
648ec0c2
|
Ermal Luçi
|
?>
|
99 |
060ed238
|
Stephen Beaver
|
<div class="panel panel-default">
|
100 |
70dc5cd6
|
Phil Davis
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Bridge Interfaces')?></h2></div>
|
101 |
060ed238
|
Stephen Beaver
|
<div class="panel-body">
|
102 |
|
|
<div class="table-responsive">
|
103 |
1c10ce97
|
PiBa-NL
|
<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
|
104 |
060ed238
|
Stephen Beaver
|
<thead>
|
105 |
|
|
<tr>
|
106 |
70dc5cd6
|
Phil Davis
|
<th><?=gettext("Interface"); ?></th>
|
107 |
|
|
<th><?=gettext("Members"); ?></th>
|
108 |
|
|
<th><?=gettext("Description"); ?></th>
|
109 |
|
|
<th><?=gettext("Actions"); ?></th>
|
110 |
060ed238
|
Stephen Beaver
|
</tr>
|
111 |
|
|
</thead>
|
112 |
|
|
<tbody>
|
113 |
648ec0c2
|
Ermal Luçi
|
<?php
|
114 |
34998435
|
sbeaver
|
|
115 |
|
|
$i = 0;
|
116 |
|
|
$ifdescrs = get_configured_interface_with_descr();
|
117 |
|
|
|
118 |
|
|
foreach ($a_bridges as $bridge) {
|
119 |
648ec0c2
|
Ermal Luçi
|
?>
|
120 |
060ed238
|
Stephen Beaver
|
<tr>
|
121 |
|
|
<td>
|
122 |
|
|
<?=htmlspecialchars(strtoupper($bridge['bridgeif']))?>
|
123 |
|
|
</td>
|
124 |
|
|
<td>
|
125 |
34998435
|
sbeaver
|
<?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 |
aa82505e
|
Phil Davis
|
if ($j > 0 && $j < count($members)) {
|
134 |
34998435
|
sbeaver
|
echo ", ";
|
135 |
aa82505e
|
Phil Davis
|
}
|
136 |
34998435
|
sbeaver
|
}
|
137 |
|
|
?>
|
138 |
060ed238
|
Stephen Beaver
|
</td>
|
139 |
|
|
<td>
|
140 |
|
|
<?=htmlspecialchars($bridge['descr'])?>
|
141 |
|
|
</td>
|
142 |
|
|
<td>
|
143 |
4401107f
|
Steve Beaver
|
<a class="fa fa-pencil" title="<?=gettext('Edit interface bridge')?>" href="interfaces_bridge_edit.php?id=<?=$i?>"></a>
|
144 |
c5ae2b4d
|
Steve Beaver
|
<a class="fa fa-trash" title="<?=gettext('Delete interface bridge')?>" href="interfaces_bridge.php?act=del&id=<?=$i?>" usepost></a>
|
145 |
060ed238
|
Stephen Beaver
|
</td>
|
146 |
|
|
</tr>
|
147 |
34998435
|
sbeaver
|
<?php
|
148 |
|
|
$i++;
|
149 |
|
|
}
|
150 |
|
|
?>
|
151 |
060ed238
|
Stephen Beaver
|
</tbody>
|
152 |
|
|
</table>
|
153 |
|
|
</div>
|
154 |
|
|
</div>
|
155 |
34998435
|
sbeaver
|
</div>
|
156 |
|
|
|
157 |
060ed238
|
Stephen Beaver
|
<nav class="action-buttons">
|
158 |
4401107f
|
Steve Beaver
|
<a href="interfaces_bridge_edit.php" class="btn btn-success btn-sm">
|
159 |
060ed238
|
Stephen Beaver
|
<i class="fa fa-plus icon-embed-btn"></i>
|
160 |
|
|
<?=gettext("Add")?>
|
161 |
|
|
</a>
|
162 |
|
|
</nav>
|
163 |
|
|
|
164 |
d9cfc587
|
heper
|
<?php include("foot.inc");
|