Projet

Général

Profil

Télécharger (9,03 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / firewall_shaper_queues.php @ 7e736f38

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 php");
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
$rowIndex = 0;
62
foreach ($qlist as $queue => $qkey) {
63
	$rowIndex++;
64
	$tree .= "<li><a href=\"firewall_shaper_queues.php?queue={$queue}&amp;action=show\" >";
65
	if (isset($shaperIFlist[$queue]))
66
		$tree .= $shaperIFlist[$queue] . "</a></li>";
67
	else	
68
		$tree .= $queue . "</a></li>";
69
}
70
if ($rowIndex == 0)
71
	$tree .= "<li></li>";
72
$tree .= "</ul>";
73

    
74
if ($_GET) {
75
	if ($_GET['queue'])
76
        	$qname = htmlspecialchars(trim($_GET['queue']));
77
        if ($_GET['interface'])
78
                $interface = htmlspecialchars(trim($_GET['interface']));
79
        if ($_GET['action'])
80
                $action = htmlspecialchars($_GET['action']);
81

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

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

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

    
156
if ($_POST['apply']) {
157
          write_config();
158

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

    
168
 		/* reset rrd queues */
169
                system("rm -f /var/db/rrd/*queuedrops.rrd");
170
                system("rm -f /var/db/rrd/*queues.rrd");
171
			enable_rrd_graphing();
172

    
173
		clear_subsystem_dirty('shaper');
174
}
175

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

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

    
226
		</div><!-- div:main area -->
227
	  </td>
228
	</tr>
229
</table>
230
            </form>
231
<?php include("fend.inc"); ?>
232
</body>
233
</html>
(75-75/246)