Project

General

Profile

Download (6.22 KB) Statistics
| Branch: | Tag: | Revision:
1 648ec0c2 Ermal Luçi
<?php
2
/* $Id$ */
3
/*
4
	interfaces_bridge.php
5
6 e395ef5d Ermal Luçi
	Copyright (C) 2008 Ermal Lu?i
7 648ec0c2 Ermal Luçi
	All rights reserved.
8
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30 7ac5a4cb Scott Ullrich
/*
31
	pfSense_BUILDER_BINARIES:	/bin/rm
32
	pfSense_MODULE:	interfaces_assign
33
*/
34 648ec0c2 Ermal Luçi
35 ea9828af Ermal Lu?i
##|+PRIV
36
##|*IDENT=page-interfaces-bridge
37
##|*NAME=Interfaces: Bridge page
38
##|*DESCR=Allow access to the 'Interfaces: Bridge' page.
39
##|*MATCH=interfaces_bridge.php*
40
##|-PRIV
41
42 648ec0c2 Ermal Luçi
require("guiconfig.inc");
43
44 3134528d Ermal Luçi
if (!is_array($config['bridges']['bridged']))
45
	$config['bridges']['bridged'] = array();
46 648ec0c2 Ermal Luçi
47 3134528d Ermal Luçi
$a_bridges = &$config['bridges']['bridged'] ;
48 648ec0c2 Ermal Luçi
49 9c17db74 Erik Fonnesbeck
function bridge_inuse($num) {
50 c059940b Erik Fonnesbeck
	global $config, $a_bridges;
51 648ec0c2 Ermal Luçi
52
	$iflist = get_configured_interface_list(false, true);
53
	foreach ($iflist as $if) {
54 9c17db74 Erik Fonnesbeck
		if ($config['interfaces'][$if]['if'] == $a_bridges[$num]['bridgeif'])
55 648ec0c2 Ermal Luçi
			return true;
56
	}
57
58
	return false;
59
}
60
61
if ($_GET['act'] == "del") {
62 0e22dda5 Ermal
	if (!isset($_GET['id']))
63
		$input_errors[] = getext("Wrong parameters supplied");
64
	else if (empty($a_bridges[$_GET['id']]))
65
		$input_errors[] = getext("Wrong index supplied");
66 648ec0c2 Ermal Luçi
	/* check if still in use */
67 0e22dda5 Ermal
	else if (bridge_inuse($_GET['id'])) {
68 9cdd5a84 Carlos Eduardo Ramos
		$input_errors[] = gettext("This bridge cannot be deleted because it is assigned as an interface.");
69 30b3f068 Renato Botelho
	} elseif (!does_interface_exist($a_bridges[$_GET['id']]['bridgeif'])) {
70
		$input_errors[] = gettext("Invalid bridge interface.");
71 648ec0c2 Ermal Luçi
	} else {
72
		mwexec("/sbin/ifconfig " . $a_bridges[$_GET['id']]['bridgeif'] . " destroy");
73
		unset($a_bridges[$_GET['id']]);
74
75
		write_config();
76
77
		header("Location: interfaces_bridge.php");
78
		exit;
79
	}
80
}
81
82
83 9cdd5a84 Carlos Eduardo Ramos
$pgtitle = array(gettext("Interfaces"),gettext("Bridge"));
84 b32dd0a6 jim-p
$shortcut_section = "interfaces";
85 648ec0c2 Ermal Luçi
include("head.inc");
86
87
?>
88
89
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
90
<?php include("fbegin.inc"); ?>
91
<?php if ($input_errors) print_input_errors($input_errors); ?>
92 7c9aa7dd Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="interfaces bridge">
93 648ec0c2 Ermal Luçi
  <tr><td>
94
<?php
95
	$tab_array = array();
96 9cdd5a84 Carlos Eduardo Ramos
	$tab_array[0] = array(gettext("Interface assignments"), false, "interfaces_assign.php");
97
	$tab_array[1] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
98
	$tab_array[2] = array(gettext("Wireless"), false, "interfaces_wireless.php");
