Project

General

Profile

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