summaryrefslogtreecommitdiffhomepage
path: root/table/policy.go
diff options
context:
space:
mode:
authorHiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>2016-12-07 10:35:44 -0800
committerHiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>2016-12-14 15:28:37 -0800
commitae496021e06452f92da8738671112597374775c1 (patch)
tree69841e23e1b679058a9265873594476c662a6246 /table/policy.go
parent2c66865d5ee574d868284dd6a8e104ebe2aab283 (diff)
policy: allow using invert condition in statement
Signed-off-by: Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>
Diffstat (limited to 'table/policy.go')
-rw-r--r--table/policy.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/table/policy.go b/table/policy.go
index 5916d0a3..72313007 100644
--- a/table/policy.go
+++ b/table/policy.go
@@ -110,6 +110,16 @@ func (o MatchOption) String() string {
}
}
+func (o MatchOption) ConvertToMatchSetOptionsRestrictedType() config.MatchSetOptionsRestrictedType {
+ switch o {
+ case MATCH_OPTION_ANY:
+ return config.MATCH_SET_OPTIONS_RESTRICTED_TYPE_ANY
+ case MATCH_OPTION_INVERT:
+ return config.MATCH_SET_OPTIONS_RESTRICTED_TYPE_INVERT
+ }
+ return "unknown"
+}
+
type MedActionType int
const (
@@ -2363,10 +2373,10 @@ func (s *Statement) ToConfig() *config.Statement {
switch c.(type) {
case *PrefixCondition:
v := c.(*PrefixCondition)
- cond.MatchPrefixSet = config.MatchPrefixSet{PrefixSet: v.set.Name(), MatchSetOptions: config.IntToMatchSetOptionsRestrictedTypeMap[int(v.option)]}
+ cond.MatchPrefixSet = config.MatchPrefixSet{PrefixSet: v.set.Name(), MatchSetOptions: v.option.ConvertToMatchSetOptionsRestrictedType()}
case *NeighborCondition:
v := c.(*NeighborCondition)
- cond.MatchNeighborSet = config.MatchNeighborSet{NeighborSet: v.set.Name(), MatchSetOptions: config.IntToMatchSetOptionsRestrictedTypeMap[int(v.option)]}
+ cond.MatchNeighborSet = config.MatchNeighborSet{NeighborSet: v.set.Name(), MatchSetOptions: v.option.ConvertToMatchSetOptionsRestrictedType()}
case *AsPathLengthCondition:
v := c.(*AsPathLengthCondition)
cond.BgpConditions.AsPathLength = config.AsPathLength{Operator: config.IntToAttributeComparisonMap[int(v.operator)], Value: v.length}