diff options
author | rbgarga <garga@FreeBSD.org> | 2013-02-04 01:25:40 -0800 |
---|---|---|
committer | rbgarga <garga@FreeBSD.org> | 2013-02-04 01:25:40 -0800 |
commit | 032c72453158ed20c38c57015e3ffd1eead2e3dc (patch) | |
tree | e82c95fd04fbd4999acc6b0878684254c9a02b7c | |
parent | e3c4b0244c805daf69fc661dff8dded100ee44cc (diff) | |
parent | c02ef67f8fa7825f2859293c4c0ddeb5b2d9abb8 (diff) | |
download | pfsense-032c72453158ed20c38c57015e3ffd1eead2e3dc.zip pfsense-032c72453158ed20c38c57015e3ffd1eead2e3dc.tar.gz |
Merge pull request #372 from miken32/reverseacct
Allow RADIUS accounting to be reversed
-rw-r--r-- | etc/inc/captiveportal.inc | 23 | ||||
-rwxr-xr-x | usr/local/www/services_captiveportal.php | 13 |
2 files changed, 29 insertions, 7 deletions
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc index 2582ea0..e7e9e47 100644 --- a/etc/inc/captiveportal.inc +++ b/etc/inc/captiveportal.inc @@ -1480,22 +1480,35 @@ function captiveportal_get_ipfw_passthru_ruleno($value) { */ function getVolume($ip) { - global $cpzone; + global $config, $cpzone; + $reverse = empty($config['captiveportal'][$cpzone]['reverseacct']) ? false : true; $volume = array(); // 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); if (is_array($ipfw)) { - $volume['input_pkts'] = $ipfw['packets']; - $volume['input_bytes'] = $ipfw['bytes']; + if ($reverse) { + $volume['output_pkts'] = $ipfw['packets']; + $volume['output_bytes'] = $ipfw['bytes']; + } + else { + $volume['input_pkts'] = $ipfw['packets']; + $volume['input_bytes'] = $ipfw['bytes']; + } } $ipfw = pfSense_ipfw_getTablestats($cpzone, 2, $ip); if (is_array($ipfw)) { - $volume['output_pkts'] = $ipfw['packets']; - $volume['output_bytes'] = $ipfw['bytes']; + if ($reverse) { + $volume['input_pkts'] = $ipfw['packets']; + $volume['input_bytes'] = $ipfw['bytes']; + } + else { + $volume['output_pkts'] = $ipfw['packets']; + $volume['output_bytes'] = $ipfw['bytes']; + } } return $volume; diff --git a/usr/local/www/services_captiveportal.php b/usr/local/www/services_captiveportal.php index 42362d8..373a199 100755 --- a/usr/local/www/services_captiveportal.php +++ b/usr/local/www/services_captiveportal.php @@ -133,6 +133,7 @@ if ($a_cp[$cpzone]) { $pconfig['passthrumacadd'] = isset($a_cp[$cpzone]['passthrumacadd']); $pconfig['passthrumacaddusername'] = isset($a_cp[$cpzone]['passthrumacaddusername']); $pconfig['radmac_format'] = $a_cp[$cpzone]['radmac_format']; + $pconfig['reverseacct'] = isset($a_cp[$cpzone]['reverseacct']); $pconfig['page'] = array(); if ($a_cp[$cpzone]['page']['htmltext']) $pconfig['page']['htmltext'] = $a_cp[$cpzone]['page']['htmltext']; @@ -303,6 +304,7 @@ if ($_POST) { $newcp['passthrumacadd'] = $_POST['passthrumacadd'] ? true : false; $newcp['passthrumacaddusername'] = $_POST['passthrumacaddusername'] ? true : false; $newcp['radmac_format'] = $_POST['radmac_format'] ? $_POST['radmac_format'] : false; + $newcp['reverseacct'] = $_POST['reverseacct'] ? true : false; if (!is_array($newcp['page'])) $newcp['page'] = array(); @@ -392,6 +394,7 @@ function enable_change(enable_change) { document.iform.reauthenticateacct[0].disabled = radacct_dis; document.iform.reauthenticateacct[1].disabled = radacct_dis; document.iform.reauthenticateacct[2].disabled = radacct_dis; + document.iform.reverseacct.disabled = (radius_endis || !document.iform.radacct_enable.checked) && !enable_change; } //--> </script> @@ -753,12 +756,12 @@ function enable_change(enable_change) { <td colspan="2" class="list" height="12"></td> </tr> <tr> - <td colspan="2" valign="top" class="optsect_t2"><?=gettext("RADIUS options"); ?></td> + <td colspan="2" valign="top" class="listtopic"><?=gettext("RADIUS options"); ?></td> </tr> <tr> <td class="vncell" valign="top"><?=gettext("RADIUS NAS IP attribute"); ?></td> - <td> + <td class="vtable"> <select name="radiussrcip_attribute" id="radiussrcip_attribute"> <?php $iflist = get_configured_interface_with_descr(); foreach ($iflist as $ifdesc => $ifdescr) { @@ -814,6 +817,12 @@ function enable_change(enable_change) { "the Called-Station-Id to the client's MAC address. Default behavior is Calling-Station-Id = client's MAC address and Called-Station-Id = %s's WAN IP address."), $g['product_name']);?></td> </tr> + + <tr> + <td class="vncell" valign="top"><?=gettext("Accounting Style"); ?></td> + <td class="vtable"><input name="reverseacct" type="checkbox" id="reverseacct" value="yes" <?php if ($pconfig['reverseacct']) echo "checked"; ?>><strong><?=gettext("Invert Acct-Input-Octets and Acct-Output-Octets"); ?></strong><br> + <?=gettext("When this is enabled, data counts for RADIUS accounting packets will be taken from the client perspective, not the NAS. Acct-Input-Octets will represent download, and Acct-Output-Octets will represent upload."); ?></td> + </tr> </table> </tr> <tr> |