Project

General

Profile

Download (48.4 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	firewall_rules_edit.php
5
	part of pfSense (http://www.pfsense.com)
6
        Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
7

    
8
	originally part of m0n0wall (http://m0n0.ch/wall)
9
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11

    
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14

    
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17

    
18
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21

    
22
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33
/*
34
	pfSense_MODULE:	filter
35
*/
36

    
37
##|+PRIV
38
##|*IDENT=page-firewall-rules-edit
39
##|*NAME=Firewall: Rules: Edit page
40
##|*DESCR=Allow access to the 'Firewall: Rules: Edit' page.
41
##|*MATCH=firewall_rules_edit.php*
42
##|-PRIV
43

    
44
require("guiconfig.inc");
45
require("filter.inc");
46
require("shaper.inc");
47

    
48
$specialsrcdst = explode(" ", "any pptp pppoe l2tp");
49
$ifdisp = get_configured_interface_with_descr();
50
foreach ($ifdisp as $kif => $kdescr) {
51
	$specialsrcdst[] = "{$kif}";
52
	$specialsrcdst[] = "{$kif}ip";
53
}
54

    
55
if (!is_array($config['filter']['rule'])) {
56
	$config['filter']['rule'] = array();
57
}
58
filter_rules_sort();
59
$a_filter = &$config['filter']['rule'];
60

    
61
$id = $_GET['id'];
62
if (is_numeric($_POST['id']))
63
	$id = $_POST['id'];
64

    
65
$after = $_GET['after'];
66

    
67
if (isset($_POST['after']))
68
	$after = $_POST['after'];
69

    
70
if (isset($_GET['dup'])) {
71
	$id = $_GET['dup'];
72
	$after = $_GET['dup'];
73
}
74

    
75
if (isset($id) && $a_filter[$id]) {
76
	$pconfig['interface'] = $a_filter[$id]['interface'];
77

    
78
	if (isset($a_filter[$id]['id']))
79
		$pconfig['ruleid'] = $a_filter[$id]['id'];
80

    
81
	if (!isset($a_filter[$id]['type']))
82
		$pconfig['type'] = "pass";
83
	else
84
		$pconfig['type'] = $a_filter[$id]['type'];
85

    
86
	if (isset($a_filter[$id]['floating']) || $if == "FloatingRules") {
87
		$pconfig['floating'] = $a_filter[$id]['floating'];
88
		if (isset($a_filter[$id]['interface']) && $a_filter[$id]['interface'] <> "") 
89
			$pconfig['interface'] = $a_filter[$id]['interface'];
90
	}
91
	
92
	if (isset($a_filter['floating'])) 
93
		$pconfig['floating'] = "yes";
94

    
95
	if (isset($a_filter[$id]['direction']))
96
                $pconfig['direction'] = $a_filter[$id]['direction'];
97

    
98
	if (isset($a_filter[$id]['protocol']))
99
		$pconfig['proto'] = $a_filter[$id]['protocol'];
100
	else
101
		$pconfig['proto'] = "any";
102

    
103
	if ($a_filter[$id]['protocol'] == "icmp")
104
		$pconfig['icmptype'] = $a_filter[$id]['icmptype'];
105

    
106
	address_to_pconfig($a_filter[$id]['source'], $pconfig['src'],
107
		$pconfig['srcmask'], $pconfig['srcnot'],
108
		$pconfig['srcbeginport'], $pconfig['srcendport']);
109

    
110
	if($a_filter[$id]['os'] <> "")
111
		$pconfig['os'] = $a_filter[$id]['os'];
112

    
113
	address_to_pconfig($a_filter[$id]['destination'], $pconfig['dst'],
114
		$pconfig['dstmask'], $pconfig['dstnot'],
115
		$pconfig['dstbeginport'], $pconfig['dstendport']);
116

    
117
	if ($a_filter[$id]['dscp'] <> "")
118
		$pconfig['dscp'] = $a_filter[$id]['dscp'];
119

    
120
	$pconfig['disabled'] = isset($a_filter[$id]['disabled']);
121
	$pconfig['log'] = isset($a_filter[$id]['log']);
122
	$pconfig['descr'] = $a_filter[$id]['descr'];
123

    
124
	if (isset($a_filter[$id]['tag']) && $a_filter[$id]['tag'] <> "") 
125
		$pconfig['tag'] = $a_filter[$id]['tag'];
126
	if (isset($a_filter[$id]['tagged']) && $a_filter[$id]['tagged'] <> "")
127
        	$pconfig['tagged'] = $a_filter[$id]['tagged'];
128
	if (isset($a_filter[$id]['quick']) && $a_filter[$id]['quick'])
129
		$pconfig['quick'] = $a_filter[$id]['quick'];
130
	if (isset($a_filter[$id]['allowopts']))
131
		$pconfig['allowopts'] = true;
132

    
133
	/* advanced */
134
	$pconfig['max-src-nodes'] = $a_filter[$id]['max-src-nodes'];
135
	$pconfig['max-src-conn'] = $a_filter[$id]['max-src-conn'];
136
	$pconfig['max-src-states'] = $a_filter[$id]['max-src-states'];
137
	$pconfig['statetype'] = $a_filter[$id]['statetype'];
138
	$pconfig['statetimeout'] = $a_filter[$id]['statetimeout'];
139

    
140
	/* advanced - nosync */
141
	$pconfig['nosync'] = isset($a_filter[$id]['nosync']);
142

    
143
	/* advanced - new connection per second banning*/
144
	$pconfig['max-src-conn-rate'] = $a_filter[$id]['max-src-conn-rate'];
145
	$pconfig['max-src-conn-rates'] = $a_filter[$id]['max-src-conn-rates'];
146

    
147
	/* Multi-WAN next-hop support */
148
	$pconfig['gateway'] = $a_filter[$id]['gateway'];
149
	
150
	/* Shaper support */
151
	$pconfig['defaultqueue'] = $a_filter[$id]['defaultqueue'];
152
	$pconfig['ackqueue'] = $a_filter[$id]['ackqueue'];
153
	$pconfig['dnpipe'] = $a_filter[$id]['dnpipe'];
154
	$pconfig['pdnpipe'] = $a_filter[$id]['pdnpipe'];
155
	$pconfig['l7container'] = $a_filter[$id]['l7container'];
156

    
157
	//schedule support
158
	$pconfig['sched'] = $a_filter[$id]['sched'];
159

    
160
} else {
161
	/* defaults */
162
	if ($_GET['if'])
163
		$pconfig['interface'] = $_GET['if'];
164
	$pconfig['type'] = "pass";
165
	$pconfig['src'] = "any";
166
	$pconfig['dst'] = "any";
167
}
168
/* Allow the FlotingRules to work */
169
$if = $pconfig['interface'];
170

    
171
if (isset($_GET['dup']))
172
	unset($id);
173

    
174
if ($_POST) {
175

    
176
	if ($_POST['type'] == "reject" && $_POST['proto'] <> "tcp")
177
		$input_errors[] = "Reject type rules only works when the protocol is set to TCP.";
178

    
179
	if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp")) {
180
		$_POST['srcbeginport'] = 0;
181
		$_POST['srcendport'] = 0;
182
		$_POST['dstbeginport'] = 0;
183
		$_POST['dstendport'] = 0;
184
	} else {
185

    
186
		if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
187
			$_POST['srcbeginport'] = $_POST['srcbeginport_cust'];
188
		if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
189
			$_POST['srcendport'] = $_POST['srcendport_cust'];
190

    
191
		if ($_POST['srcbeginport'] == "any") {
192
			$_POST['srcbeginport'] = 0;
193
			$_POST['srcendport'] = 0;
194
		} else {
195
			if (!$_POST['srcendport'])
196
				$_POST['srcendport'] = $_POST['srcbeginport'];
197
		}
198
		if ($_POST['srcendport'] == "any")
199
			$_POST['srcendport'] = $_POST['srcbeginport'];
200

    
201
		if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
202
			$_POST['dstbeginport'] = $_POST['dstbeginport_cust'];
203
		if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
204
			$_POST['dstendport'] = $_POST['dstendport_cust'];
205

    
206
		if ($_POST['dstbeginport'] == "any") {
207
			$_POST['dstbeginport'] = 0;
208
			$_POST['dstendport'] = 0;
209
		} else {
210
			if (!$_POST['dstendport'])
211
				$_POST['dstendport'] = $_POST['dstbeginport'];
212
		}
213
		if ($_POST['dstendport'] == "any")
214
			$_POST['dstendport'] = $_POST['dstbeginport'];
215
	}
216

    
217
	if (is_specialnet($_POST['srctype'])) {
218
		$_POST['src'] = $_POST['srctype'];
219
		$_POST['srcmask'] = 0;
220
	} else if ($_POST['srctype'] == "single") {
221
		$_POST['srcmask'] = 32;
222
	}
223
	if (is_specialnet($_POST['dsttype'])) {
224
		$_POST['dst'] = $_POST['dsttype'];
225
		$_POST['dstmask'] = 0;
226
	}  else if ($_POST['dsttype'] == "single") {
227
		$_POST['dstmask'] = 32;
228
	}
229

    
230
	unset($input_errors);
231
	$pconfig = $_POST;
232

    
233
	/*  run through $_POST items encoding HTML entties so that the user
234
	 *  cannot think he is slick and perform a XSS attack on the unwilling 
235
	 */
236
	foreach ($_POST as $key => $value) {
237
		$temp = $value;
238
		if (isset($_POST['floating']) && $key == "interface")
239
			continue;
240
		$newpost = htmlentities($temp);
241
		if($newpost <> $temp)   	 
242
			$input_errors[] = "Invalid characters detected ($temp).  Please remove invalid characters and save again.";		
243
	}
244

    
245
	/* input validation */
246
	$reqdfields = explode(" ", "type proto src dst");
247
	$reqdfieldsn = explode(",", "Type,Protocol,Source,Destination");
248

    
249
	if($_POST['statetype'] == "modulate state" or $_POST['statetype'] == "synproxy state") {
250
		if( $_POST['proto'] != "tcp" )
251
			$input_errors[] = "{$_POST['statetype']} is only valid with protocol tcp.";
252
		if(($_POST['statetype'] == "synproxy state") && ($_POST['gateway'] != ""))
253
			$input_errors[] = "{$_POST['statetype']} is only valid if the gateway is set to 'default'.";
254
	}
255
        
256
	if (!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single"))) {
257
		$reqdfields[] = "srcmask";
258
		$reqdfieldsn[] = "Source bit count";
259
	}
260
	if (!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single"))) {
261
		$reqdfields[] = "dstmask";
262
		$reqdfieldsn[] = "Destination bit count";
263
	}
264

    
265
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
266

    
267
	if (!$_POST['srcbeginport']) {
268
		$_POST['srcbeginport'] = 0;
269
		$_POST['srcendport'] = 0;
270
	}
271
	if (!$_POST['dstbeginport']) {
272
		$_POST['dstbeginport'] = 0;
273
		$_POST['dstendport'] = 0;
274
	}
275

    
276
	if (($_POST['srcbeginport'] && !alias_expand($_POST['srcbeginport']) && !is_port($_POST['srcbeginport']))) {
277
		$input_errors[] = "The start source port must be an alias or integer between 1 and 65535.";
278
	}
279
	if (($_POST['srcendport'] && !alias_expand($_POST['srcendport']) && !is_port($_POST['srcendport']))) {
280
		$input_errors[] = "The end source port must be an alias or integer between 1 and 65535.";
281
	}
282
	if (($_POST['dstbeginport'] && !alias_expand($_POST['dstbeginport']) && !is_port($_POST['dstbeginport']))) {
283
		$input_errors[] = "The start destination port must be an alias or integer between 1 and 65535.";
284
	}
285
	if (($_POST['dstendport'] && !alias_expand($_POST['dstbeginport']) && !is_port($_POST['dstendport']))) {
286
		$input_errors[] = "The end destination port must be an alias or integer between 1 and 65535.";
287
	}
288

    
289
	/* if user enters an alias and selects "network" then disallow. */
290
	if($_POST['srctype'] == "network") {
291
		if(is_alias($_POST['src']))
292
			$input_errors[] = "You must specify single host or alias for alias entries.";
293
	}
294
	if($_POST['dsttype'] == "network") {
295
		if(is_alias($_POST['dst']))
296
			$input_errors[] = "You must specify single host or alias for alias entries.";
297
	}
298

    
299
	if (!is_specialnet($_POST['srctype'])) {
300
		if (($_POST['src'] && !is_ipaddroranyalias($_POST['src']))) {
301
			$input_errors[] = "A valid source IP address or alias must be specified.";
302
		}
303
		if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) {
304
			$input_errors[] = "A valid source bit count must be specified.";
305
		}
306
	}
307
	if (!is_specialnet($_POST['dsttype'])) {
308
		if (($_POST['dst'] && !is_ipaddroranyalias($_POST['dst']))) {
309
			$input_errors[] = "A valid destination IP address or alias must be specified.";
310
		}
311
		if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) {
312
			$input_errors[] = "A valid destination bit count must be specified.";
313
		}
314
	}
315

    
316
	if ($_POST['srcbeginport'] > $_POST['srcendport']) {
317
		/* swap */
318
		$tmp = $_POST['srcendport'];
319
		$_POST['srcendport'] = $_POST['srcbeginport'];
320
		$_POST['srcbeginport'] = $tmp;
321
	}
322
	if ($_POST['dstbeginport'] > $_POST['dstendport']) {
323
		/* swap */
324
		$tmp = $_POST['dstendport'];
325
		$_POST['dstendport'] = $_POST['dstbeginport'];
326
		$_POST['dstbeginport'] = $tmp;
327
	}
328
	if ($_POST['os'])
329
		if( $_POST['proto'] != "tcp" )
330
			$input_errors[] = "OS detection is only valid with protocol tcp.";
331

    
332
	if ($_POST['ackqueue'] && $_POST['ackqueue'] != "none") {
333
		if ($_POST['defaultqueue'] == "none" )
334
			$input_errors[] = "You have to select a queue when you select an acknowledge queue too.";
335
		else if ($_POST['ackqueue'] == $_POST['defaultqueue'])
336
			$input_errors[] = "Acknowledge queue and Queue cannot be the same.";		
337
	}
338
	if ($_POST['pdnpipe'] && $_POST['pdnpipe'] != "none") {
339
		if ($_POST['dnpipe'] == "none" )
340
			$input_errors[] = "You must select a queue for the In direction before selecting one for Out too.";
341
		else if ($_POST['pdnpipe'] == $_POST['dnpipe'])
342
			$input_errors[] = "In and Out Queue cannot be the same.";
343
		else if ($pdnpipe[0] == "?" && $dnpipe[0] <> "?")
344
			$input_errors[] = "You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.";
345
		else if ($dnpipe[0] == "?" && $pdnpipe[0] <> "?")
346
			$input_errors[] = "You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.";
347
	}
348
	if( !empty($_POST['ruleid']) && !ctype_digit($_POST['ruleid']))
349
		$input_errors[] = 'ID must be an integer';
350
	if($_POST['l7container'] && $_POST['l7container'] != "none") {
351
		if(!($_POST['proto'] == "tcp" || $_POST['proto'] == "udp" || $_POST['proto'] == "tcp/udp"))
352
			$input_errors[] = "You can only select a layer7 container for tcp and/or udp protocols";
353
		if ($_POST['type'] <> "pass")
354
			$input_errors[] = "You can only select a layer7 container for Pass type rules.";
355
	}
356

    
357
	if (!$input_errors) {
358
		$filterent = array();
359
		$filterent['id'] = $_POST['ruleid']>0?$_POST['ruleid']:'';
360
		$filterent['type'] = $_POST['type'];
361
		if (isset($_POST['interface'] ))
362
			$filterent['interface'] = $_POST['interface'];
363

    
364
		if ($if == "FloatingRules" || isset($_POST['floating'])) {
365
			if (isset($_POST['tag']))
366
				$filterent['tag'] = $_POST['tag'];
367
			if (isset($_POST['tagged']))
368
            			$filterent['tagged'] = $_POST['tagged'];
369
			$filterent['direction'] = $_POST['direction'];
370
			if (isset($_POST['quick']) && $_POST['quick'] <> "")
371
				$filterent['quick'] = $_POST['quick'];
372
			$filterent['floating'] = "yes";
373
			if (isset($_POST['interface']) && count($_POST['interface']) > 0)  {
374
					$filterent['interface'] = implode(",", $_POST['interface']);
375
			}
376
		}
377

    
378
		/* Advanced options */
379
		if ($_POST['allowopts'] == "yes")
380
			$filterent['allowopts'] = true;
381
		else
382
			unset($filterent['allowopts']);
383
		$filterent['max-src-nodes'] = $_POST['max-src-nodes'];
384
		$filterent['max-src-conn'] = $_POST['max-src-conn'];
385
		$filterent['max-src-states'] = $_POST['max-src-states'];
386
		$filterent['statetimeout'] = $_POST['statetimeout'];
387
		$filterent['statetype'] = $_POST['statetype'];
388
		$filterent['os'] = $_POST['os'];
389

    
390
		/* Nosync directive - do not xmlrpc sync this item */
391
		if($_POST['nosync'] <> "")
392
			$filterent['nosync'] = true;
393
		else
394
			unset($filterent['nosync']);
395

    
396
		/* unless both values are provided, unset the values - ticket #650 */
397
		if($_POST['max-src-conn-rate'] <> "" and $_POST['max-src-conn-rates'] <> "") {
398
			$filterent['max-src-conn-rate'] = $_POST['max-src-conn-rate'];
399
			$filterent['max-src-conn-rates'] = $_POST['max-src-conn-rates'];
400
		} else {
401
			unset($filterent['max-src-conn-rate']);
402
			unset($filterent['max-src-conn-rates']);
403
		}
404

    
405
		if ($_POST['proto'] != "any")
406
			$filterent['protocol'] = $_POST['proto'];
407
		else
408
			unset($filterent['protocol']);
409

    
410
		if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
411
			$filterent['icmptype'] = $_POST['icmptype'];
412
		else
413
			unset($filterent['icmptype']);
414

    
415
		pconfig_to_address($filterent['source'], $_POST['src'],
416
			$_POST['srcmask'], $_POST['srcnot'],
417
			$_POST['srcbeginport'], $_POST['srcendport']);
418

    
419
		pconfig_to_address($filterent['destination'], $_POST['dst'],
420
			$_POST['dstmask'], $_POST['dstnot'],
421
			$_POST['dstbeginport'], $_POST['dstendport']);
422

    
423
                if ($_POST['disabled'])
424
                        $filterent['disabled'] = true;
425
                else
426
                        unset($filterent['disabled']);
427
		
428
		if ($_POST['dscp'])
429
			$filterent['dscp'] = $_POST['dscp'];
430

    
431
                if ($_POST['log'])
432
                        $filterent['log'] = true;
433
                else
434
                        unset($filterent['log']);
435
		strncpy($filterent['descr'], $_POST['descr'], 52);
436

    
437
		if ($_POST['gateway'] != "") {
438
			$filterent['gateway'] = $_POST['gateway'];
439
		}
440
		
441
		if (isset($_POST['defaultqueue']) && $_POST['defaultqueue'] != "none") {
442
			$filterent['defaultqueue'] = $_POST['defaultqueue'];
443
			if (isset($_POST['ackqueue']) && $_POST['ackqueue'] != "none")
444
				$filterent['ackqueue'] = $_POST['ackqueue'];
445
		}
446

    
447
		if (isset($_POST['dnpipe']) && $_POST['dnpipe'] != "none") {
448
			$filterent['dnpipe'] = $_POST['dnpipe'];
449
			if (isset($_POST['pdnpipe']) && $_POST['pdnpipe'] != "none")
450
				$filterent['pdnpipe'] = $_POST['pdnpipe'];
451
		}
452

    
453
		if (isset($_POST['l7container']) && $_POST['l7container'] != "none") {
454
			$filterent['l7container'] = $_POST['l7container'];
455
		}
456
		
457
		if ($_POST['sched'] != "") {
458
			$filterent['sched'] = $_POST['sched'];
459
		}
460

    
461
		if (isset($id) && $a_filter[$id])
462
			$a_filter[$id] = $filterent;
463
		else {
464
			if (is_numeric($after))
465
				array_splice($a_filter, $after+1, 0, array($filterent));
466
			else
467
				$a_filter[] = $filterent;
468
		}
469

    
470
		write_config();
471
		mark_subsystem_dirty('filter');
472

    
473
		if (isset($_POST['floating']))
474
			header("Location: firewall_rules.php?if=FloatingRules");
475
		else
476
			header("Location: firewall_rules.php?if=" . $_POST['interface']);
477
		exit;
478
	}
479
}
480

    
481
read_altq_config(); /* XXX: */
482
$qlist =& get_unique_queue_list();
483
read_dummynet_config(); /* XXX: */
484
$dnqlist =& get_unique_dnqueue_list();
485
read_layer7_config();
486
$l7clist =& get_l7_unique_list();
487

    
488
$pgtitle = array("Firewall","Rules","Edit");
489
$closehead = false;
490

    
491
$page_filename = "firewall_rules_edit.php";
492
include("head.inc");
493

    
494
?>
495

    
496
</head>
497

    
498
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
499
<?php include("fbegin.inc"); ?>
500
<?php if ($input_errors) print_input_errors($input_errors); ?>
501

    
502
<form action="firewall_rules_edit.php" method="post" name="iform" id="iform">
503
<input type='hidden' name="ruleid" value="<?=(isset($pconfig['ruleid'])&&$pconfig['ruleid']>0)?htmlspecialchars($pconfig['ruleid']):''?>">
504

    
505
	<table width="100%" border="0" cellpadding="6" cellspacing="0">
