MCPcopy Index your code
hub / github.com/google/gopacket / testSerializationWithOpts

Function testSerializationWithOpts

layers/decode_test.go:509–528  ·  view source on GitHub ↗
(t *testing.T, p gopacket.Packet, data []byte, opts gopacket.SerializeOptions)

Source from the content-addressed store, hash-verified

507}
508
509func testSerializationWithOpts(t *testing.T, p gopacket.Packet, data []byte, opts gopacket.SerializeOptions) {
510 // Test re-serialization.
511 slayers := []gopacket.SerializableLayer{}
512 for _, l := range p.Layers() {
513 slayers = append(slayers, l.(gopacket.SerializableLayer))
514 if h, ok := l.(canSetNetLayer); ok {
515 if err := h.SetNetworkLayerForChecksum(p.NetworkLayer()); err != nil {
516 t.Fatal("can't set network layer:", err)
517 }
518 }
519 }
520 buf := gopacket.NewSerializeBuffer()
521 err := gopacket.SerializeLayers(buf, opts, slayers...)
522 if err != nil {
523 t.Errorf("unable to reserialize layers with opts %#v: %v", opts, err)
524 } else if !bytes.Equal(buf.Bytes(), data) {
525 t.Errorf("serialization failure with opts %#v:\n---want---\n%v\n---got---\n%v\nBASH-colorized diff, want->got:\n%v\n\n---PACKET---\n%v",
526 opts, hex.Dump(data), hex.Dump(buf.Bytes()), bytediff.BashOutput.String(bytediff.Diff(data, buf.Bytes())), p)
527 }
528}
529
530// Makes sure packet payload doesn't display the 6 trailing null of this packet
531// as part of the payload. They're actually the ethernet trailer.

Callers 3

testSerializationFunction · 0.85
TestDecodeSCTPPacketsFunction · 0.85
TestPacketIPv4FragmentedFunction · 0.85

Calls 9

BytesMethod · 0.95
NewSerializeBufferFunction · 0.92
SerializeLayersFunction · 0.92
DiffFunction · 0.92
LayersMethod · 0.65
NetworkLayerMethod · 0.65
DumpMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…