(p gopacket.Packet, want []gopacket.LayerType, t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func 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. |
no test coverage detected
searching dependent graphs…