Project

General

Profile

Download (10.8 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / interfaces_gif_edit.php @ a1b66bec

1
<?php
2
/* $Id$ */
3
/*
4
	interfaces_gif_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
	pfSense_MODULE:	interfaces
32
*/
33

    
34
##|+PRIV
35
##|*IDENT=page-interfaces-gif-edit
36
##|*NAME=Interfaces: GIF: Edit page
37
##|*DESCR=Allow access to the 'Interfaces: GIF: Edit' page.
38
##|*MATCH=interfaces_gif_edit.php*
39
##|-PRIV
40

    
41
require("guiconfig.inc");
42

    
43
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces_gif.php');
44

    
45
if (!is_array($config['gifs']['gif']))
46
	$config['gifs']['gif'] = array();
47

    
48
$a_gifs = &$config['gifs']['gif'];
49

    
50
if (is_numericint($_GET['id']))
51
	$id = $_GET['id'];
52
if (isset($_POST['id']) && is_numericint($_POST['id']))
53
	$id = $_POST['id'];
54

    
55
if (isset($id) && $a_gifs[$id]) {
56
	$pconfig['if'] = $a_gifs[$id]['if'];
57
	if (!empty($a_gifs[$id]['ipaddr'])) {
58
		$pconfig['if'] = $pconfig['if'] . '|' . $a_gifs[$id]['ipaddr'];
59
	}
60
	$pconfig['gifif'] = $a_gifs[$id]['gifif'];
61
	$pconfig['remote-addr'] = $a_gifs[$id]['remote-addr'];
62
	$pconfig['tunnel-remote-net'] = $a_gifs[$id]['tunnel-remote-net'];
63
	$pconfig['tunnel-local-addr'] = $a_gifs[$id]['tunnel-local-addr'];
64
	$pconfig['tunnel-remote-addr'] = $a_gifs[$id]['tunnel-remote-addr'];
65
	$pconfig['link1'] = isset($a_gifs[$id]['link1']);
66
	$pconfig['link0'] = isset($a_gifs[$id]['link0']);
67
	$pconfig['descr'] = $a_gifs[$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
	$reqdfieldsn = array(gettext("Parent interface,Local address, Remote tunnel address, Remote tunnel network, Local tunnel address"));
78

    
79
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
80

    
81
	if ((!is_ipaddr($_POST['tunnel-local-addr'])) || (!is_ipaddr($_POST['tunnel-remote-addr'])) ||
82
			(!is_ipaddr($_POST['remote-addr']))) {
83
		$input_errors[] = gettext("The tunnel local and tunnel remote fields must have valid IP addresses.");
84
	}
85

    
86
	$alias = strstr($_POST['if'],'|');
87
	if ((is_ipaddrv4($alias) && !is_ipaddrv4($_POST['remote-addr'])) ||
88
			(is_ipaddrv6($alias) && !is_ipaddrv6($_POST['remote-addr'])))
89
		$input_errors[] = gettext("The alias IP address family has to match the family of the remote peer address.");
90

    
91
	foreach ($a_gifs as $gif) {
92
		if (isset($id) && ($a_gifs[$id]) && ($a_gifs[$id] === $gif))
93
			continue;
94

    
95
		/* FIXME: needs to perform proper subnet checks in the feature */
96
		if (($gif['if'] == $interface) && ($gif['tunnel-remote-addr'] == $_POST['tunnel-remote-addr'])) {
97
			$input_errors[] = sprintf(gettext("A gif with the network %s is already defined."), $gif['tunnel-remote-addr']);
98
			break;
99
		}
100
	}
101

    
102
	if (!$input_errors) {
103
		$gif = array();
104
		list($gif['if'], $gif['ipaddr']) = explode("|",$_POST['if']);
105
		$gif['tunnel-local-addr'] = $_POST['tunnel-local-addr'];
106
		$gif['tunnel-remote-addr'] = $_POST['tunnel-remote-addr'];
107
		$gif['tunnel-remote-net'] = $_POST['tunnel-remote-net'];
108
		$gif['remote-addr'] = $_POST['remote-addr'];
109
		$gif['descr'] = $_POST['descr'];
110
		$gif['link1'] = isset($_POST['link1']);
111
		$gif['link0'] = isset($_POST['link0']);
112
		$gif['gifif'] = $_POST['gifif'];
113

    
114
                $gif['gifif'] = interface_gif_configure($gif);
115
                if ($gif['gifif'] == "" || !stristr($gif['gifif'], "gif"))
116
                        $input_errors[] = gettext("Error occurred creating interface, please retry.");
117
                else {
118
                        if (isset($id) && $a_gifs[$id])
119
                                $a_gifs[$id] = $gif;
120
                        else
121
                                $a_gifs[] = $gif;
122

    
123
                        write_config();
124

    
125
			$confif = convert_real_interface_to_friendly_interface_name($gif['gifif']);
126
                        if ($confif <> "")
127
                                interface_configure($confif);
128

    
129
			header("Location: interfaces_gif.php");
130
			exit;
131
		}
132
	}
133
}
134

    
135
$pgtitle = array(gettext("Interfaces"),gettext("GIF"),gettext("Edit"));
136
$shortcut_section = "interfaces";
137
include("head.inc");
138

    
139
?>
140

    
141
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
142
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js"></script>
143
<?php include("fbegin.inc"); ?>
144
<?php if ($input_errors) print_input_errors($input_errors); ?>
145
            <form action="interfaces_gif_edit.php" method="post" name="iform" id="iform">
146
              <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces gif edit">
147
				<tr>
148
					<td colspan="2" valign="top" class="listtopic"><?=gettext("GIF configuration"); ?></td>
149
				</tr>
150
				<tr>
151
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Parent interface"); ?></td>
152
                  <td width="78%" class="vtable">
153
                    <select name="if" class="formselect">
154
                      <?php
155
						$portlist = get_configured_interface_with_descr();
156
						$carplist = get_configured_carp_interface_list();
157
						foreach ($carplist as $cif => $carpip)
158
							$portlist[$cif] = $carpip." (".get_vip_descr($carpip).")";
159
						$aliaslist = get_configured_ip_aliases_list();
160
						foreach ($aliaslist as $aliasip => $aliasif)
161
							$portlist[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
162
						foreach ($portlist as $ifn => $ifinfo) {
163
							echo "<option value=\"{$ifn}\"";
164
							if ($ifn == $pconfig['if'])
165
								echo " selected=\"selected\"";
166
							echo ">" . htmlspecialchars($ifinfo) . "</option>\n";
167
						}
168
		      		?>
169
                    </select>
170
			<br />
171
			<span class="vexpl"><?=gettext("The interface here serves as the local address to be used for the gif tunnel."); ?></span></td>
172
                </tr>
173
				<tr>
174
                  <td valign="top" class="vncellreq"><?=gettext("gif remote address"); ?></td>
175
                  <td class="vtable">
176
                    <input name="remote-addr" type="text" class="formfld unknown" id="remote-addr" size="24" value="<?=htmlspecialchars($pconfig['remote-addr']);?>" />
177
                    <br />
178
                    <span class="vexpl"><?=gettext("Peer address where encapsulated gif packets will be sent. "); ?></span></td>
179
			    </tr>
180
				<tr>
181
                  <td valign="top" class="vncellreq"><?=gettext("gif tunnel local address"); ?></td>
182
                  <td class="vtable">
183
                    <input name="tunnel-local-addr" type="text" class="formfld unknown" id="tunnel-local-addr" size="24" value="<?=htmlspecialchars($pconfig['tunnel-local-addr']);?>" />
184
                    <br />
185
                    <span class="vexpl"><?=gettext("Local gif tunnel endpoint"); ?></span></td>
186
			    </tr>
187
				<tr>
188
                  <td valign="top" class="vncellreq"><?=gettext("gif tunnel remote address "); ?></td>
189
                  <td class="vtable">
190
                    <input name="tunnel-remote-addr" type="text" class="formfld unknown ipv4v6" id="tunnel-remote-addr" size="24" value="<?=htmlspecialchars($pconfig['tunnel-remote-addr']);?>" />
191
                    <select name="tunnel-remote-net" class="formselect ipv4v6" id="tunnel-remote-net">
192
                                        <?php
193
                                        for ($i = 128; $i > 0; $i--) {
194
						echo "<option value=\"{$i}\"";
195
						if ($i == $pconfig['tunnel-remote-net'])
196
							echo " selected=\"selected\"";
197
						echo ">" . $i . "</option>";
198
                                        }
199
                                        ?>
200
                    </select>
201
                    <br />
202
                    <span class="vexpl"><?=gettext("Remote gif address endpoint. The subnet part is used for determining the network that is tunnelled."); ?></span></td>
203
			    </tr>
204
				<tr>
205
                  <td valign="top" class="vncell"><?=gettext("Route caching  "); ?></td>
206
                  <td class="vtable">
207
                    <input name="link0" type="checkbox" id="link0" <?if ($pconfig['link0']) echo "checked=\"checked\"";?> />
208
                    <br />
209
                    <span class="vexpl"><?=gettext("Specify if route caching can be enabled. Be careful with these settings on dynamic networks. "); ?></span></td>
210
			    </tr>
211
				<tr>
212
                  <td valign="top" class="vncell"><?=gettext("ECN friendly behavior"); ?></td>
213
                  <td class="vtable">
214
                    <input name="link1" type="checkbox" id="link1" <?if ($pconfig['link1']) echo "checked=\"checked\"";?> />
215
                    <br />
216
                    <span class="vexpl">
217
     <?=gettext("Note that the ECN friendly behavior violates RFC2893.  This should be " .
218
     "used in mutual agreement with the peer."); ?>					
219
					 </span></td>
220
			    </tr>
221
				<tr>
222
                  <td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
223
                  <td width="78%" class="vtable">
224
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
225
                    <br /> <span class="vexpl"><?=gettext("You may enter a description here " .
226
                    "for your reference (not parsed)."); ?></span></td>
227
                </tr>
228
                <tr>
229
                  <td width="22%" valign="top">&nbsp;</td>
230
                  <td width="78%">
231
		    <input type="hidden" name="gifif" value="<?=htmlspecialchars($pconfig['gifif']); ?>" />
232
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
233
                    <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
234
                    <?php if (isset($id) && $a_gifs[$id]): ?>
235
                    <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
236
                    <?php endif; ?>
237
                  </td>
238
                </tr>
239
              </table>
240
</form>
241
<?php include("fend.inc"); ?>
242
</body>
243
</html>
(100-100/256)