diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-09-22 23:41:39 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-09-22 23:41:39 +0900 |
commit | c9262d33b3dccba3dba46063d0db206448f2feea (patch) | |
tree | 0a8406b013977cc5e3f93d12820367d90bd2ebca /packet/bgp.go | |
parent | 19ca5ae906d509c516e0038866a88e09ca269568 (diff) |
cli: show mpls label in vrf rib view
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'packet/bgp.go')
-rw-r--r-- | packet/bgp.go | 15 |
1 files changed, 15 insertions, 0 deletions
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} |