Project

General

Profile

Download (48.1 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-states'] = $a_filter[$id]['max-src-states'];
135
	$pconfig['statetype'] = $a_filter[$id]['statetype'];
136
	$pconfig['statetimeout'] = $a_filter[$id]['statetimeout'];
137

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

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

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

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

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

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

    
172
if ($_POST) {
173

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
467
		write_config();
468
		mark_subsystem_dirty('filter');
469

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

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

    
485
$pgtitle = array("Firewall","Rules","Edit");
486
$closehead = false;
487

    
488
$page_filename = "firewall_rules_edit.php";
489
include("head.inc");
490

    
491
?>
492

    
493
</head>
494

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

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

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

    
556
				$ifdescs = get_configured_interface_with_descr();
557

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1209
	var addressarray=new Array(<?php echo $aliasesaddr; ?>);
1210
	var customarray=new Array(<?php echo $aliases; ?>);
1211

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

    
1221

    
1222
<?php include("fend.inc"); ?>
1223
</body>
1224
</html>
1225

    
(59-59/218)