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

Function testDecodingLayerContainer

layers/decode_test.go:1045–1065  ·  view source on GitHub ↗
(t *testing.T, dlc gopacket.DecodingLayerContainer)

Source from the content-addressed store, hash-verified

1043}
1044
1045func testDecodingLayerContainer(t *testing.T, dlc gopacket.DecodingLayerContainer) {
1046 dlc = dlc.Put(&Ethernet{})
1047 dlc = dlc.Put(&IPv4{})
1048 dlc = dlc.Put(&TCP{})
1049 dlc = dlc.Put(&gopacket.Payload{})
1050 decoded := make([]gopacket.LayerType, 1)
1051
1052 // just as a DecodeFeedback
1053 df := gopacket.NewDecodingLayerParser(LayerTypeEthernet)
1054 decoder := dlc.LayersDecoder(LayerTypeEthernet, df)
1055 typ, err := decoder(testSimpleTCPPacket, &decoded)
1056 if err != nil {
1057 t.Error("Error from decoder: ", err)
1058 }
1059 if typ != gopacket.LayerTypeZero {
1060 t.Error("Unsupported layer type", typ)
1061 }
1062 if len(decoded) != 4 {
1063 t.Error("Expected 4 layers parsed, instead got ", len(decoded))
1064 }
1065}
1066
1067func TestDecodingLayerMap(t *testing.T) {
1068 testDecodingLayerContainer(t, gopacket.DecodingLayerMap(nil))

Callers 3

TestDecodingLayerMapFunction · 0.85
TestDecodingLayerSparseFunction · 0.85
TestDecodingLayerArrayFunction · 0.85

Calls 4

NewDecodingLayerParserFunction · 0.92
PutMethod · 0.65
LayersDecoderMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…