1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
interfaces_lagg_edit.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
|
require("guiconfig.inc");
|
32
|
|
33
|
if (!is_array($config['laggs']['lagg']))
|
34
|
$config['laggs']['lagg'] = array();
|
35
|
|
36
|
$a_laggs = &$config['laggs']['lagg'];
|
37
|
|
38
|
$portlist = get_interface_list();
|
39
|
|
40
|
$checklist = get_configured_interface_list(false, true);
|
41
|
$realifchecklist = array();
|
42
|
foreach ($checklist as $tmpif)
|
43
|
$realifchecklist[get_real_wan_interface($tmpif)] = $tmpif;
|
44
|
|
45
|
$id = $_GET['id'];
|
46
|
if (isset($_POST['id']))
|
47
|
$id = $_POST['id'];
|
48
|
|
49
|
if (isset($id) && $a_laggs[$id]) {
|
50
|
$pconfig['laggif'] = $a_laggs[$id]['laggif'];
|
51
|
$pconfig['members'] = $a_laggs[$id]['members'];
|
52
|
$pconfig['proto'] = $a_laggs[$id]['proto'];
|
53
|
$pconfig['descr'] = $a_laggs[$id]['descr'];
|
54
|
}
|
55
|
|
56
|
if ($_POST) {
|
57
|
|
58
|
unset($input_errors);
|
59
|
$pconfig = $_POST;
|
60
|
|
61
|
/* input validation */
|
62
|
$reqdfields = explode(" ", "members proto");
|
63
|
$reqdfieldsn = explode(",", "Member interfaces, Lagg protocol");
|
64
|
|
65
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
66
|
|
67
|
if (!$input_errors) {
|
68
|
$lagg = array();
|
69
|
$lagg['members'] = implode(',', $_POST['members']);
|
70
|
$lagg['descr'] = $_POST['descr'];
|
71
|
$lagg['laggif'] = $_POST['laggif'];
|
72
|
|
73
|
$lagg['laggif'] = interface_lagg_configure($lagg);
|
74
|
if ($lagg['laggif'] == "" || !stristr($lagg['laggif'], "lagg"))
|
75
|
$input_errors[] = "Error occured creating interface, please retry.";
|
76
|
else {
|
77
|
if (isset($id) && $a_laggs[$id])
|
78
|
$a_laggs[$id] = $lagg;
|
79
|
else
|
80
|
$a_laggs[] = $lagg;
|
81
|
|
82
|
write_config();
|
83
|
|
84
|
header("Location: interfaces_lagg.php");
|
85
|
exit;
|
86
|
}
|
87
|
}
|
88
|
}
|
89
|
|
90
|
$pgtitle = array("Firewall","LAGG","Edit");
|
91
|
include("head.inc");
|
92
|
|
93
|
?>
|
94
|
|
95
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
96
|
<?php include("fbegin.inc"); ?>
|
97
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
98
|
<form action="interfaces_lagg_edit.php" method="post" name="iform" id="iform">
|
99
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
100
|
<tr>
|
101
|
<td colspan="2" valign="top" class="listtopic">LAGG configuration</td>
|
102
|
</tr>
|
103
|
<tr>
|
104
|
<td width="22%" valign="top" class="vncellreq">Parent interface</td>
|
105
|
<td width="78%" class="vtable">
|
106
|
<select name="members[]" multiple="true" size="4" class="formselect">
|
107
|
<?php
|
108
|
foreach ($portlist as $ifn => $ifinfo) {
|
109
|
if (array_key_exists($ifn, $realifchecklist))
|
110
|
continue;
|
111
|
echo "<option value=\"{$ifn}\"";
|
112
|
if (stristr($pconfig['members'], $ifn))
|
113
|
echo "selected";
|
114
|
echo ">". $ifn ."(".$ifinfo['mac'] .")</option>";
|
115
|
}
|
116
|
?>
|
117
|
</select>
|
118
|
<br/>
|
119
|
<span class="vexpl">Choose the members that will be used for the link aggregation.</span></td>
|
120
|
</tr>
|
121
|
<tr>
|
122
|
<td valign="top" class="vncellreq">Lag proto</td>
|
123
|
<td class="vtable">
|
124
|
<select name="proto" class="formselect" id="proto">
|
125
|
<?php
|
126
|
foreach (array("none", "lacp", "failover", "fec", "loadbalance", "roundrobin") as $proto) {
|
127
|
echo "<option value=\"{$proto}\"";
|
128
|
if ($proto == $pconfig['proto'])
|
129
|
echo "selected";
|
130
|
echo ">".strtoupper($proto)."</option>";
|
131
|
}
|
132
|
?>
|
133
|
</select>
|
134
|
<br/>
|
135
|
<span class="vexpl">Remote lagg address endpoint. The subnet part is used for the determinig the network that is tunneled.</span></td>
|
136
|
</tr>
|
137
|
<tr>
|
138
|
<td width="22%" valign="top" class="vncell">Description</td>
|
139
|
<td width="78%" class="vtable">
|
140
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
|
141
|
<br> <span class="vexpl">You may enter a description here
|
142
|
for your reference (not parsed).</span></td>
|
143
|
</tr>
|
144
|
<tr>
|
145
|
<td width="22%" valign="top"> </td>
|
146
|
<td width="78%">
|
147
|
<input type="hidden" name="laggif" value="<?=$pconfig['laggif']; ?>">
|
148
|
<input name="Submit" type="submit" class="formbtn" value="Save"> <input type="button" value="Cancel" onclick="history.back()">
|
149
|
<?php if (isset($id) && $a_laggs[$id]): ?>
|
150
|
<input name="id" type="hidden" value="<?=$id;?>">
|
151
|
<?php endif; ?>
|
152
|
</td>
|
153
|
</tr>
|
154
|
</table>
|
155
|
</form>
|
156
|
<?php include("fend.inc"); ?>
|
157
|
</body>
|
158
|
</html>
|