Skip to content

Commit

Permalink
proto: change protobuf definition case (cloudflare#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
lspgn authored Oct 8, 2022
1 parent f542b64 commit 3326554
Show file tree
Hide file tree
Showing 8 changed files with 760 additions and 654 deletions.
4 changes: 2 additions & 2 deletions cmd/enricher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func MapCountry(db *geoip2.Reader, addr []byte, dest *string) {

func MapFlow(dbAsn, dbCountry *geoip2.Reader, msg *flowmessage.FlowMessageExt) {
if dbAsn != nil {
MapAsn(dbAsn, msg.SrcAddr, &(msg.SrcAS))
MapAsn(dbAsn, msg.DstAddr, &(msg.DstAS))
MapAsn(dbAsn, msg.SrcAddr, &(msg.SrcAs))
MapAsn(dbAsn, msg.DstAddr, &(msg.DstAs))
}
if dbCountry != nil {
MapCountry(dbCountry, msg.SrcAddr, &(msg.SrcCountry))
Expand Down
491 changes: 290 additions & 201 deletions cmd/enricher/pb/flowext.pb.go

Large diffs are not rendered by default.

119 changes: 65 additions & 54 deletions cmd/enricher/pb/flowext.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,94 +11,105 @@ message FlowMessageExt {
NETFLOW_V9 = 3;
IPFIX = 4;
}
FlowType Type = 1;
FlowType type = 1;

uint64 TimeReceived = 2;
uint32 SequenceNum = 4;
uint64 SamplingRate = 3;
uint64 time_received = 2;
uint32 sequence_num = 4;
uint64 sampling_rate = 3;

uint32 FlowDirection = 42;
uint32 flow_direction = 42;

// Sampler information
bytes SamplerAddress = 11;
bytes sampler_address = 11;

// Found inside packet
uint64 TimeFlowStart = 38;
uint64 TimeFlowEnd = 5;
uint64 time_flow_start = 38;
uint64 time_flow_end = 5;
uint64 time_flow_start_ms = 63;
uint64 time_flow_end_ms = 64;

// Size of the sampled packet
uint64 Bytes = 9;
uint64 Packets = 10;
uint64 bytes = 9;
uint64 packets = 10;

// Source/destination addresses
bytes SrcAddr = 6;
bytes DstAddr = 7;
bytes src_addr = 6;
bytes dst_addr = 7;

// Layer 3 protocol (IPv4/IPv6/ARP/MPLS...)
uint32 Etype = 30;
uint32 etype = 30;

// Layer 4 protocol
uint32 Proto = 20;
uint32 proto = 20;

// Ports for UDP and TCP
uint32 SrcPort = 21;
uint32 DstPort = 22;
uint32 src_port = 21;
uint32 dst_port = 22;

// Interfaces
uint32 InIf = 18;
uint32 OutIf = 19;
uint32 in_if = 18;
uint32 out_if = 19;

// Ethernet information
uint64 SrcMac = 27;
uint64 DstMac = 28;
uint64 src_mac = 27;
uint64 dst_mac = 28;

// Vlan
uint32 SrcVlan = 33;
uint32 DstVlan = 34;
uint32 src_vlan = 33;
uint32 dst_vlan = 34;
// 802.1q VLAN in sampled packet
uint32 VlanId = 29;
uint32 vlan_id = 29;

// VRF
uint32 IngressVrfID = 39;
uint32 EgressVrfID = 40;
uint32 ingress_vrf_id = 39;
uint32 egress_vrf_id = 40;

// IP and TCP special flags
uint32 IPTos = 23;
uint32 ForwardingStatus = 24;
uint32 IPTTL = 25;
uint32 TCPFlags = 26;
uint32 IcmpType = 31;
uint32 IcmpCode = 32;
uint32 IPv6FlowLabel = 37;
uint32 ip_tos = 23;
uint32 forwarding_status = 24;
uint32 ip_ttl = 25;
uint32 tcp_flags = 26;
uint32 icmp_type = 31;
uint32 icmp_code = 32;
uint32 ipv6_flow_label = 37;
// Fragments (IPv4/IPv6)
uint32 FragmentId = 35;
uint32 FragmentOffset = 36;
uint32 BiFlowDirection = 41;
uint32 fragment_id = 35;
uint32 fragment_offset = 36;
uint32 bi_flow_direction = 41;

// Autonomous system information
uint32 SrcAS = 14;
uint32 DstAS = 15;
uint32 src_as = 14;
uint32 dst_as = 15;

bytes NextHop = 12;
uint32 NextHopAS = 13;
bytes next_hop = 12;
uint32 next_hop_as = 13;

// Prefix size
uint32 SrcNet = 16;
uint32 DstNet = 17;
uint32 src_net = 16;
uint32 dst_net = 17;

// BGP information
bytes bgp_next_hop = 100;
repeated uint32 bgp_communities = 101;
repeated uint32 as_path = 102;

// MPLS information
bool HasMPLS = 53;
uint32 MPLSCount = 54;
uint32 MPLS1TTL = 55; // First TTL
uint32 MPLS1Label = 56; // First Label
uint32 MPLS2TTL = 57; // Second TTL
uint32 MPLS2Label = 58; // Second Label
uint32 MPLS3TTL = 59; // Third TTL
uint32 MPLS3Label = 60; // Third Label
uint32 MPLSLastTTL = 61; // Last TTL
uint32 MPLSLastLabel = 62; // Last Label

string SrcCountry = 1000;
string DstCountry = 1001;
bool has_mpls = 53;
uint32 mpls_count = 54;
uint32 mpls_1_ttl = 55; // First TTL
uint32 mpls_1_label = 56; // First Label
uint32 mpls_2_ttl = 57; // Second TTL
uint32 mpls_2_label = 58; // Second Label
uint32 mpls_3_ttl = 59; // Third TTL
uint32 mpls_3_label = 60; // Third Label
uint32 mpls_last_ttl = 61; // Last TTL
uint32 mpls_last_label = 62; // Last Label
bytes mpls_label_ip = 65; // MPLS TOP Label IP

uint32 observation_domain_id = 70;
uint32 observation_point_id = 71;

string src_country = 1000;
string dst_country = 1001;

}
568 changes: 287 additions & 281 deletions pb/flow.pb.go

Large diffs are not rendered by default.

144 changes: 72 additions & 72 deletions pb/flow.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,119 +11,119 @@ message FlowMessage {
NETFLOW_V9 = 3;
IPFIX = 4;
}
FlowType Type = 1;
FlowType type = 1;

uint64 TimeReceived = 2;
uint32 SequenceNum = 4;
uint64 SamplingRate = 3;
uint64 time_received = 2;
uint32 sequence_num = 4;
uint64 sampling_rate = 3;

uint32 FlowDirection = 42;
uint32 flow_direction = 42;

// Sampler information
bytes SamplerAddress = 11;
bytes sampler_address = 11;

// Found inside packet
uint64 TimeFlowStart = 38;
uint64 TimeFlowEnd = 5;
uint64 TimeFlowStartMs = 63;
uint64 TimeFlowEndMs = 64;
uint64 time_flow_start = 38;
uint64 time_flow_end = 5;
uint64 time_flow_start_ms = 63;
uint64 time_flow_end_ms = 64;

// Size of the sampled packet
uint64 Bytes = 9;
uint64 Packets = 10;
uint64 bytes = 9;
uint64 packets = 10;

// Source/destination addresses
bytes SrcAddr = 6;
bytes DstAddr = 7;
bytes src_addr = 6;
bytes dst_addr = 7;

// Layer 3 protocol (IPv4/IPv6/ARP/MPLS...)
uint32 Etype = 30;
uint32 etype = 30;

// Layer 4 protocol
uint32 Proto = 20;
uint32 proto = 20;

// Ports for UDP and TCP
uint32 SrcPort = 21;
uint32 DstPort = 22;
uint32 src_port = 21;
uint32 dst_port = 22;

// Interfaces
uint32 InIf = 18;
uint32 OutIf = 19;
uint32 in_if = 18;
uint32 out_if = 19;

// Ethernet information
uint64 SrcMac = 27;
uint64 DstMac = 28;
uint64 src_mac = 27;
uint64 dst_mac = 28;

// Vlan
uint32 SrcVlan = 33;
uint32 DstVlan = 34;
uint32 src_vlan = 33;
uint32 dst_vlan = 34;
// 802.1q VLAN in sampled packet
uint32 VlanId = 29;
uint32 vlan_id = 29;

// VRF
uint32 IngressVrfID = 39;
uint32 EgressVrfID = 40;
uint32 ingress_vrf_id = 39;
uint32 egress_vrf_id = 40;

// IP and TCP special flags
uint32 IPTos = 23;
uint32 ForwardingStatus = 24;
uint32 IPTTL = 25;
uint32 TCPFlags = 26;
uint32 IcmpType = 31;
uint32 IcmpCode = 32;
uint32 IPv6FlowLabel = 37;
uint32 ip_tos = 23;
uint32 forwarding_status = 24;
uint32 ip_ttl = 25;
uint32 tcp_flags = 26;
uint32 icmp_type = 31;
uint32 icmp_code = 32;
uint32 ipv6_flow_label = 37;
// Fragments (IPv4/IPv6)
uint32 FragmentId = 35;
uint32 FragmentOffset = 36;
uint32 BiFlowDirection = 41;
uint32 fragment_id = 35;
uint32 fragment_offset = 36;
uint32 bi_flow_direction = 41;

// Autonomous system information
uint32 SrcAS = 14;
uint32 DstAS = 15;
uint32 src_as = 14;
uint32 dst_as = 15;

bytes NextHop = 12;
uint32 NextHopAS = 13;
bytes next_hop = 12;
uint32 next_hop_as = 13;

// Prefix size
uint32 SrcNet = 16;
uint32 DstNet = 17;
uint32 src_net = 16;
uint32 dst_net = 17;

// BGP information
bytes BgpNextHop = 100;
repeated uint32 BgpCommunities = 101;
repeated uint32 AsPath = 102;
bytes bgp_next_hop = 100;
repeated uint32 bgp_communities = 101;
repeated uint32 as_path = 102;

// MPLS information
bool HasMPLS = 53;
uint32 MPLSCount = 54;
uint32 MPLS1TTL = 55; // First TTL
uint32 MPLS1Label = 56; // First Label
uint32 MPLS2TTL = 57; // Second TTL
uint32 MPLS2Label = 58; // Second Label
uint32 MPLS3TTL = 59; // Third TTL
uint32 MPLS3Label = 60; // Third Label
uint32 MPLSLastTTL = 61; // Last TTL
uint32 MPLSLastLabel = 62; // Last Label
bytes MPLSLabelIP = 65; // MPLS TOP Label IP

uint32 ObservationDomainID = 70;
uint32 ObservationPointID = 71;
bool has_mpls = 53;
uint32 mpls_count = 54;
uint32 mpls_1_ttl = 55; // First TTL
uint32 mpls_1_label = 56; // First Label
uint32 mpls_2_ttl = 57; // Second TTL
uint32 mpls_2_label = 58; // Second Label
uint32 mpls_3_ttl = 59; // Third TTL
uint32 mpls_3_label = 60; // Third Label
uint32 mpls_last_ttl = 61; // Last TTL
uint32 mpls_last_label = 62; // Last Label
bytes mpls_label_ip = 65; // MPLS TOP Label IP

uint32 observation_domain_id = 70;
uint32 observation_point_id = 71;

// Custom fields: start after ID 1000:
// uint32 MyCustomField = 1000;
// uint32 my_custom_field = 1000;


// Custom allocations
uint64 CustomInteger1 = 1001;
uint64 CustomInteger2 = 1002;
uint64 CustomInteger3 = 1003;
uint64 CustomInteger4 = 1004;
uint64 CustomInteger5 = 1005;

bytes CustomBytes1 = 1011;
bytes CustomBytes2 = 1012;
bytes CustomBytes3 = 1013;
bytes CustomBytes4 = 1014;
bytes CustomBytes5 = 1015;
uint64 custom_integer_1 = 1001;
uint64 custom_integer_2 = 1002;
uint64 custom_integer_3 = 1003;
uint64 custom_integer_4 = 1004;
uint64 custom_integer_5 = 1005;

bytes custom_bytes_1 = 1011;
bytes custom_bytes_2 = 1012;
bytes custom_bytes_3 = 1013;
bytes custom_bytes_4 = 1014;
bytes custom_bytes_5 = 1015;

}
Loading

0 comments on commit 3326554

Please sign in to comment.