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

Function SerializeLayers

writer.go:206–217  ·  view source on GitHub ↗

SerializeLayers clears the given write buffer, then writes all layers into it so they correctly wrap each other. Note that by clearing the buffer, it invalidates all slices previously returned by w.Bytes() Example: buf := gopacket.NewSerializeBuffer() opts := gopacket.SerializeOptions{} gopacket.S

(w SerializeBuffer, opts SerializeOptions, layers ...SerializableLayer)

Source from the content-addressed store, hash-verified

204// gopacket.SerializeLayers(buf, opts, d, e, f)
205// secondPayload := buf.Bytes() // contains byte representation of d(e(f)). firstPayload is now invalidated, since the SerializeLayers call Clears buf.
206func SerializeLayers(w SerializeBuffer, opts SerializeOptions, layers ...SerializableLayer) error {
207 w.Clear()
208 for i := len(layers) - 1; i >= 0; i-- {
209 layer := layers[i]
210 err := layer.SerializeTo(w, opts)
211 if err != nil {
212 return err
213 }
214 w.PushLayer(layer.LayerType())
215 }
216 return nil
217}
218
219// SerializePacket is a convenience function that calls SerializeLayers
220// on packet's Layers().

Calls 4

ClearMethod · 0.65
SerializeToMethod · 0.65
PushLayerMethod · 0.65
LayerTypeMethod · 0.65

Used in the wild real call sites across dependent graphs

searching dependent graphs…