@@ -223,10 +223,12 @@ type ProtoInfo interface {
223
223
type ProtoInfoTCP struct {
224
224
State uint8
225
225
}
226
+
226
227
// Protocol returns "tcp".
227
- func (* ProtoInfoTCP ) Protocol () string {return "tcp" }
228
+ func (* ProtoInfoTCP ) Protocol () string { return "tcp" }
229
+
228
230
func (p * ProtoInfoTCP ) toNlData () ([]* nl.RtAttr , error ) {
229
- ctProtoInfo := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_PROTOINFO , []byte {})
231
+ ctProtoInfo := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_PROTOINFO , []byte {})
230
232
ctProtoInfoTCP := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_PROTOINFO_TCP , []byte {})
231
233
ctProtoInfoTCPState := nl .NewRtAttr (nl .CTA_PROTOINFO_TCP_STATE , nl .Uint8Attr (p .State ))
232
234
ctProtoInfoTCP .AddChild (ctProtoInfoTCPState )
@@ -236,14 +238,16 @@ func (p *ProtoInfoTCP) toNlData() ([]*nl.RtAttr, error) {
236
238
}
237
239
238
240
// ProtoInfoSCTP only supports the protocol name.
239
- type ProtoInfoSCTP struct {}
241
+ type ProtoInfoSCTP struct {}
242
+
240
243
// Protocol returns "sctp".
241
- func (* ProtoInfoSCTP ) Protocol () string {return "sctp" }
244
+ func (* ProtoInfoSCTP ) Protocol () string { return "sctp" }
242
245
243
246
// ProtoInfoDCCP only supports the protocol name.
244
- type ProtoInfoDCCP struct {}
247
+ type ProtoInfoDCCP struct {}
248
+
245
249
// Protocol returns "dccp".
246
- func (* ProtoInfoDCCP ) Protocol () string {return "dccp" }
250
+ func (* ProtoInfoDCCP ) Protocol () string { return "dccp" }
247
251
248
252
// The full conntrack flow structure is very complicated and can be found in the file:
249
253
// http://git.netfilter.org/libnetfilter_conntrack/tree/include/internal/object.h
@@ -261,7 +265,6 @@ type IPTuple struct {
261
265
// toNlData generates the inner fields of a nested tuple netlink datastructure
262
266
// does not generate the "nested"-flagged outer message.
263
267
func (t * IPTuple ) toNlData (family uint8 ) ([]* nl.RtAttr , error ) {
264
-
265
268
var srcIPsFlag , dstIPsFlag int
266
269
if family == nl .FAMILY_V4 {
267
270
srcIPsFlag = nl .CTA_IP_V4_SRC
@@ -285,7 +288,7 @@ func (t *IPTuple) toNlData(family uint8) ([]*nl.RtAttr, error) {
285
288
ctTupleProtoSrcPort := nl .NewRtAttr (nl .CTA_PROTO_SRC_PORT , nl .BEUint16Attr (t .SrcPort ))
286
289
ctTupleProto .AddChild (ctTupleProtoSrcPort )
287
290
ctTupleProtoDstPort := nl .NewRtAttr (nl .CTA_PROTO_DST_PORT , nl .BEUint16Attr (t .DstPort ))
288
- ctTupleProto .AddChild (ctTupleProtoDstPort , )
291
+ ctTupleProto .AddChild (ctTupleProtoDstPort )
289
292
290
293
return []* nl.RtAttr {ctTupleIP , ctTupleProto }, nil
291
294
}
@@ -362,7 +365,7 @@ func (s *ConntrackFlow) toNlData() ([]*nl.RtAttr, error) {
362
365
// <len, CTA_TIMEOUT>
363
366
// <BEuint64>
364
367
// <len, NLA_F_NESTED|CTA_PROTOINFO>
365
-
368
+
366
369
// CTA_TUPLE_ORIG
367
370
ctTupleOrig := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_TUPLE_ORIG , nil )
368
371
forwardFlowAttrs , err := s .Forward .toNlData (s .FamilyType )
@@ -540,17 +543,16 @@ func parseTimeStamp(r *bytes.Reader, readSize uint16) (tstart, tstop uint64) {
540
543
}
541
544
}
542
545
return
543
-
544
546
}
545
547
546
548
func parseProtoInfoTCPState (r * bytes.Reader ) (s uint8 ) {
547
549
binary .Read (r , binary .BigEndian , & s )
548
- r .Seek (nl .SizeofNfattr - 1 , seekCurrent )
550
+ r .Seek (nl .SizeofNfattr - 1 , seekCurrent )
549
551
return s
550
552
}
551
553
552
554
// parseProtoInfoTCP reads the entire nested protoinfo structure, but only parses the state attr.
553
- func parseProtoInfoTCP (r * bytes.Reader , attrLen uint16 ) ( * ProtoInfoTCP ) {
555
+ func parseProtoInfoTCP (r * bytes.Reader , attrLen uint16 ) * ProtoInfoTCP {
554
556
p := new (ProtoInfoTCP )
555
557
bytesRead := 0
556
558
for bytesRead < int (attrLen ) {
@@ -664,7 +666,7 @@ func parseRawData(data []byte) *ConntrackFlow {
664
666
switch t {
665
667
case nl .CTA_MARK :
666
668
s .Mark = parseConnectionMark (reader )
667
- case nl .CTA_LABELS :
669
+ case nl .CTA_LABELS :
668
670
s .Labels = parseConnectionLabels (reader )
669
671
case nl .CTA_TIMEOUT :
670
672
s .TimeOut = parseTimeOut (reader )
0 commit comments