summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorErik Fonnesbeck <efonnes@gmail.com>2010-11-10 22:58:30 -0700
committerErik Fonnesbeck <efonnes@gmail.com>2010-11-10 22:58:30 -0700
commitbaaa8bb142f1f86dd7a7e60fe34fc07020fb482e (patch)
tree146336050de7920b8b62f217c865e64dda1efae4 /etc
parent88bc276013552268ebef7058cd7b58c89de67125 (diff)
downloadpfsense-baaa8bb142f1f86dd7a7e60fe34fc07020fb482e.zip
pfsense-baaa8bb142f1f86dd7a7e60fe34fc07020fb482e.tar.gz
Move this function to allow removing it from easyrule.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/pfsense-utils.inc26
1 files changed, 26 insertions, 0 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 6bd1671..7c0bdc0 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -2107,4 +2107,30 @@ function get_country_name($country_code) {
return "";
}
+/* sort by interface only, retain the original order of rules that apply to
+ the same interface */
+function filter_rules_sort() {
+ global $config;
+
+ /* mark each rule with the sequence number (to retain the order while sorting) */
+ for ($i = 0; isset($config['filter']['rule'][$i]); $i++)
+ $config['filter']['rule'][$i]['seq'] = $i;
+
+ usort($config['filter']['rule'], "filter_rules_compare");
+
+ /* strip the sequence numbers again */
+ for ($i = 0; isset($config['filter']['rule'][$i]); $i++)
+ unset($config['filter']['rule'][$i]['seq']);
+}
+function filter_rules_compare($a, $b) {
+ if ($a['interface'] == $b['interface'] || ( isset($a['floating']) && isset($b['floating']) ))
+ return $a['seq'] - $b['seq'];
+ else if (isset($a['floating']))
+ return -1;
+ else if (isset($b['floating']))
+ return 1;
+ else
+ return compare_interface_friendly_names($a['interface'], $b['interface']);
+}
+
?>
OpenPOWER on IntegriCloud