forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types_test.go
43 lines (37 loc) · 1.03 KB
/
types_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package sflow
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestRawPacketHeaderFlowData(t *testing.T) {
h := RawPacketHeaderFlowData{
HeaderProtocol: HeaderProtocolTypeEthernetISO88023,
FrameLength: 64,
Bytes: 64,
StrippedOctets: 0,
HeaderLength: 0,
Header: nil,
}
tags := h.GetTags()
fields := h.GetFields()
require.NotNil(t, fields)
require.NotNil(t, tags)
require.Contains(t, tags, "header_protocol")
require.Equal(t, 1, len(tags))
}
// process a raw ethernet packet without any encapsulated protocol
func TestEthHeader(t *testing.T) {
h := EthHeader{
DestinationMAC: [6]byte{0xca, 0xff, 0xee, 0xff, 0xe, 0x0},
SourceMAC: [6]byte{0xde, 0xad, 0xbe, 0xef, 0x0, 0x0},
TagProtocolIdentifier: 0x88B5, // IEEE Std 802 - Local Experimental Ethertype
TagControlInformation: 0,
EtherTypeCode: 0,
EtherType: "",
IPHeader: nil,
}
tags := h.GetTags()
fields := h.GetFields()
require.NotNil(t, fields)
require.NotNil(t, tags)
}