summaryrefslogtreecommitdiffstats
path: root/src/etc/inc
diff options
context:
space:
mode:
Diffstat (limited to 'src/etc/inc')
-rw-r--r--src/etc/inc/filter.inc13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/etc/inc/filter.inc b/src/etc/inc/filter.inc
index 6890c98..9cac2ed 100644
--- a/src/etc/inc/filter.inc
+++ b/src/etc/inc/filter.inc
@@ -102,6 +102,8 @@ $icmptypes = array(
define("ANTILOCKOUT_TRACKER", 10000);
define("BOGONS_TRACKER", 11000);
define("RFC1918_TRACKER", 12000);
+define("PFLABEL_MAXLEN", 63);
+define("USER_LABEL_INTRO", "USER_RULE: ");
$tracker = 1000000000;
$negate_tracker = 10000000;
@@ -119,10 +121,15 @@ function filter_negaterule_tracker() {
return "tracker {$negate_tracker} ";
}
+function user_rule_descr_maxlen() {
+ return PFLABEL_MAXLEN - strlen(USER_LABEL_INTRO);
+}
+
function fix_rule_label($descr) {
$descr = str_replace('"', '', $descr);
- if (strlen($descr) > 63) {
- return substr($descr, 0, 60) . "...";
+ if (strlen($descr) > PFLABEL_MAXLEN) {
+ $dots = "...";
+ return substr($descr, 0, PFLABEL_MAXLEN - strlen($dots)) . $dots;
} else {
return $descr;
}
@@ -2374,7 +2381,7 @@ function filter_generate_user_rule_arr($rule) {
$ret['rule'] = $line;
$ret['interface'] = $rule['interface'];
if ($rule['descr'] != "" and $line != "") {
- $ret['descr'] = "label \"" . fix_rule_label("USER_RULE: {$rule['descr']}") . "\"";
+ $ret['descr'] = "label \"" . fix_rule_label(USER_LABEL_INTRO . "{$rule['descr']}") . "\"";
} else {
$ret['descr'] = "label \"USER_RULE\"";
}
OpenPOWER on IntegriCloud