Skip to content

Commit

Permalink
Merge pull request #49 from simPod/rename-if-fields
Browse files Browse the repository at this point in the history
Rename SrcIf to InIf and DstIf to OutIf
  • Loading branch information
lspgn authored Jan 31, 2020
2 parents d05ab46 + 2b389c6 commit 699477c
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 86 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ You can find information on how they are populated from the original source:
|Proto|Protocol (UDP, TCP, ICMP...)|prot|Included|PROTOCOL (4)|protocolIdentifier (4)|
|SrcPort|Source port (when UDP/TCP/SCTP)|srcport|Included|L4_DST_PORT (11)|destinationTransportPort (11)|
|DstPort|Destination port (when UDP/TCP/SCTP)|dstport|Included|L4_SRC_PORT (7)|sourceTransportPort (7)|
|SrcIf|Source interface|input|Included|INPUT_SNMP (10)|ingressInterface (10)|
|DstIf|Destination interface|output|Included|OUTPUT_SNMP (14)|egressInterface (14)|
|InIf|Input interface|input|Included|INPUT_SNMP (10)|ingressInterface (10)|
|OutIf|Output interface|output|Included|OUTPUT_SNMP (14)|egressInterface (14)|
|SrcMac|Source mac address| |Included|IN_SRC_MAC (56)|sourceMacAddress (56)|
|DstMac|Destination mac address| |Included|OUT_DST_MAC (57)|postDestinationMacAddress (57)|
|SrcVlan|Source VLAN ID| |From ExtendedSwitch|SRC_VLAN (59)|vlanId (58)|
Expand Down
140 changes: 70 additions & 70 deletions pb/flow.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pb/flow.proto
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ message FlowMessage {
uint32 DstPort = 22;

// Interfaces
uint32 SrcIf = 18;
uint32 DstIf = 19;
uint32 InIf = 18;
uint32 OutIf = 19;

// Ethernet information
uint64 SrcMac = 27;
Expand Down
4 changes: 2 additions & 2 deletions producer/producer_nf.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ func ConvertNetFlowDataSet(version uint16, baseTime uint32, uptime uint32, recor

// Interfaces
case netflow.NFV9_FIELD_INPUT_SNMP:
DecodeUNumber(v, &(flowMessage.SrcIf))
DecodeUNumber(v, &(flowMessage.InIf))
case netflow.NFV9_FIELD_OUTPUT_SNMP:
DecodeUNumber(v, &(flowMessage.DstIf))
DecodeUNumber(v, &(flowMessage.OutIf))

case netflow.NFV9_FIELD_FORWARDING_STATUS:
DecodeUNumber(v, &(flowMessage.ForwardingStatus))
Expand Down
4 changes: 2 additions & 2 deletions producer/producer_nflegacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func ConvertNetFlowLegacyRecord(baseTime uint32, uptime uint32, record netflowle
flowMessage.Proto = uint32(record.Proto)
flowMessage.TCPFlags = uint32(record.TCPFlags)
flowMessage.IPTos = uint32(record.Tos)
flowMessage.SrcIf = uint32(record.Input)
flowMessage.DstIf = uint32(record.Output)
flowMessage.InIf = uint32(record.Input)
flowMessage.OutIf = uint32(record.Output)
flowMessage.SrcPort = uint32(record.SrcPort)
flowMessage.DstPort = uint32(record.DstPort)
flowMessage.Packets = uint64(record.DPkts)
Expand Down
8 changes: 4 additions & 4 deletions producer/producer_sf.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,13 @@ func SearchSFlowSamplesConfig(samples []interface{}, config *SFlowProducerConfig
case sflow.FlowSample:
records = flowSample.Records
flowMessage.SamplingRate = uint64(flowSample.SamplingRate)
flowMessage.SrcIf = flowSample.Input
flowMessage.DstIf = flowSample.Output
flowMessage.InIf = flowSample.Input
flowMessage.OutIf = flowSample.Output
case sflow.ExpandedFlowSample:
records = flowSample.Records
flowMessage.SamplingRate = uint64(flowSample.SamplingRate)
flowMessage.SrcIf = flowSample.InputIfValue
flowMessage.DstIf = flowSample.OutputIfValue
flowMessage.InIf = flowSample.InputIfValue
flowMessage.OutIf = flowSample.OutputIfValue
}

ipNh := net.IP{}
Expand Down
8 changes: 4 additions & 4 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func FlowMessageToString(fmsg *flowmessage.FlowMessage) string {

s := fmt.Sprintf("Type:%v TimeReceived:%v SequenceNum:%v SamplingRate:%v "+
"SamplerAddress:%v TimeFlowStart:%v TimeFlowEnd:%v Bytes:%v Packets:%v SrcAddr:%v "+
"DstAddr:%v Etype:%v Proto:%v SrcPort:%v DstPort:%v SrcIf:%v DstIf:%v SrcMac:%v "+
"DstAddr:%v Etype:%v Proto:%v SrcPort:%v DstPort:%v InIf:%v OutIf:%v SrcMac:%v "+
"DstMac:%v SrcVlan:%v DstVlan:%v VlanId:%v IngressVrfID:%v EgressVrfID:%v IPTos:%v "+
"ForwardingStatus:%v IPTTL:%v TCPFlags:%v IcmpType:%v IcmpCode:%v IPv6FlowLabel:%v "+
"FragmentId:%v FragmentOffset:%v BiFlowDirection:%v SrcAS:%v DstAS:%v NextHop:%v NextHopAS:%v SrcNet:%v DstNet:%v "+
Expand All @@ -100,7 +100,7 @@ func FlowMessageToString(fmsg *flowmessage.FlowMessage) string {
"HasMPLS:%v MPLSCount:%v MPLS1TTL:%v MPLS1Label:%v MPLS2TTL:%v, MPLS2Label: %v, MPLS3TTL:%v MPLS3Label:%v MPLSLastTTL:%v MPLSLastLabel:%v",
fmsg.Type, fmsg.TimeReceived, fmsg.SequenceNum, fmsg.SamplingRate, net.IP(fmsg.SamplerAddress),
fmsg.TimeFlowStart, fmsg.TimeFlowEnd, fmsg.Bytes, fmsg.Packets, net.IP(fmsg.SrcAddr), net.IP(fmsg.DstAddr),
fmsg.Etype, fmsg.Proto, fmsg.SrcPort, fmsg.DstPort, fmsg.SrcIf, fmsg.DstIf, net.HardwareAddr(srcmac),
fmsg.Etype, fmsg.Proto, fmsg.SrcPort, fmsg.DstPort, fmsg.InIf, fmsg.OutIf, net.HardwareAddr(srcmac),
net.HardwareAddr(dstmac), fmsg.SrcVlan, fmsg.DstVlan, fmsg.VlanId, fmsg.IngressVrfID,
fmsg.EgressVrfID, fmsg.IPTos, fmsg.ForwardingStatus, fmsg.IPTTL, fmsg.TCPFlags, fmsg.IcmpType,
fmsg.IcmpCode, fmsg.IPv6FlowLabel, fmsg.FragmentId, fmsg.FragmentOffset, fmsg.BiFlowDirection, fmsg.SrcAS, fmsg.DstAS,
Expand All @@ -121,7 +121,7 @@ func FlowMessageToJSON(fmsg *flowmessage.FlowMessage) string {

s := fmt.Sprintf("{\"Type\":\"%v\",\"TimeReceived\":%v,\"SequenceNum\":%v,\"SamplingRate\":%v,"+
"\"SamplerAddress\":\"%v\",\"TimeFlowStart\":%v,\"TimeFlowEnd\":%v,\"Bytes\":%v,\"Packets\":%v,\"SrcAddr\":\"%v\","+
"\"DstAddr\":\"%v\",\"Etype\":%v,\"Proto\":%v,\"SrcPort\":%v,\"DstPort\":%v,\"SrcIf\":%v,\"DstIf\":%v,\"SrcMac\":\"%v\","+
"\"DstAddr\":\"%v\",\"Etype\":%v,\"Proto\":%v,\"SrcPort\":%v,\"DstPort\":%v,\"InIf\":%v,\"OutIf\":%v,\"SrcMac\":\"%v\","+
"\"DstMac\":\"%v\",\"SrcVlan\":%v,\"DstVlan\":%v,\"VlanId\":%v,\"IngressVrfID\":%v,\"EgressVrfID\":%v,\"IPTos\":%v,"+
"\"ForwardingStatus\":%v,\"IPTTL\":%v,\"TCPFlags\":%v,\"IcmpType\":%v,\"IcmpCode\":%v,\"IPv6FlowLabel\":%v,"+
"\"FragmentId\":%v,\"FragmentOffset\":%v,\"BiFlowDirection\":%v,\"SrcAS\":%v,\"DstAS\":%v,\"NextHop\":\"%v\",\"NextHopAS\":%v,\"SrcNet\":%v,\"DstNet\":%v,"+
Expand All @@ -130,7 +130,7 @@ func FlowMessageToJSON(fmsg *flowmessage.FlowMessage) string {
"\"HasMPLS\":%v,\"MPLSCount\":%v,\"MPLS1TTL\":%v,\"MPLS1Label\":%v,\"MPLS2TTL\":%v,\"MPLS2Label\":%v,\"MPLS3TTL\":%v,\"MPLS3Label\":%v,\"MPLSLastTTL\":%v,\"MPLSLastLabel\":%v}",
fmsg.Type, fmsg.TimeReceived, fmsg.SequenceNum, fmsg.SamplingRate, net.IP(fmsg.SamplerAddress),
fmsg.TimeFlowStart, fmsg.TimeFlowEnd, fmsg.Bytes, fmsg.Packets, net.IP(fmsg.SrcAddr), net.IP(fmsg.DstAddr),
fmsg.Etype, fmsg.Proto, fmsg.SrcPort, fmsg.DstPort, fmsg.SrcIf, fmsg.DstIf, net.HardwareAddr(srcmac),
fmsg.Etype, fmsg.Proto, fmsg.SrcPort, fmsg.DstPort, fmsg.InIf, fmsg.OutIf, net.HardwareAddr(srcmac),
net.HardwareAddr(dstmac), fmsg.SrcVlan, fmsg.DstVlan, fmsg.VlanId, fmsg.IngressVrfID,
fmsg.EgressVrfID, fmsg.IPTos, fmsg.ForwardingStatus, fmsg.IPTTL, fmsg.TCPFlags, fmsg.IcmpType,
fmsg.IcmpCode, fmsg.IPv6FlowLabel, fmsg.FragmentId, fmsg.FragmentOffset, fmsg.BiFlowDirection, fmsg.SrcAS, fmsg.DstAS,
Expand Down

0 comments on commit 699477c

Please sign in to comment.