From: jdegraeve Date: Wed, 8 Feb 2006 16:42:48 +0000 (+0000) Subject: Add nas_ip and nas_id into radius.inc. Phase1 of migration. X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e12a4a409a28168dbf8ca0ab99adeabb5d3b43fb;p=m0n0chwall.git Add nas_ip and nas_id into radius.inc. Phase1 of migration. git-svn-id: https://svn.m0n0.ch/wall/trunk@61 e36fee2c-cc09-0410-a7cc-ebac5c6737de --- diff --git a/captiveportal/radius_accounting_nas_ip.inc b/captiveportal/radius_accounting_nas_ip.inc index b53a008..bb876a6 100644 --- a/captiveportal/radius_accounting_nas_ip.inc +++ b/captiveportal/radius_accounting_nas_ip.inc @@ -1,12 +1,12 @@ + 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 . 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 . 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']); diff --git a/phpconf/inc/radius.inc b/phpconf/inc/radius.inc index 53a56ba..ad01d99 100644 --- a/phpconf/inc/radius.inc +++ b/phpconf/inc/radius.inc @@ -35,8 +35,6 @@ any other GPL-like (LGPL, GPL2) License. This version of RADIUS.php has been modified by Jonathan De Graeve to integrate with M0n0wall - $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; }