99
	$tab_array[3] = array(gettext("VLANs"), false, "interfaces_vlan.php");
100
	$tab_array[4] = array(gettext("QinQs"), false, "interfaces_qinq.php");
101
	$tab_array[5] = array(gettext("PPPs"), false, "interfaces_ppps.php");
102
	$tab_array[6] = array(gettext("GRE"), false, "interfaces_gre.php");
103
	$tab_array[7] = array(gettext("GIF"), false, "interfaces_gif.php");
104
	$tab_array[8] = array(gettext("Bridges"), true, "interfaces_bridge.php");
105
	$tab_array[9] = array(gettext("LAGG"), false, "interfaces_lagg.php");
106 648ec0c2 Ermal Luçi
	display_top_tabs($tab_array);
107
?>
108
  </td></tr>
109
  <tr>
110
    <td>
111
	<div id="mainarea">
112 7c9aa7dd Colin Fleming
	<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
113 648ec0c2 Ermal Luçi
                <tr>
114 9cdd5a84 Carlos Eduardo Ramos
                  <td width="20%" class="listhdrr"><?=gettext("Interface"); ?></td>
115
                  <td width="20%" class="listhdrr"><?=gettext("Members"); ?></td>
116
                  <td width="50%" class="listhdr"><?=gettext("Description"); ?></td>
117 648ec0c2 Ermal Luçi
                  <td width="10%" class="list"></td>
118
				</tr>
119 4bd1d5eb Ermal Luçi
			  <?php $i = 0; $ifdescrs = get_configured_interface_with_descr();
120
					foreach ($a_bridges as $bridge): ?>
121 fd22be34 Ermal Lu?i
                <tr  ondblclick="document.location='interfaces_bridge_edit.php?id=<?=$i;?>'">
122 648ec0c2 Ermal Luçi
                  <td class="listlr">
123
					<?=htmlspecialchars(strtoupper($bridge['bridgeif']));?>
124
                  </td>
125
                  <td class="listr">
126 a3381369 Colin Fleming
					<?php $members = explode(',', $bridge['members']);
127 4bd1d5eb Ermal Luçi
					$j = 0;
128
					foreach ($members as $member) {
129
						if (isset($ifdescrs[$member])) {
130
							echo $ifdescrs[$member];
131
							$j++;
132
						}
133 ca59a45f Chris Buechler
						if ($j > 0 && $j < count($members))
134 4bd1d5eb Ermal Luçi
							echo ", ";
135
					}
136
					?>
137 648ec0c2 Ermal Luçi
                  </td>
138
                  <td class="listbg">
139
                    <?=htmlspecialchars($bridge['descr']);?>&nbsp;
140
                  </td>
141 7c9aa7dd Colin Fleming
                  <td valign="middle" class="list nowrap"> <a href="interfaces_bridge_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="edit" /></a>
142
                     &nbsp;<a href="interfaces_bridge.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this bridge?"); ?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete" /></a></td>
143 648ec0c2 Ermal Luçi
				</tr>
144
			  <?php $i++; endforeach; ?>
145
                <tr>
146
                  <td class="list" colspan="3">&nbsp;</td>
147 7c9aa7dd Colin Fleming
                  <td class="list"> <a href="interfaces_bridge_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" /></a></td>
148 648ec0c2 Ermal Luçi
				</tr>
149
				<tr>
150
				<td colspan="3" class="list"><p class="vexpl"><span class="red"><strong>
151 7c9aa7dd Colin Fleming
				  <?=gettext("Note:"); ?><br/>
152 648ec0c2 Ermal Luçi
				  </strong></span>
153 7c9aa7dd Colin Fleming
				  <?=gettext("Here you can configure bridging of interfaces."); ?></p>
154 648ec0c2 Ermal Luçi
				  </td>
155
				<td class="list">&nbsp;</td>
156
				</tr>
157
              </table>
158
	      </div>
159
	</td>
160
	</tr>
161
</table>
162
<?php include("fend.inc"); ?>
163
</body>
164
</html>