summaryrefslogtreecommitdiffstats
path: root/usr/local/captiveportal
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2013-04-11 23:47:32 -0700
committerErmal Luçi <eri@pfsense.org>2013-04-11 23:47:32 -0700
commit9a2d3fc164d8246c809082ed750df9b121b4ad47 (patch)
tree3dc69a6d1c46e98a7e845fe02f5d8908788e4be2 /usr/local/captiveportal
parent4b3a2e1471981251213316b097459b74f9da220c (diff)
parentc8b07434e3a1c9ae905c2e6cbef6f8fb25e3db00 (diff)
downloadpfsense-9a2d3fc164d8246c809082ed750df9b121b4ad47.zip
pfsense-9a2d3fc164d8246c809082ed750df9b121b4ad47.tar.gz
Merge pull request #556 from tuyan/c8b07434e3a1c9ae905c2e6cbef6f8fb25e3db00
Fix calculation of accounting gigawords.
Diffstat (limited to 'usr/local/captiveportal')
-rw-r--r--usr/local/captiveportal/radius_accounting.inc5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr/local/captiveportal/radius_accounting.inc b/usr/local/captiveportal/radius_accounting.inc
index 4a167e7..e43a188 100644
--- a/usr/local/captiveportal/radius_accounting.inc
+++ b/usr/local/captiveportal/radius_accounting.inc
@@ -42,6 +42,7 @@
pfSense_MODULE: captiveportal
*/
+define('GIGAWORDS_RIGHT_OPERAND', '4294967296'); // 2^32
/**
* Get the NAS-IP-Address based on the current wan address
@@ -319,7 +320,7 @@ function gigawords($bytes) {
*/
// We use BCMath functions since normal integers don't work with so large numbers
- $gigawords = bcdiv( bcsub( $bytes, remainder($bytes) ) , PHP_INT_MAX) ;
+ $gigawords = bcdiv( bcsub( $bytes, remainder($bytes) ) , GIGAWORDS_RIGHT_OPERAND) ;
// We need to manually set this to a zero instead of NULL for put_int() safety
if (is_null($gigawords)) {
@@ -333,7 +334,7 @@ function gigawords($bytes) {
function remainder($bytes) {
// Calculate the bytes we are going to send to the radius
- $bytes = bcmod($bytes, PHP_INT_MAX);
+ $bytes = bcmod($bytes, GIGAWORDS_RIGHT_OPERAND);
if (is_null($bytes)) {
$bytes = 0;
OpenPOWER on IntegriCloud