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

Function TestDecodeUDPSFlow

layers/sflow_test.go:407–429  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

405}
406
407func TestDecodeUDPSFlow(t *testing.T) {
408 p := gopacket.NewPacket(SFlowTestPacket1, LayerTypeEthernet, gopacket.Default)
409 if p.ErrorLayer() != nil {
410 t.Error("Failed to decode packet:", p.ErrorLayer().Error())
411 }
412 checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeUDP, LayerTypeSFlow}, t)
413 if got, ok := p.TransportLayer().(*UDP); ok {
414 want := &UDP{
415 BaseLayer: BaseLayer{SFlowTestPacket1[34:42], SFlowTestPacket1[42:]},
416 sPort: []byte{199, 87},
417 dPort: []byte{24, 199},
418 SrcPort: 51031,
419 DstPort: 6343,
420 Checksum: 8763,
421 Length: 1448,
422 }
423 if !reflect.DeepEqual(want, got) {
424 t.Errorf("UDP layer mismatch, \nwant %#v\ngot %#v\n", want, got)
425 }
426 } else {
427 t.Error("Transport layer packet not UDP")
428 }
429}
430
431func TestDecodeSFlowDatagram(t *testing.T) {
432 p := gopacket.NewPacket(SFlowTestPacket1, LayerTypeEthernet, gopacket.Default)

Callers

nothing calls this directly

Calls 5

ErrorLayerMethod · 0.95
TransportLayerMethod · 0.95
NewPacketFunction · 0.92
checkLayersFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…