1 |
ead45104
|
Ermal Luçi
|
<?php
|
2 |
|
|
/* $Id$ */
|
3 |
|
|
/*
|
4 |
|
|
interfaces_gre_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 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
32 |
|
|
##|*IDENT=page-interfaces-gre-edit
|
33 |
|
|
##|*NAME=Interfaces: GRE: Edit page
|
34 |
|
|
##|*DESCR=Allow access to the 'Interfaces: GRE: Edit' page.
|
35 |
|
|
##|*MATCH=interfaces_gre_edit.php*
|
36 |
|
|
##|-PRIV
|
37 |
|
|
|
38 |
|
|
|
39 |
ead45104
|
Ermal Luçi
|
require("guiconfig.inc");
|
40 |
|
|
|
41 |
|
|
if (!is_array($config['gres']['gre']))
|
42 |
|
|
$config['gres']['gre'] = array();
|
43 |
|
|
|
44 |
|
|
$a_gres = &$config['gres']['gre'];
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
$id = $_GET['id'];
|
48 |
|
|
if (isset($_POST['id']))
|
49 |
|
|
$id = $_POST['id'];
|
50 |
|
|
|
51 |
|
|
if (isset($id) && $a_gres[$id]) {
|
52 |
|
|
$pconfig['if'] = $a_gres[$id]['if'];
|
53 |
|
|
$pconfig['greif'] = $a_gres[$id]['greif'];
|
54 |
|
|
$pconfig['remote-addr'] = $a_gres[$id]['remote-addr'];
|
55 |
|
|
$pconfig['tunnel-remote-net'] = $a_gres[$id]['tunnel-remote-net'];
|
56 |
|
|
$pconfig['tunnel-local-addr'] = $a_gres[$id]['tunnel-local-addr'];
|
57 |
|
|
$pconfig['tunnel-remote-addr'] = $a_gres[$id]['tunnel-remote-addr'];
|
58 |
|
|
$pconfig['link1'] = isset($a_gres[$id]['link1']);
|
59 |
|
|
$pconfig['link2'] = isset($a_gres[$id]['link2']);
|
60 |
|
|
$pconfig['link0'] = isset($a_gres[$id]['link0']);
|
61 |
|
|
$pconfig['descr'] = $a_gres[$id]['descr'];
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
if ($_POST) {
|
65 |
|
|
|
66 |
|
|
unset($input_errors);
|
67 |
|
|
$pconfig = $_POST;
|
68 |
|
|
|
69 |
|
|
/* input validation */
|
70 |
|
|
$reqdfields = explode(" ", "if tunnel-remote-addr tunnel-remote-net tunnel-local-addr");
|
71 |
|
|
$reqdfieldsn = explode(",", "Parent interface,Local address, Remote tunnel address, Remote tunnel network, Local tunnel address");
|
72 |
|
|
|
73 |
|
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
74 |
|
|
|
75 |
|
|
if ((!is_ipaddr($_POST['tunnel-local-addr'])) || (!is_ipaddr($_POST['tunnel-remote-addr'])) ||
|
76 |
|
|
(!is_ipaddr($_POST['remote-addr']))) {
|
77 |
|
|
$input_errors[] = "All fildes must have valid ip addresses.";
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
foreach ($a_gres as $gre) {
|
81 |
|
|
if (isset($id) && ($a_gres[$id]) && ($a_gres[$id] === $gre))
|
82 |
|
|
continue;
|
83 |
|
|
|
84 |
|
|
if (($gre['if'] == $_POST['if']) && ($gre['tunnel-remote-net'] == $_POST['tunnel-remote-net'])) {
|
85 |
|
|
$input_errors[] = "A gre with the network {$gre['remote-network']} is already defined.";
|
86 |
|
|
break;
|
87 |
|
|
}
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
if (!$input_errors) {
|
91 |
|
|
$gre = array();
|
92 |
|
|
$gre['if'] = $_POST['if'];
|
93 |
|
|
$gre['tunnel-local-addr'] = $_POST['tunnel-local-addr'];
|
94 |
|
|
$gre['tunnel-remote-addr'] = $_POST['tunnel-remote-addr'];
|
95 |
|
|
$gre['tunnel-remote-net'] = $_POST['tunnel-remote-net'];
|
96 |
|
|
$gre['remote-addr'] = $_POST['remote-addr'];
|
97 |
|
|
$gre['descr'] = $_POST['descr'];
|
98 |
|
|
$gre['link1'] = isset($_POST['link1']);
|
99 |
|
|
$gre['link2'] = isset($_POST['link2']);
|
100 |
|
|
$gre['link0'] = isset($_POST['link0']);
|
101 |
|
|
$gre['greif'] = $_POST['greif'];
|
102 |
|
|
|
103 |
|
|
$gre['greif'] = interface_gre_configure($gre);
|
104 |
|
|
if ($gre['greif'] == "" || !stristr($gre['greif'], "gre"))
|
105 |
|
|
$input_errors[] = "Error occured creating interface, please retry.";
|
106 |
|
|
else {
|
107 |
|
|
if (isset($id) && $a_gres[$id])
|
108 |
|
|
$a_gres[$id] = $gre;
|
109 |
|
|
else
|
110 |
|
|
$a_gres[] = $gre;
|
111 |
|
|
|
112 |
|
|
write_config();
|
113 |
|
|
|
114 |
|
|
header("Location: interfaces_gre.php");
|
115 |
|
|
exit;
|
116 |
|
|
}
|
117 |
|
|
}
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
$pgtitle = array("Firewall","GRE","Edit");
|
121 |
|
|
include("head.inc");
|
122 |
|
|
|
123 |
|
|
?>
|
124 |
|
|
|
125 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
126 |
|
|
<?php include("fbegin.inc"); ?>
|
127 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
128 |
|
|
<form action="interfaces_gre_edit.php" method="post" name="iform" id="iform">
|
129 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
130 |
|
|
<tr>
|
131 |
|
|
<td width="22%" valign="top" class="vncellreq">Parent interface</td>
|
132 |
|
|
<td width="78%" class="vtable">
|
133 |
|
|
<select name="if" class="formselect">
|
134 |
|
|
<?php
|
135 |
|
|
$portlist = get_configured_interface_with_descr();
|
136 |
|
|
foreach ($portlist as $ifn => $ifinfo) {
|
137 |
|
|
echo "<option value=\"{$ifn}\"";
|
138 |
|
|
if ($ifn == $pconfig['if'])
|
139 |
|
|
echo "selected";
|
140 |
|
|
echo ">{$ifinfo}</option>";
|
141 |
|
|
}
|
142 |
|
|
?>
|
143 |
|
|
</select>
|
144 |
|
|
<br/>
|
145 |
|
|
<span class="vexpl">The interface here servers as the local address to be used for the GRE tunnel.</span></td>
|
146 |
|
|
</tr>
|
147 |
|
|
<tr>
|
148 |
|
|
<td valign="top" class="vncellreq">GRE remote address. </td>
|
149 |
|
|
<td class="vtable">
|
150 |
|
|
<input name="remote-addr" type="text" class="formfld unknown" id="remote-addr" size="16" value="<?=$pconfig['remote-addr'];?>">
|
151 |
|
|
<br>
|
152 |
|
|
<span class="vexpl">Peer address where encapsulated GRE packets will be sent. </span></td>
|
153 |
|
|
</tr>
|
154 |
|
|
<tr>
|
155 |
|
|
<td valign="top" class="vncellreq">GRE tunnel local address. </td>
|
156 |
|
|
<td class="vtable">
|
157 |
|
|
<input name="tunnel-local-addr" type="text" class="formfld unknown" id="tunnel-local-addr" size="16" value="<?=$pconfig['tunnel-local-addr'];?>">
|
158 |
|
|
<br>
|
159 |
|
|
<span class="vexpl">Local GRE tunnel endpoint. </span></td>
|
160 |
|
|
</tr>
|
161 |
|
|
<tr>
|
162 |
|
|
<td valign="top" class="vncellreq">GRE tunnel remote address. </td>
|
163 |
|
|
<td class="vtable">
|
164 |
|
|
<input name="tunnel-remote-addr" type="text" class="formfld unknown" id="tunnel-remote-addr" size="16" value="<?=$pconfig['tunnel-remote-addr'];?>">
|
165 |
|
|
<select name="tunnel-remote-net" class="formselect" id="tunnel-remote-net">
|
166 |
|
|
<?php
|
167 |
|
|
for ($i = 32; $i > 0; $i--) {
|
168 |
|
|
if($i <> 31) {
|
169 |
|
|
echo "<option value=\"{$i}\" ";
|
170 |
|
|
if ($i == $pconfig['tunnel-remote-net']) echo "selected";
|
171 |
|
|
echo ">" . $i . "</option>";
|
172 |
|
|
}
|
173 |
|
|
}
|
174 |
|
|
?>
|
175 |
|
|
</select>
|
176 |
|
|
<br/>
|
177 |
|
|
<span class="vexpl">Remote GRE address endpoint. The subnet part is used for the determinig the network that is tunneled.</span></td>
|
178 |
|
|
</tr>
|
179 |
|
|
<tr>
|
180 |
|
|
<td valign="top" class="vncellreq">Mobile tunnel. </td>
|
181 |
|
|
<td class="vtable">
|
182 |
|
|
<input name="link0" type="checkbox" id="link0" <?if ($pconfig['link0']) echo "checked";?>>
|
183 |
|
|
<br>
|
184 |
|
|
<span class="vexpl">Specify which encapsulation method the tunnel should do. </span></td>
|
185 |
|
|
</tr>
|
186 |
|
|
<tr>
|
187 |
|
|
<td valign="top" class="vncellreq">Route search type. </td>
|
188 |
|
|
<td class="vtable">
|
189 |
|
|
<input name="link1" type="checkbox" id="link1" <?if ($pconfig['link1']) echo "checked";?>>
|
190 |
|
|
<br>
|
191 |
|
|
<span class="vexpl">
|
192 |
|
|
For correct operation, the gre device needs a route to the destination
|
193 |
|
|
that is less specific than the one over the tunnel. (Basically, there
|
194 |
|
|
needs to be a route to the decapsulating host that does not run over the
|
195 |
|
|
tunnel, as this would be a loop.) If the addresses are ambiguous, doing
|
196 |
|
|
the ifconfig tunnel step before the ifconfig(8) call to set the gre IP
|
197 |
|
|
addresses will help to find a route outside the tunnel.
|
198 |
|
|
</span></td>
|
199 |
|
|
</tr>
|
200 |
|
|
<tr>
|
201 |
|
|
<td valign="top" class="vncellreq">WCCP version. </td>
|
202 |
|
|
<td class="vtable">
|
203 |
|
|
<input name="link2" type="checkbox" id="link2" <?if ($pconfig['link2']) echo "checked";?>>
|
204 |
|
|
<br>
|
205 |
|
|
<span class="vexpl">Specify which WCCP encapsulation(version 1 or 2) method the tunnel should do. </span></td>
|
206 |
|
|
</tr>
|
207 |
|
|
<tr>
|
208 |
|
|
<td width="22%" valign="top" class="vncell">Description</td>
|
209 |
|
|
<td width="78%" class="vtable">
|
210 |
|
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
|
211 |
|
|
<br> <span class="vexpl">You may enter a description here
|
212 |
|
|
for your reference (not parsed).</span></td>
|
213 |
|
|
</tr>
|
214 |
|
|
<tr>
|
215 |
|
|
<td width="22%" valign="top"> </td>
|
216 |
|
|
<td width="78%">
|
217 |
|
|
<input type="hidden" name="greif" value="<?=$pconfig['greif']; ?>">
|
218 |
|
|
<input name="Submit" type="submit" class="formbtn" value="Save"> <input type="button" value="Cancel" onclick="history.back()">
|
219 |
|
|
<?php if (isset($id) && $a_gres[$id]): ?>
|
220 |
|
|
<input name="id" type="hidden" value="<?=$id;?>">
|
221 |
|
|
<?php endif; ?>
|
222 |
|
|
</td>
|
223 |
|
|
</tr>
|
224 |
|
|
</table>
|
225 |
|
|
</form>
|
226 |
|
|
<?php include("fend.inc"); ?>
|
227 |
|
|
</body>
|
228 |
|
|
</html>
|