Project

General

Profile

Download (10.9 KB) Statistics
| Branch: | Tag: | Revision:
1 ead45104 Ermal Luçi
<?php
2
/* $Id$ */
3
/*
4
	interfaces_gif_edit.php
5
6 ce77a9c4 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-gif-edit
37
##|*NAME=Interfaces: GIF: Edit page
38
##|*DESCR=Allow access to the 'Interfaces: GIF: Edit' page.
39
##|*MATCH=interfaces_gif_edit.php*
40
##|-PRIV
41
42 ead45104 Ermal Luçi
require("guiconfig.inc");
43
44 62424bdb Renato Botelho
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces_gif.php');
45
46 ead45104 Ermal Luçi
if (!is_array($config['gifs']['gif']))
47
	$config['gifs']['gif'] = array();
48
49
$a_gifs = &$config['gifs']['gif'];
50
51 e41ec584 Renato Botelho
if (is_numericint($_GET['id']))
52
	$id = $_GET['id'];
53
if (isset($_POST['id']) && is_numericint($_POST['id']))
54 ead45104 Ermal Luçi
	$id = $_POST['id'];
55
56
if (isset($id) && $a_gifs[$id]) {
57
	$pconfig['if'] = $a_gifs[$id]['if'];
58 8436caa7 bcyrill
	if (!empty($a_gifs[$id]['ipaddr'])) {
59
		$pconfig['if'] = $pconfig['if'] . '|' . $a_gifs[$id]['ipaddr'];
60
	}
61 ead45104 Ermal Luçi
	$pconfig['gifif'] = $a_gifs[$id]['gifif'];
62
	$pconfig['remote-addr'] = $a_gifs[$id]['remote-addr'];
63
	$pconfig['tunnel-remote-net'] = $a_gifs[$id]['tunnel-remote-net'];
64
	$pconfig['tunnel-local-addr'] = $a_gifs[$id]['tunnel-local-addr'];
65
	$pconfig['tunnel-remote-addr'] = $a_gifs[$id]['tunnel-remote-addr'];
66
	$pconfig['link1'] = isset($a_gifs[$id]['link1']);
67
	$pconfig['link0'] = isset($a_gifs[$id]['link0']);
68
	$pconfig['descr'] = $a_gifs[$id]['descr'];
69
}
70
71
if ($_POST) {
72
73
	unset($input_errors);
74
	$pconfig = $_POST;
75
76
	/* input validation */
77
	$reqdfields = explode(" ", "if tunnel-remote-addr tunnel-remote-net tunnel-local-addr");
78 a2418a80 Neriberto C.Prado
	$reqdfieldsn = array(gettext("Parent interface,Local address, Remote tunnel address, Remote tunnel network, Local tunnel address"));
79 ead45104 Ermal Luçi
80 1e9b4611 Renato Botelho
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
81 ead45104 Ermal Luçi
82
	if ((!is_ipaddr($_POST['tunnel-local-addr'])) || (!is_ipaddr($_POST['tunnel-remote-addr'])) ||
83
			(!is_ipaddr($_POST['remote-addr']))) {
84 a2418a80 Neriberto C.Prado
		$input_errors[] = gettext("The tunnel local and tunnel remote fields must have valid IP addresses.");
85 ead45104 Ermal Luçi
	}
86 0e22dda5 Ermal
87 8436caa7 bcyrill
	$alias = strstr($_POST['if'],'|');
88
	if ((is_ipaddrv4($alias) && !is_ipaddrv4($_POST['remote-addr'])) ||
89
			(is_ipaddrv6($alias) && !is_ipaddrv6($_POST['remote-addr'])))
90
		$input_errors[] = gettext("The alias IP address family has to match the family of the remote peer address.");
91 ead45104 Ermal Luçi
92
	foreach ($a_gifs as $gif) {
93
		if (isset($id) && ($a_gifs[$id]) && ($a_gifs[$id] === $gif))
94
			continue;
95
96 404e0009 Seth Mos
		/* FIXME: needs to perform proper subnet checks in the feature */
97 5b3bd46c bcyrill
		if (($gif['if'] == $interface) && ($gif['tunnel-remote-addr'] == $_POST['tunnel-remote-addr'])) {
98 404e0009 Seth Mos
			$input_errors[] = sprintf(gettext("A gif with the network %s is already defined."), $gif['tunnel-remote-addr']);
99 ead45104 Ermal Luçi
			break;
100
		}
101
	}
