]> git.gsnw.org Git - m0n0chwall.git/commitdiff
Add nas_ip and nas_id into radius.inc. Phase1 of migration.
authorjdegraeve <jdegraeve@e36fee2c-cc09-0410-a7cc-ebac5c6737de>
Wed, 8 Feb 2006 16:42:48 +0000 (16:42 +0000)
committerjdegraeve <jdegraeve@e36fee2c-cc09-0410-a7cc-ebac5c6737de>
Wed, 8 Feb 2006 16:42:48 +0000 (16:42 +0000)
git-svn-id: https://svn.m0n0.ch/wall/trunk@61 e36fee2c-cc09-0410-a7cc-ebac5c6737de

captiveportal/radius_accounting_nas_ip.inc
phpconf/inc/radius.inc

index b53a00825766a57f0a16fab551eb051554b5c752..bb876a60f07bedd37d9402b52dd6631c76beb658 100644 (file)
@@ -1,12 +1,12 @@
 <?php
 /*
 
-$Id$
+    $Id$
 
     radius_accounting.inc
     part of m0n0wall (http://m0n0.ch/wall)
     
-    Copyright (C) 2004 Dinesh Nair <dinesh@alphaque.com>
+    Copyright (C) M0n0wall Project
     All rights reserved.
     
     Redistribution and use in source and binary forms, with or without
@@ -30,19 +30,6 @@ $Id$
     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     POSSIBILITY OF SUCH DAMAGE.
 
-    // This version of radius_accounting.inc has been modified by
-    // Rob Parker <rob.parker@keycom.co.uk>. Changes made include:
-    // * now sends Framed-IP-Address (client IP)
-    // * now sends Called-Station-ID (NAS IP)
-    // * now sends Calling-Station-ID (client IP)
-
-    // This version of radius_accounting.inc has been modified by
-    // Jonathan De Graeve <jonathan@imelda.be>. Changes made include:
-    // - RFC2869 (Radius Extensions)
-    // * now sends Acct-Input-Gigawords
-    // * now sends Acct-Output-Gigawords
-    // * full implementation of nas-ip/nas_mac and called/calling-station ids
-
 */
 
 function RADIUS_ACCOUNTING_START($ruleno,$username,$sessionid,$radiusip,$radiusport,$radiuskey,$clientip,$clientmac) {
@@ -60,7 +47,7 @@ function RADIUS_ACCOUNTING_START($ruleno,$username,$sessionid,$radiusip,$radiusp
     /* set 5 second timeout on socket i/o */
     stream_set_timeout($fd, 5) ;
 
-    $nas_ip = get_nas_ip();
+    $nas_ip = get_current_wan_address();
     $nas_ip_exp = explode(".",$nas_ip);
     $nas_mac = get_interface_mac($config['interfaces']['wan']['if']); // This function is defined in radius_authentication.inc
     $nas_port = $ruleno - 10000;
@@ -199,7 +186,7 @@ function RADIUS_ACCOUNTING_STOP($ruleno,$username,$sessionid,$start_time,$radius
     /* set 5 second timeout on socket i/o */
     stream_set_timeout($fd, 5) ;
 
-    $nas_ip = get_nas_ip();
+    $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']);
index 53a56baf5716188af99cd72225e1143439768c3c..ad01d99091534b7020a9a5321ece664c4899f8f2 100644 (file)
@@ -35,8 +35,6 @@ any other GPL-like (LGPL, GPL2) License.
     This version of RADIUS.php has been modified by
     Jonathan De Graeve <jonathan@imelda.be> to integrate with M0n0wall <http://www.m0n0.ch/wall>
 
-    $Id_jdg: 2005/12/22 14:22:42
-
     Changes made include:
     * StandardAttributes for M0n0wall use
     * Removed internal Session-Id creation
@@ -105,6 +103,18 @@ class Auth_RADIUS extends PEAR {
      */
     var $password = null;
 
+    /**
+     * NAS-IP-Address
+     * @var string
+     */
+    var $nas_ip = null;
+    
+    /**
+     * NAS-Identifier
+     * @var array (note: RFC specifies string and PECL specifies integer)
+     */
+    var $nas_id = array();
+
     /**
      * List of known attributes.
      * @var  array
@@ -157,7 +167,32 @@ class Auth_RADIUS extends PEAR {
     {
         $this->_servers[] = array($servername, $port, $sharedSecret, $timeout, $maxtries);    
     }
-    
+
+    /**
+     * Get the NAS-Identifier
+     *
+     * We will use our local hostname to make up the nas_id
+     */
+    function getNasID()
+    {
+        exec("/bin/hostname", $nas_id);
+        if(!$nas_id[0])
+        $nas_id[0] = "m0n0wall";
+        return $nas_id[0];
+    }
+
+    /**
+     * Get the NAS-IP-Address based on the current wan address
+     *
+     * Use functions in interfaces.inc to find this out
+     *
+     */
+    function getNasIP()
+    {
+        $nas_ip = get_current_wan_address();
+        return $nas_ip;
+    }
+
     /**
      * Returns an error message, if an error occurred.
      *
@@ -284,12 +319,22 @@ class Auth_RADIUS extends PEAR {
     /**
      * Puts standard attributes.
      *
+     * These attributes will always be present in a radius request
+     *
      * @access public
      */ 
     function putStandardAttributes()
     {
+        // Not sure if these need to be in here but for the moment its ok
         $this->putAttribute(RADIUS_NAS_PORT_TYPE, RADIUS_ETHERNET);
         $this->putAttribute(RADIUS_SERVICE_TYPE, RADIUS_LOGIN);
+
+        // Add support for sending NAS-IP-Address, set this explicitly as an ip_addr
+        $this->putAttribute(RADIUS_NAS_IP_ADDRESS, $this->getNasIP(), addr);
+
+        // Add support for sending NAS-Identifier
+        $this->putAttribute(RADIUS_NAS_IDENTIFIER, $this->getNasID());
+
     }
     
     /**
@@ -365,7 +410,7 @@ class Auth_RADIUS extends PEAR {
         }
         
         $this->createRequest();
-       $this->putStandardAttributes();
+        $this->putStandardAttributes();
         $this->putAuthAttributes();
         return true;
     }