diff options
author | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2016-12-07 10:35:44 -0800 |
---|---|---|
committer | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2016-12-14 15:28:37 -0800 |
commit | ae496021e06452f92da8738671112597374775c1 (patch) | |
tree | 69841e23e1b679058a9265873594476c662a6246 /table/policy.go | |
parent | 2c66865d5ee574d868284dd6a8e104ebe2aab283 (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.go | 14 |
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} |