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

Method SerializeTo

layers/icmp6msg.go:253–269  ·  view source on GitHub ↗

SerializeTo writes the serialized form of this layer into the SerializationBuffer, implementing gopacket.SerializableLayer. See the docs for gopacket.SerializableLayer for more info.

(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions)

Source from the content-addressed store, hash-verified

251// SerializationBuffer, implementing gopacket.SerializableLayer.
252// See the docs for gopacket.SerializableLayer for more info.
253func (i *ICMPv6RouterAdvertisement) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
254 if err := i.Options.SerializeTo(b, opts); err != nil {
255 return err
256 }
257
258 buf, err := b.PrependBytes(12)
259 if err != nil {
260 return err
261 }
262
263 buf[0] = byte(i.HopLimit)
264 buf[1] = byte(i.Flags)
265 binary.BigEndian.PutUint16(buf[2:], i.RouterLifetime)
266 binary.BigEndian.PutUint32(buf[4:], i.ReachableTime)
267 binary.BigEndian.PutUint32(buf[8:], i.RetransTimer)
268 return nil
269}
270
271// CanDecode returns the set of layer types that this DecodingLayer can decode.
272func (i *ICMPv6RouterAdvertisement) CanDecode() gopacket.LayerClass {

Callers

nothing calls this directly

Calls 2

SerializeToMethod · 0.65
PrependBytesMethod · 0.65

Tested by

no test coverage detected