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

Function checkLayers

layers/base_test.go:17–41  ·  view source on GitHub ↗
(p gopacket.Packet, want []gopacket.LayerType, t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func checkLayers(p gopacket.Packet, want []gopacket.LayerType, t *testing.T) {
18 layers := p.Layers()
19 t.Log("Checking packet layers, want", want)
20 for _, l := range layers {
21 t.Logf(" Got layer %v, %d bytes, payload of %d bytes", l.LayerType(),
22 len(l.LayerContents()), len(l.LayerPayload()))
23 }
24 t.Log(p)
25 if len(layers) < len(want) {
26 t.Errorf(" Number of layers mismatch: got %d want %d", len(layers),
27 len(want))
28 return
29 }
30 for i, l := range want {
31 if l == gopacket.LayerTypePayload {
32 // done matching layers
33 return
34 }
35
36 if layers[i].LayerType() != l {
37 t.Errorf(" Layer %d mismatch: got %v want %v", i,
38 layers[i].LayerType(), l)
39 }
40 }
41}
42
43// Checks that when a serialized version of p is decoded, p and the serialized version of p are the same.
44// Does not work for packets where the order of options can change, like icmpv6 router advertisements, dhcpv6, etc.

Callers 15

TestPacketDot11CtrlCTSFunction · 0.85
TestPacketDot11CtrlAckFunction · 0.85
TestPacketDot11DataARPFunction · 0.85
TestPacketDot11DataIPFunction · 0.85
TestPacketP6196Function · 0.85
TestPacketDot11HTControlFunction · 0.85
TestPacketIPSecAHTunnelFunction · 0.85
TestPacketIPSecESPFunction · 0.85

Calls 4

LayersMethod · 0.65
LayerTypeMethod · 0.65
LayerContentsMethod · 0.65
LayerPayloadMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…