[freeside-commits] freeside/FS/FS Conf.pm, 1.180.2.47, 1.180.2.48 svc_acct.pm, 1.217.2.27, 1.217.2.28

Ivan,,, ivan at wavetail.420.am
Fri Jul 24 02:38:24 PDT 2009


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv10264

Modified Files:
      Tag: FREESIDE_1_7_BRANCH
	Conf.pm svc_acct.pm 
Log Message:
add handling of ChilliSpot (and CoovaChilli) Max attributes, specifically ChilliSpot-Max-{Input,Output,Total}-{Octets,Gigawords}, RT#5815

Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.180.2.47
retrieving revision 1.180.2.48
diff -u -d -r1.180.2.47 -r1.180.2.48
--- Conf.pm	12 Jun 2009 10:20:30 -0000	1.180.2.47
+++ Conf.pm	24 Jul 2009 09:38:22 -0000	1.180.2.48
@@ -1598,6 +1598,14 @@
     'select_enum' => [ 'Framed-IP-Address', 'Framed-Address' ],
   },
 
+  #http://dev.coova.org/svn/coova-chilli/doc/dictionary.chillispot
+  {
+    'key'         => 'radius-chillispot-max',
+    'section'     => '',
+    'description' => 'Enable ChilliSpot (and CoovaChilli) Max attributes, specifically ChilliSpot-Max-{Input,Output,Total}-{Octets,Gigawords}.',
+    'type'        => 'checkbox',
+  },
+
   {
     'key'         => 'svc_acct-alldomains',
     'section'     => '',

Index: svc_acct.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_acct.pm,v
retrieving revision 1.217.2.27
retrieving revision 1.217.2.28
diff -u -d -r1.217.2.27 -r1.217.2.28
--- svc_acct.pm	30 May 2009 03:14:35 -0000	1.217.2.27
+++ svc_acct.pm	24 Jul 2009 09:38:22 -0000	1.217.2.28
@@ -16,6 +16,7 @@
              $radius_password $radius_ip
              $dirhash
              @saltset @pw_set );
+use Math::BigInt;
 use Carp;
 use Fcntl qw(:flock);
 use Date::Format;
@@ -1393,6 +1394,28 @@
     $reply{'Session-Timeout'} = $self->seconds;
   }
 
+  if ( $conf->exists('radius-chillispot-max') ) {
+    #http://dev.coova.org/svn/coova-chilli/doc/dictionary.chillispot
+
+    #hmm.  just because sqlradius.pm says so?
+    my %whatis = (
+      'input'  => 'up',
+      'output' => 'down',
+      'total'  => 'total',
+    );
+
+    foreach my $what (qw( input output total )) {
+      my $is = $whatis{$what}.'bytes';
+      if ( $self->$is() =~ /\d/ ) {
+        my $big = new Math::BigInt $self->$is();
+        my $att = "Chillispot-Max-\u$what";
+        $reply{"$att-Octets"}    = $big->copy->band(0xffffffff)->bstr;
+        $reply{"$att-Gigawords"} = $big->copy->brsft(32)->bstr;
+      }
+    }
+
+  }
+
   %reply;
 }
 
@@ -1687,6 +1710,16 @@
   die "Can't update $column for svcnum". $self->svcnum
     if $rv == 0;
 
+  #$self->snapshot; #not necessary, we retain the old values
+  #create an object with the updated usage values
+  my $new = qsearchs('svc_acct', { 'svcnum' => $self->svcnum });
+  #call exports
+  my $error = $new->replace($self);
+  if ( $error ) {
+    $dbh->rollback if $oldAutoCommit;
+    return "Error replacing: $error";
+  }
+
   #overlimit_action eq 'cancel' handling
   my $cust_pkg = $self->cust_svc->cust_pkg;
   if ( $cust_pkg
@@ -1840,6 +1873,16 @@
       if $rv == 0;
   }
 
+  #$self->snapshot; #not necessary, we retain the old values
+  #create an object with the updated usage values
+  my $new = qsearchs('svc_acct', { 'svcnum' => $self->svcnum });
+  #call exports
+  my $error = $new->replace($self);
+  if ( $error ) {
+    $dbh->rollback if $oldAutoCommit;
+    return "Error replacing: $error";
+  }
+
   if ( $reset ) {
     my $error;
 
@@ -2509,6 +2552,8 @@
 insertion of RADIUS group stuff in insert could be done with child_objects now
 (would probably clean up export of them too)
 
+_op_usage and set_usage bypass the history... maybe they shouldn't
+
 =head1 SEE ALSO
 
 L<FS::svc_Common>, edit/part_svc.cgi from an installed web interface,



More information about the freeside-commits mailing list