From c9262d33b3dccba3dba46063d0db206448f2feea Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Tue, 22 Sep 2015 23:41:39 +0900 Subject: cli: show mpls label in vrf rib view Signed-off-by: ISHIDA Wataru --- packet/bgp.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'packet/bgp.go') diff --git a/packet/bgp.go b/packet/bgp.go index 60c1b645..3dd18be3 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -1098,6 +1098,21 @@ func (l *MPLSLabelStack) Serialize() ([]byte, error) { func (l *MPLSLabelStack) Len() int { return 3 * len(l.Labels) } +func (l *MPLSLabelStack) String() string { + if len(l.Labels) == 0 { + return "" + } + s := bytes.NewBuffer(make([]byte, 0, 64)) + s.WriteString("[") + ss := make([]string, 0, len(l.Labels)) + for _, label := range l.Labels { + ss = append(ss, fmt.Sprintf("%d", label)) + } + s.WriteString(strings.Join(ss, ", ")) + s.WriteString("]") + return s.String() +} + func NewMPLSLabelStack(labels ...uint32) *MPLSLabelStack { if len(labels) == 0 { labels = []uint32{0} -- cgit v1.2.3