Project

General

Profile

Download (4.91 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
$a_bridges = &$config['bridges']['bridged'] ;
49

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

    
53
	$iflist = get_configured_interface_list(false, true);
54
	foreach ($iflist as $if) {
55
		if ($config['interfaces'][$if]['if'] == $a_bridges[$num]['bridgeif'])
56
			return true;
57
	}
58

    
59
	return false;
60
}
61

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

    
77
		unset($a_bridges[$_GET['id']]);
78

    
79
		write_config();
80

    
81
		header("Location: interfaces_bridge.php");
82
		exit;
83
	}
84
}
85

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

    
92
<?php
93
$tab_array = array();
94
$tab_array[0] = array(gettext("Interface assignments"), false, "interfaces_assign.php");
95
$tab_array[1] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
96
$tab_array[2] = array(gettext("Wireless"), false, "interfaces_wireless.php");
97
$tab_array[3] = array(gettext("VLANs"), false, "interfaces_vlan.php");
98
$tab_array[4] = array(gettext("QinQs"), false, "interfaces_qinq.php");
99
$tab_array[5] = array(gettext("PPPs"), false, "interfaces_ppps.php");
100
$tab_array[6] = array(gettext("GRE"), false, "interfaces_gre.php");
101
$tab_array[7] = array(gettext("GIF"), false, "interfaces_gif.php");
102
$tab_array[8] = array(gettext("Bridges"), true, "interfaces_bridge.php");
103
$tab_array[9] = array(gettext("LAGG"), false, "interfaces_lagg.php");
104
display_top_tabs($tab_array);
105
?>
106

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

    
120
$i = 0;
121
$ifdescrs = get_configured_interface_with_descr();
122

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

    
158
	<a href="interfaces_bridge_edit.php" class="btn btn-success"><?=gettext("Add")?></a>
159

    
160
</div>
161

    
162
<?php include("foot.inc");
(84-84/241)