summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2006-09-22 14:39:57 +0000
committerScott Ullrich <sullrich@pfsense.org>2006-09-22 14:39:57 +0000
commit920cafaf0b7ab5116a683fe05a8e70ac0b2bef01 (patch)
tree0157d7e53e9bc557ef82616795c13168cf5c89a7 /etc/inc
parente7933a2bb4fffe1ac22d236fc28dc73f46952338 (diff)
downloadpfsense-920cafaf0b7ab5116a683fe05a8e70ac0b2bef01.zip
pfsense-920cafaf0b7ab5116a683fe05a8e70ac0b2bef01.tar.gz
Move helper function to correct area
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/captiveportal.inc25
1 files changed, 25 insertions, 0 deletions
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc
index e09a027..1c44870 100644
--- a/etc/inc/captiveportal.inc
+++ b/etc/inc/captiveportal.inc
@@ -940,4 +940,29 @@ function captiveportal_write_elements() {
return 0;
}
+/*
+ * This function will calculate the lowest free firewall ruleno
+ * within the range specified based on the actual installed rules
+ *
+ */
+
+function captiveportal_get_next_ipfw_ruleno($rulenos_start = 10000, $rulenos_range_max = 9899) {
+
+ exec("/sbin/ipfw show", $fwrules);
+ foreach ($fwrules as $fwrule) {
+ preg_match("/^(\d+)\s+/", $fwrule, $matches);
+ $rulenos_used[] = $matches[1];
+ }
+ $rulenos_used = array_unique($rulenos_used);
+ $rulenos_range = count($rulenos_used);
+ if ($rulenos_range > $rulenos_range_max) {
+ return NULL;
+ }
+ $rulenos_pool = range($rulenos_start, ($rulenos_start + $rulenos_range));
+ $rulenos_free = array_diff($rulenos_pool, $rulenos_used);
+ $ruleno = array_shift($rulenos_free);
+
+ return $ruleno;
+}
+
?> \ No newline at end of file
OpenPOWER on IntegriCloud