506
		<tr>
507
			<td colspan="2" valign="top" class="listtopic">Edit Firewall rule</td>
508
		</tr>	
509
    	<tr>
510
			<td width="22%" valign="top" class="vncellreq">Action</td>
511
			<td width="78%" class="vtable">
512
				<select name="type" class="formselect">
513
					<?php $types = explode(" ", "Pass Block Reject"); foreach ($types as $type): ?>
514
					<option value="<?=strtolower($type);?>" <?php if (strtolower($type) == strtolower($pconfig['type'])) echo "selected"; ?>>
515
					<?=htmlspecialchars($type);?>
516
					</option>
517
					<?php endforeach; ?>
518
				</select>
519
				<br/>
520
				<span class="vexpl">
521
					Choose what to do with packets that match the criteria specified below. <br/>
522
					Hint: the difference between block and reject is that with reject, a packet (TCP RST or ICMP port unreachable for UDP) is returned to the sender, whereas with block the packet is dropped silently. In either case, the original packet is discarded. Reject only works when the protocol is set to either TCP or UDP (but not &quot;TCP/UDP&quot;) below.
523
				</span>
524
			</td>
525
		</tr>
526
		<tr>
527
			<td width="22%" valign="top" class="vncellreq">Disabled</td>
528
			<td width="78%" class="vtable">
