From cff5204a17992f77de04544f75f939ddcfabf84c Mon Sep 17 00:00:00 2001 From: Ermal Date: Fri, 20 Jan 2012 12:21:19 +0000 Subject: Correct the Called-Station-Id attribute setting to be the same on STOP/START packets --- usr/local/captiveportal/radius_accounting.inc | 38 ++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'usr/local') diff --git a/usr/local/captiveportal/radius_accounting.inc b/usr/local/captiveportal/radius_accounting.inc index 1f24e65..0a1300c 100644 --- a/usr/local/captiveportal/radius_accounting.inc +++ b/usr/local/captiveportal/radius_accounting.inc @@ -42,6 +42,34 @@ pfSense_MODULE: captiveportal */ + +/** + * Get the NAS-IP-Address based on the current wan address + * + * Use functions in interfaces.inc to find this out + * + */ +if (!function_exists('getNasIP')) { + function getNasIP() + { + global $config, $cpzone; + + if (empty($config['captiveportal'][$cpzone]['radiussrcip_attribute'])) { + $nasIp = get_interface_ip(); + } else { + if (is_ipaddr($config['captiveportal'][$cpzone]['radiussrcip_attribute'])) + $nasIp = $config['captiveportal'][$cpzone]['radiussrcip_attribute']; + else + $nasIp = get_interface_ip($config['captiveportal'][$cpzone]['radiussrcip_attribute']); + } + + if(!is_ipaddr($nasIp)) + $nasIp = "0.0.0.0"; + + return $nasIp; + } +} + /* RADIUS ACCOUNTING START ----------------------- @@ -67,12 +95,9 @@ function RADIUS_ACCOUNTING_START($ruleno, $username, $sessionid, $radiusservers, break; default: - if (is_ipaddr($config['captiveportal'][$cpzone]['radiussrcip_attribute'])) - $calledstationid = $config['captiveportal'][$cpzone]['radiussrcip_attribute']; - else - $calledstationid = get_interface_ip($config['captiveportal'][$cpzone]['radiussrcip_attribute']); - $callingstationid = $clientmac; + $calledstationid = getNasIP(); $callingstationid = $clientmac; + break; } // Create our instance @@ -189,8 +214,9 @@ function RADIUS_ACCOUNTING_STOP($ruleno,$username,$sessionid,$start_time,$radius break; default: - $calledstationid = get_interface_ip("wan"); + $calledstationid = getNasIP(); $callingstationid = $clientmac; + break; } // Create our instance, see if we should use Accounting Interim Updates or Accounting STOP messages -- cgit v1.1