forked from sipcapture/heplify-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecoder_test.go
More file actions
173 lines (146 loc) · 12.8 KB
/
decoder_test.go
File metadata and controls
173 lines (146 loc) · 12.8 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package decoder
import (
"bytes"
"encoding/binary"
"testing"
"github.com/stretchr/testify/assert"
)
var hepPacket = []byte{0x48, 0x45, 0x50, 0x33, 0x3, 0xa, 0x0, 0x0, 0x0, 0x1, 0x0, 0x7, 0x2, 0x0, 0x0, 0x0, 0x2, 0x0, 0x7, 0x11, 0x0, 0x0, 0x0, 0x3, 0x0, 0xa, 0xc0, 0xa8, 0xf7, 0xfa, 0x0, 0x0, 0x0, 0x4, 0x0, 0xa, 0xc0, 0xa8, 0xf5, 0xfa, 0x0, 0x0, 0x0, 0x7, 0x0, 0x8, 0x13, 0xc4, 0x0, 0x0, 0x0, 0x8, 0x0, 0x8, 0x13, 0xc4, 0x0, 0x0, 0x0, 0x9, 0x0, 0xa, 0x5a, 0xa2, 0x9b, 0x98, 0x0, 0x0, 0x0, 0xa, 0x0, 0xa, 0x0, 0x1, 0xd2, 0xf4, 0x0, 0x0, 0x0, 0xb, 0x0, 0x7, 0x1, 0x0, 0x0, 0x0, 0xc, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe, 0x0, 0x6, 0x0, 0x0, 0x0, 0xf, 0x2, 0xa7, 0x53, 0x49, 0x50, 0x2f, 0x32, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x43, 0x61, 0x6c, 0x6c, 0x2d, 0x49, 0x44, 0x3a, 0x20, 0x42, 0x43, 0x30, 0x39, 0x39, 0x38, 0x38, 0x34, 0x40, 0x36, 0x64, 0x66, 0x63, 0x66, 0x66, 0x65, 0x38, 0xd, 0xa, 0x43, 0x53, 0x65, 0x71, 0x3a, 0x20, 0x32, 0x31, 0x35, 0x38, 0x33, 0x34, 0x34, 0x38, 0x39, 0x20, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0xd, 0xa, 0x46, 0x72, 0x6f, 0x6d, 0x3a, 0x20, 0x3c, 0x73, 0x69, 0x70, 0x3a, 0x31, 0x39, 0x32, 0x2e, 0x31, 0x36, 0x38, 0x2e, 0x31, 0x31, 0x31, 0x2e, 0x31, 0x31, 0x31, 0x3a, 0x35, 0x30, 0x36, 0x30, 0x3e, 0x3b, 0x74, 0x61, 0x67, 0x3d, 0x36, 0x64, 0x66, 0x63, 0x66, 0x66, 0x65, 0x38, 0x2b, 0x31, 0x2b, 0x62, 0x30, 0x61, 0x39, 0x30, 0x30, 0x30, 0x33, 0x2b, 0x63, 0x39, 0x65, 0x66, 0x63, 0x32, 0x30, 0x62, 0xd, 0xa, 0x54, 0x6f, 0x3a, 0x20, 0x3c, 0x73, 0x69, 0x70, 0x3a, 0x31, 0x39, 0x32, 0x2e, 0x31, 0x36, 0x38, 0x2e, 0x31, 0x31, 0x31, 0x2e, 0x31, 0x31, 0x31, 0x3a, 0x35, 0x30, 0x36, 0x30, 0x3b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x3d, 0x75, 0x64, 0x70, 0x3e, 0x3b, 0x74, 0x61, 0x67, 0x3d, 0x31, 0x38, 0x30, 0x34, 0x61, 0x34, 0x37, 0x64, 0x2b, 0x31, 0x2b, 0x65, 0x31, 0x30, 0x35, 0x30, 0x34, 0x37, 0x30, 0x2b, 0x62, 0x31, 0x32, 0x38, 0x61, 0x35, 0x36, 0x39, 0xd, 0xa, 0x56, 0x69, 0x61, 0x3a, 0x20, 0x53, 0x49, 0x50, 0x2f, 0x32, 0x2e, 0x30, 0x2f, 0x55, 0x44, 0x50, 0x20, 0x31, 0x39, 0x32, 0x2e, 0x31, 0x36, 0x38, 0x2e, 0x31, 0x31, 0x31, 0x2e, 0x31, 0x31, 0x31, 0x3a, 0x35, 0x30, 0x36, 0x30, 0x3b, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x3d, 0x7a, 0x39, 0x68, 0x47, 0x34, 0x62, 0x4b, 0x2b, 0x32, 0x31, 0x66, 0x31, 0x31, 0x33, 0x65, 0x37, 0x65, 0x33, 0x64, 0x30, 0x34, 0x63, 0x38, 0x34, 0x36, 0x31, 0x34, 0x38, 0x61, 0x39, 0x61, 0x64, 0x37, 0x36, 0x30, 0x37, 0x61, 0x65, 0x66, 0x61, 0x31, 0x2b, 0x36, 0x64, 0x66, 0x63, 0x66, 0x66, 0x65, 0x38, 0x2b, 0x31, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x3a, 0x20, 0x37, 0x38, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x73, 0x64, 0x70, 0xd, 0xa, 0x53, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x72, 0x65, 0x6c, 0x2c, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x72, 0xd, 0xa, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x65, 0x6e, 0xd, 0xa, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0xd, 0xa, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x73, 0x64, 0x70, 0x2c, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x69, 0x73, 0x75, 0x70, 0x2c, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x61, 0x72, 0x74, 0x2f, 0x6d, 0x69, 0x78, 0x65, 0x64, 0xd, 0xa, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x3a, 0x20, 0x49, 0x4e, 0x56, 0x49, 0x54, 0x45, 0x2c, 0x20, 0x41, 0x43, 0x4b, 0x2c, 0x20, 0x43, 0x41, 0x4e, 0x43, 0x45, 0x4c, 0x2c, 0x20, 0x42, 0x59, 0x45, 0x2c, 0x20, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x2c, 0x20, 0x4e, 0x4f, 0x54, 0x49, 0x46, 0x59, 0x2c, 0x20, 0x50, 0x52, 0x41, 0x43, 0x4b, 0x2c, 0x20, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x2c, 0x20, 0x49, 0x4e, 0x46, 0x4f, 0x2c, 0x20, 0x52, 0x45, 0x46, 0x45, 0x52, 0xd, 0xa, 0xd, 0xa, 0x76, 0x3d, 0x30, 0xd, 0xa, 0x6f, 0x3d, 0x2d, 0x20, 0x30, 0x20, 0x30, 0x20, 0x49, 0x4e, 0x20, 0x49, 0x50, 0x34, 0x20, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0xd, 0xa, 0x73, 0x3d, 0x2d, 0xd, 0xa, 0x63, 0x3d, 0x49, 0x4e, 0x20, 0x49, 0x50, 0x34, 0x20, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0xd, 0xa, 0x74, 0x3d, 0x30, 0x20, 0x30, 0xd, 0xa, 0x6d, 0x3d, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x20, 0x30, 0x20, 0x52, 0x54, 0x50, 0x2f, 0x41, 0x56, 0x50, 0x20, 0x38}
var rawPacket = []byte{0x0, 0xa, 0xa0, 0x0, 0xbe, 0xa8, 0x0, 0x26, 0x52, 0xe, 0xd3, 0x41, 0x8, 0x0, 0x45, 0x0, 0x2, 0xbd, 0xa1, 0xc3, 0x0, 0x0, 0x3e, 0x11, 0x69, 0x26, 0xc0, 0xa8, 0xf7, 0xfa, 0xc0, 0xa8, 0xf5, 0xfa, 0x13, 0xc4, 0x13, 0xc4, 0x2, 0xa9, 0x0, 0x0, 0x53, 0x49, 0x50, 0x2f, 0x32, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x43, 0x61, 0x6c, 0x6c, 0x2d, 0x49, 0x44, 0x3a, 0x20, 0x42, 0x43, 0x30, 0x39, 0x39, 0x38, 0x38, 0x34, 0x40, 0x36, 0x64, 0x66, 0x63, 0x66, 0x66, 0x65, 0x38, 0xd, 0xa, 0x43, 0x53, 0x65, 0x71, 0x3a, 0x20, 0x32, 0x31, 0x35, 0x38, 0x33, 0x34, 0x34, 0x38, 0x39, 0x20, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0xd, 0xa, 0x46, 0x72, 0x6f, 0x6d, 0x3a, 0x20, 0x3c, 0x73, 0x69, 0x70, 0x3a, 0x31, 0x39, 0x32, 0x2e, 0x31, 0x36, 0x38, 0x2e, 0x31, 0x31, 0x31, 0x2e, 0x31, 0x31, 0x31, 0x3a, 0x35, 0x30, 0x36, 0x30, 0x3e, 0x3b, 0x74, 0x61, 0x67, 0x3d, 0x36, 0x64, 0x66, 0x63, 0x66, 0x66, 0x65, 0x38, 0x2b, 0x31, 0x2b, 0x62, 0x30, 0x61, 0x39, 0x30, 0x30, 0x30, 0x33, 0x2b, 0x63, 0x39, 0x65, 0x66, 0x63, 0x32, 0x30, 0x62, 0xd, 0xa, 0x54, 0x6f, 0x3a, 0x20, 0x3c, 0x73, 0x69, 0x70, 0x3a, 0x31, 0x39, 0x32, 0x2e, 0x31, 0x36, 0x38, 0x2e, 0x31, 0x31, 0x31, 0x2e, 0x31, 0x31, 0x31, 0x3a, 0x35, 0x30, 0x36, 0x30, 0x3b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x3d, 0x75, 0x64, 0x70, 0x3e, 0x3b, 0x74, 0x61, 0x67, 0x3d, 0x31, 0x38, 0x30, 0x34, 0x61, 0x34, 0x37, 0x64, 0x2b, 0x31, 0x2b, 0x65, 0x31, 0x30, 0x35, 0x30, 0x34, 0x37, 0x30, 0x2b, 0x62, 0x31, 0x32, 0x38, 0x61, 0x35, 0x36, 0x39, 0xd, 0xa, 0x56, 0x69, 0x61, 0x3a, 0x20, 0x53, 0x49, 0x50, 0x2f, 0x32, 0x2e, 0x30, 0x2f, 0x55, 0x44, 0x50, 0x20, 0x31, 0x39, 0x32, 0x2e, 0x31, 0x36, 0x38, 0x2e, 0x31, 0x31, 0x31, 0x2e, 0x31, 0x31, 0x31, 0x3a, 0x35, 0x30, 0x36, 0x30, 0x3b, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x3d, 0x7a, 0x39, 0x68, 0x47, 0x34, 0x62, 0x4b, 0x2b, 0x32, 0x31, 0x66, 0x31, 0x31, 0x33, 0x65, 0x37, 0x65, 0x33, 0x64, 0x30, 0x34, 0x63, 0x38, 0x34, 0x36, 0x31, 0x34, 0x38, 0x61, 0x39, 0x61, 0x64, 0x37, 0x36, 0x30, 0x37, 0x61, 0x65, 0x66, 0x61, 0x31, 0x2b, 0x36, 0x64, 0x66, 0x63, 0x66, 0x66, 0x65, 0x38, 0x2b, 0x31, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x3a, 0x20, 0x37, 0x38, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x73, 0x64, 0x70, 0xd, 0xa, 0x53, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x72, 0x65, 0x6c, 0x2c, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x72, 0xd, 0xa, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x65, 0x6e, 0xd, 0xa, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0xd, 0xa, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x73, 0x64, 0x70, 0x2c, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x69, 0x73, 0x75, 0x70, 0x2c, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x61, 0x72, 0x74, 0x2f, 0x6d, 0x69, 0x78, 0x65, 0x64, 0xd, 0xa, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x3a, 0x20, 0x49, 0x4e, 0x56, 0x49, 0x54, 0x45, 0x2c, 0x20, 0x41, 0x43, 0x4b, 0x2c, 0x20, 0x43, 0x41, 0x4e, 0x43, 0x45, 0x4c, 0x2c, 0x20, 0x42, 0x59, 0x45, 0x2c, 0x20, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x2c, 0x20, 0x4e, 0x4f, 0x54, 0x49, 0x46, 0x59, 0x2c, 0x20, 0x50, 0x52, 0x41, 0x43, 0x4b, 0x2c, 0x20, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x2c, 0x20, 0x49, 0x4e, 0x46, 0x4f, 0x2c, 0x20, 0x52, 0x45, 0x46, 0x45, 0x52, 0xd, 0xa, 0xd, 0xa, 0x76, 0x3d, 0x30, 0xd, 0xa, 0x6f, 0x3d, 0x2d, 0x20, 0x30, 0x20, 0x30, 0x20, 0x49, 0x4e, 0x20, 0x49, 0x50, 0x34, 0x20, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0xd, 0xa, 0x73, 0x3d, 0x2d, 0xd, 0xa, 0x63, 0x3d, 0x49, 0x4e, 0x20, 0x49, 0x50, 0x34, 0x20, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0xd, 0xa, 0x74, 0x3d, 0x30, 0x20, 0x30, 0xd, 0xa, 0x6d, 0x3d, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x20, 0x30, 0x20, 0x52, 0x54, 0x50, 0x2f, 0x41, 0x56, 0x50, 0x20, 0x38}
func TestDecodeEncodeHEP(t *testing.T) {
hep, err := DecodeHEP(hepPacket)
if err != nil {
t.Error(err)
}
rawPacket := EncodeHEP(hep)
assert.Equal(t, hepPacket, rawPacket)
}
func BenchmarkEncodeHEP(b *testing.B) {
pkt, _ := DecodeHEP(hepPacket)
b.ResetTimer()
for i := 0; i < b.N; i++ {
val := EncodeHEP(pkt)
_ = val
}
}
func BenchmarkDecodeHEPSIP(b *testing.B) {
for i := 0; i < b.N; i++ {
val, _ := DecodeHEP(hepPacket)
_ = val
}
}
func BenchmarkDecodeHEP(b *testing.B) {
hep := &HEP{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
hep.parseHEP(hepPacket)
}
}
// EncodeHEP creates the HEP Packet which
// will be send to wire
func EncodeHEP(h *HEP) []byte {
buf := new(bytes.Buffer)
hepMsg := makeChuncks(h, buf)
binary.BigEndian.PutUint16(hepMsg[4:6], uint16(len(hepMsg)))
return hepMsg
}
// makeChuncks will construct the respective HEP chunck
func makeChuncks(h *HEP, w *bytes.Buffer) []byte {
w.Write(hepVer)
// hepMsg length placeholder. Will be written later
w.Write(hepLen)
// Chunk IP protocol family (0x02=IPv4, 0x0a=IPv6)
w.Write([]byte{0x00, 0x00, 0x00, 0x01})
w.Write(hepLen7)
w.WriteByte(byte(h.Version))
// Chunk IP protocol ID (0x06=TCP, 0x11=UDP)
w.Write([]byte{0x00, 0x00, 0x00, 0x02})
w.Write(hepLen7)
w.WriteByte(byte(h.Protocol))
if h.Version == 0x02 {
// Chunk IPv4 source address
w.Write([]byte{0x00, 0x00, 0x00, 0x03})
binary.BigEndian.PutUint16(hepLen, 6+uint16(len(h.NetSrcIP)))
w.Write(hepLen)
w.Write([]byte(h.NetSrcIP))
// Chunk IPv4 destination address
w.Write([]byte{0x00, 0x00, 0x00, 0x04})
binary.BigEndian.PutUint16(hepLen, 6+uint16(len(h.NetDstIP)))
w.Write(hepLen)
w.Write([]byte(h.NetDstIP))
} else if h.Version == 0x0a {
// Chunk IPv6 source address
w.Write([]byte{0x00, 0x00, 0x00, 0x05})
binary.BigEndian.PutUint16(hepLen, 6+uint16(len(h.NetSrcIP)))
w.Write(hepLen)
w.Write([]byte(h.NetSrcIP))
// Chunk IPv6 destination address
w.Write([]byte{0x00, 0x00, 0x00, 0x06})
binary.BigEndian.PutUint16(hepLen, 6+uint16(len(h.NetDstIP)))
w.Write(hepLen)
w.Write([]byte(h.NetDstIP))
}
// Chunk protocol source port
w.Write([]byte{0x00, 0x00, 0x00, 0x07})
w.Write(hepLen8)
binary.BigEndian.PutUint16(chunck16, uint16(h.SrcPort))
w.Write(chunck16)
// Chunk protocol destination port
w.Write([]byte{0x00, 0x00, 0x00, 0x08})
w.Write(hepLen8)
binary.BigEndian.PutUint16(chunck16, uint16(h.DstPort))
w.Write(chunck16)
// Chunk unix timestamp, seconds
w.Write([]byte{0x00, 0x00, 0x00, 0x09})
w.Write(hepLen10)
binary.BigEndian.PutUint32(chunck32, h.Tsec)
w.Write(chunck32)
// Chunk unix timestamp, microseconds offset
w.Write([]byte{0x00, 0x00, 0x00, 0x0a})
w.Write(hepLen10)
binary.BigEndian.PutUint32(chunck32, h.Tmsec)
w.Write(chunck32)
// Chunk protocol type (DNS, LOG, RTCP, SIP)
w.Write([]byte{0x00, 0x00, 0x00, 0x0b})
w.Write(hepLen7)
w.WriteByte(byte(h.ProtoType))
// Chunk capture agent ID
w.Write([]byte{0x00, 0x00, 0x00, 0x0c})
w.Write(hepLen10)
binary.BigEndian.PutUint32(chunck32, h.NodeID)
w.Write(chunck32)
// Chunk keep alive timer
//w.Write([]byte{0x00, 0x00, 0x00, 0x0d})
// Chunk authenticate key (plain text / TLS connection)
w.Write([]byte{0x00, 0x00, 0x00, 0x0e})
binary.BigEndian.PutUint16(hepLen, 6+uint16(len(h.NodePW)))
w.Write(hepLen)
w.Write([]byte(h.NodePW))
// Chunk captured packet payload
w.Write([]byte{0x00, 0x00, 0x00, 0x0f})
binary.BigEndian.PutUint16(hepLen, 6+uint16(len(h.Payload)))
w.Write(hepLen)
w.Write([]byte(h.Payload))
// Chunk captured compressed payload (gzip/inflate)
//w.Write([]byte{0x00,0x00, 0x00,0x10})
if h.CID != "" && h.ProtoType != 1 {
// Chunk internal correlation id
w.Write([]byte{0x00, 0x00, 0x00, 0x11})
binary.BigEndian.PutUint16(hepLen, 6+uint16(len(h.CID)))
w.Write(hepLen)
w.Write([]byte(h.CID))
}
/*
// Chunk VLAN
w.Write([]byte{0x00, 0x00, 0x00, 0x12})
w.Write(hepLen8)
binary.BigEndian.PutUint16(chunck16, uint16(h.Vlan))
w.Write(chunck16)
// Chunk MOS only
w.Write([]byte{0x00, 0x00, 0x00, 0x20})
w.Write(hepLen8)
binary.BigEndian.PutUint16(chunck16, h.MOS)
w.Write(chunck16)
*/
return w.Bytes()
}