1 |
5b237745
|
Scott Ullrich
|
#!/usr/local/bin/php
|
2 |
|
|
<?php
|
3 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
4 |
5b237745
|
Scott Ullrich
|
/*
|
5 |
|
|
firewall_shaper_queues.php
|
6 |
b49448ac
|
Scott Ullrich
|
Copyright (C) 2004, 2005 Scott Ullrich
|
7 |
|
|
All rights reserved.
|
8 |
5b237745
|
Scott Ullrich
|
|
9 |
b49448ac
|
Scott Ullrich
|
Originally part of m0n0wall (http://m0n0.ch/wall)
|
10 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11 |
|
|
All rights reserved.
|
12 |
|
|
|
13 |
|
|
Redistribution and use in source and binary forms, with or without
|
14 |
|
|
modification, are permitted provided that the following conditions are met:
|
15 |
|
|
|
16 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
17 |
|
|
this list of conditions and the following disclaimer.
|
18 |
|
|
|
19 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
20 |
|
|
notice, this list of conditions and the following disclaimer in the
|
21 |
|
|
documentation and/or other materials provided with the distribution.
|
22 |
|
|
|
23 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
24 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
25 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
26 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
27 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
33 |
|
|
*/
|
34 |
|
|
|
35 |
|
|
require("guiconfig.inc");
|
36 |
|
|
|
37 |
4f335a1b
|
Scott Ullrich
|
if($_GET['reset'] <> "") {
|
38 |
|
|
mwexec("killall -9 pfctl php");
|
39 |
|
|
exit;
|
40 |
|
|
}
|
41 |
|
|
|
42 |
12bcdc89
|
Scott Ullrich
|
if (!is_array($config['shaper']['queue'])) {
|
43 |
|
|
$config['shaper']['queue'] = array();
|
44 |
5b237745
|
Scott Ullrich
|
}
|
45 |
12bcdc89
|
Scott Ullrich
|
$a_queues = &$config['shaper']['queue'];
|
46 |
5b237745
|
Scott Ullrich
|
|
47 |
845dc7ed
|
Scott Ullrich
|
$iflist = array("lan" => "LAN", "wan" => "WAN");
|
48 |
|
|
|
49 |
|
|
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
|
50 |
|
|
$iflist['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
|
51 |
|
|
}
|
52 |
|
|
|
53 |
e8731417
|
Scott Ullrich
|
if ($_POST['apply'] || $_POST['submit']) {
|
54 |
|
|
$config['shaper']['enable'] = true;
|
55 |
|
|
write_config();
|
56 |
|
|
|
57 |
|
|
$retval = 0;
|
58 |
|
|
$savemsg = get_std_save_message($retval);
|
59 |
|
|
/* Setup pf rules since the user may have changed the optimization value */
|
60 |
527be97b
|
Bill Marquette
|
config_lock();
|
61 |
e8731417
|
Scott Ullrich
|
$retval = filter_configure();
|
62 |
527be97b
|
Bill Marquette
|
config_unlock();
|
63 |
e8731417
|
Scott Ullrich
|
if(stristr($retval, "error") <> true)
|
64 |
|
|
$savemsg = get_std_save_message($retval);
|
65 |
|
|
else
|
66 |
|
|
$savemsg = $retval;
|
67 |
|
|
|
68 |
|
|
if(file_exists($d_shaperconfdirty_path))
|
69 |
|
|
unlink($d_shaperconfdirty_path);
|
70 |
|
|
}
|
71 |
|
|
|
72 |
5b237745
|
Scott Ullrich
|
if ($_GET['act'] == "del") {
|
73 |
|
|
if ($a_queues[$_GET['id']]) {
|
74 |
|
|
/* check that no rule references this queue */
|
75 |
12bcdc89
|
Scott Ullrich
|
if (is_array($config['shaper']['rule'])) {
|
76 |
|
|
foreach ($config['shaper']['rule'] as $rule) {
|
77 |
5b237745
|
Scott Ullrich
|
if (isset($rule['targetqueue']) && ($rule['targetqueue'] == $_GET['id'])) {
|
78 |
|
|
$input_errors[] = "This queue cannot be deleted because it is still referenced by a rule.";
|
79 |
|
|
break;
|
80 |
|
|
}
|
81 |
|
|
}
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
if (!$input_errors) {
|
85 |
|
|
unset($a_queues[$_GET['id']]);
|
86 |
|
|
|
87 |
|
|
/* renumber all rules */
|
88 |
12bcdc89
|
Scott Ullrich
|
if (is_array($config['shaper']['rule'])) {
|
89 |
|
|
for ($i = 0; isset($config['shaper']['rule'][$i]); $i++) {
|
90 |
|
|
$currule = &$config['shaper']['rule'][$i];
|
91 |
5b237745
|
Scott Ullrich
|
if (isset($currule['targetqueue']) && ($currule['targetqueue'] > $_GET['id']))
|
92 |
|
|
$currule['targetqueue']--;
|
93 |
|
|
}
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
write_config();
|
97 |
|
|
touch($d_shaperconfdirty_path);
|
98 |
|
|
header("Location: firewall_shaper_queues.php");
|
99 |
|
|
exit;
|
100 |
|
|
}
|
101 |
|
|
}
|
102 |
|
|
}
|
103 |
52380979
|
Scott Ullrich
|
|
104 |
|
|
$pgtitle = "Firewall: Shaper: Queues";
|
105 |
|
|
include("head.inc");
|
106 |
|
|
|
107 |
5b237745
|
Scott Ullrich
|
?>
|
108 |
|
|
|
109 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
110 |
|
|
<?php include("fbegin.inc"); ?>
|
111 |
da7ae7ef
|
Bill Marquette
|
<p class="pgtitle"><?=$pgtitle?></p>
|
112 |
54eaa3c1
|
Scott Ullrich
|
<form action="firewall_shaper_queues.php" method="post">
|
113 |
5b237745
|
Scott Ullrich
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
114 |
|
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
115 |
|
|
<?php if (file_exists($d_shaperconfdirty_path)): ?><p>
|
116 |
|
|
<?php print_info_box_np("The traffic shaper configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
|
117 |
|
|
<?php endif; ?>
|
118 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
119 |
|
|
<tr><td>
|
120 |
52380979
|
Scott Ullrich
|
<?php
|
121 |
|
|
$tab_array = array();
|
122 |
4958090d
|
Bill Marquette
|
$tab_array[0] = array("Rules", false, "firewall_shaper.php");
|
123 |
|
|
$tab_array[1] = array("Queues", true, "firewall_shaper_queues.php");
|
124 |
|
|
$tab_array[2] = array("EZ Shaper wizard", false, "wizard.php?xml=traffic_shaper_wizard.xml");
|
125 |
52380979
|
Scott Ullrich
|
display_top_tabs($tab_array);
|
126 |
|
|
?>
|
127 |
5b237745
|
Scott Ullrich
|
</td></tr>
|
128 |
|
|
<tr>
|
129 |
d732f186
|
Bill Marquette
|
<td>
|
130 |
|
|
<div id="mainarea">
|
131 |
|
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
132 |
5b237745
|
Scott Ullrich
|
<tr>
|
133 |
8217e5e0
|
Scott Ullrich
|
<td width="5%" class="listhdrr">No.</td>
|
134 |
|
|
<td width="5%" class="listhdrr">Flags</td>
|
135 |
|
|
<td width="5%" class="listhdrr">Priority</td>
|
136 |
|
|
<td width="5%" class="listhdr">Default</td>
|
137 |
dbab498d
|
Scott Ullrich
|
<td width="5%" class="listhdr">Bandwidth</td>
|
138 |
8217e5e0
|
Scott Ullrich
|
<td width="70%" class="listhdr">Name</td>
|
139 |
5b237745
|
Scott Ullrich
|
<td width="10%" class="list"></td>
|
140 |
|
|
</tr>
|
141 |
|
|
<?php $i = 0; foreach ($a_queues as $queue): ?>
|
142 |
|
|
<tr valign="top">
|
143 |
4c0eaa7f
|
Bill Marquette
|
<td class="listlr" ondblclick="document.location='firewall_shaper_queues_edit.php?id=<?=$i;?>';">
|
144 |
12bcdc89
|
Scott Ullrich
|
<?=($i+1);?>
|
145 |
|
|
</td>
|
146 |
4c0eaa7f
|
Bill Marquette
|
<td class="listlr" ondblclick="document.location='firewall_shaper_queues_edit.php?id=<?=$i;?>';">
|
147 |
b9000512
|
Scott Ullrich
|
<?php
|
148 |
|
|
if($queue['red'] <> "") echo " RED";
|
149 |
94743d1d
|
Bill Marquette
|
if($queue['rio'] <> "") echo " RIO";
|
150 |
b9000512
|
Scott Ullrich
|
if($queue['ecn'] <> "") echo " ECN";
|
151 |
|
|
if($queue['borrow'] <> "") echo " Borrow";
|
152 |
253ac606
|
Bill Marquette
|
if(isset($queue['ack'])) echo "ACK"
|
153 |
b9000512
|
Scott Ullrich
|
?>
|
154 |
|
|
|
155 |
|
|
</td>
|
156 |
4c0eaa7f
|
Bill Marquette
|
<td class="listr" ondblclick="document.location='firewall_shaper_queues_edit.php?id=<?=$i;?>';">
|
157 |
740dac81
|
Scott Ullrich
|
<?=$queue['priority'];?>
|
158 |
12bcdc89
|
Scott Ullrich
|
</td>
|
159 |
4c0eaa7f
|
Bill Marquette
|
<td class="listr" ondblclick="document.location='firewall_shaper_queues_edit.php?id=<?=$i;?>';">
|
160 |
12bcdc89
|
Scott Ullrich
|
<?php
|
161 |
7fc9b85f
|
Scott Ullrich
|
if($queue['defaultqueue'] <> "") {
|
162 |
12bcdc89
|
Scott Ullrich
|
echo "Yes";
|
163 |
|
|
} else {
|
164 |
|
|
echo "No";
|
165 |
|
|
}
|
166 |
|
|
?>
|
167 |
|
|
</td>
|
168 |
4c0eaa7f
|
Bill Marquette
|
<td class="listr" ondblclick="document.location='firewall_shaper_queues_edit.php?id=<?=$i;?>';">
|
169 |
dbab498d
|
Scott Ullrich
|
<?=htmlspecialchars($queue['bandwidth']);?> <?=htmlspecialchars($queue['bandwidthtype']);?>
|
170 |
|
|
|
171 |
|
|
</td>
|
172 |
4c0eaa7f
|
Bill Marquette
|
<td class="listbg" ondblclick="document.location='firewall_shaper_queues_edit.php?id=<?=$i;?>';">
|
173 |
2dc6b3ad
|
Scott Ullrich
|
<font color="#FFFFFF"><?=htmlspecialchars($queue['name']);?>
|
174 |
a11c626c
|
Scott Ullrich
|
|
175 |
12bcdc89
|
Scott Ullrich
|
</td>
|
176 |
c39b8aa6
|
Bill Marquette
|
<td valign="middle" nowrap class="list">
|
177 |
|
|
<table border="0" cellspacing="0" cellpadding="1">
|
178 |
|
|
<tr>
|
179 |
677c0869
|
Erik Kristensen
|
<td valign="middle"><a href="firewall_shaper_queues_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
|
180 |
|
|
<td valign="middle"><a href="firewall_shaper_queues.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this queue?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
|
181 |
c39b8aa6
|
Bill Marquette
|
</tr>
|
182 |
|
|
</table>
|
183 |
|
|
</td>
|
184 |
5b237745
|
Scott Ullrich
|
</tr>
|
185 |
b45ea709
|
Scott Ullrich
|
<?php $i++; endforeach; $total_queues = $i; ?>
|
186 |
5b237745
|
Scott Ullrich
|
<tr>
|
187 |
f274eb83
|
Scott Ullrich
|
<td class="list" colspan="6"></td>
|
188 |
c39b8aa6
|
Bill Marquette
|
<td class="list">
|
189 |
|
|
<table border="0" cellspacing="0" cellpadding="1">
|
190 |
|
|
<tr>
|
191 |
677c0869
|
Erik Kristensen
|
<td valign="middle"><a href="firewall_shaper_queues_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
192 |
c39b8aa6
|
Bill Marquette
|
</tr>
|
193 |
|
|
</table>
|
194 |
|
|
</td>
|
195 |
5b237745
|
Scott Ullrich
|
</tr>
|
196 |
d732f186
|
Bill Marquette
|
<tr><td colspan="6">
|
197 |
b45ea709
|
Scott Ullrich
|
<p>
|
198 |
cad11f37
|
Bill Marquette
|
<strong><span class="red">Note:</span></strong><strong><br></strong>
|
199 |
c55a8ab9
|
Holger Bauer
|
A queue can only be deleted if it is not referenced by any rules.<br>
|
200 |
|
|
You can check the results of your queues at <a href="status_queues.php">Status:Queues</a>.
|
201 |
b45ea709
|
Scott Ullrich
|
</p>
|
202 |
d732f186
|
Bill Marquette
|
</td></tr>
|
203 |
|
|
</table>
|
204 |
|
|
</div>
|
205 |
|
|
</td>
|
206 |
5b237745
|
Scott Ullrich
|
</tr>
|
207 |
|
|
</table>
|
208 |
|
|
</form>
|
209 |
|
|
<?php include("fend.inc"); ?>
|
210 |
|
|
</body>
|
211 |
|
|
</html>
|