Catch up with mac needed for all operations in the table nowdays.

This commit is contained in:
Ermal 2013-11-23 19:32:49 +00:00
parent e5f2cf3a94
commit fcaf17090a
4 changed files with 13 additions and 13 deletions

View File

@ -664,7 +664,7 @@ function captiveportal_prune_old() {
$uidletimeout = (is_numeric($cpentry[8])) ? $cpentry[8] : $idletimeout;
/* if an idle timeout is specified, get last activity timestamp from ipfw */
if (!$timedout && $uidletimeout > 0) {
$lastact = captiveportal_get_last_activity($cpentry[2]);
$lastact = captiveportal_get_last_activity($cpentry[2], $cpentry[3]);
/* If the user has logged on but not sent any traffic they will never be logged out.
* We "fix" this by setting lastact to the login timestamp.
*/
@ -712,8 +712,8 @@ function captiveportal_prune_old() {
$cpentry[2], // clientip
$cpentry[3], // clientmac
10); // NAS Request
$_gb = @pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_ZERO_ENTRY_STATS, 1, $cpentry[2]);
$_gb = @pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_ZERO_ENTRY_STATS, 2, $cpentry[2]);
$_gb = @pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_ZERO_ENTRY_STATS, 1, $cpentry[2], $cpentry[3]);
$_gb = @pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_ZERO_ENTRY_STATS, 2, $cpentry[2], $cpentry[3]);
RADIUS_ACCOUNTING_START($cpentry[1], // ruleno
$cpentry[4], // username
$cpentry[5], // sessionid
@ -856,8 +856,8 @@ function captiveportal_disconnect($dbent, $radiusservers,$term_cause = 1,$stop_t
if (is_ipaddr($dbent[2])) {
/* Delete client's ip entry from tables 1 and 2. */
$_gb = @pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_DEL, 1, $dbent[2]);
$_gb = @pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_DEL, 2, $dbent[2]);
$_gb = @pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_DEL, 1, $dbent[2], $dbent[3]);
$_gb = @pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_DEL, 2, $dbent[2], $dbent[3]);
/* XXX: Redundant?! Ensure all pf(4) states are killed. */
$_gb = @pfSense_kill_states($dbent[2]);
$_gb = @pfSense_kill_srcstates($dbent[2]);
@ -1096,10 +1096,10 @@ function captiveportal_allowedip_configure() {
}
/* get last activity timestamp given client IP address */
function captiveportal_get_last_activity($ip) {
function captiveportal_get_last_activity($ip, $mac = NULL) {
global $cpzone;
$ipfwoutput = pfSense_ipfw_getTablestats($cpzone, 1, $ip);
$ipfwoutput = pfSense_ipfw_getTablestats($cpzone, 1, $ip, $mac);
/* Reading only from one of the tables is enough of approximation. */
if (is_array($ipfwoutput)) {
return $ipfwoutput['timestamp'];
@ -1544,7 +1544,7 @@ function captiveportal_get_ipfw_passthru_ruleno($value) {
*
*/
function getVolume($ip) {
function getVolume($ip, $mac = NULL) {
global $config, $cpzone;
$reverse = empty($config['captiveportal'][$cpzone]['reverseacct']) ? false : true;
@ -1552,7 +1552,7 @@ function getVolume($ip) {
// Initialize vars properly, since we don't want NULL vars
$volume['input_pkts'] = $volume['input_bytes'] = $volume['output_pkts'] = $volume['output_bytes'] = 0 ;
$ipfw = pfSense_ipfw_getTablestats($cpzone, 1, $ip);
$ipfw = pfSense_ipfw_getTablestats($cpzone, 1, $ip, $mac);
if (is_array($ipfw)) {
if ($reverse) {
$volume['output_pkts'] = $ipfw['packets'];

View File

@ -176,7 +176,7 @@ function RADIUS_ACCOUNTING_STOP($ruleno,$username,$sessionid,$start_time,$radius
$radiusvendor = $config['captiveportal'][$cpzone]['radiusvendor'] ? $config['captiveportal'][$cpzone]['radiusvendor'] : null;
$stop_time = (empty($stop_time)) ? time() : $stop_time;
$session_time = $stop_time - $start_time;
$volume = getVolume($clientip);
$volume = getVolume($clientip, $clientmac);
$volume['input_bytes_radius'] = remainder($volume['input_bytes']);
$volume['input_gigawords'] = gigawords($volume['input_bytes']);
$volume['output_bytes_radius'] = remainder($volume['output_bytes']);

View File

@ -172,7 +172,7 @@ $mac_man = load_mac_manufacturer_table();
<td class="listr"><?=$cpent[4];?>&nbsp;</td>
<td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
<?php if ($_GET['showact']):
$last_act = captiveportal_get_last_activity($cpent[2]); ?>
$last_act = captiveportal_get_last_activity($cpent[2], $cpent[3]); ?>
<td class="listr"><?php if ($last_act != 0) echo htmlspecialchars(date("m/d/Y H:i:s", $last_act));?></td>
<?php endif; ?>
<td valign="middle" class="list" nowrap>

View File

@ -67,7 +67,7 @@ foreach ($a_cp as $cpzone => $cp) {
foreach ($cpdb as $cpent) {
$cpent[10] = $cpzone;
if ($_GET['showact'])
$cpent[11] = captiveportal_get_last_activity($cpent[2]);
$cpent[11] = captiveportal_get_last_activity($cpent[2], $cpentry[3]);
$cpdb_all[] = $cpent;
}
}
@ -111,4 +111,4 @@ if ($_GET['order']) {
<a href="?order=<?=$_GET['order'];?>&amp;showact=<?=$_GET['showact'];?>&amp;act=del&amp;zone=<?=$cpent[10];?>&amp;id=<?=$cpent[5];?>" onclick="return confirm('Do you really want to disconnect this client?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="x" /></a></td>
</tr>
<?php endforeach; ?>
</table>
</table>