Project

General

Profile

Download (8.96 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / firewall_shaper_queues.php @ a1b66bec

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
	All rights reserved.
8

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

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

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

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

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

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

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

    
78
	switch ($action) {
79
	case "delete":
80
			$altq =& $altq_list_queues[$interface];
81
			$qtmp =& $altq->find_queue("", $qname);
82
			if ($qtmp) {
83
				$qtmp->delete_queue(); 
84
				if (write_config())
85
					mark_subsystem_dirty('shaper');
86
			}
87
			header("Location: firewall_shaper_queues.php");
88
			exit;
89
		break;
90
	case "add":
91
			/* 
92
			 * XXX: WARNING: This returns the first it finds.
93
			 * Maybe the user expects something else?!
94
			 */
95
                        foreach ($altq_list_queues as $altq) {
96
                                $qtmp =& $altq->find_queue("", $qname);
97
                                if ($qtmp) {
98
                                        $copycfg = array();
99
                                        $qtmp->copy_queue($interface, $copycfg);
100
                                        $aq =& $altq_list_queues[$interface];
101
					if ($qname == $qtmp->GetInterface()) {
102
                                                $config['shaper']['queue'][] = $copycfg;
103
                                        } else if ($aq) {
104
                                                $tmp1 =& $qtmp->find_parentqueue($interface, $qname);
105
                                                if ($tmp1) 
106
                                                        $tmp =& $aq->find_queue($interface, $tmp1->GetQname());
107

    
108
                                                if ($tmp)
109
                                                        $link =& get_reference_to_me_in_config($tmp->GetLink());
110
                                                else
111
                                                        $link =& get_reference_to_me_in_config($aq->GetLink());
112
                                                $link['queue'][] = $copycfg;
113
                                        } else {
114
                                                $newroot = array();
115
                                                $newroot['name'] = $interface;
116
                                                $newroot['interface'] = $interface;
117
                                                $newroot['scheduler'] = $altq->GetScheduler();
118
                                                $newroot['queue'] = array();
119
                                                $newroot['queue'][] = $copycfg;
120
                                                $config['shaper']['queue'][] = $newroot;
121
                                        }
122
					if (write_config())
123
						mark_subsystem_dirty('shaper');
124
                                        break;
125
                                }
126
                        }
127

    
128
			header("Location: firewall_shaper_queues.php?queue=".$qname."&action=show");
129
			exit;
130
		break;
131
	case "show":
132
                        foreach ($config['interfaces'] as $if => $ifdesc) {
133
                                $altq = $altq_list_queues[$if];
134
                                if ($altq) {
135
                                        $qtmp =& $altq->find_queue("", $qname);
136
                                        if ($qtmp)
137
                                                $output .= $qtmp->build_shortform();
138
                                        else
139
                                                $output .= build_iface_without_this_queue($if, $qname);
140
                                } else {
141
                                        if (!is_altq_capable($ifdesc['if']))
142
                                                continue;
143
                                        if (!isset($ifdesc['enable']) && $if != "lan" && $if != "wan")
144
                                                continue;
145
                                        $output .= build_iface_without_this_queue($if, $qname);
146
                                }
147
                        }
148
		break;
149
	}
150
}
151

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

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

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

    
169
		clear_subsystem_dirty('shaper');
170
}
171

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

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

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