529
				<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
530
				<strong>Disable this rule</strong><br />
531
				<span class="vexpl">Set this option to disable this rule without removing it from the list.</span>
532
			</td>
533
		</tr>
534
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
535
		<tr>
536
                        <td width="22%" valign="top" class="vncellreq"><?=gettext("Quick");?></td>
537
                        <td width="78%" class="vtable">
538
                                <input name="quick" type="checkbox" id="quick" value="yes" <?php if ($pconfig['quick']) echo "checked=\"checked\""; ?> />
539
                                <strong><?=gettext("Apply the action immediately on match.");?></strong><br />
540
                                <span class="vexpl"><?=gettext("Set this option if you need to apply this action to traffic that matches this rule immediately.");?></span>
541
                        </td>
542
                </tr>
543
<? endif; ?>
544
		<tr>
545
			<td width="22%" valign="top" class="vncellreq">Interface</td>
546
			<td width="78%" class="vtable">
547
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
548
				<select name="interface[]" multiple="true" class="formselect" size="3">
549
<? else: ?>
550
				<select name="interface" class="formselect">
551
<?php
552
   endif;
553
				/* add group interfaces */
554
                                if (is_array($config['ifgroups']['ifgroupentry']))
555
					foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
556
						if (have_ruleint_access($ifgen['ifname']))
