1 |
5b237745
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
|
|
firewall_shaper_queues.php
|
5 |
b49448ac
|
Scott Ullrich
|
Copyright (C) 2004, 2005 Scott Ullrich
|
6 |
197bfe96
|
Ermal Luçi
|
Copyright (C) 2008 Ermal Lu?i
|
7 |
b49448ac
|
Scott Ullrich
|
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 |
|
|
|
46 |
197bfe96
|
Ermal Luçi
|
/* on HEAD it has to use vc_* api on variable_cache.inc */
|
47 |
|
|
if (!is_array($GLOBALS['allqueue_list'])) {
|
48 |
|
|
$GLOBALS['allqueue_list'] = array();
|
49 |
b3e7dc67
|
Scott Ullrich
|
}
|
50 |
|
|
|
51 |
197bfe96
|
Ermal Luçi
|
/* XXX: NOTE: When dummynet is implemented these will be moved from here */
|
52 |
|
|
read_altq_config();
|
53 |
845dc7ed
|
Scott Ullrich
|
|
54 |
197bfe96
|
Ermal Luçi
|
$tree = "<ul class=\"tree\" >";
|
55 |
e0405a4b
|
Ermal Luçi
|
foreach ($GLOBALS['allqueue_list'] as $queue) {
|
56 |
|
|
$tree .= "<li><a href=\"firewall_shaper_queues.php?queue={$queue}&action=show\" >{$queue}</a></li>";
|
57 |
e8731417
|
Scott Ullrich
|
}
|
58 |
197bfe96
|
Ermal Luçi
|
$tree .= "</ul>";
|
59 |
|
|
|
60 |
|
|
if ($_GET) {
|
61 |
|
|
if ($_GET['queue'])
|
62 |
|
|
$qname = trim($_GET['queue']);
|
63 |
|
|
if ($_GET['interface'])
|
64 |
|
|
$interface = trim($_GET['interface']);
|
65 |
|
|
if ($_GET['action'])
|
66 |
|
|
$action = $_GET['action'];
|
67 |
|
|
|
68 |
|
|
switch ($action) {
|
69 |
|
|
case "delete":
|
70 |
|
|
$altq =& $altq_list_queues[$interface];
|
71 |
|
|
$qtmp =& $altq->find_queue("", $qname);
|
72 |
|
|
if ($qtmp) {
|
73 |
|
|
$qtmp->delete_queue();
|
74 |
|
|
write_config();
|
75 |
|
|
touch($d_shaperconfdirty_path);
|
76 |
5b237745
|
Scott Ullrich
|
}
|
77 |
197bfe96
|
Ermal Luçi
|
header("Location: firewall_shaper_queues.php");
|
78 |
|
|
exit;
|
79 |
|
|
break;
|
80 |
|
|
case "add":
|
81 |
|
|
/*
|
82 |
|
|
* XXX: WARNING: This returns the first it finds.
|
83 |
|
|
* Maybe the user expects something else?!
|
84 |
|
|
*/
|
85 |
|
|
foreach ($altq_list_queues as $altq) {
|
86 |
|
|
$qtmp =& $altq->find_queue("", $qname);
|
87 |
|
|
if ($qtmp) {
|
88 |
|
|
$aq =& $altq_list_queues[$interface];
|
89 |
|
|
if ($aq) {
|
90 |
|
|
//$link =& get_reference_to_me_in_config(&$link);
|
91 |
|
|
$aq->copy_queue($interface, &$qtmp);
|
92 |
|
|
write_config();
|
93 |
|
|
touch($d_shaperconfdirty_path);
|
94 |
|
|
break;
|
95 |
|
|
}
|
96 |
5b237745
|
Scott Ullrich
|
}
|
97 |
|
|
}
|
98 |
197bfe96
|
Ermal Luçi
|
header("Location: firewall_shaper_queues.php?queue=".$qname."&action=show");
|
99 |
5b237745
|
Scott Ullrich
|
exit;
|
100 |
197bfe96
|
Ermal Luçi
|
break;
|
101 |
|
|
case "show":
|
102 |
|
|
$iflist = get_interface_list();
|
103 |
|
|
foreach ($iflist as $if) {
|
104 |
|
|
$altq = $altq_list_queues[$if['friendly']];
|
105 |
|
|
if ($altq) {
|
106 |
|
|
$qtmp =& $altq->find_queue("", $qname);
|
107 |
|
|
if ($qtmp)
|
108 |
|
|
$output .= $qtmp->build_shortform();
|
109 |
|
|
else
|
110 |
|
|
$output .= build_iface_without_this_queue($if['friendly'], $qname);
|
111 |
|
|
} else
|
112 |
|
|
$output .= build_iface_without_this_queue($if['friendly'], $qname);
|
113 |
|
|
}
|
114 |
|
|
break;
|
115 |
5b237745
|
Scott Ullrich
|
}
|
116 |
|
|
}
|
117 |
52380979
|
Scott Ullrich
|
|
118 |
197bfe96
|
Ermal Luçi
|
if ($_POST['apply']) {
|
119 |
|
|
write_config();
|
120 |
b7ff5e40
|
Scott Ullrich
|
|
121 |
197bfe96
|
Ermal Luçi
|
$retval = 0;
|
122 |
|
|
$savemsg = get_std_save_message($retval);
|
123 |
|
|
/* Setup pf rules since the user may have changed the optimization value */
|
124 |
b7ff5e40
|
Scott Ullrich
|
|
125 |
197bfe96
|
Ermal Luçi
|
config_lock();
|
126 |
|
|
$retval = filter_configure();
|
127 |
|
|
config_unlock();
|
128 |
|
|
if (stristr($retval, "error") <> true)
|
129 |
|
|
$savemsg = get_std_save_message($retval);
|
130 |
|
|
else
|
131 |
|
|
$savemsg = $retval;
|
132 |
b7ff5e40
|
Scott Ullrich
|
|
133 |
197bfe96
|
Ermal Luçi
|
enable_rrd_graphing();
|
134 |
b7ff5e40
|
Scott Ullrich
|
|
135 |
197bfe96
|
Ermal Luçi
|
unlink($d_shaperconfdirty_path);
|
136 |
b7ff5e40
|
Scott Ullrich
|
}
|
137 |
|
|
|
138 |
197bfe96
|
Ermal Luçi
|
$pgtitle = "Firewall: Shaper: By Queues View";
|
139 |
b7ff5e40
|
Scott Ullrich
|
|
140 |
52380979
|
Scott Ullrich
|
include("head.inc");
|
141 |
5b237745
|
Scott Ullrich
|
?>
|
142 |
197bfe96
|
Ermal Luçi
|
<link rel="stylesheet" type="text/css" media="all" href="./tree/tree.css" />
|
143 |
|
|
<script type="text/javascript" src="./tree/tree.js"></script>
|
144 |
5b237745
|
Scott Ullrich
|
|
145 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
146 |
|
|
<?php include("fbegin.inc"); ?>
|
147 |
197bfe96
|
Ermal Luçi
|
<div id="inputerrors"></div>
|
148 |
5b237745
|
Scott Ullrich
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
149 |
197bfe96
|
Ermal Luçi
|
<form action="firewall_shaper_queues.php" method="post" name="iform" id="iform">
|
150 |
5b237745
|
Scott Ullrich
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
151 |
|
|
<?php if (file_exists($d_shaperconfdirty_path)): ?><p>
|
152 |
|
|
<?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>
|
153 |
|
|
<?php endif; ?>
|
154 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
155 |
|
|
<tr><td>
|
156 |
52380979
|
Scott Ullrich
|
<?php
|
157 |
|
|
$tab_array = array();
|
158 |
e0405a4b
|
Ermal Luçi
|
$tab_array[0] = array("By Interface", false, "firewall_shaper.php");
|
159 |
|
|
$tab_array[1] = array("By Queue", true, "firewall_shaper_queues.ph");
|
160 |
|
|
$tab_array[2] = array("EZ Shaper wizard", false, "wizard.php?xml=traffic_shaper_wizard.xml");
|
161 |
52380979
|
Scott Ullrich
|
display_top_tabs($tab_array);
|
162 |
|
|
?>
|
163 |
5b237745
|
Scott Ullrich
|
</td></tr>
|
164 |
92125c97
|
Ermal Luçi
|
<tr>
|
165 |
|
|
<td valign="top">
|
166 |
d732f186
|
Bill Marquette
|
<div id="mainarea">
|
167 |
e0405a4b
|
Ermal Luçi
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
168 |
|
|
<tr>
|
169 |
|
|
<td width="30%" valign="top" algin="left">
|
170 |
|
|
<? echo $tree; ?>
|
171 |
|
|
</td>
|
172 |
|
|
<td width="70%" valign="top" align="center">
|
173 |
197bfe96
|
Ermal Luçi
|
<?
|
174 |
|
|
if ($qname)
|
175 |
|
|
echo "<pr class=\"pgtitle\">" . $qname . "</pr><br />";
|
176 |
e0405a4b
|
Ermal Luçi
|
echo "<table align=\"center\" class=\"tabcont\" width=\"80%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\">";
|
177 |
197bfe96
|
Ermal Luçi
|
echo $output;
|
178 |
|
|
echo "</table>";
|
179 |
|
|
?>
|
180 |
|
|
</td></tr>
|
181 |
|
|
</table>
|
182 |
|
|
|
183 |
d732f186
|
Bill Marquette
|
</td></tr>
|
184 |
|
|
</div>
|
185 |
|
|
</td>
|
186 |
5b237745
|
Scott Ullrich
|
</tr>
|
187 |
|
|
</table>
|
188 |
|
|
</form>
|
189 |
197bfe96
|
Ermal Luçi
|
<?php include("fend.inc");
|
190 |
|
|
?>
|
191 |
5b237745
|
Scott Ullrich
|
</body>
|
192 |
|
|
</html>
|