@@ -223,10 +223,12 @@ type ProtoInfo interface {
223223type ProtoInfoTCP struct {
224224 State uint8
225225}
226+
226227// Protocol returns "tcp".
227- func (* ProtoInfoTCP ) Protocol () string {return "tcp" }
228+ func (* ProtoInfoTCP ) Protocol () string { return "tcp" }
229+
228230func (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 {})
230232 ctProtoInfoTCP := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_PROTOINFO_TCP , []byte {})
231233 ctProtoInfoTCPState := nl .NewRtAttr (nl .CTA_PROTOINFO_TCP_STATE , nl .Uint8Attr (p .State ))
232234 ctProtoInfoTCP .AddChild (ctProtoInfoTCPState )
@@ -236,14 +238,16 @@ func (p *ProtoInfoTCP) toNlData() ([]*nl.RtAttr, error) {
236238}
237239
238240// ProtoInfoSCTP only supports the protocol name.
239- type ProtoInfoSCTP struct {}
241+ type ProtoInfoSCTP struct {}
242+
240243// Protocol returns "sctp".
241- func (* ProtoInfoSCTP ) Protocol () string {return "sctp" }
244+ func (* ProtoInfoSCTP ) Protocol () string { return "sctp" }
242245
243246// ProtoInfoDCCP only supports the protocol name.
244- type ProtoInfoDCCP struct {}
247+ type ProtoInfoDCCP struct {}
248+
245249// Protocol returns "dccp".
246- func (* ProtoInfoDCCP ) Protocol () string {return "dccp" }
250+ func (* ProtoInfoDCCP ) Protocol () string { return "dccp" }
247251
248252// The full conntrack flow structure is very complicated and can be found in the file:
249253// http://git.netfilter.org/libnetfilter_conntrack/tree/include/internal/object.h
@@ -261,7 +265,6 @@ type IPTuple struct {
261265// toNlData generates the inner fields of a nested tuple netlink datastructure
262266// does not generate the "nested"-flagged outer message.
263267func (t * IPTuple ) toNlData (family uint8 ) ([]* nl.RtAttr , error ) {
264-
265268 var srcIPsFlag , dstIPsFlag int
266269 if family == nl .FAMILY_V4 {
267270 srcIPsFlag = nl .CTA_IP_V4_SRC
@@ -285,7 +288,7 @@ func (t *IPTuple) toNlData(family uint8) ([]*nl.RtAttr, error) {
285288 ctTupleProtoSrcPort := nl .NewRtAttr (nl .CTA_PROTO_SRC_PORT , nl .BEUint16Attr (t .SrcPort ))
286289 ctTupleProto .AddChild (ctTupleProtoSrcPort )
287290 ctTupleProtoDstPort := nl .NewRtAttr (nl .CTA_PROTO_DST_PORT , nl .BEUint16Attr (t .DstPort ))
288- ctTupleProto .AddChild (ctTupleProtoDstPort , )
291+ ctTupleProto .AddChild (ctTupleProtoDstPort )
289292
290293 return []* nl.RtAttr {ctTupleIP , ctTupleProto }, nil
291294}
@@ -362,7 +365,7 @@ func (s *ConntrackFlow) toNlData() ([]*nl.RtAttr, error) {
362365 // <len, CTA_TIMEOUT>
363366 // <BEuint64>
364367 // <len, NLA_F_NESTED|CTA_PROTOINFO>
365-
368+
366369 // CTA_TUPLE_ORIG
367370 ctTupleOrig := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_TUPLE_ORIG , nil )
368371 forwardFlowAttrs , err := s .Forward .toNlData (s .FamilyType )
@@ -540,17 +543,16 @@ func parseTimeStamp(r *bytes.Reader, readSize uint16) (tstart, tstop uint64) {
540543 }
541544 }
542545 return
543-
544546}
545547
546548func parseProtoInfoTCPState (r * bytes.Reader ) (s uint8 ) {
547549 binary .Read (r , binary .BigEndian , & s )
548- r .Seek (nl .SizeofNfattr - 1 , seekCurrent )
550+ r .Seek (nl .SizeofNfattr - 1 , seekCurrent )
549551 return s
550552}
551553
552554// 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 {
554556 p := new (ProtoInfoTCP )
555557 bytesRead := 0
556558 for bytesRead < int (attrLen ) {
@@ -664,7 +666,7 @@ func parseRawData(data []byte) *ConntrackFlow {
664666 switch t {
665667 case nl .CTA_MARK :
666668 s .Mark = parseConnectionMark (reader )
667- case nl .CTA_LABELS :
669+ case nl .CTA_LABELS :
668670 s .Labels = parseConnectionLabels (reader )
669671 case nl .CTA_TIMEOUT :
670672 s .TimeOut = parseTimeOut (reader )
0 commit comments