MCPcopy
hub / github.com/google/gopacket / DecodeFromBytes

Method DecodeFromBytes

layers/icmp6msg.go:299–312  ·  view source on GitHub ↗

DecodeFromBytes decodes the given bytes into this layer.

(data []byte, df gopacket.DecodeFeedback)

Source from the content-addressed store, hash-verified

297
298// DecodeFromBytes decodes the given bytes into this layer.
299func (i *ICMPv6NeighborSolicitation) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
300 if len(data) < 20 {
301 df.SetTruncated()
302 return errors.New("ICMP layer less then 20 bytes for ICMPv6 neighbor solicitation")
303 }
304
305 i.TargetAddress = net.IP(data[4:20])
306 i.BaseLayer = BaseLayer{data, nil} // assume no payload
307
308 // truncate old options
309 i.Options = i.Options[:0]
310
311 return i.Options.DecodeFromBytes(data[20:], df)
312}
313
314// SerializeTo writes the serialized form of this layer into the
315// SerializationBuffer, implementing gopacket.SerializableLayer.

Callers

nothing calls this directly

Calls 3

SetTruncatedMethod · 0.65
NewMethod · 0.65
DecodeFromBytesMethod · 0.65

Tested by

no test coverage detected