Project

General

Profile

Download (47 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
##|+PRIV
35
##|*IDENT=page-firewall-rules-edit
36
##|*NAME=Firewall: Rules: Edit page
37
##|*DESCR=Allow access to the 'Firewall: Rules: Edit' page.
38
##|*MATCH=firewall_rules_edit.php*
39
##|-PRIV
40

    
41

    
42
require("guiconfig.inc");
43

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

    
51
if (!is_array($config['filter']['rule'])) {
52
	$config['filter']['rule'] = array();
53
}
54
filter_rules_sort();
55
$a_filter = &$config['filter']['rule'];
56

    
57
$id = $_GET['id'];
58
if (is_numeric($_POST['id']))
59
	$id = $_POST['id'];
60

    
61
$after = $_GET['after'];
62

    
63
if (isset($_POST['after']))
64
	$after = $_POST['after'];
65

    
66
if (isset($_GET['dup'])) {
67
	$id = $_GET['dup'];
68
	$after = $_GET['dup'];
69
}
70

    
71
if (isset($id) && $a_filter[$id]) {
72
	$pconfig['interface'] = $a_filter[$id]['interface'];
73

    
74
	if (!isset($a_filter[$id]['type']))
75
		$pconfig['type'] = "pass";
76
	else
77
		$pconfig['type'] = $a_filter[$id]['type'];
78

    
79
	if (isset($a_filter[$id]['floating']) || $if == "FloatingRules") {
80
		$pconfig['floating'] = $a_filter[$id]['floating'];
81
		if (isset($a_filter[$id]['interface']) && $a_filter[$id]['interface'] <> "") 
82
			$pconfig['interface'] = $a_filter[$id]['interface'];
83
	}
84
	
85
	if (isset($a_filter['floating'])) 
86
		$pconfig['floating'] = "yes";
87

    
88
	if (isset($a_filter[$id]['direction']))
89
                $pconfig['direction'] = $a_filter[$id]['direction'];
90

    
91
	if (isset($a_filter[$id]['protocol']))
92
		$pconfig['proto'] = $a_filter[$id]['protocol'];
93
	else
94
		$pconfig['proto'] = "any";
95

    
96
	if ($a_filter[$id]['protocol'] == "icmp")
97
		$pconfig['icmptype'] = $a_filter[$id]['icmptype'];
98

    
99
	address_to_pconfig($a_filter[$id]['source'], $pconfig['src'],
100
		$pconfig['srcmask'], $pconfig['srcnot'],
101
		$pconfig['srcbeginport'], $pconfig['srcendport']);
102

    
103
	if($a_filter[$id]['os'] <> "")
104
		$pconfig['os'] = $a_filter[$id]['os'];
105

    
106
	address_to_pconfig($a_filter[$id]['destination'], $pconfig['dst'],
107
		$pconfig['dstmask'], $pconfig['dstnot'],
108
		$pconfig['dstbeginport'], $pconfig['dstendport']);
109

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

    
113
	$pconfig['disabled'] = isset($a_filter[$id]['disabled']);
114
	$pconfig['log'] = isset($a_filter[$id]['log']);
115
	$pconfig['descr'] = $a_filter[$id]['descr'];
116

    
117
	if (isset($a_filter[$id]['tag']) && $a_filter[$id]['tag'] <> "") 
118
		$pconfig['tag'] = $a_filter[$id]['tag'];
119
	if (isset($a_filter[$id]['tagged']) && $a_filter[$id]['tagged'] <> "")
120
        	$pconfig['tagged'] = $a_filter[$id]['tagged'];
121
	if (isset($a_filter[$id]['quick']) && $a_filter[$id]['quick'])
122
		$pconfig['quick'] = $a_filter[$id]['quick'];
123
	if (isset($a_filter[$id]['allowopts']))
124
		$pconfig['allowopts'] = true;
125

    
126
	/* advanced */
127
	$pconfig['max-src-nodes'] = $a_filter[$id]['max-src-nodes'];
128
	$pconfig['max-src-states'] = $a_filter[$id]['max-src-states'];
129
	$pconfig['statetype'] = $a_filter[$id]['statetype'];
130
	$pconfig['statetimeout'] = $a_filter[$id]['statetimeout'];
131

    
132
	/* advanced - nosync */
133
	$pconfig['nosync'] = isset($a_filter[$id]['nosync']);
134

    
135
	/* advanced - new connection per second banning*/
136
	$pconfig['max-src-conn-rate'] = $a_filter[$id]['max-src-conn-rate'];
137
	$pconfig['max-src-conn-rates'] = $a_filter[$id]['max-src-conn-rates'];
138

    
139
	/* Multi-WAN next-hop support */
140
	$pconfig['gateway'] = $a_filter[$id]['gateway'];
141
	
142
	/* Shaper support */
143
	$pconfig['defaultqueue'] = $a_filter[$id]['defaultqueue'];
144
	$pconfig['ackqueue'] = $a_filter[$id]['ackqueue'];
145
	$pconfig['dnpipe'] = $a_filter[$id]['dnpipe'];
146
	$pconfig['pdnpipe'] = $a_filter[$id]['pdnpipe'];
147
	$pconfig['l7container'] = $a_filter[$id]['l7container'];
148

    
149
	//schedule support
150
	$pconfig['sched'] = $a_filter[$id]['sched'];
151

    
152
} else {
153
	/* defaults */
154
	if ($_GET['if'])
155
		$pconfig['interface'] = $_GET['if'];
156
	$pconfig['type'] = "pass";
157
	$pconfig['src'] = "any";
158
	$pconfig['dst'] = "any";
159
}
160
/* Allow the FlotingRules to work */
161
$if = $pconfig['interface'];
162

    
163
if (isset($_GET['dup']))
164
	unset($id);
165

    
166
if ($_POST) {
167

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

    
171
	if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp")) {
172
		$_POST['srcbeginport'] = 0;
173
		$_POST['srcendport'] = 0;
174
		$_POST['dstbeginport'] = 0;
175
		$_POST['dstendport'] = 0;
176
	} else {
177

    
178
		if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
179
			$_POST['srcbeginport'] = $_POST['srcbeginport_cust'];
180
		if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
181
			$_POST['srcendport'] = $_POST['srcendport_cust'];
182

    
183
		if ($_POST['srcbeginport'] == "any") {
184
			$_POST['srcbeginport'] = 0;
185
			$_POST['srcendport'] = 0;
186
		} else {
187
			if (!$_POST['srcendport'])
188
				$_POST['srcendport'] = $_POST['srcbeginport'];
189
		}
190
		if ($_POST['srcendport'] == "any")
191
			$_POST['srcendport'] = $_POST['srcbeginport'];
192

    
193
		if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
194
			$_POST['dstbeginport'] = $_POST['dstbeginport_cust'];
195
		if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
196
			$_POST['dstendport'] = $_POST['dstendport_cust'];
197

    
198
		if ($_POST['dstbeginport'] == "any") {
199
			$_POST['dstbeginport'] = 0;
200
			$_POST['dstendport'] = 0;
201
		} else {
202
			if (!$_POST['dstendport'])
203
				$_POST['dstendport'] = $_POST['dstbeginport'];
204
		}
205
		if ($_POST['dstendport'] == "any")
206
			$_POST['dstendport'] = $_POST['dstbeginport'];
207
	}
208

    
209
	if (is_specialnet($_POST['srctype'])) {
210
		$_POST['src'] = $_POST['srctype'];
211
		$_POST['srcmask'] = 0;
212
	} else if ($_POST['srctype'] == "single") {
213
		$_POST['srcmask'] = 32;
214
	}
215
	if (is_specialnet($_POST['dsttype'])) {
216
		$_POST['dst'] = $_POST['dsttype'];
217
		$_POST['dstmask'] = 0;
218
	}  else if ($_POST['dsttype'] == "single") {
219
		$_POST['dstmask'] = 32;
220
	}
221

    
222
	unset($input_errors);
223
	$pconfig = $_POST;
224

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

    
237
	/* input validation */
238
	$reqdfields = explode(" ", "type proto src dst");
239
	$reqdfieldsn = explode(",", "Type,Protocol,Source,Destination");
240

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

    
257
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
258

    
259
	if (!$_POST['srcbeginport']) {
260
		$_POST['srcbeginport'] = 0;
261
		$_POST['srcendport'] = 0;
262
	}
263
	if (!$_POST['dstbeginport']) {
264
		$_POST['dstbeginport'] = 0;
265
		$_POST['dstendport'] = 0;
266
	}
267

    
268
	if (($_POST['srcbeginport'] && !alias_expand($_POST['srcbeginport']) && !is_port($_POST['srcbeginport']))) {
269
		$input_errors[] = "The start source port must be an alias or integer between 1 and 65535.";
270
	}
271
	if (($_POST['srcendport'] && !alias_expand($_POST['srcendport']) && !is_port($_POST['srcendport']))) {
272
		$input_errors[] = "The end source port must be an alias or integer between 1 and 65535.";
273
	}
274
	if (($_POST['dstbeginport'] && !alias_expand($_POST['dstbeginport']) && !is_port($_POST['dstbeginport']))) {
275
		$input_errors[] = "The start destination port must be an alias or integer between 1 and 65535.";
276
	}
277
	if (($_POST['dstendport'] && !alias_expand($_POST['dstbeginport']) && !is_port($_POST['dstendport']))) {
278
		$input_errors[] = "The end destination port must be an alias or integer between 1 and 65535.";
279
	}
280

    
281
	/* if user enters an alias and selects "network" then disallow. */
282
	if($_POST['srctype'] == "network") {
283
		if(is_alias($_POST['src']))
284
			$input_errors[] = "You must specify single host or alias for alias entries.";
285
	}
286
	if($_POST['dsttype'] == "network") {
287
		if(is_alias($_POST['dst']))
288
			$input_errors[] = "You must specify single host or alias for alias entries.";
289
	}
290

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

    
308
	if ($_POST['srcbeginport'] > $_POST['srcendport']) {
309
		/* swap */
310
		$tmp = $_POST['srcendport'];
311
		$_POST['srcendport'] = $_POST['srcbeginport'];
312
		$_POST['srcbeginport'] = $tmp;
313
	}
314
	if ($_POST['dstbeginport'] > $_POST['dstendport']) {
315
		/* swap */
316
		$tmp = $_POST['dstendport'];
317
		$_POST['dstendport'] = $_POST['dstbeginport'];
318
		$_POST['dstbeginport'] = $tmp;
319
	}
320
	if ($_POST['os'])
321
		if( $_POST['proto'] != "tcp" )
322
			$input_errors[] = "OS detection is only valid with protocol tcp.";
323

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

    
347
	if (!$input_errors) {
348
		$filterent = array();
349
		$filterent['type'] = $_POST['type'];
350
		if (isset($_POST['interface'] ))
351
			$filterent['interface'] = $_POST['interface'];
352

    
353
		if ($if == "FloatingRules" || isset($_POST['floating'])) {
354
			if (isset($_POST['tag']))
355
				$filterent['tag'] = $_POST['tag'];
356
			if (isset($_POST['tagged']))
357
            			$filterent['tagged'] = $_POST['tagged'];
358
			$filterent['direction'] = $_POST['direction'];
359
			if (isset($_POST['quick']) && $_POST['quick'] <> "")
360
				$filterent['quick'] = $_POST['quick'];
361
			$filterent['floating'] = "yes";
362
			if (isset($_POST['interface']) && count($_POST['interface']) > 0)  {
363
					$filterent['interface'] = implode(",", $_POST['interface']);
364
			}
365
		}
366

    
367
		/* Advanced options */
368
		if ($_POST['allowopts'] == "yes")
369
			$filterent['allowopts'] = true;
370
		else
371
			unset($filterent['allowopts']);
372
		$filterent['max-src-nodes'] = $_POST['max-src-nodes'];
373
		$filterent['max-src-states'] = $_POST['max-src-states'];
374
		$filterent['statetimeout'] = $_POST['statetimeout'];
375
		$filterent['statetype'] = $_POST['statetype'];
376
		$filterent['os'] = $_POST['os'];
377

    
378
		/* Nosync directive - do not xmlrpc sync this item */
379
		if($_POST['nosync'] <> "")
380
			$filterent['nosync'] = true;
381
		else
382
			unset($filterent['nosync']);
383

    
384
		/* unless both values are provided, unset the values - ticket #650 */
385
		if($_POST['max-src-conn-rate'] <> "" and $_POST['max-src-conn-rates'] <> "") {
386
			$filterent['max-src-conn-rate'] = $_POST['max-src-conn-rate'];
387
			$filterent['max-src-conn-rates'] = $_POST['max-src-conn-rates'];
388
		} else {
389
			unset($filterent['max-src-conn-rate']);
390
			unset($filterent['max-src-conn-rates']);
391
		}
392

    
393
		if ($_POST['proto'] != "any")
394
			$filterent['protocol'] = $_POST['proto'];
395
		else
396
			unset($filterent['protocol']);
397

    
398
		if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
399
			$filterent['icmptype'] = $_POST['icmptype'];
400
		else
401
			unset($filterent['icmptype']);
402

    
403
		pconfig_to_address($filterent['source'], $_POST['src'],
404
			$_POST['srcmask'], $_POST['srcnot'],
405
			$_POST['srcbeginport'], $_POST['srcendport']);
406

    
407
		pconfig_to_address($filterent['destination'], $_POST['dst'],
408
			$_POST['dstmask'], $_POST['dstnot'],
409
			$_POST['dstbeginport'], $_POST['dstendport']);
410

    
411
                if ($_POST['disabled'])
412
                        $filterent['disabled'] = true;
413
                else
414
                        unset($filterent['disabled']);
415
		
416
		if ($_POST['dscp'])
417
			$filterent['dscp'] = $_POST['dscp'];
418

    
419
                if ($_POST['log'])
420
                        $filterent['log'] = true;
421
                else
422
                        unset($filterent['log']);
423
		strncpy($filterent['descr'], $_POST['descr'], 52);
424

    
425
		if ($_POST['gateway'] != "") {
426
			$filterent['gateway'] = $_POST['gateway'];
427
		}
428
		
429
		if (isset($_POST['defaultqueue']) && $_POST['defaultqueue'] != "none") {
430
			$filterent['defaultqueue'] = $_POST['defaultqueue'];
431
			if (isset($_POST['ackqueue']) && $_POST['ackqueue'] != "none")
432
				$filterent['ackqueue'] = $_POST['ackqueue'];
433
		}
434

    
435
		if (isset($_POST['dnpipe']) && $_POST['dnpipe'] != "none") {
436
			$filterent['dnpipe'] = $_POST['dnpipe'];
437
			if (isset($_POST['pdnpipe']) && $_POST['pdnpipe'] != "none")
438
				$filterent['pdnpipe'] = $_POST['pdnpipe'];
439
		}
440

    
441
		if (isset($_POST['l7container']) && $_POST['l7container'] != "none") {
442
			$filterent['l7container'] = $_POST['l7container'];
443
		}
444
		
445
		if ($_POST['sched'] != "") {
446
			$filterent['sched'] = $_POST['sched'];
447
		}
448

    
449
		if (isset($id) && $a_filter[$id])
450
			$a_filter[$id] = $filterent;
451
		else {
452
			if (is_numeric($after))
453
				array_splice($a_filter, $after+1, 0, array($filterent));
454
			else
455
				$a_filter[] = $filterent;
456
		}
457

    
458
		write_config();
459
		mark_subsystem_dirty('filter');
460

    
461
		if (isset($_POST['floating']))
462
			header("Location: firewall_rules.php?if=FloatingRules");
463
		else
464
			header("Location: firewall_rules.php?if=" . $_POST['interface']);
465
		exit;
466
	}
467
}
468

    
469
read_altq_config(); /* XXX: */
470
$qlist =& get_unique_queue_list();
471
read_dummynet_config(); /* XXX: */
472
$dnqlist =& get_unique_dnqueue_list();
473
read_layer7_config();
474
$l7clist =& get_l7_unique_list();
475

    
476
$pgtitle = array("Firewall","Rules","Edit");
477
$closehead = false;
478

    
479
$page_filename = "firewall_rules_edit.php";
480
include("head.inc");
481

    
482
?>
483

    
484
</head>
485

    
486
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
487
<?php include("fbegin.inc"); ?>
488
<?php if ($input_errors) print_input_errors($input_errors); ?>
489

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

    
545
				$ifdescs = get_configured_interface_with_descr();
