Project

General

Profile

Download (4.87 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces_bridge.php
5

    
6
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
7
	Copyright (C) 2008 Ermal Luçi
8
	All rights reserved.
9

    
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

    
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15

    
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19

    
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31
/*
32
	pfSense_BUILDER_BINARIES:	/bin/rm
33
	pfSense_MODULE: interfaces_assign
34
*/
35

    
36
##|+PRIV
37
##|*IDENT=page-interfaces-bridge
38
##|*NAME=Interfaces: Bridge page
39
##|*DESCR=Allow access to the 'Interfaces: Bridge' page.
40
##|*MATCH=interfaces_bridge.php*
41
##|-PRIV
42

    
43
require("guiconfig.inc");
44

    
45
if (!is_array($config['bridges']['bridged'])) {
46
	$config['bridges']['bridged'] = array();
47
}
48

    
49
$a_bridges = &$config['bridges']['bridged'] ;
50

    
51
function bridge_inuse($num) {
52
	global $config, $a_bridges;
53

    
54
	$iflist = get_configured_interface_list(false, true);
55

    
56
	foreach ($iflist as $if) {
57
		if ($config['interfaces'][$if]['if'] == $a_bridges[$num]['bridgeif']) {
58
			return true;
59
		}
60
	}
61

    
62
	return false;
63
}
64

    
65
if ($_GET['act'] == "del") {
66
	if (!isset($_GET['id'])) {
67
		$input_errors[] = gettext("Wrong parameters supplied");
68
	} else if (empty($a_bridges[$_GET['id']])) {
69
		$input_errors[] = gettext("Wrong index supplied");
70
	/* check if still in use */
71
	} else if (bridge_inuse($_GET['id'])) {
72
		$input_errors[] = gettext("This bridge cannot be deleted because it is assigned as an interface.");
73
	} else {
74
		if (!does_interface_exist($a_bridges[$_GET['id']]['bridgeif'])) {
75
			log_error("Bridge interface does not exist, skipping ifconfig destroy.");
76
		} else {
77
			mwexec("/sbin/ifconfig " . $a_bridges[$_GET['id']]['bridgeif'] . " destroy");
78
		}
79

    
80
		unset($a_bridges[$_GET['id']]);
81

    
82
		write_config();
83

    
84
		header("Location: interfaces_bridge.php");
85
		exit;
86
	}
87
}
88

    
89
$pgtitle = array(gettext("Interfaces"),gettext("Bridge"));
90
$shortcut_section = "interfaces";
91
include("head.inc");
92
if ($input_errors)
93
	print_input_errors($input_errors); ?>
94

    
95
<?php
96
$tab_array = array();
97
$tab_array[] = array(gettext("Interface assignments"), false, "interfaces_assign.php");
98
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
99
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
100
$tab_array[] = array(gettext("VLANs"), false, "interfaces_vlan.php");
101
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
102
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
103
$tab_array[] = array(gettext("GRE"), false, "interfaces_gre.php");
104
$tab_array[] = array(gettext("GIF"), false, "interfaces_gif.php");
105
$tab_array[] = array(gettext("Bridges"), true, "interfaces_bridge.php");
106
$tab_array[] = array(gettext("LAGG"), false, "interfaces_lagg.php");
107
display_top_tabs($tab_array);
108
?>
109

    
110
<div class="table-responsive">
111
	<table class="table table-striped table-hover table-condensed">
112
		<thead>
113
			<tr>
114
			  <th><?=gettext("Interface"); ?></th>
115
			  <th><?=gettext("Members"); ?></th>
116
			  <th><?=gettext("Description"); ?></th>
117
			  <th></th>
118
			</tr>
119
		</thead>
120
		<tbody>
121
<?php
122

    
123
$i = 0;
124
$ifdescrs = get_configured_interface_with_descr();
125

    
126
foreach ($a_bridges as $bridge) {
127
?>
128
			<tr>
129
				<td>
130
					<?=htmlspecialchars(strtoupper($bridge['bridgeif']))?>
131
				</td>
132
				<td>
133
<?php
134
	$members = explode(',', $bridge['members']);
135
	$j = 0;
136
	foreach ($members as $member) {
137
		if (isset($ifdescrs[$member])) {
138
			echo $ifdescrs[$member];
139
			$j++;
140
		}
141
		if ($j > 0 && $j < count($members))
142
			echo ", ";
143
	}
144
?>
145
				</td>
146
				<td>
147
					<?=htmlspecialchars($bridge['descr'])?>
148
				</td>
149
				<td>
150
					<a href="interfaces_bridge_edit.php?id=<?=$i?>" class="btn btn-default btn-xs"><?=gettext("Edit")?></a>
151
					<a href="interfaces_bridge.php?act=del&amp;id=<?=$i?>" class="btn btn-danger btn-xs"><?=gettext("Delete")?></a>
152
				</td>
153
			</tr>
154
<?php
155
	$i++;
156
}
157
?>
158
		</tbody>
159
	</table>
160

    
161
	<nav class="action-buttons">
162
		<a href="interfaces_bridge_edit.php" class="btn btn-success"><?=gettext("Add")?></a>
163
	</nav>
164

    
165
</div>
166

    
167
<?php include("foot.inc");
(85-85/238)