diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2018-02-03 22:18:01 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-02-06 20:41:52 +0900 |
commit | 5322e63522e9320bc460f5a68538d24d11c5a0ef (patch) | |
tree | f2607108bd0580bd93032f92816ef10cc36ad548 | |
parent | 3c5ddc684ec6633698acda8e89803b456132aa62 (diff) |
table: Change type of BestPathReason to uint8
The current type is string, which size is multiple of byte(=uint8).
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
-rw-r--r-- | table/destination.go | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/table/destination.go b/table/destination.go index 5de89321..15029d52 100644 --- a/table/destination.go +++ b/table/destination.go @@ -23,33 +23,55 @@ import ( "net" "sort" + log "github.com/sirupsen/logrus" + "github.com/osrg/gobgp/config" "github.com/osrg/gobgp/packet/bgp" - log "github.com/sirupsen/logrus" ) var SelectionOptions config.RouteSelectionOptionsConfig var UseMultiplePaths config.UseMultiplePathsConfig -type BestPathReason string +type BestPathReason uint8 const ( - BPR_UNKNOWN BestPathReason = "Unknown" - BPR_ONLY_PATH BestPathReason = "Only Path" - BPR_REACHABLE_NEXT_HOP BestPathReason = "Reachable Next Hop" - BPR_HIGHEST_WEIGHT BestPathReason = "Highest Weight" - BPR_LOCAL_PREF BestPathReason = "Local Pref" - BPR_LOCAL_ORIGIN BestPathReason = "Local Origin" - BPR_ASPATH BestPathReason = "AS Path" - BPR_ORIGIN BestPathReason = "Origin" - BPR_MED BestPathReason = "MED" - BPR_ASN BestPathReason = "ASN" - BPR_IGP_COST BestPathReason = "IGP Cost" - BPR_ROUTER_ID BestPathReason = "Router ID" - BPR_OLDER BestPathReason = "Older" - BPR_NON_LLGR_STALE BestPathReason = "no LLGR Stale" + BPR_UNKNOWN BestPathReason = iota + BPR_ONLY_PATH + BPR_REACHABLE_NEXT_HOP + BPR_HIGHEST_WEIGHT + BPR_LOCAL_PREF + BPR_LOCAL_ORIGIN + BPR_ASPATH + BPR_ORIGIN + BPR_MED + BPR_ASN + BPR_IGP_COST + BPR_ROUTER_ID + BPR_OLDER + BPR_NON_LLGR_STALE ) +var BestPathReasonStringMap = map[BestPathReason]string{ + BPR_UNKNOWN: "Unknown", + BPR_ONLY_PATH: "Only Path", + BPR_REACHABLE_NEXT_HOP: "Reachable Next Hop", + BPR_HIGHEST_WEIGHT: "Highest Weight", + BPR_LOCAL_PREF: "Local Pref", + BPR_LOCAL_ORIGIN: "Local Origin", + BPR_ASPATH: "AS Path", + BPR_ORIGIN: "Origin", + BPR_MED: "MED", + BPR_ASN: "ASN", + BPR_IGP_COST: "IGP Cost", + BPR_ROUTER_ID: "Router ID", + BPR_OLDER: "Older", + BPR_NON_LLGR_STALE: "no LLGR Stale", +} + +func (r *BestPathReason) String() string { + return BestPathReasonStringMap[*r] +} + func IpToRadixkey(b []byte, max uint8) string { var buffer bytes.Buffer for i := 0; i < len(b) && i < int(max); i++ { |