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

Function SerializePacket

writer.go:222–232  ·  view source on GitHub ↗

SerializePacket is a convenience function that calls SerializeLayers on packet's Layers(). It returns an error if one of the packet layers is not a SerializableLayer.

(buf SerializeBuffer, opts SerializeOptions, packet Packet)

Source from the content-addressed store, hash-verified

220// on packet's Layers().
221// It returns an error if one of the packet layers is not a SerializableLayer.
222func SerializePacket(buf SerializeBuffer, opts SerializeOptions, packet Packet) error {
223 sls := []SerializableLayer{}
224 for _, layer := range packet.Layers() {
225 sl, ok := layer.(SerializableLayer)
226 if !ok {
227 return fmt.Errorf("layer %s is not serializable", layer.LayerType().String())
228 }
229 sls = append(sls, sl)
230 }
231 return SerializeLayers(buf, opts, sls...)
232}

Callers 1

checkSerializationFunction · 0.92

Calls 4

SerializeLayersFunction · 0.85
LayersMethod · 0.65
StringMethod · 0.65
LayerTypeMethod · 0.65

Tested by 1

checkSerializationFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…