diff options
author | Naoto Hanaue <hanaue.naoto@po.ntts.co.jp> | 2015-07-08 11:35:51 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-07-11 21:45:21 +0900 |
commit | 4719ec6b4a0dd403010a33376eee9b30b3a99a25 (patch) | |
tree | e9c0f111f3429377a8ce82b16d1225be730500f9 /packet | |
parent | d5028c1b6e29c312c1364c41555cb77c09c3f64b (diff) |
policy: support extended community condition
Diffstat (limited to 'packet')
-rw-r--r-- | packet/bgp.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/packet/bgp.go b/packet/bgp.go index b95d48f3..3ff5615e 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -3023,6 +3023,7 @@ func NewPathAttributeMpUnreachNLRI(nlri []AddrPrefixInterface) *PathAttributeMpU type ExtendedCommunityInterface interface { Serialize() ([]byte, error) String() string + GetTypes() (ExtendedCommunityAttrType, ExtendedCommunityAttrSubType) ToApiStruct() *api.ExtendedCommunity } @@ -3050,6 +3051,14 @@ func (e *TwoOctetAsSpecificExtended) String() string { return fmt.Sprintf("%d:%d", e.AS, e.LocalAdmin) } +func (e *TwoOctetAsSpecificExtended) GetTypes() (ExtendedCommunityAttrType, ExtendedCommunityAttrSubType) { + t := EC_TYPE_TRANSITIVE_TWO_OCTET_AS_SPECIFIC + if !e.IsTransitive { + t = EC_TYPE_NON_TRANSITIVE_TWO_OCTET_AS_SPECIFIC + } + return t, e.SubType +} + func (e *TwoOctetAsSpecificExtended) ToApiStruct() *api.ExtendedCommunity { return &api.ExtendedCommunity{ Type: api.EXTENDED_COMMUNITIE_TYPE_TWO_OCTET_AS_SPECIFIC, @@ -3093,6 +3102,14 @@ func (e *IPv4AddressSpecificExtended) String() string { return fmt.Sprintf("%s:%d", e.IPv4.String(), e.LocalAdmin) } +func (e *IPv4AddressSpecificExtended) GetTypes() (ExtendedCommunityAttrType, ExtendedCommunityAttrSubType) { + t := EC_TYPE_TRANSITIVE_IP4_SPECIFIC + if !e.IsTransitive { + t = EC_TYPE_NON_TRANSITIVE_IP4_SPECIFIC + } + return t, e.SubType +} + func (e *IPv4AddressSpecificExtended) ToApiStruct() *api.ExtendedCommunity { return &api.ExtendedCommunity{ Type: api.EXTENDED_COMMUNITIE_TYPE_IP4_SPECIFIC, @@ -3131,6 +3148,14 @@ func (e *FourOctetAsSpecificExtended) String() string { return fmt.Sprintf("%d.%d:%d", asUpper, asLower, e.LocalAdmin) } +func (e *FourOctetAsSpecificExtended) GetTypes() (ExtendedCommunityAttrType, ExtendedCommunityAttrSubType) { + t := EC_TYPE_TRANSITIVE_FOUR_OCTET_AS_SPECIFIC + if !e.IsTransitive { + t = EC_TYPE_NON_TRANSITIVE_FOUR_OCTET_AS_SPECIFIC + } + return t, e.SubType +} + func (e *FourOctetAsSpecificExtended) ToApiStruct() *api.ExtendedCommunity { return &api.ExtendedCommunity{ Type: api.EXTENDED_COMMUNITIE_TYPE_FOUR_OCTET_AS_SPECIFIC, @@ -3259,6 +3284,14 @@ func (e *OpaqueExtended) String() string { return e.Value.String() } +func (e *OpaqueExtended) GetTypes() (ExtendedCommunityAttrType, ExtendedCommunityAttrSubType) { + t := EC_TYPE_TRANSITIVE_OPAQUE + if !e.IsTransitive { + t = EC_TYPE_NON_TRANSITIVE_OPAQUE + } + return t, ExtendedCommunityAttrSubType(0xFF) +} + func (e *OpaqueExtended) ToApiStruct() *api.ExtendedCommunity { return &api.ExtendedCommunity{ Type: api.EXTENDED_COMMUNITIE_TYPE_OPAQUE, @@ -3290,6 +3323,10 @@ func (e *UnknownExtended) String() string { return fmt.Sprintf("%d", v) } +func (e *UnknownExtended) GetTypes() (ExtendedCommunityAttrType, ExtendedCommunityAttrSubType) { + return ExtendedCommunityAttrType(0xFF), ExtendedCommunityAttrSubType(0xFF) +} + func (e *UnknownExtended) ToApiStruct() *api.ExtendedCommunity { return &api.ExtendedCommunity{} } |