Project

General

Profile

Download (8.53 KB) Statistics
| Branch: | Tag: | Revision:
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
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30 7ac5a4cb Scott Ullrich
/*
31
	pfSense_BUILDER_BINARIES:	/usr/bin/killall
32
	pfSense_MODULE:	shaper
33
*/
34 5b237745 Scott Ullrich
35 6b07c15a Matthew Grooms
##|+PRIV
36
##|*IDENT=page-firewall-trafficshaper-queues
37
##|*NAME=Firewall: Traffic Shaper: Queues page
38
##|*DESCR=Allow access to the 'Firewall: Traffic Shaper: Queues' page.
39
##|*MATCH=firewall_shaper_queues.php*
40
##|-PRIV
41
42 5b237745 Scott Ullrich
require("guiconfig.inc");
43
44 4f335a1b Scott Ullrich
if($_GET['reset'] <> "") {
45
	mwexec("killall -9 pfctl php");
46 8f8a97c8 Ermal Luçi
	exit;
47 4f335a1b Scott Ullrich
}
48
49 9d5b21c6 Ermal Luçi
$shaperIFlist = get_configured_interface_with_descr();
50 197bfe96 Ermal Luçi
read_altq_config();
51 21a0464c Ermal Luçi
$qlist =& get_unique_queue_list();
52
53
if (!is_array($qlist)) 
54
	$qlist = array();
55 845dc7ed Scott Ullrich
56 197bfe96 Ermal Luçi
$tree = "<ul class=\"tree\" >";
57 21a0464c Ermal Luçi
foreach ($qlist as $queue => $qkey) {
58 9d5b21c6 Ermal Luçi
	$tree .= "<li><a href=\"firewall_shaper_queues.php?queue={$queue}&action=show\" >";
59
	if (isset($shaperIFlist[$queue]))
60
		$tree .= $shaperIFlist[$queue] . "</a></li>";
61
	else	
62
		$tree .= $queue . "</a></li>";
63 e8731417 Scott Ullrich
}
64 197bfe96 Ermal Luçi
$tree .= "</ul>";
65
66
if ($_GET) {
67
	if ($_GET['queue'])
68
        	$qname = trim($_GET['queue']);
69
        if ($_GET['interface'])
70
                $interface = trim($_GET['interface']);
71
        if ($_GET['action'])
72
                $action = $_GET['action'];
73
74
	switch ($action) {
75
	case "delete":
76
			$altq =& $altq_list_queues[$interface];
77
			$qtmp =& $altq->find_queue("", $qname);
78
			if ($qtmp) {
79
				$qtmp->delete_queue(); 
80
				write_config();
81 a368a026 Ermal Lu?i
				mark_subsystem_dirty('shaper');
82 5b237745 Scott Ullrich
			}
83 197bfe96 Ermal Luçi
			header("Location: firewall_shaper_queues.php");
84
			exit;
85
		break;
86
	case "add":
87
			/* 
88
			 * XXX: WARNING: This returns the first it finds.
89
			 * Maybe the user expects something else?!
90
			 */
91 a843b04f Ermal Luçi
                        foreach ($altq_list_queues as $altq) {
92
                                $qtmp =& $altq->find_queue("", $qname);
93
                                if ($qtmp) {
94
                                        $copycfg = array();
95
                                        $qtmp->copy_queue($interface, &$copycfg);
96
                                        $aq =& $altq_list_queues[$interface];
97 63502467 Ermal Luçi
					if ($qname == $qtmp->GetInterface()) {
98
                                                $config['shaper']['queue'][] = $copycfg;
99
                                        } else if ($aq) {
100 a843b04f Ermal Luçi
                                                $tmp1 =& $qtmp->find_parentqueue($interface, $qname);
101 63502467 Ermal Luçi
                                                if ($tmp1) 
102 a843b04f Ermal Luçi
                                                        $tmp =& $aq->find_queue($interface, $tmp1->GetQname());
103
104
                                                if ($tmp)
105
                                                        $link =& get_reference_to_me_in_config($tmp->GetLink());
106
                                                else
107
                                                        $link =& get_reference_to_me_in_config($aq->GetLink());
108
                                                $link['queue'][] = $copycfg;
109
                                        } else {
110
                                                $newroot = array();
111
                                                $newroot['name'] = $interface;
112
                                                $newroot['interface'] = $interface;
113
                                                $newroot['scheduler'] = $altq->GetScheduler();
114
                                                $newroot['queue'] = array();
115
                                                $newroot['queue'][] = $copycfg;
116
                                                $config['shaper']['queue'][] = $newroot;
117
                                        }
118
                                        write_config();
119 a368a026 Ermal Lu?i
					mark_subsystem_dirty('shaper');
120 a843b04f Ermal Luçi
                                        break;
121
                                }
122
                        }
123
124 197bfe96 Ermal Luçi
			header("Location: firewall_shaper_queues.php?queue=".$qname."&action=show");
125 5b237745 Scott Ullrich
			exit;
126 197bfe96 Ermal Luçi
		break;
127
	case "show":
128 67aeb121 Ermal Luçi
                        foreach ($config['interfaces'] as $if => $ifdesc) {
129
                                $altq = $altq_list_queues[$if];
130
                                if ($altq) {
131
                                        $qtmp =& $altq->find_queue("", $qname);
132
                                        if ($qtmp)
133
                                                $output .= $qtmp->build_shortform();
134
                                        else
135
                                                $output .= build_iface_without_this_queue($if, $qname);
136
                                } else {
137
                                        if (!is_altq_capable($ifdesc['if']))
138
                                                continue;
139
                                        if (!isset($ifdesc['enable']) && $if != "lan" && $if != "wan")
140
                                                continue;
141
                                        $output .= build_iface_without_this_queue($if, $qname);
142
                                }
143
                        }
144 197bfe96 Ermal Luçi
		break;
145 5b237745 Scott Ullrich
	}
146
}
147 52380979 Scott Ullrich
148 197bfe96 Ermal Luçi
if ($_POST['apply']) {
149
          write_config();
150 b7ff5e40 Scott Ullrich
151 0027de0a Ermal Lu?i
	$retval = 0;
152 197bfe96 Ermal Luçi
        /* Setup pf rules since the user may have changed the optimization value */
153 0027de0a Ermal Lu?i
	$retval = filter_configure();
154
	$savemsg = get_std_save_message($retval);
155 197bfe96 Ermal Luçi
                        if (stristr($retval, "error") <> true)
156
                                $savemsg = get_std_save_message($retval);
157
                        else
158
                                $savemsg = $retval;
159 b7ff5e40 Scott Ullrich
160 96b777d6 Ermal Luçi
 		/* reset rrd queues */
161
                system("rm -f /var/db/rrd/*queuedrops.rrd");
162
                system("rm -f /var/db/rrd/*queues.rrd");
163 197bfe96 Ermal Luçi
			enable_rrd_graphing();
164 b7ff5e40 Scott Ullrich
165 a368a026 Ermal Lu?i
		clear_subsystem_dirty('shaper');
166 b7ff5e40 Scott Ullrich
}
167
168 197bfe96 Ermal Luçi
$pgtitle = "Firewall: Shaper: By Queues View";
169 b7ff5e40 Scott Ullrich
170 52380979 Scott Ullrich
include("head.inc");
171 5b237745 Scott Ullrich
?>
172 197bfe96 Ermal Luçi
<link rel="stylesheet" type="text/css" media="all" href="./tree/tree.css" />
173
<script type="text/javascript" src="./tree/tree.js"></script>
174 5b237745 Scott Ullrich
175
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
176
<?php include("fbegin.inc"); ?>
177 197bfe96 Ermal Luçi
<div id="inputerrors"></div>
178 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
179 197bfe96 Ermal Luçi
<form action="firewall_shaper_queues.php" method="post" name="iform" id="iform">
180 5b237745 Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
181 a368a026 Ermal Lu?i
<?php if (is_subsystem_dirty('shaper')): ?><p>
182 5b237745 Scott Ullrich
<?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>
183
<?php endif; ?>
184
<table width="100%" border="0" cellpadding="0" cellspacing="0">
185
  <tr><td>