557
							$interfaces[$ifgen['ifname']] = $ifgen['ifname'];
558

    
559
				$ifdescs = get_configured_interface_with_descr();
560

    
561
				foreach ($ifdescs as $ifent => $ifdesc)
562
        				if(have_ruleint_access($ifent))
563
                				$interfaces[$ifent] = $ifdesc;
564

    
565
					if ($config['l2tp']['mode'] == "server")
566
                                                if(have_ruleint_access("l2tp"))
567
                                                        $interfaces['l2tp'] = "L2TP VPN";
568

    
569
					if ($config['pptpd']['mode'] == "server")
570
						if(have_ruleint_access("pptp")) 
571
							$interfaces['pptp'] = "PPTP VPN";
572
					
573
					if ($config['pppoe']['mode'] == "server")
574
						if(have_ruleint_access("pppoe")) 
575
							$interfaces['pppoe'] = "PPPoE VPN";
576
					
577
					/* add ipsec interfaces */
578
					if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
579
						if(have_ruleint_access("enc0")) 
580
							$interfaces["enc0"] = "IPsec";
581
		
582
					/* add openvpn/tun interfaces */
583
					if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
584
       					$interfaces["openvpn"] = "OpenVPN";
585

    
586
					foreach ($interfaces as $iface => $ifacename): ?>
587
						<option value="<?=$iface;?>" <?php if ($pconfig['interface'] <> "" && stristr($pconfig['interface'], $iface)) echo "selected"; ?>><?=gettext($ifacename);?></option>
588
<?php 				endforeach; ?>
589
				</select>
590
				<br />
591
				<span class="vexpl">Choose on which interface packets must come in to match this rule.</span>
592
			</td>
593
		</tr>
594
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
595
                <tr>
596
                        <td width="22%" valign="top" class="vncellreq"><?=gettext("Direction");?></td>
597
                        <td width="78%" class="vtable">
598
                                 <select name="direction" class="formselect">
599
                                  <?php      $directions = array('any', 'in', 'out');
600
                                        foreach ($directions as $direction): ?>
601
                                                <option value="<?=$direction;?>"
602
                                                <?php if ($direction == $pconfig['direction']): ?>
603
                                                        selected="selected" 
604
						<?php endif; ?>
605
                                                ><?=$direction;?></option>
606
                  	                <?php endforeach; ?>      
607
                                </select>
608
                		<input type="hidden" id="floating" name="floating" value="floating">
609
                        </td>
610
                <tr>
611
<?php endif; ?>
612
		<tr>
613
			<td width="22%" valign="top" class="vncellreq">Protocol</td>
614
			<td width="78%" class="vtable">
615
				<select name="proto" class="formselect" onchange="proto_change()">
616
<?php
617
				$protocols = explode(" ", "TCP UDP TCP/UDP ICMP ESP AH GRE IGMP any carp pfsync");
618
				foreach ($protocols as $proto): ?>
619
					<option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected"; ?>><?=htmlspecialchars($proto);?></option>
620
<?php 			endforeach; ?>
621
				</select>
622
				<br />
623
				<span class="vexpl">Choose which IP protocol this rule should match. <br /> Hint: in most cases, you should specify <em>TCP</em> &nbsp;here.</span>
624
			</td>
625
		</tr>
626
		<tr id="icmpbox" name="icmpbox">
627
			<td valign="top" class="vncell">ICMP type</td>
628
			<td class="vtable">
629
				<select name="icmptype" class="formselect">