102
103
	if (!$input_errors) {
104
		$gif = array();
105 13b31977 bcyrill
		list($gif['if'], $gif['ipaddr']) = explode("|",$_POST['if']);
106 ead45104 Ermal Luçi
		$gif['tunnel-local-addr'] = $_POST['tunnel-local-addr'];
107
		$gif['tunnel-remote-addr'] = $_POST['tunnel-remote-addr'];
108
		$gif['tunnel-remote-net'] = $_POST['tunnel-remote-net'];
109
		$gif['remote-addr'] = $_POST['remote-addr'];
110
		$gif['descr'] = $_POST['descr'];
111
		$gif['link1'] = isset($_POST['link1']);
112
		$gif['link0'] = isset($_POST['link0']);
113
		$gif['gifif'] = $_POST['gifif'];
114
115
                $gif['gifif'] = interface_gif_configure($gif);
116
                if ($gif['gifif'] == "" || !stristr($gif['gifif'], "gif"))
117 ab9dc5be Chris Buechler
                        $input_errors[] = gettext("Error occurred creating interface, please retry.");
118 ead45104 Ermal Luçi
                else {
119
                        if (isset($id) && $a_gifs[$id])
120
                                $a_gifs[$id] = $gif;
121
                        else
122
                                $a_gifs[] = $gif;
123
124
                        write_config();
125
126 a2ec32a9 Ermal
			$confif = convert_real_interface_to_friendly_interface_name($gif['gifif']);
127
                        if ($confif <> "")
128
                                interface_configure($confif);
129
130 ead45104 Ermal Luçi
			header("Location: interfaces_gif.php");
131
			exit;
132
		}
133
	}
134
}
135
136 baca83aa gnhb
$pgtitle = array(gettext("Interfaces"),gettext("GIF"),gettext("Edit"));
137 b32dd0a6 jim-p
$shortcut_section = "interfaces";
138 ead45104 Ermal Luçi
include("head.inc");
139
140
?>
141
142
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
143 f51d5d57 Darren Embry
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js"></script>
144 ead45104 Ermal Luçi
<?php include("fbegin.inc"); ?>
145
<?php if ($input_errors) print_input_errors($input_errors); ?>
146
            <form action="interfaces_gif_edit.php" method="post" name="iform" id="iform">
147 a20a972d Colin Fleming
              <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces gif edit">
148 ead45104 Ermal Luçi
				<tr>
149 a2418a80 Neriberto C.Prado
					<td colspan="2" valign="top" class="listtopic"><?=gettext("GIF configuration"); ?></td>
150 6ad8bd3a Scott Ullrich
				</tr>
151
				<tr>
152 a2418a80 Neriberto C.Prado
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Parent interface"); ?></td>
153 ead45104 Ermal Luçi
                  <td width="78%" class="vtable">
154
                    <select name="if" class="formselect">
155
                      <?php
156
						$portlist = get_configured_interface_with_descr();
157 11decf6e Ermal
						$carplist = get_configured_carp_interface_list();
158 8436caa7 bcyrill
						foreach ($carplist as $cif => $carpip)
159
							$portlist[$cif] = $carpip." (".get_vip_descr($carpip).")";
160
						$aliaslist = get_configured_ip_aliases_list();
161
						foreach ($aliaslist as $aliasip => $aliasif)
