]> git.gsnw.org Git - m0n0chwall.git/commitdiff
Commit to repository, the rest is for tomorrow on dual screen PC :)
authorjdegraeve <jdegraeve@e36fee2c-cc09-0410-a7cc-ebac5c6737de>
Wed, 8 Feb 2006 21:18:15 +0000 (21:18 +0000)
committerjdegraeve <jdegraeve@e36fee2c-cc09-0410-a7cc-ebac5c6737de>
Wed, 8 Feb 2006 21:18:15 +0000 (21:18 +0000)
git-svn-id: https://svn.m0n0.ch/wall/trunk@62 e36fee2c-cc09-0410-a7cc-ebac5c6737de

captiveportal/radius_accounting_v2.inc
phpconf/inc/radius.inc

index 193bfaa48efeb9b222596bae6b1aaa9ffeaff74f..5ab44222a953a9325a3af97c2aa16a5fa1e19fa9 100644 (file)
@@ -55,18 +55,6 @@ RADIUS ACCOUNTING START
 function RADIUS_ACCOUNTING_START($username,$sessionid,$radiusip,$radiusport,$radiuskey,$clientip) {
     global $debug;
 
-    exec("/bin/hostname", $nasHostname) ;
-    if(!$nasHostname[0])
-            $nasHostname[0] = "m0n0wall" ;
-
-    $nas_ip_address = get_nas_ip();
-
-    if(!isset($clientip)) {
-            //if there's no client ip, we'll need to use the NAS ip
-            $clientip=$nas_ip_address;
-    }
-
-
 $racct = new Auth_RADIUS_Acct_Start;
 $racct->addServer($radiusip, $radiusport, $radiuskey);
 /* Different Authentication options
@@ -86,14 +74,13 @@ if(PEAR::isError($status)) {
 
 /*
 NAS_PORT_TYPE, int => RADIUS_ETHERNET (15), RADIUS_WIRELESS_OTHER (18), RADIUS_WIRELESS_IEEE_802_11 (19)
-NAS_IDENTIFIER, int => should be int but nasHostname[0] returns string
 */
 
+
+// Other options
 $racct->putAttribute(RADIUS_SERVICE_TYPE, RADIUS_LOGIN);
 $racct->putAttribute(RADIUS_NAS_PORT, 0); 
 $racct->putAttribute(RADIUS_NAS_PORT_TYPE, RADIUS_ETHERNET);
-//$racct->putAttribute(RADIUS_NAS_IDENTIFIER, $nasHostname[0]);
-$racct->putAttribute(RADIUS_NAS_IP_ADDRESS, $nas_ip_address); 
 $racct->putAttribute(RADIUS_ACCT_SESSION_ID, $sessionid); 
 $racct->putAttribute(RADIUS_FRAMED_IP_ADDRESS, $clientip); 
 $result = $racct->send();
@@ -144,12 +131,14 @@ function RADIUS_ACCOUNTING_STOP($ruleno,$username,$sessionid,$start_time,$radius
     $output_bytes = remainder($matches[3]);
     $output_gigawords = gigawords($matches[3]);
 
-    $nas_ip_address = get_nas_ip();
 
-    if(!isset($clientip)) {
-            //if there's no client ip, we'll need to use the NAS ip
-            $clientip=$nas_ip_address;
-    }
+    $nas_ip = get_current_wan_address();
+    $nas_ip_exp = explode(".",$nas_ip);
+    $nas_port = $ruleno - 10000;
+    $nas_mac = get_interface_mac($config['interfaces']['wan']['if']);
+    $ip_exp=explode(".",$clientip);
+    $session_time = $stop_time - $start_time;
+    $radiusvendor = $config['captiveportal']['radiusvendor'] ? $config['captiveportal']['radiusvendor'] : null
 
     if ($debug)
         echo "<br>radius-port: $radiusport<br>radius-host: $radiusip<br>username: $username<hr>\n";
@@ -164,7 +153,8 @@ function RADIUS_ACCOUNTING_STOP($ruleno,$username,$sessionid,$start_time,$radius
 // Construct data package
 $racct->addServer($radiusip, $radiusport, $radiuskey);
 $racct->username = $username;
-$racct->session_time = time() - $start_time;
+
+
 $status = $racct->start();
 if(PEAR::isError($status)) {
     if ($debug)
@@ -173,9 +163,31 @@ if(PEAR::isError($status)) {
 }
 // you can put any additional attributes here
 //$racct->putAttribute(RADIUS_SERVICE_TYPE, RADIUS_LOGIN);
-//$racct->putAttribute(RADIUS_NAS_IDENTIFIER, $nasHostname[0]);
-$racct->putAttribute(RADIUS_NAS_IP_ADDRESS, $nas_ip_address);
+
+// Do the accounting style as configured in GUI
+       switch($radiusvendor) {
+
+        case 'cisco':
+        $rauth->putAttribute(RADIUS_CALLED_STATION_ID, $clientmac);
+        $rauth->putAttribute(RADIUS_CALLING_STATION_ID, $clientip);
+        break;
+
+        default:
+        $rauth->putAttribute(RADIUS_CALLED_STATION_ID, $nas_mac);
+        $rauth->putAttribute(RADIUS_CALLING_STATION_ID, $clientmac);
+       }
+
+       // Default attributes
+       $rauth->putAttribute(RADIUS_NAS_PORT, $nas_port)
+
+$session_time = $stop_time - $start_time;
+// We have 2 ways to set the session-time, we will see which one to use in a later version
+$racct->session_time = $session_time;
+$racct->putAttribute(RADIUS_ACCT_SESSION_TIME, $session_time);
+
+// Set the session_id here since we removed it into the radius.inc removing the possibility to overwrite it by $racct->session_id
 $racct->putAttribute(RADIUS_ACCT_SESSION_ID, $sessionid);
+
 $racct->putAttribute(RADIUS_FRAMED_IP_ADDRESS, $clientip);
 $racct->putAttribute(RADIUS_CALLING_STATION_ID, $clientip);
 $racct->putAttribute(RADIUS_CALLED_STATION_ID, $nas_ip_address);
index ad01d99091534b7020a9a5321ece664c4899f8f2..0181db8979d06a43ab5dba056347981e289517cc 100644 (file)
@@ -107,13 +107,13 @@ class Auth_RADIUS extends PEAR {
      * NAS-IP-Address
      * @var string
      */
-    var $nas_ip = null;
+    var $nasIp = null;
     
     /**
      * NAS-Identifier
      * @var array (note: RFC specifies string and PECL specifies integer)
      */
-    var $nas_id = array();
+    var $nasId = array();
 
     /**
      * List of known attributes.
@@ -175,10 +175,10 @@ class Auth_RADIUS extends PEAR {
      */
     function getNasID()
     {
-        exec("/bin/hostname", $nas_id);
-        if(!$nas_id[0])
-        $nas_id[0] = "m0n0wall";
-        return $nas_id[0];
+        exec("/bin/hostname", $_nasId);
+        if(!$_nasId[0])
+            $_nasId[0] = "m0n0wall";
+        return $_nasId[0];
     }
 
     /**
@@ -189,8 +189,10 @@ class Auth_RADIUS extends PEAR {
      */
     function getNasIP()
     {
-        $nas_ip = get_current_wan_address();
-        return $nas_ip;
+        $_nasIp = get_current_wan_address();
+        if(!$_nasIp)
+            $_nasIp = "0.0.0.0";
+        return $_nasIp;
     }
 
     /**
@@ -1069,7 +1071,9 @@ class Auth_RADIUS_Acct extends Auth_RADIUS
      */ 
     function putAuthAttributes()
     {
+        /* Remove the internal ACCT_SESSION_ID function since we are going to set it manually
         $this->putAttribute(RADIUS_ACCT_SESSION_ID, $this->session_id);
+        */
         $this->putAttribute(RADIUS_ACCT_STATUS_TYPE, $this->status_type);
         if (isset($this->session_time) && $this->status_type == RADIUS_STOP) {
             $this->putAttribute(RADIUS_ACCT_SESSION_TIME, $this->session_time);