@@ -225,10 +225,12 @@ type ProtoInfo interface {
225225type ProtoInfoTCP struct {
226226 State uint8
227227}
228+
228229// Protocol returns "tcp".
229- func (* ProtoInfoTCP ) Protocol () string {return "tcp" }
230+ func (* ProtoInfoTCP ) Protocol () string { return "tcp" }
231+
230232func (p * ProtoInfoTCP ) toNlData () ([]* nl.RtAttr , error ) {
231- ctProtoInfo := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_PROTOINFO , []byte {})
233+ ctProtoInfo := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_PROTOINFO , []byte {})
232234 ctProtoInfoTCP := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_PROTOINFO_TCP , []byte {})
233235 ctProtoInfoTCPState := nl .NewRtAttr (nl .CTA_PROTOINFO_TCP_STATE , nl .Uint8Attr (p .State ))
234236 ctProtoInfoTCP .AddChild (ctProtoInfoTCPState )
@@ -238,14 +240,16 @@ func (p *ProtoInfoTCP) toNlData() ([]*nl.RtAttr, error) {
238240}
239241
240242// ProtoInfoSCTP only supports the protocol name.
241- type ProtoInfoSCTP struct {}
243+ type ProtoInfoSCTP struct {}
244+
242245// Protocol returns "sctp".
243- func (* ProtoInfoSCTP ) Protocol () string {return "sctp" }
246+ func (* ProtoInfoSCTP ) Protocol () string { return "sctp" }
244247
245248// ProtoInfoDCCP only supports the protocol name.
246- type ProtoInfoDCCP struct {}
249+ type ProtoInfoDCCP struct {}
250+
247251// Protocol returns "dccp".
248- func (* ProtoInfoDCCP ) Protocol () string {return "dccp" }
252+ func (* ProtoInfoDCCP ) Protocol () string { return "dccp" }
249253
250254// The full conntrack flow structure is very complicated and can be found in the file:
251255// http://git.netfilter.org/libnetfilter_conntrack/tree/include/internal/object.h
@@ -263,7 +267,6 @@ type IPTuple struct {
263267// toNlData generates the inner fields of a nested tuple netlink datastructure
264268// does not generate the "nested"-flagged outer message.
265269func (t * IPTuple ) toNlData (family uint8 ) ([]* nl.RtAttr , error ) {
266-
267270 var srcIPsFlag , dstIPsFlag int
268271 if family == nl .FAMILY_V4 {
269272 srcIPsFlag = nl .CTA_IP_V4_SRC
@@ -287,7 +290,7 @@ func (t *IPTuple) toNlData(family uint8) ([]*nl.RtAttr, error) {
287290 ctTupleProtoSrcPort := nl .NewRtAttr (nl .CTA_PROTO_SRC_PORT , nl .BEUint16Attr (t .SrcPort ))
288291 ctTupleProto .AddChild (ctTupleProtoSrcPort )
289292 ctTupleProtoDstPort := nl .NewRtAttr (nl .CTA_PROTO_DST_PORT , nl .BEUint16Attr (t .DstPort ))
290- ctTupleProto .AddChild (ctTupleProtoDstPort , )
293+ ctTupleProto .AddChild (ctTupleProtoDstPort )
291294
292295 return []* nl.RtAttr {ctTupleIP , ctTupleProto }, nil
293296}
@@ -364,7 +367,7 @@ func (s *ConntrackFlow) toNlData() ([]*nl.RtAttr, error) {
364367 // <len, CTA_TIMEOUT>
365368 // <BEuint64>
366369 // <len, NLA_F_NESTED|CTA_PROTOINFO>
367-
370+
368371 // CTA_TUPLE_ORIG
369372 ctTupleOrig := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_TUPLE_ORIG , nil )
370373 forwardFlowAttrs , err := s .Forward .toNlData (s .FamilyType )
@@ -542,17 +545,16 @@ func parseTimeStamp(r *bytes.Reader, readSize uint16) (tstart, tstop uint64) {
542545 }
543546 }
544547 return
545-
546548}
547549
548550func parseProtoInfoTCPState (r * bytes.Reader ) (s uint8 ) {
549551 binary .Read (r , binary .BigEndian , & s )
550- r .Seek (nl .SizeofNfattr - 1 , seekCurrent )
552+ r .Seek (nl .SizeofNfattr - 1 , seekCurrent )
551553 return s
552554}
553555
554556// parseProtoInfoTCP reads the entire nested protoinfo structure, but only parses the state attr.
555- func parseProtoInfoTCP (r * bytes.Reader , attrLen uint16 ) ( * ProtoInfoTCP ) {
557+ func parseProtoInfoTCP (r * bytes.Reader , attrLen uint16 ) * ProtoInfoTCP {
556558 p := new (ProtoInfoTCP )
557559 bytesRead := 0
558560 for bytesRead < int (attrLen ) {
@@ -666,7 +668,7 @@ func parseRawData(data []byte) *ConntrackFlow {
666668 switch t {
667669 case nl .CTA_MARK :
668670 s .Mark = parseConnectionMark (reader )
669- case nl .CTA_LABELS :
671+ case nl .CTA_LABELS :
670672 s .Labels = parseConnectionLabels (reader )
671673 case nl .CTA_TIMEOUT :
672674 s .TimeOut = parseTimeOut (reader )
0 commit comments