aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/google/gopacket/layers
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/google/gopacket/layers')
-rw-r--r--vendor/github.com/google/gopacket/layers/base_test.go42
-rw-r--r--vendor/github.com/google/gopacket/layers/bfd_test.go289
-rw-r--r--vendor/github.com/google/gopacket/layers/decode_test.go1234
-rw-r--r--vendor/github.com/google/gopacket/layers/dhcp_test.go129
-rw-r--r--vendor/github.com/google/gopacket/layers/dns_test.go833
-rw-r--r--vendor/github.com/google/gopacket/layers/dot11_test.go495
-rw-r--r--vendor/github.com/google/gopacket/layers/dot1q_test.go62
-rw-r--r--vendor/github.com/google/gopacket/layers/endpoints_test.go37
-rw-r--r--vendor/github.com/google/gopacket/layers/geneve_test.go108
-rw-r--r--vendor/github.com/google/gopacket/layers/gre_test.go389
-rw-r--r--vendor/github.com/google/gopacket/layers/icmp6_test.go84
-rw-r--r--vendor/github.com/google/gopacket/layers/igmp_test.go171
-rw-r--r--vendor/github.com/google/gopacket/layers/ip4_test.go131
-rw-r--r--vendor/github.com/google/gopacket/layers/ip6_test.go430
-rw-r--r--vendor/github.com/google/gopacket/layers/ipsec_test.go154
-rw-r--r--vendor/github.com/google/gopacket/layers/mpls_test.go96
-rw-r--r--vendor/github.com/google/gopacket/layers/ntp_test.go258
-rw-r--r--vendor/github.com/google/gopacket/layers/ospf_test.go559
-rw-r--r--vendor/github.com/google/gopacket/layers/prism_test.go120
-rw-r--r--vendor/github.com/google/gopacket/layers/radiotap_test.go79
-rw-r--r--vendor/github.com/google/gopacket/layers/sflow_test.go1246
-rw-r--r--vendor/github.com/google/gopacket/layers/tcp_test.go60
-rw-r--r--vendor/github.com/google/gopacket/layers/tcpip_test.go185
-rw-r--r--vendor/github.com/google/gopacket/layers/udp_test.go372
-rw-r--r--vendor/github.com/google/gopacket/layers/usb_test.go73
-rw-r--r--vendor/github.com/google/gopacket/layers/vrrp_test.go55
-rw-r--r--vendor/github.com/google/gopacket/layers/vxlan_test.go108
27 files changed, 0 insertions, 7799 deletions
diff --git a/vendor/github.com/google/gopacket/layers/base_test.go b/vendor/github.com/google/gopacket/layers/base_test.go
deleted file mode 100644
index 4be7480..0000000
--- a/vendor/github.com/google/gopacket/layers/base_test.go
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2012, Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-// This file contains some test helper functions.
-
-package layers
-
-import (
- "github.com/google/gopacket"
- "testing"
-)
-
-func min(a, b int) int {
- if a < b {
- return a
- }
- return b
-}
-
-func checkLayers(p gopacket.Packet, want []gopacket.LayerType, t *testing.T) {
- layers := p.Layers()
- t.Log("Checking packet layers, want", want)
- for _, l := range layers {
- t.Logf(" Got layer %v, %d bytes, payload of %d bytes", l.LayerType(),
- len(l.LayerContents()), len(l.LayerPayload()))
- }
- t.Log(p)
- if len(layers) != len(want) {
- t.Errorf(" Number of layers mismatch: got %d want %d", len(layers),
- len(want))
- return
- }
- for i, l := range layers {
- if l.LayerType() != want[i] {
- t.Errorf(" Layer %d mismatch: got %v want %v", i, l.LayerType(),
- want[i])
- }
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/bfd_test.go b/vendor/github.com/google/gopacket/layers/bfd_test.go
deleted file mode 100644
index 1ac84cb..0000000
--- a/vendor/github.com/google/gopacket/layers/bfd_test.go
+++ /dev/null
@@ -1,289 +0,0 @@
-// Copyright 2017 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-//
-//******************************************************************************
-
-package layers
-
-import (
- "github.com/google/gopacket"
- "reflect"
- "testing"
-)
-
-//******************************************************************************
-
-// checkBFD() uses the bfd.go code to analyse the packet bytes as an BFD Control
-// packet and generate an BFD object. It then compares the generated BFD object
-// with the one provided and throws an error if there is any difference.
-// The desc argument is output with any failure message to identify the test.
-func checkBFD(desc string, t *testing.T, packetBytes []byte, pExpectedBFD *BFD) {
-
- // Analyse the packet bytes, yielding a new packet object p.
- p := gopacket.NewPacket(packetBytes, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Errorf("Failed to decode packet %s: %v", desc, p.ErrorLayer().Error())
- }
-
- // Ensure that the packet analysis yielded the correct set of layers:
- // Link Layer = Ethernet.
- // Network Layer = IPv4.
- // Transport Layer = UDP.
- // Application Layer = BFD.
- checkLayers(p, []gopacket.LayerType{
- LayerTypeEthernet,
- LayerTypeIPv4,
- LayerTypeUDP,
- LayerTypeBFD}, t)
-
- // Select the Application (BFD) layer.
- pResultBFD, ok := p.ApplicationLayer().(*BFD)
- if !ok {
- t.Error("No BFD layer type found in packet in " + desc + ".")
- }
-
- // Compare the generated BFD object with the expected BFD object.
- if !reflect.DeepEqual(pResultBFD, pExpectedBFD) {
- t.Errorf("BFD packet processing failed for packet "+desc+
- ":\ngot :\n%#v\n\nwant :\n%#v\n\n", pResultBFD, pExpectedBFD)
- }
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{}
- err := pResultBFD.SerializeTo(buf, opts)
- if err != nil {
- t.Error(err)
- }
- if !reflect.DeepEqual(pResultBFD.Contents, buf.Bytes()) {
- t.Errorf("BFD packet serialization failed for packet "+desc+
- ":\ngot :\n%+v\n\nwant :\n%+v\n\n", buf.Bytes(), pResultBFD.Contents)
- }
-
-}
-
-func TestBFDNoAuth(t *testing.T) {
- // This test packet is based off of the first BFD packet in the BFD sample capture
- // pcap file bfd-raw-auth-simple.pcap on the Wireshark sample captures page:
- //
- // https://wiki.wireshark.org/SampleCaptures
- // https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=bfd-raw-auth-simple.pcap
- //
- // Changed to remove the authentication header, and adjust all of the lengths
- var testPacketBFD = []byte{
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x10, 0x94, 0x00, 0x00, 0x02, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x11, 0x2f, 0x58, 0xc0, 0x55, 0x01, 0x02, 0xc0, 0x00,
- 0x00, 0x01, 0xc0, 0x00, 0x0e, 0xc8, 0x00, 0x20, 0x72, 0x31, 0x20, 0x40, 0x05, 0x18, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x42, 0x40, 0x00, 0x0f, 0x42, 0x40, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x4e, 0x0a, 0x90, 0x40,
- }
-
- // Assemble the BFD object that we expect to emerge from this test.
- pExpectedBFD := &BFD{
- BaseLayer: BaseLayer{
- Contents: []byte{
- 0x20, 0x40, 0x05, 0x18, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x42, 0x40,
- 0x00, 0x0f, 0x42, 0x40, 0x00, 0x00, 0x00, 0x00,
- },
- Payload: nil,
- },
- Version: 1,
- Diagnostic: BFDDiagnosticNone,
- State: BFDStateDown,
- Poll: false,
- Final: false,
- ControlPlaneIndependent: false,
- AuthPresent: false,
- Demand: false,
- Multipoint: false,
- DetectMultiplier: 5,
- MyDiscriminator: 1,
- YourDiscriminator: 0,
- DesiredMinTxInterval: 1000000,
- RequiredMinRxInterval: 1000000,
- RequiredMinEchoRxInterval: 0,
- AuthHeader: nil,
- }
-
- checkBFD("testNoAuth", t, testPacketBFD, pExpectedBFD)
-}
-
-//******************************************************************************
-
-func TestBFDAuthTypePassword(t *testing.T) {
-
- // This test packet is the first BFD packet in the BFD sample capture
- // pcap file bfd-raw-auth-simple.pcap on the Wireshark sample captures page:
- //
- // https://wiki.wireshark.org/SampleCaptures
- // https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=bfd-raw-auth-simple.pcap
- var testPacketBFD = []byte{
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x10, 0x94, 0x00, 0x00, 0x02, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x11, 0x2f, 0x58, 0xc0, 0x55, 0x01, 0x02, 0xc0, 0x00,
- 0x00, 0x01, 0xc0, 0x00, 0x0e, 0xc8, 0x00, 0x29, 0x72, 0x31, 0x20, 0x44, 0x05, 0x21, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x42, 0x40, 0x00, 0x0f, 0x42, 0x40, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x09, 0x02, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4e, 0x0a, 0x90, 0x40,
- }
-
- // Assemble the BFD object that we expect to emerge from this test.
- pExpectedBFD := &BFD{
- BaseLayer: BaseLayer{
- Contents: []byte{
- 0x20, 0x44, 0x05, 0x21, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x42, 0x40,
- 0x00, 0x0f, 0x42, 0x40, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x09, 0x02, 0x73, 0x65, 0x63, 0x72, 0x65,
- 0x74,
- },
- Payload: nil,
- },
- Version: 1,
- Diagnostic: BFDDiagnosticNone,
- State: BFDStateDown,
- Poll: false,
- Final: false,
- ControlPlaneIndependent: false,
- AuthPresent: true,
- Demand: false,
- Multipoint: false,
- DetectMultiplier: 5,
- MyDiscriminator: 1,
- YourDiscriminator: 0,
- DesiredMinTxInterval: 1000000,
- RequiredMinRxInterval: 1000000,
- RequiredMinEchoRxInterval: 0,
- AuthHeader: &BFDAuthHeader{
- AuthType: BFDAuthTypePassword,
- KeyID: 2,
- SequenceNumber: 0,
- Data: []byte{'s', 'e', 'c', 'r', 'e', 't'},
- },
- }
-
- checkBFD("testBFDAuthTypePassword", t, testPacketBFD, pExpectedBFD)
-}
-
-//******************************************************************************
-
-func TestBFDAuthTypeKeyedMD5(t *testing.T) {
-
- // This test packet is the first BFD packet in the BFD sample capture
- // pcap file bfd-raw-auth-md5.pcap on the Wireshark sample captures page:
- //
- // https://wiki.wireshark.org/SampleCaptures
- // https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=bfd-raw-auth-md5.pcap
- var testPacketBFD = []byte{
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x10, 0x94, 0x00, 0x00, 0x02, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x4c, 0x00, 0x01, 0x00, 0x00, 0x0a, 0x11, 0x2f, 0x48, 0xc0, 0x55, 0x01, 0x02, 0xc0, 0x00,
- 0x00, 0x01, 0x04, 0x00, 0x0e, 0xc8, 0x00, 0x38, 0x6a, 0xcc, 0x20, 0x44, 0x05, 0x30, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x42, 0x40, 0x00, 0x0f, 0x42, 0x40, 0x00, 0x00,
- 0x00, 0x00, 0x02, 0x18, 0x02, 0x00, 0x00, 0x00, 0x00, 0x05, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
- 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x3c, 0xc3, 0xf8, 0x21,
- }
-
- // Assemble the BFD object that we expect to emerge from this test.
- pExpectedBFD := &BFD{
- BaseLayer: BaseLayer{
- Contents: []byte{
- 0x20, 0x44, 0x05, 0x30, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x42, 0x40,
- 0x00, 0x0f, 0x42, 0x40, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x18, 0x02, 0x00, 0x00, 0x00, 0x00, 0x05,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
- },
- Payload: nil,
- },
- Version: 1,
- Diagnostic: BFDDiagnosticNone,
- State: BFDStateDown,
- Poll: false,
- Final: false,
- ControlPlaneIndependent: false,
- AuthPresent: true,
- Demand: false,
- Multipoint: false,
- DetectMultiplier: 5,
- MyDiscriminator: 1,
- YourDiscriminator: 0,
- DesiredMinTxInterval: 1000000,
- RequiredMinRxInterval: 1000000,
- RequiredMinEchoRxInterval: 0,
- AuthHeader: &BFDAuthHeader{
- AuthType: BFDAuthTypeKeyedMD5,
- KeyID: 2,
- SequenceNumber: 5,
- Data: []byte{
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
- },
- },
- }
-
- checkBFD("testBFDAuthTypeKeyedMD5", t, testPacketBFD, pExpectedBFD)
-}
-
-//******************************************************************************
-
-func TestBFDAuthTypeMeticulousKeyedSHA1(t *testing.T) {
-
- // This test packet is the first BFD packet in the BFD sample capture
- // pcap file bfd-raw-auth-sha1.pcap on the Wireshark sample captures page:
- //
- // https://wiki.wireshark.org/SampleCaptures
- // https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=bfd-raw-auth-sha1.pcap
- var testPacketBFD = []byte{
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x10, 0x94, 0x00, 0x00, 0x02, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x11, 0x2f, 0x45, 0xc0, 0x55, 0x01, 0x02, 0xc0, 0x00,
- 0x00, 0x01, 0x04, 0x00, 0x0e, 0xc8, 0x00, 0x3c, 0x37, 0x8a, 0x20, 0x44, 0x05, 0x34, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x42, 0x40, 0x00, 0x0f, 0x42, 0x40, 0x00, 0x00,
- 0x00, 0x00, 0x05, 0x1c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x05, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
- 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0xea, 0x6d,
- 0x1f, 0x21,
- }
-
- // Assemble the BFD object that we expect to emerge from this test.
- pExpectedBFD := &BFD{
- BaseLayer: BaseLayer{
- Contents: []byte{
- 0x20, 0x44, 0x05, 0x34, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x42, 0x40,
- 0x00, 0x0f, 0x42, 0x40, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x1c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x05,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
- 0x17, 0x18, 0x19, 0x1a,
- },
- Payload: nil,
- },
- Version: 1,
- Diagnostic: BFDDiagnosticNone,
- State: BFDStateDown,
- Poll: false,
- Final: false,
- ControlPlaneIndependent: false,
- AuthPresent: true,
- Demand: false,
- Multipoint: false,
- DetectMultiplier: 5,
- MyDiscriminator: 1,
- YourDiscriminator: 0,
- DesiredMinTxInterval: 1000000,
- RequiredMinRxInterval: 1000000,
- RequiredMinEchoRxInterval: 0,
- AuthHeader: &BFDAuthHeader{
- AuthType: BFDAuthTypeMeticulousKeyedSHA1,
- KeyID: 2,
- SequenceNumber: 5,
- Data: []byte{
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
- 0x17, 0x18, 0x19, 0x1a,
- },
- },
- }
-
- checkBFD("TestBFDAuthTypeMeticulousKeyedSHA1", t, testPacketBFD, pExpectedBFD)
-}
diff --git a/vendor/github.com/google/gopacket/layers/decode_test.go b/vendor/github.com/google/gopacket/layers/decode_test.go
deleted file mode 100644
index ecfbff7..0000000
--- a/vendor/github.com/google/gopacket/layers/decode_test.go
+++ /dev/null
@@ -1,1234 +0,0 @@
-// Copyright 2012, Google, Inc. All rights reserved.
-// Copyright 2009-2011 Andreas Krennmair. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "bytes"
- "encoding/hex"
- "fmt"
- "net"
- "reflect"
- "strings"
- "testing"
-
- "github.com/google/gopacket"
- "github.com/google/gopacket/bytediff"
-)
-
-var testSimpleTCPPacket = []byte{
- 0x00, 0x00, 0x0c, 0x9f, 0xf0, 0x20, 0xbc, 0x30, 0x5b, 0xe8, 0xd3, 0x49,
- 0x08, 0x00, 0x45, 0x00, 0x01, 0xa4, 0x39, 0xdf, 0x40, 0x00, 0x40, 0x06,
- 0x55, 0x5a, 0xac, 0x11, 0x51, 0x49, 0xad, 0xde, 0xfe, 0xe1, 0xc5, 0xf7,
- 0x00, 0x50, 0xc5, 0x7e, 0x0e, 0x48, 0x49, 0x07, 0x42, 0x32, 0x80, 0x18,
- 0x00, 0x73, 0x9a, 0x8f, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0x03, 0x77,
- 0x37, 0x9c, 0x42, 0x77, 0x5e, 0x3a, 0x47, 0x45, 0x54, 0x20, 0x2f, 0x20,
- 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x0d, 0x0a, 0x48, 0x6f,
- 0x73, 0x74, 0x3a, 0x20, 0x77, 0x77, 0x77, 0x2e, 0x66, 0x69, 0x73, 0x68,
- 0x2e, 0x63, 0x6f, 0x6d, 0x0d, 0x0a, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
- 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x6b, 0x65, 0x65, 0x70, 0x2d, 0x61,
- 0x6c, 0x69, 0x76, 0x65, 0x0d, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41,
- 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x4d, 0x6f, 0x7a, 0x69, 0x6c, 0x6c,
- 0x61, 0x2f, 0x35, 0x2e, 0x30, 0x20, 0x28, 0x58, 0x31, 0x31, 0x3b, 0x20,
- 0x4c, 0x69, 0x6e, 0x75, 0x78, 0x20, 0x78, 0x38, 0x36, 0x5f, 0x36, 0x34,
- 0x29, 0x20, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x57, 0x65, 0x62, 0x4b, 0x69,
- 0x74, 0x2f, 0x35, 0x33, 0x35, 0x2e, 0x32, 0x20, 0x28, 0x4b, 0x48, 0x54,
- 0x4d, 0x4c, 0x2c, 0x20, 0x6c, 0x69, 0x6b, 0x65, 0x20, 0x47, 0x65, 0x63,
- 0x6b, 0x6f, 0x29, 0x20, 0x43, 0x68, 0x72, 0x6f, 0x6d, 0x65, 0x2f, 0x31,
- 0x35, 0x2e, 0x30, 0x2e, 0x38, 0x37, 0x34, 0x2e, 0x31, 0x32, 0x31, 0x20,
- 0x53, 0x61, 0x66, 0x61, 0x72, 0x69, 0x2f, 0x35, 0x33, 0x35, 0x2e, 0x32,
- 0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x3a, 0x20, 0x74, 0x65,
- 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x2c, 0x61, 0x70, 0x70, 0x6c,
- 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, 0x68, 0x74, 0x6d,
- 0x6c, 0x2b, 0x78, 0x6d, 0x6c, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63,
- 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, 0x6d, 0x6c, 0x3b, 0x71, 0x3d,
- 0x30, 0x2e, 0x39, 0x2c, 0x2a, 0x2f, 0x2a, 0x3b, 0x71, 0x3d, 0x30, 0x2e,
- 0x38, 0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x45, 0x6e,
- 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x67, 0x7a, 0x69, 0x70,
- 0x2c, 0x64, 0x65, 0x66, 0x6c, 0x61, 0x74, 0x65, 0x2c, 0x73, 0x64, 0x63,
- 0x68, 0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x4c, 0x61,
- 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x65, 0x6e, 0x2d, 0x55,
- 0x53, 0x2c, 0x65, 0x6e, 0x3b, 0x71, 0x3d, 0x30, 0x2e, 0x38, 0x0d, 0x0a,
- 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x43, 0x68, 0x61, 0x72, 0x73,
- 0x65, 0x74, 0x3a, 0x20, 0x49, 0x53, 0x4f, 0x2d, 0x38, 0x38, 0x35, 0x39,
- 0x2d, 0x31, 0x2c, 0x75, 0x74, 0x66, 0x2d, 0x38, 0x3b, 0x71, 0x3d, 0x30,
- 0x2e, 0x37, 0x2c, 0x2a, 0x3b, 0x71, 0x3d, 0x30, 0x2e, 0x33, 0x0d, 0x0a,
- 0x0d, 0x0a,
-}
-
-var testDecodeOptions = gopacket.DecodeOptions{
- SkipDecodeRecovery: true,
-}
-
-// Benchmarks for actual gopacket code
-
-func BenchmarkLayerClassSliceContains(b *testing.B) {
- lc := gopacket.NewLayerClassSlice([]gopacket.LayerType{LayerTypeTCP, LayerTypeEthernet})
- for i := 0; i < b.N; i++ {
- _ = lc.Contains(LayerTypeTCP)
- }
-}
-
-func BenchmarkLayerClassMapContains(b *testing.B) {
- lc := gopacket.NewLayerClassMap([]gopacket.LayerType{LayerTypeTCP, LayerTypeEthernet})
- for i := 0; i < b.N; i++ {
- _ = lc.Contains(LayerTypeTCP)
- }
-}
-
-func BenchmarkLazyNoCopyEthLayer(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, gopacket.DecodeOptions{Lazy: true, NoCopy: true}).Layer(LayerTypeEthernet)
- }
-}
-
-func BenchmarkLazyNoCopyIPLayer(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, gopacket.DecodeOptions{Lazy: true, NoCopy: true}).Layer(LayerTypeIPv4)
- }
-}
-
-func BenchmarkLazyNoCopyTCPLayer(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, gopacket.DecodeOptions{Lazy: true, NoCopy: true}).Layer(LayerTypeTCP)
- }
-}
-
-func BenchmarkLazyNoCopyAllLayers(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, gopacket.DecodeOptions{Lazy: true, NoCopy: true}).Layers()
- }
-}
-
-func BenchmarkDefault(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, gopacket.Default)
- }
-}
-
-func getSerializeLayers() []gopacket.SerializableLayer {
- p := gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, testDecodeOptions)
- slayers := []gopacket.SerializableLayer{}
- for _, l := range p.Layers() {
- slayers = append(slayers, l.(gopacket.SerializableLayer))
- }
- p.Layer(LayerTypeTCP).(*TCP).SetNetworkLayerForChecksum(
- p.NetworkLayer())
- return slayers
-}
-
-func BenchmarkSerializeTcpNoOptions(b *testing.B) {
- slayers := getSerializeLayers()
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{}
- for i := 0; i < b.N; i++ {
- gopacket.SerializeLayers(buf, opts, slayers...)
- }
-}
-
-func BenchmarkSerializeTcpFixLengths(b *testing.B) {
- slayers := getSerializeLayers()
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{FixLengths: true}
- for i := 0; i < b.N; i++ {
- gopacket.SerializeLayers(buf, opts, slayers...)
- }
-}
-
-func BenchmarkSerializeTcpComputeChecksums(b *testing.B) {
- slayers := getSerializeLayers()
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{ComputeChecksums: true}
- for i := 0; i < b.N; i++ {
- gopacket.SerializeLayers(buf, opts, slayers...)
- }
-}
-
-func BenchmarkSerializeTcpFixLengthsComputeChecksums(b *testing.B) {
- slayers := getSerializeLayers()
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{FixLengths: true, ComputeChecksums: true}
- for i := 0; i < b.N; i++ {
- gopacket.SerializeLayers(buf, opts, slayers...)
- }
-}
-
-func BenchmarkLazy(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, gopacket.Lazy)
- }
-}
-
-func BenchmarkNoCopy(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-func BenchmarkLazyNoCopy(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, gopacket.DecodeOptions{Lazy: true, NoCopy: true})
- }
-}
-
-func BenchmarkKnownStack(b *testing.B) {
- stack := []gopacket.DecodingLayer{&Ethernet{}, &IPv4{}, &TCP{}, &gopacket.Payload{}}
- nf := gopacket.NilDecodeFeedback
- for i := 0; i < b.N; i++ {
- data := testSimpleTCPPacket[:]
- for _, d := range stack {
- _ = d.DecodeFromBytes(data, nf)
- data = d.LayerPayload()
- }
- }
-}
-
-func BenchmarkDecodingLayerParserIgnorePanic(b *testing.B) {
- decoded := make([]gopacket.LayerType, 0, 20)
- dlp := gopacket.NewDecodingLayerParser(LayerTypeEthernet, &Ethernet{}, &IPv4{}, &TCP{}, &gopacket.Payload{})
- dlp.IgnorePanic = true
- for i := 0; i < b.N; i++ {
- dlp.DecodeLayers(testSimpleTCPPacket, &decoded)
- }
-}
-
-func BenchmarkDecodingLayerParserHandlePanic(b *testing.B) {
- decoded := make([]gopacket.LayerType, 0, 20)
- dlp := gopacket.NewDecodingLayerParser(LayerTypeEthernet, &Ethernet{}, &IPv4{}, &TCP{}, &gopacket.Payload{})
- dlp.IgnorePanic = false
- for i := 0; i < b.N; i++ {
- dlp.DecodeLayers(testSimpleTCPPacket, &decoded)
- }
-}
-
-func BenchmarkAlloc(b *testing.B) {
- for i := 0; i < b.N; i++ {
- _ = &TCP{}
- }
-}
-
-func BenchmarkFlow(b *testing.B) {
- p := gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, gopacket.DecodeOptions{Lazy: true, NoCopy: true})
- net := p.NetworkLayer()
- for i := 0; i < b.N; i++ {
- net.NetworkFlow()
- }
-}
-
-func BenchmarkEndpoints(b *testing.B) {
- p := gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, gopacket.DecodeOptions{Lazy: true, NoCopy: true})
- flow := p.NetworkLayer().NetworkFlow()
- for i := 0; i < b.N; i++ {
- flow.Endpoints()
- }
-}
-
-func BenchmarkTCPLayerFromDecodedPacket(b *testing.B) {
- b.StopTimer()
- p := gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, testDecodeOptions)
- b.StartTimer()
- for i := 0; i < b.N; i++ {
- _ = p.Layer(LayerTypeTCP)
- }
-}
-
-func BenchmarkTCPLayerClassFromDecodedPacket(b *testing.B) {
- b.StopTimer()
- p := gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, testDecodeOptions)
- lc := gopacket.NewLayerClass([]gopacket.LayerType{LayerTypeTCP})
- b.StartTimer()
- for i := 0; i < b.N; i++ {
- _ = p.LayerClass(lc)
- }
-}
-
-func BenchmarkTCPTransportLayerFromDecodedPacket(b *testing.B) {
- b.StopTimer()
- p := gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, testDecodeOptions)
- b.StartTimer()
- for i := 0; i < b.N; i++ {
- _ = p.TransportLayer()
- }
-}
-
-func testDecoder([]byte, gopacket.PacketBuilder) error {
- return nil
-}
-
-func BenchmarkDecodeFuncCallOverheadDirectCall(b *testing.B) {
- var data []byte
- var pb gopacket.PacketBuilder
- for i := 0; i < b.N; i++ {
- _ = testDecoder(data, pb)
- }
-}
-
-func BenchmarkDecodeFuncCallOverheadDecoderCall(b *testing.B) {
- d := gopacket.DecodeFunc(testDecoder)
- var data []byte
- var pb gopacket.PacketBuilder
- for i := 0; i < b.N; i++ {
- _ = d.Decode(data, pb)
- }
-}
-
-func BenchmarkDecodeFuncCallOverheadArrayCall(b *testing.B) {
- EthernetTypeMetadata[1] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(testDecoder)}
- d := EthernetType(1)
- var data []byte
- var pb gopacket.PacketBuilder
- for i := 0; i < b.N; i++ {
- _ = d.Decode(data, pb)
- }
-}
-
-func BenchmarkFmtVerboseString(b *testing.B) {
- b.StopTimer()
- p := gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, testDecodeOptions)
- b.StartTimer()
- for i := 0; i < b.N; i++ {
- _ = fmt.Sprintf("%#v", p)
- }
-}
-
-func BenchmarkPacketString(b *testing.B) {
- b.StopTimer()
- p := gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, testDecodeOptions)
- b.StartTimer()
- for i := 0; i < b.N; i++ {
- _ = p.String()
- }
-}
-
-func BenchmarkPacketDumpString(b *testing.B) {
- b.StopTimer()
- p := gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, testDecodeOptions)
- b.StartTimer()
- for i := 0; i < b.N; i++ {
- _ = p.String()
- }
-}
-
-// TestFlowMapKey makes sure a flow and an endpoint can be used as map keys.
-func TestFlowMapKey(t *testing.T) {
- _ = map[gopacket.Flow]bool{}
- _ = map[gopacket.Endpoint]bool{}
- _ = map[[2]gopacket.Flow]bool{}
-}
-
-func TestDecodeSimpleTCPPacket(t *testing.T) {
- equal := func(desc, want string, got fmt.Stringer) {
- if want != got.String() {
- t.Errorf("%s: got %q want %q", desc, got.String(), want)
- }
- }
- p := gopacket.NewPacket(testSimpleTCPPacket, LinkTypeEthernet, gopacket.DecodeOptions{Lazy: true, NoCopy: true})
- if eth := p.LinkLayer(); eth == nil {
- t.Error("No ethernet layer found")
- } else {
- equal("Eth Src", "bc:30:5b:e8:d3:49", eth.LinkFlow().Src())
- equal("Eth Dst", "00:00:0c:9f:f0:20", eth.LinkFlow().Dst())
- }
- if net := p.NetworkLayer(); net == nil {
- t.Error("No net layer found")
- } else if ip, ok := net.(*IPv4); !ok {
- t.Error("Net layer is not IP layer")
- } else {
- equal("IP Src", "172.17.81.73", net.NetworkFlow().Src())
- equal("IP Dst", "173.222.254.225", net.NetworkFlow().Dst())
- want := &IPv4{
- BaseLayer: BaseLayer{testSimpleTCPPacket[14:34], testSimpleTCPPacket[34:]},
- Version: 4,
- IHL: 5,
- TOS: 0,
- Length: 420,
- Id: 14815,
- Flags: 0x02,
- FragOffset: 0,
- TTL: 64,
- Protocol: 6,
- Checksum: 0x555A,
- SrcIP: []byte{172, 17, 81, 73},
- DstIP: []byte{173, 222, 254, 225},
- }
- if !reflect.DeepEqual(ip, want) {
- t.Errorf("IP layer mismatch, \ngot %#v\nwant %#v\n", ip, want)
- }
- }
- if trans := p.TransportLayer(); trans == nil {
- t.Error("No transport layer found")
- } else if tcp, ok := trans.(*TCP); !ok {
- t.Error("Transport layer is not TCP layer")
- } else {
- equal("TCP Src", "50679", trans.TransportFlow().Src())
- equal("TCP Dst", "80", trans.TransportFlow().Dst())
- want := &TCP{
- BaseLayer: BaseLayer{testSimpleTCPPacket[34:66], testSimpleTCPPacket[66:]},
- SrcPort: 50679,
- DstPort: 80,
- Seq: 0xc57e0e48,
- Ack: 0x49074232,
- DataOffset: 8,
- ACK: true,
- PSH: true,
- Window: 0x73,
- Checksum: 0x9a8f,
- Urgent: 0,
- sPort: []byte{0xc5, 0xf7},
- dPort: []byte{0x0, 0x50},
- Options: []TCPOption{
- TCPOption{
- OptionType: 0x1,
- OptionLength: 0x1,
- },
- TCPOption{
- OptionType: 0x1,
- OptionLength: 0x1,
- },
- TCPOption{
- OptionType: 0x8,
- OptionLength: 0xa,
- OptionData: []byte{0x3, 0x77, 0x37, 0x9c, 0x42, 0x77, 0x5e, 0x3a},
- },
- },
- opts: [4]TCPOption{
- TCPOption{
- OptionType: 0x1,
- OptionLength: 0x1,
- },
- TCPOption{
- OptionType: 0x1,
- OptionLength: 0x1,
- },
- TCPOption{
- OptionType: 0x8,
- OptionLength: 0xa,
- OptionData: []byte{0x3, 0x77, 0x37, 0x9c, 0x42, 0x77, 0x5e, 0x3a},
- },
- TCPOption{},
- },
- }
- if !reflect.DeepEqual(tcp, want) {
- t.Errorf("TCP layer mismatch\ngot %#v\nwant %#v", tcp, want)
- }
- }
- if payload, ok := p.Layer(gopacket.LayerTypePayload).(*gopacket.Payload); payload == nil || !ok {
- t.Error("No payload layer found")
- } else {
- if string(payload.Payload()) != "GET / HTTP/1.1\r\nHost: www.fish.com\r\nConnection: keep-alive\r\nUser-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Encoding: gzip,deflate,sdch\r\nAccept-Language: en-US,en;q=0.8\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3\r\n\r\n" {
- t.Error("--- Payload STRING ---\n", string(payload.Payload()), "\n--- Payload BYTES ---\n", payload.Payload())
- }
- }
-
- // Test re-serialization.
- testSerialization(t, p, testSimpleTCPPacket)
-}
-
-type canSetNetLayer interface {
- SetNetworkLayerForChecksum(gopacket.NetworkLayer) error
-}
-
-func testSerialization(t *testing.T, p gopacket.Packet, data []byte) {
- for _, opts := range []gopacket.SerializeOptions{
- gopacket.SerializeOptions{},
- gopacket.SerializeOptions{FixLengths: true},
- gopacket.SerializeOptions{ComputeChecksums: true},
- gopacket.SerializeOptions{FixLengths: true, ComputeChecksums: true},
- } {
- testSerializationWithOpts(t, p, data, opts)
- }
-}
-
-func testSerializationWithOpts(t *testing.T, p gopacket.Packet, data []byte, opts gopacket.SerializeOptions) {
- // Test re-serialization.
- slayers := []gopacket.SerializableLayer{}
- for _, l := range p.Layers() {
- slayers = append(slayers, l.(gopacket.SerializableLayer))
- if h, ok := l.(canSetNetLayer); ok {
- if err := h.SetNetworkLayerForChecksum(p.NetworkLayer()); err != nil {
- t.Fatal("can't set network layer:", err)
- }
- }
- }
- buf := gopacket.NewSerializeBuffer()
- err := gopacket.SerializeLayers(buf, opts, slayers...)
- if err != nil {
- t.Errorf("unable to reserialize layers with opts %#v: %v", opts, err)
- } else if !bytes.Equal(buf.Bytes(), data) {
- t.Errorf("serialization failure with opts %#v:\n---want---\n%v\n---got---\n%v\nBASH-colorized diff, want->got:\n%v\n\n---PACKET---\n%v",
- opts, hex.Dump(data), hex.Dump(buf.Bytes()), bytediff.BashOutput.String(bytediff.Diff(data, buf.Bytes())), p)
- }
-}
-
-// Makes sure packet payload doesn't display the 6 trailing null of this packet
-// as part of the payload. They're actually the ethernet trailer.
-func TestDecodeSmallTCPPacketHasEmptyPayload(t *testing.T) {
- smallPacket := []byte{
- 0xbc, 0x30, 0x5b, 0xe8, 0xd3, 0x49, 0xb8, 0xac, 0x6f, 0x92, 0xd5, 0xbf,
- 0x08, 0x00, 0x45, 0x00, 0x00, 0x28, 0x00, 0x00, 0x40, 0x00, 0x40, 0x06,
- 0x3f, 0x9f, 0xac, 0x11, 0x51, 0xc5, 0xac, 0x11, 0x51, 0x49, 0x00, 0x63,
- 0x9a, 0xef, 0x00, 0x00, 0x00, 0x00, 0x2e, 0xc1, 0x27, 0x83, 0x50, 0x14,
- 0x00, 0x00, 0xc3, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- }
- p := gopacket.NewPacket(smallPacket, LinkTypeEthernet, testDecodeOptions)
-
- if payload := p.Layer(gopacket.LayerTypePayload); payload != nil {
- t.Error("Payload found for empty TCP packet")
- }
-
- testSerialization(t, p, smallPacket)
-}
-
-func TestDecodeVLANPacket(t *testing.T) {
- p := gopacket.NewPacket(
- []byte{
- 0x00, 0x10, 0xdb, 0xff, 0x10, 0x00, 0x00, 0x15, 0x2c, 0x9d, 0xcc, 0x00,
- 0x81, 0x00, 0x01, 0xf7, 0x08, 0x00, 0x45, 0x00, 0x00, 0x28, 0x29, 0x8d,
- 0x40, 0x00, 0x7d, 0x06, 0x83, 0xa0, 0xac, 0x1b, 0xca, 0x8e, 0x45, 0x16,
- 0x94, 0xe2, 0xd4, 0x0a, 0x00, 0x50, 0xdf, 0xab, 0x9c, 0xc6, 0xcd, 0x1e,
- 0xe5, 0xd1, 0x50, 0x10, 0x01, 0x00, 0x5a, 0x74, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- }, LinkTypeEthernet, testDecodeOptions)
- if err := p.ErrorLayer(); err != nil {
- t.Error("Error while parsing vlan packet:", err)
- }
- if vlan := p.Layer(LayerTypeDot1Q); vlan == nil {
- t.Error("Didn't detect vlan")
- } else if _, ok := vlan.(*Dot1Q); !ok {
- t.Error("LayerTypeDot1Q layer is not a Dot1Q object")
- }
- for i, l := range p.Layers() {
- t.Logf("Layer %d: %#v", i, l)
- }
- want := []gopacket.LayerType{LayerTypeEthernet, LayerTypeDot1Q, LayerTypeIPv4, LayerTypeTCP}
- checkLayers(p, want, t)
-}
-
-func TestDecodeSCTPPackets(t *testing.T) {
- sctpPackets := [][]byte{
- []byte{ // INIT
- 0x00, 0x00, 0x0c, 0x9f, 0xf0, 0x1f, 0x24, 0xbe, 0x05, 0x27, 0x0b, 0x17, 0x08, 0x00, 0x45, 0x02,
- 0x00, 0x44, 0x00, 0x00, 0x40, 0x00, 0x40, 0x84, 0xc4, 0x22, 0xac, 0x1d, 0x14, 0x0f, 0xac, 0x19,
- 0x09, 0xcc, 0x27, 0x0f, 0x22, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x19, 0x6b, 0x0b, 0x40, 0x01, 0x00,
- 0x00, 0x24, 0xb6, 0x96, 0xb0, 0x9e, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x0a, 0xff, 0xff, 0xdb, 0x85,
- 0x60, 0x23, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x80, 0x00, 0x00, 0x04, 0xc0, 0x00,
- 0x00, 0x04,
- }, []byte{ // INIT ACK
- 0x24, 0xbe, 0x05, 0x27, 0x0b, 0x17, 0x00, 0x1f, 0xca, 0xb3, 0x76, 0x40, 0x08, 0x00, 0x45, 0x20,
- 0x01, 0x24, 0x00, 0x00, 0x40, 0x00, 0x36, 0x84, 0xcd, 0x24, 0xac, 0x19, 0x09, 0xcc, 0xac, 0x1d,
- 0x14, 0x0f, 0x22, 0xb8, 0x27, 0x0f, 0xb6, 0x96, 0xb0, 0x9e, 0x4b, 0xab, 0x40, 0x9a, 0x02, 0x00,
- 0x01, 0x04, 0x32, 0x80, 0xfb, 0x42, 0x00, 0x00, 0xf4, 0x00, 0x00, 0x0a, 0x00, 0x0a, 0x85, 0x98,
- 0xb1, 0x26, 0x00, 0x07, 0x00, 0xe8, 0xd3, 0x08, 0xce, 0xe2, 0x52, 0x95, 0xcc, 0x09, 0xa1, 0x4c,
- 0x6f, 0xa7, 0x9e, 0xba, 0x03, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0xfb, 0x80, 0x32, 0x9e, 0xb0,
- 0x96, 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x46, 0xc2, 0x50, 0x00, 0x00,
- 0x00, 0x00, 0x5e, 0x25, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x26, 0xb1,
- 0x98, 0x85, 0x02, 0x00, 0x27, 0x0f, 0xac, 0x1d, 0x14, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0x22,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x24, 0x6a, 0x72, 0x5c, 0x1c, 0x3c, 0xaa,
- 0x7a, 0xcd, 0xd3, 0x8f, 0x52, 0x78, 0x7c, 0x77, 0xfd, 0x46, 0xbd, 0x72, 0x82, 0xc1, 0x1f, 0x70,
- 0x44, 0xcc, 0xc7, 0x9b, 0x9b, 0x7b, 0x13, 0x54, 0x3f, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x24, 0xb6, 0x96,
- 0xb0, 0x9e, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x0a, 0xff, 0xff, 0xdb, 0x85, 0x60, 0x23, 0x00, 0x0c,
- 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x80, 0x00, 0x00, 0x04, 0xc0, 0x00, 0x00, 0x04, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x04, 0xc0, 0x00,
- 0x00, 0x04,
- }, []byte{ // COOKIE ECHO, DATA
- 0x00, 0x00, 0x0c, 0x9f, 0xf0, 0x1f, 0x24, 0xbe, 0x05, 0x27, 0x0b, 0x17, 0x08, 0x00, 0x45, 0x02,
- 0x01, 0x20, 0x00, 0x00, 0x40, 0x00, 0x40, 0x84, 0xc3, 0x46, 0xac, 0x1d, 0x14, 0x0f, 0xac, 0x19,
- 0x09, 0xcc, 0x27, 0x0f, 0x22, 0xb8, 0x32, 0x80, 0xfb, 0x42, 0x01, 0xf9, 0xf3, 0xa9, 0x0a, 0x00,
- 0x00, 0xe8, 0xd3, 0x08, 0xce, 0xe2, 0x52, 0x95, 0xcc, 0x09, 0xa1, 0x4c, 0x6f, 0xa7, 0x9e, 0xba,
- 0x03, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0xfb, 0x80, 0x32, 0x9e, 0xb0, 0x96, 0xb6, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x46, 0xc2, 0x50, 0x00, 0x00, 0x00, 0x00, 0x5e, 0x25,
- 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x26, 0xb1, 0x98, 0x85, 0x02, 0x00,
- 0x27, 0x0f, 0xac, 0x1d, 0x14, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0x22, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x02, 0x00, 0x24, 0x6a, 0x72, 0x5c, 0x1c, 0x3c, 0xaa, 0x7a, 0xcd, 0xd3, 0x8f,
- 0x52, 0x78, 0x7c, 0x77, 0xfd, 0x46, 0xbd, 0x72, 0x82, 0xc1, 0x1f, 0x70, 0x44, 0xcc, 0xc7, 0x9b,
- 0x9b, 0x7b, 0x13, 0x54, 0x3f, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x24, 0xb6, 0x96, 0xb0, 0x9e, 0x00, 0x01,
- 0xc0, 0x00, 0x00, 0x0a, 0xff, 0xff, 0xdb, 0x85, 0x60, 0x23, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x05,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x04, 0xc0, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x16, 0xdb, 0x85, 0x60, 0x23, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x6f, 0x6f, 0x21, 0x0a, 0x00, 0x00, 0x00,
- }, []byte{ // COOKIE ACK, SACK
- 0x24, 0xbe, 0x05, 0x27, 0x0b, 0x17, 0x00, 0x1f, 0xca, 0xb3, 0x76, 0x40, 0x08, 0x00, 0x45, 0x20,
- 0x00, 0x34, 0x00, 0x00, 0x40, 0x00, 0x36, 0x84, 0xce, 0x14, 0xac, 0x19, 0x09, 0xcc, 0xac, 0x1d,
- 0x14, 0x0f, 0x22, 0xb8, 0x27, 0x0f, 0xb6, 0x96, 0xb0, 0x9e, 0xed, 0x64, 0x30, 0x98, 0x0b, 0x00,
- 0x00, 0x04, 0x03, 0x00, 0x00, 0x10, 0xdb, 0x85, 0x60, 0x23, 0x00, 0x00, 0xf3, 0xfa, 0x00, 0x00,
- 0x00, 0x00,
- }, []byte{ // DATA
- 0x00, 0x00, 0x0c, 0x9f, 0xf0, 0x1f, 0x24, 0xbe, 0x05, 0x27, 0x0b, 0x17, 0x08, 0x00, 0x45, 0x02,
- 0x00, 0x3c, 0x00, 0x00, 0x40, 0x00, 0x40, 0x84, 0xc4, 0x2a, 0xac, 0x1d, 0x14, 0x0f, 0xac, 0x19,
- 0x09, 0xcc, 0x27, 0x0f, 0x22, 0xb8, 0x32, 0x80, 0xfb, 0x42, 0xa1, 0xe3, 0xb2, 0x31, 0x00, 0x03,
- 0x00, 0x19, 0xdb, 0x85, 0x60, 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x62, 0x69,
- 0x7a, 0x7a, 0x6c, 0x65, 0x21, 0x0a, 0x00, 0x00, 0x00, 0x00,
- }, []byte{ // SACK
- 0x24, 0xbe, 0x05, 0x27, 0x0b, 0x17, 0x00, 0x1f, 0xca, 0xb3, 0x76, 0x40, 0x08, 0x00, 0x45, 0x20,
- 0x00, 0x30, 0x00, 0x00, 0x40, 0x00, 0x36, 0x84, 0xce, 0x18, 0xac, 0x19, 0x09, 0xcc, 0xac, 0x1d,
- 0x14, 0x0f, 0x22, 0xb8, 0x27, 0x0f, 0xb6, 0x96, 0xb0, 0x9e, 0xfa, 0x49, 0x94, 0x3a, 0x03, 0x00,
- 0x00, 0x10, 0xdb, 0x85, 0x60, 0x24, 0x00, 0x00, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00,
- }, []byte{ // SHUTDOWN
- 0x00, 0x00, 0x0c, 0x9f, 0xf0, 0x1f, 0x24, 0xbe, 0x05, 0x27, 0x0b, 0x17, 0x08, 0x00, 0x45, 0x02,
- 0x00, 0x28, 0x00, 0x00, 0x40, 0x00, 0x40, 0x84, 0xc4, 0x3e, 0xac, 0x1d, 0x14, 0x0f, 0xac, 0x19,
- 0x09, 0xcc, 0x27, 0x0f, 0x22, 0xb8, 0x32, 0x80, 0xfb, 0x42, 0x3f, 0x29, 0x59, 0x23, 0x07, 0x00,
- 0x00, 0x08, 0x85, 0x98, 0xb1, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- }, []byte{ // SHUTDOWN ACK
- 0x24, 0xbe, 0x05, 0x27, 0x0b, 0x17, 0x00, 0x1f, 0xca, 0xb3, 0x76, 0x40, 0x08, 0x00, 0x45, 0x20,
- 0x00, 0x24, 0x00, 0x00, 0x40, 0x00, 0x36, 0x84, 0xce, 0x24, 0xac, 0x19, 0x09, 0xcc, 0xac, 0x1d,
- 0x14, 0x0f, 0x22, 0xb8, 0x27, 0x0f, 0xb6, 0x96, 0xb0, 0x9e, 0xb2, 0xc8, 0x99, 0x24, 0x08, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- }, []byte{ // SHUTDOWN COMPLETE
- 0x00, 0x00, 0x0c, 0x9f, 0xf0, 0x1f, 0x24, 0xbe, 0x05, 0x27, 0x0b, 0x17, 0x08, 0x00, 0x45, 0x02,
- 0x00, 0x24, 0x00, 0x00, 0x40, 0x00, 0x40, 0x84, 0xc4, 0x42, 0xac, 0x1d, 0x14, 0x0f, 0xac, 0x19,
- 0x09, 0xcc, 0x27, 0x0f, 0x22, 0xb8, 0x32, 0x80, 0xfb, 0x42, 0xa8, 0xd1, 0x86, 0x85, 0x0e, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- }}
- wantLayers := [][]gopacket.LayerType{
- []gopacket.LayerType{LayerTypeSCTPInit},
- []gopacket.LayerType{LayerTypeSCTPInitAck},
- []gopacket.LayerType{LayerTypeSCTPCookieEcho, LayerTypeSCTPData, gopacket.LayerTypePayload},
- []gopacket.LayerType{LayerTypeSCTPCookieAck, LayerTypeSCTPSack},
- []gopacket.LayerType{LayerTypeSCTPData, gopacket.LayerTypePayload},
- []gopacket.LayerType{LayerTypeSCTPSack},
- []gopacket.LayerType{LayerTypeSCTPShutdown},
- []gopacket.LayerType{LayerTypeSCTPShutdownAck},
- []gopacket.LayerType{LayerTypeSCTPShutdownComplete},
- }
- for i, data := range sctpPackets {
- p := gopacket.NewPacket(data, LinkTypeEthernet, testDecodeOptions)
- for _, typ := range wantLayers[i] {
- if p.Layer(typ) == nil {
- t.Errorf("Packet %d missing layer type %v, got:", i, typ)
- for _, layer := range p.Layers() {
- t.Errorf("\t%v", layer.LayerType())
- }
- if p.ErrorLayer() != nil {
- t.Error("\tPacket layer error:", p.ErrorLayer().Error())
- }
- }
- }
- // Test re-serialization.
- testSerializationWithOpts(t, p, data, gopacket.SerializeOptions{FixLengths: true, ComputeChecksums: true})
- }
-}
-
-func TestDecodeCiscoDiscovery(t *testing.T) {
- // http://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=cdp_v2.pcap
- data := []byte{
- 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc, 0x00, 0x0b, 0xbe, 0x18, 0x9a, 0x41, 0x01, 0xc3, 0xaa, 0xaa,
- 0x03, 0x00, 0x00, 0x0c, 0x20, 0x00, 0x02, 0xb4, 0x09, 0xa0, 0x00, 0x01, 0x00, 0x0c, 0x6d, 0x79,
- 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x00, 0x02, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
- 0xcc, 0x00, 0x04, 0xc0, 0xa8, 0x00, 0xfd, 0x00, 0x03, 0x00, 0x13, 0x46, 0x61, 0x73, 0x74, 0x45,
- 0x74, 0x68, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x30, 0x2f, 0x31, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00,
- 0x00, 0x28, 0x00, 0x05, 0x01, 0x14, 0x43, 0x69, 0x73, 0x63, 0x6f, 0x20, 0x49, 0x6e, 0x74, 0x65,
- 0x72, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69,
- 0x6e, 0x67, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61,
- 0x72, 0x65, 0x20, 0x0a, 0x49, 0x4f, 0x53, 0x20, 0x28, 0x74, 0x6d, 0x29, 0x20, 0x43, 0x32, 0x39,
- 0x35, 0x30, 0x20, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x20, 0x28, 0x43, 0x32, 0x39,
- 0x35, 0x30, 0x2d, 0x49, 0x36, 0x4b, 0x32, 0x4c, 0x32, 0x51, 0x34, 0x2d, 0x4d, 0x29, 0x2c, 0x20,
- 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x31, 0x32, 0x2e, 0x31, 0x28, 0x32, 0x32, 0x29,
- 0x45, 0x41, 0x31, 0x34, 0x2c, 0x20, 0x52, 0x45, 0x4c, 0x45, 0x41, 0x53, 0x45, 0x20, 0x53, 0x4f,
- 0x46, 0x54, 0x57, 0x41, 0x52, 0x45, 0x20, 0x28, 0x66, 0x63, 0x31, 0x29, 0x0a, 0x54, 0x65, 0x63,
- 0x68, 0x6e, 0x69, 0x63, 0x61, 0x6c, 0x20, 0x53, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x3a, 0x20,
- 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x63, 0x69, 0x73, 0x63, 0x6f,
- 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x65, 0x63, 0x68, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74,
- 0x0a, 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x28, 0x63, 0x29, 0x20, 0x31,
- 0x39, 0x38, 0x36, 0x2d, 0x32, 0x30, 0x31, 0x30, 0x20, 0x62, 0x79, 0x20, 0x63, 0x69, 0x73, 0x63,
- 0x6f, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x0a,
- 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x64, 0x20, 0x54, 0x75, 0x65, 0x20, 0x32, 0x36, 0x2d,
- 0x4f, 0x63, 0x74, 0x2d, 0x31, 0x30, 0x20, 0x31, 0x30, 0x3a, 0x33, 0x35, 0x20, 0x62, 0x79, 0x20,
- 0x6e, 0x62, 0x75, 0x72, 0x72, 0x61, 0x00, 0x06, 0x00, 0x15, 0x63, 0x69, 0x73, 0x63, 0x6f, 0x20,
- 0x57, 0x53, 0x2d, 0x43, 0x32, 0x39, 0x35, 0x30, 0x2d, 0x31, 0x32, 0x00, 0x08, 0x00, 0x24, 0x00,
- 0x00, 0x0c, 0x01, 0x12, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x02, 0x20, 0xff,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xbe, 0x18, 0x9a, 0x40, 0xff, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x0c, 0x4d, 0x59, 0x44, 0x4f, 0x4d, 0x41, 0x49, 0x4e, 0x00, 0x0a, 0x00, 0x06, 0x00,
- 0x01, 0x00, 0x0b, 0x00, 0x05, 0x01, 0x00, 0x12, 0x00, 0x05, 0x00, 0x00, 0x13, 0x00, 0x05, 0x00,
- 0x00, 0x16, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0xcc, 0x00, 0x04, 0xc0, 0xa8, 0x00,
- 0xfd,
- }
- p := gopacket.NewPacket(data, LinkTypeEthernet, testDecodeOptions)
- wantLayers := []gopacket.LayerType{LayerTypeEthernet, LayerTypeLLC, LayerTypeSNAP, LayerTypeCiscoDiscovery, LayerTypeCiscoDiscoveryInfo}
- checkLayers(p, wantLayers, t)
-
- want := &CiscoDiscoveryInfo{
- CDPHello: CDPHello{
- OUI: []byte{0, 0, 12},
- ProtocolID: 274,
- ClusterMaster: []byte{0, 0, 0, 0},
- Unknown1: []byte{255, 255, 255, 255},
- Version: 1,
- SubVersion: 2,
- Status: 32,
- Unknown2: 255,
- ClusterCommander: net.HardwareAddr{0, 0, 0, 0, 0, 0},
- SwitchMAC: net.HardwareAddr{0, 0x0b, 0xbe, 0x18, 0x9a, 0x40},
- Unknown3: 255,
- ManagementVLAN: 0,
- },
- DeviceID: "myswitch",
- Addresses: []net.IP{net.IPv4(192, 168, 0, 253)},
- PortID: "FastEthernet0/1",
- Capabilities: CDPCapabilities{false, false, false, true, false, true, false, false, false},
- Version: "Cisco Internetwork Operating System Software \nIOS (tm) C2950 Software (C2950-I6K2L2Q4-M), Version 12.1(22)EA14, RELEASE SOFTWARE (fc1)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2010 by cisco Systems, Inc.\nCompiled Tue 26-Oct-10 10:35 by nburra",
- Platform: "cisco WS-C2950-12",
- VTPDomain: "MYDOMAIN",
- NativeVLAN: 1,
- FullDuplex: true,
- MgmtAddresses: []net.IP{net.IPv4(192, 168, 0, 253)},
- BaseLayer: BaseLayer{Contents: data[26:]},
- }
- cdpL := p.Layer(LayerTypeCiscoDiscoveryInfo)
- info, _ := cdpL.(*CiscoDiscoveryInfo)
- if !reflect.DeepEqual(info, want) {
- t.Errorf("Values mismatch, \ngot %#v\nwant %#v\n", info, want)
- }
-}
-
-func TestDecodeLinkLayerDiscovery(t *testing.T) {
- // http://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=lldp.detailed.pcap
- data := []byte{
- 0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e, 0x00, 0x01, 0x30, 0xf9, 0xad, 0xa0,
- 0x88, 0xcc, 0x02, 0x07, 0x04, 0x00, 0x01, 0x30, 0xf9, 0xad, 0xa0, 0x04,
- 0x04, 0x05, 0x31, 0x2f, 0x31, 0x06, 0x02, 0x00, 0x78, 0x08, 0x17, 0x53,
- 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30, 0x30, 0x2d, 0x34, 0x38, 0x2d,
- 0x50, 0x6f, 0x72, 0x74, 0x20, 0x31, 0x30, 0x30, 0x31, 0x00, 0x0a, 0x0d,
- 0x53, 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30, 0x30, 0x2d, 0x34, 0x38,
- 0x00, 0x0c, 0x4c, 0x53, 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30, 0x30,
- 0x2d, 0x34, 0x38, 0x20, 0x2d, 0x20, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f,
- 0x6e, 0x20, 0x37, 0x2e, 0x34, 0x65, 0x2e, 0x31, 0x20, 0x28, 0x42, 0x75,
- 0x69, 0x6c, 0x64, 0x20, 0x35, 0x29, 0x20, 0x62, 0x79, 0x20, 0x52, 0x65,
- 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72,
- 0x20, 0x30, 0x35, 0x2f, 0x32, 0x37, 0x2f, 0x30, 0x35, 0x20, 0x30, 0x34,
- 0x3a, 0x35, 0x33, 0x3a, 0x31, 0x31, 0x00, 0x0e, 0x04, 0x00, 0x14, 0x00,
- 0x14, 0x10, 0x0e, 0x07, 0x06, 0x00, 0x01, 0x30, 0xf9, 0xad, 0xa0, 0x02,
- 0x00, 0x00, 0x03, 0xe9, 0x00, 0xfe, 0x07, 0x00, 0x12, 0x0f, 0x02, 0x07,
- 0x01, 0x00, 0xfe, 0x09, 0x00, 0x12, 0x0f, 0x01, 0x03, 0x6c, 0x00, 0x00,
- 0x10, 0xfe, 0x09, 0x00, 0x12, 0x0f, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0xfe, 0x06, 0x00, 0x12, 0x0f, 0x04, 0x05, 0xf2, 0xfe, 0x06, 0x00, 0x80,
- 0xc2, 0x01, 0x01, 0xe8, 0xfe, 0x07, 0x00, 0x80, 0xc2, 0x02, 0x01, 0x00,
- 0x00, 0xfe, 0x17, 0x00, 0x80, 0xc2, 0x03, 0x01, 0xe8, 0x10, 0x76, 0x32,
- 0x2d, 0x30, 0x34, 0x38, 0x38, 0x2d, 0x30, 0x33, 0x2d, 0x30, 0x35, 0x30,
- 0x35, 0x00, 0xfe, 0x05, 0x00, 0x80, 0xc2, 0x04, 0x00, 0x00, 0x00,
- }
-
- p := gopacket.NewPacket(data, LinkTypeEthernet, testDecodeOptions)
- wantLayers := []gopacket.LayerType{LayerTypeEthernet, LayerTypeLinkLayerDiscovery, LayerTypeLinkLayerDiscoveryInfo}
- checkLayers(p, wantLayers, t)
- lldpL := p.Layer(LayerTypeLinkLayerDiscovery)
- lldp := lldpL.(*LinkLayerDiscovery)
- want := &LinkLayerDiscovery{
- ChassisID: LLDPChassisID{LLDPChassisIDSubTypeMACAddr, []byte{0x00, 0x01, 0x30, 0xf9, 0xad, 0xa0}},
- PortID: LLDPPortID{LLDPPortIDSubtypeIfaceName, []byte("1/1")},
- TTL: 120,
- BaseLayer: BaseLayer{Contents: data[14:]},
- }
- lldp.Values = nil // test these in next stage
- if !reflect.DeepEqual(lldp, want) {
- t.Errorf("Values mismatch, \ngot %#v\nwant %#v\n", lldp, want)
- }
-
- infoL := p.Layer(LayerTypeLinkLayerDiscoveryInfo)
- info := infoL.(*LinkLayerDiscoveryInfo)
- wantinfo := &LinkLayerDiscoveryInfo{
- PortDescription: "Summit300-48-Port 1001\x00",
- SysName: "Summit300-48\x00",
- SysDescription: "Summit300-48 - Version 7.4e.1 (Build 5) by Release_Master 05/27/05 04:53:11\x00",
- SysCapabilities: LLDPSysCapabilities{
- SystemCap: LLDPCapabilities{Bridge: true, Router: true},
- EnabledCap: LLDPCapabilities{Bridge: true, Router: true},
- },
- MgmtAddress: LLDPMgmtAddress{IANAAddressFamily802, []byte{0x00, 0x01, 0x30, 0xf9, 0xad, 0xa0}, LLDPInterfaceSubtypeifIndex, 1001, ""},
- OrgTLVs: []LLDPOrgSpecificTLV{
- LLDPOrgSpecificTLV{OUI: 0x120f, SubType: 0x2, Info: []uint8{0x7, 0x1, 0x0}},
- LLDPOrgSpecificTLV{OUI: 0x120f, SubType: 0x1, Info: []uint8{0x3, 0x6c, 0x0, 0x0, 0x10}},
- LLDPOrgSpecificTLV{OUI: 0x120f, SubType: 0x3, Info: []uint8{0x1, 0x0, 0x0, 0x0, 0x0}},
- LLDPOrgSpecificTLV{OUI: 0x120f, SubType: 0x4, Info: []uint8{0x5, 0xf2}},
- LLDPOrgSpecificTLV{OUI: 0x80c2, SubType: 0x1, Info: []uint8{0x1, 0xe8}},
- LLDPOrgSpecificTLV{OUI: 0x80c2, SubType: 0x2, Info: []uint8{0x1, 0x0, 0x0}},
- LLDPOrgSpecificTLV{OUI: 0x80c2, SubType: 0x3, Info: []uint8{0x1, 0xe8, 0x10, 0x76, 0x32, 0x2d, 0x30, 0x34, 0x38, 0x38, 0x2d, 0x30, 0x33, 0x2d, 0x30, 0x35, 0x30, 0x35, 0x0}},
- LLDPOrgSpecificTLV{OUI: 0x80c2, SubType: 0x4, Info: []uint8{0x0}},
- },
- Unknown: nil,
- }
- if !reflect.DeepEqual(info, wantinfo) {
- t.Errorf("Values mismatch, \ngot %#v\nwant %#v\n", info, wantinfo)
- }
- info8021, err := info.Decode8021()
- if err != nil {
- t.Errorf("8021 Values decode error: %v", err)
- }
- want8021 := LLDPInfo8021{
- PVID: 488,
- PPVIDs: []PortProtocolVLANID{PortProtocolVLANID{false, false, 0}},
- VLANNames: []VLANName{VLANName{488, "v2-0488-03-0505\x00"}},
- ProtocolIdentities: nil,
- VIDUsageDigest: 0,
- ManagementVID: 0,
- LinkAggregation: LLDPLinkAggregation{false, false, 0},
- }
- if !reflect.DeepEqual(info8021, want8021) {
- t.Errorf("Values mismatch, \ngot %#v\nwant %#v\n", info8021, want8021)
- }
- info8023, err := info.Decode8023()
- if err != nil {
- t.Errorf("8023 Values decode error: %v", err)
- }
- want8023 := LLDPInfo8023{
- LinkAggregation: LLDPLinkAggregation{true, false, 0},
- MACPHYConfigStatus: LLDPMACPHYConfigStatus{true, true, 0x6c00, 0x0010},
- PowerViaMDI: LLDPPowerViaMDI8023{true, true, true, false, 1, 0, 0, 0, 0, 0, 0},
- MTU: 1522,
- }
-
- if !reflect.DeepEqual(info8023, want8023) {
- t.Errorf("Values mismatch, \ngot %#v\nwant %#v\n", info8023, want8023)
- }
-
- // http://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=lldpmed_civicloc.pcap
- data = []byte{
- 0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e, 0x00, 0x13, 0x21, 0x57, 0xca, 0x7f,
- 0x88, 0xcc, 0x02, 0x07, 0x04, 0x00, 0x13, 0x21, 0x57, 0xca, 0x40, 0x04,
- 0x02, 0x07, 0x31, 0x06, 0x02, 0x00, 0x78, 0x08, 0x01, 0x31, 0x0a, 0x1a,
- 0x50, 0x72, 0x6f, 0x43, 0x75, 0x72, 0x76, 0x65, 0x20, 0x53, 0x77, 0x69,
- 0x74, 0x63, 0x68, 0x20, 0x32, 0x36, 0x30, 0x30, 0x2d, 0x38, 0x2d, 0x50,
- 0x57, 0x52, 0x0c, 0x5f, 0x50, 0x72, 0x6f, 0x43, 0x75, 0x72, 0x76, 0x65,
- 0x20, 0x4a, 0x38, 0x37, 0x36, 0x32, 0x41, 0x20, 0x53, 0x77, 0x69, 0x74,
- 0x63, 0x68, 0x20, 0x32, 0x36, 0x30, 0x30, 0x2d, 0x38, 0x2d, 0x50, 0x57,
- 0x52, 0x2c, 0x20, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x20,
- 0x48, 0x2e, 0x30, 0x38, 0x2e, 0x38, 0x39, 0x2c, 0x20, 0x52, 0x4f, 0x4d,
- 0x20, 0x48, 0x2e, 0x30, 0x38, 0x2e, 0x35, 0x58, 0x20, 0x28, 0x2f, 0x73,
- 0x77, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64,
- 0x2f, 0x66, 0x69, 0x73, 0x68, 0x28, 0x74, 0x73, 0x5f, 0x30, 0x38, 0x5f,
- 0x35, 0x29, 0x29, 0x0e, 0x04, 0x00, 0x14, 0x00, 0x04, 0x10, 0x0c, 0x05,
- 0x01, 0x0f, 0xff, 0x7a, 0x94, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe,
- 0x09, 0x00, 0x12, 0x0f, 0x01, 0x03, 0x6c, 0x00, 0x00, 0x10, 0xfe, 0x07,
- 0x00, 0x12, 0xbb, 0x01, 0x00, 0x0f, 0x04, 0xfe, 0x08, 0x00, 0x12, 0xbb,
- 0x02, 0x01, 0x40, 0x65, 0xae, 0xfe, 0x2e, 0x00, 0x12, 0xbb, 0x03, 0x02,
- 0x28, 0x02, 0x55, 0x53, 0x01, 0x02, 0x43, 0x41, 0x03, 0x09, 0x52, 0x6f,
- 0x73, 0x65, 0x76, 0x69, 0x6c, 0x6c, 0x65, 0x06, 0x09, 0x46, 0x6f, 0x6f,
- 0x74, 0x68, 0x69, 0x6c, 0x6c, 0x73, 0x13, 0x04, 0x38, 0x30, 0x30, 0x30,
- 0x1a, 0x03, 0x52, 0x33, 0x4c, 0xfe, 0x07, 0x00, 0x12, 0xbb, 0x04, 0x03,
- 0x00, 0x41, 0x00, 0x00,
- }
-
- p = gopacket.NewPacket(data, LinkTypeEthernet, testDecodeOptions)
- wantLayers = []gopacket.LayerType{LayerTypeEthernet, LayerTypeLinkLayerDiscovery, LayerTypeLinkLayerDiscoveryInfo}
- checkLayers(p, wantLayers, t)
- lldpL = p.Layer(LayerTypeLinkLayerDiscovery)
- lldp = lldpL.(*LinkLayerDiscovery)
- want = &LinkLayerDiscovery{
- ChassisID: LLDPChassisID{LLDPChassisIDSubTypeMACAddr, []byte{0x00, 0x13, 0x21, 0x57, 0xca, 0x40}},
- PortID: LLDPPortID{LLDPPortIDSubtypeLocal, []byte("1")},
- TTL: 120,
- BaseLayer: BaseLayer{Contents: data[14:]},
- }
- lldp.Values = nil // test these in next stage
- if !reflect.DeepEqual(lldp, want) {
- t.Errorf("Values mismatch, \ngot %#v\nwant %#v\n", lldp, want)
- }
-
- infoL = p.Layer(LayerTypeLinkLayerDiscoveryInfo)
- info = infoL.(*LinkLayerDiscoveryInfo)
- wantinfo = &LinkLayerDiscoveryInfo{
- PortDescription: "1",
- SysName: "ProCurve Switch 2600-8-PWR",
- SysDescription: "ProCurve J8762A Switch 2600-8-PWR, revision H.08.89, ROM H.08.5X (/sw/code/build/fish(ts_08_5))",
- SysCapabilities: LLDPSysCapabilities{
- SystemCap: LLDPCapabilities{Bridge: true, Router: true},
- EnabledCap: LLDPCapabilities{Bridge: true},
- },
- MgmtAddress: LLDPMgmtAddress{IANAAddressFamilyIPV4, []byte{0x0f, 0xff, 0x7a, 0x94}, LLDPInterfaceSubtypeifIndex, 0, ""},
- OrgTLVs: []LLDPOrgSpecificTLV{
- LLDPOrgSpecificTLV{OUI: 0x120f, SubType: 0x1, Info: []uint8{0x3, 0x6c, 0x0, 0x0, 0x10}},
- LLDPOrgSpecificTLV{OUI: 0x12bb, SubType: 0x1, Info: []uint8{0x0, 0xf, 0x4}},
- LLDPOrgSpecificTLV{OUI: 0x12bb, SubType: 0x2, Info: []uint8{0x1, 0x40, 0x65, 0xae}},
- LLDPOrgSpecificTLV{OUI: 0x12bb, SubType: 0x3, Info: []uint8{0x2, 0x28, 0x2, 0x55, 0x53, 0x1, 0x2, 0x43, 0x41, 0x3, 0x9, 0x52, 0x6f, 0x73, 0x65, 0x76, 0x69, 0x6c, 0x6c, 0x65, 0x6, 0x9, 0x46, 0x6f, 0x6f, 0x74, 0x68, 0x69, 0x6c, 0x6c, 0x73, 0x13, 0x4, 0x38, 0x30, 0x30, 0x30, 0x1a, 0x3, 0x52, 0x33, 0x4c}},
- LLDPOrgSpecificTLV{OUI: 0x12bb, SubType: 0x4, Info: []uint8{0x3, 0x0, 0x41}},
- },
- Unknown: nil,
- }
- if !reflect.DeepEqual(info, wantinfo) {
- t.Errorf("Values mismatch, \ngot %#v\nwant %#v\n", info, wantinfo)
- }
- info8023, err = info.Decode8023()
- if err != nil {
- t.Errorf("8023 Values decode error: %v", err)
- }
- want8023 = LLDPInfo8023{
- MACPHYConfigStatus: LLDPMACPHYConfigStatus{true, true, 0x6c00, 0x0010},
- }
-
- if !reflect.DeepEqual(info8023, want8023) {
- t.Errorf("Values mismatch, \ngot %#v\nwant %#v\n", info8023, want8023)
- }
-
- infoMedia, err := info.DecodeMedia()
- if err != nil {
- t.Errorf("8023 Values decode error: %v", err)
- }
- wantMedia := LLDPInfoMedia{
- MediaCapabilities: LLDPMediaCapabilities{true, true, true, true, false, false, LLDPMediaClassNetwork},
- NetworkPolicy: LLDPNetworkPolicy{LLDPAppTypeVoice, true, true, 50, 6, 46},
- Location: LLDPLocation{Format: LLDPLocationFormatAddress, Address: LLDPLocationAddress{
- What: LLDPLocationAddressWhatClient,
- CountryCode: "US",
- AddressLines: []LLDPLocationAddressLine{
- LLDPLocationAddressLine{LLDPLocationAddressTypeNational, "CA"},
- LLDPLocationAddressLine{LLDPLocationAddressTypeCity, "Roseville"},
- LLDPLocationAddressLine{LLDPLocationAddressTypeStreet, "Foothills"},
- LLDPLocationAddressLine{LLDPLocationAddressTypeHouseNum, "8000"},
- LLDPLocationAddressLine{LLDPLocationAddressTypeUnit, "R3L"},
- },
- }},
- PowerViaMDI: LLDPPowerViaMDI{0, 0, LLDPPowerPriorityLow, 6500},
- }
-
- if !reflect.DeepEqual(infoMedia, wantMedia) {
- t.Errorf("Values mismatch, \ngot %#v\nwant %#v\n", infoMedia, wantMedia)
- }
-
-}
-
-func TestDecodeNortelDiscovery(t *testing.T) {
- // http://www.thetechfirm.com/packets/nortel_btdp/btdp_nai.enc
- data := []byte{
- 0x01, 0x00, 0x81, 0x00, 0x01, 0x00, 0x00, 0x04, 0x38, 0xe0, 0xcc, 0xde,
- 0x00, 0x13, 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x81, 0x01, 0xa2, 0xac, 0x13,
- 0x58, 0x03, 0x00, 0x04, 0x15, 0x30, 0x0c, 0x02, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x04, 0x38, 0xe0, 0xcc, 0xde, 0x80, 0x6a, 0x00, 0x01, 0x14, 0x00,
- 0x02, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- }
- p := gopacket.NewPacket(data, LinkTypeEthernet, testDecodeOptions)
- wantLayers := []gopacket.LayerType{LayerTypeEthernet, LayerTypeLLC, LayerTypeSNAP, LayerTypeNortelDiscovery}
- checkLayers(p, wantLayers, t)
-
- want := &NortelDiscovery{
- IPAddress: []byte{172, 19, 88, 3},
- SegmentID: []byte{0x00, 0x04, 0x15},
- Chassis: NDPChassisBayStack450101001000Switches,
- Backplane: NDPBackplaneEthernetFastEthernetGigabitEthernet,
- State: NDPStateHeartbeat,
- NumLinks: 0,
- }
- ndpL := p.Layer(LayerTypeNortelDiscovery)
- info, _ := ndpL.(*NortelDiscovery)
- if !reflect.DeepEqual(info, want) {
- t.Errorf("Values mismatch, \ngot %#v\nwant %#v\n", info, want)
- }
-}
-
-func TestDecodeIPv6Jumbogram(t *testing.T) {
- // Haven't found any of these in the wild or on example pcaps online, so had
- // to generate one myself via scapy. Unfortunately, scapy can only
- // str(packet) for packets with length < 65536, due to limitations in python's
- // struct library, so I generated the header with:
- // Ether() / IPv6(src='::1', dst='::2') / IPv6ExtHdrHopByHop(options=[Jumbo(jumboplen=70000)]) / TCP(sport=8888, dport=80)
- // then added the payload manually ("payload" * 9996). The checksums here are
- // not correct, but we don't check, so who cares ;)
- dataStr := "\x00\x1f\xca\xb3v@$\xbe\x05'\x0b\x17\x86\xdd`\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x06\x00\xc2\x04\x00\x01\x11p\"\xb8\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00l\xd8\x00\x00"
- payload := strings.Repeat("payload", 9996)
- data := []byte(dataStr + payload)
- p := gopacket.NewPacket(data, LinkTypeEthernet, testDecodeOptions)
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeIPv6HopByHop, LayerTypeTCP, gopacket.LayerTypePayload}, t)
- if p.ApplicationLayer() == nil {
- t.Error("Packet has no application layer")
- } else if string(p.ApplicationLayer().Payload()) != payload {
- t.Errorf("Jumbogram payload wrong")
- }
- // Check truncated for jumbograms
- data = data[:len(data)-1]
- p = gopacket.NewPacket(data, LinkTypeEthernet, testDecodeOptions)
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeIPv6HopByHop, LayerTypeTCP, gopacket.LayerTypePayload}, t)
- if !p.Metadata().Truncated {
- t.Error("Jumbogram should be truncated")
- }
-}
-
-func TestDecodeUDPPacketTooSmall(t *testing.T) {
- data := []byte{
- 0x00, 0x15, 0x2c, 0x9d, 0xcc, 0x00, 0x00, 0x10, 0xdb, 0xff, 0x10, 0x00, 0x81, 0x00, 0x01, 0xf7,
- 0x08, 0x00, 0x45, 0x60, 0x00, 0x3c, 0x0f, 0xa9, 0x00, 0x00, 0x6e, 0x11, 0x01, 0x0a, 0x47, 0xe6,
- 0xee, 0x2e, 0xac, 0x16, 0x59, 0x73, 0x00, 0x50, 0x00, 0x50, 0x00, 0x28, 0x4d, 0xad, 0x00, 0x67,
- 0x00, 0x01, 0x00, 0x72, 0xd5, 0xc7, 0xf1, 0x07, 0x00, 0x00, 0x01, 0x01, 0x00, 0x0d, 0x00, 0x00,
- 0x00, 0x14, 0x00, 0x00, 0x19, 0xba,
- }
- p := gopacket.NewPacket(data, LinkTypeEthernet, testDecodeOptions)
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeDot1Q, LayerTypeIPv4, LayerTypeUDP, gopacket.LayerTypePayload}, t)
- if !p.Metadata().Truncated {
- t.Error("UDP short packet should be truncated")
- }
-}
-
-func TestDecodingLayerParserFullTCPPacket(t *testing.T) {
- dlp := gopacket.NewDecodingLayerParser(LayerTypeEthernet, &Ethernet{}, &IPv4{}, &TCP{}, &gopacket.Payload{})
- decoded := make([]gopacket.LayerType, 1)
- err := dlp.DecodeLayers(testSimpleTCPPacket, &decoded)
- if err != nil {
- t.Error("Error from dlp parser: ", err)
- }
- if len(decoded) != 4 {
- t.Error("Expected 4 layers parsed, instead got ", len(decoded))
- }
-}
-
-// testICMP is the packet:
-// 15:49:15.773265 IP 72.14.222.226 > 172.29.20.15: ICMP host 10.66.73.201 unreachable - admin prohibited filter, length 36
-// 0x0000: 24be 0527 0b17 001f cab3 75c0 0800 4500 $..'......u...E.
-// 0x0010: 0038 0000 0000 fc01 d7a7 480e dee2 ac1d .8........H.....
-// 0x0020: 140f 030d 946e 0000 0000 4520 004d 0000 .....n....E..M..
-// 0x0030: 4000 3e11 2849 ac1d 140f 0a42 49c9 8ecc @.>.(I.....BI...
-// 0x0040: 62e1 0039 769d b..9v.
-var testICMP = []byte{
- 0x24, 0xbe, 0x05, 0x27, 0x0b, 0x17, 0x00, 0x1f, 0xca, 0xb3, 0x75, 0xc0, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x01, 0xd7, 0xa7, 0x48, 0x0e, 0xde, 0xe2, 0xac, 0x1d,
- 0x14, 0x0f, 0x03, 0x0d, 0x94, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x45, 0x20, 0x00, 0x4d, 0x00, 0x00,
- 0x40, 0x00, 0x3e, 0x11, 0x28, 0x49, 0xac, 0x1d, 0x14, 0x0f, 0x0a, 0x42, 0x49, 0xc9, 0x8e, 0xcc,
- 0x62, 0xe1, 0x00, 0x39, 0x76, 0x9d,
-}
-
-func TestICMP(t *testing.T) {
- p := gopacket.NewPacket(testICMP, LinkTypeEthernet, testDecodeOptions)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeICMPv4, gopacket.LayerTypePayload}, t)
- testSerialization(t, p, testICMP)
-}
-func BenchmarkDecodeICMP(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testICMP, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-// testICMP6 is the packet:
-// 16:17:37.758937 IP6 fe80::21f:caff:feb3:75c0 > 2620:0:1005:0:26be:5ff:fe27:b17: ICMP6, neighbor solicitation, who has 2620:0:1005:0:26be:5ff:fe27:b17, length 32
-// 0x0000: 24be 0527 0b17 001f cab3 75c0 86dd 6e00 $..'......u...n.
-// 0x0010: 0000 0020 3aff fe80 0000 0000 0000 021f ....:...........
-// 0x0020: caff feb3 75c0 2620 0000 1005 0000 26be ....u.&.......&.
-// 0x0030: 05ff fe27 0b17 8700 1eba 0000 0000 2620 ...'..........&.
-// 0x0040: 0000 1005 0000 26be 05ff fe27 0b17 0101 ......&....'....
-// 0x0050: 001f cab3 75c0 ....u.
-var testICMP6 = []byte{
- 0x24, 0xbe, 0x05, 0x27, 0x0b, 0x17, 0x00, 0x1f, 0xca, 0xb3, 0x75, 0xc0, 0x86, 0xdd, 0x6e, 0x00,
- 0x00, 0x00, 0x00, 0x20, 0x3a, 0xff, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1f,
- 0xca, 0xff, 0xfe, 0xb3, 0x75, 0xc0, 0x26, 0x20, 0x00, 0x00, 0x10, 0x05, 0x00, 0x00, 0x26, 0xbe,
- 0x05, 0xff, 0xfe, 0x27, 0x0b, 0x17, 0x87, 0x00, 0x1e, 0xba, 0x00, 0x00, 0x00, 0x00, 0x26, 0x20,
- 0x00, 0x00, 0x10, 0x05, 0x00, 0x00, 0x26, 0xbe, 0x05, 0xff, 0xfe, 0x27, 0x0b, 0x17, 0x01, 0x01,
- 0x00, 0x1f, 0xca, 0xb3, 0x75, 0xc0,
-}
-
-func TestICMP6(t *testing.T) {
- p := gopacket.NewPacket(testICMP6, LinkTypeEthernet, testDecodeOptions)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeICMPv6, gopacket.LayerTypePayload}, t)
- testSerialization(t, p, testICMP6)
-}
-func BenchmarkDecodeICMP6(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testICMP6, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-// testMPLS is the packet:
-// 12:48:57.201014 MPLS (label 29, exp 0, [S], ttl 255) IP 10.1.2.1 > 10.34.0.1: ICMP echo request, id 2618, seq 1579, length 80
-// 0x0000: 0030 96e6 fc39 0030 9605 2838 8847 0001 .0...9.0..(8.G..
-// 0x0010: d1ff 4500 0064 000b 0000 ff01 a569 0a01 ..E..d.......i..
-// 0x0020: 0201 0a22 0001 0800 3a76 0a3a 062b 0000 ..."....:v.:.+..
-// 0x0030: 0000 001f 3350 abcd abcd abcd abcd abcd ....3P..........
-// 0x0040: abcd abcd abcd abcd abcd abcd abcd abcd ................
-// 0x0050: abcd abcd abcd abcd abcd abcd abcd abcd ................
-// 0x0060: abcd abcd abcd abcd abcd abcd abcd abcd ................
-// 0x0070: abcd abcd abcd ......
-var testMPLS = []byte{
- 0x00, 0x30, 0x96, 0xe6, 0xfc, 0x39, 0x00, 0x30, 0x96, 0x05, 0x28, 0x38, 0x88, 0x47, 0x00, 0x01,
- 0xd1, 0xff, 0x45, 0x00, 0x00, 0x64, 0x00, 0x0b, 0x00, 0x00, 0xff, 0x01, 0xa5, 0x69, 0x0a, 0x01,
- 0x02, 0x01, 0x0a, 0x22, 0x00, 0x01, 0x08, 0x00, 0x3a, 0x76, 0x0a, 0x3a, 0x06, 0x2b, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x1f, 0x33, 0x50, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
-}
-
-func TestMPLS(t *testing.T) {
- p := gopacket.NewPacket(testMPLS, LinkTypeEthernet, testDecodeOptions)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeMPLS, LayerTypeIPv4, LayerTypeICMPv4, gopacket.LayerTypePayload}, t)
- testSerialization(t, p, testMPLS)
-}
-func BenchmarkDecodeMPLS(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testMPLS, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-// testPPPoEICMPv6 is the packet:
-// 07:43:31.091560 PPPoE [ses 0x11] IP6 fe80::c801:eff:fe88:8 > ff02::1: ICMP6, neighbor advertisement, tgt is fe80::c801:eff:fe88:8, length 24
-// 0x0000: cc05 0e88 0000 ca01 0e88 0006 8864 1100 .............d..
-// 0x0010: 0011 0042 0057 6e00 0000 0018 3aff fe80 ...B.Wn.....:...
-// 0x0020: 0000 0000 0000 c801 0eff fe88 0008 ff02 ................
-// 0x0030: 0000 0000 0000 0000 0000 0000 0001 8800 ................
-// 0x0040: 5083 8000 0000 fe80 0000 0000 0000 c801 P...............
-// 0x0050: 0eff fe88 0008 ......
-var testPPPoEICMPv6 = []byte{
- 0xcc, 0x05, 0x0e, 0x88, 0x00, 0x00, 0xca, 0x01, 0x0e, 0x88, 0x00, 0x06, 0x88, 0x64, 0x11, 0x00,
- 0x00, 0x11, 0x00, 0x42, 0x00, 0x57, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3a, 0xff, 0xfe, 0x80,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x01, 0x0e, 0xff, 0xfe, 0x88, 0x00, 0x08, 0xff, 0x02,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x88, 0x00,
- 0x50, 0x83, 0x80, 0x00, 0x00, 0x00, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x01,
- 0x0e, 0xff, 0xfe, 0x88, 0x00, 0x08,
-}
-
-func TestPPPoEICMPv6(t *testing.T) {
- p := gopacket.NewPacket(testPPPoEICMPv6, LinkTypeEthernet, testDecodeOptions)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{
- LayerTypeEthernet,
- LayerTypePPPoE,
- LayerTypePPP,
- LayerTypeIPv6,
- LayerTypeICMPv6,
- gopacket.LayerTypePayload,
- }, t)
- testSerialization(t, p, testPPPoEICMPv6)
-}
-func BenchmarkDecodePPPoEICMPv6(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPPPoEICMPv6, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-var testPFLogUDP = []byte{
- 0x3d, 0x02, 0x00, 0x00, 0x65, 0x6e, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6f, 0x67, 0x67, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xae, 0xff, 0xff, 0xff, 0x7f,
- 0xa0, 0x86, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xb8, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x45, 0x00, 0x00, 0x2c, 0x02, 0x16, 0x00, 0x00, 0x40, 0x11, 0x4e, 0xb0, 0xac, 0x17, 0xe8, 0xcc,
- 0xac, 0x17, 0xe8, 0xff, 0xf0, 0xff, 0x21, 0xa4, 0x00, 0x18, 0x2a, 0x25, 0x50, 0x4e, 0x4a, 0x50,
- 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-}
-
-func TestPFLogUDP(t *testing.T) {
- p := gopacket.NewPacket(testPFLogUDP, LinkTypePFLog, testDecodeOptions)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{
- LayerTypePFLog,
- LayerTypeIPv4,
- LayerTypeUDP,
- gopacket.LayerTypePayload,
- }, t)
-}
-
-func TestRegressionDot1QPriority(t *testing.T) {
- d := &Dot1Q{
- Priority: 2,
- }
- out := gopacket.NewSerializeBuffer()
- gopacket.SerializeLayers(out, gopacket.SerializeOptions{}, d)
- if err := d.DecodeFromBytes(out.Bytes(), gopacket.NilDecodeFeedback); err != nil {
- t.Errorf("could not decode encoded dot1q")
- } else if d.Priority != 2 {
- t.Errorf("priority mismatch, want 2 got %d", d.Priority)
- }
-}
-
-// testPacketMPLSInMPLS is the packet:
-// 15:27:44.753678 MPLS (label 18, exp 0, ttl 255) (label 16, exp 0, [S], ttl
-// 255) IP 10.31.0.1 > 10.34.0.1: ICMP echo request, id 3941, seq 4768, length
-// 80
-// 0x0000: 0030 96e6 fc39 0030 9605 2838 8847 0001 .0...9.0..(8.G..
-// 0x0010: 20ff 0001 01ff 4500 0064 0050 0000 ff01 ......E..d.P....
-// 0x0020: a706 0a1f 0001 0a22 0001 0800 bd11 0f65 .......".......e
-// 0x0030: 12a0 0000 0000 0053 9ee0 abcd abcd abcd .......S........
-// 0x0040: abcd abcd abcd abcd abcd abcd abcd abcd ................
-// 0x0050: abcd abcd abcd abcd abcd abcd abcd abcd ................
-// 0x0060: abcd abcd abcd abcd abcd abcd abcd abcd ................
-// 0x0070: abcd abcd abcd abcd abcd ..........
-var testPacketMPLSInMPLS = []byte{
- 0x00, 0x30, 0x96, 0xe6, 0xfc, 0x39, 0x00, 0x30, 0x96, 0x05, 0x28, 0x38, 0x88, 0x47, 0x00, 0x01,
- 0x20, 0xff, 0x00, 0x01, 0x01, 0xff, 0x45, 0x00, 0x00, 0x64, 0x00, 0x50, 0x00, 0x00, 0xff, 0x01,
- 0xa7, 0x06, 0x0a, 0x1f, 0x00, 0x01, 0x0a, 0x22, 0x00, 0x01, 0x08, 0x00, 0xbd, 0x11, 0x0f, 0x65,
- 0x12, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x9e, 0xe0, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
-}
-
-func TestPacketMPLSInMPLS(t *testing.T) {
- p := gopacket.NewPacket(testPacketMPLSInMPLS, LinkTypeEthernet, testDecodeOptions)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{
- LayerTypeEthernet,
- LayerTypeMPLS,
- LayerTypeMPLS,
- LayerTypeIPv4,
- LayerTypeICMPv4,
- gopacket.LayerTypePayload}, t)
-}
-
-// testPacketIPv4Fragmented is the packet:
-// 22:11:26.616090 IP 10.1.1.1.31915 > 129.111.30.27.20197: UDP, length 28
-// 0x0000: 0000 39cf d9cd 0040 33d9 7cfd 0800 4500 ..9....@3.|...E.
-// 0x0010: 0038 00f2 2000 4011 af37 0a01 0101 816f .8....@..7.....o
-// 0x0020: 1e1b 7cab 4ee5 0024 0000 0000 0000 0000 ..|.N..$........
-// 0x0030: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-// 0x0040: 0000 0000 0000 ......
-var testPacketIPv4Fragmented = []byte{
- 0x00, 0x00, 0x39, 0xcf, 0xd9, 0xcd, 0x00, 0x40, 0x33, 0xd9, 0x7c, 0xfd, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x38, 0x00, 0xf2, 0x20, 0x00, 0x40, 0x11, 0xaf, 0x37, 0x0a, 0x01, 0x01, 0x01, 0x81, 0x6f,
- 0x1e, 0x1b, 0x7c, 0xab, 0x4e, 0xe5, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-}
-
-func TestPacketIPv4Fragmented(t *testing.T) {
- p := gopacket.NewPacket(testPacketIPv4Fragmented, LinkTypeEthernet, testDecodeOptions)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, gopacket.LayerTypeFragment}, t)
- testSerializationWithOpts(t, p, testPacketIPv4Fragmented, gopacket.SerializeOptions{FixLengths: true, ComputeChecksums: true})
-}
-
-// TestSCTPChunkBadLength tests for issue #146
-func TestSCTPChunkBadLength(t *testing.T) {
- data := []byte(
- "0000\xad9$e\x11\xe4\xaeo\b\x00E\x00\x018\xb4\xa3" +
- "\x00\x00Y\x84\xc4@\x11gz\xc0\xa8\xee\x01\xc0\xa8" +
- "\xeeD\x007le\x03\x01\xc0\f\xdf\b\x01\x00\x00")
-
- // this panic'd previously due to a zero length chunk getting
- // repeatedly read
- gopacket.NewPacket(data, LinkTypeEthernet, gopacket.Default)
-}
-
-// TestSTP
-func TestSTP(t *testing.T) {
- testSTPpacket := []byte{
- 0x01, 0x80, 0xC2, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x0E, 0x87, 0x85, 0x04, 0x00, 0x26, 0x42, 0x42,
- 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x64, 0x00, 0x1C, 0x0E, 0x87, 0x78, 0x00, 0x00, 0x00,
- 0x00, 0x04, 0x80, 0x64, 0x00, 0x1C, 0x0E, 0x87, 0x85, 0x00, 0x80, 0x04, 0x01, 0x00, 0x14, 0x00,
- 0x02, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- }
- p := gopacket.NewPacket(testSTPpacket, LinkTypeEthernet, testDecodeOptions)
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeLLC, LayerTypeSTP}, t)
-}
diff --git a/vendor/github.com/google/gopacket/layers/dhcp_test.go b/vendor/github.com/google/gopacket/layers/dhcp_test.go
deleted file mode 100644
index c4975dc..0000000
--- a/vendor/github.com/google/gopacket/layers/dhcp_test.go
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright 2016, Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "bytes"
- "net"
- "testing"
-
- "github.com/google/gopacket"
-)
-
-func TestDHCPv4EncodeRequest(t *testing.T) {
- dhcp := &DHCPv4{Operation: DHCPOpRequest, HardwareType: LinkTypeEthernet, Xid: 0x12345678,
- ClientIP: net.IP{0, 0, 0, 0}, YourClientIP: net.IP{0, 0, 0, 0}, NextServerIP: net.IP{0, 0, 0, 0}, RelayAgentIP: net.IP{0, 0, 0, 0},
- ClientHWAddr: net.HardwareAddr{0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc},
- ServerName: make([]byte, 64), File: make([]byte, 128)}
-
- dhcp.Options = append(dhcp.Options, NewDHCPOption(DHCPOptMessageType, []byte{byte(DHCPMsgTypeDiscover)}))
- dhcp.Options = append(dhcp.Options, NewDHCPOption(DHCPOptHostname, []byte{'e', 'x', 'a', 'm', 'p', 'l', 'e', '.', 'c', 'o', 'm'}))
- dhcp.Options = append(dhcp.Options, NewDHCPOption(DHCPOptPad, nil))
- dhcp.Options = append(dhcp.Options, NewDHCPOption(DHCPOptParamsRequest,
- []byte{byte(DHCPOptSubnetMask), byte(DHCPOptBroadcastAddr), byte(DHCPOptTimeOffset),
- byte(DHCPOptRouter), byte(DHCPOptDomainName), byte(DHCPOptDNS), byte(DHCPOptDomainSearch),
- byte(DHCPOptHostname), byte(DHCPOptNetBIOSTCPNS), byte(DHCPOptInterfaceMTU), byte(DHCPOptClasslessStaticRoute),
- byte(DHCPOptNTPServers)}))
-
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{FixLengths: true}
- err := gopacket.SerializeLayers(buf, opts, dhcp)
- if err != nil {
- t.Fatal(err)
- }
-
- p2 := gopacket.NewPacket(buf.Bytes(), LayerTypeDHCPv4, testDecodeOptions)
- dhcp2 := p2.Layer(LayerTypeDHCPv4).(*DHCPv4)
- testDHCPEqual(t, dhcp, dhcp2)
-}
-
-func TestDHCPv4EncodeResponse(t *testing.T) {
- dhcp := &DHCPv4{Operation: DHCPOpReply, HardwareType: LinkTypeEthernet, Xid: 0x12345678,
- ClientIP: net.IP{0, 0, 0, 0}, YourClientIP: net.IP{192, 168, 0, 123}, NextServerIP: net.IP{192, 168, 0, 1}, RelayAgentIP: net.IP{0, 0, 0, 0},
- ClientHWAddr: net.HardwareAddr{0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc},
- ServerName: make([]byte, 64), File: make([]byte, 128)}
-
- dhcp.Options = append(dhcp.Options, NewDHCPOption(DHCPOptMessageType, []byte{byte(DHCPMsgTypeOffer)}))
- dhcp.Options = append(dhcp.Options, NewDHCPOption(DHCPOptSubnetMask, []byte{255, 255, 255, 0}))
- dhcp.Options = append(dhcp.Options, NewDHCPOption(DHCPOptPad, nil))
- dhcp.Options = append(dhcp.Options, NewDHCPOption(DHCPOptT1, []byte{0x00, 0x00, 0x0e, 0x10}))
- dhcp.Options = append(dhcp.Options, NewDHCPOption(DHCPOptT2, []byte{0x00, 0x00, 0x0e, 0x10}))
- dhcp.Options = append(dhcp.Options, NewDHCPOption(DHCPOptLeaseTime, []byte{0x00, 0x00, 0x0e, 0x10}))
- dhcp.Options = append(dhcp.Options, NewDHCPOption(DHCPOptServerID, []byte{192, 168, 0, 1}))
-
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{FixLengths: true}
- err := gopacket.SerializeLayers(buf, opts, dhcp)
- if err != nil {
- t.Fatal(err)
- }
-
- p2 := gopacket.NewPacket(buf.Bytes(), LayerTypeDHCPv4, testDecodeOptions)
- dhcp2 := p2.Layer(LayerTypeDHCPv4).(*DHCPv4)
- testDHCPEqual(t, dhcp, dhcp2)
-}
-
-func testDHCPEqual(t *testing.T, d1, d2 *DHCPv4) {
- if d1.Operation != d2.Operation {
- t.Errorf("expected Operation=%s, got %s", d1.Operation, d2.Operation)
- }
- if d1.HardwareType != d2.HardwareType {
- t.Errorf("expected HardwareType=%s, got %s", d1.HardwareType, d2.HardwareType)
- }
- if d1.HardwareLen != d2.HardwareLen {
- t.Errorf("expected HardwareLen=%v, got %v", d1.HardwareLen, d2.HardwareLen)
- }
- if d1.HardwareOpts != d2.HardwareOpts {
- t.Errorf("expected HardwareOpts=%v, got %v", d1.HardwareOpts, d2.HardwareOpts)
- }
- if d1.Xid != d2.Xid {
- t.Errorf("expected Xid=%v, got %v", d1.Xid, d2.Xid)
- }
- if d1.Secs != d2.Secs {
- t.Errorf("expected Secs=%v, got %v", d1.Secs, d2.Secs)
- }
- if d1.Flags != d2.Flags {
- t.Errorf("expected Flags=%v, got %v", d1.Flags, d2.Flags)
- }
- if !d1.ClientIP.Equal(d2.ClientIP) {
- t.Errorf("expected ClientIP=%v, got %v", d1.ClientIP, d2.ClientIP)
- }
- if !d1.YourClientIP.Equal(d2.YourClientIP) {
- t.Errorf("expected YourClientIP=%v, got %v", d1.YourClientIP, d2.YourClientIP)
- }
- if !d1.NextServerIP.Equal(d2.NextServerIP) {
- t.Errorf("expected NextServerIP=%v, got %v", d1.NextServerIP, d2.NextServerIP)
- }
- if !d1.RelayAgentIP.Equal(d2.RelayAgentIP) {
- t.Errorf("expected RelayAgentIP=%v, got %v", d1.RelayAgentIP, d2.RelayAgentIP)
- }
- if !bytes.Equal(d1.ClientHWAddr, d2.ClientHWAddr) {
- t.Errorf("expected ClientHWAddr=%v, got %v", d1.ClientHWAddr, d2.ClientHWAddr)
- }
- if !bytes.Equal(d1.ServerName, d2.ServerName) {
- t.Errorf("expected ServerName=%v, got %v", d1.ServerName, d2.ServerName)
- }
- if !bytes.Equal(d1.File, d2.File) {
- t.Errorf("expected File=%v, got %v", d1.File, d2.File)
- }
- if len(d1.Options) != len(d2.Options) {
- t.Errorf("expected %d options, got %d", len(d1.Options), len(d2.Options))
- }
-
- for i, o := range d1.Options {
- testDHCPOptionEqual(t, i, o, d2.Options[i])
- }
-}
-
-func testDHCPOptionEqual(t *testing.T, idx int, d1, d2 DHCPOption) {
- if d1.Type != d2.Type {
- t.Errorf("expection Options[%d].Type = %s, got %s", idx, d1.Type, d2.Type)
- }
- if !bytes.Equal(d1.Data, d2.Data) {
- t.Errorf("expection Options[%d].Data to be = %v, got %v", idx, d1.Data, d2.Data)
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/dns_test.go b/vendor/github.com/google/gopacket/layers/dns_test.go
deleted file mode 100644
index 264513b..0000000
--- a/vendor/github.com/google/gopacket/layers/dns_test.go
+++ /dev/null
@@ -1,833 +0,0 @@
-// Copyright 2012, Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "bytes"
- "net"
- "strings"
- "testing"
-
- "github.com/google/gopacket"
-)
-
-// testPacketDNSRegression is the packet:
-// 11:08:05.708342 IP 109.194.160.4.57766 > 95.211.92.14.53: 63000% [1au] A? picslife.ru. (40)
-// 0x0000: 0022 19b6 7e22 000f 35bb 0b40 0800 4500 ."..~"..5..@..E.
-// 0x0010: 0044 89c4 0000 3811 2f3d 6dc2 a004 5fd3 .D....8./=m..._.
-// 0x0020: 5c0e e1a6 0035 0030 a597 f618 0010 0001 \....5.0........
-// 0x0030: 0000 0000 0001 0870 6963 736c 6966 6502 .......picslife.
-// 0x0040: 7275 0000 0100 0100 0029 1000 0000 8000 ru.......)......
-// 0x0050: 0000 ..
-var testPacketDNSRegression = []byte{
- 0x00, 0x22, 0x19, 0xb6, 0x7e, 0x22, 0x00, 0x0f, 0x35, 0xbb, 0x0b, 0x40, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x44, 0x89, 0xc4, 0x00, 0x00, 0x38, 0x11, 0x2f, 0x3d, 0x6d, 0xc2, 0xa0, 0x04, 0x5f, 0xd3,
- 0x5c, 0x0e, 0xe1, 0xa6, 0x00, 0x35, 0x00, 0x30, 0xa5, 0x97, 0xf6, 0x18, 0x00, 0x10, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x70, 0x69, 0x63, 0x73, 0x6c, 0x69, 0x66, 0x65, 0x02,
- 0x72, 0x75, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x80, 0x00,
- 0x00, 0x00,
-}
-
-func TestPacketDNSRegression(t *testing.T) {
- p := gopacket.NewPacket(testPacketDNSRegression, LinkTypeEthernet, testDecodeOptions)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeUDP, LayerTypeDNS}, t)
-}
-func BenchmarkDecodePacketDNSRegression(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketDNSRegression, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-// response to `dig TXT google.com` over IPv4 link:
-var testParseDNSTypeTXTValue = `v=spf1 include:_spf.google.com ~all`
-var testParseDNSTypeTXT = []byte{
- 0x02, 0x00, 0x00, 0x00, // PF_INET
- 0x45, 0x00, 0x00, 0x73, 0x00, 0x00, 0x40, 0x00, 0x39, 0x11, 0x64, 0x98, 0xd0, 0x43, 0xde, 0xde,
- 0x0a, 0xba, 0x23, 0x06, 0x00, 0x35, 0x81, 0xb2, 0x00, 0x5f, 0xdc, 0xb5, 0x98, 0x71, 0x81, 0x80,
- 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03,
- 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x10, 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00,
- 0x0e, 0x10, 0x00, 0x24, 0x23, 0x76, 0x3d, 0x73, 0x70, 0x66, 0x31, 0x20, 0x69, 0x6e, 0x63, 0x6c,
- 0x75, 0x64, 0x65, 0x3a, 0x5f, 0x73, 0x70, 0x66, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
- 0x63, 0x6f, 0x6d, 0x20, 0x7e, 0x61, 0x6c, 0x6c, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
-}
-
-func TestParseDNSTypeTXT(t *testing.T) {
- p := gopacket.NewPacket(testParseDNSTypeTXT, LinkTypeNull, testDecodeOptions)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeLoopback, LayerTypeIPv4, LayerTypeUDP, LayerTypeDNS}, t)
- answers := p.Layer(LayerTypeDNS).(*DNS).Answers
- if len(answers) != 1 {
- t.Error("Failed to parse 1 DNS answer")
- }
- if len(answers[0].TXTs) != 1 {
- t.Error("Failed to parse 1 TXT record")
- }
- txt := string(answers[0].TXTs[0])
- if txt != testParseDNSTypeTXTValue {
- t.Errorf("Incorrect TXT value, expected %q, got %q", testParseDNSTypeTXTValue, txt)
- }
-}
-
-func testQuestionEqual(t *testing.T, i int, exp, got DNSQuestion) {
- if !bytes.Equal(exp.Name, got.Name) {
- t.Errorf("expected Questions[%d].Name = %v, got %v", i, string(exp.Name), string(got.Name))
- }
- if exp.Type != got.Type {
- t.Errorf("expected Questions[%d].Type = %v, got %v", i, exp.Type, got.Type)
- }
- if exp.Class != got.Class {
- t.Errorf("expected Questions[%d].Class = %v, got %v", i, exp.Class, got.Class)
- }
-}
-
-func testResourceEqual(t *testing.T, i int, name string, exp, got DNSResourceRecord) {
- if !bytes.Equal(exp.Name, got.Name) {
- t.Errorf("expected %s[%d].Name = %v, got %v", name, i, string(exp.Name), string(got.Name))
- }
-
- if exp.Type != got.Type {
- t.Errorf("expected %s[%d].Type = %v, got %v", name, i, exp.Type, got.Type)
- }
-
- if exp.Class != got.Class {
- t.Errorf("expected %s[%d].Class = %v, got %v", name, i, exp.Class, got.Class)
- }
-
- if exp.TTL != got.TTL {
- t.Errorf("expected %s[%d].TTL = %v, got %v", name, i, exp.TTL, got.TTL)
- }
- if exp.DataLength != got.DataLength {
- t.Errorf("expected %s[%d].DataLength = %v, got %v", name, i, exp.DataLength, got.DataLength)
- }
-
- // we don't check .Data
-
- if !exp.IP.Equal(got.IP) {
- t.Errorf("expected %s[%d].IP = %v, got %v", name, i, exp.IP, got.IP)
- }
- if !bytes.Equal(exp.NS, got.NS) {
- t.Errorf("expected %s[%d].NS = %v, got %v", name, i, exp.NS, got.NS)
- }
- if !bytes.Equal(exp.CNAME, got.CNAME) {
- t.Errorf("expected %s[%d].CNAME = %v, got %v", name, i, exp.CNAME, got.CNAME)
- }
- if !bytes.Equal(exp.PTR, got.PTR) {
- t.Errorf("expected %s[%d].PTR = %v, got %v", name, i, exp.PTR, got.PTR)
- }
- if len(exp.TXTs) != len(got.TXTs) {
- t.Errorf("expected %s[%d].TXTs = %v, got %v", name, i, exp.TXTs, got.TXTs)
- }
- for j := range exp.TXTs {
- if !bytes.Equal(exp.TXTs[j], got.TXTs[j]) {
- t.Errorf("expected %s[%d].TXTs[%d] = %v, got %v", name, i, j, exp.TXTs[j], got.TXTs[j])
- }
- }
-
- // SOA
- if !bytes.Equal(exp.SOA.MName, got.SOA.MName) {
- t.Errorf("expected %s[%d].SOA.MName = %v, got %v", name, i, exp.SOA.MName, got.SOA.MName)
- }
- if !bytes.Equal(exp.SOA.RName, got.SOA.RName) {
- t.Errorf("expected %s[%d].SOA.RName = %v, got %v", name, i, exp.SOA.RName, got.SOA.RName)
- }
- if exp.SOA.Serial != got.SOA.Serial {
- t.Errorf("expected %s[%d].SOA.Serial = %v, got %v", name, i, exp.SOA.Serial, got.SOA.Serial)
- }
- if exp.SOA.Refresh != got.SOA.Refresh {
- t.Errorf("expected %s[%d].SOA.Refresh = %v, got %v", name, i, exp.SOA.Refresh, got.SOA.Refresh)
- }
- if exp.SOA.Retry != got.SOA.Retry {
- t.Errorf("expected %s[%d].SOA.Retry = %v, got %v", name, i, exp.SOA.Retry, got.SOA.Retry)
- }
- if exp.SOA.Expire != got.SOA.Expire {
- t.Errorf("expected %s[%d].SOA.Expire = %v, got %v", name, i, exp.SOA.Expire, got.SOA.Expire)
- }
- if exp.SOA.Minimum != got.SOA.Minimum {
- t.Errorf("expected %s[%d].SOA.Minimum = %v, got %v", name, i, exp.SOA.Minimum, got.SOA.Minimum)
- }
-
- // SRV
- if !bytes.Equal(exp.SRV.Name, got.SRV.Name) {
- t.Errorf("expected %s[%d].SRV.Name = %v, got %v", name, i, exp.SRV.Name, got.SRV.Name)
- }
- if exp.SRV.Weight != got.SRV.Weight {
- t.Errorf("expected %s[%d].SRV.Weight = %v, got %v", name, i, exp.SRV.Weight, got.SRV.Weight)
- }
- if exp.SRV.Port != got.SRV.Port {
- t.Errorf("expected %s[%d].SRV.Port = %v, got %v", name, i, exp.SRV.Port, got.SRV.Port)
- }
- // MX
- if !bytes.Equal(exp.MX.Name, got.MX.Name) {
- t.Errorf("expected %s[%d].MX.Name = %v, got %v", name, i, exp.MX.Name, got.MX.Name)
- }
- if exp.MX.Preference != got.MX.Preference {
- t.Errorf("expected %s[%d].MX.Preference = %v, got %v", name, i, exp.MX.Preference, got.MX.Preference)
- }
-}
-
-func testDNSEqual(t *testing.T, exp, got *DNS) {
- if exp.ID != got.ID {
- t.Errorf("expected ID = %v, got %v", exp.ID, got.ID)
- }
- if exp.AA != got.AA {
- t.Errorf("expected AA = %v, got %v", exp.AA, got.AA)
- }
- if exp.OpCode != got.OpCode {
- t.Errorf("expected OpCode = %v, got %v", exp.OpCode, got.OpCode)
- }
- if exp.AA != got.AA {
- t.Errorf("expected AA = %v, got %v", exp.AA, got.AA)
- }
- if exp.TC != got.TC {
- t.Errorf("expected TC = %v, got %v", exp.TC, got.TC)
- }
- if exp.RD != got.RD {
- t.Errorf("expected RD = %v, got %v", exp.RD, got.RD)
- }
- if exp.RA != got.RA {
- t.Errorf("expected RA = %v, got %v", exp.RA, got.RA)
- }
- if exp.Z != got.Z {
- t.Errorf("expected Z = %v, got %v", exp.Z, got.Z)
- }
- if exp.ResponseCode != got.ResponseCode {
- t.Errorf("expected ResponseCode = %v, got %v", exp.ResponseCode, got.ResponseCode)
- }
- if exp.QDCount != got.QDCount {
- t.Errorf("expected QDCount = %v, got %v", exp.QDCount, got.QDCount)
- }
- if exp.ANCount != got.ANCount {
- t.Errorf("expected ANCount = %v, got %v", exp.ANCount, got.ANCount)
- }
- if exp.ANCount != got.ANCount {
- t.Errorf("expected ANCount = %v, got %v", exp.ANCount, got.ANCount)
- }
- if exp.NSCount != got.NSCount {
- t.Errorf("expected NSCount = %v, got %v", exp.NSCount, got.NSCount)
- }
- if exp.ARCount != got.ARCount {
- t.Errorf("expected ARCount = %v, got %v", exp.ARCount, got.ARCount)
- }
-
- if len(exp.Questions) != len(got.Questions) {
- t.Errorf("expected %d Questions, got %d", len(exp.Questions), len(got.Questions))
- }
- for i := range exp.Questions {
- testQuestionEqual(t, i, exp.Questions[i], got.Questions[i])
- }
-
- if len(exp.Answers) != len(got.Answers) {
- t.Errorf("expected %d Answers, got %d", len(exp.Answers), len(got.Answers))
- }
- for i := range exp.Answers {
- testResourceEqual(t, i, "Answers", exp.Answers[i], got.Answers[i])
- }
-
- if len(exp.Authorities) != len(got.Authorities) {
- t.Errorf("expected %d Answers, got %d", len(exp.Authorities), len(got.Authorities))
- }
- for i := range exp.Authorities {
- testResourceEqual(t, i, "Authorities", exp.Authorities[i], got.Authorities[i])
- }
-
- if len(exp.Additionals) != len(got.Additionals) {
- t.Errorf("expected %d Additionals, got %d", len(exp.Additionals), len(got.Additionals))
- }
- for i := range exp.Additionals {
- testResourceEqual(t, i, "Additionals", exp.Additionals[i], got.Additionals[i])
- }
-}
-
-func TestDNSEncodeQuery(t *testing.T) {
- dns := &DNS{ID: 1234, OpCode: DNSOpCodeQuery, RD: true}
- dns.Questions = append(dns.Questions,
- DNSQuestion{
- Name: []byte("example1.com"),
- Type: DNSTypeA,
- Class: DNSClassIN,
- })
-
- dns.Questions = append(dns.Questions,
- DNSQuestion{
- Name: []byte("example2.com"),
- Type: DNSTypeA,
- Class: DNSClassIN,
- })
-
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{FixLengths: true}
- err := gopacket.SerializeLayers(buf, opts, dns)
- if err != nil {
- t.Fatal(err)
- }
- if int(dns.QDCount) != len(dns.Questions) {
- t.Errorf("fix lengths did not adjust QDCount, expected %d got %d", len(dns.Questions), dns.QDCount)
- }
-
- p2 := gopacket.NewPacket(buf.Bytes(), LayerTypeDNS, testDecodeOptions)
- dns2 := p2.Layer(LayerTypeDNS).(*DNS)
- testDNSEqual(t, dns, dns2)
-}
-
-func TestDNSEncodeResponse(t *testing.T) {
- dns := &DNS{ID: 1234, QR: true, OpCode: DNSOpCodeQuery,
- AA: true, RD: true, RA: true}
- dns.Questions = append(dns.Questions,
- DNSQuestion{
- Name: []byte("example1.com"),
- Type: DNSTypeA,
- Class: DNSClassIN,
- })
- dns.Questions = append(dns.Questions,
- DNSQuestion{
- Name: []byte("www.example2.com"),
- Type: DNSTypeAAAA,
- Class: DNSClassIN,
- })
-
- dns.Answers = append(dns.Answers,
- DNSResourceRecord{
- Name: []byte("example1.com"),
- Type: DNSTypeA,
- Class: DNSClassIN,
- TTL: 1024,
- IP: net.IP([]byte{1, 2, 3, 4}),
- })
-
- dns.Answers = append(dns.Answers,
- DNSResourceRecord{
- Name: []byte("www.example2.com"),
- Type: DNSTypeAAAA,
- Class: DNSClassIN,
- TTL: 1024,
- IP: net.IP([]byte{5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4}),
- })
-
- dns.Answers = append(dns.Answers,
- DNSResourceRecord{
- Name: []byte("www.example2.com"),
- Type: DNSTypeCNAME,
- Class: DNSClassIN,
- TTL: 1024,
- CNAME: []byte("example2.com"),
- })
-
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{FixLengths: true}
- err := gopacket.SerializeLayers(buf, opts, dns)
- if err != nil {
- t.Fatal(err)
- }
- if int(dns.ANCount) != len(dns.Answers) {
- t.Errorf("fix lengths did not adjust ANCount, expected %d got %d", len(dns.Answers), dns.ANCount)
- }
- for i, a := range dns.Answers {
- if a.DataLength == 0 {
- t.Errorf("fix lengths did not adjust Answers[%d].DataLength", i)
- }
- }
-
- p2 := gopacket.NewPacket(buf.Bytes(), LayerTypeDNS, testDecodeOptions)
- dns2 := p2.Layer(LayerTypeDNS).(*DNS)
- testDNSEqual(t, dns, dns2)
-}
-
-// testDNSMalformedPacket is the packet:
-// 10:30:00.389666 IP 10.77.43.131.60718 > 10.1.0.17.53: 18245 updateD [b2&3=0x5420] [18516a] [12064q] [21584n] [12081au][|domain]
-// 0x0000: 0000 0101 0000 4e96 1476 afa1 0800 4500 ......N..v....E.
-// 0x0010: 0039 d431 0000 f311 b3a0 0a4d 2b83 0a01 .9.1.......M+...
-// 0x0020: 0011 ed2e 0035 0025 0832 4745 5420 2f20 .....5.%.2GET./.
-// 0x0030: 4854 5450 2f31 2e31 0d0a 486f 7374 3a20 HTTP/1.1..Host:.
-// 0x0040: 7777 770d 0a0d 0a www....
-var testDNSMalformedPacket = []byte{
- 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x4e, 0x96, 0x14, 0x76, 0xaf, 0xa1, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x39, 0xd4, 0x31, 0x00, 0x00, 0xf3, 0x11, 0xb3, 0xa0, 0x0a, 0x4d, 0x2b, 0x83, 0x0a, 0x01,
- 0x00, 0x11, 0xed, 0x2e, 0x00, 0x35, 0x00, 0x25, 0x08, 0x32, 0x47, 0x45, 0x54, 0x20, 0x2f, 0x20,
- 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x0d, 0x0a, 0x48, 0x6f, 0x73, 0x74, 0x3a, 0x20,
- 0x77, 0x77, 0x77, 0x0d, 0x0a, 0x0d, 0x0a,
-}
-
-func TestDNSMalformedPacket(t *testing.T) {
- p := gopacket.NewPacket(testDNSMalformedPacket, LinkTypeEthernet, testDecodeOptions)
- if errLayer := p.ErrorLayer(); errLayer == nil {
- t.Error("No error layer on invalid DNS name")
- } else if err := errLayer.Error(); !strings.Contains(err.Error(), "invalid index") {
- t.Errorf("unexpected error message: %v", err)
- }
-}
-
-// testDNSMalformedPacket2 is the packet:
-// 15:14:42.056054 IP 10.77.0.245.53 > 10.1.0.45.38769: 12625 zoneInit YXRRSet- [49833q],[|domain]
-// 0x0000: 0055 22af c637 0022 55ac deac 0800 4500 .U"..7."U.....E.
-// 0x0010: 0079 3767 4000 3911 f49d 0a4d 00f5 0a01 .y7g@.9....M....
-// 0x0020: 002d 0035 9771 0065 6377 3151 f057 c2a9 .-.5.q.ecw1Q.W..
-// 0x0030: fc6e e86a beb0 f7d4 8599 373e b5f8 9db2 .n.j......7>....
-// 0x0040: a399 21a1 9762 def1 def4 f5ab 5675 023e ..!..b......Vu.>
-// 0x0050: c9ca 304f 178a c2ad f2fc 677a 0e4c b892 ..0O......gz.L..
-// 0x0060: ab71 09bb 1ea4 f7c4 fe47 7a39 868b 29a0 .q.......Gz9..).
-// 0x0070: 62c4 d184 5b4e 8817 4cc0 d1d0 d430 11d3 b...[N..L....0..
-// 0x0080: d147 543f afc7 1a .GT?...
-var testDNSMalformedPacket2 = []byte{
- 0x00, 0x55, 0x22, 0xaf, 0xc6, 0x37, 0x00, 0x22, 0x55, 0xac, 0xde, 0xac, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x79, 0x37, 0x67, 0x40, 0x00, 0x39, 0x11, 0xf4, 0x9d, 0x0a, 0x4d, 0x00, 0xf5, 0x0a, 0x01,
- 0x00, 0x2d, 0x00, 0x35, 0x97, 0x71, 0x00, 0x65, 0x63, 0x77, 0x31, 0x51, 0xf0, 0x57, 0xc2, 0xa9,
- 0xfc, 0x6e, 0xe8, 0x6a, 0xbe, 0xb0, 0xf7, 0xd4, 0x85, 0x99, 0x37, 0x3e, 0xb5, 0xf8, 0x9d, 0xb2,
- 0xa3, 0x99, 0x21, 0xa1, 0x97, 0x62, 0xde, 0xf1, 0xde, 0xf4, 0xf5, 0xab, 0x56, 0x75, 0x02, 0x3e,
- 0xc9, 0xca, 0x30, 0x4f, 0x17, 0x8a, 0xc2, 0xad, 0xf2, 0xfc, 0x67, 0x7a, 0x0e, 0x4c, 0xb8, 0x92,
- 0xab, 0x71, 0x09, 0xbb, 0x1e, 0xa4, 0xf7, 0xc4, 0xfe, 0x47, 0x7a, 0x39, 0x86, 0x8b, 0x29, 0xa0,
- 0x62, 0xc4, 0xd1, 0x84, 0x5b, 0x4e, 0x88, 0x17, 0x4c, 0xc0, 0xd1, 0xd0, 0xd4, 0x30, 0x11, 0xd3,
- 0xd1, 0x47, 0x54, 0x3f, 0xaf, 0xc7, 0x1a,
-}
-
-func TestDNSMalformedPacket2(t *testing.T) {
- p := gopacket.NewPacket(testDNSMalformedPacket2, LinkTypeEthernet, testDecodeOptions)
- if errLayer := p.ErrorLayer(); errLayer == nil {
- t.Error("No error layer on invalid DNS name")
- } else if err := errLayer.Error(); !strings.Contains(err.Error(), "offset pointer too high") {
- t.Errorf("unexpected error message: %v", err)
- }
-}
-
-// testMalformedRootQuery is the packet:
-// 08:31:18.143065 IP 10.77.0.26.53 > 10.1.0.233.65071: 59508- 0/13/3 (508)
-// 0x0000: 0055 22af c637 0022 55ac deac 0800 4500 .U"..7."U.....E.
-// 0x0010: 0218 76b2 4000 7211 7ad2 0a4d 001a 0a01 ..v.@.r.z..M....
-// 0x0020: 00e9 0035 fe2f 0204 b8f5 e874 8100 0001 ...5./.....t....
-// 0x0030: 0000 000d 0003 0c61 786b 7663 6863 7063 .......axkvchcpc
-// 0x0040: 7073 6c0a 7878 7878 7878 7878 7878 036e psl.xxxxxxxxxx.n
-// 0x0050: 6574 0000 0100 0100 0002 0001 0000 0e10 et..............
-// 0x0060: 0014 016d 0c72 6f6f 742d 7365 7276 6572 ...m.root-server
-// 0x0070: 7303 6e65 7400 c02d 0002 0001 0000 0e10 s.net..-........
-// 0x0080: 0014 0161 0c72 6f6f 742d 7365 7276 6572 ...a.root-server
-// 0x0090: 7303 6e65 7400 c02d 0002 0001 0000 0e10 s.net..-........
-// 0x00a0: 0014 0169 0c72 6f6f 742d 7365 7276 6572 ...i.root-server
-// 0x00b0: 7303 6e65 7400 c02d 0002 0001 0000 0e10 s.net..-........
-// 0x00c0: 0014 0162 0c72 6f6f 742d 7365 7276 6572 ...b.root-server
-// 0x00d0: 7303 6e65 7400 c02d 0002 0001 0000 0e10 s.net..-........
-// 0x00e0: 0014 016c 0c72 6f6f 742d 7365 7276 6572 ...l.root-server
-// 0x00f0: 7303 6e65 7400 c02d 0002 0001 0000 0e10 s.net..-........
-// 0x0100: 0014 0166 0c72 6f6f 742d 7365 7276 6572 ...f.root-server
-// 0x0110: 7303 6e65 7400 c02d 0002 0001 0000 0e10 s.net..-........
-// 0x0120: 0014 0167 0c72 6f6f 742d 7365 7276 6572 ...g.root-server
-// 0x0130: 7303 6e65 7400 c02d 0002 0001 0000 0e10 s.net..-........
-// 0x0140: 0014 0164 0c72 6f6f 742d 7365 7276 6572 ...d.root-server
-// 0x0150: 7303 6e65 7400 c02d 0002 0001 0000 0e10 s.net..-........
-// 0x0160: 0014 0168 0c72 6f6f 742d 7365 7276 6572 ...h.root-server
-// 0x0170: 7303 6e65 7400 c02d 0002 0001 0000 0e10 s.net..-........
-// 0x0180: 0014 0165 0c72 6f6f 742d 7365 7276 6572 ...e.root-server
-// 0x0190: 7303 6e65 7400 c02d 0002 0001 0000 0e10 s.net..-........
-// 0x01a0: 0014 016a 0c72 6f6f 742d 7365 7276 6572 ...j.root-server
-// 0x01b0: 7303 6e65 7400 c02d 0002 0001 0000 0e10 s.net..-........
-// 0x01c0: 0014 016b 0c72 6f6f 742d 7365 7276 6572 ...k.root-server
-// 0x01d0: 7303 6e65 7400 c02d 0002 0001 0000 0e10 s.net..-........
-// 0x01e0: 0014 0163 0c72 6f6f 742d 7365 7276 6572 ...c.root-server
-// 0x01f0: 7303 6e65 7400 c038 0001 0001 0000 0e10 s.net..8........
-// 0x0200: 0004 ca0c 1b21 c058 0001 0001 0000 0e10 .....!.X........
-// 0x0210: 0004 c629 0004 c078 0001 0001 0000 0e10 ...)...x........
-// 0x0220: 0004 c024 9411 ...$..
-var testMalformedRootQuery = []byte{
- 0x00, 0x55, 0x22, 0xaf, 0xc6, 0x37, 0x00, 0x22, 0x55, 0xac, 0xde, 0xac, 0x08, 0x00, 0x45, 0x00,
- 0x02, 0x18, 0x76, 0xb2, 0x40, 0x00, 0x72, 0x11, 0x7a, 0xd2, 0x0a, 0x4d, 0x00, 0x1a, 0x0a, 0x01,
- 0x00, 0xe9, 0x00, 0x35, 0xfe, 0x2f, 0x02, 0x04, 0xb8, 0xf5, 0xe8, 0x74, 0x81, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x0d, 0x00, 0x03, 0x0c, 0x61, 0x78, 0x6b, 0x76, 0x63, 0x68, 0x63, 0x70, 0x63,
- 0x70, 0x73, 0x6c, 0x0a, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x03, 0x6e,
- 0x65, 0x74, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x14, 0x01, 0x6d, 0x0c, 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
- 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00, 0xc0, 0x2d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x14, 0x01, 0x61, 0x0c, 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
- 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00, 0xc0, 0x2d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x14, 0x01, 0x69, 0x0c, 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
- 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00, 0xc0, 0x2d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x14, 0x01, 0x62, 0x0c, 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
- 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00, 0xc0, 0x2d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x14, 0x01, 0x6c, 0x0c, 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
- 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00, 0xc0, 0x2d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x14, 0x01, 0x66, 0x0c, 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
- 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00, 0xc0, 0x2d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x14, 0x01, 0x67, 0x0c, 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
- 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00, 0xc0, 0x2d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x14, 0x01, 0x64, 0x0c, 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
- 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00, 0xc0, 0x2d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x14, 0x01, 0x68, 0x0c, 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
- 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00, 0xc0, 0x2d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x14, 0x01, 0x65, 0x0c, 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
- 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00, 0xc0, 0x2d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x14, 0x01, 0x6a, 0x0c, 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
- 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00, 0xc0, 0x2d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x14, 0x01, 0x6b, 0x0c, 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
- 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00, 0xc0, 0x2d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x14, 0x01, 0x63, 0x0c, 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
- 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00, 0xc0, 0x38, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x04, 0xca, 0x0c, 0x1b, 0x21, 0xc0, 0x58, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x04, 0xc6, 0x29, 0x00, 0x04, 0xc0, 0x78, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
- 0x00, 0x04, 0xc0, 0x24, 0x94, 0x11,
-}
-
-func TestMalformedRootQuery(t *testing.T) {
- p := gopacket.NewPacket(testMalformedRootQuery, LinkTypeEthernet, testDecodeOptions)
- if errLayer := p.ErrorLayer(); errLayer == nil {
- t.Error("No error layer on invalid DNS name")
- } else if err := errLayer.Error(); !strings.Contains(err.Error(), "no dns data found") {
- t.Errorf("unexpected error message: %v", err)
- }
-}
-
-// testAnotherMalformedDNS is the packet:
-// 10:52:13.690904 IP 10.77.0.29.53 > 10.1.0.6.42280: 13491 op6+% [b2&3=0x3313] [11720a] [23583q] [29742n] [52087au] Type22277 (Class 43688)? M- M-<.VM-^KM-wQM-s"M-^E^]M-+^Wx^P^@M-^\^\M-oM-FM-U^F^E7M-tM-^VM-^[M-F^H>G^FM-uM-^KM-_6GM-[M-jM-bM-^H]hM-^J.[|domain]
-// 0x0000: 0055 22af c637 0022 55ac deac 0800 4500 .U"..7."U.....E.
-// 0x0010: 05c1 2eea 4000 3611 fbd1 0a4d 001d 0a01 ....@.6....M....
-// 0x0020: 0006 0035 a528 05ad 00a2 34b3 3313 5c1f ...5.(....4.3.\.
-// 0x0030: 2dc8 742e cb77 2da0 bc2e 568b f751 f322 -.t..w-...V..Q."
-// 0x0040: 851d ab17 7810 009c 1cef c6d5 0605 37f4 ....x.........7.
-// 0x0050: 969b c65e 483e 4706 f58b df36 47db eae2 ...^H>G....6G...
-// 0x0060: 885d 688a c5a5 5705 aaa8 95eb 93a4 d85a .]h...W........Z
-// 0x0070: c9af 261f 7816 a354 2d23 d84a 579c 4876 ..&.x..T-#.JW.Hv
-// 0x0080: a391 43db 5c41 191a 92b8 dcdd 6839 eef5 ..C.\A......h9..
-// 0x0090: 728e 13e0 0679 6f47 88a0 25b9 44d8 f8e7 r....yoG..%.D...
-// 0x00a0: 8afe 0bfa f811 8da5 f8a3 1f8e d23b fe12 .............;..
-// 0x00b0: d943 9327 92ad 4410 183e 688d b06d 5391 .C.'..D..>h..mS.
-// 0x00c0: 695b e49f 8f1e c075 d043 afe0 1174 9db0 i[.....u.C...t..
-// 0x00d0: 06b0 f01e b85b 3c84 945e 06d0 b20f 9eaa .....[<..^......
-// 0x00e0: 123d 0ab0 2a55 309c 0ee9 3e5e db2f f377 .=..*U0...>^./.w
-// 0x00f0: d7f1 9bae 373d 3316 0796 b80e dd18 5173 ....7=3.......Qs
-// 0x0100: b28d 84fd 1812 d87b 42c8 5f11 4db6 b269 .......{B._.M..i
-// 0x0110: 1c42 4aea d5a4 644b 6c00 f0c0 fcee 71a7 .BJ...dKl.....q.
-// 0x0120: e7f0 719c a207 dc5c a6fa f005 a338 7ff0 ..q....\.....8..
-// 0x0130: 5beb 3b4d 8952 2a46 d47b a5a2 e1fb 9e76 [.;M.R*F.{.....v
-// 0x0140: c815 6258 50f4 6997 bad5 b479 2d06 ebbb ..bXP.i....y-...
-// 0x0150: 2cac 2ecc e4f0 1f94 ce9f 186c 61da 9681 ,..........la...
-// 0x0160: 345c 4d88 efc7 037b fbe3 4402 ea06 2e5d 4\M....{..D....]
-// 0x0170: 2e6e 4860 e180 3ef7 c006 0ad1 ebb9 c4ff .nH`..>.........
-// 0x0180: dee2 f21c 02c2 751a ded8 ae2e 13a9 3fa2 ......u.......?.
-// 0x0190: 392a 8b54 11b2 2b4e 2bf1 4780 db9f 8c10 9*.T..+N+.G.....
-// 0x01a0: ac6f 61b0 7b19 423f 07e5 4628 b870 f75d .oa.{.B?..F(.p.]
-// 0x01b0: 09a3 63b2 77af 5985 a0ae 51d8 243f a7c8 ..c.w.Y...Q.$?..
-// 0x01c0: ab08 7fc6 0217 c09f c412 0c45 e6aa 96bf ...........E....
-// 0x01d0: 184c 4307 1f1f c4f4 7734 da31 2088 662b .LC.....w4.1..f+
-// 0x01e0: 44c5 096f 1d1d 2dc5 ffd6 867d 9fc5 7b45 D..o..-....}..{E
-// 0x01f0: f949 7dd9 38de 0d51 ac2a 32fc f50b 1bbe .I}.8..Q.*2.....
-// 0x0200: 1c4b 5441 fbf3 0821 6c28 4530 5676 1d27 .KTA...!l(E0Vv.'
-// 0x0210: 5087 466c 3d5b 45a6 af7f 917a 6d43 66c2 P.Fl=[E....zmCf.
-// 0x0220: 036a 8bef ca60 9b13 8d29 9fda 82fa 01b1 .j...`...)......
-// 0x0230: df8f 1f83 c71d 630f 349e 508c 9f7a e3da ......c.4.P..z..
-// 0x0240: a114 3622 9df8 9926 4dac 4150 d505 7b3a ..6"...&M.AP..{:
-// 0x0250: 6fed fc75 6b4f 2d60 8a89 767d 9af0 896e o..ukO-`..v}...n
-// 0x0260: 907d 1ada def3 345c 0d81 283c a24f fcbb .}....4\..(<.O..
-// 0x0270: bbdd b7b3 e3bb 9f1b d966 51b7 8217 7fa0 .........fQ.....
-// 0x0280: e828 d3ca a6f1 532f 164e e405 bb3b 0de3 .(....S/.N...;..
-// 0x0290: 985d 6e89 d825 ebc6 d8ba 5190 a114 c6a3 .]n..%....Q.....
-// 0x02a0: 18b4 8aa7 181a 01ac cdc0 8048 ea72 a5e3 ...........H.r..
-// 0x02b0: e37a dc57 65cd b787 39e6 c39e 317b 45d8 .z.We...9...1{E.
-// 0x02c0: 475c 05ba e8f8 8224 5a85 27b8 1584 8d78 G\.....$Z.'....x
-// 0x02d0: 62b6 6495 ac10 338f 1122 f2ff 043e 9e2a b.d...3.."...>.*
-// 0x02e0: 1058 a910 5792 6fcd 9a96 6183 6708 8f70 .X..W.o...a.g..p
-// 0x02f0: edc6 a67c 64ff 50fa 520b de94 c82c c4d6 ...|d.P.R....,..
-// 0x0300: 7d8f 0fd5 2f0d 9833 7c6c be10 a4e5 dc99 }.../..3|l......
-// 0x0310: a467 ef5f b35b c11c e23c 131a 48b2 9cef .g._.[...<..H...
-// 0x0320: 5a2f fece dd9e 2aea 0db9 faf3 a6ef b29d Z/....*.........
-// 0x0330: e85d a410 dd6a 6806 3fc6 1694 179f cb4b .]...jh.?......K
-// 0x0340: 08c4 86b2 0713 cddb b257 d56b fe82 7d82 .........W.k..}.
-// 0x0350: 0d1f 6dc9 67b2 d2a1 6791 4f38 edf9 491f ..m.g...g.O8..I.
-// 0x0360: 2c02 35f5 8165 ecc3 bc6a b631 3c7e 1ad4 ,.5..e...j.1<~..
-// 0x0370: 8e27 f962 f942 11b5 1b45 9bac b474 3c6e .'.b.B...E...t<n
-// 0x0380: 6832 3075 be6d ac0d a8a0 7d47 a6ef 4e43 h20u.m....}G..NC
-// 0x0390: 6b9a 3097 8a8b 82a3 9515 362c f7d6 a37f k.0.......6,....
-// 0x03a0: 7313 1199 a5f3 03dc bcc9 fb10 c23d eeb9 s............=..
-// 0x03b0: 78ff c8f3 0d38 9f74 ceec b7ae 63e3 3424 x....8.t....c.4$
-// 0x03c0: b783 f106 011f 666b bf2d abc8 ea10 57a1 ......fk.-....W.
-// 0x03d0: 7cf2 4a3f 57ca 1386 bfba 27e5 4662 81c8 |.J?W.....'.Fb..
-// 0x03e0: 041e 1820 b3d5 c399 cd4d 222f 29f0 b994 .........M"/)...
-// 0x03f0: 865a e6e2 1686 3261 b0cd caaf 07ec d0bc .Z....2a........
-// 0x0400: afb8 3cf0 51c1 6c7a 6383 6b3a ff47 9551 ..<.Q.lzc.k:.G.Q
-// 0x0410: 1099 525f 355e 4684 bd34 ec12 88c9 dcc2 ..R_5^F..4......
-// 0x0420: d11c 826d f1df 37e6 f08f 6ce8 817d bdc3 ...m..7...l..}..
-// 0x0430: 20b9 a274 c645 c67d f299 fef9 287f 09ee ...t.E.}....(...
-// 0x0440: ac67 6872 a126 b1d3 922c 4c2a 0ec9 b6d4 .ghr.&...,L*....
-// 0x0450: fb59 6163 d1c4 1708 8d94 bc3d be5e ae29 .Yac.......=.^.)
-// 0x0460: 51ff a765 9df6 ae35 ed6b 0555 933f 3ed6 Q..e...5.k.U.?>.
-// 0x0470: 259b d93e f86f 6088 0c4e 357b 5c67 7d93 %..>.o`..N5{\g}.
-// 0x0480: a695 1a42 e1e1 ef91 14d7 b7b7 0ca4 2dda ...B..........-.
-// 0x0490: 6ac1 771e 25c1 a578 4ca8 6fd8 de04 1c09 j.w.%..xL.o.....
-// 0x04a0: df49 f179 6a58 2b45 7231 307f bc67 e5e7 .I.yjX+Er10..g..
-// 0x04b0: c5cd fec0 b021 508e 4fc5 f821 f734 90bc .....!P.O..!.4..
-// 0x04c0: c87f 14f1 2e5c d17b 1818 5b4a 6b68 0212 .....\.{..[Jkh..
-// 0x04d0: 1791 4a30 8518 99a9 b516 67e7 ed56 d1d1 ..J0......g..V..
-// 0x04e0: 239d dfda 11c5 0afe e58a b6e0 fb66 ab5c #............f.\
-// 0x04f0: f590 dcd6 457d 01d1 83f5 a9f0 cdb2 9c14 ....E}..........
-// 0x0500: ff66 f10c d428 a07b 34e3 d600 91f2 aca7 .f...(.{4.......
-// 0x0510: 4e1f f3ac a96e 2aa3 ec9b 448c 748d f858 N....n*...D.t..X
-// 0x0520: 131c d496 af9b f5f0 d2f5 57ac 0b64 55a1 ..........W..dU.
-// 0x0530: 860e 5ad0 3e62 26b5 9e17 f51f 88c1 02e3 ..Z.>b&.........
-// 0x0540: 4a38 de70 3216 6f88 5d1e f429 ee19 4121 J8.p2.o.]..)..A!
-// 0x0550: f571 84ac 3789 141f 1798 90b1 8373 2499 .q..7........s$.
-// 0x0560: c131 b13f f3a3 9a07 aef1 bfe8 8cd7 8c2e .1.?............
-// 0x0570: ba35 dfc5 eb07 013c 7621 6481 bdfb 6233 .5.....<v!d...b3
-// 0x0580: 22e2 0f05 7e15 0417 67e4 2632 5207 28a6 "...~...g.&2R.(.
-// 0x0590: 8e88 9423 de54 5412 b53e fd8d d47a de58 ...#.TT..>...z.X
-// 0x05a0: a1b2 6e08 d06d dc21 1eda 14a0 a2f7 1701 ..n..m.!........
-// 0x05b0: a5e0 dfd7 871f 595d db43 70f5 bab3 b732 ......Y].Cp....2
-// 0x05c0: 6275 da15 b203 dac7 321f 8d61 11bd 30 bu......2..a..0
-var testAnotherMalformedDNS = []byte{
- 0x00, 0x55, 0x22, 0xaf, 0xc6, 0x37, 0x00, 0x22, 0x55, 0xac, 0xde, 0xac, 0x08, 0x00, 0x45, 0x00,
- 0x05, 0xc1, 0x2e, 0xea, 0x40, 0x00, 0x36, 0x11, 0xfb, 0xd1, 0x0a, 0x4d, 0x00, 0x1d, 0x0a, 0x01,
- 0x00, 0x06, 0x00, 0x35, 0xa5, 0x28, 0x05, 0xad, 0x00, 0xa2, 0x34, 0xb3, 0x33, 0x13, 0x5c, 0x1f,
- 0x2d, 0xc8, 0x74, 0x2e, 0xcb, 0x77, 0x2d, 0xa0, 0xbc, 0x2e, 0x56, 0x8b, 0xf7, 0x51, 0xf3, 0x22,
- 0x85, 0x1d, 0xab, 0x17, 0x78, 0x10, 0x00, 0x9c, 0x1c, 0xef, 0xc6, 0xd5, 0x06, 0x05, 0x37, 0xf4,
- 0x96, 0x9b, 0xc6, 0x5e, 0x48, 0x3e, 0x47, 0x06, 0xf5, 0x8b, 0xdf, 0x36, 0x47, 0xdb, 0xea, 0xe2,
- 0x88, 0x5d, 0x68, 0x8a, 0xc5, 0xa5, 0x57, 0x05, 0xaa, 0xa8, 0x95, 0xeb, 0x93, 0xa4, 0xd8, 0x5a,
- 0xc9, 0xaf, 0x26, 0x1f, 0x78, 0x16, 0xa3, 0x54, 0x2d, 0x23, 0xd8, 0x4a, 0x57, 0x9c, 0x48, 0x76,
- 0xa3, 0x91, 0x43, 0xdb, 0x5c, 0x41, 0x19, 0x1a, 0x92, 0xb8, 0xdc, 0xdd, 0x68, 0x39, 0xee, 0xf5,
- 0x72, 0x8e, 0x13, 0xe0, 0x06, 0x79, 0x6f, 0x47, 0x88, 0xa0, 0x25, 0xb9, 0x44, 0xd8, 0xf8, 0xe7,
- 0x8a, 0xfe, 0x0b, 0xfa, 0xf8, 0x11, 0x8d, 0xa5, 0xf8, 0xa3, 0x1f, 0x8e, 0xd2, 0x3b, 0xfe, 0x12,
- 0xd9, 0x43, 0x93, 0x27, 0x92, 0xad, 0x44, 0x10, 0x18, 0x3e, 0x68, 0x8d, 0xb0, 0x6d, 0x53, 0x91,
- 0x69, 0x5b, 0xe4, 0x9f, 0x8f, 0x1e, 0xc0, 0x75, 0xd0, 0x43, 0xaf, 0xe0, 0x11, 0x74, 0x9d, 0xb0,
- 0x06, 0xb0, 0xf0, 0x1e, 0xb8, 0x5b, 0x3c, 0x84, 0x94, 0x5e, 0x06, 0xd0, 0xb2, 0x0f, 0x9e, 0xaa,
- 0x12, 0x3d, 0x0a, 0xb0, 0x2a, 0x55, 0x30, 0x9c, 0x0e, 0xe9, 0x3e, 0x5e, 0xdb, 0x2f, 0xf3, 0x77,
- 0xd7, 0xf1, 0x9b, 0xae, 0x37, 0x3d, 0x33, 0x16, 0x07, 0x96, 0xb8, 0x0e, 0xdd, 0x18, 0x51, 0x73,
- 0xb2, 0x8d, 0x84, 0xfd, 0x18, 0x12, 0xd8, 0x7b, 0x42, 0xc8, 0x5f, 0x11, 0x4d, 0xb6, 0xb2, 0x69,
- 0x1c, 0x42, 0x4a, 0xea, 0xd5, 0xa4, 0x64, 0x4b, 0x6c, 0x00, 0xf0, 0xc0, 0xfc, 0xee, 0x71, 0xa7,
- 0xe7, 0xf0, 0x71, 0x9c, 0xa2, 0x07, 0xdc, 0x5c, 0xa6, 0xfa, 0xf0, 0x05, 0xa3, 0x38, 0x7f, 0xf0,
- 0x5b, 0xeb, 0x3b, 0x4d, 0x89, 0x52, 0x2a, 0x46, 0xd4, 0x7b, 0xa5, 0xa2, 0xe1, 0xfb, 0x9e, 0x76,
- 0xc8, 0x15, 0x62, 0x58, 0x50, 0xf4, 0x69, 0x97, 0xba, 0xd5, 0xb4, 0x79, 0x2d, 0x06, 0xeb, 0xbb,
- 0x2c, 0xac, 0x2e, 0xcc, 0xe4, 0xf0, 0x1f, 0x94, 0xce, 0x9f, 0x18, 0x6c, 0x61, 0xda, 0x96, 0x81,
- 0x34, 0x5c, 0x4d, 0x88, 0xef, 0xc7, 0x03, 0x7b, 0xfb, 0xe3, 0x44, 0x02, 0xea, 0x06, 0x2e, 0x5d,
- 0x2e, 0x6e, 0x48, 0x60, 0xe1, 0x80, 0x3e, 0xf7, 0xc0, 0x06, 0x0a, 0xd1, 0xeb, 0xb9, 0xc4, 0xff,
- 0xde, 0xe2, 0xf2, 0x1c, 0x02, 0xc2, 0x75, 0x1a, 0xde, 0xd8, 0xae, 0x2e, 0x13, 0xa9, 0x3f, 0xa2,
- 0x39, 0x2a, 0x8b, 0x54, 0x11, 0xb2, 0x2b, 0x4e, 0x2b, 0xf1, 0x47, 0x80, 0xdb, 0x9f, 0x8c, 0x10,
- 0xac, 0x6f, 0x61, 0xb0, 0x7b, 0x19, 0x42, 0x3f, 0x07, 0xe5, 0x46, 0x28, 0xb8, 0x70, 0xf7, 0x5d,
- 0x09, 0xa3, 0x63, 0xb2, 0x77, 0xaf, 0x59, 0x85, 0xa0, 0xae, 0x51, 0xd8, 0x24, 0x3f, 0xa7, 0xc8,
- 0xab, 0x08, 0x7f, 0xc6, 0x02, 0x17, 0xc0, 0x9f, 0xc4, 0x12, 0x0c, 0x45, 0xe6, 0xaa, 0x96, 0xbf,
- 0x18, 0x4c, 0x43, 0x07, 0x1f, 0x1f, 0xc4, 0xf4, 0x77, 0x34, 0xda, 0x31, 0x20, 0x88, 0x66, 0x2b,
- 0x44, 0xc5, 0x09, 0x6f, 0x1d, 0x1d, 0x2d, 0xc5, 0xff, 0xd6, 0x86, 0x7d, 0x9f, 0xc5, 0x7b, 0x45,
- 0xf9, 0x49, 0x7d, 0xd9, 0x38, 0xde, 0x0d, 0x51, 0xac, 0x2a, 0x32, 0xfc, 0xf5, 0x0b, 0x1b, 0xbe,
- 0x1c, 0x4b, 0x54, 0x41, 0xfb, 0xf3, 0x08, 0x21, 0x6c, 0x28, 0x45, 0x30, 0x56, 0x76, 0x1d, 0x27,
- 0x50, 0x87, 0x46, 0x6c, 0x3d, 0x5b, 0x45, 0xa6, 0xaf, 0x7f, 0x91, 0x7a, 0x6d, 0x43, 0x66, 0xc2,
- 0x03, 0x6a, 0x8b, 0xef, 0xca, 0x60, 0x9b, 0x13, 0x8d, 0x29, 0x9f, 0xda, 0x82, 0xfa, 0x01, 0xb1,
- 0xdf, 0x8f, 0x1f, 0x83, 0xc7, 0x1d, 0x63, 0x0f, 0x34, 0x9e, 0x50, 0x8c, 0x9f, 0x7a, 0xe3, 0xda,
- 0xa1, 0x14, 0x36, 0x22, 0x9d, 0xf8, 0x99, 0x26, 0x4d, 0xac, 0x41, 0x50, 0xd5, 0x05, 0x7b, 0x3a,
- 0x6f, 0xed, 0xfc, 0x75, 0x6b, 0x4f, 0x2d, 0x60, 0x8a, 0x89, 0x76, 0x7d, 0x9a, 0xf0, 0x89, 0x6e,
- 0x90, 0x7d, 0x1a, 0xda, 0xde, 0xf3, 0x34, 0x5c, 0x0d, 0x81, 0x28, 0x3c, 0xa2, 0x4f, 0xfc, 0xbb,
- 0xbb, 0xdd, 0xb7, 0xb3, 0xe3, 0xbb, 0x9f, 0x1b, 0xd9, 0x66, 0x51, 0xb7, 0x82, 0x17, 0x7f, 0xa0,
- 0xe8, 0x28, 0xd3, 0xca, 0xa6, 0xf1, 0x53, 0x2f, 0x16, 0x4e, 0xe4, 0x05, 0xbb, 0x3b, 0x0d, 0xe3,
- 0x98, 0x5d, 0x6e, 0x89, 0xd8, 0x25, 0xeb, 0xc6, 0xd8, 0xba, 0x51, 0x90, 0xa1, 0x14, 0xc6, 0xa3,
- 0x18, 0xb4, 0x8a, 0xa7, 0x18, 0x1a, 0x01, 0xac, 0xcd, 0xc0, 0x80, 0x48, 0xea, 0x72, 0xa5, 0xe3,
- 0xe3, 0x7a, 0xdc, 0x57, 0x65, 0xcd, 0xb7, 0x87, 0x39, 0xe6, 0xc3, 0x9e, 0x31, 0x7b, 0x45, 0xd8,
- 0x47, 0x5c, 0x05, 0xba, 0xe8, 0xf8, 0x82, 0x24, 0x5a, 0x85, 0x27, 0xb8, 0x15, 0x84, 0x8d, 0x78,
- 0x62, 0xb6, 0x64, 0x95, 0xac, 0x10, 0x33, 0x8f, 0x11, 0x22, 0xf2, 0xff, 0x04, 0x3e, 0x9e, 0x2a,
- 0x10, 0x58, 0xa9, 0x10, 0x57, 0x92, 0x6f, 0xcd, 0x9a, 0x96, 0x61, 0x83, 0x67, 0x08, 0x8f, 0x70,
- 0xed, 0xc6, 0xa6, 0x7c, 0x64, 0xff, 0x50, 0xfa, 0x52, 0x0b, 0xde, 0x94, 0xc8, 0x2c, 0xc4, 0xd6,
- 0x7d, 0x8f, 0x0f, 0xd5, 0x2f, 0x0d, 0x98, 0x33, 0x7c, 0x6c, 0xbe, 0x10, 0xa4, 0xe5, 0xdc, 0x99,
- 0xa4, 0x67, 0xef, 0x5f, 0xb3, 0x5b, 0xc1, 0x1c, 0xe2, 0x3c, 0x13, 0x1a, 0x48, 0xb2, 0x9c, 0xef,
- 0x5a, 0x2f, 0xfe, 0xce, 0xdd, 0x9e, 0x2a, 0xea, 0x0d, 0xb9, 0xfa, 0xf3, 0xa6, 0xef, 0xb2, 0x9d,
- 0xe8, 0x5d, 0xa4, 0x10, 0xdd, 0x6a, 0x68, 0x06, 0x3f, 0xc6, 0x16, 0x94, 0x17, 0x9f, 0xcb, 0x4b,
- 0x08, 0xc4, 0x86, 0xb2, 0x07, 0x13, 0xcd, 0xdb, 0xb2, 0x57, 0xd5, 0x6b, 0xfe, 0x82, 0x7d, 0x82,
- 0x0d, 0x1f, 0x6d, 0xc9, 0x67, 0xb2, 0xd2, 0xa1, 0x67, 0x91, 0x4f, 0x38, 0xed, 0xf9, 0x49, 0x1f,
- 0x2c, 0x02, 0x35, 0xf5, 0x81, 0x65, 0xec, 0xc3, 0xbc, 0x6a, 0xb6, 0x31, 0x3c, 0x7e, 0x1a, 0xd4,
- 0x8e, 0x27, 0xf9, 0x62, 0xf9, 0x42, 0x11, 0xb5, 0x1b, 0x45, 0x9b, 0xac, 0xb4, 0x74, 0x3c, 0x6e,
- 0x68, 0x32, 0x30, 0x75, 0xbe, 0x6d, 0xac, 0x0d, 0xa8, 0xa0, 0x7d, 0x47, 0xa6, 0xef, 0x4e, 0x43,
- 0x6b, 0x9a, 0x30, 0x97, 0x8a, 0x8b, 0x82, 0xa3, 0x95, 0x15, 0x36, 0x2c, 0xf7, 0xd6, 0xa3, 0x7f,
- 0x73, 0x13, 0x11, 0x99, 0xa5, 0xf3, 0x03, 0xdc, 0xbc, 0xc9, 0xfb, 0x10, 0xc2, 0x3d, 0xee, 0xb9,
- 0x78, 0xff, 0xc8, 0xf3, 0x0d, 0x38, 0x9f, 0x74, 0xce, 0xec, 0xb7, 0xae, 0x63, 0xe3, 0x34, 0x24,
- 0xb7, 0x83, 0xf1, 0x06, 0x01, 0x1f, 0x66, 0x6b, 0xbf, 0x2d, 0xab, 0xc8, 0xea, 0x10, 0x57, 0xa1,
- 0x7c, 0xf2, 0x4a, 0x3f, 0x57, 0xca, 0x13, 0x86, 0xbf, 0xba, 0x27, 0xe5, 0x46, 0x62, 0x81, 0xc8,
- 0x04, 0x1e, 0x18, 0x20, 0xb3, 0xd5, 0xc3, 0x99, 0xcd, 0x4d, 0x22, 0x2f, 0x29, 0xf0, 0xb9, 0x94,
- 0x86, 0x5a, 0xe6, 0xe2, 0x16, 0x86, 0x32, 0x61, 0xb0, 0xcd, 0xca, 0xaf, 0x07, 0xec, 0xd0, 0xbc,
- 0xaf, 0xb8, 0x3c, 0xf0, 0x51, 0xc1, 0x6c, 0x7a, 0x63, 0x83, 0x6b, 0x3a, 0xff, 0x47, 0x95, 0x51,
- 0x10, 0x99, 0x52, 0x5f, 0x35, 0x5e, 0x46, 0x84, 0xbd, 0x34, 0xec, 0x12, 0x88, 0xc9, 0xdc, 0xc2,
- 0xd1, 0x1c, 0x82, 0x6d, 0xf1, 0xdf, 0x37, 0xe6, 0xf0, 0x8f, 0x6c, 0xe8, 0x81, 0x7d, 0xbd, 0xc3,
- 0x20, 0xb9, 0xa2, 0x74, 0xc6, 0x45, 0xc6, 0x7d, 0xf2, 0x99, 0xfe, 0xf9, 0x28, 0x7f, 0x09, 0xee,
- 0xac, 0x67, 0x68, 0x72, 0xa1, 0x26, 0xb1, 0xd3, 0x92, 0x2c, 0x4c, 0x2a, 0x0e, 0xc9, 0xb6, 0xd4,
- 0xfb, 0x59, 0x61, 0x63, 0xd1, 0xc4, 0x17, 0x08, 0x8d, 0x94, 0xbc, 0x3d, 0xbe, 0x5e, 0xae, 0x29,
- 0x51, 0xff, 0xa7, 0x65, 0x9d, 0xf6, 0xae, 0x35, 0xed, 0x6b, 0x05, 0x55, 0x93, 0x3f, 0x3e, 0xd6,
- 0x25, 0x9b, 0xd9, 0x3e, 0xf8, 0x6f, 0x60, 0x88, 0x0c, 0x4e, 0x35, 0x7b, 0x5c, 0x67, 0x7d, 0x93,
- 0xa6, 0x95, 0x1a, 0x42, 0xe1, 0xe1, 0xef, 0x91, 0x14, 0xd7, 0xb7, 0xb7, 0x0c, 0xa4, 0x2d, 0xda,
- 0x6a, 0xc1, 0x77, 0x1e, 0x25, 0xc1, 0xa5, 0x78, 0x4c, 0xa8, 0x6f, 0xd8, 0xde, 0x04, 0x1c, 0x09,
- 0xdf, 0x49, 0xf1, 0x79, 0x6a, 0x58, 0x2b, 0x45, 0x72, 0x31, 0x30, 0x7f, 0xbc, 0x67, 0xe5, 0xe7,
- 0xc5, 0xcd, 0xfe, 0xc0, 0xb0, 0x21, 0x50, 0x8e, 0x4f, 0xc5, 0xf8, 0x21, 0xf7, 0x34, 0x90, 0xbc,
- 0xc8, 0x7f, 0x14, 0xf1, 0x2e, 0x5c, 0xd1, 0x7b, 0x18, 0x18, 0x5b, 0x4a, 0x6b, 0x68, 0x02, 0x12,
- 0x17, 0x91, 0x4a, 0x30, 0x85, 0x18, 0x99, 0xa9, 0xb5, 0x16, 0x67, 0xe7, 0xed, 0x56, 0xd1, 0xd1,
- 0x23, 0x9d, 0xdf, 0xda, 0x11, 0xc5, 0x0a, 0xfe, 0xe5, 0x8a, 0xb6, 0xe0, 0xfb, 0x66, 0xab, 0x5c,
- 0xf5, 0x90, 0xdc, 0xd6, 0x45, 0x7d, 0x01, 0xd1, 0x83, 0xf5, 0xa9, 0xf0, 0xcd, 0xb2, 0x9c, 0x14,
- 0xff, 0x66, 0xf1, 0x0c, 0xd4, 0x28, 0xa0, 0x7b, 0x34, 0xe3, 0xd6, 0x00, 0x91, 0xf2, 0xac, 0xa7,
- 0x4e, 0x1f, 0xf3, 0xac, 0xa9, 0x6e, 0x2a, 0xa3, 0xec, 0x9b, 0x44, 0x8c, 0x74, 0x8d, 0xf8, 0x58,
- 0x13, 0x1c, 0xd4, 0x96, 0xaf, 0x9b, 0xf5, 0xf0, 0xd2, 0xf5, 0x57, 0xac, 0x0b, 0x64, 0x55, 0xa1,
- 0x86, 0x0e, 0x5a, 0xd0, 0x3e, 0x62, 0x26, 0xb5, 0x9e, 0x17, 0xf5, 0x1f, 0x88, 0xc1, 0x02, 0xe3,
- 0x4a, 0x38, 0xde, 0x70, 0x32, 0x16, 0x6f, 0x88, 0x5d, 0x1e, 0xf4, 0x29, 0xee, 0x19, 0x41, 0x21,
- 0xf5, 0x71, 0x84, 0xac, 0x37, 0x89, 0x14, 0x1f, 0x17, 0x98, 0x90, 0xb1, 0x83, 0x73, 0x24, 0x99,
- 0xc1, 0x31, 0xb1, 0x3f, 0xf3, 0xa3, 0x9a, 0x07, 0xae, 0xf1, 0xbf, 0xe8, 0x8c, 0xd7, 0x8c, 0x2e,
- 0xba, 0x35, 0xdf, 0xc5, 0xeb, 0x07, 0x01, 0x3c, 0x76, 0x21, 0x64, 0x81, 0xbd, 0xfb, 0x62, 0x33,
- 0x22, 0xe2, 0x0f, 0x05, 0x7e, 0x15, 0x04, 0x17, 0x67, 0xe4, 0x26, 0x32, 0x52, 0x07, 0x28, 0xa6,
- 0x8e, 0x88, 0x94, 0x23, 0xde, 0x54, 0x54, 0x12, 0xb5, 0x3e, 0xfd, 0x8d, 0xd4, 0x7a, 0xde, 0x58,
- 0xa1, 0xb2, 0x6e, 0x08, 0xd0, 0x6d, 0xdc, 0x21, 0x1e, 0xda, 0x14, 0xa0, 0xa2, 0xf7, 0x17, 0x01,
- 0xa5, 0xe0, 0xdf, 0xd7, 0x87, 0x1f, 0x59, 0x5d, 0xdb, 0x43, 0x70, 0xf5, 0xba, 0xb3, 0xb7, 0x32,
- 0x62, 0x75, 0xda, 0x15, 0xb2, 0x03, 0xda, 0xc7, 0x32, 0x1f, 0x8d, 0x61, 0x11, 0xbd, 0x30,
-}
-
-func TestAnotherMalformedDNS(t *testing.T) {
- p := gopacket.NewPacket(testAnotherMalformedDNS, LinkTypeEthernet, testDecodeOptions)
- if errLayer := p.ErrorLayer(); errLayer == nil {
- t.Error("No error layer on invalid DNS name")
- } else if err := errLayer.Error(); !strings.Contains(err.Error(), "offset too high") {
- t.Errorf("unexpected error message: %v", err)
- }
-}
-
-// testMalformedDNSAgain is the packet:
-// 12:14:52.702061 IP 10.77.0.4.53 > 10.1.0.41.61610: 12529 updateDA [b2&3=0x5cad] [38274a] [61303q] [1718n] [14913au][|domain]
-// 0x0000: 0055 22af c637 0022 55ac deac 0800 4500 .U"..7."U.....E.
-// 0x0010: 0091 2dff 0000 7811 ffe2 0a4d 0004 0a01 ..-...x....M....
-// 0x0020: 0029 0035 f0aa 007d 5b53 30f1 5cad ef77 .).5...}[S0.\..w
-// 0x0030: 9582 06b6 3a41 357a 8cef cdc0 a732 b800 ....:A5z.....2..
-// 0x0040: 466e 1c30 2e75 95ac c03d 1ed4 8635 2d09 Fn.0.u...=...5-.
-// 0x0050: 2fee 3a82 b4f0 427e 2b6b f870 cc7f c9a1 /.:...B~+k.p....
-// 0x0060: e6f1 a761 97ec 2ff7 d248 4d95 321c 6e4e ...a../..HM.2.nN
-// 0x0070: 57fa 6d3d 9ec0 fe3a 6f1e e634 4396 b494 W.m=...:o..4C...
-// 0x0080: 8b7a a929 d7e1 da7c c346 ca77 4890 6bf3 .z.)...|.F.wH.k.
-// 0x0090: 5ecb 7e97 c49d 3564 984f bf7c 8ac1 dd ^.~...5d.O.|...
-var testMalformedDNSAgain = []byte{
- 0x00, 0x55, 0x22, 0xaf, 0xc6, 0x37, 0x00, 0x22, 0x55, 0xac, 0xde, 0xac, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x91, 0x2d, 0xff, 0x00, 0x00, 0x78, 0x11, 0xff, 0xe2, 0x0a, 0x4d, 0x00, 0x04, 0x0a, 0x01,
- 0x00, 0x29, 0x00, 0x35, 0xf0, 0xaa, 0x00, 0x7d, 0x5b, 0x53, 0x30, 0xf1, 0x5c, 0xad, 0xef, 0x77,
- 0x95, 0x82, 0x06, 0xb6, 0x3a, 0x41, 0x35, 0x7a, 0x8c, 0xef, 0xcd, 0xc0, 0xa7, 0x32, 0xb8, 0x00,
- 0x46, 0x6e, 0x1c, 0x30, 0x2e, 0x75, 0x95, 0xac, 0xc0, 0x3d, 0x1e, 0xd4, 0x86, 0x35, 0x2d, 0x09,
- 0x2f, 0xee, 0x3a, 0x82, 0xb4, 0xf0, 0x42, 0x7e, 0x2b, 0x6b, 0xf8, 0x70, 0xcc, 0x7f, 0xc9, 0xa1,
- 0xe6, 0xf1, 0xa7, 0x61, 0x97, 0xec, 0x2f, 0xf7, 0xd2, 0x48, 0x4d, 0x95, 0x32, 0x1c, 0x6e, 0x4e,
- 0x57, 0xfa, 0x6d, 0x3d, 0x9e, 0xc0, 0xfe, 0x3a, 0x6f, 0x1e, 0xe6, 0x34, 0x43, 0x96, 0xb4, 0x94,
- 0x8b, 0x7a, 0xa9, 0x29, 0xd7, 0xe1, 0xda, 0x7c, 0xc3, 0x46, 0xca, 0x77, 0x48, 0x90, 0x6b, 0xf3,
- 0x5e, 0xcb, 0x7e, 0x97, 0xc4, 0x9d, 0x35, 0x64, 0x98, 0x4f, 0xbf, 0x7c, 0x8a, 0xc1, 0xdd,
-}
-
-func TestMalformedDNSAgain(t *testing.T) {
- p := gopacket.NewPacket(testMalformedDNSAgain, LinkTypeEthernet, testDecodeOptions)
- if errLayer := p.ErrorLayer(); errLayer == nil {
- t.Error("No error layer on invalid DNS name")
- } else if err := errLayer.Error(); !strings.Contains(err.Error(), "walked out of range") {
- t.Errorf("unexpected error message: %v", err)
- }
-}
-
-// testMalformedDNSOhGodMakeItStop is the packet:
-// 15:08:24.430906 IP 10.77.0.19.53 > 10.1.0.19.50635: 12397 zoneInit% [b2&3=0x7232] [47729a] [46283q] [60247n] [61718au][|domain]
-// 0x0000: 0055 22af c637 0022 55ac deac 0800 4500 .U"..7."U.....E.
-// 0x0010: 0079 c51c 4000 3511 6be4 0a4d 0013 0a01 .y..@.5.k..M....
-// 0x0020: 0013 0035 c5cb 0065 ef45 306d 7232 b4cb ...5...e.E0mr2..
-// 0x0030: ba71 eb57 f116 3994 e000 4626 0534 66cc .q.W..9...F&.4f.
-// 0x0040: 7b32 24f2 eece bca7 20e2 9a2a e1ce e737 {2$........*...7
-// 0x0050: ac39 5fae 72ec c3ec 284f ca4a 171f 466d .9_.r...(O.J..Fm
-// 0x0060: f6c6 84d7 e795 310f 26df 9b59 6db9 21cf ......1.&..Ym.!.
-// 0x0070: 15cb 30a3 c4cf df23 805a ed1a 0584 4fc3 ..0....#.Z....O.
-// 0x0080: 7fa3 3cb4 e04f e9 ..<..O.
-var testMalformedDNSOhGodMakeItStop = []byte{
- 0x00, 0x55, 0x22, 0xaf, 0xc6, 0x37, 0x00, 0x22, 0x55, 0xac, 0xde, 0xac, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x79, 0xc5, 0x1c, 0x40, 0x00, 0x35, 0x11, 0x6b, 0xe4, 0x0a, 0x4d, 0x00, 0x13, 0x0a, 0x01,
- 0x00, 0x13, 0x00, 0x35, 0xc5, 0xcb, 0x00, 0x65, 0xef, 0x45, 0x30, 0x6d, 0x72, 0x32, 0xb4, 0xcb,
- 0xba, 0x71, 0xeb, 0x57, 0xf1, 0x16, 0x39, 0x94, 0xe0, 0x00, 0x46, 0x26, 0x05, 0x34, 0x66, 0xcc,
- 0x7b, 0x32, 0x24, 0xf2, 0xee, 0xce, 0xbc, 0xa7, 0x20, 0xe2, 0x9a, 0x2a, 0xe1, 0xce, 0xe7, 0x37,
- 0xac, 0x39, 0x5f, 0xae, 0x72, 0xec, 0xc3, 0xec, 0x28, 0x4f, 0xca, 0x4a, 0x17, 0x1f, 0x46, 0x6d,
- 0xf6, 0xc6, 0x84, 0xd7, 0xe7, 0x95, 0x31, 0x0f, 0x26, 0xdf, 0x9b, 0x59, 0x6d, 0xb9, 0x21, 0xcf,
- 0x15, 0xcb, 0x30, 0xa3, 0xc4, 0xcf, 0xdf, 0x23, 0x80, 0x5a, 0xed, 0x1a, 0x05, 0x84, 0x4f, 0xc3,
- 0x7f, 0xa3, 0x3c, 0xb4, 0xe0, 0x4f, 0xe9,
-}
-
-func TestMalformedDNSOhGodMakeItStop(t *testing.T) {
- p := gopacket.NewPacket(testMalformedDNSOhGodMakeItStop, LinkTypeEthernet, testDecodeOptions)
- if errLayer := p.ErrorLayer(); errLayer == nil {
- t.Error("No error layer on invalid DNS name")
- } else if err := errLayer.Error(); !strings.Contains(err.Error(), "offset pointer too high") {
- t.Errorf("unexpected error message: %v", err)
- }
-}
-
-// testPacketDNSPanic7 is the packet:
-// 07:56:25.174747 IP 10.77.0.11.53 > 10.1.0.67.55777: 41808*-| 3/7/0 TXT "google-site-verification=DC2uC-T8kD33lINhNzfo0bNBrw-vrCXs5BPF5BXY56g", TXT "v=spf1 include:spf-a.outlook.com include:spf-b.outlook.com ip4:157.55.9.128/25 include:spf.protection.outlook.com include:spf-a.hotmail.com include:_spf-ssg-b.microsoft.com include:_spf-ssg-c.microsoft.com ~all", TXT "google-site-verification=0iLWhIMhXEkeWwWfFU4ursTn-_OvoOjaA0Lr7Pg1sEM" (512)
-// 0x0000: 0055 22af c637 0022 55ac deac 0800 4500 .U"..7."U.....E.
-// 0x0010: 021c b5ca 4000 fa11 b46a 0a4d 000b 0a01 ....@....j.M....
-// 0x0020: 0043 0035 d9e1 0208 afd6 a350 8600 0001 .C.5.......P....
-// 0x0030: 0003 0007 0000 076f 7574 6c6f 6f6b 0363 .......outlook.c
-// 0x0040: 6f6d 0000 1000 01c0 0c00 1000 0100 0001 om..............
-// 0x0050: 2c00 4544 676f 6f67 6c65 2d73 6974 652d ,.EDgoogle-site-
-// 0x0060: 7665 7269 6669 6361 7469 6f6e 3d44 4332 verification=DC2
-// 0x0070: 7543 2d54 386b 4433 336c 494e 684e 7a66 uC-T8kD33lINhNzf
-// 0x0080: 6f30 624e 4272 772d 7672 4358 7335 4250 o0bNBrw-vrCXs5BP
-// 0x0090: 4635 4258 5935 3667 c00c 0010 0001 0000 F5BXY56g........
-// 0x00a0: 012c 00d3 d276 3d73 7066 3120 696e 636c .,...v=spf1.incl
-// 0x00b0: 7564 653a 7370 662d 612e 6f75 746c 6f6f ude:spf-a.outloo
-// 0x00c0: 6b2e 636f 6d20 696e 636c 7564 653a 7370 k.com.include:sp
-// 0x00d0: 662d 622e 6f75 746c 6f6f 6b2e 636f 6d20 f-b.outlook.com.
-// 0x00e0: 6970 343a 3135 372e 3535 2e39 2e31 3238 ip4:157.55.9.128
-// 0x00f0: 2f32 3520 696e 636c 7564 653a 7370 662e /25.include:spf.
-// 0x0100: 7072 6f74 6563 7469 6f6e 2e6f 7574 6c6f protection.outlo
-// 0x0110: 6f6b 2e63 6f6d 2069 6e63 6c75 6465 3a73 ok.com.include:s
-// 0x0120: 7066 2d61 2e68 6f74 6d61 696c 2e63 6f6d pf-a.hotmail.com
-// 0x0130: 2069 6e63 6c75 6465 3a5f 7370 662d 7373 .include:_spf-ss
-// 0x0140: 672d 622e 6d69 6372 6f73 6f66 742e 636f g-b.microsoft.co
-// 0x0150: 6d20 696e 636c 7564 653a 5f73 7066 2d73 m.include:_spf-s
-// 0x0160: 7367 2d63 2e6d 6963 726f 736f 6674 2e63 sg-c.microsoft.c
-// 0x0170: 6f6d 207e 616c 6cc0 0c00 1000 0100 0001 om.~all.........
-// 0x0180: 2c00 4544 676f 6f67 6c65 2d73 6974 652d ,.EDgoogle-site-
-// 0x0190: 7665 7269 6669 6361 7469 6f6e 3d30 694c verification=0iL
-// 0x01a0: 5768 494d 6858 456b 6557 7757 6646 5534 WhIMhXEkeWwWfFU4
-// 0x01b0: 7572 7354 6e2d 5f4f 766f 4f6a 6141 304c ursTn-_OvoOjaA0L
-// 0x01c0: 7237 5067 3173 454d c00c 0002 0001 0002 r7Pg1sEM........
-// 0x01d0: a300 000e 036e 7332 046d 7366 7403 6e65 .....ns2.msft.ne
-// 0x01e0: 7400 c00c 0002 0001 0002 a300 0006 036e t..............n
-// 0x01f0: 7334 c1ae c00c 0002 0001 0002 a300 0006 s4..............
-// 0x0200: 036e 7331 c1ae c00c 0002 0001 0002 a300 .ns1............
-// 0x0210: 0006 036e 7333 c1ae c00c 0002 0001 0002 ...ns3..........
-// 0x0220: a300 0015 046e 7331 610d .....ns1a.
-var testPacketDNSPanic7 = []byte{
- 0x00, 0x55, 0x22, 0xaf, 0xc6, 0x37, 0x00, 0x22, 0x55, 0xac, 0xde, 0xac, 0x08, 0x00, 0x45, 0x00,
- 0x02, 0x1c, 0xb5, 0xca, 0x40, 0x00, 0xfa, 0x11, 0xb4, 0x6a, 0x0a, 0x4d, 0x00, 0x0b, 0x0a, 0x01,
- 0x00, 0x43, 0x00, 0x35, 0xd9, 0xe1, 0x02, 0x08, 0xaf, 0xd6, 0xa3, 0x50, 0x86, 0x00, 0x00, 0x01,
- 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x07, 0x6f, 0x75, 0x74, 0x6c, 0x6f, 0x6f, 0x6b, 0x03, 0x63,
- 0x6f, 0x6d, 0x00, 0x00, 0x10, 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x01,
- 0x2c, 0x00, 0x45, 0x44, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2d, 0x73, 0x69, 0x74, 0x65, 0x2d,
- 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x44, 0x43, 0x32,
- 0x75, 0x43, 0x2d, 0x54, 0x38, 0x6b, 0x44, 0x33, 0x33, 0x6c, 0x49, 0x4e, 0x68, 0x4e, 0x7a, 0x66,
- 0x6f, 0x30, 0x62, 0x4e, 0x42, 0x72, 0x77, 0x2d, 0x76, 0x72, 0x43, 0x58, 0x73, 0x35, 0x42, 0x50,
- 0x46, 0x35, 0x42, 0x58, 0x59, 0x35, 0x36, 0x67, 0xc0, 0x0c, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00,
- 0x01, 0x2c, 0x00, 0xd3, 0xd2, 0x76, 0x3d, 0x73, 0x70, 0x66, 0x31, 0x20, 0x69, 0x6e, 0x63, 0x6c,
- 0x75, 0x64, 0x65, 0x3a, 0x73, 0x70, 0x66, 0x2d, 0x61, 0x2e, 0x6f, 0x75, 0x74, 0x6c, 0x6f, 0x6f,
- 0x6b, 0x2e, 0x63, 0x6f, 0x6d, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x3a, 0x73, 0x70,
- 0x66, 0x2d, 0x62, 0x2e, 0x6f, 0x75, 0x74, 0x6c, 0x6f, 0x6f, 0x6b, 0x2e, 0x63, 0x6f, 0x6d, 0x20,
- 0x69, 0x70, 0x34, 0x3a, 0x31, 0x35, 0x37, 0x2e, 0x35, 0x35, 0x2e, 0x39, 0x2e, 0x31, 0x32, 0x38,
- 0x2f, 0x32, 0x35, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x3a, 0x73, 0x70, 0x66, 0x2e,
- 0x70, 0x72, 0x6f, 0x74, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x6f, 0x75, 0x74, 0x6c, 0x6f,
- 0x6f, 0x6b, 0x2e, 0x63, 0x6f, 0x6d, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x3a, 0x73,
- 0x70, 0x66, 0x2d, 0x61, 0x2e, 0x68, 0x6f, 0x74, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x63, 0x6f, 0x6d,
- 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x3a, 0x5f, 0x73, 0x70, 0x66, 0x2d, 0x73, 0x73,
- 0x67, 0x2d, 0x62, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x2e, 0x63, 0x6f,
- 0x6d, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x3a, 0x5f, 0x73, 0x70, 0x66, 0x2d, 0x73,
- 0x73, 0x67, 0x2d, 0x63, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x2e, 0x63,
- 0x6f, 0x6d, 0x20, 0x7e, 0x61, 0x6c, 0x6c, 0xc0, 0x0c, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x01,
- 0x2c, 0x00, 0x45, 0x44, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2d, 0x73, 0x69, 0x74, 0x65, 0x2d,
- 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x30, 0x69, 0x4c,
- 0x57, 0x68, 0x49, 0x4d, 0x68, 0x58, 0x45, 0x6b, 0x65, 0x57, 0x77, 0x57, 0x66, 0x46, 0x55, 0x34,
- 0x75, 0x72, 0x73, 0x54, 0x6e, 0x2d, 0x5f, 0x4f, 0x76, 0x6f, 0x4f, 0x6a, 0x61, 0x41, 0x30, 0x4c,
- 0x72, 0x37, 0x50, 0x67, 0x31, 0x73, 0x45, 0x4d, 0xc0, 0x0c, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02,
- 0xa3, 0x00, 0x00, 0x0e, 0x03, 0x6e, 0x73, 0x32, 0x04, 0x6d, 0x73, 0x66, 0x74, 0x03, 0x6e, 0x65,
- 0x74, 0x00, 0xc0, 0x0c, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, 0xa3, 0x00, 0x00, 0x06, 0x03, 0x6e,
- 0x73, 0x34, 0xc1, 0xae, 0xc0, 0x0c, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, 0xa3, 0x00, 0x00, 0x06,
- 0x03, 0x6e, 0x73, 0x31, 0xc1, 0xae, 0xc0, 0x0c, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, 0xa3, 0x00,
- 0x00, 0x06, 0x03, 0x6e, 0x73, 0x33, 0xc1, 0xae, 0xc0, 0x0c, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02,
- 0xa3, 0x00, 0x00, 0x15, 0x04, 0x6e, 0x73, 0x31, 0x61, 0x0d,
-}
-
-func TestPacketDNSPanic7(t *testing.T) {
- p := gopacket.NewPacket(testPacketDNSPanic7, LinkTypeEthernet, testDecodeOptions)
- if errLayer := p.ErrorLayer(); errLayer == nil {
- t.Error("No error layer on invalid DNS name")
- } else if err := errLayer.Error(); !strings.Contains(err.Error(), "resource record length exceeds data") {
- t.Errorf("unexpected error message: %v", err)
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/dot11_test.go b/vendor/github.com/google/gopacket/layers/dot11_test.go
deleted file mode 100644
index b0299fc..0000000
--- a/vendor/github.com/google/gopacket/layers/dot11_test.go
+++ /dev/null
@@ -1,495 +0,0 @@
-// Copyright 2014, Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "bytes"
- "net"
- "reflect"
- "testing"
-
- "github.com/google/gopacket"
-)
-
-// Generator: python layers/test_creator.py --layerType=LayerTypeRadioTap --linkType=LinkTypeIEEE80211Radio --name=Dot11%s ~/Downloads/mesh.pcap
-// http://wiki.wireshark.org/SampleCaptures#Sample_Captures
-
-// testPacketDot11CtrlCTS is the packet:
-// 09:28:41.830560 20604983us tsft short preamble 24.0 Mb/s 5240 MHz 11a -79dB signal -92dB noise antenna 1 Clear-To-Send RA:d8:a2:5e:97:61:c1
-// 0x0000: 0000 1900 6f08 0000 3768 3a01 0000 0000 ....o...7h:.....
-// 0x0010: 1230 7814 4001 b1a4 01c4 0094 00d8 a25e .0x.@..........^
-// 0x0020: 9761 c136 5095 8e .a.6P..
-
-var testPacketDot11CtrlCTS = []byte{
- 0x00, 0x00, 0x19, 0x00, 0x6f, 0x08, 0x00, 0x00, 0x37, 0x68, 0x3a, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x12, 0x30, 0x78, 0x14, 0x40, 0x01, 0xb1, 0xa4, 0x01, 0xc4, 0x00, 0x94, 0x00, 0xd8, 0xa2, 0x5e,
- 0x97, 0x61, 0xc1, 0x36, 0x50, 0x95, 0x8e,
-}
-
-func TestPacketDot11CtrlCTS(t *testing.T) {
- p := gopacket.NewPacket(testPacketDot11CtrlCTS, LinkTypeIEEE80211Radio, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeRadioTap, LayerTypeDot11}, t)
-
- if got, ok := p.Layer(LayerTypeRadioTap).(*RadioTap); ok {
- want := &RadioTap{
- BaseLayer: BaseLayer{
- Contents: []uint8{0x0, 0x0, 0x19, 0x0, 0x6f, 0x8, 0x0, 0x0, 0x37, 0x68, 0x3a, 0x1, 0x0, 0x0, 0x0, 0x0, 0x12, 0x30, 0x78, 0x14, 0x40, 0x1, 0xb1, 0xa4, 0x1},
- Payload: []uint8{0xc4, 0x0, 0x94, 0x0, 0xd8, 0xa2, 0x5e, 0x97, 0x61, 0xc1, 0x36, 0x50, 0x95, 0x8e},
- },
- Version: 0x0,
- Length: 0x19,
- Present: 0x86f,
- TSFT: 0x13a6837,
- Flags: 0x12,
- Rate: 0x30,
- ChannelFrequency: 0x1478,
- ChannelFlags: 0x140,
- FHSS: 0x0,
- DBMAntennaSignal: -79,
- DBMAntennaNoise: -92,
- LockQuality: 0x0,
- TxAttenuation: 0x0,
- DBTxAttenuation: 0x0,
- DBMTxPower: 0,
- Antenna: 1,
- DBAntennaSignal: 0x0,
- DBAntennaNoise: 0x0,
- }
-
- if !reflect.DeepEqual(got, want) {
- t.Errorf("RadioTap packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- }
-
- if got, ok := p.Layer(LayerTypeDot11).(*Dot11); ok {
- if !got.ChecksumValid() {
- t.Errorf("Dot11 packet processing failed:\nchecksum failed. got :\n%#v\n\n", got)
- }
-
- want := &Dot11{
- BaseLayer: BaseLayer{
- Contents: []uint8{0xc4, 0x0, 0x94, 0x0, 0xd8, 0xa2, 0x5e, 0x97, 0x61, 0xc1},
- Payload: []uint8{},
- },
- Type: Dot11TypeCtrlCTS,
- Proto: 0x0,
- Flags: 0x0,
- DurationID: 0x94,
- Address1: net.HardwareAddr{0xd8, 0xa2, 0x5e, 0x97, 0x61, 0xc1}, // check
- Address2: net.HardwareAddr(nil),
- Address3: net.HardwareAddr(nil),
- Address4: net.HardwareAddr(nil),
- Checksum: 0x8e955036,
- }
-
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Dot11 packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- }
-}
-
-func BenchmarkDecodePacketDot11CtrlCTS(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketDot11CtrlCTS, LinkTypeIEEE80211Radio, gopacket.NoCopy)
- }
-}
-
-// testPacketDot11MgmtBeacon is the packet:
-// 15:44:56.531833 6.0 Mb/s 2412 MHz 11g -81dB signal antenna 5 Beacon (Wi2) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS CH: 1
-// 0x0000: 0000 1200 2e48 0000 100c 6c09 c000 af05 .....H....l.....
-// 0x0010: 0000 8000 0000 ffff ffff ffff c08a de01 ................
-// 0x0020: 11b8 c08a de01 11b8 f097 80f1 30bc 1300 ............0...
-// 0x0030: 0000 6400 2104 0003 5769 3201 088c 1298 ..d.!...Wi2.....
-// 0x0040: 24b0 4860 6c03 0101 0504 0001 0000 2a01 $.H`l.........*.
-// 0x0050: 00dd 1800 50f2 0201 0181 0007 a400 0023 ....P..........#
-// 0x0060: a400 0042 435e 0062 322f 00dd 1e00 904c ...BC^.b2/.....L
-// 0x0070: 338c 011b ffff 0000 0000 0000 0000 0000 3...............
-// 0x0080: 1000 0000 0000 0000 0000 002d 1a8c 011b ...........-....
-// 0x0090: ffff 0000 0000 0000 0000 0000 1000 0000 ................
-// 0x00a0: 0000 0000 0000 00dd 1a00 904c 3401 0000 ...........L4...
-// 0x00b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-// 0x00c0: 0000 003d 1601 0000 0000 0000 0000 0000 ...=............
-// 0x00d0: 0000 0000 0000 0000 0000 007f 0400 0000 ................
-// 0x00e0: 00dd 0800 1392 0100 0185 0094 0b90 15 ...............
-var testPacketDot11MgmtBeacon = []byte{
- 0x00, 0x00, 0x12, 0x00, 0x2e, 0x48, 0x00, 0x00, 0x10, 0x0c, 0x6c, 0x09, 0xc0, 0x00, 0xaf, 0x05,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x8a, 0xde, 0x01,
- 0x11, 0xb8, 0xc0, 0x8a, 0xde, 0x01, 0x11, 0xb8, 0xf0, 0x97, 0x80, 0xf1, 0x30, 0xbc, 0x13, 0x00,
- 0x00, 0x00, 0x64, 0x00, 0x21, 0x04, 0x00, 0x03, 0x57, 0x69, 0x32, 0x01, 0x08, 0x8c, 0x12, 0x98,
- 0x24, 0xb0, 0x48, 0x60, 0x6c, 0x03, 0x01, 0x01, 0x05, 0x04, 0x00, 0x01, 0x00, 0x00, 0x2a, 0x01,
- 0x00, 0xdd, 0x18, 0x00, 0x50, 0xf2, 0x02, 0x01, 0x01, 0x81, 0x00, 0x07, 0xa4, 0x00, 0x00, 0x23,
- 0xa4, 0x00, 0x00, 0x42, 0x43, 0x5e, 0x00, 0x62, 0x32, 0x2f, 0x00, 0xdd, 0x1e, 0x00, 0x90, 0x4c,
- 0x33, 0x8c, 0x01, 0x1b, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x1a, 0x8c, 0x01, 0x1b,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdd, 0x1a, 0x00, 0x90, 0x4c, 0x34, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x3d, 0x16, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x04, 0x00, 0x00, 0x00,
- 0x00, 0xdd, 0x08, 0x00, 0x13, 0x92, 0x01, 0x00, 0x01, 0x85, 0x00, 0x94, 0x0b, 0x90, 0x15,
-}
-
-func TestPacketDot11MgmtBeacon(t *testing.T) {
- p := gopacket.NewPacket(testPacketDot11MgmtBeacon, LinkTypeIEEE80211Radio, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- expectedLayers := []gopacket.LayerType{LayerTypeRadioTap, LayerTypeDot11, LayerTypeDot11MgmtBeacon}
- for i := 0; i < 12; i++ {
- expectedLayers = append(expectedLayers, LayerTypeDot11InformationElement)
- }
- checkLayers(p, expectedLayers, t)
-
- if p.Layer(LayerTypeDot11).(*Dot11).SequenceNumber != 2431 {
- t.Error("dot11 invalid sequence number")
- }
- if p.Layer(LayerTypeDot11).(*Dot11).FragmentNumber != 0 {
- t.Error("dot11 invalid fragment number")
- }
- if _, ok := p.Layer(LayerTypeDot11MgmtBeacon).(*Dot11MgmtBeacon); !ok {
- t.Errorf("dot11 management beacon frame was expected")
- }
-}
-
-func BenchmarkDecodePacketDot11MgmtBeacon(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketDot11MgmtBeacon, LinkTypeIEEE80211Radio, gopacket.NoCopy)
- }
-}
-
-// testPacketDot11DataQOSData is the packet:
-// 06:14:27.838634 638790765us tsft short preamble 54.0 Mb/s -51dB signal -96dB noise antenna 2 5180 MHz 11a CF +QoS ARP, Request who-has 140.180.51.68 tell 169.254.247.0, length 28
-// 0x0000: 0000 2000 6708 0400 6d2c 1326 0000 0000 ....g...m,.&....
-// 0x0010: 226c cda0 0200 0000 4001 0000 3c14 2411 "l......@...<.$.
-// 0x0020: 8801 2c00 0603 7f07 a016 0019 e3d3 5352 ..,...........SR
-// 0x0030: ffff ffff ffff 5064 0000 50aa aaaa 0300 ......Pd..P.....
-// 0x0040: 0000 0806 0001 0800 0604 0001 0019 e3d3 ................
-// 0x0050: 5352 a9fe f700 0000 0000 0000 8cb4 3344 SR............3D
-var testPacketDot11DataQOSData = []byte{
- 0x00, 0x00, 0x20, 0x00, 0x67, 0x08, 0x04, 0x00, 0x6d, 0x2c, 0x13, 0x26, 0x00, 0x00, 0x00, 0x00,
- 0x22, 0x6c, 0xcd, 0xa0, 0x02, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x3c, 0x14, 0x24, 0x11,
- 0x88, 0x01, 0x2c, 0x00, 0x06, 0x03, 0x7f, 0x07, 0xa0, 0x16, 0x00, 0x19, 0xe3, 0xd3, 0x53, 0x52,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x50, 0x64, 0x00, 0x00, 0x50, 0xaa, 0xaa, 0xaa, 0x03, 0x00,
- 0x00, 0x00, 0x08, 0x06, 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0x00, 0x19, 0xe3, 0xd3,
- 0x53, 0x52, 0xa9, 0xfe, 0xf7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0xb4, 0x33, 0x44,
-}
-
-func TestPacketDot11DataQOSData(t *testing.T) {
- p := gopacket.NewPacket(testPacketDot11DataQOSData, LinkTypeIEEE80211Radio, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeRadioTap, LayerTypeDot11, LayerTypeDot11DataQOSData, LayerTypeDot11Data, LayerTypeLLC, LayerTypeSNAP, LayerTypeARP}, t)
-
- if got, ok := p.Layer(LayerTypeARP).(*ARP); ok {
- want := &ARP{BaseLayer: BaseLayer{
- Contents: []uint8{0x0, 0x1, 0x8, 0x0, 0x6, 0x4, 0x0, 0x1, 0x0, 0x19, 0xe3, 0xd3, 0x53, 0x52, 0xa9, 0xfe, 0xf7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8c, 0xb4, 0x33, 0x44},
- Payload: []uint8{},
- },
- AddrType: 0x1,
- Protocol: 0x800,
- HwAddressSize: 0x6,
- ProtAddressSize: 0x4,
- Operation: 0x1,
- SourceHwAddress: []uint8{0x0, 0x19, 0xe3, 0xd3, 0x53, 0x52},
- SourceProtAddress: []uint8{0xa9, 0xfe, 0xf7, 0x0},
- DstHwAddress: []uint8{0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
- DstProtAddress: []uint8{0x8c, 0xb4, 0x33, 0x44},
- }
-
- if !reflect.DeepEqual(got, want) {
- t.Errorf("ARP packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- }
-}
-func BenchmarkDecodePacketDot11DataQOSData(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketDot11DataQOSData, LinkTypeIEEE80211Radio, gopacket.NoCopy)
- }
-}
-
-// testPacketDot11MgmtAction is the packet:
-// 15:54:43.236460 1.0 Mb/s 2412 MHz 11b -67dB signal antenna 5 Action (8e:3a:e3:44:ac:c6): Spectrum Management Act#4
-// 0x0000: 0000 1200 2e48 0000 1002 6c09 a000 bd05 .....H....l.....
-// 0x0010: 0000 d000 0000 ffff ffff ffff 8e3a e344 .............:.D
-// 0x0020: acc6 8e3a e344 acc6 001b 0004 2503 0001 ...:.D......%...
-// 0x0030: 0055 39f0 33 .U9.3
-var testPacketDot11MgmtAction = []byte{
- 0x00, 0x00, 0x12, 0x00, 0x2e, 0x48, 0x00, 0x00, 0x10, 0x02, 0x6c, 0x09, 0xa0, 0x00, 0xbd, 0x05,
- 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8e, 0x3a, 0xe3, 0x44,
- 0xac, 0xc6, 0x8e, 0x3a, 0xe3, 0x44, 0xac, 0xc6, 0x00, 0x1b, 0x00, 0x04, 0x25, 0x03, 0x00, 0x01,
- 0x00, 0x55, 0x39, 0xf0, 0x33,
-}
-
-func TestPacketDot11MgmtAction(t *testing.T) {
- p := gopacket.NewPacket(testPacketDot11MgmtAction, LinkTypeIEEE80211Radio, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeRadioTap, LayerTypeDot11, LayerTypeDot11MgmtAction}, t)
- if got, ok := p.Layer(LayerTypeDot11).(*Dot11); !ok {
- t.Errorf("dot11 frame was not parsed")
- } else if !got.ChecksumValid() {
- t.Errorf("Dot11 packet processing failed: checksum failed")
- }
- if got, ok := p.Layer(LayerTypeDot11MgmtAction).(*Dot11MgmtAction); !ok {
- t.Errorf("management action frame was not parsed")
- } else if got.Contents[0] != 0 {
- t.Errorf("action category was not spectrum management")
- }
-}
-
-func BenchmarkDecodePacketDot11MgmtAction(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketDot11MgmtAction, LinkTypeIEEE80211Radio, gopacket.NoCopy)
- }
-}
-
-// testPacketDot11CtrlAck is the packet:
-// 06:14:27.838669 638758038us tsft short preamble 24.0 Mb/s -39dB signal -96dB noise antenna 2 5180 MHz 11a Acknowledgment RA:00:19:e3:d3:53:52
-// 0x0000: 0000 2000 6708 0400 96ac 1226 0000 0000 ....g......&....
-// 0x0010: 2230 d9a0 0200 0000 4001 0000 3c14 2411 "0......@...<.$.
-// 0x0020: d400 0000 0019 e3d3 5352 46e9 7687 ........SRF.v.
-var testPacketDot11CtrlAck = []byte{
- 0x00, 0x00, 0x20, 0x00, 0x67, 0x08, 0x04, 0x00, 0x96, 0xac, 0x12, 0x26, 0x00, 0x00, 0x00, 0x00,
- 0x32, 0x30, 0xd9, 0xa0, 0x02, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x3c, 0x14, 0x24, 0x11,
- 0xd4, 0x00, 0x00, 0x00, 0x00, 0x19, 0xe3, 0xd3, 0x53, 0x52, 0x46, 0xe9, 0x76, 0x87,
-}
-
-func TestPacketDot11CtrlAck(t *testing.T) {
- p := gopacket.NewPacket(testPacketDot11CtrlAck, LinkTypeIEEE80211Radio, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeRadioTap, LayerTypeDot11}, t)
-
- if got, ok := p.Layer(LayerTypeDot11).(*Dot11); ok {
- if !got.ChecksumValid() {
- t.Errorf("Dot11 packet processing failed:\nchecksum failed. got :\n%#v\n\n", got)
- }
- }
-
- if got, ok := p.Layer(LayerTypeDot11).(*Dot11); ok {
- if !got.ChecksumValid() {
- t.Errorf("Dot11 packet processing failed:\nchecksum failed. got :\n%#v\n\n", got)
- }
- want := &Dot11{
- BaseLayer: BaseLayer{
- Contents: []uint8{0xd4, 0x0, 0x0, 0x0, 0x0, 0x19, 0xe3, 0xd3, 0x53, 0x52},
- Payload: []uint8{},
- },
- Type: Dot11TypeCtrlAck,
- Proto: 0x0,
- Flags: 0x0,
- DurationID: 0x0,
- Address1: net.HardwareAddr{0x0, 0x19, 0xe3, 0xd3, 0x53, 0x52},
- Address2: net.HardwareAddr(nil),
- Address3: net.HardwareAddr(nil),
- Address4: net.HardwareAddr(nil),
- Checksum: 0x8776e946,
- }
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Dot11 packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- }
-}
-func BenchmarkDecodePacketDot11CtrlAck(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketDot11CtrlAck, LinkTypeIEEE80211Radio, gopacket.NoCopy)
- }
-}
-
-// testPacketDot11DataARP is the packet:
-// 06:14:11.512316 622463798us tsft short preamble 6.0 Mb/s -39dB signal -96dB noise antenna 2 5180 MHz 11a ARP, Request who-has 67.8.14.54 tell 169.254.247.0, length 28
-// 0x0000: 0000 2000 6708 0400 360b 1a25 0000 0000 ....g...6..%....
-// 0x0010: 220c d9a0 0200 0000 4001 0000 3c14 2411 ".......@...<.$.
-// 0x0020: 0802 0000 ffff ffff ffff 0603 7f07 a016 ................
-// 0x0030: 0019 e3d3 5352 e07f aaaa 0300 0000 0806 ....SR..........
-// 0x0040: 0001 0800 0604 0001 0019 e3d3 5352 a9fe ............SR..
-// 0x0050: f700 0000 0000 0000 4308 0e36 ........C..6
-var testPacketDot11DataARP = []byte{
- 0x00, 0x00, 0x20, 0x00, 0x67, 0x08, 0x04, 0x00, 0x36, 0x0b, 0x1a, 0x25, 0x00, 0x00, 0x00, 0x00,
- 0x22, 0x0c, 0xd9, 0xa0, 0x02, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x3c, 0x14, 0x24, 0x11,
- 0x08, 0x02, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x06, 0x03, 0x7f, 0x07, 0xa0, 0x16,
- 0x00, 0x19, 0xe3, 0xd3, 0x53, 0x52, 0xe0, 0x7f, 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x08, 0x06,
- 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0x00, 0x19, 0xe3, 0xd3, 0x53, 0x52, 0xa9, 0xfe,
- 0xf7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x08, 0x0e, 0x36,
-}
-
-func TestPacketDot11DataARP(t *testing.T) {
- p := gopacket.NewPacket(testPacketDot11DataARP, LinkTypeIEEE80211Radio, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeRadioTap, LayerTypeDot11, LayerTypeDot11Data, LayerTypeLLC, LayerTypeSNAP, LayerTypeARP}, t)
-
- if got, ok := p.Layer(LayerTypeARP).(*ARP); ok {
- want := &ARP{
- BaseLayer: BaseLayer{
- Contents: []uint8{0x0, 0x1, 0x8, 0x0, 0x6, 0x4, 0x0, 0x1, 0x0, 0x19, 0xe3, 0xd3, 0x53, 0x52, 0xa9, 0xfe, 0xf7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x43, 0x8, 0xe, 0x36},
- Payload: []uint8{},
- },
- AddrType: 0x1,
- Protocol: 0x800,
- HwAddressSize: 0x6,
- ProtAddressSize: 0x4,
- Operation: 0x1,
- SourceHwAddress: []uint8{0x0, 0x19, 0xe3, 0xd3, 0x53, 0x52},
- SourceProtAddress: []uint8{0xa9, 0xfe, 0xf7, 0x0},
- DstHwAddress: []uint8{0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
- DstProtAddress: []uint8{0x43, 0x8, 0xe, 0x36},
- }
-
- if !reflect.DeepEqual(got, want) {
- t.Errorf("ARP packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- }
-}
-
-func BenchmarkDecodePacketDot11DataARP(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketDot11DataARP, LinkTypeIEEE80211Radio, gopacket.NoCopy)
- }
-}
-
-// testPacketDot11DataIP is the packet:
-// 06:14:21.388622 632340487us tsft short preamble 6.0 Mb/s -40dB signal -96dB noise antenna 1 5180 MHz 11a IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:19:e3:d3:53:52, length 300
-// 0x0000: 0000 2000 6708 0400 07c0 b025 0000 0000 ....g......%....
-// 0x0010: 220c d8a0 0100 0000 4001 0000 3c14 2411 ".......@...<.$.
-// 0x0020: 0802 0000 ffff ffff ffff 0603 7f07 a016 ................
-// 0x0030: 0019 e3d3 5352 4095 aaaa 0300 0000 0800 ....SR@.........
-// 0x0040: 4500 0148 c514 0000 ff11 f590 0000 0000 E..H............
-// 0x0050: ffff ffff 0044 0043 0134 2b39 0101 0600 .....D.C.4+9....
-// 0x0060: 131f 8c43 003c 0000 0000 0000 0000 0000 ...C.<..........
-// 0x0070: 0000 0000 0000 0000 0019 e3d3 5352 0000 ............SR..
-// 0x0080: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-// 0x0090: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-// 0x00a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-// 0x00b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-// 0x00c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-// 0x00d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-// 0x00e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-// 0x00f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-// 0x0100: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-// 0x0110: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-// 0x0120: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-// 0x0130: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-// 0x0140: 0000 0000 0000 0000 6382 5363 3501 0137 ........c.Sc5..7
-// 0x0150: 0a01 0306 0f77 5ffc 2c2e 2f39 0205 dc3d .....w_.,./9...=
-// 0x0160: 0701 0019 e3d3 5352 3304 0076 a700 0c0b ......SR3..v....
-// 0x0170: 4d61 6369 6e74 6f73 682d 34ff 0000 0000 Macintosh-4.....
-// 0x0180: 0000 0000 0000 0000 ........
-var testPacketDot11DataIP = []byte{
- 0x00, 0x00, 0x20, 0x00, 0x67, 0x08, 0x04, 0x00, 0x07, 0xc0, 0xb0, 0x25, 0x00, 0x00, 0x00, 0x00,
- 0x22, 0x0c, 0xd8, 0xa0, 0x01, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x3c, 0x14, 0x24, 0x11,
- 0x08, 0x02, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x06, 0x03, 0x7f, 0x07, 0xa0, 0x16,
- 0x00, 0x19, 0xe3, 0xd3, 0x53, 0x52, 0x40, 0x95, 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00,
- 0x45, 0x00, 0x01, 0x48, 0xc5, 0x14, 0x00, 0x00, 0xff, 0x11, 0xf5, 0x90, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x44, 0x00, 0x43, 0x01, 0x34, 0x2b, 0x39, 0x01, 0x01, 0x06, 0x00,
- 0x13, 0x1f, 0x8c, 0x43, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0xe3, 0xd3, 0x53, 0x52, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, 0x53, 0x63, 0x35, 0x01, 0x01, 0x37,
- 0x0a, 0x01, 0x03, 0x06, 0x0f, 0x77, 0x5f, 0xfc, 0x2c, 0x2e, 0x2f, 0x39, 0x02, 0x05, 0xdc, 0x3d,
- 0x07, 0x01, 0x00, 0x19, 0xe3, 0xd3, 0x53, 0x52, 0x33, 0x04, 0x00, 0x76, 0xa7, 0x00, 0x0c, 0x0b,
- 0x4d, 0x61, 0x63, 0x69, 0x6e, 0x74, 0x6f, 0x73, 0x68, 0x2d, 0x34, 0xff, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-}
-
-func TestPacketDot11DataIP(t *testing.T) {
- p := gopacket.NewPacket(testPacketDot11DataIP, LinkTypeIEEE80211Radio, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeRadioTap, LayerTypeDot11, LayerTypeDot11Data, LayerTypeLLC, LayerTypeSNAP, LayerTypeIPv4, LayerTypeUDP, LayerTypeDHCPv4}, t)
-}
-func BenchmarkDecodePacketDot11DataIP(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketDot11DataIP, LinkTypeIEEE80211Radio, gopacket.NoCopy)
- }
-}
-
-// Encrypted
-
-/// testPacketP6196 is the packet:
-// 09:28:41.830631 20605036us tsft wep -69dB signal -92dB noise antenna 1 5240 MHz 11a ht/40- 162.0 Mb/s MCS 12 40 MHz lon GI mixed BCC FEC [bit 20] CF +QoS Data IV:50a9 Pad 20 KeyID 0
-// 0x0000: 0000 3000 6b08 1c00 6c68 3a01 0000 0000 ..0.k...lh:.....
-// 0x0010: 1400 7814 4001 bba4 0160 0e1a 4001 0400 ..x.@....`..@...
-// 0x0020: 7814 3022 1f01 0cff b10d 0000 0400 0000 x.0"............
-// 0x0030: 8841 2c00 0025 9c42 c262 d8a2 5e97 61c1 .A,..%.B.b..^.a.
-// 0x0040: 0025 9c42 c25f 10db 0000 a950 0020 0000 .%.B._.....P....
-// 0x0050: 0000 f8ab a97e 3fbd d6e1 785b 0040 5f15 .....~?...x[.@_.
-// 0x0060: 7123 8711 bd1f ffb9 e5b3 84bb ec2a 0a90 q#...........*..
-// 0x0070: d0a0 1a6f 9033 1083 5179 a0da f833 3a00 ...o.3..Qy...3:.
-// 0x0080: 5471 f596 539b 1823 a33c 4908 545c 266a Tq..S..#.<I.T\&j
-// 0x0090: 8540 515a 1da9 c49e a85a fbf7 de09 7f9c .@QZ.....Z......
-// 0x00a0: 6f35 0b8b 6831 2c10 43dc 8983 b1d9 dd29 o5..h1,.C......)
-// 0x00b0: 7395 65b9 4b43 b391 16ec 4201 86c9 ca s.e.KC....B....
-var testPacketP6196 = []byte{
- 0x00, 0x00, 0x30, 0x00, 0x6b, 0x08, 0x1c, 0x00, 0x6c, 0x68, 0x3a, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x14, 0x00, 0x78, 0x14, 0x40, 0x01, 0xbb, 0xa4, 0x01, 0x60, 0x0e, 0x1a, 0x40, 0x01, 0x04, 0x00,
- 0x78, 0x14, 0x30, 0x22, 0x1f, 0x01, 0x0c, 0xff, 0xb1, 0x0d, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x88, 0x41, 0x2c, 0x00, 0x00, 0x25, 0x9c, 0x42, 0xc2, 0x62, 0xd8, 0xa2, 0x5e, 0x97, 0x61, 0xc1,
- 0x00, 0x25, 0x9c, 0x42, 0xc2, 0x5f, 0x10, 0xdb, 0x00, 0x00, 0xa9, 0x50, 0x00, 0x20, 0x00, 0x00,
- 0x00, 0x00, 0xf8, 0xab, 0xa9, 0x7e, 0x3f, 0xbd, 0xd6, 0xe1, 0x78, 0x5b, 0x00, 0x40, 0x5f, 0x15,
- 0x71, 0x23, 0x87, 0x11, 0xbd, 0x1f, 0xff, 0xb9, 0xe5, 0xb3, 0x84, 0xbb, 0xec, 0x2a, 0x0a, 0x90,
- 0xd0, 0xa0, 0x1a, 0x6f, 0x90, 0x33, 0x10, 0x83, 0x51, 0x79, 0xa0, 0xda, 0xf8, 0x33, 0x3a, 0x00,
- 0x54, 0x71, 0xf5, 0x96, 0x53, 0x9b, 0x18, 0x23, 0xa3, 0x3c, 0x49, 0x08, 0x54, 0x5c, 0x26, 0x6a,
- 0x85, 0x40, 0x51, 0x5a, 0x1d, 0xa9, 0xc4, 0x9e, 0xa8, 0x5a, 0xfb, 0xf7, 0xde, 0x09, 0x7f, 0x9c,
- 0x6f, 0x35, 0x0b, 0x8b, 0x68, 0x31, 0x2c, 0x10, 0x43, 0xdc, 0x89, 0x83, 0xb1, 0xd9, 0xdd, 0x29,
- 0x73, 0x95, 0x65, 0xb9, 0x4b, 0x43, 0xb3, 0x91, 0x16, 0xec, 0x42, 0x01, 0x86, 0xc9, 0xca,
-}
-
-func TestPacketP6196(t *testing.T) {
- p := gopacket.NewPacket(testPacketP6196, LinkTypeIEEE80211Radio, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
-
- checkLayers(p, []gopacket.LayerType{LayerTypeRadioTap, LayerTypeDot11, LayerTypeDot11WEP}, t)
-}
-
-func BenchmarkDecodePacketP6196(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketP6196, LinkTypeIEEE80211Radio, gopacket.NoCopy)
- }
-}
-
-func TestInformationElement(t *testing.T) {
- bin := []byte{
- 0, 0,
- 0, 2, 1, 3,
- 221, 5, 1, 2, 3, 4, 5,
- }
- pkt := gopacket.NewPacket(bin, LayerTypeDot11InformationElement, gopacket.NoCopy)
-
- buf := gopacket.NewSerializeBuffer()
- var sLayers []gopacket.SerializableLayer
- for _, l := range pkt.Layers() {
- sLayers = append(sLayers, l.(*Dot11InformationElement))
- }
- if err := gopacket.SerializeLayers(buf, gopacket.SerializeOptions{}, sLayers...); err != nil {
- t.Error(err.Error())
- }
- if !bytes.Equal(bin, buf.Bytes()) {
- t.Error("build failed")
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/dot1q_test.go b/vendor/github.com/google/gopacket/layers/dot1q_test.go
deleted file mode 100644
index 4a409c7..0000000
--- a/vendor/github.com/google/gopacket/layers/dot1q_test.go
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-package layers
-
-import (
- "fmt"
- "reflect"
- "testing"
-
- "github.com/google/gopacket"
-)
-
-// test harness to ensure the dot1q layer can be encoded/decoded properly
-// return error if decoded data not match.
-func testEncodeDecodeDot1Q(dot1Q *Dot1Q) error {
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{}
- expectedDot1Q := dot1Q
-
- err := dot1Q.SerializeTo(buf, opts)
- if err != nil {
- return err
- }
-
- newDot1q := &Dot1Q{}
- err = newDot1q.DecodeFromBytes(buf.Bytes(), gopacket.NilDecodeFeedback)
- if err != nil {
- return err
- }
- newDot1q.BaseLayer = BaseLayer{}
-
- if !reflect.DeepEqual(expectedDot1Q, newDot1q) {
- return fmt.Errorf("Expect %v actual %v", expectedDot1Q, newDot1q)
- }
- return nil
-
-}
-
-// Test to ensure what has been encode can be decoded
-func TestEncodeDecodeDot1Q(t *testing.T) {
- dot1Qs := []*Dot1Q{
- &Dot1Q{
- Priority: uint8(3),
- VLANIdentifier: uint16(30),
- },
- &Dot1Q{
- Priority: uint8(0x07),
- DropEligible: true,
- VLANIdentifier: uint16(0xFFF),
- },
- }
-
- for i, curTest := range dot1Qs {
- err := testEncodeDecodeDot1Q(curTest)
- if err != nil {
- t.Error("Error with item ", i, " with error message :", err)
- }
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/endpoints_test.go b/vendor/github.com/google/gopacket/layers/endpoints_test.go
deleted file mode 100644
index 906762a..0000000
--- a/vendor/github.com/google/gopacket/layers/endpoints_test.go
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2017, Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "net"
- "testing"
-
- "github.com/google/gopacket"
-)
-
-func TestNewIPEndpoint(t *testing.T) {
- cases := []struct {
- ip net.IP
- endpointType gopacket.EndpointType
- }{
- {net.ParseIP("192.168.0.1").To4(), EndpointIPv4},
- {net.ParseIP("192.168.0.1").To16(), EndpointIPv4},
- {net.ParseIP("2001:0db8:85a3:0000:0000:8a2e:0370:7334"), EndpointIPv6},
- }
-
- for _, c := range cases {
- endpoint := NewIPEndpoint(c.ip)
- if endpoint == gopacket.InvalidEndpoint {
- t.Errorf("Failed to create an IP endpoint for %s (%d-bytes)",
- c.ip, len(c.ip))
- }
- if endpoint.EndpointType() != c.endpointType {
- t.Errorf("Wrong endpoint type created for %s (%d-bytes): expected %s, got %s",
- c.ip, len(c.ip), c.endpointType, endpoint.EndpointType())
- }
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/geneve_test.go b/vendor/github.com/google/gopacket/layers/geneve_test.go
deleted file mode 100644
index ee34d52..0000000
--- a/vendor/github.com/google/gopacket/layers/geneve_test.go
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2016 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "reflect"
- "testing"
-
- "github.com/google/gopacket"
-)
-
-var testPacketGeneve1 = []byte{
- 0x00, 0x04, 0x00, 0x01, 0x00, 0x06, 0xfa, 0x16, 0x3e, 0x23, 0xd3, 0x42,
- 0x00, 0x00, 0x08, 0x00, 0x45, 0x00, 0x00, 0x86, 0x87, 0x39, 0x40, 0x00,
- 0x40, 0x11, 0x31, 0x35, 0xc0, 0xa8, 0x00, 0x53, 0xc0, 0xa8, 0x00, 0x55,
- 0x31, 0x57, 0x17, 0xc1, 0x00, 0x72, 0x00, 0x00, 0x00, 0x00, 0x65, 0x58,
- 0x00, 0x00, 0x00, 0x00, 0xba, 0x09, 0x60, 0x5f, 0xa0, 0x91, 0xa2, 0xfe,
- 0x54, 0x48, 0x88, 0x51, 0x08, 0x00, 0x45, 0x00, 0x00, 0x54, 0x01, 0xf6,
- 0x40, 0x00, 0x40, 0x01, 0xb7, 0x5f, 0xc0, 0xa8, 0x00, 0x01, 0xc0, 0xa8,
- 0x00, 0x02, 0x08, 0x00, 0x79, 0xdf, 0x0c, 0xfa, 0x63, 0xc4, 0x03, 0x0b,
- 0x50, 0x58, 0x00, 0x00, 0x00, 0x00, 0xee, 0x2b, 0x0d, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
- 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
- 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
- 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
-}
-
-var testPacketGeneve2 = []byte{
- 0x12, 0xbe, 0x4e, 0xb6, 0xa7, 0xc7, 0x02, 0x88, 0x0a, 0x81, 0xbd, 0x6d,
- 0x08, 0x00, 0x45, 0x00, 0x00, 0x86, 0x20, 0xf2, 0x00, 0x00, 0x40, 0x11,
- 0x01, 0x52, 0xac, 0x10, 0x00, 0x01, 0xac, 0x10, 0x00, 0x02, 0x40, 0xa6,
- 0x17, 0xc1, 0x00, 0x72, 0x00, 0x00, 0x00, 0x00, 0x65, 0x58, 0x00, 0x00,
- 0x0a, 0x00, 0xd2, 0x8c, 0xdb, 0x12, 0x53, 0xd5, 0x8e, 0xab, 0xa2, 0xa5,
- 0x02, 0xf7, 0x08, 0x00, 0x45, 0x00, 0x00, 0x54, 0x38, 0x1a, 0x40, 0x00,
- 0x40, 0x01, 0x81, 0x3b, 0xc0, 0xa8, 0x00, 0x01, 0xc0, 0xa8, 0x00, 0x02,
- 0x08, 0x00, 0xdd, 0x9d, 0x7e, 0xde, 0x02, 0xc3, 0xcb, 0x07, 0x51, 0x58,
- 0x00, 0x00, 0x00, 0x00, 0xba, 0x8d, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
- 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
- 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
- 0x34, 0x35, 0x36, 0x37,
-}
-
-func TestDecodeGeneve1(t *testing.T) {
- p := gopacket.NewPacket(testPacketGeneve1, LinkTypeLinuxSLL, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{
- LayerTypeLinuxSLL, LayerTypeIPv4, LayerTypeUDP, LayerTypeGeneve,
- LayerTypeEthernet, LayerTypeIPv4, LayerTypeICMPv4, gopacket.LayerTypePayload,
- }, t)
- if got, ok := p.Layer(LayerTypeGeneve).(*Geneve); ok {
- want := &Geneve{
- BaseLayer: BaseLayer{
- Contents: testPacketGeneve1[44:52],
- Payload: testPacketGeneve1[52:150],
- },
- Version: 0x0,
- OptionsLength: 0x0,
- OAMPacket: false,
- CriticalOption: false,
- Protocol: EthernetTypeTransparentEthernetBridging,
- VNI: 0x0,
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("Geneve layer mismatch, \nwant %#v\ngot %#v\n", want, got)
- }
- }
-}
-
-func TestDecodeGeneve2(t *testing.T) {
- p := gopacket.NewPacket(testPacketGeneve2, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{
- LayerTypeEthernet, LayerTypeIPv4, LayerTypeUDP, LayerTypeGeneve,
- LayerTypeEthernet, LayerTypeIPv4, LayerTypeICMPv4, gopacket.LayerTypePayload,
- }, t)
- if got, ok := p.Layer(LayerTypeGeneve).(*Geneve); ok {
- want := &Geneve{
- BaseLayer: BaseLayer{
- Contents: testPacketGeneve2[42:50],
- Payload: testPacketGeneve2[50:148],
- },
- Version: 0x0,
- OptionsLength: 0x0,
- OAMPacket: false,
- CriticalOption: false,
- Protocol: EthernetTypeTransparentEthernetBridging,
- VNI: 0xa,
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("Geneve layer mismatch, \nwant %#v\ngot %#v\n", want, got)
- }
- }
-}
-
-func BenchmarkDecodeGeneve1(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketGeneve1, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/gre_test.go b/vendor/github.com/google/gopacket/layers/gre_test.go
deleted file mode 100644
index af2e38e..0000000
--- a/vendor/github.com/google/gopacket/layers/gre_test.go
+++ /dev/null
@@ -1,389 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-package layers
-
-import (
- "fmt"
- "net"
- "reflect"
- "testing"
-
- "github.com/google/gopacket"
-)
-
-// testPacketGRE is the packet:
-// 15:08:08.003196 IP 192.168.1.1 > 192.168.1.2: GREv0, length 88: IP 172.16.1.1 > 172.16.2.1: ICMP echo request, id 4724, seq 1, length 64
-// 0x0000: 3a56 6b69 595e 8e7a 12c3 a971 0800 4500 :VkiY^.z...q..E.
-// 0x0010: 006c 843c 4000 402f 32d3 c0a8 0101 c0a8 .l.<@.@/2.......
-// 0x0020: 0102 0000 0800 4500 0054 0488 4000 4001 ......E..T..@.@.
-// 0x0030: dafe ac10 0101 ac10 0201 0800 82c4 1274 ...............t
-// 0x0040: 0001 c892 a354 0000 0000 380c 0000 0000 .....T....8.....
-// 0x0050: 0000 1011 1213 1415 1617 1819 1a1b 1c1d ................
-// 0x0060: 1e1f 2021 2223 2425 2627 2829 2a2b 2c2d ...!"#$%&'()*+,-
-// 0x0070: 2e2f 3031 3233 3435 3637 ./01234567
-var testPacketGRE = []byte{
- 0x3a, 0x56, 0x6b, 0x69, 0x59, 0x5e, 0x8e, 0x7a, 0x12, 0xc3, 0xa9, 0x71, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x6c, 0x84, 0x3c, 0x40, 0x00, 0x40, 0x2f, 0x32, 0xd3, 0xc0, 0xa8, 0x01, 0x01, 0xc0, 0xa8,
- 0x01, 0x02, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00, 0x00, 0x54, 0x04, 0x88, 0x40, 0x00, 0x40, 0x01,
- 0xda, 0xfe, 0xac, 0x10, 0x01, 0x01, 0xac, 0x10, 0x02, 0x01, 0x08, 0x00, 0x82, 0xc4, 0x12, 0x74,
- 0x00, 0x01, 0xc8, 0x92, 0xa3, 0x54, 0x00, 0x00, 0x00, 0x00, 0x38, 0x0c, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
- 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
- 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
-}
-
-func TestPacketGRE(t *testing.T) {
- p := gopacket.NewPacket(testPacketGRE, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeGRE, LayerTypeIPv4, LayerTypeICMPv4, gopacket.LayerTypePayload}, t)
- if got, ok := p.Layer(LayerTypeGRE).(*GRE); ok {
- want := &GRE{
- BaseLayer: BaseLayer{testPacketGRE[34:38], testPacketGRE[38:]},
- Protocol: EthernetTypeIPv4,
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("GRE layer mismatch, \nwant %#v\ngot %#v\n", want, got)
- }
- }
-}
-
-func BenchmarkDecodePacketGRE(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketGRE, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-var testIPv4OverGRE = []gopacket.SerializableLayer{
- &Ethernet{
- SrcMAC: net.HardwareAddr{142, 122, 18, 195, 169, 113},
- DstMAC: net.HardwareAddr{58, 86, 107, 105, 89, 94},
- EthernetType: EthernetTypeIPv4,
- },
- &IPv4{
- Version: 4,
- SrcIP: net.IP{192, 168, 1, 1},
- DstIP: net.IP{192, 168, 1, 2},
- Protocol: IPProtocolGRE,
- Flags: IPv4DontFragment,
- TTL: 64,
- Id: 33852,
- IHL: 5,
- },
- &GRE{
- Protocol: EthernetTypeIPv4,
- },
- &IPv4{
- Version: 4,
- SrcIP: net.IP{172, 16, 1, 1},
- DstIP: net.IP{172, 16, 2, 1},
- Protocol: IPProtocolICMPv4,
- Flags: IPv4DontFragment,
- TTL: 64,
- IHL: 5,
- Id: 1160,
- },
- &ICMPv4{
- TypeCode: CreateICMPv4TypeCode(ICMPv4TypeEchoRequest, 0),
- Id: 4724,
- Seq: 1,
- },
- gopacket.Payload{
- 0xc8, 0x92, 0xa3, 0x54, 0x00, 0x00, 0x00, 0x00, 0x38, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
- },
-}
-
-func TestIPv4OverGREEncode(t *testing.T) {
- b := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{
- ComputeChecksums: true,
- FixLengths: true,
- }
- if err := gopacket.SerializeLayers(b, opts, testIPv4OverGRE...); err != nil {
- t.Errorf("Unable to serialize: %v", err)
- }
- p := gopacket.NewPacket(b.Bytes(), LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeGRE, LayerTypeIPv4, LayerTypeICMPv4, gopacket.LayerTypePayload}, t)
- if got, want := b.Bytes(), testPacketGRE; !reflect.DeepEqual(want, got) {
- t.Errorf("Encoding mismatch, \nwant: %v\ngot %v\n", want, got)
- }
-}
-
-func BenchmarkEncodePacketGRE(b *testing.B) {
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{
- ComputeChecksums: true,
- FixLengths: true,
- }
- for i := 0; i < b.N; i++ {
- gopacket.SerializeLayers(buf, opts, testIPv4OverGRE...)
- buf.Clear()
- }
-}
-
-// testPacketEthernetOverGRE is the packet:
-// 11:01:38.124768 IP 192.168.1.1 > 192.168.1.2: GREv0, length 102: IP 172.16.1.1 > 172.16.1.2: ICMP echo request, id 3842, seq 1, length 64
-// 0x0000: ea6b 4cd3 5513 d6b9 d880 56ef 0800 4500 .kL.U.....V...E.
-// 0x0010: 007a 0acd 4000 402f ac34 c0a8 0101 c0a8 .z..@.@/.4......
-// 0x0020: 0102 0000 6558 aa6a 36e6 c630 6e32 3ec7 ....eX.j6..0n2>.
-// 0x0030: 9def 0800 4500 0054 d970 4000 4001 0715 ....E..T.p@.@...
-// 0x0040: ac10 0101 ac10 0102 0800 3f15 0f02 0001 ..........?.....
-// 0x0050: 82d9 b154 0000 0000 b5e6 0100 0000 0000 ...T............
-// 0x0060: 1011 1213 1415 1617 1819 1a1b 1c1d 1e1f ................
-// 0x0070: 2021 2223 2425 2627 2829 2a2b 2c2d 2e2f .!"#$%&'()*+,-./
-// 0x0080: 3031 3233 3435 3637 01234567
-var testPacketEthernetOverGRE = []byte{
- 0xea, 0x6b, 0x4c, 0xd3, 0x55, 0x13, 0xd6, 0xb9, 0xd8, 0x80, 0x56, 0xef, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x7a, 0x0a, 0xcd, 0x40, 0x00, 0x40, 0x2f, 0xac, 0x34, 0xc0, 0xa8, 0x01, 0x01, 0xc0, 0xa8,
- 0x01, 0x02, 0x00, 0x00, 0x65, 0x58, 0xaa, 0x6a, 0x36, 0xe6, 0xc6, 0x30, 0x6e, 0x32, 0x3e, 0xc7,
- 0x9d, 0xef, 0x08, 0x00, 0x45, 0x00, 0x00, 0x54, 0xd9, 0x70, 0x40, 0x00, 0x40, 0x01, 0x07, 0x15,
- 0xac, 0x10, 0x01, 0x01, 0xac, 0x10, 0x01, 0x02, 0x08, 0x00, 0x3f, 0x15, 0x0f, 0x02, 0x00, 0x01,
- 0x82, 0xd9, 0xb1, 0x54, 0x00, 0x00, 0x00, 0x00, 0xb5, 0xe6, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
-}
-
-func TestPacketEthernetOverGRE(t *testing.T) {
- p := gopacket.NewPacket(testPacketEthernetOverGRE, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeGRE, LayerTypeEthernet, LayerTypeIPv4, LayerTypeICMPv4, gopacket.LayerTypePayload}, t)
- if got, ok := p.Layer(LayerTypeGRE).(*GRE); ok {
- want := &GRE{
- BaseLayer: BaseLayer{testPacketEthernetOverGRE[34:38], testPacketEthernetOverGRE[38:]},
- Protocol: EthernetTypeTransparentEthernetBridging,
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("GRE layer mismatch, \nwant %#v\ngot %#v\n", want, got)
- }
- }
-}
-
-func BenchmarkDecodePacketEthernetOverGRE(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketEthernetOverGRE, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-var testEthernetOverGRE = []gopacket.SerializableLayer{
- &Ethernet{
- SrcMAC: net.HardwareAddr{0xd6, 0xb9, 0xd8, 0x80, 0x56, 0xef},
- DstMAC: net.HardwareAddr{0xea, 0x6b, 0x4c, 0xd3, 0x55, 0x13},
- EthernetType: EthernetTypeIPv4,
- },
- &IPv4{
- Version: 4,
- SrcIP: net.IP{192, 168, 1, 1},
- DstIP: net.IP{192, 168, 1, 2},
- Protocol: IPProtocolGRE,
- Flags: IPv4DontFragment,
- TTL: 64,
- Id: 2765,
- IHL: 5,
- },
- &GRE{
- Protocol: EthernetTypeTransparentEthernetBridging,
- },
- &Ethernet{
- SrcMAC: net.HardwareAddr{0x6e, 0x32, 0x3e, 0xc7, 0x9d, 0xef},
- DstMAC: net.HardwareAddr{0xaa, 0x6a, 0x36, 0xe6, 0xc6, 0x30},
- EthernetType: EthernetTypeIPv4,
- },
- &IPv4{
- Version: 4,
- SrcIP: net.IP{172, 16, 1, 1},
- DstIP: net.IP{172, 16, 1, 2},
- Protocol: IPProtocolICMPv4,
- Flags: IPv4DontFragment,
- TTL: 64,
- IHL: 5,
- Id: 55664,
- },
- &ICMPv4{
- TypeCode: CreateICMPv4TypeCode(ICMPv4TypeEchoRequest, 0),
- Id: 3842,
- Seq: 1,
- },
- gopacket.Payload{
- 0x82, 0xd9, 0xb1, 0x54, 0x00, 0x00, 0x00, 0x00, 0xb5, 0xe6, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
- },
-}
-
-func TestEthernetOverGREEncode(t *testing.T) {
- b := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{
- ComputeChecksums: true,
- FixLengths: true,
- }
- if err := gopacket.SerializeLayers(b, opts, testEthernetOverGRE...); err != nil {
- t.Errorf("Unable to serialize: %v", err)
- }
- p := gopacket.NewPacket(b.Bytes(), LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeGRE, LayerTypeEthernet, LayerTypeIPv4, LayerTypeICMPv4, gopacket.LayerTypePayload}, t)
- if got, want := b.Bytes(), testPacketEthernetOverGRE; !reflect.DeepEqual(want, got) {
- t.Errorf("Encoding mismatch, \nwant: %v\ngot %v\n", want, got)
- }
-}
-
-func BenchmarkEncodePacketEthernetOverGRE(b *testing.B) {
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{
- ComputeChecksums: true,
- FixLengths: true,
- }
- for i := 0; i < b.N; i++ {
- gopacket.SerializeLayers(buf, opts, testEthernetOverGRE...)
- buf.Clear()
- }
-}
-
-var testGREChecksum = map[uint16][]gopacket.SerializableLayer{
- 0x77ff: {
- &Ethernet{
- SrcMAC: net.HardwareAddr{0xc2, 0x00, 0x57, 0x75, 0x00, 0x00},
- DstMAC: net.HardwareAddr{0xc2, 0x01, 0x57, 0x75, 0x00, 0x00},
- EthernetType: EthernetTypeIPv4,
- },
- &IPv4{
- Version: 4,
- SrcIP: net.IP{10, 0, 0, 1},
- DstIP: net.IP{10, 0, 0, 2},
- Protocol: IPProtocolGRE,
- TTL: 255,
- Id: 10,
- IHL: 5,
- },
- &GRE{
- Protocol: EthernetTypeIPv4,
- ChecksumPresent: true,
- },
- &IPv4{
- Version: 4,
- SrcIP: net.IP{1, 1, 1, 1},
- DstIP: net.IP{2, 2, 2, 2},
- Protocol: IPProtocolICMPv4,
- TTL: 255,
- IHL: 5,
- Id: 10,
- },
- &ICMPv4{
- TypeCode: CreateICMPv4TypeCode(ICMPv4TypeEchoRequest, 0),
- Id: 2,
- Seq: 0,
- },
- gopacket.Payload{
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xbe, 0x70, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- },
- },
- 0x8475: {
- &Ethernet{
- SrcMAC: net.HardwareAddr{0xc2, 0x00, 0x57, 0x75, 0x00, 0x00},
- DstMAC: net.HardwareAddr{0xc2, 0x01, 0x57, 0x75, 0x00, 0x00},
- EthernetType: EthernetTypeIPv4,
- },
- &IPv4{
- Version: 4,
- SrcIP: net.IP{10, 0, 0, 1},
- DstIP: net.IP{10, 0, 0, 2},
- Protocol: IPProtocolGRE,
- TTL: 255,
- Id: 10,
- IHL: 5,
- },
- &GRE{
- Protocol: EthernetTypeIPv4,
- ChecksumPresent: true,
- },
- &IPv4{
- Version: 4,
- SrcIP: net.IP{2, 3, 4, 5},
- DstIP: net.IP{2, 3, 4, 50},
- Protocol: IPProtocolUDP,
- TTL: 1,
- IHL: 5,
- Flags: IPv4DontFragment,
- Id: 964,
- },
- &UDP{
- SrcPort: 41781,
- DstPort: 33434,
- },
- gopacket.Payload{
- 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
- 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
- },
- },
-}
-
-func TestGREChecksum(t *testing.T) {
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{
- ComputeChecksums: true,
- FixLengths: true,
- }
- for cksum, packet := range testGREChecksum {
- buf.Clear()
- if err := setNetworkLayer(packet); err != nil {
- t.Errorf("Failed to set network layer: %v", err)
- continue
- }
- if err := gopacket.SerializeLayers(buf, opts, packet...); err != nil {
- t.Errorf("Failed to serialize packet: %v", err)
- continue
- }
- p := gopacket.NewPacket(buf.Bytes(), LinkTypeEthernet, gopacket.Default)
- t.Log(p)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- continue
- }
- if got, ok := p.Layer(LayerTypeGRE).(*GRE); ok {
- if got.Checksum != cksum {
- t.Errorf("Incorrect checksum calculated for GRE packet: want %v, got %v", cksum, got.Checksum)
- }
- }
- }
-}
-
-func setNetworkLayer(layers []gopacket.SerializableLayer) error {
- type setNetworkLayerForChecksum interface {
- SetNetworkLayerForChecksum(gopacket.NetworkLayer) error
- }
- var l gopacket.NetworkLayer
- for _, layer := range layers {
- if n, ok := layer.(gopacket.NetworkLayer); ok {
- l = n
- }
- if s, ok := layer.(setNetworkLayerForChecksum); ok {
- if l == nil {
- return fmt.Errorf("no enclosing network layer found before: %v", s)
- }
- if err := s.SetNetworkLayerForChecksum(l); err != nil {
- return fmt.Errorf("failed to set network layer(%v) on layer(%v): %v", l, s, err)
- }
- }
- }
- return nil
-}
diff --git a/vendor/github.com/google/gopacket/layers/icmp6_test.go b/vendor/github.com/google/gopacket/layers/icmp6_test.go
deleted file mode 100644
index 4a6d248..0000000
--- a/vendor/github.com/google/gopacket/layers/icmp6_test.go
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2012, Google, Inc. All rights reserved.
-// Copyright 2009-2011 Andreas Krennmair. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "github.com/google/gopacket"
- "net"
- "reflect"
- "testing"
-)
-
-// testPacketICMPv6 is the packet:
-// 10:48:30.088384 IP6 2620:0:1005:0:26be:5ff:fe27:b17 > fe80::21f:caff:feb3:7640: ICMP6, neighbor advertisement, tgt is 2620:0:1005:0:26be:5ff:fe27:b17, length 24
-// 0x0000: 001f cab3 7640 24be 0527 0b17 86dd 6000 ....v@$..'....`.
-// 0x0010: 0000 0018 3aff 2620 0000 1005 0000 26be ....:.&.......&.
-// 0x0020: 05ff fe27 0b17 fe80 0000 0000 0000 021f ...'............
-// 0x0030: caff feb3 7640 8800 1ed6 4000 0000 2620 ....v@....@...&.
-// 0x0040: 0000 1005 0000 26be 05ff fe27 0b17 ......&....'..
-var testPacketICMPv6 = []byte{
- 0x00, 0x1f, 0xca, 0xb3, 0x76, 0x40, 0x24, 0xbe, 0x05, 0x27, 0x0b, 0x17, 0x86, 0xdd, 0x60, 0x00,
- 0x00, 0x00, 0x00, 0x18, 0x3a, 0xff, 0x26, 0x20, 0x00, 0x00, 0x10, 0x05, 0x00, 0x00, 0x26, 0xbe,
- 0x05, 0xff, 0xfe, 0x27, 0x0b, 0x17, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1f,
- 0xca, 0xff, 0xfe, 0xb3, 0x76, 0x40, 0x88, 0x00, 0x1e, 0xd6, 0x40, 0x00, 0x00, 0x00, 0x26, 0x20,
- 0x00, 0x00, 0x10, 0x05, 0x00, 0x00, 0x26, 0xbe, 0x05, 0xff, 0xfe, 0x27, 0x0b, 0x17,
-}
-
-func TestPacketICMPv6(t *testing.T) {
- p := gopacket.NewPacket(testPacketICMPv6, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeICMPv6, gopacket.LayerTypePayload}, t)
- if got, ok := p.Layer(LayerTypeIPv6).(*IPv6); ok {
- want := &IPv6{
- BaseLayer: BaseLayer{
- Contents: []byte{0x60, 0x0, 0x0, 0x0, 0x0, 0x18,
- 0x3a, 0xff, 0x26, 0x20, 0x0, 0x0, 0x10, 0x5, 0x0, 0x0, 0x26, 0xbe, 0x5,
- 0xff, 0xfe, 0x27, 0xb, 0x17, 0xfe, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x2, 0x1f, 0xca, 0xff, 0xfe, 0xb3, 0x76, 0x40},
- Payload: []byte{0x88, 0x0, 0x1e, 0xd6, 0x40, 0x0, 0x0, 0x0, 0x26, 0x20,
- 0x0, 0x0, 0x10, 0x5, 0x0, 0x0, 0x26, 0xbe, 0x5, 0xff, 0xfe, 0x27, 0xb,
- 0x17},
- },
- Version: 6,
- TrafficClass: 0,
- FlowLabel: 0,
- Length: 24,
- NextHeader: IPProtocolICMPv6,
- HopLimit: 255,
- SrcIP: net.IP{0x26, 0x20, 0x0, 0x0, 0x10, 0x5, 0x0, 0x0, 0x26, 0xbe, 0x5, 0xff, 0xfe, 0x27, 0xb, 0x17},
- DstIP: net.IP{0xfe, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x1f, 0xca, 0xff, 0xfe, 0xb3, 0x76, 0x40},
- }
- if !reflect.DeepEqual(got, want) {
- t.Errorf("IPv6 packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- } else {
- t.Error("No IPv6 layer type found in packet")
- }
- if got, ok := p.Layer(LayerTypeICMPv6).(*ICMPv6); ok {
- want := &ICMPv6{
- BaseLayer: BaseLayer{
- Contents: []byte{0x88, 0x0, 0x1e, 0xd6, 0x40, 0x0, 0x0, 0x0},
- Payload: []byte{0x26, 0x20, 0x0, 0x0, 0x10,
- 0x5, 0x0, 0x0, 0x26, 0xbe, 0x5, 0xff, 0xfe, 0x27, 0xb, 0x17},
- },
- TypeCode: 0x8800,
- Checksum: 0x1ed6,
- TypeBytes: []byte{0x40, 0x0, 0x0, 0x0},
- }
- if !reflect.DeepEqual(got, want) {
- t.Errorf("ICMPv6 packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- if got.TypeCode.String() != "NeighborAdvertisement" {
- t.Errorf("ICMPv6 type code, got %q want 'NeighborAdvertisement'", got.TypeCode.String())
- }
- } else {
- t.Error("No ICMPv6 layer type found in packet")
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/igmp_test.go b/vendor/github.com/google/gopacket/layers/igmp_test.go
deleted file mode 100644
index 923356d..0000000
--- a/vendor/github.com/google/gopacket/layers/igmp_test.go
+++ /dev/null
@@ -1,171 +0,0 @@
-// Copyright 2016, Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "testing"
-
- "github.com/google/gopacket"
-)
-
-// igmpv1MembershipReportPacket is the packet:
-// 02:45:36.033916 IP 10.60.0.132 > 224.0.1.60: igmp v1 report 224.0.1.60
-// 0x0000: 0100 5e00 013c 0030 c1bf 5755 0800 4500 ..^..<.0..WU..E.
-// 0x0010: 001c 6a7f 0000 0102 6365 0a3c 0084 e000 ..j.....ce.<....
-// 0x0020: 013c 1200 0cc3 e000 013c 0000 0000 0000 .<.......<......
-// 0x0030: ffff ffff ffff 0452 0000 0000 .......R....
-var igmpv1MembershipReportPacket = []byte{
- 0x01, 0x00, 0x5e, 0x00, 0x01, 0x3c, 0x00, 0x30, 0xc1, 0xbf, 0x57, 0x55, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x1c, 0x6a, 0x7f, 0x00, 0x00, 0x01, 0x02, 0x63, 0x65, 0x0a, 0x3c, 0x00, 0x84, 0xe0, 0x00,
- 0x01, 0x3c, 0x12, 0x00, 0x0c, 0xc3, 0xe0, 0x00, 0x01, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x04, 0x52, 0x00, 0x00, 0x00, 0x00,
-}
-
-func TestIGMPv1MembershipReportPacket(t *testing.T) {
- p := gopacket.NewPacket(igmpv1MembershipReportPacket, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeIGMP}, t)
-
- igmp := p.Layer(LayerTypeIGMP).(*IGMPv1or2)
- if igmp.Type != IGMPMembershipReportV1 {
- t.Fatal("Invalid IGMP type")
- }
-}
-
-func BenchmarkDecodeigmpv1MembershipReportPacket(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(igmpv1MembershipReportPacket, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-// igmpv2MembershipQueryPacket is the packet:
-// 02:45:28.071636 IP 10.60.0.189 > 224.0.0.1: igmp query v2
-// 0x0000: 0100 5e00 0001 0001 636f c800 0800 45c0 ..^.....co....E.
-// 0x0010: 001c 0153 0000 0102 ccd3 0a3c 00bd e000 ...S.......<....
-// 0x0020: 0001 1164 ee9b 0000 0000 0000 0000 0000 ...d............
-// 0x0030: 0000 0000 0000 0000 0000 0000 ............
-var igmpv2MembershipQueryPacket = []byte{
- 0x01, 0x00, 0x5e, 0x00, 0x00, 0x01, 0x00, 0x01, 0x63, 0x6f, 0xc8, 0x00, 0x08, 0x00, 0x45, 0xc0,
- 0x00, 0x1c, 0x01, 0x53, 0x00, 0x00, 0x01, 0x02, 0xcc, 0xd3, 0x0a, 0x3c, 0x00, 0xbd, 0xe0, 0x00,
- 0x00, 0x01, 0x11, 0x64, 0xee, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-}
-
-func TestIGMPv2MembershipQuery(t *testing.T) {
- p := gopacket.NewPacket(igmpv2MembershipQueryPacket, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeIGMP}, t)
-
- igmp := p.Layer(LayerTypeIGMP).(*IGMPv1or2)
- if igmp.Type != IGMPMembershipQuery {
- t.Fatal("Invalid IGMP type")
- }
-}
-func BenchmarkDecodeigmpv2MembershipQueryPacket(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(igmpv2MembershipQueryPacket, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-// igmpv2MembershipReportPacket is the packet:
-// 02:47:32.417288 IP 10.60.5.103 > 239.255.255.253: igmp v2 report 239.255.255.253
-// 0x0000: 0100 5e7f fffd 0015 58dc d9f6 0800 4600 ..^.....X.....F.
-// 0x0010: 0020 79f0 0000 0102 ab47 0a3c 0567 efff ..y......G.<.g..
-// 0x0020: fffd 9404 0000 1600 fa01 efff fffd 0000 ................
-// 0x0030: 0000 0000 0000 0000 0000 0000 ............
-var igmpv2MembershipReportPacket = []byte{
- 0x01, 0x00, 0x5e, 0x7f, 0xff, 0xfd, 0x00, 0x15, 0x58, 0xdc, 0xd9, 0xf6, 0x08, 0x00, 0x46, 0x00,
- 0x00, 0x20, 0x79, 0xf0, 0x00, 0x00, 0x01, 0x02, 0xab, 0x47, 0x0a, 0x3c, 0x05, 0x67, 0xef, 0xff,
- 0xff, 0xfd, 0x94, 0x04, 0x00, 0x00, 0x16, 0x00, 0xfa, 0x01, 0xef, 0xff, 0xff, 0xfd, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-}
-
-func TestIGMPv2MembershipReport(t *testing.T) {
- p := gopacket.NewPacket(igmpv2MembershipReportPacket, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeIGMP}, t)
-
- igmp := p.Layer(LayerTypeIGMP).(*IGMPv1or2)
- if igmp.Type != IGMPMembershipReportV2 {
- t.Fatal("Invalid IGMP type")
- }
-}
-func BenchmarkDecodeigmpv2MembershipReportPacket(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(igmpv2MembershipReportPacket, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-// igmp3v3MembershipQueryPacket is the packet:
-// 10:07:30.488511 IP 192.168.1.254 > 224.0.0.1: igmp query v3 [max resp time 2.4s]
-// 0x0000: 0100 5e00 0001 0026 446c 1eda 0800 46c0 ..^....&Dl....F.
-// 0x0010: 0024 17f1 4000 0102 297b c0a8 01fe e000 .$..@...){......
-// 0x0020: 0001 9404 0000 1118 ecd3 0000 0000 0214 ................
-// 0x0030: 0000 0000 0000 0000 0000 0000 ............
-var igmp3v3MembershipQueryPacket = []byte{
- 0x01, 0x00, 0x5e, 0x00, 0x00, 0x01, 0x00, 0x26, 0x44, 0x6c, 0x1e, 0xda, 0x08, 0x00, 0x46, 0xc0,
- 0x00, 0x24, 0x17, 0xf1, 0x40, 0x00, 0x01, 0x02, 0x29, 0x7b, 0xc0, 0xa8, 0x01, 0xfe, 0xe0, 0x00,
- 0x00, 0x01, 0x94, 0x04, 0x00, 0x00, 0x11, 0x18, 0xec, 0xd3, 0x00, 0x00, 0x00, 0x00, 0x02, 0x14,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-}
-
-func TestIGMPv3MembershipQuery(t *testing.T) {
- p := gopacket.NewPacket(igmp3v3MembershipQueryPacket, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeIGMP}, t)
-
- igmp := p.Layer(LayerTypeIGMP).(*IGMP)
- if igmp.Type != IGMPMembershipQuery {
- t.Fatal("Invalid IGMP type")
- }
-}
-
-func BenchmarkDecodeigmp3v3MembershipQueryPacket(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(igmp3v3MembershipQueryPacket, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-// igmpv3MembershipReport2Records is the packet:
-// 10:07:29.756202 IP 192.168.1.66 > 224.0.0.22: igmp v3 report, 2 group record(s)
-// 0x0000: 0100 5e00 0016 0025 2e51 c381 0800 4658 ..^....%.Q....FX
-// 0x0010: 0030 013c 0000 0102 8133 c0a8 0142 e000 .0.<.....3...B..
-// 0x0020: 0016 9404 0000 2200 f33c 0000 0002 0200 ......"..<......
-// 0x0030: 0000 efc3 0702 0200 0000 efff fffa ..............
-var igmpv3MembershipReport2Records = []byte{
- 0x01, 0x00, 0x5e, 0x00, 0x00, 0x16, 0x00, 0x25, 0x2e, 0x51, 0xc3, 0x81, 0x08, 0x00, 0x46, 0x58,
- 0x00, 0x30, 0x01, 0x3c, 0x00, 0x00, 0x01, 0x02, 0x81, 0x33, 0xc0, 0xa8, 0x01, 0x42, 0xe0, 0x00,
- 0x00, 0x16, 0x94, 0x04, 0x00, 0x00, 0x22, 0x00, 0xf3, 0x3c, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00,
- 0x00, 0x00, 0xef, 0xc3, 0x07, 0x02, 0x02, 0x00, 0x00, 0x00, 0xef, 0xff, 0xff, 0xfa,
-}
-
-func TestIGMPv3MembershipReport2Records(t *testing.T) {
- p := gopacket.NewPacket(igmpv3MembershipReport2Records, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeIGMP}, t)
-
- igmp := p.Layer(LayerTypeIGMP).(*IGMP)
- if igmp.Type != IGMPMembershipReportV3 {
- t.Fatal("Invalid IGMP type")
- }
-}
-
-func BenchmarkDecodeigmpv3MembershipReport2Records(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(igmpv3MembershipReport2Records, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/ip4_test.go b/vendor/github.com/google/gopacket/layers/ip4_test.go
deleted file mode 100644
index ec6b351..0000000
--- a/vendor/github.com/google/gopacket/layers/ip4_test.go
+++ /dev/null
@@ -1,131 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-// This file tests some of the functionality provided in the ip4.go
-
-package layers
-
-import (
- "encoding/binary"
- "encoding/hex"
- "net"
- "testing"
-
- "github.com/google/gopacket"
-)
-
-// Test the function getIPv4OptionSize when the ipv4 has no options
-func TestGetIPOptLengthNoOpt(t *testing.T) {
- ip := IPv4{}
- length := ip.getIPv4OptionSize()
- if length != 0 {
- t.Fatalf("Empty option list should have 0 length. Actual %d", length)
- }
-}
-
-// Test the function getIPv4OptionSize when the ipv4 has end of list option
-func TestGetIPOptLengthEndOfList(t *testing.T) {
- ip := IPv4{}
- ip.Options = append(ip.Options, IPv4Option{OptionType: 0, OptionLength: 1})
- length := ip.getIPv4OptionSize()
- if length != 4 {
- t.Fatalf("After padding, the list should have 4 length. Actual %d", length)
- }
-}
-
-// Test the function getIPv4OptionSize when the ipv4 has padding and end of list option
-func TestGetIPOptLengthPaddingEndOfList(t *testing.T) {
- ip := IPv4{}
- ip.Options = append(ip.Options, IPv4Option{OptionType: 1, OptionLength: 1})
- ip.Options = append(ip.Options, IPv4Option{OptionType: 0, OptionLength: 1})
- length := ip.getIPv4OptionSize()
- if length != 4 {
- t.Fatalf("After padding, the list should have 4 length. Actual %d", length)
- }
-}
-
-// Test the function getIPv4OptionSize when the ipv4 has some non-trivial option and end of list option
-func TestGetIPOptLengthOptionEndOfList(t *testing.T) {
- ip := IPv4{}
- someByte := make([]byte, 8)
- ip.Options = append(ip.Options, IPv4Option{OptionType: 2, OptionLength: 10, OptionData: someByte})
- ip.Options = append(ip.Options, IPv4Option{OptionType: 0, OptionLength: 1})
- length := ip.getIPv4OptionSize()
- if length != 12 {
- t.Fatalf("The list should have 12 length. Actual %d", length)
- }
-}
-
-// Tests that the Options slice is properly reset before parsing new data
-func TestIPOptResetDuringDecoding(t *testing.T) {
- ip := &IPv4{
- Options: []IPv4Option{{OptionType: 42, OptionLength: 4, OptionData: make([]byte, 2)}},
- }
-
- ipWithoutOptions := &IPv4{
- SrcIP: net.IPv4(192, 168, 1, 1),
- DstIP: net.IPv4(192, 168, 1, 1),
- Protocol: IPProtocolTCP,
- }
-
- ipBytes, err := serialize(ipWithoutOptions)
-
- if err != nil {
- t.Fatalf("Failed to serialize ip layer: %v", err)
- }
-
- err = ip.DecodeFromBytes(ipBytes, gopacket.NilDecodeFeedback)
-
- if err != nil {
- t.Fatalf("Failed to deserialize ip layer: %v", err)
- }
-
- if len(ip.Options) > 0 {
- t.Fatalf("Options slice has stale data from previous packet")
- }
-
-}
-
-func serialize(ip *IPv4) ([]byte, error) {
- buffer := gopacket.NewSerializeBuffer()
- err := ip.SerializeTo(buffer, gopacket.SerializeOptions{
- FixLengths: true,
- ComputeChecksums: true,
- })
- return buffer.Bytes(), err
-}
-
-// Test the function checksum
-func TestChecksum(t *testing.T) {
- testData := []struct {
- name string
- header string
- want string
- }{{
- name: "sum has two carries",
- header: "4540005800000000ff11ffff0aeb1d070aed8877",
- want: "fffe",
- }, {
- name: "wikipedia case",
- header: "45000073000040004011b861c0a80001c0a800c7",
- want: "b861",
- }}
-
- for _, test := range testData {
- bytes, err := hex.DecodeString(test.header)
- if err != nil {
- t.Fatalf("Failed to Decode header: %v", err)
- }
- wantBytes, err := hex.DecodeString(test.want)
- if err != nil {
- t.Fatalf("Failed to decode want checksum: %v", err)
- }
-
- if got, want := checksum(bytes), binary.BigEndian.Uint16(wantBytes); got != want {
- t.Errorf("In test %q, got incorrect checksum: got(%x), want(%x)", test.name, got, want)
- }
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/ip6_test.go b/vendor/github.com/google/gopacket/layers/ip6_test.go
deleted file mode 100644
index ab22f17..0000000
--- a/vendor/github.com/google/gopacket/layers/ip6_test.go
+++ /dev/null
@@ -1,430 +0,0 @@
-// Copyright 2014, Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "bytes"
- "github.com/google/gopacket"
- "net"
- "reflect"
- "testing"
-)
-
-func TestSerializeIPv6HeaderTLVOptions(t *testing.T) {
- //RFC 2460 Appendix B
- /*
- Example 3
-
- A Hop-by-Hop or Destination Options header containing both options X
- and Y from Examples 1 and 2 would have one of the two following
- formats, depending on which option appeared first:
-
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Next Header | Hdr Ext Len=3 | Option Type=X |Opt Data Len=12|
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | 4-octet field |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- + 8-octet field +
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | PadN Option=1 |Opt Data Len=1 | 0 | Option Type=Y |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |Opt Data Len=7 | 1-octet field | 2-octet field |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | 4-octet field |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | PadN Option=1 |Opt Data Len=2 | 0 | 0 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
- opt1 := &ipv6HeaderTLVOption{}
- opt1.OptionType = 0x1e
- opt1.OptionData = []byte{0xaa, 0xaa, 0xaa, 0xaa, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb}
- opt1.OptionAlignment = [2]uint8{8, 2}
-
- opt2 := &ipv6HeaderTLVOption{}
- opt2.OptionType = 0x3e
- opt2.OptionData = []byte{0x11, 0x22, 0x22, 0x44, 0x44, 0x44, 0x44}
- opt2.OptionAlignment = [2]uint8{4, 3}
-
- l := serializeIPv6HeaderTLVOptions(nil, []*ipv6HeaderTLVOption{opt1, opt2}, true)
- b := make([]byte, l)
- serializeIPv6HeaderTLVOptions(b, []*ipv6HeaderTLVOption{opt1, opt2}, true)
- got := b
- want := []byte{0x1e, 0x0c, 0xaa, 0xaa, 0xaa, 0xaa, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0x01, 0x01, 0x00, 0x3e, 0x07, 0x11, 0x22, 0x22, 0x44, 0x44, 0x44, 0x44, 0x01, 0x02, 0x00, 0x00}
-
- if !bytes.Equal(got, want) {
- t.Errorf("IPv6HeaderTLVOption serialize (X,Y) failed:\ngot:\n%#v\n\nwant:\n%#v\n\n", got, want)
- }
-
- /*
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Next Header | Hdr Ext Len=3 | Pad1 Option=0 | Option Type=Y |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |Opt Data Len=7 | 1-octet field | 2-octet field |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | 4-octet field |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | PadN Option=1 |Opt Data Len=4 | 0 | 0 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | 0 | 0 | Option Type=X |Opt Data Len=12|
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | 4-octet field |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- + 8-octet field +
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- l = serializeIPv6HeaderTLVOptions(nil, []*ipv6HeaderTLVOption{opt2, opt1}, true)
- b = make([]byte, l)
- serializeIPv6HeaderTLVOptions(b, []*ipv6HeaderTLVOption{opt2, opt1}, true)
- got = b
- want = []byte{0x00, 0x3e, 0x07, 0x11, 0x22, 0x22, 0x44, 0x44, 0x44, 0x44, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x0c, 0xaa, 0xaa, 0xaa, 0xaa, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb}
-
- if !bytes.Equal(got, want) {
- t.Errorf("IPv6HeaderTLVOption serialize (Y,X) failed:\ngot:\n%#v\n\nwant:\n%#v\n\n", got, want)
- }
-}
-
-var testPacketIPv6HopByHop0 = []byte{
- 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x40, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x3b, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00,
-}
-
-func TestPacketIPv6HopByHop0Serialize(t *testing.T) {
- var serialize []gopacket.SerializableLayer = make([]gopacket.SerializableLayer, 0, 2)
- var err error
-
- ip6 := &IPv6{}
- ip6.Version = 6
- ip6.NextHeader = IPProtocolIPv6HopByHop
- ip6.HopLimit = 64
- ip6.SrcIP = net.ParseIP("2001:db8::1")
- ip6.DstIP = net.ParseIP("2001:db8::2")
- serialize = append(serialize, ip6)
-
- tlv := &IPv6HopByHopOption{}
- tlv.OptionType = 0x01 //PadN
- tlv.OptionData = []byte{0x00, 0x00, 0x00, 0x00}
- hop := &IPv6HopByHop{}
- hop.Options = append(hop.Options, tlv)
- hop.NextHeader = IPProtocolNoNextHeader
- ip6.HopByHop = hop
-
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{FixLengths: true}
- err = gopacket.SerializeLayers(buf, opts, serialize...)
- if err != nil {
- t.Fatal(err)
- }
-
- got := buf.Bytes()
- want := testPacketIPv6HopByHop0
- if !bytes.Equal(got, want) {
- t.Errorf("IPv6HopByHop serialize failed:\ngot:\n%#v\n\nwant:\n%#v\n\n", got, want)
- }
-}
-
-func TestPacketIPv6HopByHop0Decode(t *testing.T) {
- ip6 := &IPv6{
- BaseLayer: BaseLayer{
- Contents: []byte{
- 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x40, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- },
- Payload: []byte{0x3b, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00},
- },
- Version: 6,
- TrafficClass: 0,
- FlowLabel: 0,
- Length: 8,
- NextHeader: IPProtocolIPv6HopByHop,
- HopLimit: 64,
- SrcIP: net.IP{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
- DstIP: net.IP{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
- }
-
- hop := &ip6.hbh
- hop.ipv6ExtensionBase = ipv6ExtensionBase{
- BaseLayer: BaseLayer{
- Contents: []byte{0x3b, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00},
- Payload: []byte{},
- },
- NextHeader: IPProtocolNoNextHeader,
- HeaderLength: uint8(0),
- ActualLength: 8,
- }
- opt := &IPv6HopByHopOption{
- OptionType: uint8(0x01),
- OptionLength: uint8(0x04),
- ActualLength: 6,
- OptionData: []byte{0x00, 0x00, 0x00, 0x00},
- }
- hop.Options = append(hop.Options, opt)
- ip6.HopByHop = hop
-
- p := gopacket.NewPacket(testPacketIPv6HopByHop0, LinkTypeRaw, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeIPv6, LayerTypeIPv6HopByHop}, t)
- if got, ok := p.Layer(LayerTypeIPv6).(*IPv6); ok {
- want := ip6
- want.HopByHop = got.HopByHop // avoid comparing pointers
- if !reflect.DeepEqual(got, want) {
- t.Errorf("IPv6 packet processing failed:\ngot:\n%#v\n\nwant:\n%#v\n\n", got, want)
- }
- } else {
- t.Error("No IPv6 layer type found in packet")
- }
- if got, ok := p.Layer(LayerTypeIPv6HopByHop).(*IPv6HopByHop); ok {
- want := hop
- if !reflect.DeepEqual(got, want) {
- t.Errorf("IPv6HopByHop packet processing failed:\ngot\n%#v\n\nwant:\n%#v\n\n", got, want)
- }
- } else {
- t.Error("No IPv6HopByHop layer type found in packet")
- }
-}
-
-// testPacketIPv6Destination0 is the packet:
-// 12:40:14.429409595 IP6 2001:db8::1 > 2001:db8::2: DSTOPT no next header
-// 0x0000: 6000 0000 0008 3c40 2001 0db8 0000 0000 `.....<@........
-// 0x0010: 0000 0000 0000 0001 2001 0db8 0000 0000 ................
-// 0x0020: 0000 0000 0000 0002 3b00 0104 0000 0000 ........;.......
-var testPacketIPv6Destination0 = []byte{
- 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3c, 0x40, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x3b, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00,
-}
-
-func TestPacketIPv6Destination0Serialize(t *testing.T) {
- var serialize []gopacket.SerializableLayer = make([]gopacket.SerializableLayer, 0, 2)
- var err error
-
- ip6 := &IPv6{}
- ip6.Version = 6
- ip6.NextHeader = IPProtocolIPv6Destination
- ip6.HopLimit = 64
- ip6.SrcIP = net.ParseIP("2001:db8::1")
- ip6.DstIP = net.ParseIP("2001:db8::2")
- serialize = append(serialize, ip6)
-
- tlv := &IPv6DestinationOption{}
- tlv.OptionType = 0x01 //PadN
- tlv.OptionData = []byte{0x00, 0x00, 0x00, 0x00}
- dst := &IPv6Destination{}
- dst.Options = append(dst.Options, tlv)
- dst.NextHeader = IPProtocolNoNextHeader
- serialize = append(serialize, dst)
-
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{FixLengths: true}
- err = gopacket.SerializeLayers(buf, opts, serialize...)
- if err != nil {
- t.Fatal(err)
- }
-
- got := buf.Bytes()
- want := testPacketIPv6Destination0
- if !bytes.Equal(got, want) {
- t.Errorf("IPv6Destination serialize failed:\ngot:\n%#v\n\nwant:\n%#v\n\n", got, want)
- }
-}
-
-func TestPacketIPv6Destination0Decode(t *testing.T) {
- ip6 := &IPv6{
- BaseLayer: BaseLayer{
- Contents: []byte{
- 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3c, 0x40, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- },
- Payload: []byte{0x3b, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00},
- },
- Version: 6,
- TrafficClass: 0,
- FlowLabel: 0,
- Length: 8,
- NextHeader: IPProtocolIPv6Destination,
- HopLimit: 64,
- SrcIP: net.IP{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
- DstIP: net.IP{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
- }
-
- dst := &IPv6Destination{}
- dst.BaseLayer = BaseLayer{
- Contents: []byte{0x3b, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00},
- Payload: []byte{},
- }
- dst.NextHeader = IPProtocolNoNextHeader
- dst.HeaderLength = uint8(0)
- dst.ActualLength = 8
- opt := &IPv6DestinationOption{
- OptionType: uint8(0x01),
- OptionLength: uint8(0x04),
- ActualLength: 6,
- OptionData: []byte{0x00, 0x00, 0x00, 0x00},
- }
- dst.Options = append(dst.Options, opt)
-
- p := gopacket.NewPacket(testPacketIPv6Destination0, LinkTypeRaw, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeIPv6, LayerTypeIPv6Destination}, t)
- if got, ok := p.Layer(LayerTypeIPv6).(*IPv6); ok {
- want := ip6
- if !reflect.DeepEqual(got, want) {
- t.Errorf("IPv6 packet processing failed:\ngot:\n%#v\n\nwant:\n%#v\n\n", got, want)
- }
- } else {
- t.Error("No IPv6 layer type found in packet")
- }
- if got, ok := p.Layer(LayerTypeIPv6Destination).(*IPv6Destination); ok {
- want := dst
- if !reflect.DeepEqual(got, want) {
- t.Errorf("IPv6Destination packet processing failed:\ngot:\n%#v\n\nwant:\n%#v\n\n", got, want)
- }
- } else {
- t.Error("No IPv6Destination layer type found in packet")
- }
-}
-
-var testPacketIPv6JumbogramHeader = []byte{
- 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x3b, 0x00, 0xc2, 0x04, 0x00, 0x01, 0x00, 0x08,
-}
-
-func TestIPv6JumbogramSerialize(t *testing.T) {
- var serialize []gopacket.SerializableLayer = make([]gopacket.SerializableLayer, 0, 2)
- var err error
-
- ip6 := &IPv6{}
- ip6.Version = 6
- ip6.NextHeader = IPProtocolNoNextHeader
- ip6.HopLimit = 64
- ip6.SrcIP = net.ParseIP("2001:db8::1")
- ip6.DstIP = net.ParseIP("2001:db8::2")
- serialize = append(serialize, ip6)
-
- payload := make([]byte, ipv6MaxPayloadLength+1)
- for i := range payload {
- payload[i] = 0xfe
- }
- serialize = append(serialize, gopacket.Payload(payload))
-
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{FixLengths: true}
- err = gopacket.SerializeLayers(buf, opts, serialize...)
- if err != nil {
- t.Fatal(err)
- }
-
- got := buf.Bytes()
- w := new(bytes.Buffer)
- w.Write(testPacketIPv6JumbogramHeader)
- w.Write(payload)
- want := w.Bytes()
-
- if !bytes.Equal(got, want) {
- t.Errorf("IPv6 Jumbogram serialize failed:\ngot:\n%v\n\nwant:\n%v\n\n",
- gopacket.LongBytesGoString(got), gopacket.LongBytesGoString(want))
- }
-}
-
-func TestIPv6JumbogramDecode(t *testing.T) {
- payload := make([]byte, ipv6MaxPayloadLength+1)
- for i := range payload {
- payload[i] = 0xfe
- }
-
- ip6 := &IPv6{
- BaseLayer: BaseLayer{
- Contents: []byte{
- 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- },
- },
- Version: 6,
- TrafficClass: 0,
- FlowLabel: 0,
- Length: 0,
- NextHeader: IPProtocolIPv6HopByHop,
- HopLimit: 64,
- SrcIP: net.IP{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
- DstIP: net.IP{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
- }
- buf := new(bytes.Buffer)
- buf.Write([]byte{0x3b, 0x00, 0xc2, 0x04, 0x00, 0x01, 0x00, 0x08})
- buf.Write(payload)
- ip6.Payload = buf.Bytes()
-
- hop := &ip6.hbh
- hop.Contents = []byte{0x3b, 0x00, 0xc2, 0x04, 0x00, 0x01, 0x00, 0x08}
- hop.Payload = payload
- hop.NextHeader = IPProtocolNoNextHeader
- hop.HeaderLength = uint8(0)
- hop.ActualLength = 8
- opt := &IPv6HopByHopOption{}
- opt.OptionType = uint8(0xc2)
- opt.OptionLength = uint8(0x04)
- opt.ActualLength = 6
- opt.OptionData = []byte{0x00, 0x01, 0x00, 0x08}
- hop.Options = append(hop.Options, opt)
- ip6.HopByHop = hop
-
- pkt := new(bytes.Buffer)
- pkt.Write(testPacketIPv6JumbogramHeader)
- pkt.Write(payload)
-
- p := gopacket.NewPacket(pkt.Bytes(), LinkTypeRaw, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeIPv6, LayerTypeIPv6HopByHop, gopacket.LayerTypePayload}, t)
-
- if got, ok := p.Layer(LayerTypeIPv6).(*IPv6); ok {
- want := ip6
- want.HopByHop = got.HopByHop // Hack, avoid comparing pointers
- if !reflect.DeepEqual(got, want) {
- t.Errorf("IPv6 packet processing failed:\ngot:\n%v\n\nwant:\n%v\n\n",
- gopacket.LayerGoString(got), gopacket.LayerGoString(want))
- }
- } else {
- t.Error("No IPv6 layer type found in packet")
- }
-
- if got, ok := p.Layer(LayerTypeIPv6HopByHop).(*IPv6HopByHop); ok {
- want := hop
- if !reflect.DeepEqual(got, want) {
- t.Errorf("IPv6HopByHop packet processing failed:\ngot:\n%v\n\nwant:\n%v\n\n",
- gopacket.LayerGoString(got), gopacket.LayerGoString(want))
- }
- } else {
- t.Error("No IPv6HopByHop layer type found in packet")
- }
-
- if got, ok := p.Layer(gopacket.LayerTypePayload).(*gopacket.Payload); ok {
- want := (*gopacket.Payload)(&payload)
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Payload packet processing failed:\ngot:\n%v\n\nwant:\n%v\n\n",
- gopacket.LayerGoString(got), gopacket.LayerGoString(want))
- }
- } else {
- t.Error("No Payload layer type found in packet")
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/ipsec_test.go b/vendor/github.com/google/gopacket/layers/ipsec_test.go
deleted file mode 100644
index 466646d..0000000
--- a/vendor/github.com/google/gopacket/layers/ipsec_test.go
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright 2012, Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "github.com/google/gopacket"
- "reflect"
- "testing"
-)
-
-// testPacketIPSecAHTransport is the packet:
-// 20:45:10.325850 IP 192.168.1.1 > 192.168.1.2: AH(spi=0x00000101,seq=0x1): ICMP echo request, id 1560, seq 1, length 64
-// 0x0000: 7ec0 ffc6 48f1 1a0e 3c4e 3b3a 0800 4500 ~...H...<N;:..E.
-// 0x0010: 006c 650a 4000 4033 5201 c0a8 0101 c0a8 .le.@.@3R.......
-// 0x0020: 0102 0104 0000 0000 0101 0000 0001 2533 ..............%3
-// 0x0030: 01b1 a20b b6f1 bdbf 9d9e 0800 fbe5 0618 ................
-// 0x0040: 0001 c6e1 a354 0000 0000 c8f7 0400 0000 .....T..........
-// 0x0050: 0000 1011 1213 1415 1617 1819 1a1b 1c1d ................
-// 0x0060: 1e1f 2021 2223 2425 2627 2829 2a2b 2c2d ...!"#$%&'()*+,-
-// 0x0070: 2e2f 3031 3233 3435 3637 ./01234567
-var testPacketIPSecAHTransport = []byte{
- 0x7e, 0xc0, 0xff, 0xc6, 0x48, 0xf1, 0x1a, 0x0e, 0x3c, 0x4e, 0x3b, 0x3a, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x6c, 0x65, 0x0a, 0x40, 0x00, 0x40, 0x33, 0x52, 0x01, 0xc0, 0xa8, 0x01, 0x01, 0xc0, 0xa8,
- 0x01, 0x02, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x25, 0x33,
- 0x01, 0xb1, 0xa2, 0x0b, 0xb6, 0xf1, 0xbd, 0xbf, 0x9d, 0x9e, 0x08, 0x00, 0xfb, 0xe5, 0x06, 0x18,
- 0x00, 0x01, 0xc6, 0xe1, 0xa3, 0x54, 0x00, 0x00, 0x00, 0x00, 0xc8, 0xf7, 0x04, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
- 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
- 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
-}
-
-func TestPacketIPSecAHTransport(t *testing.T) {
- p := gopacket.NewPacket(testPacketIPSecAHTransport, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeIPSecAH, LayerTypeICMPv4, gopacket.LayerTypePayload}, t)
- if got, ok := p.Layer(LayerTypeIPSecAH).(*IPSecAH); ok {
- want := &IPSecAH{
- Reserved: 0x0,
- SPI: 0x101,
- Seq: 1,
- AuthenticationData: []byte{0x25, 0x33, 0x01, 0xb1, 0xa2, 0x0b, 0xb6, 0xf1, 0xbd, 0xbf, 0x9d, 0x9e},
- }
- want.BaseLayer = BaseLayer{testPacketIPSecAHTransport[34:58], testPacketIPSecAHTransport[58:]}
- want.NextHeader = IPProtocolICMPv4
- want.HeaderLength = 0x4
- want.ActualLength = 0x18
- if !reflect.DeepEqual(want, got) {
- t.Errorf("IPSecAH layer mismatch, \nwant %#v\ngot %#v\n", want, got)
- }
- }
-}
-
-func BenchmarkDecodePacketIPSecAHTransport(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketIPSecAHTransport, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-// testPacketIPSecAHTunnel is the packet:
-// 14:45:43.252917 IP 192.168.1.1 > 192.168.1.2: AH(spi=0x00000101,seq=0x1): IP 172.16.1.1 > 172.16.2.1: ICMP echo request, id 31322, seq 1, length 64 (ipip-proto-4)
-// 0x0000: 7220 4d91 63c9 566c ed2d 73cd 0800 4500 r.M.c.Vl.-s...E.
-// 0x0010: 0080 0000 4000 4033 b6f7 c0a8 0101 c0a8 ....@.@3........
-// 0x0020: 0102 0404 0000 0000 0101 0000 0001 cca4 ................
-// 0x0030: 01da 9eb4 fb75 10fe 5a59 4500 0054 a96f .....u..ZYE..T.o
-// 0x0040: 4000 4001 3617 ac10 0101 ac10 0201 0800 @.@.6...........
-// 0x0050: d75f 7a5a 0001 0741 3355 0000 0000 a9db ._zZ...A3U......
-// 0x0060: 0300 0000 0000 1011 1213 1415 1617 1819 ................
-// 0x0070: 1a1b 1c1d 1e1f 2021 2223 2425 2627 2829 .......!"#$%&'()
-// 0x0080: 2a2b 2c2d 2e2f 3031 3233 3435 3637 *+,-./01234567
-var testPacketIPSecAHTunnel = []byte{
- 0x72, 0x20, 0x4d, 0x91, 0x63, 0xc9, 0x56, 0x6c, 0xed, 0x2d, 0x73, 0xcd, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x40, 0x00, 0x40, 0x33, 0xb6, 0xf7, 0xc0, 0xa8, 0x01, 0x01, 0xc0, 0xa8,
- 0x01, 0x02, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0xcc, 0xa4,
- 0x01, 0xda, 0x9e, 0xb4, 0xfb, 0x75, 0x10, 0xfe, 0x5a, 0x59, 0x45, 0x00, 0x00, 0x54, 0xa9, 0x6f,
- 0x40, 0x00, 0x40, 0x01, 0x36, 0x17, 0xac, 0x10, 0x01, 0x01, 0xac, 0x10, 0x02, 0x01, 0x08, 0x00,
- 0xd7, 0x5f, 0x7a, 0x5a, 0x00, 0x01, 0x07, 0x41, 0x33, 0x55, 0x00, 0x00, 0x00, 0x00, 0xa9, 0xdb,
- 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
- 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
- 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
-}
-
-func TestPacketIPSecAHTunnel(t *testing.T) {
- p := gopacket.NewPacket(testPacketIPSecAHTunnel, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeIPSecAH, LayerTypeIPv4, LayerTypeICMPv4, gopacket.LayerTypePayload}, t)
- if got, ok := p.Layer(LayerTypeIPSecAH).(*IPSecAH); ok {
- want := &IPSecAH{
- Reserved: 0x0,
- SPI: 0x101,
- Seq: 1,
- AuthenticationData: []byte{0xcc, 0xa4, 0x01, 0xda, 0x9e, 0xb4, 0xfb, 0x75, 0x10, 0xfe, 0x5a, 0x59},
- }
- want.BaseLayer = BaseLayer{testPacketIPSecAHTunnel[34:58], testPacketIPSecAHTunnel[58:]}
- want.NextHeader = IPProtocolIPv4
- want.HeaderLength = 0x4
- want.ActualLength = 0x18
- if !reflect.DeepEqual(want, got) {
- t.Errorf("IPSecAH layer mismatch, \nwant %#v\ngot %#v\n", want, got)
- }
- }
-}
-
-func BenchmarkDecodePacketIPSecAHTunnel(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketIPSecAHTunnel, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-// testPacketIPSecESP is the packet:
-// 04:30:37.629376 IP 190.0.0.1 > 190.0.0.2: ESP(spi=0x0000006e,seq=0x13), length 116
-// 0x0000: 0000 0000 0012 0011 434a d70a 0800 4500 ........CJ....E.
-// 0x0010: 0088 0000 4000 4032 be40 be00 0001 be00 ....@.@2.@......
-// 0x0020: 0002 0000 006e 0000 0013 82f4 1077 0418 .....n.......w..
-// 0x0030: e8ce dc45 1bac 22bb daaf 2ad2 c2e8 315b ...E.."...*...1[
-// 0x0040: ce9a 39da 2aae cf43 3716 70ab 7e7c 4676 ..9.*..C7.p.~|Fv
-// 0x0050: c3fc d109 c990 274d f81c 6534 9a40 a0ef ......'M..e4.@..
-// 0x0060: 46b1 7da5 05af dda8 d0ba 6e23 d1ee 1f10 F.}.......n#....
-// 0x0070: 730c 7371 03b1 445c 2f70 852f 8475 12fb s.sq..D\/p./.u..
-// 0x0080: b057 a19b a617 bae7 09ca 8836 942f 3334 .W.........6./34
-// 0x0090: 312b 96d2 a4e3 1+....
-var testPacketIPSecESP = []byte{
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x11, 0x43, 0x4a, 0xd7, 0x0a, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x88, 0x00, 0x00, 0x40, 0x00, 0x40, 0x32, 0xbe, 0x40, 0xbe, 0x00, 0x00, 0x01, 0xbe, 0x00,
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x13, 0x82, 0xf4, 0x10, 0x77, 0x04, 0x18,
- 0xe8, 0xce, 0xdc, 0x45, 0x1b, 0xac, 0x22, 0xbb, 0xda, 0xaf, 0x2a, 0xd2, 0xc2, 0xe8, 0x31, 0x5b,
- 0xce, 0x9a, 0x39, 0xda, 0x2a, 0xae, 0xcf, 0x43, 0x37, 0x16, 0x70, 0xab, 0x7e, 0x7c, 0x46, 0x76,
- 0xc3, 0xfc, 0xd1, 0x09, 0xc9, 0x90, 0x27, 0x4d, 0xf8, 0x1c, 0x65, 0x34, 0x9a, 0x40, 0xa0, 0xef,
- 0x46, 0xb1, 0x7d, 0xa5, 0x05, 0xaf, 0xdd, 0xa8, 0xd0, 0xba, 0x6e, 0x23, 0xd1, 0xee, 0x1f, 0x10,
- 0x73, 0x0c, 0x73, 0x71, 0x03, 0xb1, 0x44, 0x5c, 0x2f, 0x70, 0x85, 0x2f, 0x84, 0x75, 0x12, 0xfb,
- 0xb0, 0x57, 0xa1, 0x9b, 0xa6, 0x17, 0xba, 0xe7, 0x09, 0xca, 0x88, 0x36, 0x94, 0x2f, 0x33, 0x34,
- 0x31, 0x2b, 0x96, 0xd2, 0xa4, 0xe3,
-}
-
-func TestPacketIPSecESP(t *testing.T) {
- p := gopacket.NewPacket(testPacketIPSecESP, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeIPSecESP}, t)
-}
-
-func BenchmarkDecodePacketIPSecESP(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketIPSecESP, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/mpls_test.go b/vendor/github.com/google/gopacket/layers/mpls_test.go
deleted file mode 100644
index e0a2b95..0000000
--- a/vendor/github.com/google/gopacket/layers/mpls_test.go
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright 2016 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "reflect"
- "testing"
-
- "github.com/google/gopacket"
-)
-
-// testPacketMPLS
-// Ethernet II, Src: cc:15:14:64:00:00 (cc:15:14:64:00:00), Dst: cc:13:14:64:00:01 (cc:13:14:64:00:01)
-// MultiProtocol Label Switching Header, Label: 17, Exp: 0, S: 0, TTL: 254
-// MultiProtocol Label Switching Header, Label: 19, Exp: 0, S: 1, TTL: 254
-// Internet Protocol Version 4, Src: 12.0.0.1, Dst: 2.2.2.2
-// Internet Control Message Protocol
-// 0000 cc 13 14 64 00 01 cc 15 14 64 00 00 88 47 00 01 ...d.....d...G..
-// 0010 10 fe 00 01 31 fe 45 00 00 64 00 39 00 00 fe 01 ....1.E..d.9....
-// 0020 ac 5b 0c 00 00 01 02 02 02 02 08 00 3a 6b 00 0b .[..........:k..
-// 0030 00 02 00 00 00 00 00 3e 43 94 ab cd ab cd ab cd .......>C.......
-// 0040 ab cd ab cd ab cd ab cd ab cd ab cd ab cd ab cd ................
-// 0050 ab cd ab cd ab cd ab cd ab cd ab cd ab cd ab cd ................
-// 0060 ab cd ab cd ab cd ab cd ab cd ab cd ab cd ab cd ................
-// 0070 ab cd ab cd ab cd ab cd ab cd ..........
-
-var testPacketMPLS = []byte{
- 0xcc, 0x13, 0x14, 0x64, 0x00, 0x01, 0xcc, 0x15, 0x14, 0x64, 0x00, 0x00, 0x88, 0x47, 0x00, 0x01,
- 0x10, 0xfe, 0x00, 0x01, 0x31, 0xfe, 0x45, 0x00, 0x00, 0x64, 0x00, 0x39, 0x00, 0x00, 0xfe, 0x01,
- 0xac, 0x5b, 0x0c, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x08, 0x00, 0x3a, 0x6b, 0x00, 0x0b,
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x43, 0x94, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
-}
-
-func TestPacketMPLS(t *testing.T) {
- p := gopacket.NewPacket(testPacketMPLS, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeMPLS, LayerTypeMPLS, LayerTypeIPv4, LayerTypeICMPv4, gopacket.LayerTypePayload}, t)
- if got, ok := p.Layers()[1].(*MPLS); ok {
- want := &MPLS{
- BaseLayer: BaseLayer{
- Contents: []byte{0x00, 0x01, 0x10, 0xfe},
- Payload: []byte{0x00, 0x01, 0x31, 0xfe, 0x45, 0x00, 0x00, 0x64, 0x00, 0x39, 0x00, 0x00, 0xfe, 0x01,
- 0xac, 0x5b, 0x0c, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x08, 0x00, 0x3a, 0x6b, 0x00, 0x0b,
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x43, 0x94, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd},
- },
- Label: 17,
- TrafficClass: 0,
- StackBottom: false,
- TTL: 254,
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("MPLS layer 1 mismatch, \nwant %#v\ngot %#v\n", want, got)
- }
- }
- if got, ok := p.Layers()[2].(*MPLS); ok {
- want := &MPLS{
- BaseLayer: BaseLayer{
- Contents: []byte{0x00, 0x01, 0x31, 0xfe},
- Payload: []byte{0x45, 0x00, 0x00, 0x64, 0x00, 0x39, 0x00, 0x00, 0xfe, 0x01,
- 0xac, 0x5b, 0x0c, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x08, 0x00, 0x3a, 0x6b, 0x00, 0x0b,
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x43, 0x94, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
- 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd},
- },
- Label: 19,
- TrafficClass: 0,
- StackBottom: true,
- TTL: 254,
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("MPLS layer 2 mismatch, \nwant %#v\ngot %#v\n", want, got)
- }
- }
-}
-
-func BenchmarkDecodePacketMPLS(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketMPLS, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/ntp_test.go b/vendor/github.com/google/gopacket/layers/ntp_test.go
deleted file mode 100644
index b522216..0000000
--- a/vendor/github.com/google/gopacket/layers/ntp_test.go
+++ /dev/null
@@ -1,258 +0,0 @@
-// Copyright 2016 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-//
-//******************************************************************************
-
-package layers
-
-import (
- "crypto/rand"
- "github.com/google/gopacket"
- "io"
- "reflect"
- "testing"
-)
-
-//******************************************************************************
-
-// checkNTP() uses the ntp.go code to analyse the packet bytes as an NTP UDP
-// packet and generate an NTP object. It then compares the generated NTP object
-// with the one provided and throws an error if there is any difference.
-// The desc argument is output with any failure message to identify the test.
-func checkNTP(desc string, t *testing.T, packetBytes []byte, pExpectedNTP *NTP) {
-
- // Analyse the packet bytes, yielding a new packet object p.
- p := gopacket.NewPacket(packetBytes, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Errorf("Failed to decode packet %s: %v", desc, p.ErrorLayer().Error())
- }
-
- // Ensure that the packet analysis yielded the correct set of layers:
- // Link Layer = Ethernet.
- // Network Layer = IPv4.
- // Transport Layer = UDP.
- // Application Layer = NTP.
- checkLayers(p, []gopacket.LayerType{
- LayerTypeEthernet,
- LayerTypeIPv4,
- LayerTypeUDP,
- LayerTypeNTP}, t)
-
- // Select the Application (NTP) layer.
- pResultNTP, ok := p.ApplicationLayer().(*NTP)
- if !ok {
- t.Error("No NTP layer type found in packet in " + desc + ".")
- }
-
- // Compare the generated NTP object with the expected NTP object.
- if !reflect.DeepEqual(pResultNTP, pExpectedNTP) {
- t.Errorf("NTP packet processing failed for packet "+desc+
- ":\ngot :\n%#v\n\nwant :\n%#v\n\n", pResultNTP, pExpectedNTP)
- }
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{}
- err := pResultNTP.SerializeTo(buf, opts)
- if err != nil {
- t.Error(err)
- }
- if !reflect.DeepEqual(pResultNTP.BaseLayer.Contents, buf.Bytes()) {
- t.Errorf("NTP packet serialization failed for packet "+desc+
- ":\ngot :\n%x\n\nwant :\n%x\n\n", buf.Bytes(), packetBytes)
- }
-}
-
-//******************************************************************************
-
-func TestNTPOne(t *testing.T) {
-
- // This test packet is the first NTP packet in the NTP sample capture
- // pcap file NTP_sync.pcap on the Wireshark sample captures page:
- //
- // https://wiki.wireshark.org/SampleCaptures
- // https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=NTP_sync.pcap
- var testPacketNTP = []byte{
- 0x00, 0x0c, 0x41, 0x82, 0xb2, 0x53, 0x00, 0xd0,
- 0x59, 0x6c, 0x40, 0x4e, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x4c, 0x0a, 0x42, 0x00, 0x00, 0x80, 0x11,
- 0xb5, 0xfa, 0xc0, 0xa8, 0x32, 0x32, 0x43, 0x81,
- 0x44, 0x09, 0x00, 0x7b, 0x00, 0x7b, 0x00, 0x38,
- 0xf8, 0xd2, 0xd9, 0x00, 0x0a, 0xfa, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x02, 0x90, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xc5, 0x02, 0x04, 0xec, 0xec, 0x42,
- 0xee, 0x92,
- }
-
- // Assemble the NTP object that we expect to emerge from this test.
- pExpectedNTP := &NTP{
- BaseLayer: BaseLayer{
- Contents: []byte{0xd9, 0x0, 0xa, 0xfa, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x1, 0x2, 0x90, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0xc5, 0x2, 0x4, 0xec, 0xec, 0x42, 0xee, 0x92},
- Payload: nil,
- },
- LeapIndicator: 3,
- Version: 3,
- Mode: 1,
- Stratum: 0,
- Poll: 10,
- Precision: -6,
- RootDelay: 0,
- RootDispersion: 0x10290,
- ReferenceID: 0,
- ReferenceTimestamp: 0,
- OriginTimestamp: 0,
- ReceiveTimestamp: 0,
- TransmitTimestamp: 0xc50204ecec42ee92,
- ExtensionBytes: []byte{},
- }
-
- checkNTP("test01", t, testPacketNTP, pExpectedNTP)
-}
-
-//******************************************************************************
-
-func TestNTPTwo(t *testing.T) {
-
- // This test packet is packet #18 in the NTP sample capture
- // pcap file NTP_sync.pcap on the Wireshark sample captures page:
- //
- // https://wiki.wireshark.org/SampleCaptures
- // https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=NTP_sync.pcap
- //
- // This packet was chosen because it is the first NTP packet after the first
- // NTP packet that has non-zero timestamps.
-
- var testPacketNTP = []byte{
- 0x00, 0xd0, 0x59, 0x6c, 0x40, 0x4e, 0x00, 0x0c,
- 0x41, 0x82, 0xb2, 0x53, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x4c, 0x32, 0x46, 0x40, 0x00, 0x2f, 0x11,
- 0xa8, 0x18, 0x45, 0x2c, 0x39, 0x3c, 0xc0, 0xa8,
- 0x32, 0x32, 0x00, 0x7b, 0x00, 0x7b, 0x00, 0x38,
- 0x09, 0x58, 0x1a, 0x03, 0x0a, 0xee, 0x00, 0x00,
- 0x1b, 0xf7, 0x00, 0x00, 0x14, 0xec, 0x51, 0xae,
- 0x80, 0xb7, 0xc5, 0x02, 0x03, 0x4c, 0x8d, 0x0e,
- 0x66, 0xcb, 0xc5, 0x02, 0x04, 0xec, 0xec, 0x42,
- 0xee, 0x92, 0xc5, 0x02, 0x04, 0xeb, 0xcf, 0x49,
- 0x59, 0xe6, 0xc5, 0x02, 0x04, 0xeb, 0xcf, 0x4c,
- 0x6e, 0x6e,
- }
-
- // Assemble the NTP object that we expect to emerge from this test.
- pExpectedNTP := &NTP{
- BaseLayer: BaseLayer{
- Contents: []byte{0x1a, 0x03, 0x0a, 0xee, 0x00, 0x00,
- 0x1b, 0xf7, 0x00, 0x00, 0x14, 0xec, 0x51, 0xae,
- 0x80, 0xb7, 0xc5, 0x02, 0x03, 0x4c, 0x8d, 0x0e,
- 0x66, 0xcb, 0xc5, 0x02, 0x04, 0xec, 0xec, 0x42,
- 0xee, 0x92, 0xc5, 0x02, 0x04, 0xeb, 0xcf, 0x49,
- 0x59, 0xe6, 0xc5, 0x02, 0x04, 0xeb, 0xcf, 0x4c,
- 0x6e, 0x6e},
- Payload: nil,
- },
- LeapIndicator: 0,
- Version: 3,
- Mode: 2,
- Stratum: 3,
- Poll: 10,
- Precision: -18,
- RootDelay: 0x1bf7,
- RootDispersion: 0x14ec,
- ReferenceID: 0x51ae80b7,
- ReferenceTimestamp: 0xc502034c8d0e66cb,
- OriginTimestamp: 0xc50204ecec42ee92,
- ReceiveTimestamp: 0xc50204ebcf4959e6,
- TransmitTimestamp: 0xc50204ebcf4c6e6e,
- ExtensionBytes: []byte{},
- }
-
- checkNTP("test02", t, testPacketNTP, pExpectedNTP)
-}
-
-//******************************************************************************
-
-func TestNTPThree(t *testing.T) {
-
- // This test packet is packet #19 in the NTP sample capture
- // pcap file NTP_sync.pcap on the Wireshark sample captures page:
- //
- // https://wiki.wireshark.org/SampleCaptures
- // https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=NTP_sync.pcap
-
- var testPacketNTP = []byte{
- 0x00, 0xd0, 0x59, 0x6c, 0x40, 0x4e, 0x00, 0x0c,
- 0x41, 0x82, 0xb2, 0x53, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x4c, 0x00, 0x00, 0x40, 0x00, 0x30, 0x11,
- 0x74, 0x65, 0x18, 0x7b, 0xca, 0xe6, 0xc0, 0xa8,
- 0x32, 0x32, 0x00, 0x7b, 0x00, 0x7b, 0x00, 0x38,
- 0x44, 0x05, 0x1a, 0x02, 0x0a, 0xec, 0x00, 0x00,
- 0x07, 0xc3, 0x00, 0x00, 0x2f, 0x80, 0xc6, 0x1e,
- 0x5c, 0x02, 0xc5, 0x01, 0xf9, 0x95, 0x42, 0x50,
- 0x82, 0xcf, 0xc5, 0x02, 0x04, 0xec, 0xec, 0x42,
- 0xee, 0x92, 0xc5, 0x02, 0x04, 0xeb, 0xd2, 0x35,
- 0x2e, 0xb5, 0xc5, 0x02, 0x04, 0xeb, 0xd2, 0x35,
- 0xd6, 0x7b,
- }
-
- // Assemble the NTP object that we expect to emerge from this test.
- pExpectedNTP := &NTP{
- BaseLayer: BaseLayer{
- Contents: []byte{0x1a, 0x02, 0x0a, 0xec, 0x00, 0x00,
- 0x07, 0xc3, 0x00, 0x00, 0x2f, 0x80, 0xc6, 0x1e,
- 0x5c, 0x02, 0xc5, 0x01, 0xf9, 0x95, 0x42, 0x50,
- 0x82, 0xcf, 0xc5, 0x02, 0x04, 0xec, 0xec, 0x42,
- 0xee, 0x92, 0xc5, 0x02, 0x04, 0xeb, 0xd2, 0x35,
- 0x2e, 0xb5, 0xc5, 0x02, 0x04, 0xeb, 0xd2, 0x35,
- 0xd6, 0x7b},
- Payload: nil,
- },
- LeapIndicator: 0,
- Version: 3,
- Mode: 2,
- Stratum: 2,
- Poll: 10,
- Precision: -20,
- RootDelay: 0x7c3,
- RootDispersion: 0x2f80,
- ReferenceID: 0xc61e5c02,
- ReferenceTimestamp: 0xc501f995425082cf,
- OriginTimestamp: 0xc50204ecec42ee92,
- ReceiveTimestamp: 0xc50204ebd2352eb5,
- TransmitTimestamp: 0xc50204ebd235d67b,
- ExtensionBytes: []byte{},
- }
-
- checkNTP("test03", t, testPacketNTP, pExpectedNTP)
-}
-
-//******************************************************************************
-
-// TestNTPIsomorphism tests whether random data gets parsed into NTP layer and
-// gets serialized back from it to the same value.
-func TestNTPIsomorphism(t *testing.T) {
- NTPData := make([]byte, ntpMinimumRecordSizeInBytes+7)
- _, err := io.ReadFull(rand.Reader, NTPData)
- if err != nil {
- t.Error(err)
- }
- ntpLayer := &NTP{}
- err = ntpLayer.DecodeFromBytes(NTPData, gopacket.NilDecodeFeedback)
- if err != nil {
- t.Error(err)
- }
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{}
- err = ntpLayer.SerializeTo(buf, opts)
- if err != nil {
- t.Error(err)
- }
- if !reflect.DeepEqual(NTPData, buf.Bytes()) {
- t.Errorf("NTP packet is not isomorphic:\ngot :\n%x\n\nwant :\n%x\n\n", buf.Bytes(), NTPData)
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/ospf_test.go b/vendor/github.com/google/gopacket/layers/ospf_test.go
deleted file mode 100644
index 930bb4d..0000000
--- a/vendor/github.com/google/gopacket/layers/ospf_test.go
+++ /dev/null
@@ -1,559 +0,0 @@
-// Copyright 2017 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "github.com/google/gopacket"
- "reflect"
- "testing"
-)
-
-// testPacketOSPF3Hello is the packet:
-// 14:43:11.663317 IP6 fe80::1 > ff02::5: OSPFv3, Hello, length 36
-// 0x0000: 3333 0000 0005 c200 1ffa 0001 86dd 6e00 33............n.
-// 0x0010: 0000 0024 5901 fe80 0000 0000 0000 0000 ...$Y...........
-// 0x0020: 0000 0000 0001 ff02 0000 0000 0000 0000 ................
-// 0x0030: 0000 0000 0005 0301 0024 0101 0101 0000 .........$......
-// 0x0040: 0001 fb86 0000 0000 0005 0100 0013 000a ................
-// 0x0050: 0028 0000 0000 0000 0000 .(........
-var testPacketOSPF3Hello = []byte{
- 0x33, 0x33, 0x00, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x1f, 0xfa, 0x00, 0x01, 0x86, 0xdd, 0x6e, 0x00,
- 0x00, 0x00, 0x00, 0x24, 0x59, 0x01, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x03, 0x01, 0x00, 0x24, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x00, 0x01, 0xfb, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, 0x00, 0x13, 0x00, 0x0a,
- 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-}
-
-func TestPacketOSPF3Hello(t *testing.T) {
- p := gopacket.NewPacket(testPacketOSPF3Hello, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeOSPF}, t)
-
- ospf := p.Layer(LayerTypeOSPF).(*OSPFv3)
- if ospf.Version != 3 {
- t.Fatal("Invalid OSPF version")
- }
- if got, ok := p.Layer(LayerTypeOSPF).(*OSPFv3); ok {
- want := &OSPFv3{
- OSPF: OSPF{
- Version: 3,
- Type: OSPFHello,
- PacketLength: 36,
- RouterID: 0x1010101,
- AreaID: 1,
- Checksum: 0xfb86,
- Content: HelloPkg{
- InterfaceID: 5,
- RtrPriority: 1,
- Options: 0x000013,
- HelloInterval: 10,
- RouterDeadInterval: 40,
- DesignatedRouterID: 0,
- BackupDesignatedRouterID: 0,
- },
- },
- Instance: 0,
- Reserved: 0,
- }
- if !reflect.DeepEqual(got, want) {
- t.Errorf("OSPF packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- } else {
- t.Error("No OSPF layer type found in packet")
- }
-}
-func BenchmarkDecodePacketPacket0(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketOSPF3Hello, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-// testPacketOSPF3DBDesc is the packet:
-// 14:43:51.657571 IP6 fe80::2 > fe80::1: OSPFv3, Database Description, length 28
-// 0x0000: c200 1ffa 0001 c201 1ffa 0001 86dd 6e00 ..............n.
-// 0x0010: 0000 001c 5901 fe80 0000 0000 0000 0000 ....Y...........
-// 0x0020: 0000 0000 0002 fe80 0000 0000 0000 0000 ................
-// 0x0030: 0000 0000 0001 0302 001c 0202 0202 0000 ................
-// 0x0040: 0001 d826 0000 0000 0013 05dc 0007 0000 ...&............
-// 0x0050: 1d46 .F
-var testPacketOSPF3DBDesc = []byte{
- 0xc2, 0x00, 0x1f, 0xfa, 0x00, 0x01, 0xc2, 0x01, 0x1f, 0xfa, 0x00, 0x01, 0x86, 0xdd, 0x6e, 0x00,
- 0x00, 0x00, 0x00, 0x1c, 0x59, 0x01, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x02, 0x00, 0x1c, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00,
- 0x00, 0x01, 0xd8, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x05, 0xdc, 0x00, 0x07, 0x00, 0x00,
- 0x1d, 0x46,
-}
-
-func TestPacketOSPF3DBDesc(t *testing.T) {
- p := gopacket.NewPacket(testPacketOSPF3DBDesc, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeOSPF}, t)
- if got, ok := p.Layer(LayerTypeOSPF).(*OSPFv3); ok {
- want := &OSPFv3{
- OSPF: OSPF{
- Version: 3,
- Type: OSPFDatabaseDescription,
- PacketLength: 28,
- RouterID: 0x2020202,
- AreaID: 1,
- Checksum: 0xd826,
- Content: DbDescPkg{
- Options: 0x000013,
- InterfaceMTU: 1500,
- Flags: 0x7,
- DDSeqNumber: 7494,
- },
- },
- Instance: 0,
- Reserved: 0,
- }
- if !reflect.DeepEqual(got, want) {
- t.Errorf("OSPF packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- } else {
- t.Error("No OSPF layer type found in packet")
- }
-}
-func BenchmarkDecodePacketPacket1(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketOSPF3DBDesc, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-// testPacketOSPF3LSRequest is the packet:
-// 14:43:51.673584 IP6 fe80::2 > fe80::1: OSPFv3, LS-Request, length 100
-// 0x0000: c200 1ffa 0001 c201 1ffa 0001 86dd 6e00 ..............n.
-// 0x0010: 0000 0064 5901 fe80 0000 0000 0000 0000 ...dY...........
-// 0x0020: 0000 0000 0002 fe80 0000 0000 0000 0000 ................
-// 0x0030: 0000 0000 0001 0303 0064 0202 0202 0000 .........d......
-// 0x0040: 0001 2c9a 0000 0000 2001 0000 0000 0101 ..,.............
-// 0x0050: 0101 0000 2003 0000 0003 0101 0101 0000 ................
-// 0x0060: 2003 0000 0002 0101 0101 0000 2003 0000 ................
-// 0x0070: 0001 0101 0101 0000 2003 0000 0000 0101 ................
-// 0x0080: 0101 0000 0008 0000 0005 0101 0101 0000 ................
-// 0x0090: 2009 0000 0000 0101 0101 ..........
-var testPacketOSPF3LSRequest = []byte{
- 0xc2, 0x00, 0x1f, 0xfa, 0x00, 0x01, 0xc2, 0x01, 0x1f, 0xfa, 0x00, 0x01, 0x86, 0xdd, 0x6e, 0x00,
- 0x00, 0x00, 0x00, 0x64, 0x59, 0x01, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x00, 0x64, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00,
- 0x00, 0x01, 0x2c, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
- 0x01, 0x01, 0x00, 0x00, 0x20, 0x03, 0x00, 0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x20, 0x03, 0x00, 0x00, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x20, 0x03, 0x00, 0x00,
- 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
- 0x01, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x05, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x20, 0x09, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
-}
-
-func TestPacketOSPF3LSRequest(t *testing.T) {
- p := gopacket.NewPacket(testPacketOSPF3LSRequest, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeOSPF}, t)
- if got, ok := p.Layer(LayerTypeOSPF).(*OSPFv3); ok {
- want := &OSPFv3{
- OSPF: OSPF{
- Version: 3,
- Type: OSPFLinkStateRequest,
- PacketLength: 100,
- RouterID: 0x2020202,
- AreaID: 1,
- Checksum: 0x2c9a,
- Content: []LSReq{
- LSReq{
- LSType: 0x2001,
- LSID: 0x00000000,
- AdvRouter: 0x01010101,
- },
- LSReq{
- LSType: 0x2003,
- LSID: 0x00000003,
- AdvRouter: 0x01010101,
- },
- LSReq{
- LSType: 0x2003,
- LSID: 0x00000002,
- AdvRouter: 0x01010101,
- },
- LSReq{
- LSType: 0x2003,
- LSID: 0x00000001,
- AdvRouter: 0x01010101,
- },
- LSReq{
- LSType: 0x2003,
- LSID: 0x00000000,
- AdvRouter: 0x01010101,
- },
- LSReq{
- LSType: 0x0008,
- LSID: 0x00000005,
- AdvRouter: 0x01010101,
- },
- LSReq{
- LSType: 0x2009,
- LSID: 0x00000000,
- AdvRouter: 0x01010101,
- },
- },
- },
- Instance: 0,
- Reserved: 0,
- }
- if !reflect.DeepEqual(got, want) {
- t.Errorf("OSPF packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- } else {
- t.Error("No OSPF layer type found in packet")
- }
-}
-func BenchmarkDecodePacketPacket2(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketOSPF3LSRequest, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-// testPacketOSPF3LSUpdate is the packet:
-// 14:43:51.681554 IP6 fe80::1 > fe80::2: OSPFv3, LS-Update, length 288
-// 0x0000: c201 1ffa 0001 c200 1ffa 0001 86dd 6e00 ..............n.
-// 0x0010: 0000 0120 5901 fe80 0000 0000 0000 0000 ....Y...........
-// 0x0020: 0000 0000 0001 fe80 0000 0000 0000 0000 ................
-// 0x0030: 0000 0000 0002 0304 0120 0101 0101 0000 ................
-// 0x0040: 0001 e556 0000 0000 0007 0028 2001 0000 ...V.......(....
-// 0x0050: 0000 0101 0101 8000 0002 d13a 0018 0100 ...........:....
-// 0x0060: 0033 0029 2003 0000 0003 0101 0101 8000 .3.)............
-// 0x0070: 0001 6259 0024 0000 004a 4000 0000 2001 ..bY.$...J@.....
-// 0x0080: 0db8 0000 0003 0029 2003 0000 0002 0101 .......)........
-// 0x0090: 0101 8000 0001 baf6 0024 0000 0054 4000 .........$...T@.
-// 0x00a0: 0000 2001 0db8 0000 0004 0029 2003 0000 ...........)....
-// 0x00b0: 0001 0101 0101 8000 0001 eba0 0024 0000 .............$..
-// 0x00c0: 004a 4000 0000 2001 0db8 0000 0034 0029 .J@..........4.)
-// 0x00d0: 2003 0000 0000 0101 0101 8000 0001 0ebd ................
-// 0x00e0: 0024 0000 0040 4000 0000 2001 0db8 0000 .$...@@.........
-// 0x00f0: 0000 0023 0008 0000 0005 0101 0101 8000 ...#............
-// 0x0100: 0002 3d08 0038 0100 0033 fe80 0000 0000 ..=..8...3......
-// 0x0110: 0000 0000 0000 0000 0001 0000 0001 4000 ..............@.
-// 0x0120: 0000 2001 0db8 0000 0012 0023 2009 0000 ...........#....
-// 0x0130: 0000 0101 0101 8000 0001 e8d2 002c 0001 .............,..
-// 0x0140: 2001 0000 0000 0101 0101 4000 000a 2001 ..........@.....
-// 0x0150: 0db8 0000 0012 ......
-var testPacketOSPF3LSUpdate = []byte{
- 0xc2, 0x01, 0x1f, 0xfa, 0x00, 0x01, 0xc2, 0x00, 0x1f, 0xfa, 0x00, 0x01, 0x86, 0xdd, 0x6e, 0x00,
- 0x00, 0x00, 0x01, 0x20, 0x59, 0x01, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x04, 0x01, 0x20, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x00, 0x01, 0xe5, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x28, 0x20, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x80, 0x00, 0x00, 0x02, 0xd1, 0x3a, 0x00, 0x18, 0x01, 0x00,
- 0x00, 0x33, 0x00, 0x29, 0x20, 0x03, 0x00, 0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x80, 0x00,
- 0x00, 0x01, 0x62, 0x59, 0x00, 0x24, 0x00, 0x00, 0x00, 0x4a, 0x40, 0x00, 0x00, 0x00, 0x20, 0x01,
- 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x03, 0x00, 0x29, 0x20, 0x03, 0x00, 0x00, 0x00, 0x02, 0x01, 0x01,
- 0x01, 0x01, 0x80, 0x00, 0x00, 0x01, 0xba, 0xf6, 0x00, 0x24, 0x00, 0x00, 0x00, 0x54, 0x40, 0x00,
- 0x00, 0x00, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x04, 0x00, 0x29, 0x20, 0x03, 0x00, 0x00,
- 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x80, 0x00, 0x00, 0x01, 0xeb, 0xa0, 0x00, 0x24, 0x00, 0x00,
- 0x00, 0x4a, 0x40, 0x00, 0x00, 0x00, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x34, 0x00, 0x29,
- 0x20, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x80, 0x00, 0x00, 0x01, 0x0e, 0xbd,
- 0x00, 0x24, 0x00, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x23, 0x00, 0x08, 0x00, 0x00, 0x00, 0x05, 0x01, 0x01, 0x01, 0x01, 0x80, 0x00,
- 0x00, 0x02, 0x3d, 0x08, 0x00, 0x38, 0x01, 0x00, 0x00, 0x33, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00,
- 0x00, 0x00, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x12, 0x00, 0x23, 0x20, 0x09, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x80, 0x00, 0x00, 0x01, 0xe8, 0xd2, 0x00, 0x2c, 0x00, 0x01,
- 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x40, 0x00, 0x00, 0x0a, 0x20, 0x01,
- 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x12,
-}
-
-func TestPacketOSPF3LSUpdate(t *testing.T) {
- p := gopacket.NewPacket(testPacketOSPF3LSUpdate, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeOSPF}, t)
- if got, ok := p.Layer(LayerTypeOSPF).(*OSPFv3); ok {
- want := &OSPFv3{
- OSPF: OSPF{
- Version: 3,
- Type: OSPFLinkStateUpdate,
- PacketLength: 288,
- RouterID: 0x1010101,
- AreaID: 1,
- Checksum: 0xe556,
- Content: LSUpdate{
- NumOfLSAs: 7,
- LSAs: []LSA{
- LSA{
- LSAheader: LSAheader{
- LSAge: 40,
- LSType: 0x2001,
- LinkStateID: 0x00000000,
- AdvRouter: 0x01010101,
- LSSeqNumber: 0x80000002,
- LSChecksum: 0xd13a,
- Length: 24,
- },
- Content: RouterLSA{
- Flags: 0x1,
- Options: 0x33,
- },
- },
- LSA{
- LSAheader: LSAheader{
- LSAge: 41,
- LSType: 0x2003,
- LinkStateID: 0x00000003,
- AdvRouter: 0x01010101,
- LSSeqNumber: 0x80000001,
- LSChecksum: 0x6259,
- Length: 36,
- },
- Content: InterAreaPrefixLSA{
- Metric: 74,
- PrefixLength: 64,
- PrefixOptions: 0,
- AddressPrefix: []byte{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x03},
- },
- },
- LSA{
- LSAheader: LSAheader{
- LSAge: 41,
- LSType: 0x2003,
- LinkStateID: 0x00000002,
- AdvRouter: 0x01010101,
- LSSeqNumber: 0x80000001,
- LSChecksum: 0xbaf6,
- Length: 36,
- },
- Content: InterAreaPrefixLSA{
- Metric: 84,
- PrefixLength: 64,
- PrefixOptions: 0,
- AddressPrefix: []byte{0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x4},
- },
- },
- LSA{
- LSAheader: LSAheader{
- LSAge: 41,
- LSType: 0x2003,
- LinkStateID: 0x00000001,
- AdvRouter: 0x01010101,
- LSSeqNumber: 0x80000001,
- LSChecksum: 0xeba0,
- Length: 36,
- },
- Content: InterAreaPrefixLSA{
- Metric: 74,
- PrefixLength: 64,
- PrefixOptions: 0,
- AddressPrefix: []byte{0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x34},
- },
- },
- LSA{
- LSAheader: LSAheader{
- LSAge: 41,
- LSType: 0x2003,
- LinkStateID: 0x00000000,
- AdvRouter: 0x01010101,
- LSSeqNumber: 0x80000001,
- LSChecksum: 0xebd,
- Length: 36,
- },
- Content: InterAreaPrefixLSA{
- Metric: 64,
- PrefixLength: 64,
- PrefixOptions: 0,
- AddressPrefix: []byte{0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0},
- },
- },
- LSA{
- LSAheader: LSAheader{
- LSAge: 35,
- LSType: 0x8,
- LinkStateID: 0x00000005,
- AdvRouter: 0x01010101,
- LSSeqNumber: 0x80000002,
- LSChecksum: 0x3d08,
- Length: 56,
- },
- Content: LinkLSA{
- RtrPriority: 1,
- Options: 0x33,
- LinkLocalAddress: []byte{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
- NumOfPrefixes: 1,
- Prefixes: []Prefix{
- Prefix{
- PrefixLength: 64,
- PrefixOptions: 0,
- AddressPrefix: []byte{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x12},
- },
- },
- },
- },
- LSA{
- LSAheader: LSAheader{
- LSAge: 35,
- LSType: 0x2009,
- LinkStateID: 0x00000000,
- AdvRouter: 0x01010101,
- LSSeqNumber: 0x80000001,
- LSChecksum: 0xe8d2,
- Length: 44,
- },
- Content: IntraAreaPrefixLSA{
- NumOfPrefixes: 1,
- RefLSType: 0x2001,
- RefAdvRouter: 0x01010101,
- Prefixes: []Prefix{
- Prefix{
- PrefixLength: 64,
- PrefixOptions: 0,
- Metric: 10,
- AddressPrefix: []byte{0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x12},
- },
- },
- },
- },
- },
- },
- },
- Instance: 0,
- Reserved: 0,
- }
- if !reflect.DeepEqual(got, want) {
- t.Errorf("OSPF packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- } else {
- t.Error("No OSPF layer type found in packet")
- }
-}
-func BenchmarkDecodePacketPacket3(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketOSPF3LSUpdate, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-// testPacketOSPF3LSAck is the packet:
-// 14:43:54.185384 IP6 fe80::1 > ff02::5: OSPFv3, LS-Ack, length 136
-// 0x0000: 3333 0000 0005 c200 1ffa 0001 86dd 6e00 33............n.
-// 0x0010: 0000 0088 5901 fe80 0000 0000 0000 0000 ....Y...........
-// 0x0020: 0000 0000 0001 ff02 0000 0000 0000 0000 ................
-// 0x0030: 0000 0000 0005 0305 0088 0101 0101 0000 ................
-// 0x0040: 0001 9d2c 0000 0005 2001 0000 0000 0202 ...,............
-// 0x0050: 0202 8000 0002 b354 0018 0006 2003 0000 .......T........
-// 0x0060: 0003 0202 0202 8000 0001 4473 0024 0006 ..........Ds.$..
-// 0x0070: 2003 0000 0002 0202 0202 8000 0001 9c11 ................
-// 0x0080: 0024 0006 2003 0000 0001 0202 0202 8000 .$..............
-// 0x0090: 0001 cdba 0024 0006 2003 0000 0000 0202 .....$..........
-// 0x00a0: 0202 8000 0001 efd7 0024 0005 0008 0000 .........$......
-// 0x00b0: 0005 0202 0202 8000 0001 5433 002c ..........T3.,
-var testPacketOSPF3LSAck = []byte{
- 0x33, 0x33, 0x00, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x1f, 0xfa, 0x00, 0x01, 0x86, 0xdd, 0x6e, 0x00,
- 0x00, 0x00, 0x00, 0x88, 0x59, 0x01, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x03, 0x05, 0x00, 0x88, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x00, 0x01, 0x9d, 0x2c, 0x00, 0x00, 0x00, 0x05, 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- 0x02, 0x02, 0x80, 0x00, 0x00, 0x02, 0xb3, 0x54, 0x00, 0x18, 0x00, 0x06, 0x20, 0x03, 0x00, 0x00,
- 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x80, 0x00, 0x00, 0x01, 0x44, 0x73, 0x00, 0x24, 0x00, 0x06,
- 0x20, 0x03, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x80, 0x00, 0x00, 0x01, 0x9c, 0x11,
- 0x00, 0x24, 0x00, 0x06, 0x20, 0x03, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x80, 0x00,
- 0x00, 0x01, 0xcd, 0xba, 0x00, 0x24, 0x00, 0x06, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- 0x02, 0x02, 0x80, 0x00, 0x00, 0x01, 0xef, 0xd7, 0x00, 0x24, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00,
- 0x00, 0x05, 0x02, 0x02, 0x02, 0x02, 0x80, 0x00, 0x00, 0x01, 0x54, 0x33, 0x00, 0x2c,
-}
-
-func TestPacketOSPF3LSAck(t *testing.T) {
- p := gopacket.NewPacket(testPacketOSPF3LSAck, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeOSPF}, t)
- if got, ok := p.Layer(LayerTypeOSPF).(*OSPFv3); ok {
- want := &OSPFv3{
- OSPF: OSPF{
- Version: 3,
- Type: OSPFLinkStateAcknowledgment,
- PacketLength: 136,
- RouterID: 0x1010101,
- AreaID: 1,
- Checksum: 0x9d2c,
- Content: []LSAheader{
- LSAheader{
- LSAge: 5,
- LSType: 0x2001,
- LinkStateID: 0x00000000,
- AdvRouter: 0x02020202,
- LSSeqNumber: 0x80000002,
- LSChecksum: 0xb354,
- Length: 24,
- },
- LSAheader{
- LSAge: 6,
- LSType: 0x2003,
- LinkStateID: 0x00000003,
- AdvRouter: 0x02020202,
- LSSeqNumber: 0x80000001,
- LSChecksum: 0x4473,
- Length: 36,
- },
- LSAheader{
- LSAge: 6,
- LSType: 0x2003,
- LinkStateID: 0x00000002,
- AdvRouter: 0x02020202,
- LSSeqNumber: 0x80000001,
- LSChecksum: 0x9c11,
- Length: 36,
- },
- LSAheader{
- LSAge: 6,
- LSType: 0x2003,
- LinkStateID: 0x00000001,
- AdvRouter: 0x02020202,
- LSSeqNumber: 0x80000001,
- LSChecksum: 0xcdba,
- Length: 36,
- },
- LSAheader{
- LSAge: 6,
- LSType: 0x2003,
- LinkStateID: 0x00000000,
- AdvRouter: 0x02020202,
- LSSeqNumber: 0x80000001,
- LSChecksum: 0xefd7,
- Length: 36,
- },
- LSAheader{
- LSAge: 5,
- LSType: 0x0008,
- LinkStateID: 0x00000005,
- AdvRouter: 0x02020202,
- LSSeqNumber: 0x80000001,
- LSChecksum: 0x5433,
- Length: 44,
- },
- },
- },
- Instance: 0,
- Reserved: 0,
- }
- if !reflect.DeepEqual(got, want) {
- t.Errorf("OSPF packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- } else {
- t.Error("No OSPF layer type found in packet")
- }
-}
-func BenchmarkDecodePacketPacket4(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketOSPF3LSAck, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/prism_test.go b/vendor/github.com/google/gopacket/layers/prism_test.go
deleted file mode 100644
index 136a04c..0000000
--- a/vendor/github.com/google/gopacket/layers/prism_test.go
+++ /dev/null
@@ -1,120 +0,0 @@
-// Copyright 2014, Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "net"
- "reflect"
- "testing"
-
- "github.com/google/gopacket"
-)
-
-// Generator: python layers/test_creator.py --layerType=LayerTypePrismHeader --linkType=LinkTypePrismHeader --name=Prism%s ~/tmp/dump.pcap
-// http://wiki.wireshark.org/SampleCaptures#Sample_Captures
-
-// testPacketPrism is the packet:
-// 21:32:37.616872 BSSID:Broadcast DA:Broadcast SA:cc:fa:00:ad:79:e8 (oui Unknown) Probe Request () [1.0 2.0 5.5 11.0 Mbit]
-// 0x0000: 4400 0000 9000 0000 7261 3000 0000 0000
-// 0x0010: 0000 0000 0000 0000 4400 0100 0000 0400
-// 0x0020: f9c1 2900 4400 0200 0000 0000 0000 0000
-// 0x0030: 4400 0300 0000 0400 0a00 0000 4400 0400
-// 0x0040: 0000 0400 e1ff ffff 0000 0000 0000 0000
-// 0x0050: 0000 0000 4400 0600 0000 0400 0000 0000
-// 0x0060: 4400 0700 0000 0400 0000 0000 4400 0800
-// 0x0070: 0000 0400 0200 0000 4400 0900 0000 0000
-// 0x0080: 0000 0000 4400 0a00 0000 0400 7e00 0000
-// 0x0090: 4000 0000 ffff ffff ffff ccfa 00ad 79e8
-// 0x00a0: ffff ffff ffff a041 0000 0104 0204 0b16
-// 0x00b0: 3208 0c12 1824 3048 606c 0301 012d 1a2d
-// 0x00c0: 1117 ff00 0000 0000 0000 0000 0000 0000
-// 0x00d0: 0000 0000 0000 0000 007f 0800 0000 0000
-// 0x00e0: 0000 40dd 0900 1018 0200 0010 0000 dd1e
-// 0x00f0: 0090 4c33 2d11 17ff 0000 0000 0000 0000
-// 0x0100: 0000 0000 0000 0000 0000 0000 0000
-
-var testPacketPrism = []byte{
- 0x44, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x72, 0x61, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00,
- 0xf9, 0xc1, 0x29, 0x00, 0x44, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x44, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x44, 0x00, 0x04, 0x00,
- 0x00, 0x00, 0x04, 0x00, 0xe1, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x44, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x08, 0x00,
- 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x44, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x7e, 0x00, 0x00, 0x00,
- 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcc, 0xfa, 0x00, 0xad, 0x79, 0xe8,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa0, 0x41, 0x00, 0x00, 0x01, 0x04, 0x02, 0x04, 0x0b, 0x16,
- 0x32, 0x08, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c, 0x03, 0x01, 0x01, 0x2d, 0x1a, 0x2d,
- 0x11, 0x17, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0xdd, 0x09, 0x00, 0x10, 0x18, 0x02, 0x00, 0x00, 0x10, 0x00, 0x00, 0xdd, 0x1e,
- 0x00, 0x90, 0x4c, 0x33, 0x2d, 0x11, 0x17, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-}
-
-func TestPacketPrism(t *testing.T) {
- p := gopacket.NewPacket(testPacketPrism, LinkTypePrismHeader, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypePrismHeader, LayerTypeDot11, LayerTypeDot11MgmtProbeReq}, t)
-
- if got, ok := p.Layer(LayerTypePrismHeader).(*PrismHeader); ok {
- want := &PrismHeader{
- BaseLayer: BaseLayer{
- Contents: []uint8{0x44, 0x0, 0x0, 0x0, 0x90, 0x0, 0x0, 0x0, 0x72, 0x61, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x44, 0x0, 0x1, 0x0, 0x0, 0x0, 0x4, 0x0, 0xf9, 0xc1, 0x29, 0x0, 0x44, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x44, 0x0, 0x3, 0x0, 0x0, 0x0, 0x4, 0x0, 0xa, 0x0, 0x0, 0x0, 0x44, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0xe1, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x44, 0x0, 0x6, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x44, 0x0, 0x7, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x44, 0x0, 0x8, 0x0, 0x0, 0x0, 0x4, 0x0, 0x2, 0x0, 0x0, 0x0, 0x44, 0x0, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x44, 0x0, 0xa, 0x0, 0x0, 0x0, 0x4, 0x0, 0x7e, 0x0, 0x0, 0x0},
- Payload: []uint8{0x40, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcc, 0xfa, 0x0, 0xad, 0x79, 0xe8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa0, 0x41, 0x0, 0x0, 0x1, 0x4, 0x2, 0x4, 0xb, 0x16, 0x32, 0x8, 0xc, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c, 0x3, 0x1, 0x1, 0x2d, 0x1a, 0x2d, 0x11, 0x17, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7f, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x40, 0xdd, 0x9, 0x0, 0x10, 0x18, 0x2, 0x0, 0x0, 0x10, 0x0, 0x0, 0xdd, 0x1e, 0x0, 0x90, 0x4c, 0x33, 0x2d, 0x11, 0x17, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}, Code: 0x44, Length: 0x90, DeviceName: "ra0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
- Values: []PrismValue{
- PrismValue{DID: PrismDIDType1HostTime, Status: 0x0, Length: 0x4, Data: []uint8{0xf9, 0xc1, 0x29, 0x0}},
- PrismValue{DID: PrismDIDType1MACTime, Status: 0x0, Length: 0x0, Data: []uint8{}},
- PrismValue{DID: PrismDIDType1Channel, Status: 0x0, Length: 0x4, Data: []uint8{0xa, 0x0, 0x0, 0x0}},
- PrismValue{DID: PrismDIDType1RSSI, Status: 0x0, Length: 0x4, Data: []uint8{0xe1, 0xff, 0xff, 0xff}},
- PrismValue{DID: 0x0, Status: 0x0, Length: 0x0, Data: []uint8{}},
- PrismValue{DID: PrismDIDType1Signal, Status: 0x0, Length: 0x4, Data: []uint8{0x0, 0x0, 0x0, 0x0}},
- PrismValue{DID: PrismDIDType1Noise, Status: 0x0, Length: 0x4, Data: []uint8{0x0, 0x0, 0x0, 0x0}},
- PrismValue{DID: PrismDIDType1Rate, Status: 0x0, Length: 0x4, Data: []uint8{0x2, 0x0, 0x0, 0x0}},
- PrismValue{DID: PrismDIDType1TransmittedFrameIndicator, Status: 0x0, Length: 0x0, Data: []uint8{}},
- PrismValue{DID: PrismDIDType1FrameLength, Status: 0x0, Length: 0x4, Data: []uint8{0x7e, 0x0, 0x0, 0x0}},
- },
- }
-
- if !reflect.DeepEqual(got, want) {
- t.Errorf("RadioTap packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- }
-
- if got, ok := p.Layer(LayerTypeDot11).(*Dot11); ok {
- want := &Dot11{
- BaseLayer: BaseLayer{
- Contents: []uint8{0x40, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcc, 0xfa, 0x0, 0xad, 0x79, 0xe8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa0, 0x41},
- Payload: []uint8{0x0, 0x0, 0x1, 0x4, 0x2, 0x4, 0xb, 0x16, 0x32, 0x8, 0xc, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c, 0x3, 0x1, 0x1, 0x2d, 0x1a, 0x2d, 0x11, 0x17, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7f, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x40, 0xdd, 0x9, 0x0, 0x10, 0x18, 0x2, 0x0, 0x0, 0x10, 0x0, 0x0, 0xdd, 0x1e, 0x0, 0x90, 0x4c, 0x33, 0x2d, 0x11, 0x17, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
- },
- Type: 0x10,
- Proto: 0x0,
- Flags: 0x0,
- DurationID: 0x0,
- Address1: net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
- Address2: net.HardwareAddr{0xcc, 0xfa, 0x0, 0xad, 0x79, 0xe8},
- Address3: net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
- Address4: net.HardwareAddr(nil),
- SequenceNumber: 0x041a,
- FragmentNumber: 0x0,
- Checksum: 0x0,
- }
-
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Dot11 packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- }
-}
-
-func BenchmarkDecodePacketPrism(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketPrism, LinkTypePrismHeader, gopacket.NoCopy)
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/radiotap_test.go b/vendor/github.com/google/gopacket/layers/radiotap_test.go
deleted file mode 100644
index 4d3c7d0..0000000
--- a/vendor/github.com/google/gopacket/layers/radiotap_test.go
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-package layers
-
-import (
- "github.com/google/gopacket"
- "testing"
-)
-
-// testPacketRadiotap0 is the packet:
-// 09:34:34.799438 1.0 Mb/s 2412 MHz 11b -58dB signal antenna 7 Acknowledgment RA:88:1f:a1:ae:9d:cb
-// 0x0000: 0000 1200 2e48 0000 1002 6c09 a000 c607 .....H....l.....
-// 0x0010: 0000 d400 0000 881f a1ae 9dcb c630 4b4b .............0KK
-var testPacketRadiotap0 = []byte{
- 0x00, 0x00, 0x12, 0x00, 0x2e, 0x48, 0x00, 0x00, 0x10, 0x02, 0x6c, 0x09, 0xa0, 0x00, 0xc6, 0x07,
- 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x88, 0x1f, 0xa1, 0xae, 0x9d, 0xcb, 0xc6, 0x30, 0x4b, 0x4b,
-}
-
-func TestPacketRadiotap0(t *testing.T) {
- p := gopacket.NewPacket(testPacketRadiotap0, LayerTypeRadioTap, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeRadioTap, LayerTypeDot11}, t)
- rt := p.Layer(LayerTypeRadioTap).(*RadioTap)
- if rt.ChannelFrequency != 2412 || rt.DBMAntennaSignal != -58 || rt.Antenna != 7 {
- t.Error("Radiotap decode error")
- }
- if rt.Rate != 2 { // 500Kbps unit
- t.Error("Radiotap Rate decode error")
- }
-}
-func BenchmarkDecodePacketRadiotap0(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketRadiotap0, LayerTypeRadioTap, gopacket.NoCopy)
- }
-}
-
-// testPacketRadiotap1 is the packet:
-// 05:24:21.380948 2412 MHz 11g -36dB signal antenna 5 65.0 Mb/s MCS 7 20 MHz lon GI
-// 0x0000: 0000 1500 2a48 0800 1000 6c09 8004 dc05 ....*H....l.....
-// 0x0010: 0000 0700 0748 112c 0000 3a9d aaf0 191c .....H.,..:.....
-// 0x0020: aba7 f213 9d00 3a9d aaf0 1970 b2ee a9f1 ......:....p....
-// 0x0030: 16 .
-var testPacketRadiotap1 = []byte{
- 0x00, 0x00, 0x15, 0x00, 0x2a, 0x48, 0x08, 0x00, 0x10, 0x00, 0x6c, 0x09, 0x80, 0x04, 0xdc, 0x05,
- 0x00, 0x00, 0x07, 0x00, 0x07, 0x48, 0x11, 0x2c, 0x00, 0x00, 0x3a, 0x9d, 0xaa, 0xf0, 0x19, 0x1c,
- 0xab, 0xa7, 0xf2, 0x13, 0x9d, 0x00, 0x3a, 0x9d, 0xaa, 0xf0, 0x19, 0x70, 0xb2, 0xee, 0xa9, 0xf1,
- 0x16,
-}
-
-func TestPacketRadiotap1(t *testing.T) {
- p := gopacket.NewPacket(testPacketRadiotap1, LayerTypeRadioTap, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeRadioTap, LayerTypeDot11}, t)
- rt := p.Layer(LayerTypeRadioTap).(*RadioTap)
- if rt.ChannelFrequency != 2412 || rt.DBMAntennaSignal != -36 || rt.Antenna != 5 {
- t.Error("Radiotap decode error")
- }
- if !rt.MCS.Known.MCSIndex() || rt.MCS.MCS != 7 {
- t.Error("Radiotap MCS error")
- }
- if !rt.MCS.Known.Bandwidth() || rt.MCS.Flags.Bandwidth() != 0 {
- t.Error("Radiotap bandwidth error")
- }
- if !rt.MCS.Known.GuardInterval() || rt.MCS.Flags.ShortGI() {
- t.Error("Radiotap GI error")
- }
-}
-func BenchmarkDecodePacketRadiotap1(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketRadiotap1, LayerTypeRadioTap, gopacket.NoCopy)
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/sflow_test.go b/vendor/github.com/google/gopacket/layers/sflow_test.go
deleted file mode 100644
index ca0f2ab..0000000
--- a/vendor/github.com/google/gopacket/layers/sflow_test.go
+++ /dev/null
@@ -1,1246 +0,0 @@
-// Copyright 2014 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-package layers
-
-import (
- "github.com/google/gopacket"
- "net"
- "reflect"
- "testing"
-)
-
-// Test packet collected from live network. See the test below for contents
-var SFlowTestPacket1 = []byte{
- 0x84, 0x2b, 0x2b, 0x16, 0x8b, 0x62, 0xf0, 0x50, 0x56, 0x85, 0x3a, 0xfd, 0x08, 0x00, 0x45, 0x00,
- 0x05, 0xbc, 0x9c, 0x04, 0x40, 0x00, 0xff, 0x11, 0xc7, 0x00, 0x0a, 0x01, 0xff, 0x0e, 0x0a, 0x01,
- 0x00, 0x1b, 0xc7, 0x57, 0x18, 0xc7, 0x05, 0xa8, 0x22, 0x3b, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
- 0x00, 0x01, 0x0a, 0x01, 0xf8, 0x16, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x9d, 0xfb, 0x40, 0x49,
- 0xc6, 0xcd, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x26,
- 0x27, 0xe8, 0x00, 0x00, 0x02, 0x13, 0x00, 0x00, 0x3e, 0x80, 0x50, 0xbd, 0xe5, 0x80, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x05, 0xd2, 0x00, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x3c, 0x8a, 0xb0, 0xe7, 0x54, 0x41, 0xb8, 0xca, 0x3a, 0x6d,
- 0xf0, 0x40, 0x08, 0x00, 0x45, 0x00, 0x05, 0xc0, 0x6b, 0xaa, 0x40, 0x00, 0x40, 0x06, 0x8f, 0x41,
- 0x0a, 0x01, 0x0e, 0x16, 0x36, 0xf0, 0xeb, 0x45, 0x76, 0xfd, 0x00, 0x50, 0xca, 0x77, 0xef, 0x96,
- 0xfc, 0x28, 0x63, 0x40, 0x50, 0x10, 0x00, 0x3c, 0x64, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
- 0xf4, 0x00, 0x00, 0x02, 0x77, 0x00, 0x00, 0x00, 0xfd, 0x3b, 0x8c, 0xe7, 0x04, 0x4a, 0x2d, 0xb2,
- 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x01, 0x48, 0xcc, 0x11, 0x0d, 0xe3, 0x00,
- 0x26, 0x85, 0x30, 0x00, 0x00, 0x07, 0x66, 0x00, 0x02, 0xd0, 0x8a, 0x00, 0x02, 0xce, 0xf0, 0x00,
- 0x29, 0x7e, 0x80, 0x00, 0x02, 0xd0, 0x98, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x26, 0x85, 0x30, 0x00,
- 0x00, 0x00, 0xf4, 0x00, 0x00, 0x02, 0x00, 0x00, 0x03, 0xe9, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
- 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x01, 0x5e, 0x5c, 0x1e, 0x00, 0x00, 0x02, 0x57, 0x00, 0x00,
- 0x07, 0xd0, 0xb1, 0x2f, 0xa2, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x57, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x05, 0xee, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x3c, 0x8a,
- 0xb0, 0xe7, 0x54, 0x41, 0xb8, 0xca, 0x3a, 0x6f, 0xbe, 0xd8, 0x08, 0x00, 0x45, 0x00, 0x05, 0xdc,
- 0x9f, 0xfd, 0x40, 0x00, 0x40, 0x06, 0x6a, 0xfa, 0x0a, 0x01, 0x0e, 0x10, 0x0a, 0x01, 0x08, 0x13,
- 0x23, 0x84, 0xb7, 0x22, 0x8a, 0xc9, 0x50, 0xb5, 0x4e, 0x10, 0x2a, 0x87, 0x80, 0x10, 0x06, 0x01,
- 0x10, 0xa6, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0xef, 0x1f, 0xf4, 0x07, 0x99, 0x3a, 0xd8, 0x5b,
- 0x01, 0x46, 0x09, 0x00, 0x0c, 0x00, 0x0c, 0x3c, 0xac, 0x4a, 0x1b, 0x06, 0x04, 0x78, 0x78, 0x4e,
- 0xc2, 0x05, 0x46, 0x43, 0x06, 0x04, 0x78, 0x78, 0xee, 0x9c, 0x00, 0x41, 0xef, 0x05, 0x81, 0x32,
- 0x1b, 0x06, 0x04, 0x78, 0x78, 0x56, 0x72, 0x05, 0x4e, 0x92, 0x00, 0x96, 0x39, 0x00, 0xea, 0x3f,
- 0x01, 0x15, 0xa3, 0x08, 0x04, 0x42, 0x6a, 0x82, 0x87, 0x08, 0x05, 0xcc, 0x00, 0x04, 0x00, 0x00,
- 0x03, 0xe9, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x01, 0x5a,
- 0xcd, 0xd0, 0x00, 0x00, 0x02, 0x55, 0x00, 0x00, 0x07, 0xd0, 0x95, 0x67, 0xe1, 0x30, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x46, 0x00, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x3c, 0x8a, 0xb0, 0xe7, 0x54, 0x41, 0xb8, 0xca, 0x3a, 0x6f,
- 0x11, 0x28, 0x08, 0x00, 0x45, 0x00, 0x04, 0x34, 0xdb, 0x36, 0x40, 0x00, 0x40, 0x06, 0x38, 0xac,
- 0x0a, 0x01, 0x0e, 0x11, 0x0a, 0x01, 0x00, 0xcf, 0x23, 0x84, 0xa0, 0x3f, 0x3c, 0xce, 0xd5, 0x4a,
- 0x72, 0x0b, 0x5d, 0x1a, 0x80, 0x10, 0x06, 0x01, 0x8a, 0x50, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a,
- 0xef, 0x1f, 0xa2, 0xba, 0xe6, 0xfa, 0xae, 0xb3, 0xfe, 0xcf, 0x00, 0x19, 0xcf, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0xb9, 0x79, 0xdd, 0x42, 0x00, 0x00, 0x02, 0x84, 0x9b, 0xa9, 0x02, 0xe2, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x06, 0x32, 0x39, 0x35, 0x34, 0x33, 0x36, 0x00, 0x00, 0x02, 0x70, 0xcd,
- 0x16, 0x40, 0xa6, 0x98, 0x88, 0x24, 0x06, 0x50, 0xb0, 0xf4, 0xee, 0x03, 0xa6, 0xfa, 0x87, 0xaf,
- 0xc1, 0x99, 0x52, 0x0d, 0x07, 0xa8, 0x00, 0x00, 0x03, 0xe9, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
- 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x02, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x20, 0xf2, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00,
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00,
- 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x54, 0x0b, 0xe4, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x03, 0x00, 0x01, 0x29, 0x82, 0x6d, 0xb0, 0x6c, 0x0b, 0xcb, 0x0d, 0xdd, 0x96, 0x00, 0x06,
- 0xa8, 0xc6, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x34, 0x02, 0x35, 0x58, 0x7c, 0x9e, 0x56, 0x64, 0x25, 0x71, 0x00, 0x70,
- 0x5a, 0xc4, 0x00, 0x09, 0x08, 0xf1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x01, 0x5e, 0x5c, 0x1f, 0x00, 0x00, 0x02, 0x57, 0x00, 0x00,
- 0x07, 0xd0, 0xb1, 0x2f, 0xaa, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x57, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x05, 0xee, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x3c, 0x8a,
- 0xb0, 0xe7, 0x54, 0x41, 0xb8, 0xca, 0x3a, 0x6f, 0xbe, 0xd8, 0x08, 0x00, 0x45, 0x00, 0x05, 0xdc,
- 0x0f, 0xba, 0x40, 0x00, 0x40, 0x06, 0xf4, 0x3f, 0x0a, 0x01, 0x0e, 0x10, 0x0a, 0x01, 0x0f, 0x11,
- 0x23, 0x84, 0xcd, 0xc0, 0xf4, 0x0e, 0x90, 0x23, 0xd7, 0x32, 0x8b, 0x31, 0x80, 0x10, 0x00, 0x1d,
- 0x6b, 0x12, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0xef, 0x1f, 0xf4, 0x28, 0xef, 0x1f, 0xec, 0x76,
- 0xaa, 0x25, 0x01, 0x04, 0xc0, 0xac, 0xfe, 0x25, 0x01, 0x8e, 0x25, 0x01, 0x16, 0xc7, 0x28, 0xfe,
- 0x7e, 0x70, 0xfe, 0x7e, 0x70, 0x52, 0x7e, 0x70, 0x15, 0x9b, 0xfe, 0x35, 0x01, 0xfe, 0x35, 0x01,
- 0x42, 0x35, 0x01, 0xfe, 0x95, 0x77, 0xfe, 0x95, 0x77, 0xfe, 0x95, 0x77, 0x52, 0x95, 0x77, 0x00,
- 0xd2, 0xfe, 0x70, 0x02, 0x92, 0x70, 0x02, 0x16, 0x60, 0x22, 0x00, 0x7e, 0xb2, 0x15, 0x00, 0x00,
- 0x03, 0xe9, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x01, 0x5a,
- 0xcd, 0xd1, 0x00, 0x00, 0x02, 0x55, 0x00, 0x00, 0x07, 0xd0, 0x95, 0x67, 0xe9, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x55, 0x00, 0x00, 0x02, 0x57, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x05, 0xee, 0x00, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0xb8, 0xca, 0x3a, 0x6f, 0xbe, 0xd8, 0xb8, 0xca, 0x3a, 0x6f,
- 0x11, 0x28, 0x08, 0x00, 0x45, 0x00, 0x05, 0xdc, 0xfe, 0x05, 0x40, 0x00, 0x40, 0x06, 0x06, 0xf4,
- 0x0a, 0x01, 0x0e, 0x11, 0x0a, 0x01, 0x0e, 0x10, 0x23, 0x84, 0xfa, 0x29, 0xae, 0xd4, 0x95, 0x03,
- 0x99, 0xb8, 0x77, 0xd0, 0x80, 0x10, 0x00, 0x1d, 0x6f, 0x4f, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a,
- 0xef, 0x1f, 0xa2, 0xcc, 0xef, 0x1f, 0xf4, 0x2c, 0xfe, 0xdb, 0x05, 0xa1, 0xdb, 0x04, 0x9e, 0xc0,
- 0xfe, 0x30, 0x08, 0xb2, 0x30, 0x08, 0xda, 0x2b, 0xbd, 0xfe, 0x2a, 0x01, 0xfe, 0x2a, 0x01, 0x21,
- 0x2a, 0x00, 0xb2, 0xfe, 0x57, 0xb0, 0xb6, 0x57, 0xb0, 0x14, 0x74, 0xf4, 0xf0, 0x4c, 0x05, 0x68,
- 0xfe, 0x54, 0x02, 0xfe, 0x54, 0x02, 0xd2, 0x54, 0x02, 0x00, 0xbe, 0xfe, 0x32, 0x0f, 0xb6, 0x32,
- 0x0f, 0x14, 0x2e, 0x16, 0xaf, 0x47, 0x00, 0x00, 0x03, 0xe9, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
- 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x94, 0x01, 0x5e, 0x5c, 0x20, 0x00, 0x00, 0x02, 0x57, 0x00, 0x00,
- 0x07, 0xd0, 0xb1, 0x2f, 0xb2, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x57, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x42, 0x3c, 0x8a,
- 0xb0, 0xe7, 0x54, 0x41, 0xb8, 0xca, 0x3a, 0x6f, 0xbe, 0xd8, 0x08, 0x00, 0x45, 0x00, 0x00, 0x34,
- 0xa8, 0x23, 0x40, 0x00, 0x40, 0x06, 0x61, 0x7f, 0x0a, 0x01, 0x0e, 0x10, 0x0a, 0x01, 0x0f, 0x10,
- 0x97, 0x91, 0x23, 0x84, 0x24, 0xfa, 0x91, 0xf7, 0xb4, 0xe8, 0xf3, 0x2d, 0x80, 0x10, 0x00, 0xab,
- 0x7b, 0x7d, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0xef, 0x1f, 0xf4, 0x36, 0xef, 0x1f, 0xdc, 0xde,
- 0x00, 0x00, 0x00, 0x00, 0x03, 0xe9, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-}
-
-// Test collected from the SFlow reference agent. Contains dummy data for several record types
-// that wern't available on an actual network for sampling.
-var SFlowTestPacket2 = []byte{
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
- 0x04, 0x88, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11, 0x38, 0x63, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00,
- 0x00, 0x01, 0xdc, 0xb8, 0x18, 0xc7, 0x04, 0x74, 0x02, 0x88, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
- 0x00, 0x01, 0xc0, 0xa8, 0x5b, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb5, 0x3a, 0x00, 0x00,
- 0xcb, 0x20, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x54, 0x00, 0x02,
- 0x1f, 0x6e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x1f, 0x6e, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
- 0x03, 0xed, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x68, 0x74,
- 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x6f,
- 0x72, 0x67, 0x00, 0x00, 0x00, 0x0f, 0x68, 0x6f, 0x73, 0x74, 0x31, 0x2e, 0x73, 0x66, 0x6c, 0x6f,
- 0x77, 0x2e, 0x6f, 0x72, 0x67, 0x06, 0x00, 0x00, 0x03, 0xec, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00,
- 0x00, 0x6a, 0x00, 0x00, 0x00, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x75, 0x73, 0x65,
- 0x72, 0xdc, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x10, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e,
- 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x75, 0x73, 0x65, 0x72, 0x00, 0x00, 0x03, 0xeb, 0x00, 0x00,
- 0x00, 0x64, 0x00, 0x00, 0x00, 0x01, 0x0d, 0x0c, 0x0b, 0x0a, 0x00, 0x00, 0xfd, 0xe9, 0x00, 0x00,
- 0x00, 0x7b, 0x00, 0x00, 0x03, 0xe7, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x01, 0xc8, 0x00, 0x00, 0x03, 0x15, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x2b, 0x67, 0x00, 0x00, 0x56, 0xce, 0x00, 0x00,
- 0x82, 0x35, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x09, 0x00, 0x00,
- 0x03, 0x78, 0x00, 0x00, 0x03, 0xe7, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
- 0x00, 0x0d, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x42, 0x00, 0x0c,
- 0x29, 0x67, 0xa0, 0xe5, 0x00, 0x50, 0x56, 0xc0, 0x00, 0x09, 0x08, 0x00, 0x45, 0x10, 0x00, 0x34,
- 0x92, 0xc3, 0x40, 0x00, 0x40, 0x06, 0x70, 0x8d, 0xc0, 0xa8, 0x5b, 0x01, 0xc0, 0xa8, 0x5b, 0x11,
- 0xd3, 0xdd, 0x00, 0x16, 0xe3, 0x2e, 0x84, 0x77, 0x13, 0x6d, 0xc5, 0x53, 0x80, 0x10, 0x1f, 0xf7,
- 0xe7, 0x7d, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0x2e, 0xc6, 0x70, 0x3a, 0x00, 0x0f, 0x84, 0x7a,
- 0xbc, 0xd2, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x90, 0x00, 0x02, 0x1f, 0x6f, 0x00, 0x00,
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x1f, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0xed, 0x00, 0x00,
- 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
- 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x6f, 0x72, 0x67, 0x00, 0x00,
- 0x00, 0x0f, 0x68, 0x6f, 0x73, 0x74, 0x31, 0x2e, 0x73, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x6f, 0x72,
- 0x67, 0x03, 0x00, 0x00, 0x03, 0xec, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00,
- 0x00, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x75, 0x73, 0x65, 0x72, 0x77, 0x00, 0x00,
- 0x00, 0x6a, 0x00, 0x00, 0x00, 0x10, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f,
- 0x6e, 0x20, 0x75, 0x73, 0x65, 0x72, 0x00, 0x00, 0x03, 0xeb, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00,
- 0x00, 0x01, 0x0d, 0x0c, 0x0b, 0x0a, 0x00, 0x00, 0xfd, 0xe9, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00,
- 0x03, 0xe7, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x7b, 0x00, 0x00, 0x01, 0xc8, 0x00, 0x00, 0x03, 0x15, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x03, 0x00, 0x00, 0x2b, 0x67, 0x00, 0x00, 0x56, 0xce, 0x00, 0x00, 0x82, 0x35, 0x00, 0x00,
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x09, 0x00, 0x00, 0x03, 0x78, 0x00, 0x00,
- 0x03, 0xe7, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00,
- 0x01, 0xb0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x01, 0x86, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x00, 0x50, 0x56, 0xc0, 0x00, 0x09,
- 0x00, 0x0c, 0x29, 0x67, 0xa0, 0xe5, 0x08, 0x00, 0x45, 0x10, 0x01, 0x74, 0xbb, 0xfa, 0x40, 0x00,
- 0x40, 0x06, 0x46, 0x16, 0xc0, 0xa8, 0x5b, 0x11, 0xc0, 0xa8, 0x5b, 0x01, 0x00, 0x16, 0xd3, 0xdd,
- 0x13, 0x6d, 0xc5, 0x53, 0xe3, 0x2e, 0x84, 0x77, 0x80, 0x18, 0x01, 0x10, 0x38, 0xca, 0x00, 0x00,
- 0x01, 0x01, 0x08, 0x0a, 0x00, 0x0f, 0x84, 0x7d, 0x2e, 0xc6, 0x70, 0x3a, 0xe3, 0x92, 0x97, 0x1a,
- 0x67, 0x3b, 0xac, 0xec, 0xfa, 0x43, 0x71, 0x5e, 0x36, 0xa1, 0x0a, 0xc6, 0x1a, 0x6a, 0xed, 0x08,
- 0xac, 0xf4, 0xbe, 0xd8, 0x36, 0x59, 0xf6, 0xe2, 0x3d, 0x34, 0x26, 0xf2, 0x42, 0xbd, 0x32, 0xd3,
- 0x37, 0x52, 0xb8, 0xf4, 0x38, 0xf0, 0xf4, 0xeb, 0x76, 0x3b, 0xda, 0x23, 0xf1, 0x92, 0x96, 0xca,
- 0xbb, 0x9c, 0x20, 0x0a, 0x38, 0x37, 0x6f, 0xd9, 0x26, 0xe6, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x01, 0x54, 0x00, 0x02, 0x1f, 0x70, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02,
- 0x1f, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x03, 0xed, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x14, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x66, 0x6c,
- 0x6f, 0x77, 0x2e, 0x6f, 0x72, 0x67, 0x00, 0x00, 0x00, 0x0f, 0x68, 0x6f, 0x73, 0x74, 0x31, 0x2e,
- 0x73, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x6f, 0x72, 0x67, 0xff, 0x00, 0x00, 0x03, 0xec, 0x00, 0x00,
- 0x00, 0x2c, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
- 0x20, 0x75, 0x73, 0x65, 0x72, 0x77, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x10, 0x64, 0x65,
- 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x75, 0x73, 0x65, 0x72, 0x00, 0x00,
- 0x03, 0xeb, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x01, 0x0d, 0x0c, 0x0b, 0x0a, 0x00, 0x00,
- 0xfd, 0xe9, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x03, 0xe7, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x01, 0xc8, 0x00, 0x00,
- 0x03, 0x15, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x2b, 0x67, 0x00, 0x00,
- 0x56, 0xce, 0x00, 0x00, 0x82, 0x35, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
- 0x03, 0x09, 0x00, 0x00, 0x03, 0x78, 0x00, 0x00, 0x03, 0xe7, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
- 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
- 0x00, 0x42, 0x00, 0x0c, 0x29, 0x67, 0xa0, 0xe5, 0x00, 0x50, 0x56, 0xc0, 0x00, 0x09, 0x08, 0x00,
- 0x45, 0x10, 0x00, 0x34, 0x65, 0x7d, 0x40, 0x00, 0x40, 0x06, 0x9d, 0xd3, 0xc0, 0xa8, 0x5b, 0x01,
- 0xc0, 0xa8, 0x5b, 0x11, 0xd3, 0xdd, 0x00, 0x16, 0xe3, 0x2e, 0x84, 0x77, 0x13, 0x6d, 0xc6, 0x93,
- 0x80, 0x10, 0x1f, 0xec, 0xe6, 0x43, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0x2e, 0xc6, 0x70, 0x3c,
- 0x00, 0x0f, 0x84, 0x7d, 0x00, 0x50,
-}
-
-// processor counter sample
-var SFlowTestPacket3 = []byte{
- 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01,
- 0x0a, 0x14, 0x04, 0x00, 0x00, 0x00, 0x00, 0x64,
- 0x00, 0x01, 0x78, 0xe0, 0x73, 0x03, 0x48, 0x78,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04,
- 0x00, 0x00, 0x00, 0x34, 0x00, 0x01, 0x78, 0xe0,
- 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xe9,
- 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x05, 0xaa,
- 0x00, 0x00, 0x05, 0x5a, 0x00, 0x00, 0x05, 0x32,
- 0x00, 0x00, 0x00, 0x00, 0xe7, 0x8d, 0x70, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x55, 0xe7, 0x70, 0x00,
-}
-
-// expanded flow sample - extended switch flow record
-var SFlowTestPacket4 = []byte{
- 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01,
- 0xc0, 0xa8, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x02, 0x7e, 0x32, 0xe0, 0xe4, 0x7c,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x01, 0x23,
- 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x03, 0x37, 0x00, 0x00, 0x56, 0x23,
- 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x04,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xe9,
- 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x03,
- 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05,
- 0xff, 0xff, 0xff, 0xff,
-}
-
-// expanded flow sample - extended router flow record
-var SFlowTestPacket5 = []byte{
- 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01,
- 0xc0, 0xa8, 0x01, 0x12, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x02, 0x7e, 0x32, 0xe0, 0xe4, 0x7c,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x01, 0x23,
- 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x03, 0x34, 0x00, 0x00, 0x56, 0x02,
- 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x04,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xea,
- 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01,
- 0xc0, 0xa8, 0x01, 0x21, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x80,
-}
-
-// expanded flow sample - Ipv4 Tunnel Ingress record
-var SFlowTestPacket6 = []byte{
- 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x00, 0x01, 0xbd, 0x50,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48,
- 0x00, 0x00, 0x00, 0x74, 0x02, 0x00, 0x03, 0xe8, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x00,
- 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2f,
- 0xc0, 0xa8, 0x00, 0x54, 0xc0, 0xa8, 0x00, 0x53, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-}
-
-// expanded flow sample - Ipv4 Tunnel Egress record
-var SFlowTestPacket7 = []byte{
- 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x42, 0x68,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48,
- 0x00, 0x00, 0x00, 0x12, 0x02, 0x00, 0x03, 0xe9, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c,
- 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x03, 0xff, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x00, 0x54,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
-}
-
-// expanded flow sample - extended router flow record IPv6 next hop
-var SFlowTestPacket8 = []byte{
- 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01,
- 0xc0, 0xa8, 0x01, 0x12, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x02, 0x7e, 0x32, 0xe0, 0xe4, 0x7c,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x01, 0x23,
- 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x03, 0x34, 0x00, 0x00, 0x56, 0x02,
- 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x04,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xea,
- 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02,
- 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80,
-}
-
-func TestDecodeUDPSFlow(t *testing.T) {
- p := gopacket.NewPacket(SFlowTestPacket1, LayerTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeUDP, LayerTypeSFlow}, t)
- if got, ok := p.TransportLayer().(*UDP); ok {
- want := &UDP{
- BaseLayer: BaseLayer{SFlowTestPacket1[34:42], SFlowTestPacket1[42:]},
- sPort: []byte{199, 87},
- dPort: []byte{24, 199},
- SrcPort: 51031,
- DstPort: 6343,
- Checksum: 8763,
- Length: 1448,
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("UDP layer mismatch, \nwant %#v\ngot %#v\n", want, got)
- }
- } else {
- t.Error("Transport layer packet not UDP")
- }
-}
-
-func TestDecodeSFlowDatagram(t *testing.T) {
- p := gopacket.NewPacket(SFlowTestPacket1, LayerTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeUDP, LayerTypeSFlow}, t)
- if got, ok := p.ApplicationLayer().(*SFlowDatagram); ok {
- want := &SFlowDatagram{
- DatagramVersion: uint32(5),
- AgentAddress: []byte{0xa, 0x1, 0xf8, 0x16},
- SubAgentID: uint32(17),
- SequenceNumber: uint32(40443),
- AgentUptime: uint32(1078576845),
- SampleCount: uint32(7),
- FlowSamples: []SFlowFlowSample{
- SFlowFlowSample{
- EnterpriseID: 0x0,
- Format: 0x1,
- SampleLength: 0xd0,
- SequenceNumber: 0x2627e8,
- SourceIDClass: 0x0,
- SourceIDIndex: 0x213,
- SamplingRate: 0x3e80,
- SamplePool: 0x50bde580,
- Dropped: 0x0,
- InputInterface: 0x213,
- OutputInterface: 0x0,
- RecordCount: 0x2,
- Records: []SFlowRecord{
- SFlowRawPacketFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: 0x1,
- FlowDataLength: 0x90,
- },
- HeaderProtocol: 0x1,
- FrameLength: 0x5d2,
- PayloadRemoved: 0x4,
- HeaderLength: 0x80,
- Header: gopacket.NewPacket(SFlowTestPacket1[134:262], LayerTypeEthernet, gopacket.Default),
- },
- SFlowExtendedSwitchFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: 0x3e9,
- FlowDataLength: 0x10,
- },
- IncomingVLAN: 0x202,
- IncomingVLANPriority: 0x0,
- OutgoingVLAN: 0x0,
- OutgoingVLANPriority: 0x0,
- },
- },
- },
- SFlowFlowSample{
- EnterpriseID: 0x0,
- Format: 0x1,
- SampleLength: 0xd0,
- SequenceNumber: 0x15e5c1e,
- SourceIDClass: 0x0,
- SourceIDIndex: 0x257,
- SamplingRate: 0x7d0,
- SamplePool: 0xb12fa290,
- Dropped: 0x0,
- InputInterface: 0x257,
- OutputInterface: 0x0,
- RecordCount: 0x2,
- Records: []SFlowRecord{
- SFlowRawPacketFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: 0x1,
- FlowDataLength: 0x90,
- },
- HeaderProtocol: 0x1,
- FrameLength: 0x5ee,
- PayloadRemoved: 0x4,
- HeaderLength: 0x80,
- Header: gopacket.NewPacket(SFlowTestPacket1[350:478], LayerTypeEthernet, gopacket.Default),
- },
- SFlowExtendedSwitchFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: 0x3e9,
- FlowDataLength: 0x10,
- },
- IncomingVLAN: 0x202,
- IncomingVLANPriority: 0x0,
- OutgoingVLAN: 0x0,
- OutgoingVLANPriority: 0x0,
- },
- },
- },
- SFlowFlowSample{
- EnterpriseID: 0x0,
- Format: 0x1,
- SampleLength: 0xd0,
- SequenceNumber: 0x15acdd0,
- SourceIDClass: 0x0,
- SourceIDIndex: 0x255,
- SamplingRate: 0x7d0,
- SamplePool: 0x9567e130,
- Dropped: 0x0,
- InputInterface: 0x255,
- OutputInterface: 0x0,
- RecordCount: 0x2,
- Records: []SFlowRecord{
- SFlowRawPacketFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: 0x1,
- FlowDataLength: 0x90,
- },
- HeaderProtocol: 0x1,
- FrameLength: 0x446,
- PayloadRemoved: 0x4,
- HeaderLength: 0x80,
- Header: gopacket.NewPacket(SFlowTestPacket1[566:694], LayerTypeEthernet, gopacket.Default),
- },
- SFlowExtendedSwitchFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: 0x3e9,
- FlowDataLength: 0x10,
- },
- IncomingVLAN: 0x202,
- IncomingVLANPriority: 0x0,
- OutgoingVLAN: 0x0,
- OutgoingVLANPriority: 0x0,
- },
- },
- },
- SFlowFlowSample{
- EnterpriseID: 0x0,
- Format: 0x1,
- SampleLength: 0xd0,
- SequenceNumber: 0x15e5c1f,
- SourceIDClass: 0x0,
- SourceIDIndex: 0x257,
- SamplingRate: 0x7d0,
- SamplePool: 0xb12faa60,
- Dropped: 0x0,
- InputInterface: 0x257,
- OutputInterface: 0x0,
- RecordCount: 0x2,
- Records: []SFlowRecord{
- SFlowRawPacketFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: 0x1,
- FlowDataLength: 0x90,
- },
- HeaderProtocol: 0x1,
- FrameLength: 0x5ee,
- PayloadRemoved: 0x4,
- HeaderLength: 0x80,
- Header: gopacket.NewPacket(SFlowTestPacket1[958:1086], LayerTypeEthernet, gopacket.Default),
- },
- SFlowExtendedSwitchFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: 0x3e9,
- FlowDataLength: 0x10,
- },
- IncomingVLAN: 0x202,
- IncomingVLANPriority: 0x0,
- OutgoingVLAN: 0x0,
- OutgoingVLANPriority: 0x0,
- },
- },
- },
- SFlowFlowSample{
- EnterpriseID: 0x0,
- Format: 0x1,
- SampleLength: 0xd0,
- SequenceNumber: 0x15acdd1,
- SourceIDClass: 0x0,
- SourceIDIndex: 0x255,
- SamplingRate: 0x7d0,
- SamplePool: 0x9567e900,
- Dropped: 0x0,
- InputInterface: 0x255,
- OutputInterface: 0x257,
- RecordCount: 0x2,
- Records: []SFlowRecord{
- SFlowRawPacketFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: 0x1,
- FlowDataLength: 0x90,
- },
- HeaderProtocol: 0x1,
- FrameLength: 0x5ee,
- PayloadRemoved: 0x4,
- HeaderLength: 0x80,
- Header: gopacket.NewPacket(SFlowTestPacket1[1174:1302], LayerTypeEthernet, gopacket.Default),
- },
- SFlowExtendedSwitchFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: 0x3e9,
- FlowDataLength: 0x10,
- },
- IncomingVLAN: 0x202,
- IncomingVLANPriority: 0x0,
- OutgoingVLAN: 0x202,
- OutgoingVLANPriority: 0x0,
- },
- },
- },
- SFlowFlowSample{
- EnterpriseID: 0x0,
- Format: 0x1,
- SampleLength: 0x94,
- SequenceNumber: 0x15e5c20,
- SourceIDClass: 0x0,
- SourceIDIndex: 0x257,
- SamplingRate: 0x7d0,
- SamplePool: 0xb12fb230,
- Dropped: 0x0,
- InputInterface: 0x257,
- OutputInterface: 0x0,
- RecordCount: 0x2,
- Records: []SFlowRecord{
- SFlowRawPacketFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: 0x1,
- FlowDataLength: 0x54,
- },
- HeaderProtocol: 0x1,
- FrameLength: 0x46,
- PayloadRemoved: 0x4,
- HeaderLength: 0x42,
- Header: gopacket.NewPacket(SFlowTestPacket1[1390:1458], LayerTypeEthernet, gopacket.Default),
- },
- SFlowExtendedSwitchFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: 0x3e9,
- FlowDataLength: 0x10,
- },
- IncomingVLAN: 0x202,
- IncomingVLANPriority: 0x0,
- OutgoingVLAN: 0x0,
- OutgoingVLANPriority: 0x0,
- },
- },
- },
- },
- CounterSamples: []SFlowCounterSample{
- SFlowCounterSample{
- Format: 0x2,
- SampleLength: 0xa8,
- SequenceNumber: 0x20f2,
- SourceIDClass: 0x0,
- SourceIDIndex: 0x20a,
- RecordCount: 0x2,
- Records: []SFlowRecord{
- SFlowGenericInterfaceCounters{
- SFlowBaseCounterRecord: SFlowBaseCounterRecord{
- EnterpriseID: 0x0,
- Format: 0x1,
- FlowDataLength: 0x58,
- },
- IfIndex: 0x20a,
- IfType: 0x6,
- IfSpeed: 0x2540be400,
- IfDirection: 0x1,
- IfStatus: 0x3,
- IfInOctets: 0x129826db06c0b,
- IfInUcastPkts: 0xcb0ddd96,
- IfInMulticastPkts: 0x6a8c6,
- IfInBroadcastPkts: 0x7b,
- IfInDiscards: 0x0,
- IfInErrors: 0x0,
- IfInUnknownProtos: 0x0,
- IfOutOctets: 0x340235587c9e,
- IfOutUcastPkts: 0x56642571,
- IfOutMulticastPkts: 0x705ac4,
- IfOutBroadcastPkts: 0x908f1,
- IfOutDiscards: 0x0,
- IfOutErrors: 0x0,
- IfPromiscuousMode: 0x0,
- },
- SFlowEthernetCounters{
- SFlowBaseCounterRecord: SFlowBaseCounterRecord{
- EnterpriseID: 0x0,
- Format: 0x2,
- FlowDataLength: 0x34,
- },
- AlignmentErrors: 0x0,
- FCSErrors: 0x0,
- SingleCollisionFrames: 0x0,
- MultipleCollisionFrames: 0x0,
- SQETestErrors: 0x0,
- DeferredTransmissions: 0x0,
- LateCollisions: 0x0,
- ExcessiveCollisions: 0x0,
- InternalMacTransmitErrors: 0x0,
- CarrierSenseErrors: 0x0,
- FrameTooLongs: 0x0,
- InternalMacReceiveErrors: 0x0,
- SymbolErrors: 0x0,
- },
- },
- },
- },
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got)
- }
- } else {
- t.Error("Application layer packet not UDP")
- }
-}
-
-func TestPacketPacket0(t *testing.T) {
- p := gopacket.NewPacket(SFlowTestPacket2, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeUDP, LayerTypeSFlow}, t)
- if got, ok := p.ApplicationLayer().(*SFlowDatagram); ok {
- want := &SFlowDatagram{
- DatagramVersion: uint32(5),
- AgentAddress: []byte{192, 168, 91, 17},
- SubAgentID: uint32(0),
- SequenceNumber: uint32(46394),
- AgentUptime: uint32(52000),
- SampleCount: uint32(3),
- FlowSamples: []SFlowFlowSample{
- SFlowFlowSample{
- EnterpriseID: 0x0,
- Format: 0x1,
- SampleLength: 340,
- SequenceNumber: 139118,
- SourceIDClass: 0,
- SourceIDIndex: 3,
- SamplingRate: 1,
- SamplePool: 139118,
- Dropped: 0,
- InputInterface: 3,
- OutputInterface: 1073741823,
- RecordCount: 4,
- Records: []SFlowRecord{
- SFlowExtendedURLRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0,
- Format: 1005,
- FlowDataLength: 48,
- },
- Direction: SFlowURLsrc,
- URL: "http://www.sflow.org",
- Host: "host1.sflow.org",
- },
- SFlowExtendedUserFlow{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0,
- Format: 1004,
- FlowDataLength: 44,
- },
- SourceCharSet: SFlowCSUTF8,
- SourceUserID: "source user",
- DestinationCharSet: SFlowCSUTF8,
- DestinationUserID: "destination user",
- },
- SFlowExtendedGatewayFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0,
- Format: 1003,
- FlowDataLength: 100,
- },
- NextHop: []byte{0x0d, 0x0c, 0x0b, 0x0a},
- AS: 65001,
- SourceAS: 123,
- PeerAS: 999,
- ASPathCount: 3,
- ASPath: []SFlowASDestination{
- SFlowASDestination{
- Type: SFlowASSequence,
- Count: 3,
- Members: []uint32{123, 456, 789},
- },
- SFlowASDestination{
- Type: SFlowASSet,
- Count: 3,
- Members: []uint32{11111, 22222, 33333},
- },
- SFlowASDestination{
- Type: SFlowASSequence,
- Count: 3,
- Members: []uint32{777, 888, 999},
- },
- },
- Communities: []uint32{12, 13},
- LocalPref: 432,
- },
- SFlowRawPacketFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: 0x1,
- FlowDataLength: 84,
- },
- HeaderProtocol: 1,
- FrameLength: 70,
- PayloadRemoved: 4,
- HeaderLength: 0x42,
- Header: gopacket.NewPacket(SFlowTestPacket2[350:418], LayerTypeEthernet, gopacket.Default),
- },
- },
- },
- SFlowFlowSample{
- EnterpriseID: 0x0,
- Format: 0x1,
- SampleLength: 400,
- SequenceNumber: 139119,
- SourceIDClass: 0,
- SourceIDIndex: 3,
- SamplingRate: 1,
- SamplePool: 139119,
- Dropped: 0,
- InputInterface: 1073741823,
- OutputInterface: 3,
- RecordCount: 4,
- Records: []SFlowRecord{
- SFlowExtendedURLRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0,
- Format: 1005,
- FlowDataLength: 48,
- },
- Direction: SFlowURLsrc,
- URL: "http://www.sflow.org",
- Host: "host1.sflow.org",
- },
- SFlowExtendedUserFlow{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0,
- Format: 1004,
- FlowDataLength: 44,
- },
- SourceCharSet: SFlowCSUTF8,
- SourceUserID: "source user",
- DestinationCharSet: SFlowCSUTF8,
- DestinationUserID: "destination user",
- },
- SFlowExtendedGatewayFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0,
- Format: 1003,
- FlowDataLength: 100,
- },
- NextHop: []byte{0x0d, 0x0c, 0x0b, 0x0a},
- AS: 65001,
- SourceAS: 123,
- PeerAS: 999,
- ASPathCount: 3,
- ASPath: []SFlowASDestination{
- SFlowASDestination{
- Type: SFlowASSequence,
- Count: 3,
- Members: []uint32{123, 456, 789},
- },
- SFlowASDestination{
- Type: SFlowASSet,
- Count: 3,
- Members: []uint32{11111, 22222, 33333},
- },
- SFlowASDestination{
- Type: SFlowASSequence,
- Count: 3,
- Members: []uint32{777, 888, 999},
- },
- },
- Communities: []uint32{12, 13},
- LocalPref: 432,
- },
- SFlowRawPacketFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: 0x1,
- FlowDataLength: 144,
- },
- HeaderProtocol: 1,
- FrameLength: 390,
- PayloadRemoved: 4,
- HeaderLength: 0x80,
- Header: gopacket.NewPacket(SFlowTestPacket2[698:826], LayerTypeEthernet, gopacket.Default),
- },
- },
- },
- SFlowFlowSample{
- EnterpriseID: 0x0,
- Format: 0x1,
- SampleLength: 340,
- SequenceNumber: 139120,
- SourceIDClass: 0,
- SourceIDIndex: 3,
- SamplingRate: 1,
- SamplePool: 139120,
- Dropped: 0,
- InputInterface: 3,
- OutputInterface: 1073741823,
- RecordCount: 4,
- Records: []SFlowRecord{
- SFlowExtendedURLRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0,
- Format: 1005,
- FlowDataLength: 48,
- },
- Direction: SFlowURLsrc,
- URL: "http://www.sflow.org",
- Host: "host1.sflow.org",
- },
- SFlowExtendedUserFlow{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0,
- Format: 1004,
- FlowDataLength: 44,
- },
- SourceCharSet: SFlowCSUTF8,
- SourceUserID: "source user",
- DestinationCharSet: SFlowCSUTF8,
- DestinationUserID: "destination user",
- },
- SFlowExtendedGatewayFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0,
- Format: 1003,
- FlowDataLength: 100,
- },
- NextHop: []byte{0x0d, 0x0c, 0x0b, 0x0a},
- AS: 65001,
- SourceAS: 123,
- PeerAS: 999,
- ASPathCount: 3,
- ASPath: []SFlowASDestination{
- SFlowASDestination{
- Type: SFlowASSequence,
- Count: 3,
- Members: []uint32{123, 456, 789},
- },
- SFlowASDestination{
- Type: SFlowASSet,
- Count: 3,
- Members: []uint32{11111, 22222, 33333},
- },
- SFlowASDestination{
- Type: SFlowASSequence,
- Count: 3,
- Members: []uint32{777, 888, 999},
- },
- },
- Communities: []uint32{12, 13},
- LocalPref: 432,
- },
- SFlowRawPacketFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: 0x1,
- FlowDataLength: 84,
- },
- HeaderProtocol: 1,
- FrameLength: 70,
- PayloadRemoved: 4,
- HeaderLength: 0x42,
- Header: gopacket.NewPacket(SFlowTestPacket2[1106:1174], LayerTypeEthernet, gopacket.Default),
- },
- },
- },
- },
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got)
- }
- } else {
- t.Error("Application layer packet not UDP")
- }
-}
-
-func TestDecodeProcessorCounter(t *testing.T) {
- p := gopacket.NewPacket(SFlowTestPacket3, LayerTypeSFlow, gopacket.Default)
-
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t)
-
- got := p.ApplicationLayer().(*SFlowDatagram)
-
- want := &SFlowDatagram{
- DatagramVersion: uint32(5),
- AgentAddress: []byte{0x0a, 0x14, 0x04, 0x00},
- SubAgentID: uint32(0x64),
- SequenceNumber: uint32(96480),
- AgentUptime: uint32(1929595000),
- SampleCount: uint32(1),
- CounterSamples: []SFlowCounterSample{
- SFlowCounterSample{
- Format: SFlowTypeExpandedCounterSample,
- SampleLength: 0x34,
- SequenceNumber: 0x0178e0,
- SourceIDClass: 0x00,
- SourceIDIndex: 0x01,
- RecordCount: 0x01,
- Records: []SFlowRecord{
- SFlowProcessorCounters{
- SFlowBaseCounterRecord: SFlowBaseCounterRecord{
- EnterpriseID: 0x0,
- Format: SFlowTypeProcessorCounters,
- FlowDataLength: 0x1c,
- },
- FiveSecCpu: 0x05aa,
- OneMinCpu: 0x055a,
- FiveMinCpu: 0x0532,
- TotalMemory: 0xe78d7000,
- FreeMemory: 0x55e77000,
- },
- },
- },
- },
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got)
- }
-}
-
-func TestDecodeExtendedSwitchFlow(t *testing.T) {
- p := gopacket.NewPacket(SFlowTestPacket4, LayerTypeSFlow, gopacket.Default)
-
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t)
-
- got := p.ApplicationLayer().(*SFlowDatagram)
-
- want := &SFlowDatagram{
- DatagramVersion: uint32(5),
- AgentAddress: []byte{0xc0, 0xa8, 0x01, 0x07},
- SubAgentID: uint32(0x00),
- SequenceNumber: uint32(0x027e),
- AgentUptime: uint32(0x32e0e47c),
- SampleCount: uint32(1),
- FlowSamples: []SFlowFlowSample{
- SFlowFlowSample{
- Format: SFlowTypeFlowSample,
- SampleLength: 0x38,
- SequenceNumber: 0x123,
- SourceIDClass: 0x00,
- SourceIDIndex: 0x1d,
- SamplingRate: 0x100,
- SamplePool: 0x337,
- Dropped: 0x5623,
- InputInterfaceFormat: 0x00,
- InputInterface: 0x1d,
- OutputInterfaceFormat: 0x00,
- OutputInterface: 0x04,
- RecordCount: 0x01,
- Records: []SFlowRecord{
- SFlowExtendedSwitchFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: SFlowTypeExtendedSwitchFlow,
- FlowDataLength: 0x10,
- },
- IncomingVLAN: 0x03,
- IncomingVLANPriority: 0x02,
- OutgoingVLAN: 0x05,
- OutgoingVLANPriority: 0xffffffff,
- },
- },
- },
- },
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got)
- }
-}
-
-func TestDecodeExtendedRouterFlow(t *testing.T) {
- p := gopacket.NewPacket(SFlowTestPacket5, LayerTypeSFlow, gopacket.Default)
-
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t)
-
- got := p.ApplicationLayer().(*SFlowDatagram)
-
- want := &SFlowDatagram{
- DatagramVersion: uint32(5),
- AgentAddress: []byte{0xc0, 0xa8, 0x01, 0x12},
- SubAgentID: uint32(0x00),
- SequenceNumber: uint32(0x027e),
- AgentUptime: uint32(0x32e0e47c),
- SampleCount: uint32(1),
- FlowSamples: []SFlowFlowSample{
- SFlowFlowSample{
- Format: SFlowTypeFlowSample,
- SampleLength: 0x34,
- SequenceNumber: 0x123,
- SourceIDClass: 0x00,
- SourceIDIndex: 0x1d,
- SamplingRate: 0x100,
- SamplePool: 0x334,
- Dropped: 0x5602,
- InputInterfaceFormat: 0x00,
- InputInterface: 0x1d,
- OutputInterfaceFormat: 0x00,
- OutputInterface: 0x04,
- RecordCount: 0x01,
- Records: []SFlowRecord{
- SFlowExtendedRouterFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: SFlowTypeExtendedRouterFlow,
- FlowDataLength: 0x10,
- },
- NextHop: []byte{0xc0, 0xa8, 0x01, 0x21},
- NextHopSourceMask: 0xffffffff,
- NextHopDestinationMask: 0xffffff80,
- },
- },
- },
- },
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got)
- }
-}
-
-func TestDecodeExtendedRouterFlowIPv6(t *testing.T) {
- p := gopacket.NewPacket(SFlowTestPacket8, LayerTypeSFlow, gopacket.Default)
-
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t)
-
- got := p.ApplicationLayer().(*SFlowDatagram)
-
- want := &SFlowDatagram{
- DatagramVersion: uint32(5),
- AgentAddress: []byte{0xc0, 0xa8, 0x01, 0x12},
- SubAgentID: uint32(0x00),
- SequenceNumber: uint32(0x027e),
- AgentUptime: uint32(0x32e0e47c),
- SampleCount: uint32(1),
- FlowSamples: []SFlowFlowSample{
- SFlowFlowSample{
- Format: SFlowTypeFlowSample,
- SampleLength: 0x34,
- SequenceNumber: 0x123,
- SourceIDClass: 0x00,
- SourceIDIndex: 0x1d,
- SamplingRate: 0x100,
- SamplePool: 0x334,
- Dropped: 0x5602,
- InputInterfaceFormat: 0x00,
- InputInterface: 0x1d,
- OutputInterfaceFormat: 0x00,
- OutputInterface: 0x04,
- RecordCount: 0x01,
- Records: []SFlowRecord{
- SFlowExtendedRouterFlowRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: SFlowTypeExtendedRouterFlow,
- FlowDataLength: 0x1c,
- },
- NextHop: []byte{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
- NextHopSourceMask: 0xffffffff,
- NextHopDestinationMask: 0xffffff80,
- },
- },
- },
- },
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got)
- }
-}
-
-func TestDecodeExtendedIpv4TunnelIngressFlow(t *testing.T) {
- p := gopacket.NewPacket(SFlowTestPacket6, LayerTypeSFlow, gopacket.Default)
-
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t)
-
- got := p.ApplicationLayer().(*SFlowDatagram)
-
- want := &SFlowDatagram{
- DatagramVersion: uint32(5),
- AgentAddress: []byte{0x7f, 0x0, 0x0, 0x1},
- SubAgentID: uint32(0),
- SequenceNumber: uint32(0x72),
- AgentUptime: uint32(0x1bd50),
- SampleCount: uint32(1),
- FlowSamples: []SFlowFlowSample{
- SFlowFlowSample{
- Format: SFlowTypeFlowSample,
- SampleLength: 0x48,
- SequenceNumber: 0x74,
- SourceIDClass: 0x0,
- SourceIDIndex: 0x20003e8,
- SamplingRate: 0x1,
- SamplePool: 0x74,
- Dropped: 0x0,
- InputInterfaceFormat: 0x0,
- InputInterface: 0x0,
- OutputInterfaceFormat: 0x0,
- OutputInterface: 0x80000001,
- RecordCount: 0x1,
- Records: []SFlowRecord{
- SFlowExtendedIpv4TunnelIngressRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: SFlowTypeExtendedIpv4TunnelIngressFlow,
- FlowDataLength: 0x20,
- },
- SFlowIpv4Record: SFlowIpv4Record{
- Length: 0x0,
- Protocol: 0x2f,
- IPSrc: net.IP{0xc0, 0xa8, 0x0, 0x54},
- IPDst: net.IP{0xc0, 0xa8, 0x0, 0x53},
- PortSrc: 0x0,
- PortDst: 0x0,
- TCPFlags: 0x0,
- TOS: 0x0,
- },
- },
- },
- },
- },
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got)
- }
-}
-
-func TestDecodeExtendedIpv4TunnelEgressFlow(t *testing.T) {
- p := gopacket.NewPacket(SFlowTestPacket7, LayerTypeSFlow, gopacket.Default)
-
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t)
-
- got := p.ApplicationLayer().(*SFlowDatagram)
-
- want := &SFlowDatagram{
- DatagramVersion: uint32(5),
- AgentAddress: []byte{0x7f, 0x0, 0x0, 0x1},
- SubAgentID: uint32(1),
- SequenceNumber: uint32(0x12),
- AgentUptime: uint32(0x4268),
- SampleCount: uint32(1),
- FlowSamples: []SFlowFlowSample{
- SFlowFlowSample{
- Format: SFlowTypeFlowSample,
- SampleLength: 0x48,
- SequenceNumber: 0x12,
- SourceIDClass: 0x0,
- SourceIDIndex: 0x20003e9,
- SamplingRate: 0x1,
- SamplePool: 0x12,
- Dropped: 0x0,
- InputInterfaceFormat: 0x0,
- InputInterface: 0x6c,
- OutputInterfaceFormat: 0x0,
- OutputInterface: 0x80000001,
- RecordCount: 0x1,
- Records: []SFlowRecord{
- SFlowExtendedIpv4TunnelEgressRecord{
- SFlowBaseFlowRecord: SFlowBaseFlowRecord{
- EnterpriseID: 0x0,
- Format: SFlowTypeExtendedIpv4TunnelEgressFlow,
- FlowDataLength: 0x20,
- },
- SFlowIpv4Record: SFlowIpv4Record{
- Length: 0x0,
- Protocol: 0x0,
- IPSrc: net.IP{0x0, 0x0, 0x0, 0x0},
- IPDst: net.IP{0xc0, 0xa8, 0x0, 0x54},
- PortSrc: 0x0,
- PortDst: 0x0,
- TCPFlags: 0x0,
- TOS: 0x0,
- },
- },
- },
- },
- },
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got)
- }
-}
-
-func BenchmarkDecodeSFlowPacket1(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(SFlowTestPacket1, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-func BenchmarkDecodeSFlowPacket2(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(SFlowTestPacket2, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-func BenchmarkDecodeSFlowPacket3(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(SFlowTestPacket3, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-func BenchmarkDecodeSFlowPacket4(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(SFlowTestPacket4, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-func BenchmarkDecodeSFlowLayerPacket1(b *testing.B) {
- var sflow SFlowDatagram
- for i := 0; i < b.N; i++ {
- sflow.DecodeFromBytes(SFlowTestPacket1[ /*eth*/ 14+ /*ipv4*/ 20+ /*udp*/ 8:], gopacket.NilDecodeFeedback)
- }
-}
-
-func BenchmarkDecodeSFlowLayerPacket2(b *testing.B) {
- var sflow SFlowDatagram
- for i := 0; i < b.N; i++ {
- sflow.DecodeFromBytes(SFlowTestPacket2[ /*eth*/ 14+ /*ipv4*/ 20+ /*udp*/ 8:], gopacket.NilDecodeFeedback)
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/tcp_test.go b/vendor/github.com/google/gopacket/layers/tcp_test.go
deleted file mode 100644
index 56a6aaa..0000000
--- a/vendor/github.com/google/gopacket/layers/tcp_test.go
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 2016, Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "testing"
-
- "github.com/google/gopacket"
-)
-
-func TestTCPOptionKindString(t *testing.T) {
- testData := []struct {
- o *TCPOption
- s string
- }{
- {&TCPOption{
- OptionType: TCPOptionKindNop,
- OptionLength: 1,
- },
- "TCPOption(NOP:)"},
- {&TCPOption{
- OptionType: TCPOptionKindMSS,
- OptionLength: 4,
- OptionData: []byte{0x12, 0x34},
- },
- "TCPOption(MSS:4660 0x1234)"},
- {&TCPOption{
- OptionType: TCPOptionKindTimestamps,
- OptionLength: 10,
- OptionData: []byte{0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01},
- },
- "TCPOption(Timestamps:2/1 0x0000000200000001)"}}
-
- for _, tc := range testData {
- if s := tc.o.String(); s != tc.s {
- t.Errorf("expected %#v string to be %s, got %s", tc.o, tc.s, s)
- }
- }
-}
-
-func TestTCPSerializePadding(t *testing.T) {
- tcp := &TCP{}
- tcp.Options = append(tcp.Options, TCPOption{
- OptionType: TCPOptionKindNop,
- OptionLength: 1,
- })
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{FixLengths: true}
- err := gopacket.SerializeLayers(buf, opts, tcp)
- if err != nil {
- t.Fatal(err)
- }
- if len(buf.Bytes())%4 != 0 {
- t.Errorf("TCP data of len %d not padding to 32 bit boundary", len(buf.Bytes()))
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/tcpip_test.go b/vendor/github.com/google/gopacket/layers/tcpip_test.go
deleted file mode 100644
index c002e84..0000000
--- a/vendor/github.com/google/gopacket/layers/tcpip_test.go
+++ /dev/null
@@ -1,185 +0,0 @@
-// Copyright 2014, Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "github.com/google/gopacket"
- "net"
- "testing"
-)
-
-const (
- ipv4UDPChecksum = uint16(0xbc5f) // Wireshark
- ipv6UDPChecksumWithIPv6DstOpts = uint16(0x4d21) // Wireshark
- ipv6UDPChecksumJumbogram = uint16(0xcda8)
-)
-
-func createIPv4ChecksumTestLayer() (ip4 *IPv4) {
- ip4 = &IPv4{}
- ip4.Version = 4
- ip4.TTL = 64
- ip4.SrcIP = net.ParseIP("192.0.2.1")
- ip4.DstIP = net.ParseIP("198.51.100.1")
- return
-}
-
-func createIPv6ChecksumTestLayer() (ip6 *IPv6) {
- ip6 = &IPv6{}
- ip6.Version = 6
- ip6.NextHeader = IPProtocolNoNextHeader
- ip6.HopLimit = 64
- ip6.SrcIP = net.ParseIP("2001:db8::1")
- ip6.DstIP = net.ParseIP("2001:db8::2")
- return
-}
-
-func createIPv6DestinationChecksumTestLayer() (dst *IPv6Destination) {
- tlv := &IPv6DestinationOption{}
- tlv.OptionType = 0x01 //PadN
- tlv.OptionData = []byte{0x00, 0x00, 0x00, 0x00}
- dst = &IPv6Destination{}
- dst.Options = append(dst.Options, tlv)
- dst.NextHeader = IPProtocolNoNextHeader
- return
-}
-
-func createUDPChecksumTestLayer() (udp *UDP) {
- udp = &UDP{}
- udp.SrcPort = UDPPort(12345)
- udp.DstPort = UDPPort(9999)
- return
-}
-
-func TestIPv4UDPChecksum(t *testing.T) {
- var serialize []gopacket.SerializableLayer = make([]gopacket.SerializableLayer, 0, 2)
- var u *UDP
- var err error
-
- ip4 := createIPv4ChecksumTestLayer()
- ip4.Protocol = IPProtocolUDP
- serialize = append(serialize, ip4)
-
- udp := createUDPChecksumTestLayer()
- udp.SetNetworkLayerForChecksum(ip4)
- serialize = append(serialize, udp)
-
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{FixLengths: true, ComputeChecksums: true}
- err = gopacket.SerializeLayers(buf, opts, serialize...)
- if err != nil {
- t.Fatal(err)
- }
-
- p := gopacket.NewPacket(buf.Bytes(), LinkTypeRaw, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Fatal("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeIPv4, LayerTypeUDP}, t)
-
- if l, ok := p.Layer(LayerTypeUDP).(*UDP); !ok {
- t.Fatal("No UDP layer type found in packet")
- } else {
- u = l
- }
- got := u.Checksum
- want := ipv4UDPChecksum
- if got != want {
- t.Errorf("Bad checksum:\ngot:\n%#v\n\nwant:\n%#v\n\n", got, want)
- }
-}
-
-func TestIPv6UDPChecksumWithIPv6DstOpts(t *testing.T) {
- var serialize []gopacket.SerializableLayer = make([]gopacket.SerializableLayer, 0, 3)
- var u *UDP
- var err error
-
- ip6 := createIPv6ChecksumTestLayer()
- ip6.NextHeader = IPProtocolIPv6Destination
- serialize = append(serialize, ip6)
-
- dst := createIPv6DestinationChecksumTestLayer()
- dst.NextHeader = IPProtocolUDP
- serialize = append(serialize, dst)
-
- udp := createUDPChecksumTestLayer()
- udp.SetNetworkLayerForChecksum(ip6)
- serialize = append(serialize, udp)
-
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{FixLengths: true, ComputeChecksums: true}
- err = gopacket.SerializeLayers(buf, opts, serialize...)
- if err != nil {
- t.Fatal(err)
- }
-
- p := gopacket.NewPacket(buf.Bytes(), LinkTypeRaw, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Fatal("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeIPv6, LayerTypeIPv6Destination, LayerTypeUDP}, t)
-
- if l, ok := p.Layer(LayerTypeUDP).(*UDP); !ok {
- t.Fatal("No UDP layer type found in packet")
- } else {
- u = l
- }
- got := u.Checksum
- want := ipv6UDPChecksumWithIPv6DstOpts
- if got != want {
- t.Errorf("Bad checksum:\ngot:\n%#v\n\nwant:\n%#v\n\n", got, want)
- }
-}
-
-func TestIPv6JumbogramUDPChecksum(t *testing.T) {
- var serialize []gopacket.SerializableLayer = make([]gopacket.SerializableLayer, 0, 4)
- var u *UDP
- var err error
-
- ip6 := &IPv6{}
- ip6.Version = 6
- ip6.NextHeader = IPProtocolUDP
- ip6.HopLimit = 64
- ip6.SrcIP = net.ParseIP("2001:db8::1")
- ip6.DstIP = net.ParseIP("2001:db8::2")
- serialize = append(serialize, ip6)
-
- udp := &UDP{}
- udp.SrcPort = UDPPort(12345)
- udp.DstPort = UDPPort(9999)
- udp.SetNetworkLayerForChecksum(ip6)
- serialize = append(serialize, udp)
-
- payload := make([]byte, ipv6MaxPayloadLength+1)
- for i := range payload {
- payload[i] = 0xfe
- }
- serialize = append(serialize, gopacket.Payload(payload))
-
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{FixLengths: true, ComputeChecksums: true}
- err = gopacket.SerializeLayers(buf, opts, serialize...)
- if err != nil {
- t.Fatal(err)
- }
-
- p := gopacket.NewPacket(buf.Bytes(), LinkTypeRaw, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Fatal("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeIPv6, LayerTypeIPv6HopByHop, LayerTypeUDP, gopacket.LayerTypePayload}, t)
-
- if l, ok := p.Layer(LayerTypeUDP).(*UDP); !ok {
- t.Fatal("No UDP layer type found in packet")
- } else {
- u = l
- }
- got := u.Checksum
- want := ipv6UDPChecksumJumbogram
- if got != want {
- t.Errorf("Bad checksum:\ngot:\n%#v\n\nwant:\n%#v\n\n", got, want)
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/udp_test.go b/vendor/github.com/google/gopacket/layers/udp_test.go
deleted file mode 100644
index e71236c..0000000
--- a/vendor/github.com/google/gopacket/layers/udp_test.go
+++ /dev/null
@@ -1,372 +0,0 @@
-// Copyright 2012, Google, Inc. All rights reserved.
-// Copyright 2009-2011 Andreas Krennmair. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "reflect"
- "testing"
-
- "github.com/google/gopacket"
-)
-
-// testUDPPacketDNS is the packet:
-// 10:33:07.883637 IP 172.16.255.1.53 > 172.29.20.15.35181: 47320 7/0/0 MX ALT2.ASPMX.L.GOOGLE.com. 20, MX ASPMX2.GOOGLEMAIL.com. 30, MX ASPMX3.GOOGLEMAIL.com. 30, MX ASPMX4.GOOGLEMAIL.com. 30, MX ASPMX5.GOOGLEMAIL.com. 30, MX ASPMX.L.GOOGLE.com. 10, MX ALT1.ASPMX.L.GOOGLE.com. 20 (202)
-// 0x0000: 24be 0527 0b17 001f cab3 75c0 0800 4500 $..'......u...E.
-// 0x0010: 00e6 68cf 0000 3f11 a6f9 ac10 ff01 ac1d ..h...?.........
-// 0x0020: 140f 0035 896d 00d2 754a b8d8 8180 0001 ...5.m..uJ......
-// 0x0030: 0007 0000 0000 0478 6b63 6403 636f 6d00 .......xkcd.com.
-// 0x0040: 000f 0001 c00c 000f 0001 0000 0258 0018 .............X..
-// 0x0050: 0014 0441 4c54 3205 4153 504d 5801 4c06 ...ALT2.ASPMX.L.
-// 0x0060: 474f 4f47 4c45 c011 c00c 000f 0001 0000 GOOGLE..........
-// 0x0070: 0258 0016 001e 0641 5350 4d58 320a 474f .X.....ASPMX2.GO
-// 0x0080: 4f47 4c45 4d41 494c c011 c00c 000f 0001 OGLEMAIL........
-// 0x0090: 0000 0258 000b 001e 0641 5350 4d58 33c0 ...X.....ASPMX3.
-// 0x00a0: 53c0 0c00 0f00 0100 0002 5800 0b00 1e06 S.........X.....
-// 0x00b0: 4153 504d 5834 c053 c00c 000f 0001 0000 ASPMX4.S........
-// 0x00c0: 0258 000b 001e 0641 5350 4d58 35c0 53c0 .X.....ASPMX5.S.
-// 0x00d0: 0c00 0f00 0100 0002 5800 0400 0ac0 2dc0 ........X.....-.
-// 0x00e0: 0c00 0f00 0100 0002 5800 0900 1404 414c ........X.....AL
-// 0x00f0: 5431 c02d T1.-
-// Packet generated by doing DNS query for 'xkcd.com'
-var testUDPPacketDNS = []byte{
- 0x24, 0xbe, 0x05, 0x27, 0x0b, 0x17, 0x00, 0x1f, 0xca, 0xb3, 0x75, 0xc0, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0xe6, 0x68, 0xcf, 0x00, 0x00, 0x3f, 0x11, 0xa6, 0xf9, 0xac, 0x10, 0xff, 0x01, 0xac, 0x1d,
- 0x14, 0x0f, 0x00, 0x35, 0x89, 0x6d, 0x00, 0xd2, 0x75, 0x4a, 0xb8, 0xd8, 0x81, 0x80, 0x00, 0x01,
- 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x78, 0x6b, 0x63, 0x64, 0x03, 0x63, 0x6f, 0x6d, 0x00,
- 0x00, 0x0f, 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x00, 0x02, 0x58, 0x00, 0x18,
- 0x00, 0x14, 0x04, 0x41, 0x4c, 0x54, 0x32, 0x05, 0x41, 0x53, 0x50, 0x4d, 0x58, 0x01, 0x4c, 0x06,
- 0x47, 0x4f, 0x4f, 0x47, 0x4c, 0x45, 0xc0, 0x11, 0xc0, 0x0c, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x00,
- 0x02, 0x58, 0x00, 0x16, 0x00, 0x1e, 0x06, 0x41, 0x53, 0x50, 0x4d, 0x58, 0x32, 0x0a, 0x47, 0x4f,
- 0x4f, 0x47, 0x4c, 0x45, 0x4d, 0x41, 0x49, 0x4c, 0xc0, 0x11, 0xc0, 0x0c, 0x00, 0x0f, 0x00, 0x01,
- 0x00, 0x00, 0x02, 0x58, 0x00, 0x0b, 0x00, 0x1e, 0x06, 0x41, 0x53, 0x50, 0x4d, 0x58, 0x33, 0xc0,
- 0x53, 0xc0, 0x0c, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x00, 0x02, 0x58, 0x00, 0x0b, 0x00, 0x1e, 0x06,
- 0x41, 0x53, 0x50, 0x4d, 0x58, 0x34, 0xc0, 0x53, 0xc0, 0x0c, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x00,
- 0x02, 0x58, 0x00, 0x0b, 0x00, 0x1e, 0x06, 0x41, 0x53, 0x50, 0x4d, 0x58, 0x35, 0xc0, 0x53, 0xc0,
- 0x0c, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x00, 0x02, 0x58, 0x00, 0x04, 0x00, 0x0a, 0xc0, 0x2d, 0xc0,
- 0x0c, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x00, 0x02, 0x58, 0x00, 0x09, 0x00, 0x14, 0x04, 0x41, 0x4c,
- 0x54, 0x31, 0xc0, 0x2d,
-}
-
-func TestUDPPacketDNS(t *testing.T) {
- p := gopacket.NewPacket(testUDPPacketDNS, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeUDP, LayerTypeDNS}, t)
- if got, ok := p.TransportLayer().(*UDP); ok {
- want := &UDP{
- BaseLayer: BaseLayer{
- Contents: []byte{0x0, 0x35, 0x89, 0x6d, 0x0, 0xd2, 0x75, 0x4a},
- Payload: []byte{0xb8, 0xd8, 0x81, 0x80, 0x0, 0x1, 0x0,
- 0x7, 0x0, 0x0, 0x0, 0x0, 0x4, 0x78, 0x6b, 0x63, 0x64, 0x3, 0x63, 0x6f,
- 0x6d, 0x0, 0x0, 0xf, 0x0, 0x1, 0xc0, 0xc, 0x0, 0xf, 0x0, 0x1, 0x0, 0x0,
- 0x2, 0x58, 0x0, 0x18, 0x0, 0x14, 0x4, 0x41, 0x4c, 0x54, 0x32, 0x5, 0x41,
- 0x53, 0x50, 0x4d, 0x58, 0x1, 0x4c, 0x6, 0x47, 0x4f, 0x4f, 0x47, 0x4c,
- 0x45, 0xc0, 0x11, 0xc0, 0xc, 0x0, 0xf, 0x0, 0x1, 0x0, 0x0, 0x2, 0x58, 0x0,
- 0x16, 0x0, 0x1e, 0x6, 0x41, 0x53, 0x50, 0x4d, 0x58, 0x32, 0xa, 0x47, 0x4f,
- 0x4f, 0x47, 0x4c, 0x45, 0x4d, 0x41, 0x49, 0x4c, 0xc0, 0x11, 0xc0, 0xc,
- 0x0, 0xf, 0x0, 0x1, 0x0, 0x0, 0x2, 0x58, 0x0, 0xb, 0x0, 0x1e, 0x6, 0x41,
- 0x53, 0x50, 0x4d, 0x58, 0x33, 0xc0, 0x53, 0xc0, 0xc, 0x0, 0xf, 0x0, 0x1,
- 0x0, 0x0, 0x2, 0x58, 0x0, 0xb, 0x0, 0x1e, 0x6, 0x41, 0x53, 0x50, 0x4d,
- 0x58, 0x34, 0xc0, 0x53, 0xc0, 0xc, 0x0, 0xf, 0x0, 0x1, 0x0, 0x0, 0x2,
- 0x58, 0x0, 0xb, 0x0, 0x1e, 0x6, 0x41, 0x53, 0x50, 0x4d, 0x58, 0x35, 0xc0,
- 0x53, 0xc0, 0xc, 0x0, 0xf, 0x0, 0x1, 0x0, 0x0, 0x2, 0x58, 0x0, 0x4, 0x0,
- 0xa, 0xc0, 0x2d, 0xc0, 0xc, 0x0, 0xf, 0x0, 0x1, 0x0, 0x0, 0x2, 0x58, 0x0,
- 0x9, 0x0, 0x14, 0x4, 0x41, 0x4c, 0x54, 0x31, 0xc0, 0x2d},
- },
- SrcPort: 53,
- DstPort: 35181,
- Length: 210,
- Checksum: 30026,
- sPort: []byte{0x0, 0x35},
- dPort: []byte{0x89, 0x6d},
- }
- if !reflect.DeepEqual(got, want) {
- t.Errorf("UDP packet mismatch:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- } else {
- t.Error("Transport layer packet not UDP")
- }
-}
-
-func loadDNS(dnspacket []byte, t *testing.T) *DNS {
- p := gopacket.NewPacket(dnspacket, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4,
- LayerTypeUDP, LayerTypeDNS}, t)
-
- dnsL := p.Layer(LayerTypeDNS)
- if dnsL == nil {
- t.Error("No DNS Layer found")
- }
-
- dns, ok := dnsL.(*DNS)
- if !ok {
- return nil
- }
- return dns
-}
-
-var testDNSQueryA = []byte{
- 0xfe, 0x54, 0x00, 0x3e, 0x00, 0x96, 0x52, 0x54, /* .T.>..RT */
- 0x00, 0xbd, 0x1c, 0x70, 0x08, 0x00, 0x45, 0x00, /* ...p..E. */
- 0x00, 0x3c, 0x22, 0xe0, 0x00, 0x00, 0x40, 0x11, /* .<"...@. */
- 0xe2, 0x38, 0xc0, 0xa8, 0x7a, 0x46, 0xc0, 0xa8, /* .8..zF.. */
- 0x7a, 0x01, 0xc3, 0x35, 0x00, 0x35, 0x00, 0x28, /* z..5.5.( */
- 0x75, 0xd2, 0x52, 0x41, 0x01, 0x00, 0x00, 0x01, /* u.RA.... */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x77, /* .......w */
- 0x77, 0x77, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, /* ww.googl */
- 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, /* e.com... */
- 0x00, 0x01, /* .. */
-}
-
-func TestDNSQueryA(t *testing.T) {
- dns := loadDNS(testDNSQueryA, t)
- if dns == nil {
- t.Fatal("Failed to get a pointer to DNS struct")
- }
-
- if uint16(len(dns.Questions)) != dns.QDCount {
- t.Fatal("Invalid query decoding, not the right number of questions")
- }
-
- if string(dns.Questions[0].Name) != "www.google.com" {
- t.Errorf("Invalid query decoding, expecting 'www.google.com', got '%s'",
- dns.Questions[0].Name)
- }
- if dns.Questions[0].Class != DNSClassIN {
- t.Errorf("Invalid query decoding, expecting Class IN, got '%d'",
- dns.Questions[0].Class)
- }
-
- if dns.Questions[0].Type != DNSTypeA {
- t.Errorf("Invalid query decoding, expecting Type A, got '%d'",
- dns.Questions[0].Type)
- }
-}
-
-var testDNSRRA = []byte{
- 0x52, 0x54, 0x00, 0xbd, 0x1c, 0x70, 0xfe, 0x54, /* RT...p.T */
- 0x00, 0x3e, 0x00, 0x96, 0x08, 0x00, 0x45, 0x00, /* .>....E. */
- 0x01, 0x24, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11, /* .$..@.@. */
- 0xc4, 0x30, 0xc0, 0xa8, 0x7a, 0x01, 0xc0, 0xa8, /* .0..z... */
- 0x7a, 0x46, 0x00, 0x35, 0xc3, 0x35, 0x01, 0x10, /* zF.5.5.. */
- 0x76, 0xba, 0x52, 0x41, 0x81, 0x80, 0x00, 0x01, /* v.RA.... */
- 0x00, 0x06, 0x00, 0x04, 0x00, 0x04, 0x03, 0x77, /* .......w */
- 0x77, 0x77, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, /* ww.googl */
- 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, /* e.com... */
- 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, /* ........ */
- 0x00, 0x00, 0x01, 0x2c, 0x00, 0x04, 0x4a, 0x7d, /* ...,..J} */
- 0xc3, 0x67, 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, /* .g...... */
- 0x00, 0x00, 0x01, 0x2c, 0x00, 0x04, 0x4a, 0x7d, /* ...,..J} */
- 0xc3, 0x68, 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, /* .h...... */
- 0x00, 0x00, 0x01, 0x2c, 0x00, 0x04, 0x4a, 0x7d, /* ...,..J} */
- 0xc3, 0x69, 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, /* .i...... */
- 0x00, 0x00, 0x01, 0x2c, 0x00, 0x04, 0x4a, 0x7d, /* ...,..J} */
- 0xc3, 0x6a, 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, /* .j...... */
- 0x00, 0x00, 0x01, 0x2c, 0x00, 0x04, 0x4a, 0x7d, /* ...,..J} */
- 0xc3, 0x93, 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, /* ........ */
- 0x00, 0x00, 0x01, 0x2c, 0x00, 0x04, 0x4a, 0x7d, /* ...,..J} */
- 0xc3, 0x63, 0xc0, 0x10, 0x00, 0x02, 0x00, 0x01, /* .c...... */
- 0x00, 0x02, 0xa3, 0x00, 0x00, 0x06, 0x03, 0x6e, /* .......n */
- 0x73, 0x32, 0xc0, 0x10, 0xc0, 0x10, 0x00, 0x02, /* s2...... */
- 0x00, 0x01, 0x00, 0x02, 0xa3, 0x00, 0x00, 0x06, /* ........ */
- 0x03, 0x6e, 0x73, 0x33, 0xc0, 0x10, 0xc0, 0x10, /* .ns3.... */
- 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, 0xa3, 0x00, /* ........ */
- 0x00, 0x06, 0x03, 0x6e, 0x73, 0x31, 0xc0, 0x10, /* ...ns1.. */
- 0xc0, 0x10, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, /* ........ */
- 0xa3, 0x00, 0x00, 0x06, 0x03, 0x6e, 0x73, 0x34, /* .....ns4 */
- 0xc0, 0x10, 0xc0, 0xb0, 0x00, 0x01, 0x00, 0x01, /* ........ */
- 0x00, 0x02, 0xa3, 0x00, 0x00, 0x04, 0xd8, 0xef, /* ........ */
- 0x20, 0x0a, 0xc0, 0x8c, 0x00, 0x01, 0x00, 0x01, /* ....... */
- 0x00, 0x02, 0xa3, 0x00, 0x00, 0x04, 0xd8, 0xef, /* ........ */
- 0x22, 0x0a, 0xc0, 0x9e, 0x00, 0x01, 0x00, 0x01, /* "....... */
- 0x00, 0x02, 0xa3, 0x00, 0x00, 0x04, 0xd8, 0xef, /* ........ */
- 0x24, 0x0a, 0xc0, 0xc2, 0x00, 0x01, 0x00, 0x01, /* $....... */
- 0x00, 0x02, 0xa3, 0x00, 0x00, 0x04, 0xd8, 0xef, /* ........ */
- 0x26, 0x0a, /* &. */
-}
-
-func TestDNSRRA(t *testing.T) {
- dns := loadDNS(testDNSRRA, t)
- if dns == nil {
- t.Fatal("Failed to get a pointer to DNS struct")
- return
- }
-
- if uint16(len(dns.Questions)) != dns.QDCount {
- t.Fatal("Invalid query decoding, not the right number of questions")
- } else if uint16(len(dns.Answers)) != dns.ANCount {
- t.Fatal("Invalid query decoding, not the right number of answers")
- } else if uint16(len(dns.Authorities)) != dns.NSCount {
- t.Fatal("Invalid query decoding, not the right number of authorities")
- } else if uint16(len(dns.Additionals)) != dns.ARCount {
- t.Fatal("Invalid query decoding, not the right number of additionals info")
- }
-
- if string(dns.Questions[0].Name) != "www.google.com" {
- t.Errorf("Invalid query decoding, expecting 'www.google.com', got '%s'",
- dns.Questions[0].Name)
- }
- if string(dns.Answers[0].Name) != "www.google.com" {
- t.Errorf("Invalid query decoding, expecting 'www.google.com', got '%d'",
- dns.Questions[0].Class)
- }
- if dns.Answers[0].Class != DNSClassIN {
- t.Errorf("Invalid query decoding, expecting Class IN, got '%d'",
- dns.Questions[0].Class)
- }
- if dns.Answers[0].Type != DNSTypeA {
- t.Errorf("Invalid query decoding, expecting Type A, got '%d'",
- dns.Questions[0].Type)
- }
- if !dns.Answers[0].IP.Equal([]byte{74, 125, 195, 103}) {
- t.Errorf("Invalid query decoding, invalid IP address,"+
- " expecting '74.125.195.103', got '%s'",
- dns.Answers[0].IP.String())
- }
- if len(dns.Answers) != 6 {
- t.Errorf("No correct number of answers, expecting 6, go '%d'",
- len(dns.Answers))
- }
- if len(dns.Authorities) != 4 {
- t.Errorf("No correct number of answers, expecting 4, go '%d'",
- len(dns.Answers))
- }
- if len(dns.Additionals) != 4 {
- t.Errorf("No correct number of answers, expecting 4, go '%d'",
- len(dns.Answers))
- } else {
- for i, want := range []string{
- "ns1.google.com",
- "ns2.google.com",
- "ns3.google.com",
- "ns4.google.com",
- } {
- if got := string(dns.Additionals[i].Name); got != want {
- t.Errorf("got %q want %q", got, want)
- }
- }
- }
-}
-
-var testDNSAAAA = []byte{
- 0x52, 0x54, 0x00, 0xbd, 0x1c, 0x70, 0xfe, 0x54, /* RT...p.T */
- 0x00, 0x3e, 0x00, 0x96, 0x08, 0x00, 0x45, 0x00, /* .>....E. */
- 0x00, 0xe0, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11, /* ....@.@. */
- 0xc4, 0x74, 0xc0, 0xa8, 0x7a, 0x01, 0xc0, 0xa8, /* .t..z... */
- 0x7a, 0x46, 0x00, 0x35, 0xdb, 0x13, 0x00, 0xcc, /* zF.5.... */
- 0x76, 0x76, 0xf3, 0x03, 0x81, 0x80, 0x00, 0x01, /* vv...... */
- 0x00, 0x01, 0x00, 0x04, 0x00, 0x04, 0x03, 0x77, /* .......w */
- 0x77, 0x77, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, /* ww.googl */
- 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x1c, /* e.com... */
- 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x1c, 0x00, 0x01, /* ........ */
- 0x00, 0x00, 0x01, 0x2c, 0x00, 0x10, 0x2a, 0x00, /* ...,..*. */
- 0x14, 0x50, 0x40, 0x0c, 0x0c, 0x01, 0x00, 0x00, /* .P@..... */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x69, 0xc0, 0x10, /* .....i.. */
- 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, 0xa3, 0x00, /* ........ */
- 0x00, 0x06, 0x03, 0x6e, 0x73, 0x34, 0xc0, 0x10, /* ...ns4.. */
- 0xc0, 0x10, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, /* ........ */
- 0xa3, 0x00, 0x00, 0x06, 0x03, 0x6e, 0x73, 0x32, /* .....ns2 */
- 0xc0, 0x10, 0xc0, 0x10, 0x00, 0x02, 0x00, 0x01, /* ........ */
- 0x00, 0x02, 0xa3, 0x00, 0x00, 0x06, 0x03, 0x6e, /* .......n */
- 0x73, 0x31, 0xc0, 0x10, 0xc0, 0x10, 0x00, 0x02, /* s1...... */
- 0x00, 0x01, 0x00, 0x02, 0xa3, 0x00, 0x00, 0x06, /* ........ */
- 0x03, 0x6e, 0x73, 0x33, 0xc0, 0x10, 0xc0, 0x6c, /* .ns3...l */
- 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0xa3, 0x00, /* ........ */
- 0x00, 0x04, 0xd8, 0xef, 0x20, 0x0a, 0xc0, 0x5a, /* .... ..Z */
- 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0xa3, 0x00, /* ........ */
- 0x00, 0x04, 0xd8, 0xef, 0x22, 0x0a, 0xc0, 0x7e, /* ...."..~ */
- 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0xa3, 0x00, /* ........ */
- 0x00, 0x04, 0xd8, 0xef, 0x24, 0x0a, 0xc0, 0x48, /* ....$..H */
- 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0xa3, 0x00, /* ........ */
- 0x00, 0x04, 0xd8, 0xef, 0x26, 0x0a, /* ....&. */
-}
-
-func TestDNSAAAA(t *testing.T) {
- dns := loadDNS(testDNSAAAA, t)
- if dns == nil {
- t.Error("Failed to get a pointer to DNS struct")
- return
- }
-
- if len(dns.Questions) != 1 {
- t.Error("Invalid number of question")
- return
- }
- if dns.Questions[0].Type != DNSTypeAAAA {
- t.Errorf("Invalid question, Type is not AAAA, found %d",
- dns.Questions[0].Type)
- }
-
- if len(dns.Answers) != 1 {
- t.Error("Invalid number of answers")
- }
- if !dns.Answers[0].IP.Equal([]byte{0x2a, 0x00, 0x14, 0x50, 0x40,
- 0x0c, 0x0c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x69}) {
- t.Error("Invalid IP address, found ",
- dns.Answers[0].IP.String())
- }
-}
-
-var testDNSMXSOA = []byte{
- 0x52, 0x54, 0x00, 0xbd, 0x1c, 0x70, 0xfe, 0x54, /* RT...p.T */
- 0x00, 0x3e, 0x00, 0x96, 0x08, 0x00, 0x45, 0x00, /* .>....E. */
- 0x00, 0x6e, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11, /* .n..@.@. */
- 0xc4, 0xe6, 0xc0, 0xa8, 0x7a, 0x01, 0xc0, 0xa8, /* ....z... */
- 0x7a, 0x46, 0x00, 0x35, 0x9c, 0x60, 0x00, 0x5a, /* zF.5.`.Z */
- 0x76, 0x04, 0xfc, 0x7a, 0x81, 0x80, 0x00, 0x01, /* v..z.... */
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x77, /* .......w */
- 0x77, 0x77, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, /* ww.googl */
- 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x0f, /* e.com... */
- 0x00, 0x01, 0xc0, 0x10, 0x00, 0x06, 0x00, 0x01, /* ........ */
- 0x00, 0x00, 0x00, 0x3c, 0x00, 0x26, 0x03, 0x6e, /* ...<.&.n */
- 0x73, 0x31, 0xc0, 0x10, 0x09, 0x64, 0x6e, 0x73, /* s1...dns */
- 0x2d, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0xc0, 0x10, /* -admin.. */
- 0x00, 0x17, 0x9f, 0x64, 0x00, 0x00, 0x1c, 0x20, /* ...d... */
- 0x00, 0x00, 0x07, 0x08, 0x00, 0x12, 0x75, 0x00, /* ......u. */
- 0x00, 0x00, 0x01, 0x2c, /* ..., */
-}
-
-func TestDNSMXSOA(t *testing.T) {
- dns := loadDNS(testDNSMXSOA, t)
- if dns == nil {
- t.Error("Failed to get a pointer to DNS struct")
- return
- }
-
- if len(dns.Authorities) != 1 {
- t.Error("Invalid number of authoritative answers, found ",
- len(dns.Authorities))
- return
- }
-}
-
-func BenchmarkDecodeDNS(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testDNSQueryA, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-func BenchmarkDecodeDNSLayer(b *testing.B) {
- var dns DNS
- for i := 0; i < b.N; i++ {
- dns.DecodeFromBytes(testDNSAAAA[ /*eth*/ 14+ /*ipv4*/ 20+ /*udp*/ 8:], gopacket.NilDecodeFeedback)
- }
-}
-func TestDNSDoesNotMalloc(t *testing.T) {
- var dns DNS
- if n := testing.AllocsPerRun(1000, func() {
- if err := dns.DecodeFromBytes(testDNSAAAA[ /*eth*/ 14+ /*ipv4*/ 20+ /*udp*/ 8:], gopacket.NilDecodeFeedback); err != nil {
- t.Fatal(err)
- }
- }); n > 0 {
- t.Error(n, "mallocs decoding DNS")
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/usb_test.go b/vendor/github.com/google/gopacket/layers/usb_test.go
deleted file mode 100644
index 35e9c70..0000000
--- a/vendor/github.com/google/gopacket/layers/usb_test.go
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2014, Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- _ "fmt"
- "github.com/google/gopacket"
- "reflect"
- "testing"
-)
-
-// Generator python layers/test_creator.py --link_type USB --name USB dongle.pcap
-// http://wiki.wireshark.org/SampleCaptures#Sample_Captures
-
-// testPacketUSB0 is the packet:
-// 02:41:04.689546 INTERRUPT COMPLETE to 2:1:1
-// 0x0000: 0038 4a3b 0088 ffff 4301 8101 0200 2d00 .8J;....C.....-.
-// 0x0010: c0d3 5b50 0000 0000 8a85 0a00 0000 0000 ..[P............
-// 0x0020: 0100 0000 0100 0000 0000 0000 0000 0000 ................
-// 0x0030: 8000 0000 0000 0000 0002 0000 0000 0000 ................
-// 0x0040: 04 .
-var testPacketUSB0 = []byte{
- 0x00, 0x38, 0x4a, 0x3b, 0x00, 0x88, 0xff, 0xff, 0x43, 0x01, 0x81, 0x01, 0x02, 0x00, 0x2d, 0x00,
- 0xc0, 0xd3, 0x5b, 0x50, 0x00, 0x00, 0x00, 0x00, 0x8a, 0x85, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04,
-}
-
-func TestPacketUSB0(t *testing.T) {
- p := gopacket.NewPacket(testPacketUSB0, LinkTypeLinuxUSB, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeUSB, LayerTypeUSBInterrupt}, t)
-
- if got, ok := p.Layer(LayerTypeUSB).(*USB); ok {
- want := &USB{
- BaseLayer: BaseLayer{
- Contents: []uint8{0x0, 0x38, 0x4a, 0x3b, 0x0, 0x88, 0xff, 0xff, 0x43, 0x1, 0x81, 0x1, 0x2, 0x0, 0x2d, 0x0, 0xc0, 0xd3, 0x5b, 0x50, 0x0, 0x0, 0x0, 0x0, 0x8a, 0x85, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0},
- Payload: []uint8{0x4},
- },
- ID: 0xffff88003b4a3800,
- EventType: USBEventTypeComplete,
- TransferType: USBTransportTypeInterrupt,
- Direction: 0x1,
- EndpointNumber: 0x1,
- DeviceAddress: 0x1,
- BusID: 0x2,
- TimestampSec: 1348195264,
- TimestampUsec: 689546,
- Setup: false,
- Data: true,
- Status: 0,
- UrbLength: 0x1,
- UrbDataLength: 0x1,
- }
-
- if !reflect.DeepEqual(got, want) {
- t.Errorf("USB packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
- }
- }
-
-}
-func BenchmarkDecodePacketUSB0(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketUSB0, LinkTypeLinuxUSB, gopacket.NoCopy)
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/vrrp_test.go b/vendor/github.com/google/gopacket/layers/vrrp_test.go
deleted file mode 100644
index bc6b7e4..0000000
--- a/vendor/github.com/google/gopacket/layers/vrrp_test.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2016 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-package layers
-
-import (
- "github.com/google/gopacket"
- "testing"
-)
-
-// vrrpPacketPriority100 is the packet:
-// 06:12:21.813317 IP 192.168.0.30 > 224.0.0.18: VRRPv2, Advertisement, vrid 1, prio 100, authtype none, intvl 1s, length 20
-// 0x0000: 0100 5e00 0012 0000 5e00 0101 0800 45c0 ..^.....^.....E.
-// 0x0010: 0028 0000 0000 ff70 19cd c0a8 001e e000 .(.....p........
-// 0x0020: 0012 2101 6401 0001 ba52 c0a8 0001 0000 ..!.d....R......
-// 0x0030: 0000 0000 0000 0000 0000 0000 ............
-var vrrpPacketPriority100 = []byte{
- 0x01, 0x00, 0x5e, 0x00, 0x00, 0x12, 0x00, 0x00, 0x5e, 0x00, 0x01, 0x01, 0x08, 0x00, 0x45, 0xc0,
- 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0xff, 0x70, 0x19, 0xcd, 0xc0, 0xa8, 0x00, 0x1e, 0xe0, 0x00,
- 0x00, 0x12, 0x21, 0x01, 0x64, 0x01, 0x00, 0x01, 0xba, 0x52, 0xc0, 0xa8, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-}
-
-func TestVRRPPacketPacket0(t *testing.T) {
- p := gopacket.NewPacket(vrrpPacketPriority100, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeVRRP}, t)
-
- // Version=2 Type=VRRPv2 Advertisement VirtualRtrID=1 Priority=100
- vrrp := p.Layer(LayerTypeVRRP).(*VRRPv2)
- if vrrp.Version != 2 {
- t.Fatalf("Unable to decode VRRPv2 version. Received %d, expected %d", vrrp.Version, 2)
- }
-
- if vrrp.Type != 1 {
- t.Fatalf("Unable to decode VRRPv2 type. Received %d, expected %d", vrrp.Type, 1)
- }
-
- if vrrp.Priority != 100 {
- t.Fatalf("Unable to decode VRRPv2 priority. Received %d, expected %d", vrrp.Priority, 100)
- }
-
- if vrrp.Checksum != 47698 {
- t.Fatalf("Unable to decode VRRPv2 checksum. Received %d, expected %d", vrrp.Checksum, 47698)
- }
-}
-func BenchmarkDecodeVRRPPacket0(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(vrrpPacketPriority100, LayerTypeEthernet, gopacket.NoCopy)
- }
-}
diff --git a/vendor/github.com/google/gopacket/layers/vxlan_test.go b/vendor/github.com/google/gopacket/layers/vxlan_test.go
deleted file mode 100644
index a02d934..0000000
--- a/vendor/github.com/google/gopacket/layers/vxlan_test.go
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2016 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package layers
-
-import (
- "github.com/google/gopacket"
- "reflect"
- "testing"
-)
-
-// VXLAN is specifed in RFC 7348
-// 0 1 2 3
-// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-// 0 8 16 24 32
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |G|R|R|R|I|R|R|R|R|D|R|R|A|R|R|R| Group Policy ID |
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// | 24 bit VXLAN Network Identifier | Reserved |
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
-// Ethernet[IP[UDP[VXLAN[Ethernet[IP[ICMP]]]]]]
-
-// testPacketVXLAN
-// 0000 00 16 3e 08 71 cf 36 dc 85 1e b3 40 08 00 45 00 ..>.q.6....@..E.
-// 0010 00 86 d2 c0 40 00 40 11 51 52 c0 a8 cb 01 c0 a8 ....@.@.QR......
-// 0020 ca 01 b0 5d 12 b5 00 72 00 00 08 00 00 00 00 00 ...]...r........
-// 0030 00 00 00 30 88 01 00 02 00 16 3e 37 f6 04 08 00 ...0......>7....
-// 0040 45 00 00 54 00 00 40 00 40 01 23 4f c0 a8 cb 03 E..T..@.@.#O....
-// 0050 c0 a8 cb 05 08 00 f6 f2 05 0c 00 01 fc e2 97 51 ...............Q
-// 0060 00 00 00 00 a6 f8 02 00 00 00 00 00 10 11 12 13 ................
-// 0070 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 ............ !"#
-// 0080 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 $%&'()*+,-./0123
-// 0090 34 35 36 37 4567 ./01234567
-var testPacketVXLAN = []byte{
- 0x00, 0x16, 0x3e, 0x08, 0x71, 0xcf, 0x36, 0xdc, 0x85, 0x1e, 0xb3, 0x40, 0x08, 0x00, 0x45, 0x00,
- 0x00, 0x86, 0xd2, 0xc0, 0x40, 0x00, 0x40, 0x11, 0x51, 0x52, 0xc0, 0xa8, 0xcb, 0x01, 0xc0, 0xa8,
- 0xca, 0x01, 0xb0, 0x5d, 0x12, 0xb5, 0x00, 0x72, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0x00, 0x00, 0x30, 0x88, 0x01, 0x00, 0x02, 0x00, 0x16, 0x3e, 0x37, 0xf6, 0x04, 0x08, 0x00,
- 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00, 0x40, 0x01, 0x23, 0x4f, 0xc0, 0xa8, 0xcb, 0x03,
- 0xc0, 0xa8, 0xcb, 0x05, 0x08, 0x00, 0xf6, 0xf2, 0x05, 0x0c, 0x00, 0x01, 0xfc, 0xe2, 0x97, 0x51,
- 0x00, 0x00, 0x00, 0x00, 0xa6, 0xf8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x12, 0x13,
- 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
- 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
- 0x34, 0x35, 0x36, 0x37,
-}
-
-func TestPacketVXLAN(t *testing.T) {
- p := gopacket.NewPacket(testPacketVXLAN, LinkTypeEthernet, gopacket.Default)
- if p.ErrorLayer() != nil {
- t.Error("Failed to decode packet:", p.ErrorLayer().Error())
- }
- checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeUDP, LayerTypeVXLAN, LayerTypeEthernet, LayerTypeIPv4, LayerTypeICMPv4, gopacket.LayerTypePayload}, t)
- if got, ok := p.Layer(LayerTypeVXLAN).(*VXLAN); ok {
- want := &VXLAN{
- BaseLayer: BaseLayer{
- Contents: []byte{0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00},
- Payload: []byte{0x00, 0x30, 0x88, 0x01, 0x00, 0x02, 0x00, 0x16, 0x3e, 0x37, 0xf6, 0x04, 0x08, 0x00,
- 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00, 0x40, 0x01, 0x23, 0x4f, 0xc0, 0xa8, 0xcb, 0x03,
- 0xc0, 0xa8, 0xcb, 0x05, 0x08, 0x00, 0xf6, 0xf2, 0x05, 0x0c, 0x00, 0x01, 0xfc, 0xe2, 0x97, 0x51,
- 0x00, 0x00, 0x00, 0x00, 0xa6, 0xf8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x12, 0x13,
- 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
- 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
- 0x34, 0x35, 0x36, 0x37},
- },
- ValidIDFlag: true,
- VNI: 255,
- GBPExtension: false,
- GBPApplied: false,
- GBPDontLearn: false,
- GBPGroupPolicyID: 0,
- }
- if !reflect.DeepEqual(want, got) {
- t.Errorf("VXLAN layer mismatch, \nwant %#v\ngot %#v\n", want, got)
- }
- }
-}
-
-func BenchmarkDecodePacketVXLAN(b *testing.B) {
- for i := 0; i < b.N; i++ {
- gopacket.NewPacket(testPacketVXLAN, LinkTypeEthernet, gopacket.NoCopy)
- }
-}
-
-func TestIsomorphicPacketVXLAN(t *testing.T) {
- vx := &VXLAN{
- ValidIDFlag: true,
- VNI: 255,
- GBPExtension: true,
- GBPApplied: true,
- GBPDontLearn: true,
- GBPGroupPolicyID: 777,
- }
-
- b := gopacket.NewSerializeBuffer()
- vx.SerializeTo(b, gopacket.SerializeOptions{})
-
- p := gopacket.NewPacket(b.Bytes(), gopacket.DecodeFunc(decodeVXLAN), gopacket.Default)
- vxTranslated := p.Layer(LayerTypeVXLAN).(*VXLAN)
- vxTranslated.BaseLayer = BaseLayer{}
-
- if !reflect.DeepEqual(vx, vxTranslated) {
- t.Errorf("VXLAN isomorph mismatch, \nwant %#v\ngot %#v\n", vx, vxTranslated)
- }
-}