diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-09-08 23:09:26 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-09-10 13:58:26 +0900 |
commit | ba3a7ddb02855ffdf799a65c4cad7d75909a1371 (patch) | |
tree | cc3ce109cf39429ea7a02133c9641e9d5f0894b5 /table/destination.go | |
parent | dae5f4eee235bfa6c81d76d1bf54889e50e7a51d (diff) |
table: add string method for easier debugging
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/destination.go')
-rw-r--r-- | table/destination.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/table/destination.go b/table/destination.go index de2bf659..61d3e4c8 100644 --- a/table/destination.go +++ b/table/destination.go @@ -76,6 +76,21 @@ func (lhs *PeerInfo) Equal(rhs *PeerInfo) bool { return false } +func (i *PeerInfo) String() string { + if i.Address == nil { + return "local" + } + s := bytes.NewBuffer(make([]byte, 0, 64)) + s.WriteString(fmt.Sprintf("{ %s | ", i.Address)) + s.WriteString(fmt.Sprintf("as: %d", i.AS)) + s.WriteString(fmt.Sprintf(", id: %s", i.ID)) + if i.RouteReflectorClient { + s.WriteString(fmt.Sprintf(", cluster-id: %s", i.RouteReflectorClusterID)) + } + s.WriteString(" }") + return s.String() +} + type Destination struct { routeFamily bgp.RouteFamily nlri bgp.AddrPrefixInterface |