DecodeFromBytes decodes the given bytes into this layer.
(data []byte, df gopacket.DecodeFeedback)
| 346 | |
| 347 | // DecodeFromBytes decodes the given bytes into this layer. |
| 348 | func (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. |