Project

General

Profile

Download (9.92 KB) Statistics
| Branch: | Tag: | Revision:
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
if (!is_array($config['gifs']['gif']))
44
	$config['gifs']['gif'] = array();
45

    
46
$a_gifs = &$config['gifs']['gif'];
47

    
48

    
49
$id = $_GET['id'];
50
if (isset($_POST['id']))
51
	$id = $_POST['id'];
52

    
53
if (isset($id) && $a_gifs[$id]) {
54
	$pconfig['if'] = $a_gifs[$id]['if'];
55
	$pconfig['gifif'] = $a_gifs[$id]['gifif'];
56
	$pconfig['remote-addr'] = $a_gifs[$id]['remote-addr'];
57
	$pconfig['tunnel-remote-net'] = $a_gifs[$id]['tunnel-remote-net'];
58
	$pconfig['tunnel-local-addr'] = $a_gifs[$id]['tunnel-local-addr'];
59
	$pconfig['tunnel-remote-addr'] = $a_gifs[$id]['tunnel-remote-addr'];
60
	$pconfig['link1'] = isset($a_gifs[$id]['link1']);
61
	$pconfig['link0'] = isset($a_gifs[$id]['link0']);
62
	$pconfig['descr'] = $a_gifs[$id]['descr'];
63
}
64

    
65
if ($_POST) {
66

    
67
	unset($input_errors);
68
	$pconfig = $_POST;
69

    
70
	/* input validation */
71
	$reqdfields = explode(" ", "if tunnel-remote-addr tunnel-remote-net tunnel-local-addr");
72
	$reqdfieldsn = array(gettext("Parent interface,Local address, Remote tunnel address, Remote tunnel network, Local tunnel address"));
73

    
74
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
75

    
76
	if ((!is_ipaddr($_POST['tunnel-local-addr'])) || (!is_ipaddr($_POST['tunnel-remote-addr'])) ||
77
			(!is_ipaddr($_POST['remote-addr']))) {
78
		$input_errors[] = gettext("The tunnel local and tunnel remote fields must have valid IP addresses.");
79
	}
80

    
81
	foreach ($a_gifs as $gif) {
82
		if (isset($id) && ($a_gifs[$id]) && ($a_gifs[$id] === $gif))
83
			continue;
84

    
85
		/* FIXME: needs to perform proper subnet checks in the feature */
86
		if (($gif['if'] == $_POST['if']) && ($gif['tunnel-remote-addr'] == $_POST['tunnel-remote-addr'])) {
87
			$input_errors[] = sprintf(gettext("A gif with the network %s is already defined."), $gif['tunnel-remote-addr']);
88
			break;
89
		}
90
	}
91

    
92
	if (!$input_errors) {
93
		$gif = array();
94
		$gif['if'] = $_POST['if'];
95
		$gif['tunnel-local-addr'] = $_POST['tunnel-local-addr'];
96
		$gif['tunnel-remote-addr'] = $_POST['tunnel-remote-addr'];
97
		$gif['tunnel-remote-net'] = $_POST['tunnel-remote-net'];
98
		$gif['remote-addr'] = $_POST['remote-addr'];
99
		$gif['descr'] = $_POST['descr'];
100
		$gif['link1'] = isset($_POST['link1']);
101
		$gif['link0'] = isset($_POST['link0']);
102
		$gif['gifif'] = $_POST['gifif'];
103

    
104
                $gif['gifif'] = interface_gif_configure($gif);
105
                if ($gif['gifif'] == "" || !stristr($gif['gifif'], "gif"))
106
                        $input_errors[] = gettext("Error occured creating interface, please retry.");
107
                else {
108
                        if (isset($id) && $a_gifs[$id])
109
                                $a_gifs[$id] = $gif;
110
                        else
111
                                $a_gifs[] = $gif;
112

    
113
                        write_config();
114

    
115
			$confif = convert_real_interface_to_friendly_interface_name($gif['gifif']);
116
                        if ($confif <> "")
117
                                interface_configure($confif);
118

    
119
			header("Location: interfaces_gif.php");
120
			exit;
121
		}
122
	}
123
}
124

    
125
$pgtitle = array(gettext("Interfaces"),gettext("GIF"),gettext("Edit"));
126
include("head.inc");
127

    
128
?>
129

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