File: linux_sll2_test.go

package info (click to toggle)
golang-github-gopacket-gopacket 1.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,004 kB
  • sloc: sh: 301; python: 76; makefile: 10
file content (28 lines) | stat: -rw-r--r-- 953 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package layers

import (
	"testing"

	"github.com/gopacket/gopacket"
)

var testParseLinkTypeLinuxSLL2 = []byte{
	// sll2
	0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,
	// ipv4
	0x45, 0x00, 0x00, 0x3c, 0xaf, 0x93, 0x40, 0x00, 0x40, 0x06, 0x8d, 0x26, 0x7f, 0x00, 0x00, 0x01,
	0x7f, 0x00, 0x00, 0x01,
	// tcp
	0xb8, 0x46, 0x04, 0xd2, 0x4e, 0x2a, 0x3f, 0xda, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0xff, 0xd7,
	0xfe, 0x30, 0x00, 0x00, 0x02, 0x04, 0xff, 0xd7, 0x04, 0x02, 0x08, 0x0a, 0xe4, 0x67, 0xf5, 0x17,
	0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07,
}

func TestParseLinkTypeLinuxSLL2(t *testing.T) {
	p := gopacket.NewPacket(testParseLinkTypeLinuxSLL2, LinkTypeLinuxSLL2, testDecodeOptions)
	if p.ErrorLayer() != nil {
		t.Error("Failed to decode packet:", p.ErrorLayer().Error())
	}
	checkLayers(p, []gopacket.LayerType{LayerTypeLinuxSLL2, LayerTypeIPv4, LayerTypeTCP}, t)
}