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

    
45
require("guiconfig.inc");
46

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
173
if ($_POST) {
174

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
493
?>
494

    
495
</head>
496

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

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

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

    
558
				$ifdescs = get_configured_interface_with_descr();
559

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

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

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

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

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

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

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

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

    
900
                                <input type="checkbox" id="allowopts" value="yes" name="allowopts"<?php if($pconfig['allowopts'] == true) echo " checked"; ?>>
901
                                <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.");?>
902
				</span><p>
903
                                <input name="tag" id="tag" value="<?=htmlspecialchars($pconfig['tag']);?>">
904
                                <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>");?>
905
                                </span><p>
906
                                <input name="tagged" id="tagged" value="<?=htmlspecialchars($pconfig['tagged']);?>">
907
                                <br /><span class="vexpl"><?=gettext("You can match packet on a mark placed before on another rule.")?>
908
                                </span> <p>
909
				<input name="max-src-nodes" id="max-src-nodes" value="<?php echo $pconfig['max-src-nodes'] ?>"><br> Simultaneous client connection limit<p>
910
				<input name="max-src-conn" id="max-src-conn" value="<?php echo $pconfig['max-src-conn'] ?>"><br> Maximum established TCP connections per host<p>	 
911
				<input name="max-src-states" id="max-src-states" value="<?php echo $pconfig['max-src-states'] ?>"><br> Maximum state entries per host<p>
912
				<input name="max-src-conn-rate" id="max-src-conn-rate" value="<?php echo $pconfig['max-src-conn-rate'] ?>"> /
913
				<select name="max-src-conn-rates" id="max-src-conn-rates">
914
					<option value=""<?php if(intval($pconfig['max-src-conn-rates']) < 1) echo " selected"; ?>></option>
915
<?php				for($x=1; $x<255; $x++) {
916
						if($x == $pconfig['max-src-conn-rates']) $selected = " selected"; else $selected = "";
917
						echo "<option value=\"{$x}\"{$selected}>{$x}</option>\n";
918
					} ?>
919
				</select><br />
920
				Maximum new connections / per second
921
				<p>
922

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

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

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

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

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

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

    
1224

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

    
(56-56/214)