546

    
547
				foreach ($ifdescs as $ifent => $ifdesc)
548
        				if(have_ruleint_access($ifent))
549
                				$interfaces[$ifent] = $ifdesc;
550

    
551
					if ($config['l2tp']['mode'] == "server")
552
                                                if(have_ruleint_access("l2tp"))
553
                                                        $interfaces['l2tp'] = "L2TP VPN";
554

    
555
					if ($config['pptpd']['mode'] == "server")
556
						if(have_ruleint_access("pptp")) 
557
							$interfaces['pptp'] = "PPTP VPN";
558
					
559
					if ($config['pppoe']['mode'] == "server")
560
						if(have_ruleint_access("pppoe")) 
561
							$interfaces['pppoe'] = "PPPoE VPN";
562
					
563
					/* add ipsec interfaces */
564
					if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
565
						if(have_ruleint_access("enc0")) 
566
							$interfaces["enc0"] = "IPsec";
567
		
568
					/* add openvpn/tun interfaces */
569
					if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
570
       					$interfaces["openvpn"] = "OpenVPN";
571

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

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

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

    
795
<?php 							foreach ($ifdisp as $if => $ifdesc): ?>
796
								<?php if(have_ruleint_access($if)): ?>
797
									<option value="<?=$if;?>" <?php if ($pconfig['dst'] == $if) { echo "selected"; } ?>><?=htmlspecialchars($ifdesc);?> subnet</option>
