Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
smradius
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
smradius
smradius
Commits
8c539166
Commit
8c539166
authored
May 15, 2019
by
Nigel Kukard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed gigaword constant name
parent
bcaa1e81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
22 deletions
+23
-22
lib/smradius/constants.pm
lib/smradius/constants.pm
+3
-4
lib/smradius/modules/accounting/mod_accounting_sql.pm
lib/smradius/modules/accounting/mod_accounting_sql.pm
+20
-18
No files found.
lib/smradius/constants.pm
View file @
8c539166
...
...
@@ -20,14 +20,13 @@
## @class smradius::constants
# SMRadius constants package
package
smradius::
constants
;
use
base
qw(Exporter)
;
use
strict
;
use
warnings
;
# Exporter stuff
use
base
qw(Exporter)
;
our
(
@EXPORT
,
@EXPORT_OK
);
@EXPORT
=
qw(
RES_OK
...
...
@@ -37,7 +36,7 @@ our (@EXPORT,@EXPORT_OK);
MOD_RES_NACK
MOD_RES_SKIP
UINT_MAX
GIGAWORD_VALUE
)
;
@EXPORT_OK
=
();
...
...
@@ -50,7 +49,7 @@ use constant {
MOD_RES_ACK
=>
1
,
MOD_RES_NACK
=>
2
,
UINT_MAX
=>
2
**
32
GIGAWORD_VALUE
=>
2
**
32
,
};
...
...
lib/smradius/modules/accounting/mod_accounting_sql.pm
View file @
8c539166
...
...
@@ -427,7 +427,7 @@ sub getUsage
}
if
(
defined
(
$row
->
{'
AcctInputGigawords
'})
&&
$row
->
{'
AcctInputGigawords
'}
>
0
)
{
my
$inputGigawords
=
Math::
BigInt
->
new
(
$row
->
{'
AcctInputGigawords
'});
$inputGigawords
->
bmul
(
UINT_MAX
);
$inputGigawords
->
bmul
(
GIGAWORD_VALUE
);
$usageTotals
{'
TotalDataInput
'}
->
badd
(
$inputGigawords
);
}
# Add output usage if we have any
...
...
@@ -436,7 +436,7 @@ sub getUsage
}
if
(
defined
(
$row
->
{'
AcctOutputGigawords
'})
&&
$row
->
{'
AcctOutputGigawords
'}
>
0
)
{
my
$outputGigawords
=
Math::
BigInt
->
new
(
$row
->
{'
AcctOutputGigawords
'});
$outputGigawords
->
bmul
(
UINT_MAX
);
$outputGigawords
->
bmul
(
GIGAWORD_VALUE
);
$usageTotals
{'
TotalDataOutput
'}
->
badd
(
$outputGigawords
);
}
}
...
...
@@ -514,12 +514,13 @@ sub acct_log
return
;
}
# Convert session total gigawords/octets into bytes
my
$totalInputBytes
=
Math::
BigInt
->
new
(
0
);
$totalInputBytes
->
badd
(
$template
->
{'
request
'}
->
{'
Acct-Input-Gigawords
'})
->
bmul
(
UINT_MAX
);
# Convert session total gigawords into bytes
my
$totalInputBytes
=
Math::
BigInt
->
new
(
$template
->
{'
request
'}
->
{'
Acct-Input-Gigawords
'});
my
$totalOutputBytes
=
Math::
BigInt
->
new
(
$template
->
{'
request
'}
->
{'
Acct-Output-Gigawords
'});
$totalInputBytes
->
bmul
(
GIGAWORD_VALUE
);
$totalOutputBytes
->
bmul
(
GIGAWORD_VALUE
);
# Add byte counters
$totalInputBytes
->
badd
(
$template
->
{'
request
'}
->
{'
Acct-Input-Octets
'});
my
$totalOutputBytes
=
Math::
BigInt
->
new
(
0
);
$totalOutputBytes
->
badd
(
$template
->
{'
request
'}
->
{'
Acct-Output-Gigawords
'})
->
bmul
(
UINT_MAX
);
$totalOutputBytes
->
badd
(
$template
->
{'
request
'}
->
{'
Acct-Output-Octets
'});
# Packets, no conversion
my
$totalInputPackets
=
Math::
BigInt
->
new
(
$template
->
{'
request
'}
->
{'
Acct-Input-Packets
'});
...
...
@@ -541,12 +542,13 @@ sub acct_log
$sessionPart
->
{'
AcctOutputPackets
'}
//
=
0
;
$sessionPart
->
{'
AcctSessionTime
'}
//
=
0
;
# Convert this session usage to bytes
my
$sessionInputBytes
=
Math::
BigInt
->
new
(
0
);
$sessionInputBytes
->
badd
(
$sessionPart
->
{'
AcctInputGigawods
'})
->
bmul
(
UINT_MAX
);
# Convert the gigawords into bytes
my
$sessionInputBytes
=
Math::
BigInt
->
new
(
$sessionPart
->
{'
AcctInputGigawords
'});
my
$sessionOutputBytes
=
Math::
BigInt
->
new
(
$sessionPart
->
{'
AcctOutputGigawords
'});
$sessionInputBytes
->
bmul
(
GIGAWORD_VALUE
);
$sessionOutputBytes
->
bmul
(
GIGAWORD_VALUE
);
# Add the byte counters
$sessionInputBytes
->
badd
(
$sessionPart
->
{'
AcctInputOctets
'});
my
$sessionOutputBytes
=
Math::
BigInt
->
new
(
0
);
$sessionOutputBytes
->
badd
(
$sessionPart
->
{'
AcctOutputGigawods
'})
->
bmul
(
UINT_MAX
);
$sessionOutputBytes
->
badd
(
$sessionPart
->
{'
AcctOutputOctets
'});
# And packets
my
$sessionInputPackets
=
Math::
BigInt
->
new
(
$sessionPart
->
{'
AcctInputPackets
'});
...
...
@@ -588,8 +590,8 @@ sub acct_log
}
# Re-calculate
my
(
$inputGigawordsStr
,
$inputOctetsStr
)
=
$totalInputBytes
->
bdiv
(
UINT_MAX
);
my
(
$outputGigawordsStr
,
$outputOctetsStr
)
=
$totalOutputBytes
->
bdiv
(
UINT_MAX
);
my
(
$inputGigawordsStr
,
$inputOctetsStr
)
=
$totalInputBytes
->
bdiv
(
GIGAWORD_VALUE
);
my
(
$outputGigawordsStr
,
$outputOctetsStr
)
=
$totalOutputBytes
->
bdiv
(
GIGAWORD_VALUE
);
# Conversion to strings
$template
->
{'
query
'}
->
{'
Acct-Input-Gigawords
'}
=
$inputGigawordsStr
->
bstr
();
...
...
@@ -806,7 +808,7 @@ sub cleanup
}
if
(
defined
(
$row
->
{'
AcctInputGigawords
'})
&&
$row
->
{'
AcctInputGigawords
'}
>
0
)
{
my
$inputGigawords
=
Math::
BigInt
->
new
(
$row
->
{'
AcctInputGigawords
'});
$inputGigawords
->
bmul
(
UINT_MAX
);
$inputGigawords
->
bmul
(
GIGAWORD_VALUE
);
$usageTotals
{
$row
->
{'
Username
'}}{'
TotalDataInput
'}
->
badd
(
$inputGigawords
);
}
# Add output usage if we have any
...
...
@@ -815,7 +817,7 @@ sub cleanup
}
if
(
defined
(
$row
->
{'
AcctOutputGigawords
'})
&&
$row
->
{'
AcctOutputGigawords
'}
>
0
)
{
my
$outputGigawords
=
Math::
BigInt
->
new
(
$row
->
{'
AcctOutputGigawords
'});
$outputGigawords
->
bmul
(
UINT_MAX
);
$outputGigawords
->
bmul
(
GIGAWORD_VALUE
);
$usageTotals
{
$row
->
{'
Username
'}}{'
TotalDataOutput
'}
->
badd
(
$outputGigawords
);
}
...
...
@@ -837,7 +839,7 @@ sub cleanup
}
if
(
defined
(
$row
->
{'
AcctInputGigawords
'})
&&
$row
->
{'
AcctInputGigawords
'}
>
0
)
{
my
$inputGigawords
=
Math::
BigInt
->
new
(
$row
->
{'
AcctInputGigawords
'});
$inputGigawords
->
bmul
(
UINT_MAX
);
$inputGigawords
->
bmul
(
GIGAWORD_VALUE
);
$usageTotals
{
$row
->
{'
Username
'}}{'
TotalDataInput
'}
->
badd
(
$inputGigawords
);
}
# Add output usage if we have any
...
...
@@ -846,7 +848,7 @@ sub cleanup
}
if
(
defined
(
$row
->
{'
AcctOutputGigawords
'})
&&
$row
->
{'
AcctOutputGigawords
'}
>
0
)
{
my
$outputGigawords
=
Math::
BigInt
->
new
(
$row
->
{'
AcctOutputGigawords
'});
$outputGigawords
->
bmul
(
UINT_MAX
);
$outputGigawords
->
bmul
(
GIGAWORD_VALUE
);
$usageTotals
{
$row
->
{'
Username
'}}{'
TotalDataOutput
'}
->
badd
(
$outputGigawords
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment