From 4719ec6b4a0dd403010a33376eee9b30b3a99a25 Mon Sep 17 00:00:00 2001 From: Naoto Hanaue Date: Wed, 8 Jul 2015 11:35:51 +0900 Subject: policy: support extended community condition --- packet/bgp.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'packet') 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{} } -- cgit v1.2.3