1 |
ead45104
|
Ermal Luçi
|
<?php
|
2 |
|
|
/* $Id$ */
|
3 |
|
|
/*
|
4 |
|
|
interfaces_gre_edit.php
|
5 |
|
|
|
6 |
6317d31d
|
Phil Davis
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
7 |
1d7ba683
|
ayvis
|
Copyright (C) 2008 Ermal Luçi
|
8 |
ead45104
|
Ermal Luçi
|
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 |
7ac5a4cb
|
Scott Ullrich
|
/*
|
32 |
|
|
pfSense_MODULE: interfaces
|
33 |
|
|
*/
|
34 |
ead45104
|
Ermal Luçi
|
|
35 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
36 |
|
|
##|*IDENT=page-interfaces-gre-edit
|
37 |
|
|
##|*NAME=Interfaces: GRE: Edit page
|
38 |
|
|
##|*DESCR=Allow access to the 'Interfaces: GRE: Edit' page.
|
39 |
|
|
##|*MATCH=interfaces_gre_edit.php*
|
40 |
|
|
##|-PRIV
|
41 |
|
|
|
42 |
ead45104
|
Ermal Luçi
|
require("guiconfig.inc");
|
43 |
517dcde7
|
Carlos Eduardo Ramos
|
require_once("functions.inc");
|
44 |
ead45104
|
Ermal Luçi
|
|
45 |
62424bdb
|
Renato Botelho
|
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces_gre.php');
|
46 |
|
|
|
47 |
ead45104
|
Ermal Luçi
|
if (!is_array($config['gres']['gre']))
|
48 |
|
|
$config['gres']['gre'] = array();
|
49 |
|
|
|
50 |
|
|
$a_gres = &$config['gres']['gre'];
|
51 |
|
|
|
52 |
e41ec584
|
Renato Botelho
|
if (is_numericint($_GET['id']))
|
53 |
|
|
$id = $_GET['id'];
|
54 |
|
|
if (isset($_POST['id']) && is_numericint($_POST['id']))
|
55 |
ead45104
|
Ermal Luçi
|
$id = $_POST['id'];
|
56 |
|
|
|
57 |
|
|
if (isset($id) && $a_gres[$id]) {
|
58 |
|
|
$pconfig['if'] = $a_gres[$id]['if'];
|
59 |
|
|
$pconfig['greif'] = $a_gres[$id]['greif'];
|
60 |
|
|
$pconfig['remote-addr'] = $a_gres[$id]['remote-addr'];
|
61 |
|
|
$pconfig['tunnel-remote-net'] = $a_gres[$id]['tunnel-remote-net'];
|
62 |
|
|
$pconfig['tunnel-local-addr'] = $a_gres[$id]['tunnel-local-addr'];
|
63 |
|
|
$pconfig['tunnel-remote-addr'] = $a_gres[$id]['tunnel-remote-addr'];
|
64 |
|
|
$pconfig['link1'] = isset($a_gres[$id]['link1']);
|
65 |
|
|
$pconfig['link2'] = isset($a_gres[$id]['link2']);
|
66 |
|
|
$pconfig['link0'] = isset($a_gres[$id]['link0']);
|
67 |
|
|
$pconfig['descr'] = $a_gres[$id]['descr'];
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
if ($_POST) {
|
71 |
|
|
|
72 |
|
|
unset($input_errors);
|
73 |
|
|
$pconfig = $_POST;
|
74 |
|
|
|
75 |
|
|
/* input validation */
|
76 |
|
|
$reqdfields = explode(" ", "if tunnel-remote-addr tunnel-remote-net tunnel-local-addr");
|
77 |
93bcbb6a
|
Renato Botelho
|
$reqdfieldsn = array(gettext("Parent interface"),gettext("Local address"),gettext("Remote tunnel address"),gettext("Remote tunnel network"), gettext("Local tunnel address"));
|
78 |
ead45104
|
Ermal Luçi
|
|
79 |
1e9b4611
|
Renato Botelho
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
80 |
ead45104
|
Ermal Luçi
|
|
81 |
|
|
if ((!is_ipaddr($_POST['tunnel-local-addr'])) || (!is_ipaddr($_POST['tunnel-remote-addr'])) ||
|
82 |
|
|
(!is_ipaddr($_POST['remote-addr']))) {
|
83 |
517dcde7
|
Carlos Eduardo Ramos
|
$input_errors[] = gettext("The tunnel local and tunnel remote fields must have valid IP addresses.");
|
84 |
ead45104
|
Ermal Luçi
|
}
|
85 |
|
|
|
86 |
|
|
foreach ($a_gres as $gre) {
|
87 |
|
|
if (isset($id) && ($a_gres[$id]) && ($a_gres[$id] === $gre))
|
88 |
|
|
continue;
|
89 |
|
|
|
90 |
58685470
|
Chris Buechler
|
if (($gre['if'] == $_POST['if']) && ($gre['tunnel-remote-addr'] == $_POST['tunnel-remote-addr'])) {
|
91 |
|
|
$input_errors[] = sprintf(gettext("A GRE tunnel with the network %s is already defined."),$gre['remote-network']);
|
92 |
ead45104
|
Ermal Luçi
|
break;
|
93 |
|
|
}
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
if (!$input_errors) {
|
97 |
|
|
$gre = array();
|
98 |
|
|
$gre['if'] = $_POST['if'];
|
99 |
|
|
$gre['tunnel-local-addr'] = $_POST['tunnel-local-addr'];
|
100 |
|
|
$gre['tunnel-remote-addr'] = $_POST['tunnel-remote-addr'];
|
101 |
|
|
$gre['tunnel-remote-net'] = $_POST['tunnel-remote-net'];
|
102 |
|
|
$gre['remote-addr'] = $_POST['remote-addr'];
|
103 |
|
|
$gre['descr'] = $_POST['descr'];
|
104 |
|
|
$gre['link1'] = isset($_POST['link1']);
|
105 |
|
|
$gre['link2'] = isset($_POST['link2']);
|
106 |
|
|
$gre['link0'] = isset($_POST['link0']);
|
107 |
|
|
$gre['greif'] = $_POST['greif'];
|
108 |
|
|
|
109 |
|
|
$gre['greif'] = interface_gre_configure($gre);
|
110 |
|
|
if ($gre['greif'] == "" || !stristr($gre['greif'], "gre"))
|
111 |
ab9dc5be
|
Chris Buechler
|
$input_errors[] = gettext("Error occurred creating interface, please retry.");
|
112 |
ead45104
|
Ermal Luçi
|
else {
|
113 |
|
|
if (isset($id) && $a_gres[$id])
|
114 |
|
|
$a_gres[$id] = $gre;
|
115 |
|
|
else
|
116 |
|
|
$a_gres[] = $gre;
|
117 |
|
|
|
118 |
|
|
write_config();
|
119 |
|
|
|
120 |
a2ec32a9
|
Ermal
|
$confif = convert_real_interface_to_friendly_interface_name($gre['greif']);
|
121 |
|
|
if ($confif <> "")
|
122 |
|
|
interface_configure($confif);
|
123 |
|
|
|
124 |
ead45104
|
Ermal Luçi
|
header("Location: interfaces_gre.php");
|
125 |
|
|
exit;
|
126 |
|
|
}
|
127 |
|
|
}
|
128 |
|
|
}
|
129 |
|
|
|
130 |
baca83aa
|
gnhb
|
$pgtitle = array(gettext("Interfaces"),gettext("GRE"),gettext("Edit"));
|
131 |
b32dd0a6
|
jim-p
|
$shortcut_section = "interfaces";
|
132 |
ead45104
|
Ermal Luçi
|
include("head.inc");
|
133 |
|
|
|
134 |
|
|
?>
|
135 |
|
|
|
136 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
137 |
dd8722db
|
Renato Botelho
|
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js"></script>
|
138 |
ead45104
|
Ermal Luçi
|
<?php include("fbegin.inc"); ?>
|
139 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
140 |
|
|
<form action="interfaces_gre_edit.php" method="post" name="iform" id="iform">
|
141 |
f8b41933
|
Colin Fleming
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces gre edit">
|
142 |
ead45104
|
Ermal Luçi
|
<tr>
|
143 |
93bcbb6a
|
Renato Botelho
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("GRE configuration");?></td>
|
144 |
16dcce2a
|
Scott Ullrich
|
</tr>
|
145 |
|
|
<tr>
|
146 |
93bcbb6a
|
Renato Botelho
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Parent interface");?></td>
|
147 |
ead45104
|
Ermal Luçi
|
<td width="78%" class="vtable">
|
148 |
|
|
<select name="if" class="formselect">
|
149 |
|
|
<?php
|
150 |
|
|
$portlist = get_configured_interface_with_descr();
|
151 |
11decf6e
|
Ermal
|
$carplist = get_configured_carp_interface_list();
|
152 |
|
|
foreach ($carplist as $cif => $carpip)
|
153 |
|
|
$portlist[$cif] = $carpip." (".get_vip_descr($carpip).")";
|
154 |
c3e77841
|
jim-p
|
$aliaslist = get_configured_ip_aliases_list();
|
155 |
|
|
foreach ($aliaslist as $aliasip => $aliasif)
|
156 |
|
|
$portlist[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
|
157 |
ead45104
|
Ermal Luçi
|
foreach ($portlist as $ifn => $ifinfo) {
|
158 |
|
|
echo "<option value=\"{$ifn}\"";
|
159 |
|
|
if ($ifn == $pconfig['if'])
|
160 |
f8b41933
|
Colin Fleming
|
echo " selected=\"selected\"";
|
161 |
c3e77841
|
jim-p
|
echo ">" . htmlspecialchars($ifinfo) . "</option>\n";
|
162 |
ead45104
|
Ermal Luçi
|
}
|
163 |
|
|
?>
|
164 |
|
|
</select>
|
165 |
1d7ba683
|
ayvis
|
<br />
|
166 |
93bcbb6a
|
Renato Botelho
|
<span class="vexpl"><?=gettext("The interface here serves as the local address to be used for the GRE tunnel.");?></span></td>
|
167 |
ead45104
|
Ermal Luçi
|
</tr>
|
168 |
|
|
<tr>
|
169 |
5046435d
|
Chris Buechler
|
<td valign="top" class="vncellreq"><?=gettext("Remote tunnel endpoint IP address");?></td>
|
170 |
ead45104
|
Ermal Luçi
|
<td class="vtable">
|
171 |
f8b41933
|
Colin Fleming
|
<input name="remote-addr" type="text" class="formfld unknown" id="remote-addr" size="16" value="<?=htmlspecialchars($pconfig['remote-addr']);?>" />
|
172 |
1d7ba683
|
ayvis
|
<br />
|
173 |
93bcbb6a
|
Renato Botelho
|
<span class="vexpl"><?=gettext("Peer address where encapsulated GRE packets will be sent ");?></span></td>
|
174 |
ead45104
|
Ermal Luçi
|
</tr>
|
175 |
|
|
<tr>
|
176 |
5046435d
|
Chris Buechler
|
<td valign="top" class="vncellreq"><?=gettext("Local tunnel IP address ");?></td>
|
177 |
ead45104
|
Ermal Luçi
|
<td class="vtable">
|
178 |
f8b41933
|
Colin Fleming
|
<input name="tunnel-local-addr" type="text" class="formfld unknown" id="tunnel-local-addr" size="16" value="<?=htmlspecialchars($pconfig['tunnel-local-addr']);?>" />
|
179 |
1d7ba683
|
ayvis
|
<br />
|
180 |
5046435d
|
Chris Buechler
|
<span class="vexpl"><?=gettext("Local IP address assigned inside this tunnel");?></span></td>
|
181 |
ead45104
|
Ermal Luçi
|
</tr>
|
182 |
|
|
<tr>
|
183 |
5046435d
|
Chris Buechler
|
<td valign="top" class="vncellreq"><?=gettext("Remote tunnel IP address ");?></td>
|
184 |
ead45104
|
Ermal Luçi
|
<td class="vtable">
|
185 |
dd8722db
|
Renato Botelho
|
<input name="tunnel-remote-addr" type="text" class="formfld unknown ipv4v6" id="tunnel-remote-addr" size="16" value="<?=htmlspecialchars($pconfig['tunnel-remote-addr']);?>" />
|
186 |
|
|
<select name="tunnel-remote-net" class="formselect ipv4v6" id="tunnel-remote-net">
|
187 |
ead45104
|
Ermal Luçi
|
<?php
|
188 |
2d107ad5
|
smos
|
for ($i = 128; $i > 0; $i--) {
|
189 |
f8b41933
|
Colin Fleming
|
echo "<option value=\"{$i}\"";
|
190 |
2d107ad5
|
smos
|
if ($i == $pconfig['tunnel-remote-net'])
|
191 |
f8b41933
|
Colin Fleming
|
echo " selected=\"selected\"";
|
192 |
2d107ad5
|
smos
|
echo ">" . $i . "</option>";
|
193 |
ead45104
|
Ermal Luçi
|
}
|
194 |
|
|
?>
|
195 |
2d107ad5
|
smos
|
</select>
|
196 |
1d7ba683
|
ayvis
|
<br />
|
197 |
5046435d
|
Chris Buechler
|
<span class="vexpl"><?=gettext("IP address inside this tunnel on the remote end. The subnet part is used for the determining the network that is tunneled.");?></span></td>
|
198 |
ead45104
|
Ermal Luçi
|
</tr>
|
199 |
|
|
<tr>
|
200 |
5046435d
|
Chris Buechler
|
<td valign="top" class="vncell"><?=gettext("Mobile encapsulation");?></td>
|
201 |
ead45104
|
Ermal Luçi
|
<td class="vtable">
|
202 |
f8b41933
|
Colin Fleming
|
<input name="link0" type="checkbox" id="link0" <?if ($pconfig['link0']) echo "checked=\"checked\"";?> />
|
203 |
1d7ba683
|
ayvis
|
<br />
|
204 |
5046435d
|
Chris Buechler
|
<span class="vexpl"><?=gettext("Check this box to use mobile encapsulation (IP protocol 55, RFC 2004). When unchecked, uses GRE encapsulation (IP protocol 47, RFCs 1701, 1702).");?></span></td>
|
205 |
ead45104
|
Ermal Luçi
|
</tr>
|
206 |
|
|
<tr>
|
207 |
93bcbb6a
|
Renato Botelho
|
<td valign="top" class="vncell"><?=gettext("Route search type");?></td>
|
208 |
ead45104
|
Ermal Luçi
|
<td class="vtable">
|
209 |
f8b41933
|
Colin Fleming
|
<input name="link1" type="checkbox" id="link1" <?if ($pconfig['link1']) echo "checked=\"checked\"";?> />
|
210 |
1d7ba683
|
ayvis
|
<br />
|
211 |
ead45104
|
Ermal Luçi
|
<span class="vexpl">
|
212 |
93bcbb6a
|
Renato Botelho
|
<?=gettext("For correct operation, the GRE device needs a route to the destination".
|
213 |
|
|
" that is less specific than the one over the tunnel. (Basically, there".
|
214 |
|
|
" needs to be a route to the decapsulating host that does not run over the".
|
215 |
|
|
" tunnel, as this would be a loop.");?>
|
216 |
ead45104
|
Ermal Luçi
|
</span></td>
|
217 |
|
|
</tr>
|
218 |
|
|
<tr>
|
219 |
93bcbb6a
|
Renato Botelho
|
<td valign="top" class="vncell"><?=gettext("WCCP version");?></td>
|
220 |
ead45104
|
Ermal Luçi
|
<td class="vtable">
|
221 |
f8b41933
|
Colin Fleming
|
<input name="link2" type="checkbox" id="link2" <?if ($pconfig['link2']) echo "checked=\"checked\"";?> />
|
222 |
1d7ba683
|
ayvis
|
<br />
|
223 |
ff6c9852
|
Chris Buechler
|
<span class="vexpl"><?=gettext("Check this box for WCCP encapsulation version 2, or leave unchecked for version 1.");?></span></td>
|
224 |
ead45104
|
Ermal Luçi
|
</tr>
|
225 |
|
|
<tr>
|
226 |
93bcbb6a
|
Renato Botelho
|
<td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
|
227 |
ead45104
|
Ermal Luçi
|
<td width="78%" class="vtable">
|
228 |
f8b41933
|
Colin Fleming
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
|
229 |
1d7ba683
|
ayvis
|
<br /> <span class="vexpl"><?=gettext("You may enter a description here".
|
230 |
93bcbb6a
|
Renato Botelho
|
" for your reference (not parsed).");?></span></td>
|
231 |
ead45104
|
Ermal Luçi
|
</tr>
|
232 |
|
|
<tr>
|
233 |
|
|
<td width="22%" valign="top"> </td>
|
234 |
|
|
<td width="78%">
|
235 |
f8b41933
|
Colin Fleming
|
<input type="hidden" name="greif" value="<?=htmlspecialchars($pconfig['greif']); ?>" />
|
236 |
62424bdb
|
Renato Botelho
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
|
237 |
|
|
<input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
|
238 |
ead45104
|
Ermal Luçi
|
<?php if (isset($id) && $a_gres[$id]): ?>
|
239 |
f8b41933
|
Colin Fleming
|
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
|
240 |
ead45104
|
Ermal Luçi
|
<?php endif; ?>
|
241 |
|
|
</td>
|
242 |
|
|
</tr>
|
243 |
|
|
</table>
|
244 |
|
|
</form>
|
245 |
|
|
<?php include("fend.inc"); ?>
|
246 |
|
|
</body>
|
247 |
|
|
</html>
|