Project

General

Profile

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