diff --git a/goflow.go b/goflow.go index 3585156..bb915d2 100644 --- a/goflow.go +++ b/goflow.go @@ -389,13 +389,13 @@ func FlowMessageToString(fmsg *flowmessage.FlowMessage) string { "SrcAS:%v DstAS:%v SrcNet:%v DstNet:%v SrcIf:%v DstIf:%v Proto:%v " + "SrcPort:%v DstPort:%v IPTos:%v ForwardingStatus:%v IPTTL:%v TCPFlags:%v " + "SrcMac:%v DstMac:%v VlanId:%v Etype:%v IcmpType:%v IcmpCode:%v " + - "SrcVlan:%v DstVlan:%v ", + "SrcVlan:%v DstVlan:%v IPv6FlowLabel:%v", fmsg.Type, fmsg.TimeRecvd, fmsg.SamplingRate, fmsg.SequenceNum, fmsg.TimeFlow, net.IP(fmsg.SrcIP), net.IP(fmsg.DstIP), fmsg.IPversion, fmsg.Bytes, fmsg.Packets, net.IP(fmsg.RouterAddr), net.IP(fmsg.NextHop), fmsg.NextHopAS, fmsg.SrcAS, fmsg.DstAS, fmsg.SrcNet, fmsg.DstNet, fmsg.SrcIf, fmsg.DstIf, fmsg.Proto, fmsg.SrcPort, fmsg.DstPort, fmsg.IPTos, fmsg.ForwardingStatus, fmsg.IPTTL, fmsg.TCPFlags, fmsg.SrcMac, fmsg.DstMac, fmsg.VlanId, fmsg.Etype, fmsg.IcmpType, fmsg.IcmpCode, - fmsg.SrcVlan, fmsg.DstVlan) + fmsg.SrcVlan, fmsg.DstVlan, fmsg.IPv6FlowLabel) return s } diff --git a/pb/flow.pb.go b/pb/flow.pb.go index 1d05daf..7ea551b 100644 --- a/pb/flow.pb.go +++ b/pb/flow.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: pb/flow.proto +// source: flow.proto package flowprotob @@ -44,7 +44,7 @@ func (x FlowMessage_FlowType) String() string { return proto.EnumName(FlowMessage_FlowType_name, int32(x)) } func (FlowMessage_FlowType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_flow_ce209d0226d051ee, []int{0, 0} + return fileDescriptor_flow_afe3427e2abb0c00, []int{0, 0} } // To be deprecated @@ -71,7 +71,7 @@ func (x FlowMessage_IPType) String() string { return proto.EnumName(FlowMessage_IPType_name, int32(x)) } func (FlowMessage_IPType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_flow_ce209d0226d051ee, []int{0, 1} + return fileDescriptor_flow_afe3427e2abb0c00, []int{0, 1} } type FlowMessage struct { @@ -126,6 +126,7 @@ type FlowMessage struct { // Fragments (IPv4/IPv6) FragmentId uint32 `protobuf:"varint,35,opt,name=FragmentId,proto3" json:"FragmentId,omitempty"` FragmentOffset uint32 `protobuf:"varint,36,opt,name=FragmentOffset,proto3" json:"FragmentOffset,omitempty"` + IPv6FlowLabel uint32 `protobuf:"varint,37,opt,name=IPv6FlowLabel,proto3" json:"IPv6FlowLabel,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -135,7 +136,7 @@ func (m *FlowMessage) Reset() { *m = FlowMessage{} } func (m *FlowMessage) String() string { return proto.CompactTextString(m) } func (*FlowMessage) ProtoMessage() {} func (*FlowMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_flow_ce209d0226d051ee, []int{0} + return fileDescriptor_flow_afe3427e2abb0c00, []int{0} } func (m *FlowMessage) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_FlowMessage.Unmarshal(m, b) @@ -407,54 +408,62 @@ func (m *FlowMessage) GetFragmentOffset() uint32 { return 0 } +func (m *FlowMessage) GetIPv6FlowLabel() uint32 { + if m != nil { + return m.IPv6FlowLabel + } + return 0 +} + func init() { proto.RegisterType((*FlowMessage)(nil), "flowprotob.FlowMessage") proto.RegisterEnum("flowprotob.FlowMessage_FlowType", FlowMessage_FlowType_name, FlowMessage_FlowType_value) proto.RegisterEnum("flowprotob.FlowMessage_IPType", FlowMessage_IPType_name, FlowMessage_IPType_value) } -func init() { proto.RegisterFile("pb/flow.proto", fileDescriptor_flow_ce209d0226d051ee) } - -var fileDescriptor_flow_ce209d0226d051ee = []byte{ - // 632 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0x51, 0x6f, 0xd3, 0x4a, - 0x10, 0x85, 0x6f, 0xee, 0x4d, 0xd3, 0x64, 0xd3, 0xb4, 0xbe, 0x4b, 0x29, 0x43, 0x29, 0xc1, 0x04, - 0x84, 0x22, 0x2a, 0x05, 0x09, 0x2a, 0x24, 0x04, 0x2f, 0x69, 0x8b, 0x85, 0x45, 0xeb, 0x5a, 0x76, - 0x68, 0x79, 0x75, 0xec, 0xb5, 0x15, 0xe1, 0x78, 0x83, 0xbd, 0x69, 0xe9, 0x2f, 0xe7, 0x15, 0xcd, - 0xac, 0xed, 0xa4, 0x20, 0xde, 0xf6, 0x3b, 0x67, 0x76, 0xd6, 0x73, 0x92, 0x61, 0xbd, 0xc5, 0xf4, - 0x55, 0x9c, 0xca, 0x9b, 0xd1, 0x22, 0x97, 0x4a, 0x72, 0x86, 0x67, 0x3a, 0x4e, 0x07, 0x3f, 0xdb, - 0xac, 0x6b, 0xa5, 0xf2, 0xe6, 0x5c, 0x14, 0x45, 0x90, 0x08, 0x7e, 0xc4, 0x9a, 0x93, 0xdb, 0x85, - 0x80, 0x86, 0xd9, 0x18, 0x6e, 0xbf, 0x36, 0x47, 0xab, 0xd2, 0xd1, 0x5a, 0x19, 0x9d, 0xb1, 0xce, - 0xa3, 0x6a, 0x7e, 0xc0, 0x3a, 0x93, 0xd9, 0x5c, 0x78, 0x22, 0xbc, 0x8e, 0xe0, 0x5f, 0xb3, 0x31, - 0x6c, 0x7a, 0x2b, 0x81, 0x0f, 0xd8, 0x96, 0x1f, 0xcc, 0x17, 0xe9, 0x2c, 0x4b, 0xbc, 0x40, 0x09, - 0xf8, 0x8f, 0x0a, 0xee, 0x68, 0xdc, 0x64, 0x5d, 0x5f, 0x7c, 0x5f, 0x8a, 0x2c, 0x14, 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cf, 0xce, 0xc5, 0x95, 0x63, 0xfc, - 0xc3, 0xdb, 0xac, 0xe9, 0x58, 0x97, 0xef, 0x8c, 0x0e, 0xef, 0x60, 0xd4, 0x96, 0xfd, 0xd5, 0x60, - 0x78, 0xf4, 0xb1, 0xcc, 0xd8, 0x18, 0x1c, 0xb2, 0x96, 0xde, 0x18, 0xde, 0xc3, 0x25, 0xbb, 0x73, - 0xd1, 0x76, 0xaf, 0x8f, 0x8c, 0x66, 0x79, 0x7a, 0x6b, 0xb4, 0x8e, 0x0f, 0xd9, 0x7e, 0x28, 0xe7, - 0xa3, 0x30, 0x95, 0xcb, 0x28, 0x4e, 0x83, 0x5c, 0x8c, 0x32, 0xa1, 0x68, 0x11, 0x83, 0x24, 0x39, - 0xee, 0xad, 0xad, 0xa1, 0x3b, 0x9d, 0xb6, 0x68, 0x39, 0xdf, 0xfc, 0x0a, 0x00, 0x00, 0xff, 0xff, - 0xbc, 0xa6, 0xfb, 0x21, 0xca, 0x04, 0x00, 0x00, +func init() { proto.RegisterFile("flow.proto", fileDescriptor_flow_afe3427e2abb0c00) } + +var fileDescriptor_flow_afe3427e2abb0c00 = []byte{ + // 645 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0xe1, 0x6f, 0xd2, 0x50, + 0x10, 0xc0, 0x45, 0x19, 0x83, 0xc7, 0xd8, 0xea, 0x73, 0xce, 0x73, 0x4e, 0xac, 0x38, 0x0d, 0x71, + 0x09, 0x1f, 0x74, 0x59, 0x62, 0xf4, 0x0b, 0xdb, 0x6c, 0x6c, 0x64, 0x5d, 0xd3, 0xe2, 0xe6, 0xd7, + 0xd2, 0xbe, 0x36, 0xc4, 0xd2, 0x62, 0xfb, 0x60, 0xee, 0x8f, 0xf1, 0x7f, 0x35, 0x77, 0xaf, 0x2d, + 0x4c, 0xe3, 0xb7, 0xf7, 0xfb, 0xdd, 0xf5, 0x5e,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0xed, 0xac, 0x2d, + 0xab, 0x3d, 0x99, 0x34, 0x68, 0x85, 0xdf, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x5c, 0x7b, + 0x89, 0xed, 0x04, 0x00, 0x00, } diff --git a/pb/flow.proto b/pb/flow.proto index 6380b90..e87e513 100644 --- a/pb/flow.proto +++ b/pb/flow.proto @@ -87,4 +87,6 @@ message FlowMessage { // Fragments (IPv4/IPv6) uint32 FragmentId = 35; uint32 FragmentOffset = 36; + + uint32 IPv6FlowLabel = 37; } \ No newline at end of file diff --git a/producer/producer_nf.go b/producer/producer_nf.go index dc78d5b..4d31a96 100644 --- a/producer/producer_nf.go +++ b/producer/producer_nf.go @@ -264,6 +264,9 @@ func ConvertNetFlowDataSet(version uint16, baseTime uint32, uptime uint32, recor case netflow.NFV9_FIELD_FRAGMENT_OFFSET: DecodeUNumber(v, &(flowMessage.FragmentOffset)) + case netflow.NFV9_FIELD_IPV6_FLOW_LABEL: + DecodeUNumber(v, &(flowMessage.IPv6FlowLabel)) + default: if version == 9 { // NetFlow v9 time works with a differential based on router's uptime diff --git a/producer/producer_sf.go b/producer/producer_sf.go index 963d8f6..5e73426 100644 --- a/producer/producer_sf.go +++ b/producer/producer_sf.go @@ -80,6 +80,9 @@ func ParseSampledHeader(flowMessage *flowmessage.FlowMessage, sampledHeader *sfl tostmp := uint32(binary.BigEndian.Uint16(data[offset : offset+2])) tos = uint8(tostmp & 0x0ff0 >> 4) ttl = data[offset+7] + + flowLabeltmp := binary.BigEndian.Uint32(data[offset : offset+4]) + (*flowMessage).IPv6FlowLabel = flowLabeltmp & 0xFFFFF } } else if etherType[0] == 0x8 && etherType[1] == 0x6 { // ARP } else {