@@ -218,10 +218,12 @@ type ProtoInfo interface {
218218type ProtoInfoTCP struct {
219219 State uint8
220220}
221+
221222// Protocol returns "tcp".
222- func (* ProtoInfoTCP ) Protocol () string {return "tcp" }
223+ func (* ProtoInfoTCP ) Protocol () string { return "tcp" }
224+
223225func (p * ProtoInfoTCP ) toNlData () ([]* nl.RtAttr , error ) {
224- ctProtoInfo := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_PROTOINFO , []byte {})
226+ ctProtoInfo := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_PROTOINFO , []byte {})
225227 ctProtoInfoTCP := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_PROTOINFO_TCP , []byte {})
226228 ctProtoInfoTCPState := nl .NewRtAttr (nl .CTA_PROTOINFO_TCP_STATE , nl .Uint8Attr (p .State ))
227229 ctProtoInfoTCP .AddChild (ctProtoInfoTCPState )
@@ -231,14 +233,16 @@ func (p *ProtoInfoTCP) toNlData() ([]*nl.RtAttr, error) {
231233}
232234
233235// ProtoInfoSCTP only supports the protocol name.
234- type ProtoInfoSCTP struct {}
236+ type ProtoInfoSCTP struct {}
237+
235238// Protocol returns "sctp".
236- func (* ProtoInfoSCTP ) Protocol () string {return "sctp" }
239+ func (* ProtoInfoSCTP ) Protocol () string { return "sctp" }
237240
238241// ProtoInfoDCCP only supports the protocol name.
239- type ProtoInfoDCCP struct {}
242+ type ProtoInfoDCCP struct {}
243+
240244// Protocol returns "dccp".
241- func (* ProtoInfoDCCP ) Protocol () string {return "dccp" }
245+ func (* ProtoInfoDCCP ) Protocol () string { return "dccp" }
242246
243247// The full conntrack flow structure is very complicated and can be found in the file:
244248// http://git.netfilter.org/libnetfilter_conntrack/tree/include/internal/object.h
@@ -256,7 +260,6 @@ type IPTuple struct {
256260// toNlData generates the inner fields of a nested tuple netlink datastructure
257261// does not generate the "nested"-flagged outer message.
258262func (t * IPTuple ) toNlData (family uint8 ) ([]* nl.RtAttr , error ) {
259-
260263 var srcIPsFlag , dstIPsFlag int
261264 if family == nl .FAMILY_V4 {
262265 srcIPsFlag = nl .CTA_IP_V4_SRC
@@ -280,7 +283,7 @@ func (t *IPTuple) toNlData(family uint8) ([]*nl.RtAttr, error) {
280283 ctTupleProtoSrcPort := nl .NewRtAttr (nl .CTA_PROTO_SRC_PORT , nl .BEUint16Attr (t .SrcPort ))
281284 ctTupleProto .AddChild (ctTupleProtoSrcPort )
282285 ctTupleProtoDstPort := nl .NewRtAttr (nl .CTA_PROTO_DST_PORT , nl .BEUint16Attr (t .DstPort ))
283- ctTupleProto .AddChild (ctTupleProtoDstPort , )
286+ ctTupleProto .AddChild (ctTupleProtoDstPort )
284287
285288 return []* nl.RtAttr {ctTupleIP , ctTupleProto }, nil
286289}
@@ -357,7 +360,7 @@ func (s *ConntrackFlow) toNlData() ([]*nl.RtAttr, error) {
357360 // <len, CTA_TIMEOUT>
358361 // <BEuint64>
359362 // <len, NLA_F_NESTED|CTA_PROTOINFO>
360-
363+
361364 // CTA_TUPLE_ORIG
362365 ctTupleOrig := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_TUPLE_ORIG , nil )
363366 forwardFlowAttrs , err := s .Forward .toNlData (s .FamilyType )
@@ -535,17 +538,16 @@ func parseTimeStamp(r *bytes.Reader, readSize uint16) (tstart, tstop uint64) {
535538 }
536539 }
537540 return
538-
539541}
540542
541543func parseProtoInfoTCPState (r * bytes.Reader ) (s uint8 ) {
542544 binary .Read (r , binary .BigEndian , & s )
543- r .Seek (nl .SizeofNfattr - 1 , seekCurrent )
545+ r .Seek (nl .SizeofNfattr - 1 , seekCurrent )
544546 return s
545547}
546548
547549// parseProtoInfoTCP reads the entire nested protoinfo structure, but only parses the state attr.
548- func parseProtoInfoTCP (r * bytes.Reader , attrLen uint16 ) ( * ProtoInfoTCP ) {
550+ func parseProtoInfoTCP (r * bytes.Reader , attrLen uint16 ) * ProtoInfoTCP {
549551 p := new (ProtoInfoTCP )
550552 bytesRead := 0
551553 for bytesRead < int (attrLen ) {
@@ -659,7 +661,7 @@ func parseRawData(data []byte) *ConntrackFlow {
659661 switch t {
660662 case nl .CTA_MARK :
661663 s .Mark = parseConnectionMark (reader )
662- case nl .CTA_LABELS :
664+ case nl .CTA_LABELS :
663665 s .Labels = parseConnectionLabels (reader )
664666 case nl .CTA_TIMEOUT :
665667 s .TimeOut = parseTimeOut (reader )
0 commit comments