Project

General

Profile

Download (8.17 KB) Statistics
| Branch: | Tag: | Revision:
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
?>
104
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
105
<html>
106
<head>
107 cad11f37 Bill Marquette
<title><?=gentitle("Firewall: Traffic shaper: Queues");?></title>
108 5b237745 Scott Ullrich
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
109
<link href="gui.css" rel="stylesheet" type="text/css">
110
</head>
111
112
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
113
<?php include("fbegin.inc"); ?>
114 cad11f37 Bill Marquette
<p class="pgtitle">Firewall: Traffic shaper: Queues</p>
115 54eaa3c1 Scott Ullrich
<form action="firewall_shaper_queues.php" method="post">
116 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
117
<?php if ($savemsg) print_info_box($savemsg); ?>
118
<?php if (file_exists($d_shaperconfdirty_path)): ?><p>
119
<?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>
120
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
121
<?php endif; ?>
122
<table width="100%" border="0" cellpadding="0" cellspacing="0">
123
  <tr><td>
124
  <ul id="tabnav">
125 1b8f6d97 Scott Ullrich
    <li class="tabinact"><a href="firewall_shaper.php">Rules</a></li>
126
    <li class="tabact">Queues</a></li>
127
    <li class="tabinact"><a href="firewall_shaper_magic.php">Magic shaper wizard</a></li>
128 5b237745 Scott Ullrich
  </ul>
129
  </td></tr>
130
  <tr>
131
    <td class="tabcont">
132
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
133
                      <tr>
134 8217e5e0 Scott Ullrich
                        <td width="5%" class="listhdrr">No.</td>
135
			<td width="5%" class="listhdrr">Flags</td>
136
                        <td width="5%" class="listhdrr">Priority</td>
137
			<td width="5%" class="listhdr">Default</td>
138 dbab498d Scott Ullrich
			<td width="5%" class="listhdr">Bandwidth</td>
139 8217e5e0 Scott Ullrich
                        <td width="70%" class="listhdr">Name</td>
140 5b237745 Scott Ullrich
                        <td width="10%" class="list"></td>
141
                      </tr>
142
                      <?php $i = 0; foreach ($a_queues as $queue): ?>
143
                      <tr valign="top">
144 be6d8fc9 Bill Marquette
                        <td class="listlr" ondblclick="document.location='firewall_shaper_queues_edit.php?id=<?=$i;?>';">
145 12bcdc89 Scott Ullrich
                          <?=($i+1);?>
146
			</td>
147 be6d8fc9 Bill Marquette
			<td class="listlr" ondblclick="document.location='firewall_shaper_queues_edit.php?id=<?=$i;?>';">
148 b9000512 Scott Ullrich
			  <?php
149
			     if($queue['red'] <> "") echo " RED";
150 94743d1d Bill Marquette
			     if($queue['rio'] <> "") echo " RIO";
151 b9000512 Scott Ullrich
			     if($queue['ecn'] <> "") echo " ECN";
152
			     if($queue['borrow'] <> "") echo " Borrow";
153
			  ?>
154
			  &nbsp;
155
			</td>
156 be6d8fc9 Bill Marquette
                        <td class="listr" ondblclick="document.location='firewall_shaper_queues_edit.php?id=<?=$i;?>';">
157 740dac81 Scott Ullrich
                          <?=$queue['priority'];?>&nbsp;
158 12bcdc89 Scott Ullrich
			</td>
159 be6d8fc9 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 be6d8fc9 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
                          &nbsp;
171
			</td>
172 be6d8fc9 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
                          &nbsp;
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
                              <td valign="middle"><a href="firewall_shaper_queues_edit.php?id=<?=$i;?>"><img src="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="x.gif" width="17" height="17" border="0"></a></td>
181
                            </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
                              <td valign="middle"><a href="firewall_shaper_queues_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
192
                            </tr>
193
                          </table>
194
                        </td>
195 5b237745 Scott Ullrich
                      </tr>
196
                    </table>
197 b45ea709 Scott Ullrich
		    <p>
198 cad11f37 Bill Marquette
                    <strong><span class="red">Note:</span></strong><strong><br></strong>
199 b45ea709 Scott Ullrich
                      1)  A queue can only be deleted if it is not referenced by any rules.<br>
200
		      2)  Queue graphs take 5 seconds to sample data.
201
		      </td>
202
		    </p>
203 5b237745 Scott Ullrich
	</tr>
204
</table>
205
            </form>
206 4f335a1b Scott Ullrich
<br><a href="firewall_shaper_queues.php?reset=true">Reset</a> queues if they do not load.
207 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
208
</body>
209
</html>