Project

General

Profile

Download (4.53 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-2016 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']['bridged'])) {
32
	$config['bridges']['bridged'] = array();
33
}
34

    
35
$a_bridges = &$config['bridges']['bridged'] ;
36

    
37
function bridge_inuse($num) {
38
	global $config, $a_bridges;
39

    
40
	$iflist = get_configured_interface_list(false, true);
41

    
42
	foreach ($iflist as $if) {
43
		if ($config['interfaces'][$if]['if'] == $a_bridges[$num]['bridgeif']) {
44
			return true;
45
		}
46
	}
47

    
48
	return false;
49
}
50

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

    
66
		unset($a_bridges[$_GET['id']]);
67

    
68
		write_config();
69

    
70
		header("Location: interfaces_bridge.php");
71
		exit;
72
	}
73
}
74

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

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

    
111
$i = 0;
112
$ifdescrs = get_configured_interface_with_descr();
113

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

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

    
160
<?php include("foot.inc");
(67-67/223)