186 52380979 Scott Ullrich
<?php
187
	$tab_array = array();
188 e0405a4b Ermal Luçi
	$tab_array[0] = array("By Interface", false, "firewall_shaper.php");
189 a843b04f Ermal Luçi
	$tab_array[1] = array("By Queue", true, "firewall_shaper_queues.php");
190 6d0c07ea Ermal Luçi
	$tab_array[2] = array("Limiter", false, "firewall_shaper_vinterface.php");
191 f63d5b66 Helder Pereira
	$tab_array[3] = array("Layer7", false, "firewall_shaper_layer7.php");
192
	$tab_array[4] = array("Wizards", false, "firewall_shaper_wizards.php");
193 52380979 Scott Ullrich
	display_top_tabs($tab_array);
194
?>
195 5b237745 Scott Ullrich
  </td></tr>
196 92125c97 Ermal Luçi
  <tr> 
197
    <td valign="top">
198 d732f186 Bill Marquette
	<div id="mainarea">
199 e0405a4b Ermal Luçi
		<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
200
		<tr>
201
		<td width="30%" valign="top" algin="left">
202
                <?      echo $tree; ?>
203
		</td>
204
		<td width="70%" valign="top" align="center">
205 197bfe96 Ermal Luçi
			<? 
206
				if ($qname)
207
        				echo "<pr class=\"pgtitle\">" . $qname . "</pr><br />";
208 e0405a4b Ermal Luçi
				echo "<table align=\"center\" class=\"tabcont\" width=\"80%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\">";
209 197bfe96 Ermal Luçi
				echo $output;
210
				echo "</table>";
211
			?>	
212
			</td></tr>
213
			</table>
214
215 d732f186 Bill Marquette
		      </td></tr>
216
		</div>
217
	  </td>
218 5b237745 Scott Ullrich
	</tr>
219
</table>
220
            </form>
221 197bfe96 Ermal Luçi
<?php include("fend.inc"); 
222
?>
223 5b237745 Scott Ullrich
</body>
224
</html>