Project

General

Profile

Download (9.01 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	firewall_shaper_queues.php
5
	Copyright (C) 2004, 2005 Scott Ullrich
6
	Copyright (C) 2008 Ermal Luçi
7
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
8
	All rights reserved.
9

    
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
/*
32
	pfSense_BUILDER_BINARIES:	/usr/bin/killall
33
	pfSense_MODULE:	shaper
34
*/
35

    
36
##|+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
require("guiconfig.inc");
44
require_once("functions.inc");
45
require_once("filter.inc");
46
require_once("shaper.inc");
47
require_once("rrd.inc");
48

    
49
if($_GET['reset'] <> "") {
50
	mwexec("killall -9 pfctl");
51
	exit;
52
}
53

    
54
$shaperIFlist = get_configured_interface_with_descr();
55
read_altq_config();
56
$qlist =& get_unique_queue_list();
57

    
58
if (!is_array($qlist)) 
59
	$qlist = array();
60

    
61
$tree = "<ul class=\"tree\" >";
62
foreach ($qlist as $queue => $qkey) {
63
	$tree .= "<li><a href=\"firewall_shaper_queues.php?queue={$queue}&amp;action=show\" >";
64
	if (isset($shaperIFlist[$queue]))
65
		$tree .= $shaperIFlist[$queue] . "</a></li>";
66
	else	
67
		$tree .= $queue . "</a></li>";
68
}
69
$tree .= "</ul>";
70

    
71
if ($_GET) {
72
	if ($_GET['queue'])
73
        	$qname = htmlspecialchars(trim($_GET['queue']));
74
        if ($_GET['interface'])
75
                $interface = htmlspecialchars(trim($_GET['interface']));
76
        if ($_GET['action'])
77
                $action = htmlspecialchars($_GET['action']);
78

    
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
				if (write_config())
86
					mark_subsystem_dirty('shaper');
87
			}
88
			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
                        foreach ($altq_list_queues as $altq) {
97
                                $qtmp =& $altq->find_queue("", $qname);
98
                                if ($qtmp) {
99
                                        $copycfg = array();
100
                                        $qtmp->copy_queue($interface, $copycfg);
101
                                        $aq =& $altq_list_queues[$interface];
102
					if ($qname == $qtmp->GetInterface()) {
103
                                                $config['shaper']['queue'][] = $copycfg;
104
                                        } else if ($aq) {
105
                                                $tmp1 =& $qtmp->find_parentqueue($interface, $qname);
106
                                                if ($tmp1) 
107
                                                        $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
					if (write_config())
124
						mark_subsystem_dirty('shaper');
125
                                        break;
126
                                }
127
                        }
128

    
129
			header("Location: firewall_shaper_queues.php?queue=".$qname."&action=show");
130
			exit;
131
		break;
132
	case "show":
133
                        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
		break;
150
	}
151
}
152

    
153
if ($_POST['apply']) {
154
          write_config();
155

    
156
	$retval = 0;
157
        /* Setup pf rules since the user may have changed the optimization value */
158
	$retval = filter_configure();
159
	$savemsg = get_std_save_message($retval);
160
                        if (stristr($retval, "error") <> true)
161
                                $savemsg = get_std_save_message($retval);
162
                        else
163
                                $savemsg = $retval;
164

    
165
 		/* reset rrd queues */
166
                system("rm -f /var/db/rrd/*queuedrops.rrd");
167
                system("rm -f /var/db/rrd/*queues.rrd");
168
			enable_rrd_graphing();
169

    
170
		clear_subsystem_dirty('shaper');
171
}
172

    
173
$pgtitle = gettext("Firewall: Shaper: By Queues View");
174
$shortcut_section = "trafficshaper";
175
$closehead = false;
176
include("head.inc");
177
?>
178
<link rel="stylesheet" type="text/css" media="all" href="./tree/tree.css" />
179
<script type="text/javascript" src="./tree/tree.js"></script>
180
</head>
181

    
182
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
183
<?php include("fbegin.inc"); ?>
184
<div id="inputerrors"></div>
185
<?php if ($input_errors) print_input_errors($input_errors); ?>
186
<form action="firewall_shaper_queues.php" method="post" name="iform" id="iform">
187
<?php if ($savemsg) print_info_box($savemsg); ?>
188
<?php if (is_subsystem_dirty('shaper')): ?><p>
189
<?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
<?php endif; ?>
191
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="traffic shaper queues">
192
  <tr><td>
193
<?php
194
	$tab_array = array();
195
	$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
	display_top_tabs($tab_array);
201
?>
202
  </td></tr>
203
  <tr> 
204
    <td valign="top">
205
	<div id="mainarea">
206
		<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
207
		<tr>
208
		<td width="30%" valign="top" align="left">
209
                <?php      echo $tree; ?>
210
		</td>
211
		<td width="70%" valign="top" align="center">
212
			<?php 
213
				if ($qname)
214
        				echo "<p class=\"pgtitle\">" . $qname . "</p><br />";
215
				echo "<table align=\"center\" class=\"tabcont\" width=\"80%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" summary=\"output form\">";
216
				echo $output;
217
				echo "<tr><td>&nbsp;</td></tr>";
218
				echo "</table>";
219
			?>	
220
			</td></tr>
221
			</table><!-- table:main area -->
222

    
223
		</div><!-- div:main area -->
224
	  </td>
225
	</tr>
226
</table>
227
            </form>
228
<?php include("fend.inc"); ?>
229
</body>
230
</html>
(77-77/256)