summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2006-10-05 16:06:37 +0000
committerScott Ullrich <sullrich@pfsense.org>2006-10-05 16:06:37 +0000
commit360d815d22bb7e2c100a445a0bdbaafdd7f6a513 (patch)
treea99fe812925552494cd5d15e4f6265abade03424 /etc/inc
parent2a871f193e4a21f5ddc1b7507a0f9953630e0e08 (diff)
downloadpfsense-360d815d22bb7e2c100a445a0bdbaafdd7f6a513.zip
pfsense-360d815d22bb7e2c100a445a0bdbaafdd7f6a513.tar.gz
Add missing getVolume() function
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/captiveportal.inc35
1 files changed, 35 insertions, 0 deletions
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc
index 064916b..9892fc6 100644
--- a/etc/inc/captiveportal.inc
+++ b/etc/inc/captiveportal.inc
@@ -992,6 +992,41 @@ function captiveportal_get_next_ipfw_ruleno($rulenos_start = 10000, $rulenos_ran
}
/**
+ * This function will calculate the traffic produced by a client
+ * based on its firewall rule
+ *
+ * Point of view: NAS
+ *
+ * Input means: from the client
+ * Output means: to the client
+ *
+ */
+
+function getVolume($ruleno) {
+
+ $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 ;
+
+ // Ingress
+ exec("/sbin/ipfw show {$ruleno}", $ipfw);
+ preg_match("/(\d+)\s+(\d+)\s+(\d+)\s+.*/", $ipfw[0], $matches);
+ $volume['input_pkts'] = $matches[2];
+ $volume['input_bytes'] = $matches[3];
+
+ // Flush internal buffer
+ unset($matches);
+
+ // Outgress
+ preg_match("/(\d+)\s+(\d+)\s+(\d+)\s+.*/", $ipfw[1], $matches);
+ $volume['output_pkts'] = $matches[2];
+ $volume['output_bytes'] = $matches[3];
+
+ return $volume;
+}
+
+/**
* Get the NAS-Identifier
*
* We will use our local hostname to make up the nas_id
OpenPOWER on IntegriCloud