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

Method DecodeFromBytes

layers/icmp6msg.go:348–362  ·  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

346
347// DecodeFromBytes decodes the given bytes into this layer.
348func (i *ICMPv6NeighborAdvertisement) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
349 if len(data) < 20 {
350 df.SetTruncated()
351 return errors.New("ICMP layer less then 20 bytes for ICMPv6 neighbor advertisement")
352 }
353
354 i.Flags = uint8(data[0])
355 i.TargetAddress = net.IP(data[4:20])
356 i.BaseLayer = BaseLayer{data, nil} // assume no payload
357
358 // truncate old options
359 i.Options = i.Options[:0]
360
361 return i.Options.DecodeFromBytes(data[20:], df)
362}
363
364// SerializeTo writes the serialized form of this layer into the
365// SerializationBuffer, implementing gopacket.SerializableLayer.

Calls 3

SetTruncatedMethod · 0.65
NewMethod · 0.65
DecodeFromBytesMethod · 0.65