@@ -196,10 +196,12 @@ type ProtoInfo interface {
196196type ProtoInfoTCP struct {
197197 State uint8
198198}
199+
199200// Protocol returns "tcp".
200- func (* ProtoInfoTCP ) Protocol () string {return "tcp" }
201+ func (* ProtoInfoTCP ) Protocol () string { return "tcp" }
202+
201203func (p * ProtoInfoTCP ) toNlData () ([]* nl.RtAttr , error ) {
202- ctProtoInfo := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_PROTOINFO , []byte {})
204+ ctProtoInfo := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_PROTOINFO , []byte {})
203205 ctProtoInfoTCP := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_PROTOINFO_TCP , []byte {})
204206 ctProtoInfoTCPState := nl .NewRtAttr (nl .CTA_PROTOINFO_TCP_STATE , nl .Uint8Attr (p .State ))
205207 ctProtoInfoTCP .AddChild (ctProtoInfoTCPState )
@@ -209,14 +211,16 @@ func (p *ProtoInfoTCP) toNlData() ([]*nl.RtAttr, error) {
209211}
210212
211213// ProtoInfoSCTP only supports the protocol name.
212- type ProtoInfoSCTP struct {}
214+ type ProtoInfoSCTP struct {}
215+
213216// Protocol returns "sctp".
214- func (* ProtoInfoSCTP ) Protocol () string {return "sctp" }
217+ func (* ProtoInfoSCTP ) Protocol () string { return "sctp" }
215218
216219// ProtoInfoDCCP only supports the protocol name.
217- type ProtoInfoDCCP struct {}
220+ type ProtoInfoDCCP struct {}
221+
218222// Protocol returns "dccp".
219- func (* ProtoInfoDCCP ) Protocol () string {return "dccp" }
223+ func (* ProtoInfoDCCP ) Protocol () string { return "dccp" }
220224
221225// The full conntrack flow structure is very complicated and can be found in the file:
222226// http://git.netfilter.org/libnetfilter_conntrack/tree/include/internal/object.h
@@ -234,7 +238,6 @@ type IPTuple struct {
234238// toNlData generates the inner fields of a nested tuple netlink datastructure
235239// does not generate the "nested"-flagged outer message.
236240func (t * IPTuple ) toNlData (family uint8 ) ([]* nl.RtAttr , error ) {
237-
238241 var srcIPsFlag , dstIPsFlag int
239242 if family == nl .FAMILY_V4 {
240243 srcIPsFlag = nl .CTA_IP_V4_SRC
@@ -258,7 +261,7 @@ func (t *IPTuple) toNlData(family uint8) ([]*nl.RtAttr, error) {
258261 ctTupleProtoSrcPort := nl .NewRtAttr (nl .CTA_PROTO_SRC_PORT , nl .BEUint16Attr (t .SrcPort ))
259262 ctTupleProto .AddChild (ctTupleProtoSrcPort )
260263 ctTupleProtoDstPort := nl .NewRtAttr (nl .CTA_PROTO_DST_PORT , nl .BEUint16Attr (t .DstPort ))
261- ctTupleProto .AddChild (ctTupleProtoDstPort , )
264+ ctTupleProto .AddChild (ctTupleProtoDstPort )
262265
263266 return []* nl.RtAttr {ctTupleIP , ctTupleProto }, nil
264267}
@@ -335,7 +338,7 @@ func (s *ConntrackFlow) toNlData() ([]*nl.RtAttr, error) {
335338 // <len, CTA_TIMEOUT>
336339 // <BEuint64>
337340 // <len, NLA_F_NESTED|CTA_PROTOINFO>
338-
341+
339342 // CTA_TUPLE_ORIG
340343 ctTupleOrig := nl .NewRtAttr (unix .NLA_F_NESTED | nl .CTA_TUPLE_ORIG , nil )
341344 forwardFlowAttrs , err := s .Forward .toNlData (s .FamilyType )
@@ -513,17 +516,16 @@ func parseTimeStamp(r *bytes.Reader, readSize uint16) (tstart, tstop uint64) {
513516 }
514517 }
515518 return
516-
517519}
518520
519521func parseProtoInfoTCPState (r * bytes.Reader ) (s uint8 ) {
520522 binary .Read (r , binary .BigEndian , & s )
521- r .Seek (nl .SizeofNfattr - 1 , seekCurrent )
523+ r .Seek (nl .SizeofNfattr - 1 , seekCurrent )
522524 return s
523525}
524526
525527// parseProtoInfoTCP reads the entire nested protoinfo structure, but only parses the state attr.
526- func parseProtoInfoTCP (r * bytes.Reader , attrLen uint16 ) ( * ProtoInfoTCP ) {
528+ func parseProtoInfoTCP (r * bytes.Reader , attrLen uint16 ) * ProtoInfoTCP {
527529 p := new (ProtoInfoTCP )
528530 bytesRead := 0
529531 for bytesRead < int (attrLen ) {
@@ -637,7 +639,7 @@ func parseRawData(data []byte) *ConntrackFlow {
637639 switch t {
638640 case nl .CTA_MARK :
639641 s .Mark = parseConnectionMark (reader )
640- case nl .CTA_LABELS :
642+ case nl .CTA_LABELS :
641643 s .Labels = parseConnectionLabels (reader )
642644 case nl .CTA_TIMEOUT :
643645 s .TimeOut = parseTimeOut (reader )
0 commit comments