diff options
author | Ermal Luçi <eri@pfsense.org> | 2008-03-04 18:29:38 +0000 |
---|---|---|
committer | Ermal Luçi <eri@pfsense.org> | 2008-03-04 18:29:38 +0000 |
commit | 3a54efed1a5beab4faef6337105838120d541d56 (patch) | |
tree | bb874aa47340f5c85607e8edfa28fedf894b80de | |
parent | 90923e0998d6c7be9174b4f3cd166a3f21bbf001 (diff) | |
download | pfsense-3a54efed1a5beab4faef6337105838120d541d56.zip pfsense-3a54efed1a5beab4faef6337105838120d541d56.tar.gz |
s/intval/floatval/
fix settings for CBQ where setting of bandwidth was wrong in some places
-rw-r--r-- | etc/inc/shaper.inc | 44 | ||||
-rw-r--r-- | usr/local/www/wizards/traffic_shaper_wizard.inc | 46 |
2 files changed, 38 insertions, 52 deletions
diff --git a/etc/inc/shaper.inc b/etc/inc/shaper.inc index fe364e5..0448339 100644 --- a/etc/inc/shaper.inc +++ b/etc/inc/shaper.inc @@ -99,7 +99,7 @@ function get_bandwidthtype_scale($type) { $factor = 1; break; } - return intval($factor); + return floatval($factor); } function get_hfsc_bandwidth($object, $bw) { @@ -118,7 +118,7 @@ function get_hfsc_bandwidth($object, $bw) { $bw_1 = $bw_1 * get_bandwidthtype_scale($match[0]); break; } - return intval($bw_1); + return floatval($bw_1); } else return 0; } @@ -131,7 +131,7 @@ function get_interface_bandwidth($object) { if ($altq) { $bw_3 = $altq->GetBandwidth(); $bw_3 = $bw_3 * get_bandwidthtype_scale($altq->GetBwscale()); - return intval($bw_3); + return floatval($bw_3); } else return 0; } @@ -238,7 +238,7 @@ class altq_root_queue { return $this->bandwidth; } function SetBandwidth($bw) { - $this->bandwidth = trim($bw); + $this->bandwidth = $bw; } function GetBwscale() { return $this->bandwidthtype; @@ -268,20 +268,6 @@ class altq_root_queue { shaper_do_input_validation($data, $reqdfields, $reqdfieldsn, $input_errors); - switch($data['banwidthtype']) { - case "%": - $myBw = $this->GetAvailableBandwidth() * intval($data['bandwidth']) / 100; - break; - default: - $myBw = intval($data['bandwidth']) * get_bandwidthtype_scale($data['banwidthtype']) -; - break; - } - - if ($this->GetAvailableBandwidth() < $myBw) - $input_errors[] = "Bandwidth cannot be set higher than that of interface."; - - if ($data['bandwidth'] && (!is_numeric($data['bandwidth']))) $input_errors[] = "Bandwidth must be an integer."; if ($data['bandwidth'] < 0) @@ -1312,9 +1298,9 @@ class hfsc_queue extends priq_queue { $parent =& $this->GetParent(); switch ($data['bandwidthtype']) { case "%": - $myBw = $parent->GetAvailableBandwidth() * intval($data['bandwidth']) / 100; + $myBw = $parent->GetAvailableBandwidth() * floatval($data['bandwidth']) / 100; default: - $mybw = intval($data['bandwiddth']) * get_bandwidthtype_scale($data['bandwidthtype']); + $mybw = floatval($data['bandwiddth']) * get_bandwidthtype_scale($data['bandwidthtype']); break; } if ($parent->GetAvailableBandwidth() < $myBw) @@ -1337,11 +1323,11 @@ class hfsc_queue extends priq_queue { if (isset($data['upperlimit']) && $data['upperlimit3'] <> "" && $data['upperlimit1'] <> "") { $bw_1 = get_hfsc_bandwidth($this, $data['upperlimit1']); $bw_2 = get_hfsc_bandwidth($this, $data['upperlimit3']); - if (intval($bw_1) < intval($bw_2)) + if (floatval($bw_1) < floatval($bw_2)) $input_errors[] = ("upperlimit m1 cannot be smaller than m2"); - if (get_interface_bandwidth($this) < (0.8 * (intval($bw_1) + intval($bw_2)))) + if (get_interface_bandwidth($this) < (0.8 * (floatval($bw_1) + floatval($bw_2)))) $input_errors[] = ("upperlimit specification excedd 80% of allowable allocation."); } if ($data['linkshare1'] <> "" && $data['linkshare2'] == "") @@ -1362,11 +1348,11 @@ class hfsc_queue extends priq_queue { if (isset($data['linkshare']) && $data['linkshare3'] <> "" && $data['linkshare1'] <> "") { $bw_1 = get_hfsc_bandwidth($this, $data['linkshare1']); $bw_2 = get_hfsc_bandwidth($this, $data['linkshare3']); - if (intval($bw_1) < intval($bw_2)) + if (floatval($bw_1) < floatval($bw_2)) $input_errors[] = ("linkshare m1 cannot be smaller than m2"); - if (get_interface_bandwidth($this) < (0.8 * (intval($bw_1) + intval($bw_2)))) + if (get_interface_bandwidth($this) < (0.8 * (floatval($bw_1) + floatval($bw_2)))) $input_errors[] = ("linkshare specification excedd 80% of allowable allocation."); } if ($data['realtime1'] <> "" && !is_valid_shaperbw($data['realtime1'])) @@ -1379,11 +1365,11 @@ class hfsc_queue extends priq_queue { if (isset($data['realtime']) && $data['realtime3'] <> "" && $data['realtime1'] <> "") { $bw_1 = get_hfsc_bandwidth($this, $data['realtime1']); $bw_2 = get_hfsc_bandwidth($this, $data['realtime3']); - if (intval($bw_1) < intval($bw_2)) + if (floatval($bw_1) < floatval($bw_2)) $input_errors[] = ("realtime m1 cannot be smaller than m2"); - if (get_interface_bandwidth($this) < (0.8 * (intval($bw_1) + intval($bw_2)))) + if (get_interface_bandwidth($this) < (0.8 * (floatval($bw_1) + floatval($bw_2)))) $input_errors[] = ("realtime specification excedd 80% of allowable allocation."); } @@ -1837,12 +1823,12 @@ class cbq_queue extends priq_queue { $parent =& $this->GetParent(); switch ($data['bandwidthtype']) { case "%": - $myBw = $parent->GetAvailableBandwidth() * intval($data['bandwidth']) / 100; + $myBw = $parent->GetAvailableBandwidth() * floatval($data['bandwidth']) / 100; default: - $mybw = intval($data['bandwiddth']) * get_bandwidthtype_scale($data['bandwidthtype']); + $mybw = floatval($data['bandwiddth']) * get_bandwidthtype_scale($data['bandwidthtype']); break; } - if ($parent->GetAvailableBandwidth() < intval($myBw)) + if ($parent->GetAvailableBandwidth() < floatval($myBw)) $input_errors[] = "The sum of child bandwidths exceeds that of the parent."; } function ReadConfig(&$q) { diff --git a/usr/local/www/wizards/traffic_shaper_wizard.inc b/usr/local/www/wizards/traffic_shaper_wizard.inc index 6863a9e..38607e6 100644 --- a/usr/local/www/wizards/traffic_shaper_wizard.inc +++ b/usr/local/www/wizards/traffic_shaper_wizard.inc @@ -86,7 +86,7 @@ function step1_submitphpaction() { header("Location:wizard.php?xml=traffic_shaper_wizard.xml&stepid=0&message={$message}"); exit; } - if (intval($_POST['numberofconnections']) > 100 || intval($_POST['numberofconnections']) < 1) { + if (floatval($_POST['numberofconnections']) > 100 || floatval($_POST['numberofconnections']) < 1) { $message=gettext("The number of connections supported is between 1 and 100."); header("Location:wizard.php?xml=traffic_shaper_wizard.xml&stepid=0&message={$message}"); exit; @@ -103,7 +103,7 @@ function step1_submitphpaction() { $numberofinterfaces++; $iflist[] = $if; } - if ($numberofinterfaces < intval($_POST['numberofconnections'])) { + if ($numberofinterfaces < floatval($_POST['numberofconnections'])) { $message=gettext("You have less interfaces than number of connections!"); header("Location:wizard.php?xml=traffic_shaper_wizard.xml&stepid=0&message={$message}"); exit; @@ -378,7 +378,7 @@ function step2_stepsubmitphpaction() { global $config; $sumdownloads = 0; - $steps = intval($config['ezshaper']['step1']['numberofconnections']); + $steps = floatval($config['ezshaper']['step1']['numberofconnections']); for ($i = 0; $i < $steps; $i++) { for ($j = $j; $j < $steps; $j++) { if ($_POST["conn{$i}interface"] == $_POST["conn{$j}interface"]) { @@ -396,8 +396,8 @@ function step2_stepsubmitphpaction() { header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=1&message={$message}"); exit; } - $upbw = intval($_POST["conn{$i}upload"]); - $downbw = intval($_POST["conn{$i}download"]); + $upbw = floatval($_POST["conn{$i}upload"]); + $downbw = floatval($_POST["conn{$i}download"]); if ($upbw == 0 || $downbw = 0) { $message = gettext("You cannot specify 0 bandwidth!") ; @@ -433,7 +433,7 @@ function step3_stepsubmitphpaction() { } } - $steps = intval($config['ezshaper']['step1']['numberofconnections']); + $steps = floatval($config['ezshaper']['step1']['numberofconnections']); for ($i = 0; $i < $steps; $i++) { if ($_POST["conn{$i}upload"]) { if (!is_numeric($_POST["conn{$i}upload"])) { @@ -442,9 +442,9 @@ function step3_stepsubmitphpaction() { exit; } $factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}uploadspeed"]); - $ifbw = $factor * intval($config['ezshaper']['step2']["conn{$i}upload"]); + $ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}upload"]); $factor = wizard_get_bandwidthtype_scale($_POST["conn{$i}uploadspeed"]); - $input_bw = $factor * intval($_POST["conn{$i}upload"]); + $input_bw = $factor * floatval($_POST["conn{$i}upload"]); if ((0.8 * $ifbw) < $input_bw) { $message=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection."); header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=2&message={$message}"); @@ -526,8 +526,8 @@ function step8_stepsubmitphpaction() { apply_all_choosen_items(); /* reset rrd queues */ - system("rm -f /var/db/rrd/wan-queuesdrop.rrd"); - system("rm -f /var/db/rrd/wan-queues.rrd"); + system("rm -f /var/db/rrd/*queuedrops.rrd"); + system("rm -f /var/db/rrd/*queues.rrd"); enable_rrd_graphing(); /* apply the new configuration to the system */ @@ -888,11 +888,11 @@ $othersplist = array(); $altq_list_queues = array(); $tmppath = array(); - $steps = intval($config['ezshaper']['step1']['numberofconnections']); + $steps = floatval($config['ezshaper']['step1']['numberofconnections']); $lanbw = 0; for ($i = 0; $i < $steps; $i++) { $down = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}downloadspeed"]); - $input_bw = intval($config['ezshaper']['step2']["conn{$i}download"]) * $down; + $input_bw = $config['ezshaper']['step2']["conn{$i}download"] * $down; $lanbw += $input_bw; } @@ -902,7 +902,7 @@ $othersplist = array(); $altq->SetInterface($config['ezshaper']['step2']["conn{$i}interface"]); $altq->SetScheduler($config['ezshaper']['step2']["conn{$i}uploadscheduler"]); - $altq->SetBandwidth(intval($config['ezshaper']['step2']["conn{$i}upload"])); + $altq->SetBandwidth(floatval($config['ezshaper']['step2']["conn{$i}upload"])); $altq->SetBwscale($config['ezshaper']['step2']["conn{$i}uploadspeed"]); $altq->SetEnabled("on"); $altq_list_queues[$altq->GetQname()] =& $altq; @@ -925,7 +925,7 @@ $othersplist = array(); $otherpriority = false; $remainbw = 0; $upfactor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}uploadspeed"]); - $upbw = intval($config['ezshaper']['step2']["conn{$i}upload"]) * $upfactor; + $upbw = floatval($config['ezshaper']['step2']["conn{$i}upload"]) * $upfactor; if ($config['ezshaper']['step3']['enable']) { $voip = true; @@ -936,7 +936,7 @@ $othersplist = array(); $penalty = true; $penaltybw = $config['ezshaper']['step4']['bandwidth']; $penaltybwunit = $config['ezshaper']['step4']['bandwidthunit']; - $remainbw += intval($config['ezshaper']['step4']['bandwidth']) * $config['ezshaper']['step4']['bandwidthunit']; + $remainbw += floatval($config['ezshaper']['step4']['bandwidth']) * $config['ezshaper']['step4']['bandwidthunit']; } else { $penalty = false; $penaltybw = 0; @@ -947,7 +947,7 @@ $othersplist = array(); $p2pcatchall = true; $p2pcatchbw = $config['ezshaper']['step5']['bandwidth']; $p2pcatchbwunit = $config['ezshaper']['step5']['bandwidthunit']; - $remainbw += intval($config['ezshaper']['step5']['bandwidth']) * $config['ezshaper']['step5']['bandwidthunit']; + $remainbw += floatval($config['ezshaper']['step5']['bandwidth']) * $config['ezshaper']['step5']['bandwidthunit']; } else { $p2pcatchall = false; $p2pcatchbw = 0; @@ -1112,8 +1112,8 @@ $othersplist = array(); if ($sched == "CBQ") { $tmpcf['borrow'] = "on"; if ($voipbw > 0) { - $tmpcf['bandwidthtype'] = $voipbw; - $tmpcf['bandwidth'] = $voipbwunit; + $tmpcf['bandwidth'] = $voipbw; + $tmpcf['bandwidthtype'] = $voipbwunit; } else { $tmpcf['bandwidth'] = $remainbw * 0.2; /* 20% bandwidth */ $tmpcf['bandwidthtype'] = "%"; @@ -1289,7 +1289,7 @@ $othersplist = array(); $penalty = true; $penaltybw = $config['ezshaper']['step4']['bandwidth']; $penaltybwunit = $config['ezshaper']['step4']['bandwidthunit']; - $remainbw += intval($config['ezshaper']['step4']['bandwidth']) * $config['ezshaper']['step4']['bandwidthunit']; + $remainbw += floatval($config['ezshaper']['step4']['bandwidth']) * $config['ezshaper']['step4']['bandwidthunit']; } else { $penalty = false; $penaltybw = 0; @@ -1300,7 +1300,7 @@ $othersplist = array(); $p2pcatchall = true; $p2pcatchbw = $config['ezshaper']['step5']['bandwidth']; $p2pcatchbwunit = $config['ezshaper']['step5']['bandwidthunit']; - $remainbw += intval($config['ezshaper']['step5']['bandwidth']) * $config['ezshaper']['step5']['bandwidthunit']; + $remainbw += floatval($config['ezshaper']['step5']['bandwidth']) * $config['ezshaper']['step5']['bandwidthunit']; } else { $p2pcatchall = false; $p2pcatchbw = 0; @@ -1465,8 +1465,8 @@ $othersplist = array(); if ($sched == "CBQ") { $tmpcf['borrow'] = "on"; if ($voipbw > 0) { - $tmpcf['bandwidthtype'] = $voipbw; - $tmpcf['bandwidth'] = $voipbwunit; + $tmpcf['bandwidth'] = $voipbw; + $tmpcf['bandwidthtype'] = $voipbwunit; } else { $tmpcf['bandwidth'] = $remainbw * 0.2; /* 20% bandwidth */ $tmpcf['bandwidthtype'] = "%"; @@ -1795,7 +1795,7 @@ function wizard_get_bandwidthtype_scale($type) { $factor = 1; break; } - return intval($factor); + return floatval($factor); } ?> |