Project

General

Profile

Download (9.06 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
##|+PRIV
32
##|*IDENT=page-interfaces-gif-edit
33
##|*NAME=Interfaces: GIF: Edit page
34
##|*DESCR=Allow access to the 'Interfaces: GIF: Edit' page.
35
##|*MATCH=interfaces_gif_edit.php*
36
##|-PRIV
37

    
38

    
39
require("guiconfig.inc");
40

    
41
if (!is_array($config['gifs']['gif']))
42
	$config['gifs']['gif'] = array();
43

    
44
$a_gifs = &$config['gifs']['gif'];
45

    
46

    
47
$id = $_GET['id'];
48
if (isset($_POST['id']))
49
	$id = $_POST['id'];
50

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

    
63
if ($_POST) {
64

    
65
	unset($input_errors);
66
	$pconfig = $_POST;
67

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

    
72
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
73

    
74
	if ((!is_ipaddr($_POST['tunnel-local-addr'])) || (!is_ipaddr($_POST['tunnel-remote-addr'])) ||
75
			(!is_ipaddr($_POST['remote-addr']))) {
76
		$input_errors[] = "All fildes must have valid ip addresses.";
77
	}
78

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

    
83
		if (($gif['if'] == $_POST['if']) && ($gif['tunnel-remote-net'] == $_POST['tunnel-remote-net'])) {
84
			$input_errors[] = "A gif with the network {$gif['remote-network']} is already defined.";
85
			break;
86
		}
87
	}
88

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

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

    
110
                        write_config();
111

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

    
118
$pgtitle = array("Firewall","GIF","Edit");
119
include("head.inc");
120

    
121
?>
122

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