diff options
-rw-r--r-- | table/destination.go | 15 | ||||
-rw-r--r-- | table/path.go | 14 |
2 files changed, 24 insertions, 5 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 diff --git a/table/path.go b/table/path.go index 386d39c3..22a068eb 100644 --- a/table/path.go +++ b/table/path.go @@ -297,11 +297,15 @@ func (path *Path) getPathAttr(pattrType bgp.BGPAttrType) (int, bgp.PathAttribute // return Path's string representation func (path *Path) String() string { - str := fmt.Sprintf("Source: %v, ", path.GetSource()) - str += fmt.Sprintf(" NLRI: %s, ", path.getPrefix()) - str += fmt.Sprintf(" nexthop: %s, ", path.GetNexthop()) - str += fmt.Sprintf(" withdraw: %s, ", path.IsWithdraw) - return str + s := bytes.NewBuffer(make([]byte, 0, 64)) + s.WriteString(fmt.Sprintf("{ %s | ", path.getPrefix())) + s.WriteString(fmt.Sprintf("src: %s", path.GetSource())) + s.WriteString(fmt.Sprintf(", nh: %s", path.GetNexthop())) + if path.IsWithdraw { + s.WriteString(", withdraw") + } + s.WriteString(" }") + return s.String() } func (path *Path) getPrefix() string { |