Project

General

Profile

Download (9.12 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 = explode(",", "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[] = "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
		if (($gif['if'] == $_POST['if']) && ($gif['tunnel-remote-net'] == $_POST['tunnel-remote-net'])) {
86
			$input_errors[] = "A gif with the network {$gif['remote-network']} is already defined.";
87
			break;
88
		}
89
	}
90

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

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

    
112
                        write_config();
113

    
114
			header("Location: interfaces_gif.php");
115
			exit;
116
		}
117
	}
118
}
119

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