Project

General

Profile

Download (9.03 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 7a927e67 Scott Ullrich
require_once("functions.inc");
44
require_once("filter.inc");
45
require_once("shaper.inc");
46 a5f07f09 Ermal Lu?i
require_once("rrd.inc");
47 5b237745 Scott Ullrich
48 4f335a1b Scott Ullrich
if($_GET['reset'] <> "") {
49
	mwexec("killall -9 pfctl php");
50 8f8a97c8 Ermal Luçi
	exit;
51 4f335a1b Scott Ullrich
}
52
53 9d5b21c6 Ermal Luçi
$shaperIFlist = get_configured_interface_with_descr();
54 197bfe96 Ermal Luçi
read_altq_config();
55 21a0464c Ermal Luçi
$qlist =& get_unique_queue_list();
56
57
if (!is_array($qlist)) 
58
	$qlist = array();
59 845dc7ed Scott Ullrich
60 197bfe96 Ermal Luçi
$tree = "<ul class=\"tree\" >";
61 0a173e6b N0YB
$rowIndex = 0;
62 21a0464c Ermal Luçi
foreach ($qlist as $queue => $qkey) {
63 0a173e6b N0YB
	$rowIndex++;
64 f6b81501 Colin Fleming
	$tree .= "<li><a href=\"firewall_shaper_queues.php?queue={$queue}&amp;action=show\" >";
65 9d5b21c6 Ermal Luçi
	if (isset($shaperIFlist[$queue]))
66
		$tree .= $shaperIFlist[$queue] . "</a></li>";
67
	else	
68
		$tree .= $queue . "</a></li>";
69 e8731417 Scott Ullrich
}
70 0a173e6b N0YB
if ($rowIndex == 0)
71
	$tree .= "<li></li>";
72 197bfe96 Ermal Luçi
$tree .= "</ul>";
73
74
if ($_GET) {
75
	if ($_GET['queue'])
76 dd5bf424 Scott Ullrich
        	$qname = htmlspecialchars(trim($_GET['queue']));
77 197bfe96 Ermal Luçi
        if ($_GET['interface'])
78 dd5bf424 Scott Ullrich
                $interface = htmlspecialchars(trim($_GET['interface']));
79 197bfe96 Ermal Luçi
        if ($_GET['action'])
80 dd5bf424 Scott Ullrich
                $action = htmlspecialchars($_GET['action']);
81 197bfe96 Ermal Luçi
82
	switch ($action) {
83
	case "delete":
84
			$altq =& $altq_list_queues[$interface];
85
			$qtmp =& $altq->find_queue("", $qname);
86
			if ($qtmp) {
87
				$qtmp->delete_queue(); 
88 3a343d73 jim-p
				if (write_config())
89
					mark_subsystem_dirty('shaper');
90 5b237745 Scott Ullrich
			}
91 197bfe96 Ermal Luçi
			header("Location: firewall_shaper_queues.php");
92
			exit;
93
		break;
94
	case "add":
95
			/* 
96
			 * XXX: WARNING: This returns the first it finds.
97
			 * Maybe the user expects something else?!
98
			 */
99 a843b04f Ermal Luçi
                        foreach ($altq_list_queues as $altq) {
100
                                $qtmp =& $altq->find_queue("", $qname);
101
                                if ($qtmp) {
102
                                        $copycfg = array();
103
                                        $qtmp->copy_queue($interface, &$copycfg);
104
                                        $aq =& $altq_list_queues[$interface];
105 63502467 Ermal Luçi
					if ($qname == $qtmp->GetInterface()) {
106
                                                $config['shaper']['queue'][] = $copycfg;
107
                                        } else if ($aq) {
108 a843b04f Ermal Luçi
                                                $tmp1 =& $qtmp->find_parentqueue($interface, $qname);
109 63502467 Ermal Luçi
                                                if ($tmp1) 
110 a843b04f Ermal Luçi
                                                        $tmp =& $aq->find_queue($interface, $tmp1->GetQname());
111
112
                                                if ($tmp)
113
                                                        $link =& get_reference_to_me_in_config($tmp->GetLink());
114
                                                else
115
                                                        $link =& get_reference_to_me_in_config($aq->GetLink());
116
                                                $link['queue'][] = $copycfg;
117
                                        } else {
118
                                                $newroot = array();
119
                                                $newroot['name'] = $interface;
120
                                                $newroot['interface'] = $interface;
121
                                                $newroot['scheduler'] = $altq->GetScheduler();
122
                                                $newroot['queue'] = array();
123
                                                $newroot['queue'][] = $copycfg;
124
                                                $config['shaper']['queue'][] = $newroot;
125
                                        }
126 3a343d73 jim-p
					if (write_config())
127
						mark_subsystem_dirty('shaper');
128 a843b04f Ermal Luçi
                                        break;
129
                                }
130
                        }
131
132 197bfe96 Ermal Luçi
			header("Location: firewall_shaper_queues.php?queue=".$qname."&action=show");
133 5b237745 Scott Ullrich
			exit;
134 197bfe96 Ermal Luçi
		break;
135
	case "show":
136 67aeb121 Ermal Luçi
                        foreach ($config['interfaces'] as $if => $ifdesc) {
137
                                $altq = $altq_list_queues[$if];
138
                                if ($altq) {
139
                                        $qtmp =& $altq->find_queue("", $qname);
140
                                        if ($qtmp)
141
                                                $output .= $qtmp->build_shortform();
142
                                        else
143
                                                $output .= build_iface_without_this_queue($if, $qname);
144
                                } else {
145
                                        if (!is_altq_capable($ifdesc['if']))
146
                                                continue;
147
                                        if (!isset($ifdesc['enable']) && $if != "lan" && $if != "wan")
148
                                                continue;
149
                                        $output .= build_iface_without_this_queue($if, $qname);
150
                                }
151
                        }
152 197bfe96 Ermal Luçi
		break;
153 5b237745 Scott Ullrich
	}
154
}
155 52380979 Scott Ullrich
156 197bfe96 Ermal Luçi
if ($_POST['apply']) {
157
          write_config();
158 b7ff5e40 Scott Ullrich
159 0027de0a Ermal Lu?i
	$retval = 0;
160 197bfe96 Ermal Luçi
        /* Setup pf rules since the user may have changed the optimization value */
161 0027de0a Ermal Lu?i
	$retval = filter_configure();
162
	$savemsg = get_std_save_message($retval);
163 197bfe96 Ermal Luçi
                        if (stristr($retval, "error") <> true)
164
                                $savemsg = get_std_save_message($retval);
165
                        else
166
                                $savemsg = $retval;
167 b7ff5e40 Scott Ullrich
168 96b777d6 Ermal Luçi
 		/* reset rrd queues */
169
                system("rm -f /var/db/rrd/*queuedrops.rrd");
170
                system("rm -f /var/db/rrd/*queues.rrd");
171 197bfe96 Ermal Luçi
			enable_rrd_graphing();
172 b7ff5e40 Scott Ullrich
173 a368a026 Ermal Lu?i
		clear_subsystem_dirty('shaper');
174 b7ff5e40 Scott Ullrich
}
175
176 fbe58e0a Renato Botelho
$pgtitle = gettext("Firewall: Shaper: By Queues View");
177 b32dd0a6 jim-p
$shortcut_section = "trafficshaper";
178 f6b81501 Colin Fleming
$closehead = false;
179 52380979 Scott Ullrich
include("head.inc");
180 5b237745 Scott Ullrich
?>
181 197bfe96 Ermal Luçi
<link rel="stylesheet" type="text/css" media="all" href="./tree/tree.css" />
182
<script type="text/javascript" src="./tree/tree.js"></script>
183 f6b81501 Colin Fleming
</head>
184 5b237745 Scott Ullrich
185
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
186
<?php include("fbegin.inc"); ?>
187 197bfe96 Ermal Luçi
<div id="inputerrors"></div>
188 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
189 197bfe96 Ermal Luçi
<form action="firewall_shaper_queues.php" method="post" name="iform" id="iform">
190 5b237745 Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
191 a368a026 Ermal Lu?i
<?php if (is_subsystem_dirty('shaper')): ?><p>
192 f6b81501 Colin Fleming
<?php print_info_box_np(gettext("The traffic shaper configuration has been changed") . ".<br/>" . gettext("You must apply the changes in order for them to take effect."));?><br/></p>
193 5b237745 Scott Ullrich
<?php endif; ?>
194 f6b81501 Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="traffic shaper queues">
195 5b237745 Scott Ullrich
  <tr><td>
196 52380979 Scott Ullrich
<?php
197
	$tab_array = array();
198 fbe58e0a Renato Botelho
	$tab_array[0] = array(gettext("By Interface"), false, "firewall_shaper.php");
199
	$tab_array[1] = array(gettext("By Queue"), true, "firewall_shaper_queues.php");
200
	$tab_array[2] = array(gettext("Limiter"), false, "firewall_shaper_vinterface.php");
201
	$tab_array[3] = array(gettext("Layer7"), false, "firewall_shaper_layer7.php");
202
	$tab_array[4] = array(gettext("Wizards"), false, "firewall_shaper_wizards.php");
203 52380979 Scott Ullrich
	display_top_tabs($tab_array);
204
?>
205 5b237745 Scott Ullrich
  </td></tr>
206 92125c97 Ermal Luçi
  <tr> 
207
    <td valign="top">
208 d732f186 Bill Marquette
	<div id="mainarea">
209 f6b81501 Colin Fleming
		<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
210 e0405a4b Ermal Luçi
		<tr>
211 f6b81501 Colin Fleming
		<td width="30%" valign="top" align="left">
212 a3381369 Colin Fleming
                <?php      echo $tree; ?>
213 e0405a4b Ermal Luçi
		</td>
214
		<td width="70%" valign="top" align="center">
215 a3381369 Colin Fleming
			<?php 
216 197bfe96 Ermal Luçi
				if ($qname)
217 7519ed16 Colin Fleming
        				echo "<p class=\"pgtitle\">" . $qname . "</p><br />";
218 f6b81501 Colin Fleming
				echo "<table align=\"center\" class=\"tabcont\" width=\"80%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" summary=\"output form\">";
219 197bfe96 Ermal Luçi
				echo $output;
220 7519ed16 Colin Fleming
				echo "<tr><td>&nbsp;</td></tr>";
221 197bfe96 Ermal Luçi
				echo "</table>";
222
			?>	
223
			</td></tr>
224 7519ed16 Colin Fleming
			</table><!-- table:main area -->
225 197bfe96 Ermal Luçi
226 7519ed16 Colin Fleming
		</div><!-- div:main area -->
227 d732f186 Bill Marquette
	  </td>
228 5b237745 Scott Ullrich
	</tr>
229
</table>
230
            </form>
231 f6b81501 Colin Fleming
<?php include("fend.inc"); ?>
232 5b237745 Scott Ullrich
</body>
233 7519ed16 Colin Fleming
</html>