Skip to content

Commit dbbbb6c

Browse files
committed
chore: cargo fmt
1 parent 1aab497 commit dbbbb6c

3 files changed

Lines changed: 52 additions & 25 deletions

File tree

benches/hot_path_bench.rs

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,14 @@ fn v9_data_packet(flow_count: u16) -> Vec<u8> {
5656
for i in 0..flow_count {
5757
let i_lo = (i & 0xFF) as u8;
5858
let i_hi = ((i >> 8) & 0xFF) as u8;
59-
packet.extend_from_slice(
60-
&[
59+
packet.extend_from_slice(&[
6160
0x0A, 0x00, i_hi, i_lo, // src IP
6261
0x0A, 0x00, 0x01, i_lo, // dst IP
6362
0x00, 0x50, // src port
6463
0x01, 0xBB, // dst port
6564
0x00, 0x00, 0x05, 0x00, // inBytes
6665
0x00, 0x00, 0x00, 0x0A, // inPkts
67-
],
68-
);
66+
]);
6967
}
7068

7169
packet
@@ -79,20 +77,50 @@ fn ipfix_template_packet() -> Vec<u8> {
7977
0x0A, // Version 10
8078
(total_length >> 8) as u8,
8179
(total_length & 0xFF) as u8,
82-
0x00, 0x00, 0x00, 0x01, // Export time
83-
0x00, 0x00, 0x00, 0x01, // Sequence
84-
0x00, 0x00, 0x00, 0x01, // Observation domain
85-
0x00, 0x02, // Set ID = 2 (template)
80+
0x00,
81+
0x00,
82+
0x00,
83+
0x01, // Export time
84+
0x00,
85+
0x00,
86+
0x00,
87+
0x01, // Sequence
88+
0x00,
89+
0x00,
90+
0x00,
91+
0x01, // Observation domain
92+
0x00,
93+
0x02, // Set ID = 2 (template)
8694
(set_length >> 8) as u8,
8795
(set_length & 0xFF) as u8,
88-
0x01, 0x00, // Template ID = 256
89-
0x00, 0x06, // Field count = 6
90-
0x00, 0x08, 0x00, 0x04, // sourceIPv4Address
91-
0x00, 0x0C, 0x00, 0x04, // destinationIPv4Address
92-
0x00, 0x07, 0x00, 0x02, // sourceTransportPort
93-
0x00, 0x0B, 0x00, 0x02, // destinationTransportPort
94-
0x00, 0x01, 0x00, 0x04, // octetDeltaCount
95-
0x00, 0x02, 0x00, 0x04, // packetDeltaCount
96+
0x01,
97+
0x00, // Template ID = 256
98+
0x00,
99+
0x06, // Field count = 6
100+
0x00,
101+
0x08,
102+
0x00,
103+
0x04, // sourceIPv4Address
104+
0x00,
105+
0x0C,
106+
0x00,
107+
0x04, // destinationIPv4Address
108+
0x00,
109+
0x07,
110+
0x00,
111+
0x02, // sourceTransportPort
112+
0x00,
113+
0x0B,
114+
0x00,
115+
0x02, // destinationTransportPort
116+
0x00,
117+
0x01,
118+
0x00,
119+
0x04, // octetDeltaCount
120+
0x00,
121+
0x02,
122+
0x00,
123+
0x04, // packetDeltaCount
96124
]
97125
}
98126

@@ -126,16 +154,14 @@ fn ipfix_data_packet(flow_count: u16) -> Vec<u8> {
126154
for i in 0..flow_count {
127155
let i_lo = (i & 0xFF) as u8;
128156
let i_hi = ((i >> 8) & 0xFF) as u8;
129-
packet.extend_from_slice(
130-
&[
157+
packet.extend_from_slice(&[
131158
0x0A, 0x00, i_hi, i_lo, // src IP
132159
0x0A, 0x00, 0x01, i_lo, // dst IP
133160
0x00, 0x50, // src port
134161
0x01, 0xBB, // dst port
135162
0x00, 0x00, 0x05, 0x00, // octetDeltaCount
136163
0x00, 0x00, 0x00, 0x0A, // packetDeltaCount
137-
],
138-
);
164+
]);
139165
}
140166

141167
packet

src/variable_versions/field_value.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
use super::fast_parse::{
2+
parse_6_bytes, parse_i8, parse_i16_be, parse_i24_be, parse_i32_be, parse_i64_be,
3+
parse_i128_be, parse_u8, parse_u16_be, parse_u24_be, parse_u32_be, parse_u64_be,
4+
parse_u128_be,
5+
};
16
use super::field_types::{
27
FirewallEvent, FlowEndReason, ForwardingStatus, FragmentFlags, Ipv4Options,
38
Ipv6ExtensionHeaders, IsMulticast, MplsLabelExp, MplsTopLabelType, NatEvent,
49
NatOriginatingAddressRealm, TcpControlBits, TcpOptions,
510
};
611
use crate::protocol::ProtocolTypes;
7-
use super::fast_parse::{
8-
parse_6_bytes, parse_i128_be, parse_i16_be, parse_i24_be, parse_i32_be, parse_i64_be,
9-
parse_i8, parse_u128_be, parse_u16_be, parse_u24_be, parse_u32_be, parse_u64_be, parse_u8,
10-
};
1112
use nom::{
1213
Err as NomErr, IResult,
1314
bytes::complete::take,

src/variable_versions/ipfix/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ use crate::variable_versions::{
2525
};
2626
use crate::{NetflowError, NetflowPacket, ParsedNetflow};
2727

28+
use crate::variable_versions::fast_parse::{parse_u8, parse_u16_be};
2829
use lru::LruCache;
2930
use nom::IResult;
3031
use nom::combinator::complete;
3132
use nom::multi::many0;
32-
use crate::variable_versions::fast_parse::{parse_u8, parse_u16_be};
3333
use nom_derive::Parse;
3434
use std::num::NonZeroUsize;
3535
use std::sync::Arc;

0 commit comments

Comments
 (0)