630
<?php
631
				$icmptypes = array(
632
				"" => "any",
633
				"echorep" => "Echo reply",
634
				"unreach" => "Destination unreachable",
635
				"squench" => "Source quench",
636
				"redir" => "Redirect",
637
				"althost" => "Alternate Host",
638
				"echoreq" => "Echo",
639
				"routeradv" => "Router advertisement",
640
				"routersol" => "Router solicitation",
641
				"timex" => "Time exceeded",
642
				"paramprob" => "Invalid IP header",
643
				"timereq" => "Timestamp",
644
				"timerep" => "Timestamp reply",
645
				"inforeq" => "Information request",
646
				"inforep" => "Information reply",
647
				"maskreq" => "Address mask request",
648
				"maskrep" => "Address mask reply"
649
				);
650

    
651
				foreach ($icmptypes as $icmptype => $descr): ?>
652
					<option value="<?=$icmptype;?>" <?php if ($icmptype == $pconfig['icmptype']) echo "selected"; ?>><?=htmlspecialchars($descr);?></option>
653
<?php 			endforeach; ?>
654
			</select>
655
			<br />
656
			<span class="vexpl">If you selected ICMP for the protocol above, you may specify an ICMP type here.</span>
657
		</td>
658
		</tr>
659
		<tr>
660
			<td width="22%" valign="top" class="vncellreq">Source</td>
661
			<td width="78%" class="vtable">
662
				<input name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked"; ?>>
663
				<strong>not</strong>
664
				<br />
665
				Use this option to invert the sense of the match.
666
				<br />
667
				<br />
668
				<table border="0" cellspacing="0" cellpadding="0">
669
					<tr>
670
						<td>Type:&nbsp;&nbsp;</td>
671
						<td>
672
							<select name="srctype" class="formselect" onChange="typesel_change()">
673
<?php
674
								$sel = is_specialnet($pconfig['src']); ?>
675
								<option value="any"     <?php if ($pconfig['src'] == "any") { echo "selected"; } ?>>any</option>
