1
|
<?php
|
2
|
/*
|
3
|
traffic_shaper_wizard_dedicated.inc
|
4
|
part of pfSense (https://www.pfsense.org/)
|
5
|
|
6
|
Copyright (C) 2006 Bill Marquette - bill.marquette@gmail.com.
|
7
|
Copyright (C) 2006 Scott Ullrich - sullrich@pfsense.com.
|
8
|
Copyright (C) 2008-2010 Ermal Luçi
|
9
|
All rights reserved.
|
10
|
|
11
|
Redistribution and use in source and binary forms, with or without
|
12
|
modification, 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 the
|
19
|
documentation and/or other materials provided with the distribution.
|
20
|
|
21
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
POSSIBILITY OF SUCH DAMAGE.
|
31
|
*/
|
32
|
|
33
|
function step1_stepbeforeformdisplay() {
|
34
|
global $stepid, $savemsg, $pkg;
|
35
|
|
36
|
$fields =& $pkg['step'][0]['fields']['field'];
|
37
|
|
38
|
$wans = 0;
|
39
|
$lans = 0;
|
40
|
|
41
|
$iflisttmp = get_configured_interface_with_descr();
|
42
|
foreach ($iflisttmp as $if => $ifdesc) {
|
43
|
if (!is_altq_capable(get_real_interface($if)))
|
44
|
continue;
|
45
|
if (interface_has_gateway($if) || interface_has_gatewayv6($if))
|
46
|
$wans++;
|
47
|
else
|
48
|
$lans++;
|
49
|
}
|
50
|
|
51
|
foreach ($fields as &$field)
|
52
|
if ($field['name'] == 'numberofconnections')
|
53
|
$field['value'] = ($wans < $lans ? $wans : $lans);
|
54
|
}
|
55
|
|
56
|
function step1_submitphpaction() {
|
57
|
global $stepid, $savemsg;
|
58
|
|
59
|
if (!isset($_POST['numberofconnections'])) {
|
60
|
$savemsg=gettext("You need to specify the number of connections.");
|
61
|
$stepid--;
|
62
|
return;
|
63
|
}
|
64
|
if (intval($_POST['numberofconnections']) < 1) {
|
65
|
$savemsg=gettext("The number of connections should be greater than 1.");
|
66
|
$stepid--;
|
67
|
return;
|
68
|
}
|
69
|
}
|
70
|
|
71
|
function step2_stepbeforeformdisplay() {
|
72
|
global $config, $pkg;
|
73
|
global $stepid, $savemsg;
|
74
|
|
75
|
$wans = 0;
|
76
|
$lans = 0;
|
77
|
$iflist = array();
|
78
|
$iflisttmp = get_configured_interface_with_descr();
|
79
|
foreach ($iflisttmp as $if => $ifdesc) {
|
80
|
if (!is_altq_capable(get_real_interface($if)))
|
81
|
continue;
|
82
|
if (interface_has_gateway($if) || interface_has_gatewayv6($if))
|
83
|
$wans++;
|
84
|
else
|
85
|
$lans++;
|
86
|
$iflist[$if] = $ifdesc;
|
87
|
}
|
88
|
$numberofconnections = intval($config['ezshaper']['step1']['numberofconnections']);
|
89
|
if ($numberofconnections > ($wans < $lans ? $wans : $lans)) {
|
90
|
$savemsg=gettext("You have less interfaces than number of connections!");
|
91
|
$stepid--;
|
92
|
return;
|
93
|
}
|
94
|
|
95
|
$cfgname = "traffic_shaper_wizard_dedicated.xml";
|
96
|
|
97
|
$fields =& $pkg['step'][1]['fields']['field'];
|
98
|
|
99
|
/*
|
100
|
unset($config['ezshaper']['step2']);
|
101
|
$config['ezshaper']['step2'] = array();
|
102
|
write_config();
|
103
|
*/
|
104
|
$fields = array();
|
105
|
|
106
|
for ($i = 0; $i < $numberofconnections; $i++) {
|
107
|
$field = array();
|
108
|
$linknum = $i+1;
|
109
|
$ifsel = ($i * 2);
|
110
|
$field['name'] = "Connection #{$linknum} parameters";
|
111
|
$field['type'] = "listtopic";
|
112
|
$fields[] = $field;
|
113
|
|
114
|
$field = array();
|
115
|
$field['displayname'] = "Local interface";
|
116
|
$field['name'] = "local{$i}interface";
|
117
|
$field['type'] = "select";
|
118
|
$field['options']['option'] = array();
|
119
|
$ifcnt = 0;
|
120
|
foreach ($iflist as $ifname => $ifdescr) {
|
121
|
// Skip wan interfaces here
|
122
|
if (interface_has_gateway($ifname) || interface_has_gatewayv6($ifname))
|
123
|
continue;
|
124
|
if ($ifcnt == ($ifsel + 1))
|
125
|
$field['value'] = $ifname;
|
126
|
$opts = array();
|
127
|
$opts['displayname'] = $ifdescr;
|
128
|
$opts['name'] = $ifname;
|
129
|
$opts['value'] = $ifname;
|
130
|
$field['options']['option'][] = $opts;
|
131
|
$ifcnt++;
|
132
|
}
|
133
|
$field['combinefieldsbegin'] = "true";
|
134
|
$field['bindstofield'] = "ezshaper->step2->local{$i}interface";
|
135
|
$fields[] = $field;
|
136
|
|
137
|
$field = array();
|
138
|
$field['combinefieldsend'] = "true";
|
139
|
$field['dontdisplayname'] = "true";
|
140
|
$field['dontcombinecells'] = "true";
|
141
|
$field['name'] = "local{$i}downloadscheduler";
|
142
|
$field['type'] = "select";
|
143
|
$field['typehint'] = "Queueing discipline to apply on the download of this connection.";
|
144
|
$field['options']['option'] = array();
|
145
|
$opts = array();
|
146
|
$opts['name'] = "HFSC";
|
147
|
$opts['value'] = "HFSC";
|
148
|
$field['options']['option'][] = $opts;
|
149
|
$opts = array();
|
150
|
$opts['name'] = "CBQ";
|
151
|
$opts['value'] = "CBQ";
|
152
|
$field['options']['option'][] = $opts;
|
153
|
$opts = array();
|
154
|
$opts['name'] = "PRIQ";
|
155
|
$opts['value'] = "PRIQ";
|
156
|
$field['options']['option'][] = $opts;
|
157
|
$field['bindstofield'] = "ezshaper->step2->local{$i}downloadscheduler";
|
158
|
$fields[] = $field;
|
159
|
|
160
|
$field = array();
|
161
|
$field['displayname'] = "WAN Interface";
|
162
|
$field['name'] = "conn{$i}interface";
|
163
|
$field['type'] = "select";
|
164
|
$field['options']['option'] = array();
|
165
|
$ifcnt = 0;
|
166
|
foreach ($iflist as $ifname => $ifdescr) {
|
167
|
// Skip lan interfaces here
|
168
|
if (!interface_has_gateway($ifname) && !interface_has_gatewayv6($ifname))
|
169
|
continue;
|
170
|
if ($ifcnt == $ifsel)
|
171
|
$field['value'] = $ifname;
|
172
|
$opts = array();
|
173
|
$opts['displayname'] = $ifdescr;
|
174
|
$opts['name'] = $ifname;
|
175
|
$opts['value'] = $ifname;
|
176
|
$field['options']['option'][] = $opts;
|
177
|
$ifcnt++;
|
178
|
}
|
179
|
$field['bindstofield'] = "ezshaper->step2->conn{$i}interface";
|
180
|
$field['combinefieldsbegin'] = "true";
|
181
|
$fields[] = $field;
|
182
|
|
183
|
$field = array();
|
184
|
$field['name'] = "conn{$i}uploadscheduler";
|
185
|
$field['combinefieldsend'] = "true";
|
186
|
$field['dontdisplayname'] = "true";
|
187
|
$field['dontcombinecells'] = "true";
|
188
|
$field['type'] = "select";
|
189
|
$field['typehint'] = "Queueing discipline to apply on the upload of this connection.";
|
190
|
$field['options']['option'] = array();
|
191
|
$opts = array();
|
192
|
$opts['name'] = "HFSC";
|
193
|
$opts['value'] = "HFSC";
|
194
|
$field['options']['option'][] = $opts;
|
195
|
$opts = array();
|
196
|
$opts['name'] = "CBQ";
|
197
|
$opts['value'] = "CBQ";
|
198
|
$field['options']['option'][] = $opts;
|
199
|
$opts = array();
|
200
|
$opts['name'] = "PRIQ";
|
201
|
$opts['value'] = "PRIQ";
|
202
|
$field['options']['option'][] = $opts;
|
203
|
$field['bindstofield'] = "ezshaper->step2->conn{$i}uploadscheduler";
|
204
|
$fields[] = $field;
|
205
|
|
206
|
$field = array();
|
207
|
$field['displayname'] = "Upload";
|
208
|
$field['name'] = "conn{$i}upload";
|
209
|
$field['type'] = "input";
|
210
|
$field['bindstofield'] = "ezshaper->step2->conn{$i}upload";
|
211
|
$field['combinefieldsbegin'] = "true";
|
212
|
$fields[] = $field;
|
213
|
|
214
|
$field = array();
|
215
|
$field['combinefieldsend'] = "true";
|
216
|
$field['dontdisplayname'] = "true";
|
217
|
$field['dontcombinecells'] = "true";
|
218
|
$field['name'] = "conn{$i}uploadspeed";
|
219
|
$field['typehint'] = "Upload bandwidth on this connection.";
|
220
|
$field['type'] = "select";
|
221
|
$field['options']['option'] = array();
|
222
|
$opts = array();
|
223
|
$opts['value'] = "Kb";
|
224
|
$opts['name'] = "Kbit/s";
|
225
|
$field['options']['option'][] = $opts;
|
226
|
$opts = array();
|
227
|
$opts['value'] = "Mb";
|
228
|
$opts['name'] = "Mbit/s";
|
229
|
$field['options']['option'][] = $opts;
|
230
|
$opts = array();
|
231
|
$opts['value'] = "Gb";
|
232
|
$opts['name'] = "Gbit/s";
|
233
|
$field['options']['option'][] = $opts;
|
234
|
$field['bindstofield'] = "ezshaper->step2->conn{$i}uploadspeed";
|
235
|
$fields[] = $field;
|
236
|
|
237
|
$field = array();
|
238
|
$field['displayname'] = "Download";
|
239
|
$field['name'] = "conn{$i}download";
|
240
|
$field['type'] = "input";
|
241
|
$field['bindstofield'] = "ezshaper->step2->conn{$i}download";
|
242
|
$field['combinefieldsbegin'] = "true";
|
243
|
$fields[] = $field;
|
244
|
|
245
|
$field = array();
|
246
|
$field['combinefieldsend'] = "true";
|
247
|
$field['dontdisplayname'] = "true";
|
248
|
$field['dontcombinecells'] = "true";
|
249
|
$field['name'] = "conn{$i}downloadspeed";
|
250
|
$field['typehint'] = "Download bandwidth on this connection.";
|
251
|
$field['type'] = "select";
|
252
|
$field['options']['option'] = array();
|
253
|
$opts = array();
|
254
|
$opts['value'] = "Kb";
|
255
|
$opts['name'] = "Kbit/s";
|
256
|
$field['options']['option'][] = $opts;
|
257
|
$opts = array();
|
258
|
$opts['value'] = "Mb";
|
259
|
$opts['name'] = "Mbit/s";
|
260
|
$field['options']['option'][] = $opts;
|
261
|
$opts = array();
|
262
|
$opts['value'] = "Gb";
|
263
|
$opts['name'] = "Gbit/s";
|
264
|
$field['options']['option'][] = $opts;
|
265
|
$field['bindstofield'] = "ezshaper->step2->conn{$i}downloadspeed";
|
266
|
$fields[] = $field;
|
267
|
}
|
268
|
$field = array();
|
269
|
$field['name'] = "Next";
|
270
|
$field['type'] = "submit";
|
271
|
$fields[] = $field;
|
272
|
}
|
273
|
|
274
|
function step2_stepsubmitphpaction() {
|
275
|
global $config;
|
276
|
global $stepid, $savemsg;
|
277
|
$sumdownloads = 0;
|
278
|
|
279
|
/* Input Validation */
|
280
|
$steps = intval($config['ezshaper']['step1']['numberofconnections']);
|
281
|
for ($i = 0; $i < $steps; $i++) {
|
282
|
for ($j = $i + 1; $j <= $steps; $j++) {
|
283
|
if ($_POST["conn{$i}interface"] == $_POST["conn{$j}interface"] || $_POST["conn{$i}interface"] == $_POST["local{$j}interface"]) {
|
284
|
$savemsg=gettext("You cannot select the same interface for connections {$i} and {$j}.");
|
285
|
$stepid--;
|
286
|
return;
|
287
|
}
|
288
|
if (trim($_POST["conn{$i}uploadscheduler"]) != "PRIQ") {
|
289
|
if (!is_numeric($_POST["conn{$i}upload"])) {
|
290
|
$savemsg = gettext("Upload bandwidth of connection {$i} is not valid.");
|
291
|
$stepid--;
|
292
|
return;
|
293
|
}
|
294
|
if (!is_numeric($_POST["conn{$i}download"])) {
|
295
|
$savemsg = gettext("Download bandwidth of connection {$i} is not valid.");
|
296
|
$stepid--;
|
297
|
return;
|
298
|
}
|
299
|
$upbw = $_POST["conn{$i}upload"];
|
300
|
$downbw = $_POST["conn{$i}download"];
|
301
|
if ($upbw < 1 || $downbw < 1) {
|
302
|
$savemsg = gettext("You cannot specify bandwidth smaller than 1!");
|
303
|
$stepid--;
|
304
|
return;
|
305
|
}
|
306
|
if (intval($upbw) < 128 && $_POST["conn{$i}uploadspeed"] == "Kb" && trim($_POST["conn{$i}uploadscheduler"]) == "CBQ") {
|
307
|
$savemsg=gettext("Uploads smaller than 128Kbit/s is not supported for connection {$i} on CBQ scheduler.");
|
308
|
$stepid--;
|
309
|
return;
|
310
|
}
|
311
|
}
|
312
|
if ($_POST["local{$i}interface"] == $_POST["conn{$j}interface"] || $_POST["local{$i}interface"] == $_POST["local{$j}interface"]) {
|
313
|
$savemsg=gettext("You cannot select the same interface for local and outside.");
|
314
|
$stepid--;
|
315
|
return;
|
316
|
}
|
317
|
}
|
318
|
}
|
319
|
|
320
|
/* This is necessary since the wizard expects pecnefined fields. */
|
321
|
unset($config['ezshaper']['step2']);
|
322
|
$config['ezshaper']['step2'] = array();
|
323
|
|
324
|
for ($i = 0; $i < $steps; $i++) {
|
325
|
$config['ezshaper']['step2']["local{$i}downloadscheduler"] = $_POST["local{$i}downloadscheduler"];
|
326
|
$config['ezshaper']['step2']["local{$i}interface"] = $_POST["local{$i}interface"];
|
327
|
$config['ezshaper']['step2']["conn{$i}uploadscheduler"] = $_POST["conn{$i}uploadscheduler"];
|
328
|
$config['ezshaper']['step2']["conn{$i}upload"] = $_POST["conn{$i}upload"];
|
329
|
$config['ezshaper']['step2']["conn{$i}uploadspeed"] = $_POST["conn{$i}uploadspeed"];
|
330
|
$config['ezshaper']['step2']["conn{$i}download"] = $_POST["conn{$i}download"];
|
331
|
$config['ezshaper']['step2']["conn{$i}downloadspeed"] = $_POST["conn{$i}downloadspeed"];
|
332
|
$config['ezshaper']['step2']["conn${i}interface"] = $_POST["conn{$i}interface"];
|
333
|
}
|
334
|
}
|
335
|
|
336
|
function step3_stepbeforeformdisplay() {
|
337
|
global $config, $pkg;
|
338
|
global $stepid, $savemsg;
|
339
|
|
340
|
$cfgname = "traffic_shaper_wizard_dedicated.xml";
|
341
|
|
342
|
$numberofconnections = intval($config['ezshaper']['step1']['numberofconnections']);
|
343
|
|
344
|
$fields =& $pkg['step'][1]['fields']['field'];
|
345
|
|
346
|
$voipfields =& $pkg['step'][2]['fields']['field'];
|
347
|
|
348
|
$voipfields = array();
|
349
|
$enablefields = array();
|
350
|
|
351
|
$field = array();
|
352
|
$field['name'] = "Enable";
|
353
|
$field['type'] = "checkbox";
|
354
|
$field['typehint'] = "Prioritize Voice over IP traffic.";
|
355
|
$field['bindstofield'] = "ezshaper->step3->enable";
|
356
|
$field['descritpion'] = "This will raise the priority of VOIP traffic above all other traffic.";
|
357
|
$voipfields[] = $field;
|
358
|
|
359
|
$field = array();
|
360
|
$field['name'] = "Next";
|
361
|
$field['type'] = "submit";
|
362
|
$voipfields[] = $field;
|
363
|
|
364
|
$field = array();
|
365
|
$field['name'] = "VOIP specific settings";
|
366
|
$field['type'] = "listtopic";
|
367
|
$voipfields[] = $field;
|
368
|
|
369
|
$field = array();
|
370
|
$field['name'] = "Provider";
|
371
|
$enablefields[] = "Provider";
|
372
|
$field['type'] = "select";
|
373
|
$field['description'] = "Choose Generic if your provider isn't listed.";
|
374
|
$field['options']['option'] = array();
|
375
|
$opts = array();
|
376
|
$opts['name'] = "Generic (lowdelay)";
|
377
|
$opts['value'] = "Generic";
|
378
|
$field['options']['option'][] = $opts;
|
379
|
$opts = array();
|
380
|
$opts['name'] = "VoicePulse";
|
381
|
$opts['value'] = "VoicePulse";
|
382
|
$field['options']['option'][] = $opts;
|
383
|
$opts = array();
|
384
|
$opts['name'] = "Asterisk/Vonage";
|
385
|
$opts['value'] = "Asterisk";
|
386
|
$field['options']['option'][] = $opts;
|
387
|
$opts = array();
|
388
|
$opts['name'] = "PanasonicTDA";
|
389
|
$opts['value'] = "Panasonic";
|
390
|
$field['options']['option'][] = $opts;
|
391
|
$field['bindstofield'] = "ezshaper->step3->provider";
|
392
|
$voipfields[] = $field;
|
393
|
|
394
|
$field = array();
|
395
|
$field['displayname'] = "Upstream SIP Server";
|
396
|
$field['name'] = "upstream_sip_server";
|
397
|
$enablefields[] = "upstream_sip_server";
|
398
|
$field['type'] = "inputalias";
|
399
|
$field['description'] = "(Optional) If this is chosen, the provider field will be overridden. This allows you to provide the IP address of the <strong>remote</strong> PBX or SIP Trunk to prioritize. <br />NOTE: You can also use a Firewall Alias in this location.";
|
400
|
$field['message'] = "IP Address field is non-blank and doesn't look like an IP address.";
|
401
|
$field['bindstofield'] = "ezshaper->step3->address";
|
402
|
$voipfields[] = $field;
|
403
|
|
404
|
for ($i = 0; $i < $numberofconnections; $i++) {
|
405
|
$connum = $i + 1;
|
406
|
$field = array();
|
407
|
$field['name'] = "Connection #{$connum} parameters";
|
408
|
$field['type'] = "listtopic";
|
409
|
$voipfields[] = $field;
|
410
|
|
411
|
$field = array();
|
412
|
$field['displayname'] = "Upload";
|
413
|
$field['name'] = "conn{$i}upload";
|
414
|
$enablefields[] = "conn{$i}upload";
|
415
|
$field['type'] = "input";
|
416
|
$field['bindstofield'] = "ezshaper->step3->conn{$i}upload";
|
417
|
$field['combinefieldsbegin'] = "true";
|
418
|
$voipfields[] = $field;
|
419
|
|
420
|
$field = array();
|
421
|
$field['combinefieldsend'] = "true";
|
422
|
$field['dontdisplayname'] = "true";
|
423
|
$field['dontcombinecells'] = "true";
|
424
|
$field['name'] = "conn{$i}uploadspeed";
|
425
|
$enablefields[] = "conn{$i}uploadspeed";
|
426
|
$field['typehint'] = "Upload bandwidth guarantee for VOIP phone(s) on connection {$i}.";
|
427
|
$field['type'] = "select";
|
428
|
$field['options']['option'] = array();
|
429
|
$opts = array();
|
430
|
$opts['value'] = "Kb";
|
431
|
$opts['name'] = "Kbit/s";
|
432
|
$field['options']['option'][] = $opts;
|
433
|
$opts = array();
|
434
|
$opts['value'] = "Mb";
|
435
|
$opts['name'] = "Mbit/s";
|
436
|
$field['options']['option'][] = $opts;
|
437
|
$opts = array();
|
438
|
$opts['value'] = "Gb";
|
439
|
$opts['name'] = "Gbit/s";
|
440
|
$field['options']['option'][] = $opts;
|
441
|
$field['bindstofield'] = "ezshaper->step3->conn{$i}uploadspeed";
|
442
|
$voipfields[] = $field;
|
443
|
|
444
|
$field = array();
|
445
|
$field['displayname'] = "Download";
|
446
|
$field['name'] = "local{$i}download";
|
447
|
$enablefields[] = "local{$i}download";
|
448
|
$field['type'] = "input";
|
449
|
$field['bindstofield'] = "ezshaper->step3->local{$i}download";
|
450
|
$field['combinefieldsbegin'] = "true";
|
451
|
$voipfields[] = $field;
|
452
|
|
453
|
$field = array();
|
454
|
$field['combinefieldsend'] = "true";
|
455
|
$field['dontdisplayname'] = "true";
|
456
|
$field['dontcombinecells'] = "true";
|
457
|
$field['name'] = "local{$i}downloadspeed";
|
458
|
$enablefields[] = "local{$i}downloadspeed";
|
459
|
$field['typehint'] = "Download bandwidth guarantee for VOIP phone(s) on connections.";
|
460
|
$field['type'] = "select";
|
461
|
$field['options']['option'] = array();
|
462
|
$opts = array();
|
463
|
$opts['value'] = "Kb";
|
464
|
$opts['name'] = "Kbit/s";
|
465
|
$field['options']['option'][] = $opts;
|
466
|
$opts = array();
|
467
|
$opts['value'] = "Mb";
|
468
|
$opts['name'] = "Mbit/s";
|
469
|
$field['options']['option'][] = $opts;
|
470
|
$opts = array();
|
471
|
$opts['value'] = "Gb";
|
472
|
$opts['name'] = "Gbit/s";
|
473
|
$field['options']['option'][] = $opts;
|
474
|
$field['bindstofield'] = "ezshaper->step3->local{$i}downloadspeed";
|
475
|
$voipfields[] = $field;
|
476
|
}
|
477
|
|
478
|
$field = array();
|
479
|
$field['name'] = "Next";
|
480
|
$field['type'] = "submit";
|
481
|
$voipfields[] = $field;
|
482
|
$voipfields[0]['enablefields'] = implode(",", $enablefields);
|
483
|
}
|
484
|
|
485
|
function step3_stepsubmitphpaction() {
|
486
|
global $config;
|
487
|
global $stepid, $savemsg;
|
488
|
|
489
|
if (!$_POST['enable'])
|
490
|
return;
|
491
|
|
492
|
if($_POST['address']) {
|
493
|
if(!is_ipaddroralias($_POST['address'])) {
|
494
|
/* item is not an ip or alias. error out */
|
495
|
$savemsg=gettext("Address must be a valid IP address or Firewall Alias. Please correct this value to continue.");
|
496
|
$stepid--;
|
497
|
return;
|
498
|
}
|
499
|
}
|
500
|
|
501
|
$steps = intval($config['ezshaper']['step1']['numberofconnections']);
|
502
|
for ($i = 0; $i < $steps; $i++) {
|
503
|
if ($config['ezshaper']['step2']["conn{$i}uploadscheduler"] != "PRIQ") {
|
504
|
if (!is_numeric($_POST["conn{$i}upload"])) {
|
505
|
$savemsg = gettext("Upload bandwidth of connection {$i} is not valid.");
|
506
|
$stepid--;
|
507
|
return;
|
508
|
}
|
509
|
if ($_POST["conn{$i}uploadspeed"] == "%") {
|
510
|
if (intval($_POST["conn{$i}upload"]) > 80) {
|
511
|
$savemsg=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection.");
|
512
|
$stepid--;
|
513
|
return;
|
514
|
}
|
515
|
} else {
|
516
|
$factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}uploadspeed"]);
|
517
|
$ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}upload"]);
|
518
|
$factor = wizard_get_bandwidthtype_scale($_POST["conn{$i}uploadspeed"]);
|
519
|
$input_bw = $factor * floatval($_POST["conn{$i}upload"]);
|
520
|
if ((0.8 * $ifbw) < $input_bw) {
|
521
|
$savemsg=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection.");
|
522
|
$stepid--;
|
523
|
return;
|
524
|
}
|
525
|
}
|
526
|
}
|
527
|
|
528
|
if ($config['ezshaper']['step2']["local{$i}downloadscheduler"] != "PRIQ") {
|
529
|
if (!is_numeric($_POST["local{$i}download"])) {
|
530
|
$savemsg = gettext("Download bandwidth of connection {$i} is not valid.");
|
531
|
$stepid--;
|
532
|
return;
|
533
|
}
|
534
|
if ($_POST["local{$i}downloadspeed"] == "%") {
|
535
|
if (intval($_POST["local{$i}download"]) > 80) {
|
536
|
$savemsg=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection.");
|
537
|
$stepid--;
|
538
|
return;
|
539
|
}
|
540
|
} else {
|
541
|
$factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}downloadspeed"]);
|
542
|
$ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}download"]);
|
543
|
$factor = wizard_get_bandwidthtype_scale($_POST["local{$i}downloadspeed"]);
|
544
|
$input_bw = $factor * floatval($_POST["local{$i}download"]);
|
545
|
if ((0.8 * $ifbw) < $input_bw) {
|
546
|
$savemsg=gettext("You cannot set the VoIP download bandwidth on connection {$i} higher than 80% of the connection.");
|
547
|
$stepid--;
|
548
|
return;
|
549
|
}
|
550
|
}
|
551
|
}
|
552
|
}
|
553
|
|
554
|
for ($i = 0; $i < $steps; $i++) {
|
555
|
$config['ezshaper']['step3']["local{$i}download"] = $_POST["local{$i}download"];
|
556
|
$config['ezshaper']['step3']["local{$i}downloadspeed"] = $_POST["local{$i}downloadspeed"];
|
557
|
$config['ezshaper']['step3']["conn{$i}upload"] = $_POST["conn{$i}upload"];
|
558
|
$config['ezshaper']['step3']["conn{$i}uploadspeed"] = $_POST["conn{$i}uploadspeed"];
|
559
|
}
|
560
|
}
|
561
|
|
562
|
function step4_stepsubmitphpaction() {
|
563
|
global $config;
|
564
|
global $stepid, $savemsg;
|
565
|
|
566
|
if ( $_POST['enable'] ) {
|
567
|
if(!$_POST['bandwidth']) {
|
568
|
$savemsg="You need to specify a value for bandwidth!";
|
569
|
$stepid--;
|
570
|
return;
|
571
|
}
|
572
|
if(!is_numeric($_POST['bandwidth'])) {
|
573
|
$savemsg="The posted value is not a valid bandwidth.";
|
574
|
$stepid--;
|
575
|
return;
|
576
|
}
|
577
|
|
578
|
if ($_POST['bandwidthspeed'] <> "%") {
|
579
|
$savemsg = gettext("Only percentage bandwidth specification is allowed.");
|
580
|
$stepid--;
|
581
|
return;
|
582
|
}
|
583
|
$bw = $_POST['bandwidth'];
|
584
|
if($bw > 15 || $bw < 2) {
|
585
|
$savemsg="Values should be between 2% and 15%!";
|
586
|
$stepid--;
|
587
|
return;
|
588
|
}
|
589
|
if($_POST['address'] <> "" && !is_ipaddroralias($_POST['address'])) {
|
590
|
/* item is not an ip or alias. error out */
|
591
|
$savemsg=gettext("Address must be a valid IP address or Firewall Alias. Please correct this value to continue.");
|
592
|
$stepid--;
|
593
|
}
|
594
|
}
|
595
|
}
|
596
|
|
597
|
function step5_stepsubmitphpaction() {
|
598
|
global $stepid, $savemsg;
|
599
|
|
600
|
if ( $_POST['enable'] ) {
|
601
|
if ($_POST['p2pcatchall']) {
|
602
|
if(!is_numeric($_POST['bandwidth'])) {
|
603
|
$savemsg="Posted value is not a valid bandwidth.";
|
604
|
$stepid--;
|
605
|
return;
|
606
|
}
|
607
|
if ($_POST['bandwidthspeed'] <> "%") {
|
608
|
$savemsg = gettext("Only percentage bandwidth specification is allowed.");
|
609
|
$stepid--;
|
610
|
return;
|
611
|
}
|
612
|
$bw = $_POST['bandwidth'];
|
613
|
if($bw > 15 || $bw < 2) {
|
614
|
$savemsg="Values should be between 2% and 15%!";
|
615
|
$stepid--;
|
616
|
return;
|
617
|
}
|
618
|
}
|
619
|
}
|
620
|
}
|
621
|
|
622
|
function step8_stepsubmitphpaction() {
|
623
|
global $g, $config;
|
624
|
|
625
|
/* save the new configuration */
|
626
|
apply_all_choosen_items();
|
627
|
|
628
|
/* reset rrd queues */
|
629
|
system("rm -f /var/db/rrd/*queuedrops.rrd");
|
630
|
system("rm -f /var/db/rrd/*queues.rrd");
|
631
|
enable_rrd_graphing();
|
632
|
|
633
|
/* apply the new configuration to the system */
|
634
|
filter_configure();
|
635
|
|
636
|
/* And we're no longer dirty! */
|
637
|
clear_subsystem_dirty('shaper');
|
638
|
|
639
|
update_filter_reload_status("Initializing");
|
640
|
header("Location: status_filter_reload.php");
|
641
|
exit;
|
642
|
}
|
643
|
|
644
|
function apply_all_choosen_items() {
|
645
|
global $config, $g, $altq_list_queues, $gamesplist, $voiplist, $othersplist, $p2plist;
|
646
|
|
647
|
require_once("wizardapp.inc");
|
648
|
|
649
|
/*
|
650
|
* Wipe previous config.
|
651
|
* Doing it here makes sense since we can wipe the previous config only after
|
652
|
* the user decides to do so, finishing the wizard.
|
653
|
*/
|
654
|
if(isset($config['shaper']['queue']))
|
655
|
unset($config['shaper']['queue']);
|
656
|
/* XXX: This is ecnundant, because this should be handled by converter at startup. */
|
657
|
if(isset($config['shaper']['rule']))
|
658
|
unset($config['shaper']['rule']);
|
659
|
foreach ($config['filter']['rule'] as $key => $rule)
|
660
|
if ($rule['wizard'] == "yes")
|
661
|
unset($config['filter']['rule'][$key]);
|
662
|
|
663
|
/* restart the cached config */
|
664
|
unset($altq_list_queues);
|
665
|
$altq_list_queues = array();
|
666
|
|
667
|
$steps = intval($config['ezshaper']['step1']['numberofconnections']);
|
668
|
|
669
|
$interfacelist = array();
|
670
|
|
671
|
for ($i = 0; $i < $steps; $i++) {
|
672
|
|
673
|
$tmppath = array();
|
674
|
$altq =& new altq_root_queue();
|
675
|
|
676
|
$altq->SetInterface($config['ezshaper']['step2']["conn{$i}interface"]);
|
677
|
$interfacelist[] = $config['ezshaper']['step2']["conn{$i}interface"];
|
678
|
$altq->SetScheduler($config['ezshaper']['step2']["conn{$i}uploadscheduler"]);
|
679
|
$altq->SetBandwidth(floatval($config['ezshaper']['step2']["conn{$i}upload"]));
|
680
|
$altq->SetBwscale($config['ezshaper']['step2']["conn{$i}uploadspeed"]);
|
681
|
$altq->SetEnabled("on");
|
682
|
$altq_list_queues[$altq->GetQname()] =& $altq;
|
683
|
array_push($tmppath, $config['ezshaper']['step2']["conn{$i}interface"]);
|
684
|
$altq->SetLink($tmppath);
|
685
|
$altq->wconfig();
|
686
|
|
687
|
$sched = $config['ezshaper']['step2']["conn{$i}uploadscheduler"];
|
688
|
$voipbw =0;
|
689
|
$voipbwunit = "Kb";
|
690
|
$voip = false;
|
691
|
$penalty = false;
|
692
|
$penaltybw = 0;
|
693
|
$penaltybwunit = "Kb";
|
694
|
$p2p = false;
|
695
|
$p2pcatchall = false;
|
696
|
$p2pcatchbw = 0;
|
697
|
$p2pcatchbwunit = "%";
|
698
|
$games = false;
|
699
|
$otherpriority = false;
|
700
|
$remainbw = 0;
|
701
|
$factor = 0;
|
702
|
$upfactor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}uploadspeed"]);
|
703
|
$upbw = floatval($config['ezshaper']['step2']["conn{$i}upload"]) * $upfactor;
|
704
|
|
705
|
if ($config['ezshaper']['step3']['enable']) {
|
706
|
$voip = true;
|
707
|
$voipbw = $config['ezshaper']['step3']["conn{$i}upload"];
|
708
|
$voipbwunit = $config['ezshaper']['step3']["conn{$i}uploadspeed"];
|
709
|
if ($voipbwunit == "%")
|
710
|
$factor = $upbw/100;
|
711
|
else
|
712
|
$factor = wizard_get_bandwidthtype_scale($voipbwunit);
|
713
|
$remainbw += $voipbw * $factor;
|
714
|
}
|
715
|
if ($config['ezshaper']['step4']['enable']) {
|
716
|
$penalty = true;
|
717
|
$penaltybw = $config['ezshaper']['step4']['bandwidth'];
|
718
|
$penaltybwunit = $config['ezshaper']['step4']['bandwidthunit'];
|
719
|
if ($penaltybwunit == "%")
|
720
|
$factor = $upbw/100;
|
721
|
else
|
722
|
$factor = wizard_get_bandwidthtype_scale($penaltybwunit);
|
723
|
$remainbw += $penaltybw * $factor;
|
724
|
} else {
|
725
|
$penalty = false;
|
726
|
$penaltybw = 0;
|
727
|
}
|
728
|
if ($config['ezshaper']['step5']['enable']) {
|
729
|
$p2p = true;
|
730
|
if ($config['ezshaper']['step5']['p2pcatchall']) {
|
731
|
$p2pcatchall = true;
|
732
|
$p2pcatchbw = $config['ezshaper']['step5']['bandwidth'];
|
733
|
$p2pcatchbwunit = $config['ezshaper']['step5']['bandwidthunit'];
|
734
|
if ($p2pcatchbwunit == "%")
|
735
|
$factor = $upbw/100;
|
736
|
else
|
737
|
$factor = wizard_get_bandwidthtype_scale($p2pcatchbwunit);
|
738
|
$remainbw += $p2pcatchbw * $factor;
|
739
|
} else {
|
740
|
$p2pcatchall = false;
|
741
|
$p2pcatchbw = 0;
|
742
|
}
|
743
|
} else {
|
744
|
$p2p = false;
|
745
|
$p2pcatchall = false;
|
746
|
$p2pcatchbw = 0;
|
747
|
}
|
748
|
if ($config['ezshaper']['step6']['enable']) {
|
749
|
$games = true;
|
750
|
} else {
|
751
|
$games = false;
|
752
|
}
|
753
|
|
754
|
if ($config['ezshaper']['step7']['enable']) {
|
755
|
$otherpriority = true;
|
756
|
} else {
|
757
|
$otherpriority = false;
|
758
|
}
|
759
|
$remainbw = round($remainbw / $upbw * 100, 2);
|
760
|
|
761
|
if (intval($remainbw) > 0 && intval($remainbw) > 30) {
|
762
|
$savemsg=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue.");
|
763
|
header("Location: wizard.php?xml=traffic_shaper_wizard_dedicated.xml&stepid=2&message={$savemsg}");
|
764
|
exit;
|
765
|
} else {
|
766
|
$remainbw = 100 - $remainbw;
|
767
|
}
|
768
|
|
769
|
if ($sched != "PRIQ") {
|
770
|
if ($sched == "CBQ")
|
771
|
$q =& new cbq_queue();
|
772
|
else if ($sched == "HFSC")
|
773
|
$q =& new hfsc_queue();
|
774
|
$tmpcf = array();
|
775
|
$tmpcf['name'] = "qInternet";
|
776
|
//$tmpcf['priority'] = 6;
|
777
|
$tmpcf['ecn'] = "on";
|
778
|
$tmpcf['enabled'] = "on";
|
779
|
If ($sched == "CBQ") {
|
780
|
$tmpcf['bandwidth'] = floatval($config['ezshaper']['step2']["conn{$i}upload"]);
|
781
|
$tmpcf['bandwidthtype'] = $config['ezshaper']['step2']["conn{$i}uploadspeed"];
|
782
|
}
|
783
|
else if ($sched == "HFSC") {
|
784
|
$tmpcf['upperlimit'] = "on";
|
785
|
$tmpcf['upperlimit3'] =
|
786
|
floatval($config['ezshaper']['step2']["conn{$i}upload"]) . $config['ezshaper']['step2']["conn{$i}uploadspeed"];
|
787
|
$tmpcf['linkshare'] = "on";
|
788
|
$tmpcf['linkshare3'] = floatval($config['ezshaper']['step2']["conn{$i}upload"]) . $config['ezshaper']['step2']["conn{$i}uploadspeed"];
|
789
|
$tmpcf['bandwidth'] = floatval($config['ezshaper']['step2']["conn{$i}upload"]);
|
790
|
$tmpcf['bandwidthtype'] = $config['ezshaper']['step2']["conn{$i}uploadspeed"];
|
791
|
}
|
792
|
array_push($tmppath, "qInternet");
|
793
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
794
|
//array_pop($tmppath);
|
795
|
//echo "qInternet <br />";
|
796
|
//var_dump($input_errors);
|
797
|
$qtmp->wconfig();
|
798
|
$altq =& $qtmp;
|
799
|
}
|
800
|
|
801
|
if ($sched == "PRIQ")
|
802
|
$q =& new priq_queue();
|
803
|
else if ($sched == "CBQ")
|
804
|
$q =& new cbq_queue();
|
805
|
else if ($sched == "HFSC")
|
806
|
$q =& new hfsc_queue();
|
807
|
$tmpcf = array();
|
808
|
$tmpcf['name'] = "qACK";
|
809
|
$tmpcf['priority'] = 6;
|
810
|
$tmpcf['ecn'] = "on";
|
811
|
$tmpcf['enabled'] = "on";
|
812
|
If ($sched == "CBQ") {
|
813
|
$tmpcf['borrow'] = "on";
|
814
|
$tmpcf['bandwidth'] = $remainbw * 0.2;
|
815
|
$tmpcf['bandwidthtype'] = "%";
|
816
|
}
|
817
|
else if ($sched == "HFSC") {
|
818
|
$lkbw = 0.20 * $remainbw;
|
819
|
$tmpcf['linkshare3'] = "{$lkbw}%";
|
820
|
$tmpcf['linkshare'] = "on";
|
821
|
$tmpcf['bandwidth'] = $lkbw;
|
822
|
$tmpcf['bandwidthtype'] = "%";
|
823
|
}
|
824
|
array_push($tmppath, "qACK");
|
825
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
826
|
array_pop($tmppath);
|
827
|
//echo "qACK <br />";
|
828
|
//var_dump($input_errors);
|
829
|
$qtmp->wconfig();
|
830
|
|
831
|
if ($sched == "PRIQ")
|
832
|
$q =& new priq_queue();
|
833
|
else if ($sched == "CBQ")
|
834
|
$q =& new cbq_queue();
|
835
|
else if ($sched == "HFSC")
|
836
|
$q =& new hfsc_queue();
|
837
|
$tmpcf = array();
|
838
|
if ($p2pcatchall)
|
839
|
$tmpcf['name'] = "qOthersDefault";
|
840
|
else
|
841
|
$tmpcf['name'] = "qDefault";
|
842
|
$tmpcf['priority'] = 3;
|
843
|
$tmpcf['enabled'] = "on";
|
844
|
if (!$p2pcatchall)
|
845
|
$tmpcf['default'] = "on";
|
846
|
$tmpcf['ecn'] = "on";
|
847
|
if ($sched == "CBQ") {
|
848
|
$tmpcf['borrow'] = "on";
|
849
|
$tmpcf['bandwidth'] = $remainbw * 0.1; /* 10% bandwidth */
|
850
|
$tmpcf['bandwidthtype'] = "%";
|
851
|
} else if ($sched == "HFSC") {
|
852
|
$tmpcf['bandwidth'] = $remainbw * 0.1; /* 10% bandwidth */
|
853
|
$tmpcf['bandwidthtype'] = "%";
|
854
|
}
|
855
|
array_push($tmppath, $tmpcf['name']);
|
856
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
857
|
array_pop($tmppath);
|
858
|
//echo "qDefault <br />";
|
859
|
//var_dump($input_errors);
|
860
|
$qtmp->wconfig();
|
861
|
|
862
|
if ($p2p) {
|
863
|
if ($sched == "PRIQ")
|
864
|
$q =& new priq_queue();
|
865
|
else if ($sched == "CBQ")
|
866
|
$q =& new cbq_queue();
|
867
|
else if ($sched == "HFSC")
|
868
|
$q =& new hfsc_queue();
|
869
|
$tmpcf = array();
|
870
|
$tmpcf['name'] = "qP2P";
|
871
|
$tmpcf['priority'] = 1;
|
872
|
$tmpcf['ecn'] = "on";
|
873
|
$tmpcf['enabled'] = "on";
|
874
|
if ($p2pcatchall) {
|
875
|
if ($sched == "CBQ") {
|
876
|
$tmpcf['borrow'] = "on";
|
877
|
$tmpcf['bandwidth'] = $p2pcatchbw;
|
878
|
$tmpcf['bandwidthtype'] = $p2pcatchbwunit;
|
879
|
} else if ($sched == "HFSC") {
|
880
|
$tmpcf['linkshare'] = "on";
|
881
|
$tmpcf['linkshare3'] = "{$p2pcatchbw}{$p2pcatchbwunit}";
|
882
|
$tmpcf['upperlimit'] = "on";
|
883
|
$tmpcf['upperlimit3'] = "{$p2pcatchbw}{$p2pcatchbwunit}";
|
884
|
$tmpcf['bandwidth'] = $p2pcatchbw;
|
885
|
$tmpcf['bandwidthtype'] = $p2pcatchbwunit;
|
886
|
}
|
887
|
$tmpcf['default'] = "on";
|
888
|
|
889
|
} else {
|
890
|
if ($sched == "CBQ") {
|
891
|
$tmpcf['borrow'] = "on";
|
892
|
$tmpcf['bandwidth'] = $remainbw * 0.05; /* 5% bandwidth */
|
893
|
$tmpcf['bandwidthtype'] = "%";
|
894
|
} else if ($sched == "HFSC") {
|
895
|
$tmpbw = $remainbw * 0.05; /* 5% bandwidth */
|
896
|
$tmpcf['linkshare'] = "on";
|
897
|
$tmpcf['linkshare3'] = "{$tmpbw}%";
|
898
|
$tmpcf['upperlimit'] = "on";
|
899
|
$tmpcf['upperlimit3'] = "{$tmpbw}%";
|
900
|
$tmpcf['bandwidth'] = $tmpbw;
|
901
|
$tmpcf['bandwidthtype'] = "%";
|
902
|
}
|
903
|
}
|
904
|
array_push($tmppath, "qP2P");
|
905
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
906
|
array_pop($tmppath);
|
907
|
//echo "qP2P <br />";
|
908
|
//var_dump($input_errors);
|
909
|
$qtmp->wconfig();
|
910
|
}
|
911
|
|
912
|
if ($voip) {
|
913
|
if ($sched == "PRIQ")
|
914
|
$q =& new priq_queue();
|
915
|
else if ($sched == "CBQ")
|
916
|
$q =& new cbq_queue();
|
917
|
else if ($sched == "HFSC")
|
918
|
$q =& new hfsc_queue();
|
919
|
$tmpcf = array();
|
920
|
$tmpcf['name'] = "qVoIP";
|
921
|
$tmpcf['priority'] = 7;
|
922
|
$tmpcf['ecn'] = "on";
|
923
|
$tmpcf['enabled'] = "on";
|
924
|
if ($sched == "CBQ") {
|
925
|
$tmpcf['borrow'] = "on";
|
926
|
if ($voipbw > 0) {
|
927
|
$tmpcf['bandwidth'] = $voipbw;
|
928
|
$tmpcf['bandwidthtype'] = $voipbwunit;
|
929
|
} else {
|
930
|
$tmpcf['bandwidth'] = $remainbw * 0.2; /* 20% bandwidth */
|
931
|
$tmpcf['bandwidthtype'] = "%";
|
932
|
}
|
933
|
} else if ($sched == "HFSC") {
|
934
|
if ($voipbw > 0) {
|
935
|
$tmpcf['realtime3'] = "{$voipbw}{$voipbwunit}";
|
936
|
} else {
|
937
|
$voipbw = $remainbw * 0.20; /* 20% bandwidth */
|
938
|
$tmpcf['realtime3'] = "{$voipbw}%";
|
939
|
}
|
940
|
$tmpcf['realtime'] = "on";
|
941
|
$tmpcf['bandwidth'] = 32;
|
942
|
$tmpcf['bandwidthtype'] = "Kb";
|
943
|
}
|
944
|
array_push($tmppath, "qVoIP");
|
945
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
946
|
array_pop($tmppath);
|
947
|
//echo "qVoIP <br />";
|
948
|
//var_dump($input_errors);
|
949
|
$qtmp->wconfig();
|
950
|
}
|
951
|
|
952
|
if ($games) {
|
953
|
if ($sched == "PRIQ")
|
954
|
$q =& new priq_queue();
|
955
|
else if ($sched == "CBQ")
|
956
|
$q =& new cbq_queue();
|
957
|
else if ($sched == "HFSC")
|
958
|
$q =& new hfsc_queue();
|
959
|
$tmpcf = array();
|
960
|
$tmpcf['name'] = "qGames";
|
961
|
$tmpcf['priority'] = 5;
|
962
|
$tmpcf['enabled'] = "on";
|
963
|
$tmpcf['ecn'] = "on";
|
964
|
if ($sched == "CBQ") {
|
965
|
$tmpcf['borrow'] = "on";
|
966
|
$tmpcf['bandwidth'] = $remainbw * 0.2; /* 20% bandwidth */
|
967
|
$tmpcf['bandwidthtype'] = "%";
|
968
|
} else if ($sched == "HFSC") {
|
969
|
$gamesbw = $remainbw * 0.2; /* 20% bandwidth */
|
970
|
$tmpcf['linkshare'] = "on";
|
971
|
$tmpcf['linkshare3'] = "{$gamesbw}%";
|
972
|
$tmpcf['bandwidth'] = "{$gamesbw}";
|
973
|
$tmpcf['bandwidthtype'] = "%";
|
974
|
}
|
975
|
array_push($tmppath, "qGames");
|
976
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
977
|
array_pop($tmppath);
|
978
|
//echo "qGames <br />";
|
979
|
//var_dump($input_errors);
|
980
|
$qtmp->wconfig();
|
981
|
}
|
982
|
|
983
|
if ($otherpriority) {
|
984
|
if ($sched == "PRIQ")
|
985
|
$q =& new priq_queue();
|
986
|
else if ($sched == "CBQ")
|
987
|
$q =& new cbq_queue();
|
988
|
else if ($sched == "HFSC")
|
989
|
$q =& new hfsc_queue();
|
990
|
$tmpcf = array();
|
991
|
$tmpcf['name'] = "qOthersHigh";
|
992
|
$tmpcf['priority'] = 4;
|
993
|
$tmpcf['ecn'] = "on";
|
994
|
$tmpcf['enabled'] = "on";
|
995
|
if ($sched == "CBQ") {
|
996
|
$tmpcf['borrow'] = "on";
|
997
|
$tmpcf['bandwidth'] = $remainbw * 0.1; /* 10% bandwidth */
|
998
|
$tmpcf['bandwidthtype'] = "%";
|
999
|
} else if ($sched == "HFSC") {
|
1000
|
$tmpcf['linkshare'] = "on";
|
1001
|
$otherbw = $remainbw * 0.1; /* 10% bandwidth */
|
1002
|
$tmpcf['linkshare3'] = "{$otherbw}%";
|
1003
|
$tmpcf['bandwidth'] = $otherbw;
|
1004
|
$tmpcf['bandwidthtype'] = "%";
|
1005
|
}
|
1006
|
array_push($tmppath, "qOthersHigh");
|
1007
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
1008
|
array_pop($tmppath);
|
1009
|
//echo "qHigh <br />";
|
1010
|
//var_dump($input_errors);
|
1011
|
$qtmp->wconfig();
|
1012
|
|
1013
|
|
1014
|
if ($sched == "PRIQ")
|
1015
|
$q =& new priq_queue();
|
1016
|
else if ($sched == "CBQ")
|
1017
|
$q =& new cbq_queue();
|
1018
|
else if ($sched == "HFSC")
|
1019
|
$q =& new hfsc_queue();
|
1020
|
$tmpcf = array();
|
1021
|
$tmpcf['name'] = "qOthersLow";
|
1022
|
$tmpcf['priority'] = 2;
|
1023
|
$tmpcf['ecn'] = "on";
|
1024
|
$tmpcf['enabled'] = "on";
|
1025
|
if ($sched == "CBQ") {
|
1026
|
$tmpcf['borrow'] = "on";
|
1027
|
if ($penalty) {
|
1028
|
$tmpcf['bandwidthtype'] = $penaltybwunit;
|
1029
|
$tmpcf['bandwidth'] = $penaltybw;
|
1030
|
} else {
|
1031
|
$tmpcf['bandwidth'] = $remainbw * 0.05; /* 5% bandwidth */
|
1032
|
$tmpcf['bandwidthtype'] = "%";
|
1033
|
}
|
1034
|
} else if ($sched == "HFSC") {
|
1035
|
if ($penalty) {
|
1036
|
$tmpcf['linkshare3'] = "{$penaltybw}{$penaltybwunit}";
|
1037
|
$tmpcf['bandwidth'] = $penaltybw;
|
1038
|
$tmpcf['bandwidthtype'] = $penaltybwunit;
|
1039
|
} else {
|
1040
|
$lsbw = $remainbw * 0.05;
|
1041
|
$tmpcf['linkshare3'] = "{$lsbw}%"; /* 5% bandwidth */
|
1042
|
$tmpcf['bandwidth'] = $lsbw;
|
1043
|
$tmpcf['bandwidthtype'] = "%";
|
1044
|
}
|
1045
|
$tmpcf['linkshare'] = "on";
|
1046
|
}
|
1047
|
array_push($tmppath, "qOthersLow");
|
1048
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
1049
|
array_pop($tmppath);
|
1050
|
//echo "qLow <br />";
|
1051
|
//var_dump($input_errors);
|
1052
|
$qtmp->wconfig();
|
1053
|
}
|
1054
|
array_pop($tmppath);
|
1055
|
|
1056
|
$downfactor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}downloadspeed"]);
|
1057
|
$downbw = floatval($config['ezshaper']['step2']["conn{$i}download"]) * $downfactor;
|
1058
|
|
1059
|
$tmppath = array();
|
1060
|
$altq =& new altq_root_queue();
|
1061
|
|
1062
|
$altq->SetInterface($config['ezshaper']['step2']["local{$i}interface"]);
|
1063
|
$altq->SetScheduler($config['ezshaper']['step2']["local{$i}downloadscheduler"]);
|
1064
|
//$altq->SetBandwidth($config['ezshaper']['step2']["conn{$i}download"]);
|
1065
|
//$altq->SetBwscale($config['ezshaper']['step2']["conn{$i}downloadspeed"]);
|
1066
|
$altq->SetEnabled("on");
|
1067
|
$altq_list_queues[$altq->GetQname()] =& $altq;
|
1068
|
array_push($tmppath, $config['ezshaper']['step2']["local{$i}interface"]);
|
1069
|
$altq->SetLink($tmppath);
|
1070
|
//var_dump($input_errors);
|
1071
|
$altq->wconfig();
|
1072
|
|
1073
|
$sched = $config['ezshaper']['step2']["local{$i}downloadscheduler"];
|
1074
|
$voipbw =0;
|
1075
|
$voipbwunit = "%";
|
1076
|
$voip = false;
|
1077
|
$penalty = false;
|
1078
|
$penaltybw = 0;
|
1079
|
$penaltybwunit = "%";
|
1080
|
$p2p = false;
|
1081
|
$p2pcatchall = false;
|
1082
|
$p2pcatchbw = 0;
|
1083
|
$games = false;
|
1084
|
$otherpriority = false;
|
1085
|
$remainbw = 0;
|
1086
|
|
1087
|
if ($config['ezshaper']['step3']['enable']) {
|
1088
|
$voip = true;
|
1089
|
$voipbw = $config['ezshaper']['step3']["local{$i}download"];
|
1090
|
$voipbwunit = $config['ezshaper']['step3']["local{$i}downloadspeed"];
|
1091
|
if ($sched != HFSC) {
|
1092
|
if ($penaltybwunit == "%")
|
1093
|
$factor = $downbw/100;
|
1094
|
else
|
1095
|
$factor = wizard_get_bandwidthtype_scale($voipbwunit);
|
1096
|
$remainbw += floatval($voipbw) * $factor;
|
1097
|
} else
|
1098
|
$remainbw += 32000; /* 32Kbit/s reserved for HFSC linksharing */
|
1099
|
}
|
1100
|
if ($config['ezshaper']['step4']['enable']) {
|
1101
|
$penalty = true;
|
1102
|
$penaltybw = $config['ezshaper']['step4']['bandwidth'];
|
1103
|
$penaltybwunit = $config['ezshaper']['step4']['bandwidthunit'];
|
1104
|
if ($penaltybwunit == "%")
|
1105
|
$factor = $downbw/100;
|
1106
|
else
|
1107
|
$factor = wizard_get_bandwidthtype_scale($penaltybwunit);
|
1108
|
$remainbw += floatval($penaltybw) * $factor;
|
1109
|
} else {
|
1110
|
$penalty = false;
|
1111
|
$penaltybw = 0;
|
1112
|
}
|
1113
|
if ($config['ezshaper']['step5']['enable']) {
|
1114
|
$p2p = true;
|
1115
|
if ($config['ezshaper']['step5']['p2pcatchall']) {
|
1116
|
$p2pcatchall = true;
|
1117
|
$p2pcatchbw = $config['ezshaper']['step5']['bandwidth'];
|
1118
|
$p2pcatchbwunit = $config['ezshaper']['step5']['bandwidthunit'];
|
1119
|
if ($p2pcatchbwunit == "%")
|
1120
|
$factor = $downbw/100;
|
1121
|
else
|
1122
|
$factor = wizard_get_bandwidthtype_scale($p2pcatchbwunit);
|
1123
|
$remainbw += floatval($p2pcatchbw) * $factor;
|
1124
|
} else {
|
1125
|
$p2pcatchall = false;
|
1126
|
$p2pcatchbw = 0;
|
1127
|
}
|
1128
|
} else {
|
1129
|
$p2p = false;
|
1130
|
$p2pcatchall = false;
|
1131
|
$p2pcatchbw = 0;
|
1132
|
}
|
1133
|
if ($config['ezshaper']['step6']['enable']) {
|
1134
|
$games = true;
|
1135
|
} else {
|
1136
|
$games = false;
|
1137
|
}
|
1138
|
|
1139
|
if ($config['ezshaper']['step7']['enable']) {
|
1140
|
$otherpriority = true;
|
1141
|
} else {
|
1142
|
$otherpriority = false;
|
1143
|
}
|
1144
|
$remainbw = round($remainbw / $downbw * 100, 2);
|
1145
|
if (intval($remainbw) > 0 && intval($remainbw) > 40) {
|
1146
|
$savemsg=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue.");
|
1147
|
header("Location: wizard.php?xml=traffic_shaper_wizard_dedicated.xml&stepid=2&message={$savemsg}");
|
1148
|
exit;
|
1149
|
} else {
|
1150
|
$remainbw = 100 - $remainbw;
|
1151
|
}
|
1152
|
|
1153
|
if (!$p2pcatchall) {
|
1154
|
if ($sched == "PRIQ")
|
1155
|
$q =& new priq_queue();
|
1156
|
else if ($sched == "CBQ")
|
1157
|
$q =& new cbq_queue();
|
1158
|
else if ($sched == "HFSC")
|
1159
|
$q =& new hfsc_queue();
|
1160
|
$tmpcf = array();
|
1161
|
$tmpcf['name'] = "qLink";
|
1162
|
$tmpcf['priority'] = 2;
|
1163
|
$tmpcf['enabled'] = "on";
|
1164
|
$tmpcf['default'] = "on";
|
1165
|
$tmpcf['qlimit'] = 500;
|
1166
|
$tmpcf['ecn'] = "on";
|
1167
|
if ($sched == "CBQ") {
|
1168
|
$tmpcf['borrow'] = "on";
|
1169
|
$tmpcf['bandwidth'] = 20; /* 20% bandwidth */
|
1170
|
$tmpcf['bandwidthtype'] = "%";
|
1171
|
} else if ($sched == "HFSC") {
|
1172
|
$tmpcf['bandwidth'] = 20; /* 20% bandwidth */
|
1173
|
$tmpcf['bandwidthtype'] = "%";
|
1174
|
}
|
1175
|
array_push($tmppath, $tmpcf['name']);
|
1176
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
1177
|
array_pop($tmppath);
|
1178
|
//echo "qDefault <br />";
|
1179
|
//var_dump($input_errors);
|
1180
|
$qtmp->wconfig();
|
1181
|
}
|
1182
|
|
1183
|
if ($sched != "PRIQ") {
|
1184
|
if ($sched == "CBQ")
|
1185
|
$q =& new cbq_queue();
|
1186
|
else if ($sched == "HFSC")
|
1187
|
$q =& new hfsc_queue();
|
1188
|
$tmpcf = array();
|
1189
|
$tmpcf['name'] = "qInternet";
|
1190
|
//$tmpcf['priority'] = 6;
|
1191
|
$tmpcf['ecn'] = "on";
|
1192
|
$tmpcf['enabled'] = "on";
|
1193
|
If ($sched == "CBQ") {
|
1194
|
$tmpcf['bandwidth'] = floatval($config['ezshaper']['step2']["conn{$i}download"]);
|
1195
|
$tmpcf['bandwidthtype'] = $config['ezshaper']['step2']["conn{$i}downloadspeed"];
|
1196
|
}
|
1197
|
else if ($sched == "HFSC") {
|
1198
|
$tmpcf['upperlimit'] = "on";
|
1199
|
$tmpcf['upperlimit3'] = floatval($config['ezshaper']['step2']["conn{$i}download"]) . $config['ezshaper']['step2']["conn{$i}downloadspeed"];
|
1200
|
$tmpcf['linkshare'] = "on";
|
1201
|
$tmpcf['linkshare3'] = floatval($config['ezshaper']['step2']["conn{$i}download"]) . $config['ezshaper']['step2']["conn{$i}downloadspeed"];
|
1202
|
$tmpcf['bandwidth'] = floatval($config['ezshaper']['step2']["conn{$i}download"]);
|
1203
|
$tmpcf['bandwidthtype'] = $config['ezshaper']['step2']["conn{$i}downloadspeed"];
|
1204
|
}
|
1205
|
array_push($tmppath, "qInternet");
|
1206
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
1207
|
//array_pop($tmppath);
|
1208
|
//echo "qInternet <br />";
|
1209
|
//var_dump($input_errors);
|
1210
|
$qtmp->wconfig();
|
1211
|
$altq =& $qtmp;
|
1212
|
}
|
1213
|
|
1214
|
if ($sched == "PRIQ")
|
1215
|
$q =& new priq_queue();
|
1216
|
else if ($sched == "CBQ")
|
1217
|
$q =& new cbq_queue();
|
1218
|
else if ($sched == "HFSC")
|
1219
|
$q =& new hfsc_queue();
|
1220
|
$tmpcf = array();
|
1221
|
$tmpcf['name'] = "qACK";
|
1222
|
$tmpcf['priority'] = 6;
|
1223
|
$tmpcf['ecn'] = "on";
|
1224
|
$tmpcf['enabled'] = "on";
|
1225
|
If ($sched == "CBQ") {
|
1226
|
$tmpcf['borrow'] = "on";
|
1227
|
$tmpcf['bandwidth'] = $remainbw * 0.2;
|
1228
|
$tmpcf['bandwidthtype'] = "%";
|
1229
|
} else if ($sched == "HFSC") {
|
1230
|
$lkbw = 0.20 * $remainbw;
|
1231
|
$tmpcf['linkshare3'] = "{$lkbw}%";
|
1232
|
$tmpcf['linkshare'] = "on";
|
1233
|
$tmpcf['bandwidth'] = $lkbw;
|
1234
|
$tmpcf['bandwidthtype'] = "%";
|
1235
|
}
|
1236
|
array_push($tmppath, "qACK");
|
1237
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
1238
|
array_pop($tmppath);
|
1239
|
//echo "qACK $remainbw <br />";
|
1240
|
//var_dump($input_errors);
|
1241
|
$qtmp->wconfig();
|
1242
|
|
1243
|
if ($p2p) {
|
1244
|
if ($sched == "PRIQ")
|
1245
|
$q =& new priq_queue();
|
1246
|
else if ($sched == "CBQ")
|
1247
|
$q =& new cbq_queue();
|
1248
|
else if ($sched == "HFSC")
|
1249
|
$q =& new hfsc_queue();
|
1250
|
$tmpcf = array();
|
1251
|
$tmpcf['name'] = "qP2P";
|
1252
|
$tmpcf['priority'] = 1;
|
1253
|
$tmpcf['ecn'] = "on";
|
1254
|
$tmpcf['enabled'] = "on";
|
1255
|
if ($p2pcatchall) {
|
1256
|
if ($sched == "CBQ") {
|
1257
|
$tmpcf['borrow'] = "on";
|
1258
|
$tmpcf['bandwidth'] = $p2pcatchbw;
|
1259
|
$tmpcf['bandwidthtype'] = $p2pcatchbwunit;
|
1260
|
} else if ($sched == "HFSC") {
|
1261
|
$tmpcf['linkshare'] = "on";
|
1262
|
$tmpcf['linkshare3'] = "{$p2pcatchbw}{$p2pcatchbwunit}";
|
1263
|
$tmpcf['upperlimit'] = "on";
|
1264
|
$tmpcf['upperlimit3'] = "{$p2pcatchbw}{$p2pcatchbwunit}";
|
1265
|
$tmpcf['bandwidth'] = $p2pcatchbw;
|
1266
|
$tmpcf['bandwidthtype'] = $p2pcatchbwunit;
|
1267
|
}
|
1268
|
$tmpcf['default'] = "on";
|
1269
|
$tmpcf['qlimit'] = 500;
|
1270
|
} else {
|
1271
|
if ($sched == "CBQ") {
|
1272
|
$tmpcf['borrow'] = "on";
|
1273
|
$tmpcf['bandwidth'] = $remainbw * 0.05; /* 5% bandwidth */
|
1274
|
$tmpcf['bandwidthtype'] = "%";
|
1275
|
} else if ($sched == "HFSC") {
|
1276
|
$tmpbw = $remainbw * 0.05; /* 5% bandwidth */
|
1277
|
$tmpcf['linkshare'] = "on";
|
1278
|
$tmpcf['linkshare3'] = "{$tmpbw}%";
|
1279
|
$tmpcf['upperlimit'] = "on";
|
1280
|
$tmpcf['upperlimit3'] = "{$tmpbw}%";
|
1281
|
$tmpcf['bandwidth'] = $tmpbw;
|
1282
|
$tmpcf['bandwidthtype'] = "%";
|
1283
|
}
|
1284
|
}
|
1285
|
array_push($tmppath, "qP2P");
|
1286
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
1287
|
array_pop($tmppath);
|
1288
|
//echo "qP2P <br />";
|
1289
|
//var_dump($input_errors);
|
1290
|
$qtmp->wconfig();
|
1291
|
}
|
1292
|
|
1293
|
if ($voip) {
|
1294
|
if ($sched == "PRIQ")
|
1295
|
$q =& new priq_queue();
|
1296
|
else if ($sched == "CBQ")
|
1297
|
$q =& new cbq_queue();
|
1298
|
else if ($sched == "HFSC")
|
1299
|
$q =& new hfsc_queue();
|
1300
|
$tmpcf = array();
|
1301
|
$tmpcf['name'] = "qVoIP";
|
1302
|
$tmpcf['priority'] = 7;
|
1303
|
$tmpcf['ecn'] = "on";
|
1304
|
$tmpcf['enabled'] = "on";
|
1305
|
if ($sched == "CBQ") {
|
1306
|
$tmpcf['borrow'] = "on";
|
1307
|
if ($voipbw > 0) {
|
1308
|
$tmpcf['bandwidth'] = $voipbw;
|
1309
|
$tmpcf['bandwidthtype'] = $voipbwunit;
|
1310
|
} else {
|
1311
|
$tmpcf['bandwidth'] = $remainbw * 0.2; /* 20% bandwidth */
|
1312
|
$tmpcf['bandwidthtype'] = "%";
|
1313
|
}
|
1314
|
} else if ($sched == "HFSC") {
|
1315
|
if ($voipbw > 0) {
|
1316
|
$tmpcf['realtime3'] = "{$voipbw}{$voipbwunit}";
|
1317
|
} else {
|
1318
|
$voipbw = $remainbw * 0.20; /* 20% bandwidth */
|
1319
|
$tmpcf['realtime3'] = "{$voipbw}%";
|
1320
|
}
|
1321
|
$tmpcf['realtime'] = "on";
|
1322
|
$tmpcf['bandwidth'] = 32;
|
1323
|
$tmpcf['bandwidthtype'] = "Kb";
|
1324
|
}
|
1325
|
array_push($tmppath, "qVoIP");
|
1326
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
1327
|
array_pop($tmppath);
|
1328
|
//echo "qVoIP <br />";
|
1329
|
//var_dump($input_errors);
|
1330
|
$qtmp->wconfig();
|
1331
|
}
|
1332
|
|
1333
|
if ($games) {
|
1334
|
if ($sched == "PRIQ")
|
1335
|
$q =& new priq_queue();
|
1336
|
else if ($sched == "CBQ")
|
1337
|
$q =& new cbq_queue();
|
1338
|
else if ($sched == "HFSC")
|
1339
|
$q =& new hfsc_queue();
|
1340
|
$tmpcf = array();
|
1341
|
$tmpcf['name'] = "qGames";
|
1342
|
$tmpcf['priority'] = 5;
|
1343
|
$tmpcf['enabled'] = "on";
|
1344
|
$tmpcf['ecn'] = "on";
|
1345
|
if ($sched == "CBQ") {
|
1346
|
$tmpcf['borrow'] = "on";
|
1347
|
$tmpcf['bandwidth'] = $remainbw * 0.2; /* 20% bandwidth */
|
1348
|
$tmpcf['bandwidthtype'] = "%";
|
1349
|
} else if ($sched == "HFSC") {
|
1350
|
$gamesbw = $remainbw * 0.2; /* 20% bandwidth */
|
1351
|
$tmpcf['linkshare'] = "on";
|
1352
|
$tmpcf['linkshare3'] = "{$gamesbw}%";
|
1353
|
$tmpcf['bandwidth'] = "{$gamesbw}";
|
1354
|
$tmpcf['bandwidthtype'] = "%";
|
1355
|
}
|
1356
|
array_push($tmppath, "qGames");
|
1357
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
1358
|
array_pop($tmppath);
|
1359
|
//echo "qGames <br />";
|
1360
|
//var_dump($input_errors);
|
1361
|
$qtmp->wconfig();
|
1362
|
}
|
1363
|
|
1364
|
if ($otherpriority) {
|
1365
|
if ($sched == "PRIQ")
|
1366
|
$q =& new priq_queue();
|
1367
|
else if ($sched == "CBQ")
|
1368
|
$q =& new cbq_queue();
|
1369
|
else if ($sched == "HFSC")
|
1370
|
$q =& new hfsc_queue();
|
1371
|
$tmpcf = array();
|
1372
|
$tmpcf['name'] = "qOthersHigh";
|
1373
|
$tmpcf['priority'] = 4;
|
1374
|
$tmpcf['ecn'] = "on";
|
1375
|
$tmpcf['enabled'] = "on";
|
1376
|
if ($sched == "CBQ") {
|
1377
|
$tmpcf['borrow'] = "on";
|
1378
|
$tmpcf['bandwidth'] = $remainbw * 0.1; /* 10% bandwidth */
|
1379
|
$tmpcf['bandwidthtype'] = "%";
|
1380
|
} else if ($sched == "HFSC") {
|
1381
|
$tmpcf['linkshare'] = "on";
|
1382
|
$otherbw = $remainbw * 0.1; /* 10% bandwidth */
|
1383
|
$tmpcf['linkshare3'] = "{$otherbw}%";
|
1384
|
$tmpcf['bandwidth'] = $otherbw;
|
1385
|
$tmpcf['bandwidthtype'] = "%";
|
1386
|
}
|
1387
|
array_push($tmppath, "qOthersHigh");
|
1388
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
1389
|
array_pop($tmppath);
|
1390
|
//echo "qHigh <br />";
|
1391
|
//var_dump($input_errors);
|
1392
|
$qtmp->wconfig();
|
1393
|
|
1394
|
if ($sched == "PRIQ")
|
1395
|
$q =& new priq_queue();
|
1396
|
else if ($sched == "CBQ")
|
1397
|
$q =& new cbq_queue();
|
1398
|
else if ($sched == "HFSC")
|
1399
|
$q =& new hfsc_queue();
|
1400
|
$tmpcf = array();
|
1401
|
$tmpcf['name'] = "qOthersLow";
|
1402
|
$tmpcf['priority'] = 3;
|
1403
|
$tmpcf['ecn'] = "on";
|
1404
|
$tmpcf['enabled'] = "on";
|
1405
|
if ($sched == "CBQ") {
|
1406
|
$tmpcf['borrow'] = "on";
|
1407
|
if ($penalty) {
|
1408
|
$tmpcf['bandwidth'] = $penaltybw;
|
1409
|
$tmpcf['bandwidthtype'] = $penaltybwunit;
|
1410
|
} else {
|
1411
|
$tmpcf['bandwidthtype'] = "%";
|
1412
|
$tmpcf['bandwidth'] = $remainbw * 0.05; /* 5% bandwidth */
|
1413
|
}
|
1414
|
} else if ($sched == "HFSC") {
|
1415
|
if ($penalty) {
|
1416
|
$tmpcf['linkshare3'] = "{$penaltybw}{$penaltybwunit}";
|
1417
|
$tmpcf['bandwidth'] = $penaltybw;
|
1418
|
$tmpcf['bandwidthtype'] = $penaltybwunit;
|
1419
|
} else {
|
1420
|
$lsbw = $remainbw * 0.05;
|
1421
|
$tmpcf['linkshare3'] = "{$lsbw}%"; /* 5% bandwidth */
|
1422
|
$tmpcf['bandwidth'] = $lsbw;
|
1423
|
$tmpcf['bandwidthtype'] = "%";
|
1424
|
}
|
1425
|
$tmpcf['linkshare'] = "on";
|
1426
|
}
|
1427
|
array_push($tmppath, "qOthersLow");
|
1428
|
$qtmp =& $altq->add_queue($q, $tmpcf, $tmppath, $input_errors);
|
1429
|
array_pop($tmppath);
|
1430
|
//echo "qLow <br />";
|
1431
|
//var_dump($input_errors);
|
1432
|
$qtmp->wconfig();
|
1433
|
}
|
1434
|
array_pop($tmppath);
|
1435
|
}
|
1436
|
|
1437
|
if (!is_array($config['filter']['rule']))
|
1438
|
$config['filter']['rule'] = array();
|
1439
|
|
1440
|
$interfacelist = implode(",", $interfacelist);
|
1441
|
|
1442
|
/* Rules */
|
1443
|
if ($penalty) {
|
1444
|
if( is_ipaddr($config['ezshaper']['step4']['address']) || is_alias($config['ezshaper']['step4']['address'])) {
|
1445
|
$rule = array();
|
1446
|
$rule['type'] = "match";
|
1447
|
$rule['interface'] = $interfacelist;
|
1448
|
$rule['descr'] = gettext("Penalty Box");
|
1449
|
$rule['defaultqueue'] = "qOthersLow";
|
1450
|
$rule['source']['address'] = $config['ezshaper']['step4']['address'];
|
1451
|
$rule['destination']['any'] = TRUE;
|
1452
|
$rule['floating'] = "yes";
|
1453
|
$rule['wizard'] = "yes";
|
1454
|
$rule['enabled'] = "on";
|
1455
|
$rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard"));
|
1456
|
$config['filter']['rule'][] = $rule;
|
1457
|
}
|
1458
|
}
|
1459
|
|
1460
|
/* If user specifies an IP, we don't bother with providers */
|
1461
|
if ($voip) {
|
1462
|
if( is_ipaddr($config['ezshaper']['step3']['address']) || is_alias($config['ezshaper']['step3']['address'])) {
|
1463
|
/* create VOIP rules */
|
1464
|
$rule = array();
|
1465
|
$rule['type'] = "match";
|
1466
|
//$rule['interface'] = $interfacelist;
|
1467
|
$rule['descr'] = gettext("Connections From Upstream SIP Server");
|
1468
|
$rule['protocol'] = "udp";
|
1469
|
$rule['defaultqueue'] = "qVoIP";
|
1470
|
$rule['source']['address'] = $config['ezshaper']['step3']['address'];
|
1471
|
$rule['destination']['any'] = TRUE;
|
1472
|
$rule['floating'] = "yes";
|
1473
|
$rule['wizard'] = "yes";
|
1474
|
$rule['enabled'] = "on";
|
1475
|
$rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard"));
|
1476
|
$config['filter']['rule'][] = $rule;
|
1477
|
|
1478
|
$rule = array();
|
1479
|
$rule['type'] = "match";
|
1480
|
//$rule['interface'] = $interfacelist;
|
1481
|
$rule['descr'] = gettext("Connections To Upstream SIP Server");
|
1482
|
$rule['protocol'] = "udp";
|
1483
|
$rule['defaultqueue'] = "qVoIP";
|
1484
|
$rule['source']['any'] = TRUE;
|
1485
|
$rule['destination']['address'] = $config['ezshaper']['step3']['address'];
|
1486
|
$rule['floating'] = "yes";
|
1487
|
$rule['wizard'] = "yes";
|
1488
|
$rule['enabled'] = "on";
|
1489
|
$rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard"));
|
1490
|
$config['filter']['rule'][] = $rule;
|
1491
|
|
1492
|
} elseif( $config['ezshaper']['step3']['provider'] == "Generic" ) {
|
1493
|
/* create VOIP rules */
|
1494
|
$rule = array();
|
1495
|
$rule['type'] = "match";
|
1496
|
$rule['interface'] = $interfacelist;
|
1497
|
$rule['descr'] = "DiffServ/Lowdelay/Upload";
|
1498
|
$rule['protocol'] = "udp";
|
1499
|
$rule['source']['any'] = TRUE;
|
1500
|
$rule['defaultqueue'] = "qVoIP";
|
1501
|
$rule['destination']['any'] = TRUE;
|
1502
|
$rule['iptos'] = "lowdelay";
|
1503
|
$rule['floating'] = "yes";
|
1504
|
$rule['wizard'] = "yes";
|
1505
|
$rule['enabled'] = "on";
|
1506
|
$rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard"));
|
1507
|
$config['filter']['rule'][] = $rule;
|
1508
|
|
1509
|
} else {
|
1510
|
/* loop through voiplist[] */
|
1511
|
foreach ($voiplist[$config['ezshaper']['step3']['provider']] as $voip) {
|
1512
|
$rule = array();
|
1513
|
$rule['type'] = "match";
|
1514
|
$rule['interface'] = $interfacelist;
|
1515
|
$rule['defaultqueue'] = 'qVoIP';
|
1516
|
$rule['source']['any'] = TRUE;
|
1517
|
$rule['destination']['any'] = TRUE;
|
1518
|
$rule['descr'] = "m_voip {$voip[0]} outbound";
|
1519
|
$rule['floating'] = "yes";
|
1520
|
$rule['wizard'] = "yes";
|
1521
|
$rule['enabled'] = "on";
|
1522
|
$rule['destination']['port'] = $voip[2]."-".$voip[3];
|
1523
|
if($voip[1] != '')
|
1524
|
$rule['protocol'] = $voip[1];
|
1525
|
$rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard"));
|
1526
|
$config['filter']['rule'][] = $rule;
|
1527
|
}
|
1528
|
}
|
1529
|
}
|
1530
|
|
1531
|
/* loop through p2plist[] */
|
1532
|
if ($p2p) {
|
1533
|
foreach($config['ezshaper']['step5'] as $key => $val) {
|
1534
|
if (!is_array($p2plist[$key]))
|
1535
|
continue;
|
1536
|
foreach ($p2plist[$key] as $p2pclient) {
|
1537
|
$rule = array();
|
1538
|
$rule['type'] = "match";
|
1539
|
$rule['interface'] = $interfacelist;
|
1540
|
$rule['defaultqueue'] = 'qP2P';
|
1541
|
$rule['source']['any'] = TRUE;
|
1542
|
$rule['destination']['any'] = TRUE;
|
1543
|
$rule['descr'] = "m_P2P {$p2pclient[0]} outbound";
|
1544
|
$rule['floating'] = "yes";
|
1545
|
$rule['wizard'] = "yes";
|
1546
|
$rule['destination']['port'] = $p2pclient[2]."-".$p2pclient[3];
|
1547
|
if($p2pclient[1] != '')
|
1548
|
$rule['protocol'] = $p2pclient[1];
|
1549
|
$rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard"));
|
1550
|
$config['filter']['rule'][] = $rule;
|
1551
|
}
|
1552
|
}
|
1553
|
}
|
1554
|
|
1555
|
/* loop through gamesplist[] */
|
1556
|
if ($games) {
|
1557
|
foreach($config['ezshaper']['step6'] as $key => $val) {
|
1558
|
if (!is_array($gamesplist[$key]))
|
1559
|
continue;
|
1560
|
foreach ($gamesplist[$key] as $Gameclient) {
|
1561
|
$rule = array();
|
1562
|
$rule['type'] = "match";
|
1563
|
$rule['interface'] = $interfacelist;
|
1564
|
$rule['defaultqueue'] = 'qGames';
|
1565
|
if ($Gameclient[1] == "tcp")
|
1566
|
$rule['ackqueue'] = 'qACK';
|
1567
|
$rule['source']['any'] = TRUE;
|
1568
|
$rule['destination']['any'] = TRUE;
|
1569
|
$rule['floating'] = "yes";
|
1570
|
$rule['wizard'] = "yes";
|
1571
|
$rule['enabled'] = "on";
|
1572
|
$rule['descr'] = "m_Game {$Gameclient[0]} outbound";
|
1573
|
$rule['destination']['port'] = $Gameclient[2]."-".$Gameclient[3];
|
1574
|
if($Gameclient[1] != '')
|
1575
|
$rule['protocol'] = $Gameclient[1];
|
1576
|
$config['filter']['rule'][] = $rule;
|
1577
|
}
|
1578
|
}
|
1579
|
}
|
1580
|
|
1581
|
/* loop through othersplist[] */
|
1582
|
if ($otherpriority) {
|
1583
|
foreach($config['ezshaper']['step7'] as $key => $val) {
|
1584
|
if (!is_array($othersplist[$key]))
|
1585
|
continue;
|
1586
|
foreach ($othersplist[$key] as $otherclient) {
|
1587
|
$rule = array();
|
1588
|
$rule['type'] = "match";
|
1589
|
$rule['interface'] = $interfacelist;
|
1590
|
switch ($val) {
|
1591
|
case "H":
|
1592
|
$rule['defaultqueue'] = 'qOthersHigh'; /* posted value H or L */
|
1593
|
if ($otherclient[1] == "tcp")
|
1594
|
$rule['ackqueue'] = 'qACK';
|
1595
|
$loop = 0;
|
1596
|
break;
|
1597
|
case "L":
|
1598
|
$rule['defaultqueue'] = 'qOthersLow'; /* posted value H or L */
|
1599
|
if ($otherclient[1] == "tcp")
|
1600
|
$rule['ackqueue'] = 'qACK';
|
1601
|
$loop = 0;
|
1602
|
break;
|
1603
|
case "D":
|
1604
|
if ($p2pcatchall) {
|
1605
|
$loop = 0;
|
1606
|
$rule['defaultqueue'] = 'qOthersDefault';
|
1607
|
if ($otherclient[1] == "tcp")
|
1608
|
$rule['ackqueue'] = 'qACK';
|
1609
|
} else
|
1610
|
$loop = 1; /* It automitaclly goes to default queue */
|
1611
|
break;
|
1612
|
default:
|
1613
|
$loop = 1;
|
1614
|
}
|
1615
|
if (!$loop) {
|
1616
|
$rule['source']['any'] = TRUE;
|
1617
|
$rule['destination']['any'] = TRUE;
|
1618
|
$rule['floating'] = "yes";
|
1619
|
$rule['wizard'] = "yes";
|
1620
|
$rule['enabled'] = "on";
|
1621
|
$rule['descr'] = "m_Other {$otherclient[0]} outbound";
|
1622
|
|
1623
|
if($otherclient[2] or $otherclient[3]) {
|
1624
|
$rule['destination']['port'] = $otherclient[2]."-".$otherclient[3];
|
1625
|
}
|
1626
|
if($otherclient[1] != '')
|
1627
|
$rule['protocol'] = $otherclient[1];
|
1628
|
$rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard"));
|
1629
|
$config['filter']['rule'][] = $rule;
|
1630
|
}
|
1631
|
}
|
1632
|
}
|
1633
|
}
|
1634
|
write_config();
|
1635
|
}
|
1636
|
|
1637
|
function wizard_get_bandwidthtype_scale($type = "b") {
|
1638
|
switch ($type) {
|
1639
|
case "Gb":
|
1640
|
$factor = 1024 * 1024 * 1024;
|
1641
|
break;
|
1642
|
case "Mb":
|
1643
|
$factor = 1024 * 1024;
|
1644
|
break;
|
1645
|
case "Kb":
|
1646
|
$factor = 1024;
|
1647
|
break;
|
1648
|
case "b":
|
1649
|
default:
|
1650
|
$factor = 1;
|
1651
|
break;
|
1652
|
}
|
1653
|
return intval($factor);
|
1654
|
}
|
1655
|
|
1656
|
?>
|