summaryrefslogtreecommitdiffhomepage
path: root/pkg/packet
diff options
context:
space:
mode:
authorKirill Smorodinnikov <shaitan@yandex-team.ru>2021-02-24 15:23:38 +0300
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2021-02-27 09:03:05 +0900
commitf33148428ac2c035e526303742983db8428236b1 (patch)
treec869f269f5ffdd9b31157aef0f18e2269ad72cff /pkg/packet
parent69fd66299fe558d4367e21d5d842f5ea5c9b2814 (diff)
Extend LsLinkDescriptor.String
Cover additional cases when only one part of the link is presented.
Diffstat (limited to 'pkg/packet')
-rw-r--r--pkg/packet/bgp/bgp.go29
1 files changed, 22 insertions, 7 deletions
diff --git a/pkg/packet/bgp/bgp.go b/pkg/packet/bgp/bgp.go
index 5112e7ae..cb28bd7f 100644
--- a/pkg/packet/bgp/bgp.go
+++ b/pkg/packet/bgp/bgp.go
@@ -5046,19 +5046,34 @@ func (l *LsLinkDescriptor) ParseTLVs(tlvs []LsTLVInterface) {
}
func (l *LsLinkDescriptor) String() string {
- if l.InterfaceAddrIPv4 != nil && l.NeighborAddrIPv4 != nil {
+ switch {
+ case l.InterfaceAddrIPv4 != nil && l.NeighborAddrIPv4 != nil:
return fmt.Sprintf("%v->%v", l.InterfaceAddrIPv4, l.NeighborAddrIPv4)
- }
- if l.InterfaceAddrIPv6 != nil && l.NeighborAddrIPv6 != nil {
+ case l.InterfaceAddrIPv6 != nil && l.NeighborAddrIPv6 != nil:
return fmt.Sprintf("%v->%v", l.InterfaceAddrIPv6, l.NeighborAddrIPv6)
- }
- if l.LinkLocalID != nil && l.LinkRemoteID != nil {
+ case l.LinkLocalID != nil && l.LinkRemoteID != nil:
return fmt.Sprintf("%v->%v", *l.LinkLocalID, *l.LinkRemoteID)
- }
- return "UNKNOWN"
+ case l.InterfaceAddrIPv4 != nil:
+ return fmt.Sprintf("%v->UNKNOWN", l.InterfaceAddrIPv4)
+ case l.NeighborAddrIPv4 != nil:
+ return fmt.Sprintf("UNKNOWN->%v", l.NeighborAddrIPv4)
+
+ case l.InterfaceAddrIPv6 != nil:
+ return fmt.Sprintf("%v->UNKNOWN", l.InterfaceAddrIPv6)
+ case l.NeighborAddrIPv6 != nil:
+ return fmt.Sprintf("UNKNOWN->%v", l.NeighborAddrIPv6)
+
+ case l.LinkLocalID != nil:
+ return fmt.Sprintf("%v->UNKNOWN", *l.LinkLocalID)
+ case l.LinkRemoteID != nil:
+ return fmt.Sprintf("UNKNOWN->%v", *l.LinkRemoteID)
+
+ default:
+ return "UNKNOWN"
+ }
}
type LsLinkNLRI struct {