798
									<option value="<?=$if;?>ip"<?php if ($pconfig['dst'] == $if . "ip") { echo "selected"; } ?>>
799
										<?=$ifdesc;?> address
800
									</option>
801
								<?php endif; ?>
802
<?php 							endforeach; ?>
803
							</select>
804
						</td>
805
					</tr>
806
					<tr>
807
						<td>Address:&nbsp;&nbsp;</td>
808
						<td>
809
							<input name="dst" type="text" class="formfldalias" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>">
810
							/
811
							<select name="dstmask" class="formselect" id="dstmask">
812
<?php
813
							for ($i = 31; $i > 0; $i--): ?>
814
								<option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected"; ?>><?=$i;?></option>
815
<?php						endfor; ?>
816
							</select>
817
						</td>
818
					</tr>
819
				</table>
820

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

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

    
909
				<input name="statetimeout" value="<?php echo $pconfig['statetimeout'] ?>"><br>
910
				State Timeout in seconds
911
				<p />
912

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

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

    
1179
<?php
1180
	$isfirst = 0;
1181
	$aliases = "";
1182
	$addrisfirst = 0;
1183
	$aliasesaddr = "";
1184
	if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
1185
		foreach($config['aliases']['alias'] as $alias_name) {
1186
			if(!stristr($alias_name['address'], ".")) {
1187
				if($isfirst == 1) $aliases .= ",";
1188
				$aliases .= "'" . $alias_name['name'] . "'";
1189
				$isfirst = 1;
1190
			} else {
1191
				if($addrisfirst == 1) $aliasesaddr .= ",";
1192
				$aliasesaddr .= "'" . $alias_name['name'] . "'";
1193
				$addrisfirst = 1;
1194
			}
1195
		}
1196
?>
1197

    
1198
	var addressarray=new Array(<?php echo $aliasesaddr; ?>);
1199
	var customarray=new Array(<?php echo $aliases; ?>);
1200

    
1201
//-->
1202
</script>
1203

    
1204

    
1205
<?php include("fend.inc"); ?>
1206
</body>
1207
</html>
1208

    
(57-57/217)