Project

General

Profile

Download (7.9 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/* NEW
4
	firewall_shaper_queues.php
5
*/
6
/* ====================================================================
7
 *  Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved. 
8
 *  Copyright (c)  2004, 2005 Scott Ullrich
9
 *  Copyright (c)  2008 Ermal Luçi
10
 *
11
 *  Redistribution and use in source and binary forms, with or without modification, 
12
 *  are permitted provided that the following conditions are met: 
13
 *
14
 *  1. Redistributions of source code must retain the above copyright notice,
15
 *      this list of conditions and the following disclaimer.
16
 *
17
 *  2. Redistributions in binary form must reproduce the above copyright
18
 *      notice, this list of conditions and the following disclaimer in
19
 *      the documentation and/or other materials provided with the
20
 *      distribution. 
21
 *
22
 *  3. All advertising materials mentioning features or use of this software 
23
 *      must display the following acknowledgment:
24
 *      "This product includes software developed by the pfSense Project
25
 *       for use in the pfSense software distribution. (http://www.pfsense.org/). 
26
 *
27
 *  4. The names "pfSense" and "pfSense Project" must not be used to
28
 *       endorse or promote products derived from this software without
29
 *       prior written permission. For written permission, please contact
30
 *       coreteam@pfsense.org.
31
 *
32
 *  5. Products derived from this software may not be called "pfSense"
33
 *      nor may "pfSense" appear in their names without prior written
34
 *      permission of the Electric Sheep Fencing, LLC.
35
 *
36
 *  6. Redistributions of any form whatsoever must retain the following
37
 *      acknowledgment:
38
 *
39
 *  "This product includes software developed by the pfSense Project
40
 *  for use in the pfSense software distribution (http://www.pfsense.org/).
41
  *
42
 *  THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
43
 *  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45
 *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
46
 *  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47
 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48
 *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50
 *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51
 *  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52
 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53
 *  OF THE POSSIBILITY OF SUCH DAMAGE.
54
 *
55
 *  ====================================================================
56
 *
57
 */
58
/*
59
	pfSense_BUILDER_BINARIES:	/usr/bin/killall
60
	pfSense_MODULE: shaper
61
*/
62

    
63
##|+PRIV
64
##|*IDENT=page-firewall-trafficshaper-queues
65
##|*NAME=Firewall: Traffic Shaper: Queues page
66
##|*DESCR=Allow access to the 'Firewall: Traffic Shaper: Queues' page.
67
##|*MATCH=firewall_shaper_queues.php*
68
##|-PRIV
69

    
70
require("guiconfig.inc");
71
require_once("functions.inc");
72
require_once("filter.inc");
73
require_once("shaper.inc");
74
require_once("rrd.inc");
75

    
76
if($_GET['reset'] != "") {
77
	mwexec("killall -9 pfctl");
78
	exit;
79
}
80

    
81
$qname = gettext("No queue configured/selected");
82

    
83
$shaperIFlist = get_configured_interface_with_descr();
84
read_altq_config();
85
$qlist =& get_unique_queue_list();
86

    
87
if (!is_array($qlist)) {
88
	$qlist = array();
89
}
90

    
91
$tree = "<ul class=\"tree\" >";
92
foreach ($qlist as $queue => $qkey) {
93
	$tree .= "<li><a href=\"firewall_shaper_queues.php?queue={$queue}&amp;action=show\" >";
94
	if (isset($shaperIFlist[$queue])) {
95
		$tree .= $shaperIFlist[$queue] . "</a></li>";
96
	} else {
97
		$tree .= $queue . "</a></li>";
98
	}
99
}
100
$tree .= "</ul>";
101

    
102
if ($_GET) {
103
	if ($_GET['queue']) {
104
		$qname = htmlspecialchars(trim($_GET['queue']));
105
	}
106

    
107
	if ($_GET['interface']) {
108
		$interface = htmlspecialchars(trim($_GET['interface']));
109
	}
110

    
111
	if ($_GET['action']) {
112
		$action = htmlspecialchars($_GET['action']);
113
	}
114

    
115
	switch ($action) {
116
		case "delete":
117
			$altq =& $altq_list_queues[$interface];
118
			$qtmp =& $altq->find_queue("", $qname);
119
			if ($qtmp) {
120
				$qtmp->delete_queue();
121
				if (write_config()) {
122
					mark_subsystem_dirty('shaper');
123
				}
124
			}
125
			header("Location: firewall_shaper_queues.php");
126
			exit;
127
			break;
128
		case "add":
129
			/*
130
			 * XXX: WARNING: This returns the first it finds.
131
			 * Maybe the user expects something else?!
132
			 */
133
			foreach ($altq_list_queues as $altq) {
134
				$qtmp =& $altq->find_queue("", $qname);
135
				
136
				if ($qtmp) {
137
					$copycfg = array();
138
					$qtmp->copy_queue($interface, $copycfg);
139
					$aq =& $altq_list_queues[$interface];
140
					
141
					if ($qname == $qtmp->GetInterface()) {
142
						$config['shaper']['queue'][] = $copycfg;
143
					} else if ($aq) {
144
						$tmp1 =& $qtmp->find_parentqueue($interface, $qname);
145
						if ($tmp1) {
146
							$tmp =& $aq->find_queue($interface, $tmp1->GetQname());
147
						}
148

    
149
						if ($tmp) {
150
							$link =& get_reference_to_me_in_config($tmp->GetLink());
151
						} else {
152
							$link =& get_reference_to_me_in_config($aq->GetLink());
153
						}
154

    
155
						$link['queue'][] = $copycfg;
156
					} else {
157
						$newroot = array();
158
						$newroot['name'] = $interface;
159
						$newroot['interface'] = $interface;
160
						$newroot['scheduler'] = $altq->GetScheduler();
161
						$newroot['queue'] = array();
162
						$newroot['queue'][] = $copycfg;
163
						$config['shaper']['queue'][] = $newroot;
164
					}
165

    
166
					if (write_config())
167
						mark_subsystem_dirty('shaper');
168

    
169
					break;
170
					}
171
				}
172

    
173
			header("Location: firewall_shaper_queues.php?queue=".$qname."&action=show");
174
			exit;
175
		break;
176
		case "show":
177
			foreach ($config['interfaces'] as $if => $ifdesc) {
178
				$altq = $altq_list_queues[$if];
179

    
180
				if ($altq) {
181
					$qtmp =& $altq->find_queue("", $qname);
182

    
183
					if ($qtmp)
184
						$output .= $qtmp->build_shortform();
185
					else
186
						$output .= build_iface_without_this_queue($if, $qname);
187

    
188
				} else {
189
					if (!is_altq_capable($ifdesc['if']))
190
						continue;
191

    
192
					if (!isset($ifdesc['enable']) && $if != "lan" && $if != "wan")
193
						continue;
194

    
195
					$output .= build_iface_without_this_queue($if, $qname);
196
				}
197
			}
198
		break;
199
	}
200
}
201

    
202
if ($_POST['apply']) {
203
	write_config();
204

    
205
	$retval = 0;
206
	/* Setup pf rules since the user may have changed the optimization value */
207
	$retval = filter_configure();
208
	$savemsg = get_std_save_message($retval);
209
	if (stristr($retval, "error") <> true) {
210
		$savemsg = get_std_save_message($retval);
211
	} else {
212
		$savemsg = $retval;
213
	}
214

    
215
	/* reset rrd queues */
216
	system("rm -f /var/db/rrd/*queuedrops.rrd");
217
	system("rm -f /var/db/rrd/*queues.rrd");
218
	enable_rrd_graphing();
219

    
220
	clear_subsystem_dirty('shaper');
221
}
222

    
223
$pgtitle = gettext("Firewall: Shaper: By Queues View");
224
$shortcut_section = "trafficshaper";
225
$closehead = false;
226

    
227
include("head.inc");
228
?>
229

    
230
<link rel="stylesheet" type="text/css" media="all" href="./tree/tree.css" />
231
<script type="text/javascript" src="./tree/tree.js"></script>
232

    
233
<?php
234
if ($input_errors)
235
	print_input_errors($input_errors);
236

    
237
if ($savemsg)
238
	print_info_box($savemsg);
239

    
240
if (is_subsystem_dirty('shaper'))
241
	print_info_box_np(gettext("The traffic shaper configuration has been changed. You must apply the changes in order for them to take effect."));
242

    
243
$tab_array = array();
244
$tab_array[] = array(gettext("By Interface"), false, "firewall_shaper.php");
245
$tab_array[] = array(gettext("By Queue"), true, "firewall_shaper_queues.php");
246
$tab_array[] = array(gettext("Limiter"), false, "firewall_shaper_vinterface.php");
247
$tab_array[] = array(gettext("Layer7"), false, "firewall_shaper_layer7.php");
248
$tab_array[] = array(gettext("Wizards"), false, "firewall_shaper_wizards.php");
249
display_top_tabs($tab_array);
250

    
251
?>
252

    
253
<form action="firewall_shaper_queues.php" method="post" name="iform" id="iform">
254
	<div class="panel panel-default">
255
		<div class="panel-heading" align="center"><h2 class="panel-title"><?=$qname?></h2></div>
256
		<div class="panel-body">
257
			<div class="form-group">
258
				<div class="col-sm-2 ">
259
					<?=$tree?>
260
				</div>
261
				<div class="col-sm-10">
262
					<?=$output?>
263
				</div>
264
			</div>
265
		</div>
266
	</div>
267
</form>
268

    
269
<?php
270

    
271
include("foot.inc");
(67-67/238)