From 2f038c0b12ebeed6677fb8c1c3455a493cdf66c2 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Fri, 17 Mar 2006 22:08:25 +0000 Subject: MFC 10668 expand aliases to include " ! " to negate all entries in a list. --- etc/inc/shaper.inc | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'etc/inc/shaper.inc') diff --git a/etc/inc/shaper.inc b/etc/inc/shaper.inc index 00184e7..b794e48 100644 --- a/etc/inc/shaper.inc +++ b/etc/inc/shaper.inc @@ -470,7 +470,29 @@ function filter_generate_pf_altq_rules() { } if (isset($rule['source']['not'])) { - $src = "!{$src}"; + + /*pf is not really happy with this sexy ($src = "!{$src}";) approach of + * negating a list or macro. So we have to write out a ! on each entry. + */ + + /* not very happy with this! but it beats copying this section to + * several places. + */ + $alias = alias_expand(substr($src, 1)); + + if(isset($alias) && stristr($alias, "$")) { + $alias = alias_expand_value(substr($src, 1)); + $src = "{"; + foreach(preg_split("/[\s]+/", $alias) as $item) { + if($item != "") { + $src .= " !{$item}"; + } + } + $src .= " }"; + } + else { + $src = "!{$src}"; + } } $line .= "from {$src} "; @@ -531,7 +553,29 @@ function filter_generate_pf_altq_rules() { } if (isset($rule['destination']['not'])) { - $dst = "!{$dst}"; + + /*pf is not really happy with this sexy ($dst = "!{$dst}";) approach of + * negating a list or macro. So we have to write out a ! on each entry. + */ + + /* not very happy with this! but it beats copying this section to + * several places. + */ + $alias = alias_expand(substr($dst, 1)); + + if(isset($alias) && stristr($alias, "$")) { + $alias = alias_expand_value(substr($dst, 1)); + $dst = "{"; + foreach(preg_split("/[\s]+/", $alias) as $item) { + if($item != "") { + $dst .= " !{$item}"; + } + } + $dst .= " }"; + } + else { + $dst = "!{$dst}"; + } } $line .= "to {$dst} "; -- cgit v1.1