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

Function TestIPv4OverGREEncode

layers/gre_test.go:103–120  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

101}
102
103func TestIPv4OverGREEncode(t *testing.T) {
104 b := gopacket.NewSerializeBuffer()
105 opts := gopacket.SerializeOptions{
106 ComputeChecksums: true,
107 FixLengths: true,
108 }
109 if err := gopacket.SerializeLayers(b, opts, testIPv4OverGRE...); err != nil {
110 t.Errorf("Unable to serialize: %v", err)
111 }
112 p := gopacket.NewPacket(b.Bytes(), LinkTypeEthernet, gopacket.Default)
113 if p.ErrorLayer() != nil {
114 t.Error("Failed to decode packet:", p.ErrorLayer().Error())
115 }
116 checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeGRE, LayerTypeIPv4, LayerTypeICMPv4, gopacket.LayerTypePayload}, t)
117 if got, want := b.Bytes(), testPacketGRE; !reflect.DeepEqual(want, got) {
118 t.Errorf("Encoding mismatch, \nwant: %v\ngot %v\n", want, got)
119 }
120}
121
122func BenchmarkEncodePacketGRE(b *testing.B) {
123 buf := gopacket.NewSerializeBuffer()

Callers

nothing calls this directly

Calls 7

BytesMethod · 0.95
ErrorLayerMethod · 0.95
NewSerializeBufferFunction · 0.92
SerializeLayersFunction · 0.92
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…