MCPcopy Create free account
hub / github.com/danderson/netboot / DebugString

Method DebugString

dhcp4/packet.go:107–137  ·  view source on GitHub ↗

DebugString prints the contents of a DHCP packet for human consumption.

()

Source from the content-addressed store, hash-verified

105
106// DebugString prints the contents of a DHCP packet for human consumption.
107func (p *Packet) DebugString() string {
108 var b bytes.Buffer
109 bcast := "Unicast"
110 if p.Broadcast {
111 bcast = "Broadcast"
112 }
113 fmt.Fprintf(&b, `%s
114 %#v
115 %s
116 MAC: %s
117 ClientIP: %s
118 YourIP: %s
119 ServerIP: %s
120 RelayIP: %s
121
122 BootServerName: %s
123 BootFilename: %s
124
125 Options:
126`, p.Type, p.TransactionID, bcast, p.HardwareAddr, p.ClientAddr, p.YourAddr, p.ServerAddr, p.RelayAddr, p.BootServerName, p.BootFilename)
127
128 var opts []int
129 for n := range p.Options {
130 opts = append(opts, int(n))
131 }
132 sort.Ints(opts)
133 for _, n := range opts {
134 fmt.Fprintf(&b, " %d: %#v\n", n, p.Options[Option(n)])
135 }
136 return b.String()
137}
138
139// Marshal returns the wire encoding of p.
140func (p *Packet) Marshal() ([]byte, error) {

Callers 1

TestParseFunction · 0.80

Calls 2

OptionTypeAlias · 0.70
StringMethod · 0.45

Tested by 1

TestParseFunction · 0.64