summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/dhcpv6relay.go
diff options
context:
space:
mode:
Diffstat (limited to 'dhcpv6/dhcpv6relay.go')
-rw-r--r--dhcpv6/dhcpv6relay.go39
1 files changed, 25 insertions, 14 deletions
diff --git a/dhcpv6/dhcpv6relay.go b/dhcpv6/dhcpv6relay.go
index ace35f7..5a29c87 100644
--- a/dhcpv6/dhcpv6relay.go
+++ b/dhcpv6/dhcpv6relay.go
@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"net"
+ "strings"
"github.com/insomniacslk/dhcp/iana"
"github.com/u-root/uio/uio"
@@ -100,20 +101,30 @@ func (r *RelayMessage) String() string {
// Summary prints all options associated with this relay message.
func (r *RelayMessage) Summary() string {
- ret := fmt.Sprintf(
- "RelayMessage\n"+
- " messageType=%v\n"+
- " hopcount=%v\n"+
- " linkaddr=%v\n"+
- " peeraddr=%v\n"+
- " options=%v\n",
- r.Type(),
- r.HopCount,
- r.LinkAddr,
- r.PeerAddr,
- r.Options,
- )
- return ret
+ return r.LongString(0)
+}
+
+// LongString prints all options associated with this message.
+func (r *RelayMessage) LongString(spaceIndent int) string {
+ indent := strings.Repeat(" ", spaceIndent)
+
+ var s strings.Builder
+ s.WriteString(indent)
+ s.WriteString("RelayMessage{\n")
+ s.WriteString(indent)
+ s.WriteString(fmt.Sprintf(" MessageType=%s\n", r.MessageType))
+ s.WriteString(indent)
+ s.WriteString(fmt.Sprintf(" HopCount=%d\n", r.HopCount))
+ s.WriteString(indent)
+ s.WriteString(fmt.Sprintf(" LinkAddr=%s\n", r.LinkAddr))
+ s.WriteString(indent)
+ s.WriteString(fmt.Sprintf(" PeerAddr=%s\n", r.PeerAddr))
+ s.WriteString(indent)
+ s.WriteString(" Options: ")
+ s.WriteString(r.Options.Options.LongString(spaceIndent + 2))
+ s.WriteString("\n}")
+
+ return s.String()
}
// ToBytes returns the serialized version of this relay message as defined by