Revision baaa8bb1
Added by Erik Fonnesbeck over 14 years ago
etc/inc/pfsense-utils.inc | ||
---|---|---|
2107 | 2107 |
return ""; |
2108 | 2108 |
} |
2109 | 2109 |
|
2110 |
/* sort by interface only, retain the original order of rules that apply to |
|
2111 |
the same interface */ |
|
2112 |
function filter_rules_sort() { |
|
2113 |
global $config; |
|
2114 |
|
|
2115 |
/* mark each rule with the sequence number (to retain the order while sorting) */ |
|
2116 |
for ($i = 0; isset($config['filter']['rule'][$i]); $i++) |
|
2117 |
$config['filter']['rule'][$i]['seq'] = $i; |
|
2118 |
|
|
2119 |
usort($config['filter']['rule'], "filter_rules_compare"); |
|
2120 |
|
|
2121 |
/* strip the sequence numbers again */ |
|
2122 |
for ($i = 0; isset($config['filter']['rule'][$i]); $i++) |
|
2123 |
unset($config['filter']['rule'][$i]['seq']); |
|
2124 |
} |
|
2125 |
function filter_rules_compare($a, $b) { |
|
2126 |
if ($a['interface'] == $b['interface'] || ( isset($a['floating']) && isset($b['floating']) )) |
|
2127 |
return $a['seq'] - $b['seq']; |
|
2128 |
else if (isset($a['floating'])) |
|
2129 |
return -1; |
|
2130 |
else if (isset($b['floating'])) |
|
2131 |
return 1; |
|
2132 |
else |
|
2133 |
return compare_interface_friendly_names($a['interface'], $b['interface']); |
|
2134 |
} |
|
2135 |
|
|
2110 | 2136 |
?> |
Also available in: Unified diff
Move this function to allow removing it from easyrule.