1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
|
#!/usr/local/bin/php
<?php
/* $Id$ */
/*
firewall_shaper_edit.php
part of m0n0wall (http://m0n0.ch/wall)
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require("guiconfig.inc");
if (!is_array($config['shaper']['rule'])) {
$config['shaper']['rule'] = array();
}
$a_shaper = &$config['shaper']['rule'];
$specialsrcdst = explode(" ", "any lan pptp");
$id = $_GET['id'];
if (isset($_POST['id']))
$id = $_POST['id'];
$after = $_GET['after'];
if (isset($_POST['after']))
$after = $_POST['after'];
if (isset($_GET['dup'])) {
$id = $_GET['dup'];
$after = $_GET['dup'];
}
if (isset($id) && $a_shaper[$id]) {
$pconfig['interface'] = $a_shaper[$id]['interface'];
if (isset($a_shaper[$id]['protocol']))
$pconfig['proto'] = $a_shaper[$id]['protocol'];
else
$pconfig['proto'] = "any";
address_to_pconfig($a_shaper[$id]['source'], $pconfig['src'],
$pconfig['srcmask'], $pconfig['srcnot'],
$pconfig['srcbeginport'], $pconfig['srcendport']);
address_to_pconfig($a_shaper[$id]['destination'], $pconfig['dst'],
$pconfig['dstmask'], $pconfig['dstnot'],
$pconfig['dstbeginport'], $pconfig['dstendport']);
$pconfig['inqueue'] = $a_shaper[$id]['inqueue'];
$pconfig['outqueue'] = $a_shaper[$id]['outqueue'];
$pconfig['direction'] = $a_shaper[$id]['direction'];
$pconfig['iptos'] = $a_shaper[$id]['iptos'];
$pconfig['iplen'] = $a_shaper[$id]['iplen'];
$pconfig['tcpflags'] = $a_shaper[$id]['tcpflags'];
$pconfig['descr'] = $a_shaper[$id]['descr'];
$pconfig['disabled'] = isset($a_shaper[$id]['disabled']);
if ($pconfig['srcbeginport'] == 0) {
$pconfig['srcbeginport'] = "any";
$pconfig['srcendport'] = "any";
}
if ($pconfig['dstbeginport'] == 0) {
$pconfig['dstbeginport'] = "any";
$pconfig['dstendport'] = "any";
}
} else {
/* defaults */
$pconfig['src'] = "any";
$pconfig['dst'] = "any";
}
if (isset($_GET['dup']))
unset($id);
if ($_POST) {
if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "any")) {
$_POST['srcbeginport'] = 0;
$_POST['srcendport'] = 0;
$_POST['dstbeginport'] = 0;
$_POST['dstendport'] = 0;
} else {
if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
$_POST['srcbeginport'] = $_POST['srcbeginport_cust'];
if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
$_POST['srcendport'] = $_POST['srcendport_cust'];
if ($_POST['srcbeginport'] == "any") {
$_POST['srcbeginport'] = 0;
$_POST['srcendport'] = 0;
} else {
if (!$_POST['srcendport'])
$_POST['srcendport'] = $_POST['srcbeginport'];
}
if ($_POST['srcendport'] == "any")
$_POST['srcendport'] = $_POST['srcbeginport'];
if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
$_POST['dstbeginport'] = $_POST['dstbeginport_cust'];
if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
$_POST['dstendport'] = $_POST['dstendport_cust'];
if ($_POST['dstbeginport'] == "any") {
$_POST['dstbeginport'] = 0;
$_POST['dstendport'] = 0;
} else {
if (!$_POST['dstendport'])
$_POST['dstendport'] = $_POST['dstbeginport'];
}
if ($_POST['dstendport'] == "any")
$_POST['dstendport'] = $_POST['dstbeginport'];
}
if (is_specialnet($_POST['srctype'])) {
$_POST['src'] = $_POST['srctype'];
$_POST['srcmask'] = 0;
} else if ($_POST['srctype'] == "single") {
$_POST['srcmask'] = 32;
}
if (is_specialnet($_POST['dsttype'])) {
$_POST['dst'] = $_POST['dsttype'];
$_POST['dstmask'] = 0;
} else if ($_POST['dsttype'] == "single") {
$_POST['dstmask'] = 32;
}
$intos = array();
foreach ($iptos as $tos) {
if ($_POST['iptos_' . $tos] == "on")
$intos[] = $tos;
else if ($_POST['iptos_' . $tos] == "off")
$intos[] = "!" . $tos;
}
$_POST['iptos'] = join(",", $intos);
$intcpflags = array();
foreach ($tcpflags as $tcpflag) {
if ($_POST['tcpflags_' . $tcpflag] == "on")
$intcpflags[] = $tcpflag;
else if ($_POST['tcpflags_' . $tcpflag] == "off")
$intcpflags[] = "!" . $tcpflag;
}
$_POST['tcpflags'] = join(",", $intcpflags);
unset($input_errors);
$pconfig = $_POST;
/* input validation */
$reqdfields = explode(" ", "inqueue outqueue proto src dst");
$reqdfieldsn = explode(",", "Inbound Queue,Outbound Queue,Protocol,Source,Destination");
if (!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single"))) {
$reqdfields[] = "srcmask";
$reqdfieldsn[] = "Source bit count";
}
if (!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single"))) {
$reqdfields[] = "dstmask";
$reqdfieldsn[] = "Destination bit count";
}
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
if (!$_POST['srcbeginport']) {
$_POST['srcbeginport'] = 0;
$_POST['srcendport'] = 0;
}
if (!$_POST['dstbeginport']) {
$_POST['dstbeginport'] = 0;
$_POST['dstendport'] = 0;
}
if (($_POST['srcbeginport'] && !alias_expand($_POST['srcbeginport']) && !is_port($_POST['srcbeginport']))) {
$input_errors[] = "The start source port must be an alias or integer between 1 and 65535.";
}
if (($_POST['srcendport'] && !alias_expand($_POST['srcendport']) && !is_port($_POST['srcendport']))) {
$input_errors[] = "The end source port must be an alias or integer between 1 and 65535.";
}
if (($_POST['dstbeginport'] && !alias_expand($_POST['dstbeginport']) && !is_port($_POST['dstbeginport']))) {
$input_errors[] = "The start destination port must be an alias or integer between 1 and 65535.";
}
if (($_POST['dstendport'] && !alias_expand($_POST['dstbeginport']) && !is_port($_POST['dstendport']))) {
$input_errors[] = "The end destination port must be an alias or integer between 1 and 65535.";
}
if (!is_specialnet($_POST['srctype'])) {
if (($_POST['src'] && !is_ipaddroranyalias($_POST['src']))) {
$input_errors[] = "A valid source IP address or alias must be specified.";
}
if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) {
$input_errors[] = "A valid source bit count must be specified.";
}
}
if (!is_specialnet($_POST['dsttype'])) {
if (($_POST['dst'] && !is_ipaddroranyalias($_POST['dst']))) {
$input_errors[] = "A valid destination IP address or alias must be specified.";
}
if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) {
$input_errors[] = "A valid destination bit count must be specified.";
}
}
if ($_POST['srcbeginport'] > $_POST['srcendport']) {
/* swap */
$tmp = $_POST['srcendport'];
$_POST['srcendport'] = $_POST['srcbeginport'];
$_POST['srcbeginport'] = $tmp;
}
if ($_POST['dstbeginport'] > $_POST['dstendport']) {
/* swap */
$tmp = $_POST['dstendport'];
$_POST['dstendport'] = $_POST['dstbeginport'];
$_POST['dstbeginport'] = $tmp;
}
if (($_POST['iplen'] && !preg_match("/^(\d+)(-(\d+))?$/", $_POST['iplen']))) {
$input_errors[] = "The IP packet length must be an integer or a range (from-to).";
}
if (!$input_errors) {
$shaperent = array();
$shaperent['interface'] = $_POST['interface'];
if ($_POST['proto'] != "any")
$shaperent['protocol'] = $_POST['proto'];
else
unset($shaperent['protocol']);
pconfig_to_address($shaperent['source'], $_POST['src'],
$_POST['srcmask'], $_POST['srcnot'],
$_POST['srcbeginport'], $_POST['srcendport']);
pconfig_to_address($shaperent['destination'], $_POST['dst'],
$_POST['dstmask'], $_POST['dstnot'],
$_POST['dstbeginport'], $_POST['dstendport']);
$shaperent['direction'] = $_POST['direction'];
$shaperent['iplen'] = $_POST['iplen'];
$shaperent['iptos'] = $_POST['iptos'];
$shaperent['tcpflags'] = $_POST['tcpflags'];
$shaperent['descr'] = $_POST['descr'];
$shaperent['disabled'] = $_POST['disabled'] ? true : false;
$shaperent['inqueue'] = $_POST['inqueue'];
$shaperent['outqueue'] = $_POST['outqueue'];
if (isset($id) && $a_shaper[$id])
$a_shaper[$id] = $shaperent;
else {
if (is_numeric($after))
array_splice($a_shaper, $after+1, 0, array($shaperent));
else
$a_shaper[] = $shaperent;
}
write_config();
touch($d_shaperconfdirty_path);
header("Location: firewall_shaper.php");
exit;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?=gentitle("Firewall: Traffic shaper: Edit rule");?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="gui.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
<!--
var portsenabled = 1;
function ext_change() {
if ((document.iform.srcbeginport.selectedIndex == 0) && portsenabled) {
document.iform.srcbeginport_cust.disabled = 0;
} else {
document.iform.srcbeginport_cust.value = "";
document.iform.srcbeginport_cust.disabled = 1;
}
if ((document.iform.srcendport.selectedIndex == 0) && portsenabled) {
document.iform.srcendport_cust.disabled = 0;
} else {
document.iform.srcendport_cust.value = "";
document.iform.srcendport_cust.disabled = 1;
}
if ((document.iform.dstbeginport.selectedIndex == 0) && portsenabled) {
document.iform.dstbeginport_cust.disabled = 0;
} else {
document.iform.dstbeginport_cust.value = "";
document.iform.dstbeginport_cust.disabled = 1;
}
if ((document.iform.dstendport.selectedIndex == 0) && portsenabled) {
document.iform.dstendport_cust.disabled = 0;
} else {
document.iform.dstendport_cust.value = "";
document.iform.dstendport_cust.disabled = 1;
}
if (!portsenabled) {
document.iform.srcbeginport.disabled = 1;
document.iform.srcendport.disabled = 1;
document.iform.dstbeginport.disabled = 1;
document.iform.dstendport.disabled = 1;
} else {
document.iform.srcbeginport.disabled = 0;
document.iform.srcendport.disabled = 0;
document.iform.dstbeginport.disabled = 0;
document.iform.dstendport.disabled = 0;
}
}
function typesel_change() {
switch (document.iform.srctype.selectedIndex) {
case 1: /* single */
document.iform.src.disabled = 0;
document.iform.srcmask.value = "";
document.iform.srcmask.disabled = 1;
break;
case 2: /* network */
document.iform.src.disabled = 0;
document.iform.srcmask.disabled = 0;
break;
default:
document.iform.src.value = "";
document.iform.src.disabled = 1;
document.iform.srcmask.value = "";
document.iform.srcmask.disabled = 1;
break;
}
switch (document.iform.dsttype.selectedIndex) {
case 1: /* single */
document.iform.dst.disabled = 0;
document.iform.dstmask.value = "";
document.iform.dstmask.disabled = 1;
break;
case 2: /* network */
document.iform.dst.disabled = 0;
document.iform.dstmask.disabled = 0;
break;
default:
document.iform.dst.value = "";
document.iform.dst.disabled = 1;
document.iform.dstmask.value = "";
document.iform.dstmask.disabled = 1;
break;
}
}
function proto_change() {
if (document.iform.proto.selectedIndex < 2 || document.iform.proto.selectedIndex == 8) {
portsenabled = 1;
} else {
portsenabled = 0;
}
ext_change();
}
function src_rep_change() {
document.iform.srcendport.selectedIndex = document.iform.srcbeginport.selectedIndex;
}
function dst_rep_change() {
document.iform.dstendport.selectedIndex = document.iform.dstbeginport.selectedIndex;
}
//-->
</script>
</head>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
<p class="pgtitle">Firewall: Traffic shaper: Edit rule</p>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if (is_array($config['shaper']['queue']) && (count($config['shaper']['queue']) > 0)): ?>
<form action="firewall_shaper_edit.php" method="post" name="iform" id="iform">
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td valign="top" class="vncellreq">Target</td>
<td class="vtable"> <select name="inqueue" class="formfld">
<?php
foreach ($config['shaper']['queue'] as $queuei => $queue): ?>
<option value="<?=$queue['name'];?>" <?php if ($queue['name'] == $pconfig['inqueue']) echo "selected"; ?>>
<?php
echo htmlspecialchars("Queue " . ($queuei + 1));
if ($queue['name'])
echo htmlspecialchars(" (" . $queue['name'] . ")");
?>
</option>
<?php endforeach; ?>
</select>/<select name="outqueue" class="formfld">
<?php
foreach ($config['shaper']['queue'] as $queuei => $queue): ?>
<option value="<?=$queue['name'];?>" <?php if ($queue['name'] == $pconfig['outqueue']) echo "selected"; ?>>
<?php
echo htmlspecialchars("Queue " . ($queuei + 1));
if ($queue['name'])
echo htmlspecialchars(" (" . $queue['name'] . ")");
?>
</option>
<?php endforeach; ?> <br>
<span class="vexpl">Choose a queue where packets that
match this rule should be sent.</span></td>
</tr>
<tr>
<td valign="top" class="vncellreq">Disabled</td>
<td class="vtable">
<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
<strong>Disable this rule</strong><br>
<span class="vexpl">Set this option to disable this rule without removing it from the list.</span></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq">Interface</td>
<td width="78%" class="vtable"> <select name="interface" class="formfld">
<?php $interfaces = array('lan' => 'LAN', 'wan' => 'WAN', 'pptp' => 'PPTP');
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
$interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
}
foreach ($interfaces as $iface => $ifacename): ?>
<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
<?=htmlspecialchars($ifacename);?>
</option>
<?php endforeach; ?>
</select> <br>
<span class="vexpl">Choose which interface packets must pass
through to match this rule.</span></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq">Protocol</td>
<td width="78%" class="vtable"> <select name="proto" class="formfld" onchange="proto_change()">
<?php $protocols = explode(" ", "TCP UDP ICMP ESP AH GRE IPv6 IGMP any"); foreach ($protocols as $proto): ?>
<option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected"; ?>>
<?=htmlspecialchars($proto);?>
</option>
<?php endforeach; ?>
</select> <br> <span class="vexpl">Choose which IP protocol
this rule should match.<br>
Hint: in most cases, you should specify <em>TCP</em> here.</span></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq">Source</td>
<td width="78%" class="vtable"> <input name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked"; ?>>
<strong>not</strong><br>
Use this option to invert the sense of the match.<br> <br>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Type: </td>
<td><select name="srctype" class="formfld" onChange="typesel_change()">
<?php $sel = is_specialnet($pconfig['src']); ?>
<option value="any" <?php if ($pconfig['src'] == "any") { echo "selected"; } ?>>
any</option>
<option value="single" <?php if (($pconfig['srcmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>
Single host or alias</option>
<option value="network" <?php if (!$sel) echo "selected"; ?>>
Network</option>
<option value="lan" <?php if ($pconfig['src'] == "lan") { echo "selected"; } ?>>
LAN subnet</option>
<option value="pptp" <?php if ($pconfig['src'] == "pptp") { echo "selected"; } ?>>
PPTP clients</option>
<?php for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++): ?>
<option value="opt<?=$i;?>" <?php if ($pconfig['src'] == "opt" . $i) { echo "selected"; } ?>>
<?=htmlspecialchars($config['interfaces']['opt' . $i]['descr']);?>
subnet</option>
<?php endfor; ?>
</select></td>
</tr>
<tr>
<td>Address: </td>
<td><input autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);' onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,addressarray)' name="src" type="text" class="formfldalias" id="src" size="20" value="<?php if (!is_specialnet($pconfig['src'])) echo htmlspecialchars($pconfig['src']);?>">
/
<select name="srcmask" class="formfld" id="srcmask">
<?php for ($i = 31; $i > 0; $i--): ?>
<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected"; ?>>
<?=$i;?>
</option>
<?php endfor; ?>
</select></td>
</tr>
</table></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq">Source port range
</td>
<td width="78%" class="vtable"> <table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>from: </td>
<td><select name="srcbeginport" class="formfld" onchange="src_rep_change();ext_change()">
<option value="">(other)</option>
<option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
<?php foreach ($wkports as $wkport => $wkportdesc): ?>
<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) {
echo "selected";
$bfound = 1;
}?>>
<?=htmlspecialchars($wkportdesc);?>
</option>
<?php endforeach; ?>
</select> <input autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);' onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="srcbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcbeginport']) echo $pconfig['srcbeginport']; ?>"></td>
</tr>
<tr>
<td>to:</td>
<td><select name="srcendport" class="formfld" onchange="ext_change()">
<option value="">(other)</option>
<option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
<?php foreach ($wkports as $wkport => $wkportdesc): ?>
<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) {
echo "selected";
$bfound = 1;
}?>>
<?=htmlspecialchars($wkportdesc);?>
</option>
<?php endforeach; ?>
</select> <input autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);' onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo $pconfig['srcendport']; ?>"></td>
</tr>
</table>
<br> <span class="vexpl">Specify the port or port range for
the source of the packet for this rule.<br>
Hint: you can leave the <em>'to'</em> field empty if you only
want to filter a single port</span></td>
<tr>
<td width="22%" valign="top" class="vncellreq">Destination</td>
<td width="78%" class="vtable"> <input name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked"; ?>>
<strong>not</strong><br>
Use this option to invert the sense of the match.<br> <br>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Type: </td>
<td><select name="dsttype" class="formfld" onChange="typesel_change()">
<?php $sel = is_specialnet($pconfig['dst']); ?>
<option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected"; } ?>>
any</option>
<option value="single" <?php if (($pconfig['dstmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>
Single host or alias</option>
<option value="network" <?php if (!$sel) echo "selected"; ?>>
Network</option>
<option value="lan" <?php if ($pconfig['dst'] == "lan") { echo "selected"; } ?>>
LAN subnet</option>
<option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected"; } ?>>
PPTP clients</option>
<?php for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++): ?>
<option value="opt<?=$i;?>" <?php if ($pconfig['dst'] == "opt" . $i) { echo "selected"; } ?>>
<?=htmlspecialchars($config['interfaces']['opt' . $i]['descr']);?>
subnet</option>
<?php endfor; ?>
</select> </td>
</tr>
<tr>
<td>Address: </td>
<td><input name="dst" autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);' onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,addressarray)' type="text" class="formfldalias" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>">
/
<select name="dstmask" class="formfld" id="dstmask">
<?php for ($i = 31; $i > 0; $i--): ?>
<option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected"; ?>>
<?=$i;?>
</option>
<?php endfor; ?>
</select></td>
</tr>
</table></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq">Destination port
range </td>
<td width="78%" class="vtable"> <table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>from: </td>
<td><select name="dstbeginport" class="formfld" onchange="dst_rep_change();ext_change()">
<option value="">(other)</option>
<option value="any" <?php $bfound = 0; if ($pconfig['dstbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
<?php foreach ($wkports as $wkport => $wkportdesc): ?>
<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstbeginport']) {
echo "selected";
$bfound = 1;
}?>>
<?=htmlspecialchars($wkportdesc);?>
</option>
<?php endforeach; ?>
</select> <input autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);' onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="dstbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstbeginport']) echo $pconfig['dstbeginport']; ?>"></td>
</tr>
<tr>
<td>to:</td>
<td><select name="dstendport" class="formfld" onchange="ext_change()">
<option value="">(other)</option>
<option value="any" <?php $bfound = 0; if ($pconfig['dstendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
<?php foreach ($wkports as $wkport => $wkportdesc): ?>
<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstendport']) {
echo "selected";
$bfound = 1;
}?>>
<?=htmlspecialchars($wkportdesc);?>
</option>
<?php endforeach; ?>
</select> <input autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);' onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="dstendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstendport']) echo $pconfig['dstendport']; ?>"></td>
</tr>
</table>
<br> <span class="vexpl">Specify the port or port range for
the destination of the packet for this rule.<br>
Hint: you can leave the <em>'to'</em> field empty if you only
want to filter a single port</span></td>
<tr>
<td valign="top" class="vncell">Direction</td>
<td class="vtable"> <select name="direction" class="formfld">
<option value="" <?php if (!$pconfig['direction']) echo "selected"; ?>>any</option>
<option value="in" <?php if ($pconfig['direction'] == "in") echo "selected"; ?>>in</option>
<option value="out" <?php if ($pconfig['direction'] == "out") echo "selected"; ?>>out</option>
</select> <br>
Use this to match only packets travelling in a given direction
on the interface specified above (as seen from the firewall's
perspective). </td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell">IP Type of Service (TOS)</td>
<td width="78%" class="vtable"> <table border="0" cellspacing="0" cellpadding="0">
<?php
$iniptos = explode(",", $pconfig['iptos']);
foreach ($iptos as $tos): $dontcare = true; ?>
<tr>
<td width="80" nowrap><strong>
<?echo $tos;?>
</strong></td>
<td nowrap> <input type="radio" name="iptos_<?=$tos;?>" value="on" <?php if (array_search($tos, $iniptos) !== false) { echo "checked"; $dontcare = false; }?>>
yes </td>
<td nowrap> <input type="radio" name="iptos_<?=$tos;?>" value="off" <?php if (array_search("!" . $tos, $iniptos) !== false) { echo "checked"; $dontcare = false; }?>>
no </td>
<td nowrap> <input type="radio" name="iptos_<?=$tos;?>" value="" <?php if ($dontcare) echo "checked";?>>
don't care</td>
</tr>
<?php endforeach; ?>
</table>
<span class="vexpl">Use this to match packets according to their IP TOS values.
</span></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell">IP packet length</td>
<td width="78%" class="vtable"><input name="iplen" type="text" id="iplen" size="10" value="<?=htmlspecialchars($pconfig['iplen']);?>">
<br>
Setting this makes the rule match packets of a given length
(either a single value or a range in the syntax <em>from-to</em>,
e.g. 0-80). </td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell">TCP flags</td>
<td width="78%" class="vtable"> <table border="0" cellspacing="0" cellpadding="0">
<?php
$inflags = explode(",", $pconfig['tcpflags']);
foreach ($tcpflags as $tcpflag): $dontcare = true; ?>
<tr>
<td width="40" nowrap><strong>
<?=strtoupper($tcpflag);?>
</strong></td>
<td nowrap> <input type="radio" name="tcpflags_<?=$tcpflag;?>" value="on" <?php if (array_search($tcpflag, $inflags) !== false) { echo "checked"; $dontcare = false; }?>>
set </td>
<td nowrap> <input type="radio" name="tcpflags_<?=$tcpflag;?>" value="off" <?php if (array_search("!" . $tcpflag, $inflags) !== false) { echo "checked"; $dontcare = false; }?>>
cleared </td>
<td nowrap> <input type="radio" name="tcpflags_<?=$tcpflag;?>" value="" <?php if ($dontcare) echo "checked";?>>
don't care</td>
</tr>
<?php endforeach; ?>
</table>
<span class="vexpl">Use this to choose TCP flags that must
be set or cleared for this rule to match.</span></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell">Description</td>
<td width="78%" class="vtable"> <input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
<br> <span class="vexpl">You may enter a description here
for your reference (not parsed).</span></td>
</tr>
<tr>
<td width="22%" valign="top"> </td>
<td width="78%"> <input name="Submit" type="submit" class="formbtn" value="Save"> <input type="button" class="formbtn" value="Cancel" onclick="history.back()">
<?php if (isset($id) && $a_shaper[$id]): ?>
<input name="id" type="hidden" value="<?=$id;?>">
<?php endif; ?>
<input name="after" type="hidden" value="<?=$after;?>">
</td>
</tr>
</table>
</form>
<script language="JavaScript">
<!--
ext_change();
typesel_change();
proto_change();
-->
</script>
<?php else: ?>
<p><strong>You need to create a queue before you can add a new rule.</strong></p>
<?php endif; ?>
<?php
$isfirst = 0;
$aliases = "";
$addrisfirst = 0;
$aliasesaddr = "";
if(is_array($config['aliases']['alias'])) {
foreach($config['aliases']['alias'] as $alias_name) {
if(!stristr($alias_name['address'], ".")) {
if($isfirst == 1) $aliases .= ",";
$aliases .= "'" . $alias_name['name'] . "'";
$isfirst = 1;
} else {
if($addrisfirst == 1) $aliasesaddr .= ",";
$aliasesaddr .= "'" . $alias_name['name'] . "'";
$addrisfirst = 1;
}
}
}
?>
<script language="JavaScript">
<!--
var addressarray=new Array(<?php echo $aliasesaddr; ?>);
var customarray=new Array(<?php echo $aliases; ?>);
//-->
</script>
<script type="text/javascript" language="javascript" src="auto_complete_helper.js">
</script>
<?php include("fend.inc"); ?>
</body>
</html>
|