[Xorp-hackers] [PATCH] xorp: policy: Fix usage of network{4, 6}-lists

igorm at etf.rs igorm at etf.rs
Mon Jun 11 01:29:50 PDT 2012


From: Igor Maravic <igorm at etf.rs>

Add '~' as string distguisher, instead of ' '.
Also add posible completions to policy template.

Reported-by: Jens Dackenberg <jens.devel at gmail.com>
Signed-off-by: Igor Maravic <igorm at etf.rs>
---
 xorp/etc/templates/policy.tp  |   30 ++++++++++++++++++++++++++++--
 xorp/policy/common/element.cc |    4 ++--
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/xorp/etc/templates/policy.tp b/xorp/etc/templates/policy.tp
index 5e01975..b48bcaa 100644
--- a/xorp/etc/templates/policy.tp
+++ b/xorp/etc/templates/policy.tp
@@ -340,8 +340,21 @@ policy {
 
 	    modifier {
 		%help: short "Set prefix modifier";
+		%allow: $(@) ":" %help: "Exact";
+		%allow: $(@) "==" %help: "Exact";
+		%allow: $(@) "exact" %help: "Exact";
+		%allow: $(@) "!=" %help: "Not";
+		%allow: $(@) "not" %help: "Not";
+		%allow: $(@) ">=" %help: "Or shorter";
+		%allow: $(@) "orshorter" %help: "Or shorter";
+		%allow: $(@) ">" %help: "Shorter";
+		%allow: $(@) "shorter" %help: "Shorter";
+		%allow: $(@) "<" %help: "Longer";
+		%allow: $(@) "longer" %help: "Longer";
+		%allow: $(@) "<=" %help: "Or longer";
+		%allow: $(@) "orlonger" %help: "Or longer";
 		%set: xrl "$(policy.targetname)/policy/0.1/delete_from_set?type:txt=set_ipv4net&set:txt=$(network4-list.@)&element:txt=$(network.@)";
-		%set: xrl "$(policy.targetname)/policy/0.1/add_to_set?type:txt=set_ipv4net&set:txt=$(network4-list.@)&element:txt=$(network.@) $(@)";
+		%set: xrl "$(policy.targetname)/policy/0.1/add_to_set?type:txt=set_ipv4net&set:txt=$(network4-list.@)&element:txt=$(network.@)~$(@)";
 		%delete: xrl "$(policy.targetname)/policy/0.1/delete_from_set?type:txt=set_ipv4net&set:txt=$(network4-list.@)&element:txt=$(network.@)";
 		%delete: xrl "$(policy.targetname)/policy/0.1/add_to_set?type:txt=set_ipv4net&set:txt=$(network4-list.@)&element:txt=$(network.@)";
 	    }
@@ -366,8 +379,21 @@ policy {
 
 	    modifier {
 		%help: short "Set prefix modifier";
+		%allow: $(@) ":" %help: "Exact";
+		%allow: $(@) "==" %help: "Exact";
+		%allow: $(@) "exact" %help: "Exact";
+		%allow: $(@) "!=" %help: "Not";
+		%allow: $(@) "not" %help: "Not";
+		%allow: $(@) ">=" %help: "Or shorter";
+		%allow: $(@) "orshorter" %help: "Or shorter";
+		%allow: $(@) ">" %help: "Shorter";
+		%allow: $(@) "shorter" %help: "Shorter";
+		%allow: $(@) "<" %help: "Longer";
+		%allow: $(@) "longer" %help: "Longer";
+		%allow: $(@) "<=" %help: "Or longer";
+		%allow: $(@) "orlonger" %help: "Or longer";
 		%set: xrl "$(policy.targetname)/policy/0.1/delete_from_set?type:txt=set_ipv6net&set:txt=$(network6-list.@)&element:txt=$(network.@)";
-		%set: xrl "$(policy.targetname)/policy/0.1/add_to_set?type:txt=set_ipv6net&set:txt=$(network6-list.@)&element:txt=$(network.@) $(@)";
+		%set: xrl "$(policy.targetname)/policy/0.1/add_to_set?type:txt=set_ipv6net&set:txt=$(network6-list.@)&element:txt=$(network.@)~$(@)";
 		%delete: xrl "$(policy.targetname)/policy/0.1/delete_from_set?type:txt=set_ipv6net&set:txt=$(network6-list.@)&element:txt=$(network.@)";
 		%delete: xrl "$(policy.targetname)/policy/0.1/add_to_set?type:txt=set_ipv6net&set:txt=$(network6-list.@)&element:txt=$(network.@)";
 	    }
diff --git a/xorp/policy/common/element.cc b/xorp/policy/common/element.cc
index 2d9523f..a09a417 100644
--- a/xorp/policy/common/element.cc
+++ b/xorp/policy/common/element.cc
@@ -140,7 +140,7 @@ ElemNet<A>::ElemNet(const char* str) : Element(_hash), _net(NULL),
     // parse modifier
     string in = str;
 
-    const char* p = strchr(str, ' ');
+    const char* p = strchr(str, '~');
     if (p) {
 	in = in.substr(0, p - str);
 
@@ -189,7 +189,7 @@ ElemNet<A>::str() const
     string str = _net->str();
 
     if (_mod != MOD_NONE) {
-	str += " ";
+	str += "~";
 	str += mod_to_str(_mod);
     }
 
-- 
1.7.5.4



More information about the Xorp-hackers mailing list