diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-27 07:12:51 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-27 07:12:51 -0800 |
commit | ebd6f9a06639df996da8e4570b8c26b664bbbc1a (patch) | |
tree | d30505b840eba4d2aaef5d914374154c822bccec /packet | |
parent | a3c1e53deda9f9834994751382f64827c14a9c32 (diff) |
packet: BGPCapabiltyCode cleanup
use stringer command.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'packet')
-rw-r--r-- | packet/bgp.go | 36 | ||||
-rw-r--r-- | packet/bgpcapabilitycode_string.go | 40 |
2 files changed, 48 insertions, 28 deletions
diff --git a/packet/bgp.go b/packet/bgp.go index fda524d0..60502e1a 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -56,34 +56,14 @@ type BGPCapabilityCode uint8 const ( BGP_CAP_MULTIPROTOCOL BGPCapabilityCode = 1 - BGP_CAP_ROUTE_REFRESH = 2 - BGP_CAP_CARRYING_LABEL_INFO = 4 - BGP_CAP_GRACEFUL_RESTART = 64 - BGP_CAP_FOUR_OCTET_AS_NUMBER = 65 - BGP_CAP_ENHANCED_ROUTE_REFRESH = 70 - BGP_CAP_ROUTE_REFRESH_CISCO = 128 + BGP_CAP_ROUTE_REFRESH BGPCapabilityCode = 2 + BGP_CAP_CARRYING_LABEL_INFO BGPCapabilityCode = 4 + BGP_CAP_GRACEFUL_RESTART BGPCapabilityCode = 64 + BGP_CAP_FOUR_OCTET_AS_NUMBER BGPCapabilityCode = 65 + BGP_CAP_ENHANCED_ROUTE_REFRESH BGPCapabilityCode = 70 + BGP_CAP_ROUTE_REFRESH_CISCO BGPCapabilityCode = 128 ) -func (c BGPCapabilityCode) String() string { - switch c { - case BGP_CAP_MULTIPROTOCOL: - return "MultiProtocol" - case BGP_CAP_ROUTE_REFRESH: - return "RouteRefresh" - case BGP_CAP_CARRYING_LABEL_INFO: - return "CarryingLabelInfo" - case BGP_CAP_GRACEFUL_RESTART: - return "GracefulRestart" - case BGP_CAP_FOUR_OCTET_AS_NUMBER: - return "FourOctetASNumber" - case BGP_CAP_ENHANCED_ROUTE_REFRESH: - return "EnhancedRouteRefresh" - case BGP_CAP_ROUTE_REFRESH_CISCO: - return "RouteRefreshCisco" - } - return "Unknown" -} - type ParameterCapabilityInterface interface { DecodeFromBytes([]byte) error Serialize() ([]byte, error) @@ -943,8 +923,8 @@ func (n *RouteTargetMembershipNLRI) SAFI() uint8 { func (n *RouteTargetMembershipNLRI) Len() int { return 12 } -func rfshift(afi uint16, safi uint8) RouteFamily { - return RouteFamily (int(afi)<<16 | int(safi)) +func rfshift(afi uint16, safi uint8) RouteFamily { + return RouteFamily(int(afi)<<16 | int(safi)) } type RouteFamily int diff --git a/packet/bgpcapabilitycode_string.go b/packet/bgpcapabilitycode_string.go new file mode 100644 index 00000000..0dc70a87 --- /dev/null +++ b/packet/bgpcapabilitycode_string.go @@ -0,0 +1,40 @@ +// generated by stringer -type=BGPCapabilityCode; DO NOT EDIT + +package bgp + +import "fmt" + +const ( + _BGPCapabilityCode_name_0 = "BGP_CAP_MULTIPROTOCOLBGP_CAP_ROUTE_REFRESH" + _BGPCapabilityCode_name_1 = "BGP_CAP_CARRYING_LABEL_INFO" + _BGPCapabilityCode_name_2 = "BGP_CAP_GRACEFUL_RESTARTBGP_CAP_FOUR_OCTET_AS_NUMBER" + _BGPCapabilityCode_name_3 = "BGP_CAP_ENHANCED_ROUTE_REFRESH" + _BGPCapabilityCode_name_4 = "BGP_CAP_ROUTE_REFRESH_CISCO" +) + +var ( + _BGPCapabilityCode_index_0 = [...]uint8{0, 21, 42} + _BGPCapabilityCode_index_1 = [...]uint8{0, 27} + _BGPCapabilityCode_index_2 = [...]uint8{0, 24, 52} + _BGPCapabilityCode_index_3 = [...]uint8{0, 30} + _BGPCapabilityCode_index_4 = [...]uint8{0, 27} +) + +func (i BGPCapabilityCode) String() string { + switch { + case 1 <= i && i <= 2: + i -= 1 + return _BGPCapabilityCode_name_0[_BGPCapabilityCode_index_0[i]:_BGPCapabilityCode_index_0[i+1]] + case i == 4: + return _BGPCapabilityCode_name_1 + case 64 <= i && i <= 65: + i -= 64 + return _BGPCapabilityCode_name_2[_BGPCapabilityCode_index_2[i]:_BGPCapabilityCode_index_2[i+1]] + case i == 70: + return _BGPCapabilityCode_name_3 + case i == 128: + return _BGPCapabilityCode_name_4 + default: + return fmt.Sprintf("BGPCapabilityCode(%d)", i) + } +} |