From: Ivan Kohler <ivan@freeside.biz>
Date: Thu, 21 Aug 2014 07:35:26 +0000 (-0700)
Subject: how Calling-Station-Id on RADIUS reports (as a MAC address w/vendor), RT#29154
X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=b95256aad16c4bdafd089d26c0f9147f3ec7755e

how Calling-Station-Id on RADIUS reports (as a MAC address w/vendor), RT#29154
---

diff --git a/FS/FS/part_export/sqlradius.pm b/FS/FS/part_export/sqlradius.pm
index 5d84f37ec..7ec869cb2 100644
--- a/FS/FS/part_export/sqlradius.pm
+++ b/FS/FS/part_export/sqlradius.pm
@@ -48,7 +48,7 @@ tie %options, 'Tie::IxHash',
   },
   'show_called_station' => {
     type  => 'checkbox',
-    label => 'Show the Called-Station-ID on session reports',
+    label => 'Show the Called-Station-ID on session reports', #as a phone number
   },
   'overlimit_groups' => {
       label => 'Radius groups to assign to svc_acct which has exceeded its bandwidth or time limit (if not overridden by overlimit_groups global or per-agent config)', 
diff --git a/httemplate/search/sqlradius.cgi b/httemplate/search/sqlradius.cgi
index f7873e72f..604f44ea0 100644
--- a/httemplate/search/sqlradius.cgi
+++ b/httemplate/search/sqlradius.cgi
@@ -12,17 +12,6 @@
 %   delete $efields{'framedipaddress'} if $part_export->option('hide_ip');
 %   if ( $part_export->option('hide_data') ) {
 %     delete $efields{$_} foreach qw(acctinputoctets acctoutputoctets);
-%   }
-%   if ( $part_export->option('show_called_station') ) {
-%     $efields->Splice(1, 0,
-%       'calledstationid' => {
-%                              'name'   => 'Destination',
-%                              'attrib' => 'Called-Station-ID',
-%                              'fmt'    =>
-%                                sub { length($_[0]) ? shift : '&nbsp'; },
-%                              'align'  => 'left',
-%                            },
-%     );
 %   }
 
     <FONT CLASS="fsinnerbox-title">
@@ -384,6 +373,37 @@ tie %fields, 'Tie::IxHash',
                                           },
                            align   => 'right',
                          },
+  'callingstationid'  => {
+                           name    => 'Source&nbsp;or&nbsp;MAC',
+                           attrib  => 'Calling-Station-Id',
+                           fmt     => sub {
+                             my $src = shift;
+                             if ( $src =~
+                                    /^\s*(([\dA-F]{2}[\-:]){5}[\dA-F]{2})/i ) {
+                               return $src. ' ('.
+                                        (Net::MAC::Vendor::lookup($1))->[0].
+                                      ')';
+
+                             }
+                             length($src) ? $src : '&nbsp';
+                           },
+                           align   => 'right',
+                         },
+  'calledstationid'   => {
+                           name    => 'Destination',
+                           attrib  => 'Called-Station-ID',
+                           fmt     => sub {
+                             my $dst = shift;
+                             if ( $dst =~
+                                    /^\s*(([\dA-F]{2}[\-:]){5}[\dA-F]{2})/i ) {
+                               return $dst. ' ('.
+                                        (Net::MAC::Vendor::lookup($1))->[0].
+                                      ')';
+                             }
+                             length($dst) ? $dst : '&nbsp';
+                           },
+                           align   => 'left',
+                       },
   'acctstarttime'     => {
                            name    => 'Start&nbsp;time',
                            attrib  => 'Acct-Start-Time',