Commit 8c539166 authored by Nigel Kukard's avatar Nigel Kukard

Changed gigaword constant name

parent bcaa1e81
...@@ -20,14 +20,13 @@ ...@@ -20,14 +20,13 @@
## @class smradius::constants ## @class smradius::constants
# SMRadius constants package # SMRadius constants package
package smradius::constants; package smradius::constants;
use base qw(Exporter);
use strict; use strict;
use warnings; use warnings;
# Exporter stuff
use base qw(Exporter);
our (@EXPORT,@EXPORT_OK); our (@EXPORT,@EXPORT_OK);
@EXPORT = qw( @EXPORT = qw(
RES_OK RES_OK
...@@ -37,7 +36,7 @@ our (@EXPORT,@EXPORT_OK); ...@@ -37,7 +36,7 @@ our (@EXPORT,@EXPORT_OK);
MOD_RES_NACK MOD_RES_NACK
MOD_RES_SKIP MOD_RES_SKIP
UINT_MAX GIGAWORD_VALUE
); );
@EXPORT_OK = (); @EXPORT_OK = ();
...@@ -50,7 +49,7 @@ use constant { ...@@ -50,7 +49,7 @@ use constant {
MOD_RES_ACK => 1, MOD_RES_ACK => 1,
MOD_RES_NACK => 2, MOD_RES_NACK => 2,
UINT_MAX => 2**32 GIGAWORD_VALUE => 2**32,
}; };
......
...@@ -427,7 +427,7 @@ sub getUsage ...@@ -427,7 +427,7 @@ sub getUsage
} }
if (defined($row->{'AcctInputGigawords'}) && $row->{'AcctInputGigawords'} > 0) { if (defined($row->{'AcctInputGigawords'}) && $row->{'AcctInputGigawords'} > 0) {
my $inputGigawords = Math::BigInt->new($row->{'AcctInputGigawords'}); my $inputGigawords = Math::BigInt->new($row->{'AcctInputGigawords'});
$inputGigawords->bmul(UINT_MAX); $inputGigawords->bmul(GIGAWORD_VALUE);
$usageTotals{'TotalDataInput'}->badd($inputGigawords); $usageTotals{'TotalDataInput'}->badd($inputGigawords);
} }
# Add output usage if we have any # Add output usage if we have any
...@@ -436,7 +436,7 @@ sub getUsage ...@@ -436,7 +436,7 @@ sub getUsage
} }
if (defined($row->{'AcctOutputGigawords'}) && $row->{'AcctOutputGigawords'} > 0) { if (defined($row->{'AcctOutputGigawords'}) && $row->{'AcctOutputGigawords'} > 0) {
my $outputGigawords = Math::BigInt->new($row->{'AcctOutputGigawords'}); my $outputGigawords = Math::BigInt->new($row->{'AcctOutputGigawords'});
$outputGigawords->bmul(UINT_MAX); $outputGigawords->bmul(GIGAWORD_VALUE);
$usageTotals{'TotalDataOutput'}->badd($outputGigawords); $usageTotals{'TotalDataOutput'}->badd($outputGigawords);
} }
} }
...@@ -514,12 +514,13 @@ sub acct_log ...@@ -514,12 +514,13 @@ sub acct_log
return; return;
} }
# Convert session total gigawords/octets into bytes # Convert session total gigawords into bytes
my $totalInputBytes = Math::BigInt->new(0); my $totalInputBytes = Math::BigInt->new($template->{'request'}->{'Acct-Input-Gigawords'});
$totalInputBytes->badd($template->{'request'}->{'Acct-Input-Gigawords'})->bmul(UINT_MAX); 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'}); $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'}); $totalOutputBytes->badd($template->{'request'}->{'Acct-Output-Octets'});
# Packets, no conversion # Packets, no conversion
my $totalInputPackets = Math::BigInt->new($template->{'request'}->{'Acct-Input-Packets'}); my $totalInputPackets = Math::BigInt->new($template->{'request'}->{'Acct-Input-Packets'});
...@@ -541,12 +542,13 @@ sub acct_log ...@@ -541,12 +542,13 @@ sub acct_log
$sessionPart->{'AcctOutputPackets'} //= 0; $sessionPart->{'AcctOutputPackets'} //= 0;
$sessionPart->{'AcctSessionTime'} //= 0; $sessionPart->{'AcctSessionTime'} //= 0;
# Convert this session usage to bytes # Convert the gigawords into bytes
my $sessionInputBytes = Math::BigInt->new(0); my $sessionInputBytes = Math::BigInt->new($sessionPart->{'AcctInputGigawords'});
$sessionInputBytes->badd($sessionPart->{'AcctInputGigawods'})->bmul(UINT_MAX); my $sessionOutputBytes = Math::BigInt->new($sessionPart->{'AcctOutputGigawords'});
$sessionInputBytes->bmul(GIGAWORD_VALUE);
$sessionOutputBytes->bmul(GIGAWORD_VALUE);
# Add the byte counters
$sessionInputBytes->badd($sessionPart->{'AcctInputOctets'}); $sessionInputBytes->badd($sessionPart->{'AcctInputOctets'});
my $sessionOutputBytes = Math::BigInt->new(0);
$sessionOutputBytes->badd($sessionPart->{'AcctOutputGigawods'})->bmul(UINT_MAX);
$sessionOutputBytes->badd($sessionPart->{'AcctOutputOctets'}); $sessionOutputBytes->badd($sessionPart->{'AcctOutputOctets'});
# And packets # And packets
my $sessionInputPackets = Math::BigInt->new($sessionPart->{'AcctInputPackets'}); my $sessionInputPackets = Math::BigInt->new($sessionPart->{'AcctInputPackets'});
...@@ -588,8 +590,8 @@ sub acct_log ...@@ -588,8 +590,8 @@ sub acct_log
} }
# Re-calculate # Re-calculate
my ($inputGigawordsStr,$inputOctetsStr) = $totalInputBytes->bdiv(UINT_MAX); my ($inputGigawordsStr,$inputOctetsStr) = $totalInputBytes->bdiv(GIGAWORD_VALUE);
my ($outputGigawordsStr,$outputOctetsStr) = $totalOutputBytes->bdiv(UINT_MAX); my ($outputGigawordsStr,$outputOctetsStr) = $totalOutputBytes->bdiv(GIGAWORD_VALUE);
# Conversion to strings # Conversion to strings
$template->{'query'}->{'Acct-Input-Gigawords'} = $inputGigawordsStr->bstr(); $template->{'query'}->{'Acct-Input-Gigawords'} = $inputGigawordsStr->bstr();
...@@ -806,7 +808,7 @@ sub cleanup ...@@ -806,7 +808,7 @@ sub cleanup
} }
if (defined($row->{'AcctInputGigawords'}) && $row->{'AcctInputGigawords'} > 0) { if (defined($row->{'AcctInputGigawords'}) && $row->{'AcctInputGigawords'} > 0) {
my $inputGigawords = Math::BigInt->new($row->{'AcctInputGigawords'}); my $inputGigawords = Math::BigInt->new($row->{'AcctInputGigawords'});
$inputGigawords->bmul(UINT_MAX); $inputGigawords->bmul(GIGAWORD_VALUE);
$usageTotals{$row->{'Username'}}{'TotalDataInput'}->badd($inputGigawords); $usageTotals{$row->{'Username'}}{'TotalDataInput'}->badd($inputGigawords);
} }
# Add output usage if we have any # Add output usage if we have any
...@@ -815,7 +817,7 @@ sub cleanup ...@@ -815,7 +817,7 @@ sub cleanup
} }
if (defined($row->{'AcctOutputGigawords'}) && $row->{'AcctOutputGigawords'} > 0) { if (defined($row->{'AcctOutputGigawords'}) && $row->{'AcctOutputGigawords'} > 0) {
my $outputGigawords = Math::BigInt->new($row->{'AcctOutputGigawords'}); my $outputGigawords = Math::BigInt->new($row->{'AcctOutputGigawords'});
$outputGigawords->bmul(UINT_MAX); $outputGigawords->bmul(GIGAWORD_VALUE);
$usageTotals{$row->{'Username'}}{'TotalDataOutput'}->badd($outputGigawords); $usageTotals{$row->{'Username'}}{'TotalDataOutput'}->badd($outputGigawords);
} }
...@@ -837,7 +839,7 @@ sub cleanup ...@@ -837,7 +839,7 @@ sub cleanup
} }
if (defined($row->{'AcctInputGigawords'}) && $row->{'AcctInputGigawords'} > 0) { if (defined($row->{'AcctInputGigawords'}) && $row->{'AcctInputGigawords'} > 0) {
my $inputGigawords = Math::BigInt->new($row->{'AcctInputGigawords'}); my $inputGigawords = Math::BigInt->new($row->{'AcctInputGigawords'});
$inputGigawords->bmul(UINT_MAX); $inputGigawords->bmul(GIGAWORD_VALUE);
$usageTotals{$row->{'Username'}}{'TotalDataInput'}->badd($inputGigawords); $usageTotals{$row->{'Username'}}{'TotalDataInput'}->badd($inputGigawords);
} }
# Add output usage if we have any # Add output usage if we have any
...@@ -846,7 +848,7 @@ sub cleanup ...@@ -846,7 +848,7 @@ sub cleanup
} }
if (defined($row->{'AcctOutputGigawords'}) && $row->{'AcctOutputGigawords'} > 0) { if (defined($row->{'AcctOutputGigawords'}) && $row->{'AcctOutputGigawords'} > 0) {
my $outputGigawords = Math::BigInt->new($row->{'AcctOutputGigawords'}); my $outputGigawords = Math::BigInt->new($row->{'AcctOutputGigawords'});
$outputGigawords->bmul(UINT_MAX); $outputGigawords->bmul(GIGAWORD_VALUE);
$usageTotals{$row->{'Username'}}{'TotalDataOutput'}->badd($outputGigawords); $usageTotals{$row->{'Username'}}{'TotalDataOutput'}->badd($outputGigawords);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment