-
Notifications
You must be signed in to change notification settings - Fork 7
/
types.go
94 lines (81 loc) · 1.9 KB
/
types.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// +build linux !darwin
package nflog
import (
"net"
"syscall"
"go.aporeto.io/netlink-go/common/syscallwrappers"
)
// NfLog -- Nflog struct
// Groups -- Nflog group to bind with. max 32
// CopyRange -- Nflog packetsize. 0: Unlimited
type NfLog struct {
Groups []uint16
CopyRange uint16
callback func(buf *NfPacket, data interface{})
errorCallback func(err error)
Socket SockHandle
NflogHandle NFLog
Syscalls syscallwrappers.Syscalls
}
// nflogHeader -- unexported header struct for parsing
type nflogHeader struct {
Family uint8
Version uint8
ResID uint16 // BigEndian
}
// nflogTlv -- unexported attribute struct for parsing
type nflogTlv struct {
Len uint16
Type uint16
}
// NflMsgConfigCommand -- NflMsgConfigCommand struct for configs (ex: bind)
type NflMsgConfigCommand struct {
command uint8
}
// NflMsgConfigMode -- NflMsgConfigMode struct for copy range and mode (ex: copy meta)
type NflMsgConfigMode struct {
copyRange uint32
copyMode uint8
}
//SockHandles -- Sock handle of netlink socket
//fd -- fd of socket
//rcvbufSize -- rcv buffer Size
//lsa -- local address
type SockHandles struct {
Syscalls syscallwrappers.Syscalls
fd int
rcvbufSize uint32
buf []byte
lsa syscall.SockaddrNetlink
}
// NfPacket -- NfPacket struct for parsing logs
// Payload -- Complete packet with ethernet,tcp and ip
// IPLayer -- Iplayer struct
// TCPLayer -- Tcplayer struct
// PacketPayload -- Tcp payload
type NfPacket struct {
Prefix string
Payload []byte
IPLayer
Ports
PacketPayload
NflogHandle *NfLog
}
// IPLayer -- IPLayer struct
type IPLayer struct {
SrcIP net.IP
DstIP net.IP
Version uint8
Protocol uint8
Length uint16
ID string
}
// Ports -- Generic struct for TCP and UDP ports
type Ports struct {
SrcPort uint16
DstPort uint16
}
// PacketPayload -- PacketPayload struct
type PacketPayload struct {
AppPayload []byte
}