Projet

Général

Profil

Télécharger (6,25 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / interfaces_bridge.php @ fab1cd2f

1
<?php
2
/* $Id$ */
3
/*
4
	interfaces_bridge.php
5

    
6
	Copyright (C) 2008 Ermal Luçi
7
	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
/*
31
	pfSense_BUILDER_BINARIES:	/bin/rm
32
	pfSense_MODULE:	interfaces_assign
33
*/
34

    
35
##|+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
require("guiconfig.inc");
43

    
44
if (!is_array($config['bridges']['bridged']))
45
	$config['bridges']['bridged'] = array();
46

    
47
$a_bridges = &$config['bridges']['bridged'] ;
48

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

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

    
58
	return false;
59
}
60

    
61
if ($_GET['act'] == "del") {
62
	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
	/* check if still in use */
67
	else if (bridge_inuse($_GET['id'])) {
68
		$input_errors[] = gettext("This bridge cannot be deleted because it is assigned as an interface.");
69
	} else {
70
		if (!does_interface_exist($a_bridges[$_GET['id']]['bridgeif'])) {
71
			log_error("Bridge interface does not exist, skipping ifconfig destroy.");
72
		} else {
73
			mwexec("/sbin/ifconfig " . $a_bridges[$_GET['id']]['bridgeif'] . " destroy");
74
		}
75
		
76
		unset($a_bridges[$_GET['id']]);
77

    
78
		write_config();
79

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

    
85

    
86
$pgtitle = array(gettext("Interfaces"),gettext("Bridge"));
87
$shortcut_section = "interfaces";
88
include("head.inc");
89

    
90
?>
91

    
92
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
93
<?php include("fbegin.inc"); ?>
94
<?php if ($input_errors) print_input_errors($input_errors); ?>
95
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="interfaces bridge">
96
  <tr><td>
97
<?php
98
	$tab_array = array();
99
	$tab_array[0] = array(gettext("Interface assignments"), false, "interfaces_assign.php");
100
	$tab_array[1] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
101
	$tab_array[2] = array(gettext("Wireless"), false, "interfaces_wireless.php");
102
	$tab_array[3] = array(gettext("VLANs"), false, "interfaces_vlan.php");
103
	$tab_array[4] = array(gettext("QinQs"), false, "interfaces_qinq.php");
104
	$tab_array[5] = array(gettext("PPPs"), false, "interfaces_ppps.php");
105
	$tab_array[6] = array(gettext("GRE"), false, "interfaces_gre.php");
106
	$tab_array[7] = array(gettext("GIF"), false, "interfaces_gif.php");
107
	$tab_array[8] = array(gettext("Bridges"), true, "interfaces_bridge.php");
108
	$tab_array[9] = array(gettext("LAGG"), false, "interfaces_lagg.php");
109
	display_top_tabs($tab_array);
110
?>
111
  </td></tr>
112
  <tr>
113
    <td>
114
	<div id="mainarea">
115
	<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
116
                <tr>
117
                  <td width="20%" class="listhdrr"><?=gettext("Interface"); ?></td>
118
                  <td width="20%" class="listhdrr"><?=gettext("Members"); ?></td>
119
                  <td width="50%" class="listhdr"><?=gettext("Description"); ?></td>
120
                  <td width="10%" class="list"></td>
121
				</tr>
122
			  <?php $i = 0; $ifdescrs = get_configured_interface_with_descr();
123
					foreach ($a_bridges as $bridge): ?>
124
                <tr  ondblclick="document.location='interfaces_bridge_edit.php?id=<?=$i;?>'">
125
                  <td class="listlr">
126
					<?=htmlspecialchars(strtoupper($bridge['bridgeif']));?>
127
                  </td>
128
                  <td class="listr">
129
					<?php $members = explode(',', $bridge['members']);
130
					$j = 0;
131
					foreach ($members as $member) {
132
						if (isset($ifdescrs[$member])) {
133
							echo $ifdescrs[$member];
134
							$j++;
135
						}
136
						if ($j > 0 && $j < count($members))
137
							echo ", ";
138
					}
139
					?>
140
                  </td>
141
                  <td class="listbg">
142
                    <?=htmlspecialchars($bridge['descr']);?>&nbsp;
143
                  </td>
144
                  <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>
145
                     &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>
146
				</tr>
147
			  <?php $i++; endforeach; ?>
148
                <tr>
149
                  <td class="list" colspan="3">&nbsp;</td>
150
                  <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>
151
				</tr>
152
				<tr>
153
				<td colspan="3" class="list"><p class="vexpl"><span class="red"><strong>
154
				  <?=gettext("Note:"); ?><br />
155
				  </strong></span>
156
				  <?=gettext("Here you can configure bridging of interfaces."); ?></p>
157
				  </td>
158
				<td class="list">&nbsp;</td>
159
				</tr>
160
              </table>
161
	      </div>
162
	</td>
163
	</tr>
164
</table>
165
<?php include("fend.inc"); ?>
166
</body>
167
</html>
(96-96/255)