162
							$portlist[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
163
						foreach ($portlist as $ifn => $ifinfo) {
164 ead45104 Ermal Luçi
							echo "<option value=\"{$ifn}\"";
165
							if ($ifn == $pconfig['if'])
166 a20a972d Colin Fleming
								echo " selected=\"selected\"";
167 c3e77841 jim-p
							echo ">" . htmlspecialchars($ifinfo) . "</option>\n";
168 ead45104 Ermal Luçi
						}
169
		      		?>
170
                    </select>
171 1d7ba683 ayvis
			<br />
172 8976f70d Warren Baker
			<span class="vexpl"><?=gettext("The interface here serves as the local address to be used for the gif tunnel."); ?></span></td>
173 ead45104 Ermal Luçi
                </tr>
174
				<tr>
175 a2418a80 Neriberto C.Prado
                  <td valign="top" class="vncellreq"><?=gettext("gif remote address"); ?></td>
176 ead45104 Ermal Luçi
                  <td class="vtable">
177 a20a972d Colin Fleming
                    <input name="remote-addr" type="text" class="formfld unknown" id="remote-addr" size="24" value="<?=htmlspecialchars($pconfig['remote-addr']);?>" />
178 1d7ba683 ayvis
                    <br />
179 a2418a80 Neriberto C.Prado
                    <span class="vexpl"><?=gettext("Peer address where encapsulated gif packets will be sent. "); ?></span></td>
180 ead45104 Ermal Luçi
			    </tr>
181
				<tr>
182 a2418a80 Neriberto C.Prado
                  <td valign="top" class="vncellreq"><?=gettext("gif tunnel local address"); ?></td>
183 ead45104 Ermal Luçi
                  <td class="vtable">
184 a20a972d Colin Fleming
                    <input name="tunnel-local-addr" type="text" class="formfld unknown" id="tunnel-local-addr" size="24" value="<?=htmlspecialchars($pconfig['tunnel-local-addr']);?>" />
185 1d7ba683 ayvis
                    <br />
186 a2418a80 Neriberto C.Prado
                    <span class="vexpl"><?=gettext("Local gif tunnel endpoint"); ?></span></td>
187 ead45104 Ermal Luçi
			    </tr>
188
				<tr>
189 a2418a80 Neriberto C.Prado
                  <td valign="top" class="vncellreq"><?=gettext("gif tunnel remote address "); ?></td>
190 ead45104 Ermal Luçi
                  <td class="vtable">
191 a20a972d Colin Fleming
                    <input name="tunnel-remote-addr" type="text" class="formfld unknown ipv4v6" id="tunnel-remote-addr" size="24" value="<?=htmlspecialchars($pconfig['tunnel-remote-addr']);?>" />
192 a8fe61f1 Darren Embry
                    <select name="tunnel-remote-net" class="formselect ipv4v6" id="tunnel-remote-net">
193 ead45104 Ermal Luçi
                                        <?php
194 9b1ff028 Seth Mos
                                        for ($i = 128; $i > 0; $i--) {
195 a20a972d Colin Fleming
						echo "<option value=\"{$i}\"";
196 2d107ad5 smos
						if ($i == $pconfig['tunnel-remote-net'])
197 a20a972d Colin Fleming
							echo " selected=\"selected\"";
198 2d107ad5 smos
						echo ">" . $i . "</option>";
199 ead45104 Ermal Luçi
                                        }
200
                                        ?>
201 2d107ad5 smos
                    </select>
202 1d7ba683 ayvis
                    <br />
203 8e559859 Scott Ullrich
                    <span class="vexpl"><?=gettext("Remote gif address endpoint. The subnet part is used for determining the network that is tunnelled."); ?></span></td>
204 ead45104 Ermal Luçi
			    </tr>
205
				<tr>
206 a2418a80 Neriberto C.Prado
                  <td valign="top" class="vncell"><?=gettext("Route caching  "); ?></td>
207 ead45104 Ermal Luçi
                  <td class="vtable">
208 a20a972d Colin Fleming
                    <input name="link0" type="checkbox" id="link0" <?if ($pconfig['link0']) echo "checked=\"checked\"";?> />
209 1d7ba683 ayvis
                    <br />
210 a2418a80 Neriberto C.Prado
                    <span class="vexpl"><?=gettext("Specify if route caching can be enabled. Be careful with these settings on dynamic networks. "); ?></span></td>
211 ead45104 Ermal Luçi
			    </tr>
212
				<tr>
213 8436f2e3 jim-p
                  <td valign="top" class="vncell"><?=gettext("ECN friendly behavior"); ?></td>
214 ead45104 Ermal Luçi
                  <td class="vtable">
215 a20a972d Colin Fleming
                    <input name="link1" type="checkbox" id="link1" <?if ($pconfig['link1']) echo "checked=\"checked\"";?> />
216 1d7ba683 ayvis
                    <br />
217 ead45104 Ermal Luçi
                    <span class="vexpl">
218 6440ddec Carlos Eduardo Ramos
     <?=gettext("Note that the ECN friendly behavior violates RFC2893.  This should be " .
219 a2418a80 Neriberto C.Prado
     "used in mutual agreement with the peer."); ?>					
220 ead45104 Ermal Luçi
					 </span></td>
221
			    </tr>
222
				<tr>
223 a2418a80 Neriberto C.Prado
                  <td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
224 ead45104 Ermal Luçi
                  <td width="78%" class="vtable">
225 a20a972d Colin Fleming
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
226 1d7ba683 ayvis
                    <br /> <span class="vexpl"><?=gettext("You may enter a description here " .
227 a2418a80 Neriberto C.Prado
                    "for your reference (not parsed)."); ?></span></td>
228 ead45104 Ermal Luçi
                </tr>
229
                <tr>
230
                  <td width="22%" valign="top">&nbsp;</td>
231
                  <td width="78%">
232 a20a972d Colin Fleming
		    <input type="hidden" name="gifif" value="<?=htmlspecialchars($pconfig['gifif']); ?>" />
233 62424bdb Renato Botelho
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
234
                    <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
235 ead45104 Ermal Luçi
                    <?php if (isset($id) && $a_gifs[$id]): ?>
236 a20a972d Colin Fleming
                    <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
237 ead45104 Ermal Luçi
                    <?php endif; ?>
238
                  </td>
239
                </tr>
240
              </table>
241
</form>
242
<?php include("fend.inc"); ?>
243
</body>
244
</html>