summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp.go
diff options
context:
space:
mode:
Diffstat (limited to 'packet/bgp.go')
-rw-r--r--packet/bgp.go15
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}