diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-01-23 17:18:56 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-01-25 04:57:11 -0800 |
commit | d94f5d2c03b8eb265cfa1af5dce43da7194538b8 (patch) | |
tree | 94872abec34c97a19c9abe457b10217d8c44964a /table | |
parent | 3817b82f9d57ce02adb025f5acff6f06b54c6641 (diff) |
config: add openconfig identity structs in bgp_configs.go
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r-- | table/policy.go | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/table/policy.go b/table/policy.go index 81010a9d..68792a6c 100644 --- a/table/policy.go +++ b/table/policy.go @@ -1546,15 +1546,12 @@ func NewAsPathLengthCondition(c config.AsPathLength) (*AsPathLengthCondition, er return nil, nil } var op AttributeComparison - switch strings.ToLower(c.Operator) { - case "eq": - op = ATTRIBUTE_EQ - case "ge": - op = ATTRIBUTE_GE - case "le": - op = ATTRIBUTE_LE - default: + if i := c.Operator.ToInt(); i < 0 { return nil, fmt.Errorf("invalid as path length operator: %s", c.Operator) + } else { + // take mod 3 because we have extended openconfig attribute-comparison + // for simple configuration. see config.AttributeComparison definition + op = AttributeComparison(i % 3) } return &AsPathLengthCondition{ length: c.Value, @@ -1582,9 +1579,7 @@ func NewRpkiValidationConditionFromApiStruct(a int32) (*RpkiValidationCondition, if a < 1 { return nil, nil } - var typ config.RpkiValidationResultType - typ = typ.FromInt(int(a)) - return NewRpkiValidationCondition(typ) + return NewRpkiValidationCondition(config.IntToRpkiValidationResultTypeMap[int(a)]) } func NewRpkiValidationCondition(c config.RpkiValidationResultType) (*RpkiValidationCondition, error) { @@ -1735,8 +1730,7 @@ func NewCommunityActionFromApiStruct(a *api.CommunityAction) (*CommunityAction, } var list []uint32 var removeList []*regexp.Regexp - var op config.BgpSetCommunityOptionType - op = op.FromInt(int(a.Type)) + op := config.IntToBgpSetCommunityOptionTypeMap[int(a.Type)] if op == config.BGP_SET_COMMUNITY_OPTION_TYPE_REMOVE { removeList = make([]*regexp.Regexp, 0, len(a.Communities)) } else { @@ -1857,8 +1851,7 @@ func NewExtCommunityActionFromApiStruct(a *api.CommunityAction) (*ExtCommunityAc var list []bgp.ExtendedCommunityInterface var removeList []*regexp.Regexp subtypeList := make([]bgp.ExtendedCommunityAttrSubType, 0, len(a.Communities)) - var op config.BgpSetCommunityOptionType - op = op.FromInt(int(a.Type)) + op := config.IntToBgpSetCommunityOptionTypeMap[int(a.Type)] if op == config.BGP_SET_COMMUNITY_OPTION_TYPE_REMOVE { removeList = make([]*regexp.Regexp, 0, len(a.Communities)) } else { |