676
								<option value="single"  <?php if (($pconfig['srcmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>Single host or alias</option>
677
								<option value="network" <?php if (!$sel) echo "selected"; ?>>Network</option>
678
								<?php if(have_ruleint_access("pptp")): ?>
679
								<option value="pptp"    <?php if ($pconfig['src'] == "pptp") { echo "selected"; } ?>>PPTP clients</option>
680
								<?php endif; ?>
681
								<?php if(have_ruleint_access("pppoe")): ?>
682
								<option value="pppoe"   <?php if ($pconfig['src'] == "pppoe") { echo "selected"; } ?>>PPPoE clients</option>
683
								<?php endif; ?>								
684
								 <?php if(have_ruleint_access("l2tp")): ?>
685
                                                                <option value="l2tp"   <?php if ($pconfig['src'] == "l2tp") { echo "selected"; } ?>>L2TP clients</option>
686
                                                                <?php endif; ?>
687
<?php
688
								foreach ($ifdisp as $ifent => $ifdesc): ?>
689
								<?php if(have_ruleint_access($ifent)): ?>
690
									<option value="<?=$ifent;?>" <?php if ($pconfig['src'] == $ifent) { echo "selected"; } ?>><?=htmlspecialchars($ifdesc);?> subnet</option>
691
									<option value="<?=$ifent;?>ip"<?php if ($pconfig['src'] ==  $ifent . "ip") { echo "selected"; } ?>>
692
										<?=$ifdesc?> address
693
									</option>
694
								<?php endif; ?>
695
<?php 							endforeach; ?>
696
							</select>
697
						</td>
698
					</tr>
699
					<tr>
700
						<td>Address:&nbsp;&nbsp;</td>
701
						<td>
702
							<input autocomplete='off' name="src" type="text" class="formfldalias" id="src" size="20" value="<?php if (!is_specialnet($pconfig['src'])) echo htmlspecialchars($pconfig['src']);?>"> /
703
							<select name="srcmask" class="formselect" id="srcmask">
704
<?php						for ($i = 31; $i > 0; $i--): ?>
705
								<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected"; ?>><?=$i;?></option>
706
<?php 						endfor; ?>
707
							</select>
708
						</td>
709
					</tr>
710
				</table>
711
				<div id="showadvancedboxspr">
712
					<p>
713
					<input type="button" onClick="show_source_port_range()" value="Advanced"></input> - Show source port range</a>
714
				</div>
715
			</td>
716
		</tr>
717
		<tr style="display:none" id="sprtable" name="sprtable">
718
			<td width="22%" valign="top" class="vncellreq">Source port range</td>
719
			<td width="78%" class="vtable">
720
				<table border="0" cellspacing="0" cellpadding="0">
721
					<tr>
722
						<td>from:&nbsp;&nbsp;</td>
723
						<td>
724
							<select name="srcbeginport" class="formselect" onchange="src_rep_change();ext_change()">
725
								<option value="">(other)</option>
726
								<option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
727
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
728
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) { echo "selected"; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
729
<?php 							endforeach; ?>
730
							</select>
731
							<input autocomplete='off' class="formfldalias" name="srcbeginport_cust" id="srcbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcbeginport']) echo $pconfig['srcbeginport']; ?>">
732
						</td>
733
					</tr>
734
					<tr>
735
						<td>to:</td>
736
						<td>
737
							<select name="srcendport" class="formselect" onchange="ext_change()">
738
								<option value="">(other)</option>
739
								<option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
740
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
741
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) { echo "selected"; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
742
<?php							endforeach; ?>
743
							</select>
744
							<input autocomplete='off' class="formfldalias" name="srcendport_cust" id="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo $pconfig['srcendport']; ?>">
745
						</td>
746
					</tr>
747
				</table>
748
				<br />
749
				<span class="vexpl">Specify the port or port range for the source of the packet for this rule. This is usually not equal to the destination port range (and is often &quot;any&quot;). <br /> Hint: you can leave the <em>'to'</em> field empty if you only want to filter a single port</span><br/>
750
				<span class="vexpl"><B>NOTE:</B> You will not need to enter anything here in 99.99999% of the circumstances.  If you're unsure, do not enter anything here!</span>
751
			</td>
752
		</tr>
753
		<tr>
754
			<td width="22%" valign="top" class="vncell">Source OS</td>
755
			<td width="78%" class="vtable">OS Type:&nbsp;
756
				<select name="os" id="os" class="formselect">
757
<?php
758
		           $ostypes = array(
759
						 "" => "any",
760
		                 "AIX" => "AIX",
761
		                 "Linux" => "Linux",
762
		                 "FreeBSD" => "FreeBSD",
763
		                 "NetBSD" => "NetBSD",
764
		                 "OpenBSD" => "OpenBSD",
765
		                 "Solaris" => "Solaris",
766
		                 "MacOS" => "MacOS",
767
		                 "Windows" => "Windows",
768
		                 "Novell" => "Novell",
769
		                 "NMAP" => "NMAP"
770
		           );
771

    
772
					foreach ($ostypes as $ostype => $descr): ?>
773
						<option value="<?=$ostype;?>" <?php if ($ostype == $pconfig['os']) echo "selected"; ?>><?=htmlspecialchars($descr);?></option>
774
<?php				endforeach; ?>
775
				</select>
776
				<br />
777
				Note: this only works for TCP rules
778
			</td>
779
		</tr>
780
		<tr>
781
			<td width="22%" valign="top" class="vncellreq">Destination</td>
782
			<td width="78%" class="vtable">
783
				<input name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked"; ?>>
784
				<strong>not</strong>
785
					<br />
786
				Use this option to invert the sense of the match.
787
					<br />
788
					<br />
789
				<table border="0" cellspacing="0" cellpadding="0">
790
					<tr>
791
						<td>Type:&nbsp;&nbsp;</td>
792
						<td>
793
							<select name="dsttype" class="formselect" onChange="typesel_change()">
794
<?php
795
								$sel = is_specialnet($pconfig['dst']); ?>
796
								<option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected"; } ?>>any</option>
797
								<option value="single" <?php if (($pconfig['dstmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>Single host or alias</option>
798
								<option value="network" <?php if (!$sel) echo "selected"; ?>>Network</option>
799
								<?php if(have_ruleint_access("pptp")): ?>
800
								<option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected"; } ?>>PPTP clients</option>
801
								<?php endif; ?>
802
								<?php if(have_ruleint_access("pppoe")): ?>
803
								<option value="pppoe" <?php if ($pconfig['dst'] == "pppoe") { echo "selected"; } ?>>PPPoE clients</option>
804
								<?php endif; ?>								
805
								<?php if(have_ruleint_access("l2tp")): ?>
806
                                                                <option value="l2tp" <?php if ($pconfig['dst'] == "l2tp") { echo "selected"; } ?>>L2TP clients</option>
807
                                                                <?php endif; ?>
808

    
809
<?php 							foreach ($ifdisp as $if => $ifdesc): ?>
810
								<?php if(have_ruleint_access($if)): ?>
811
									<option value="<?=$if;?>" <?php if ($pconfig['dst'] == $if) { echo "selected"; } ?>><?=htmlspecialchars($ifdesc);?> subnet</option>
812
									<option value="<?=$if;?>ip"<?php if ($pconfig['dst'] == $if . "ip") { echo "selected"; } ?>>
813
										<?=$ifdesc;?> address
814
									</option>
815
								<?php endif; ?>
816
<?php 							endforeach; ?>
817
							</select>
818
						</td>
819
					</tr>
820
					<tr>
821
						<td>Address:&nbsp;&nbsp;</td>
822
						<td>
823
							<input name="dst" type="text" class="formfldalias" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>">
824
							/
825
							<select name="dstmask" class="formselect" id="dstmask">
826
<?php
827
							for ($i = 31; $i > 0; $i--): ?>
828
								<option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected"; ?>><?=$i;?></option>
829
<?php						endfor; ?>
830
							</select>
831
						</td>
832
					</tr>
833
				</table>
834

    
835
			</td>
836
		</tr>
837
		<tr id="dprtr" name="dprtr">
838
			<td width="22%" valign="top" class="vncellreq">Destination port range </td>
839
			<td width="78%" class="vtable">
840
				<table border="0" cellspacing="0" cellpadding="0">
841
					<tr>
842
						<td>from:&nbsp;&nbsp;</td>
843
						<td>
844
							<select name="dstbeginport" class="formselect" onchange="dst_rep_change();ext_change()">
845
								<option value="">(other)</option>
846
								<option value="any" <?php $bfound = 0; if ($pconfig['dstbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
847
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
848
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstbeginport']) { echo "selected"; $bfound = 1; }?>><?=htmlspecialchars($wkportdesc);?></option>
849
<?php 							endforeach; ?>
850
							</select>
851
							<input autocomplete='off' class="formfldalias" name="dstbeginport_cust" id="dstbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstbeginport']) echo $pconfig['dstbeginport']; ?>">
852
						</td>
853
					</tr>
854
					<tr>
855
						<td>to:</td>
856
						<td>
857
							<select name="dstendport" class="formselect" onchange="ext_change()">
858
								<option value="">(other)</option>
859
								<option value="any" <?php $bfound = 0; if ($pconfig['dstendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
860
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
861
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstendport']) { echo "selected"; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
862
<?php 							endforeach; ?>
863
							</select>
864
							<input autocomplete='off' class="formfldalias" name="dstendport_cust" id="dstendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstendport']) echo $pconfig['dstendport']; ?>">
865
						</td>
866
					</tr>
867
				</table>
868
				<br />
869
				<span class="vexpl">
870
					Specify the port or port range for the destination of the packet for this rule.
871
						<br />
872
					Hint: you can leave the <em>'to'</em> field empty if you only want to filter a single port
873
				</span>
874
			</td>
875
		</tr>
876
                <tr>
877
                        <td width="22%" valign="top" class="vncellreq">Diffserv Code Point</td>
878
                        <td width="78%" class="vtable">
879
                                <input name="dscp" id="dscp" value="<?=htmlspecialchars($pconfig['dscp']);?>">
880
                                        <br />
881
                                <span class="vexpl">Valid values are: af11, af12, af13, af21, af22, af23, af31, af32, af33, af41, af42, af43, EF, 1-64, 0x04-0xfc.</span>
882
                        </td>
883
                </tr>
884
		<tr>
885
			<td width="22%" valign="top" class="vncellreq">Log</td>
886
			<td width="78%" class="vtable">
887
				<input name="log" type="checkbox" id="log" value="yes" <?php if ($pconfig['log']) echo "checked"; ?>>
888
				<strong>Log packets that are handled by this rule</strong>
889
					<br />
890
				<span class="vexpl">Hint: the firewall has limited local log space. Don't turn on logging for everything. If you want to do a lot of logging, consider using a remote syslog server (see the <a href="diag_logs_settings.php">Diagnostics: System logs: Settings</a> page).</span>
891
			</td>
892
		</tr>
893
		<tr>
894
			<td width="22%" valign="top" class="vncell">Advanced Options</td>
895
			<td width="78%" class="vtable">
896
			<div id="aoadv" name="aoadv">
897
				<input type="button" onClick="show_aodiv();" value="Advanced"> - Show advanced options
898
			</div>
899
			<div id="aodivmain" name="aodivmain" style="display:none">
900

    
901
                                <input type="checkbox" id="allowopts" value="yes" name="allowopts"<?php if($pconfig['allowopts'] == true) echo " checked"; ?>>
902
                                <br/><span class="vexpl"><?=gettext("This allows packets with ip options to pass otherwise they are blocked by default i.e. with multicast routing/proxing.");?>
903
				</span><p>
904
                                <input name="tag" id="tag" value="<?=htmlspecialchars($pconfig['tag']);?>">
905
                                <br /><span class="vexpl"><?=gettext("You can mark a packet matching this rule and use this mark to match on other nat/filter rules. It is called <b>Policy filtering</b>");?>
906
                                </span><p>
907
                                <input name="tagged" id="tagged" value="<?=htmlspecialchars($pconfig['tagged']);?>">
908
                                <br /><span class="vexpl"><?=gettext("You can match packet on a mark placed before on another rule.")?>
909
                                </span> <p>
910
				<input name="max-src-nodes" id="max-src-nodes" value="<?php echo $pconfig['max-src-nodes'] ?>"><br> Simultaneous client connection limit<p>
911
				<input name="max-src-conn" id="max-src-conn" value="<?php echo $pconfig['max-src-conn'] ?>"><br> Maximum established TCP connections per host<p>	 
912
				<input name="max-src-states" id="max-src-states" value="<?php echo $pconfig['max-src-states'] ?>"><br> Maximum state entries per host<p>
913
				<input name="max-src-conn-rate" id="max-src-conn-rate" value="<?php echo $pconfig['max-src-conn-rate'] ?>"> /
914
				<select name="max-src-conn-rates" id="max-src-conn-rates">
915
					<option value=""<?php if(intval($pconfig['max-src-conn-rates']) < 1) echo " selected"; ?>></option>
916
<?php				for($x=1; $x<255; $x++) {
917
						if($x == $pconfig['max-src-conn-rates']) $selected = " selected"; else $selected = "";
918
						echo "<option value=\"{$x}\"{$selected}>{$x}</option>\n";
919
					} ?>
920
				</select><br />
921
				Maximum new connections / per second
922
				<p>
923

    
924
				<input name="statetimeout" value="<?php echo $pconfig['statetimeout'] ?>"><br>
925
				State Timeout in seconds
926
				<p />
927

    
928
				<p><strong>NOTE: Leave these fields blank to disable this feature.</strong>
929
			  </div>
930
			</td>
931
		</tr>
932
		<tr>
933
			<td width="22%" valign="top" class="vncell">State Type</td>
934
			<td width="78%" class="vtable">
935
				<div id="showadvstatebox">
936
					<input type="button" onClick="show_advanced_state()" value="Advanced"></input> - Show state</a>
937
				</div>
938
				<div id="showstateadv" style="display:none">
939
					<select name="statetype">
940
						<option value="keep state" <?php if(!isset($pconfig['statetype']) or $pconfig['statetype'] == "keep state") echo "selected"; ?>>keep state</option>
941
						<option value="synproxy state"<?php if($pconfig['statetype'] == "synproxy state")  echo "selected"; ?>>synproxy state</option>
942
						<option value="none"<?php if($pconfig['statetype'] == "none") echo "selected"; ?>>none</option>
943
					</select><br>HINT: Select which type of state tracking mechanism you would like to use.  If in doubt, use keep state.
944
					<p>
945
					<table width="90%">
946
						<tr><td width="25%"><ul><li>keep state</li></td><td>Works with all IP protocols.</ul></td></tr>
947
						<tr><td width="25%"><ul><li>synproxy state</li></td><td>Proxies incoming TCP connections to help protect servers from spoofed TCP SYN floods. This option includes the functionality of keep state and modulate state combined.</ul></td></tr>
948
						<tr><td width="25%"><ul><li>none</li></td><td>Do not use state mechanisms to keep track.  This is only useful if you're doing advanced queueing in certain situations.  Please check the documentation.</ul></td></tr>
949
					</table>
950
					</p>
951
			  </div>
952
			</td>
953
		</tr>
954
		<tr>
955
			<td width="22%" valign="top" class="vncell">No XMLRPC Sync</td>
956
			<td width="78%" class="vtable">
957
				<input type="checkbox" name="nosync"<?php if($pconfig['nosync']) echo " CHECKED"; ?>><br>
958
				HINT: This prevents the rule from automatically syncing to other carp members.
959
			</td>
960
		</tr>
961
		<?php
962
			//build list of schedules
963
			$schedules = array();
964
			$schedules[] = "none";//leave none to leave rule enabled all the time
965
			if(is_array($config['schedules']['schedule'])) {
966
				foreach ($config['schedules']['schedule'] as $schedule) {
967
					if ($schedule['name'] <> "")
968
						$schedules[] = $schedule['name'];
969
				}
970
			}
971
		?>
972
		<tr>
973
			<td width="22%" valign="top" class="vncell">Schedule</td>
974
			<td width="78%" class="vtable">
975
				<select name='sched'>
976
<?php
977
				foreach($schedules as $schedule) {
978
					if($schedule == $pconfig['sched']) {
979
						$selected = " SELECTED";
980
					} else {
981
						$selected = "";
982
					}
983
					if ($schedule == "none") {
984
						echo "<option value=\"\" {$selected}>{$schedule}</option>\n";
985
					} else {
986
						echo "<option value=\"{$schedule}\" {$selected}>{$schedule}</option>\n";
987
					}
988
				}?>
989
				</select>
990
				<p>Leave as 'none' to leave the rule enabled all the time.</p>
991
			</td>
992
		</tr>
993
		
994
<?php
995
			/* build a list of gateways */
996
			$gateways = array();
997
			$gateways[] = "default"; // default to don't use this feature :)
998
			if (is_array($config['gateways']['gateway_item'])) {
999
				foreach($config['gateways']['gateway_item'] as $gw_item) {
1000
				if($gw_item['gateway'] <> "")
1001
					$gateways[] = $gw_item['name'];
1002
				}
1003
			}
1004
			
1005
?>
1006
		<tr>
1007
			<td width="22%" valign="top" class="vncell">Gateway</td>
1008
			<td width="78%" class="vtable">
1009
				<select name='gateway'>
1010
<?php
1011
				foreach($gateways as $gw) {
1012
					if($gw == "") 
1013
						continue;
1014
					if($gw == $pconfig['gateway']) {
1015
						$selected = " SELECTED";
1016
					} else {
1017
						$selected = "";
1018
					}
1019
					if ($gw == "default") {
1020
						echo "<option value=\"\" {$selected}>{$gw}</option>\n";
1021
					} else {
1022
						$gwip = lookup_gateway_ip_by_name($gw);
1023
						echo "<option value=\"{$gw}\" {$selected}>{$gw} - {$gwip}</option>\n";
1024
					}
1025
				}
1026
				/* add gateway groups to the list */
1027
				if (is_array($config['gateways']['gateway_group'])) {
1028
					foreach($config['gateways']['gateway_group'] as $gw_group) {
1029
						if($gw_group['name'] == "")
1030
							continue;
1031
						if($pconfig['gateway'] == $gw_group['name']) {
1032
							echo "<option value=\"{$gw_group['name']}\" SELECTED>{$gw_group['name']}</option>\n";
1033
						} else {
1034
							echo "<option value=\"{$gw_group['name']}\">{$gw_group['name']}</option>\n";
1035
						}
1036
					}
1037
				}
1038
				$iflist = get_configured_interface_with_descr();
1039
				foreach ($iflist as $ifent => $ifdesc) {
1040
					if (in_array($config['interfaces'][$ifent]['ipaddr'],
1041
						 array("dhcp", "pppoe", "pptp"))) {
1042
						if ($pconfig['gateway'] == $ifent) {
1043
							$selected = " SELECTED";
1044
						} else {
1045
							$selected = "";
1046
						}
1047
						if($ifdesc <> "") 
1048
							echo "<option value=\"{$ifent}\" {$selected}>".strtoupper($if)." - {$ifdesc}</option>\n";
1049
					}
1050
				}
1051
?>
1052
				</select>
1053
				<p><strong>Leave as 'default' to use the system routing table.  Or choose a gateway to utilize policy based routing.</strong></p>
1054
			</td>
1055
		</tr>
1056
		<tr>
1057
			<td width="22%" valign="top" class="vncell">In/Out</td>
1058
			<td width="78%" class="vtable">
1059
			<select name="dnpipe">
1060
<?php
1061
		if (!is_array($dnqlist))
1062
			$dnqlist = array();
1063
		echo "<option value=\"none\"";
1064
		if (!$dnqselected) echo " SELECTED";
1065
		echo " >none</option>";
1066
		foreach ($dnqlist as $dnq => $dnqkey) {
1067
			if($dnq == "")
1068
				continue;
1069
			echo "<option value=\"$dnqkey\"";
1070
			if ($dnqkey == $pconfig['dnpipe']) {
1071
				$dnqselected = 1;
1072
				echo " SELECTED";
1073
			}
1074
			echo ">{$dnq}</option>"; 
1075
		}
1076
?>
1077
			</select> / 			
1078
			<select name="pdnpipe">
1079
<?php
1080
		$dnqselected = 0;
1081
		echo "<option value=\"none\"";
1082
		if (!$dnqselected) echo " SELECTED";
1083
		echo " >none</option>";
1084
		foreach ($dnqlist as $dnq => $dnqkey) {
1085
			if($dnq == "")
1086
				continue;
1087
			echo "<option value=\"$dnqkey\"";
1088
			if ($dnqkey == $pconfig['pdnpipe']) {
1089
				$dnqselected = 1;
1090
				echo " SELECTED";
1091
			}
1092
			echo ">{$dnq}</option>"; 
1093
		}
1094
?>
1095
			</select>
1096
				<br />
1097
				<span class="vexpl">Choose the Out queue/Virtual interface only if you have selected In too. <br/> The Out selection is applied to traffic going out the interface the rule is created, In is the incoming one. <br/> If you are creating a rule on the Floating tab if the direction is In then the same rules apply, if the direction is out the selections are reverted Out is for incoming and In is for outgoing and if you do not select any direction use only the In since the Out selection does not make sense in there to prevent oddities.</span>
1098
			</td>
1099
		</tr>
1100

    
1101
		<tr>
1102
			<td width="22%" valign="top" class="vncell">Ackqueue/Queue</td>
1103
			<td width="78%" class="vtable">
1104
			<select name="ackqueue">
1105
<?php
1106
		if (!is_array($qlist))
1107
			$qlist = array();
1108
		echo "<option value=\"none\"";
1109
		if (!$qselected) echo " SELECTED";
1110
		echo " >none</option>";
1111
		foreach ($qlist as $q => $qkey) {
1112
			if($q == "")
1113
				continue;
1114
			echo "<option value=\"$q\"";
1115
			if ($q == $pconfig['ackqueue']) {
1116
				$qselected = 1;
1117
				echo " SELECTED";
1118
			}
1119
			echo ">{$q}</option>"; 
1120
		}
1121
?>
1122
			</select> / 			
1123
			<select name="defaultqueue">
1124
<?php
1125
		$qselected = 0;
1126
		echo "<option value=\"none\"";
1127
		if (!$qselected) echo " SELECTED";
1128
		echo " >none</option>";
1129
		foreach ($qlist as $q => $qkey) {
1130
			if($q == "")
1131
				continue;
1132
			echo "<option value=\"$q\"";
1133
			if ($q == $pconfig['defaultqueue']) {
1134
				$qselected = 1;
1135
				echo " SELECTED";
1136
			}
1137
			echo ">{$q}</option>"; 
1138
		}
1139
?>
1140
			</select>
1141
				<br />
1142
				<span class="vexpl">Choose the Acknowledge Queue only if you have selected Queue.</span>
1143
			</td>
1144
		</tr>
1145
		<tr>
1146
			<td width="22%" valign="top" class="vncell">Layer7</td>
1147
			<td width="78%" class="vtable">
1148
			<select name="l7container">
1149
<?php
1150
		if (!is_array($l7clist))
1151
			$dnqlist = array();
1152
		echo "<option value=\"none\"";
1153
		echo " >none</option>";
1154
		foreach ($l7clist as $l7ckey) {
1155
			echo "<option value=\"{$l7ckey}\"";
1156
			if ($l7ckey == $pconfig['l7container']) {
1157
				echo " SELECTED";
1158
			}
1159
			echo ">{$l7ckey}</option>"; 
1160
		}
1161
?>
1162
			</select>			
1163
				<br/>
1164
				<span class="vexpl">Choose a Layer7 container to apply application protocol inspection rules.
1165
				This rule are valid for tcp and udp protocols for now.</span>
1166
			</td>
1167
		</tr>
1168
		<tr>
1169
			<td width="22%" valign="top" class="vncell">Description</td>
1170
			<td width="78%" class="vtable">
1171
				<input name="descr" type="text" class="formfld unknown" id="descr" size="52" maxlength="52" value="<?=htmlspecialchars($pconfig['descr']);?>">
1172
				<br />
1173
				<span class="vexpl">You may enter a description here for your reference.</span>
1174
			</td>
1175
		</tr>
1176
		<tr>
1177
			<td width="22%" valign="top">&nbsp;</td>
1178
			<td width="78%">
1179
				<input name="Submit" type="submit" class="formbtn" value="Save">  <input type="button" class="formbtn" value="Cancel" onclick="history.back()">
1180
<?php			if (isset($id) && $a_filter[$id]): ?>
1181
					<input name="id" type="hidden" value="<?=$id;?>">
1182
<?php 			endif; ?>
1183
				<input name="after" type="hidden" value="<?=$after;?>">
1184
			</td>
1185
		</tr>
1186
	</table>
1187
</form>
1188
<script language="JavaScript">
1189
<!--
1190
	ext_change();
1191
	typesel_change();
1192
	proto_change();
1193

    
1194
<?php
1195
	$isfirst = 0;
1196
	$aliases = "";
1197
	$addrisfirst = 0;
1198
	$aliasesaddr = "";
1199
	if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
1200
		foreach($config['aliases']['alias'] as $alias_name) {
1201
			if(!stristr($alias_name['address'], ".")) {
1202
				if($isfirst == 1) $aliases .= ",";
1203
				$aliases .= "'" . $alias_name['name'] . "'";
1204
				$isfirst = 1;
1205
			} else {
1206
				if($addrisfirst == 1) $aliasesaddr .= ",";
1207
				$aliasesaddr .= "'" . $alias_name['name'] . "'";
1208
				$addrisfirst = 1;
1209
			}
1210
		}
1211
?>
1212

    
1213
	var addressarray=new Array(<?php echo $aliasesaddr; ?>);
1214
	var customarray=new Array(<?php echo $aliases; ?>);
1215

    
1216
	var oTextbox1 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
1217
        var oTextbox2 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
1218
        var oTextbox3 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
1219
        var oTextbox4 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
1220
        var oTextbox5 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
1221
        var oTextbox6 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
1222
//-->
1223
</script>
1224

    
1225

    
1226
<?php include("fend.inc"); ?>
1227
</body>
1228
</html>
1229

    
(56-56/214)