summaryrefslogtreecommitdiffstats
path: root/etc/inc/shaper.inc
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2008-03-04 18:29:38 +0000
committerErmal Luçi <eri@pfsense.org>2008-03-04 18:29:38 +0000
commit3a54efed1a5beab4faef6337105838120d541d56 (patch)
treebb874aa47340f5c85607e8edfa28fedf894b80de /etc/inc/shaper.inc
parent90923e0998d6c7be9174b4f3cd166a3f21bbf001 (diff)
downloadpfsense-3a54efed1a5beab4faef6337105838120d541d56.zip
pfsense-3a54efed1a5beab4faef6337105838120d541d56.tar.gz
s/intval/floatval/
fix settings for CBQ where setting of bandwidth was wrong in some places
Diffstat (limited to 'etc/inc/shaper.inc')
-rw-r--r--etc/inc/shaper.inc44
1 files changed, 15 insertions, 29 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) {
OpenPOWER on IntegriCloud