Skip to content

Commit 28f6b33

Browse files
mikemiles-devMichael Mileusnich
and
Michael Mileusnich
authored
Common cleanup (#95)
* chore: typos --------- Co-authored-by: Michael Mileusnich <[email protected]>
1 parent 84d3fba commit 28f6b33

File tree

6 files changed

+51
-33
lines changed

6 files changed

+51
-33
lines changed

src/netflow_common.rs

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -294,22 +294,31 @@ mod common_tests {
294294

295295
let common: NetflowCommon = NetflowCommon::try_from(&v5).unwrap();
296296

297-
assert!(common.version == 5);
298-
assert!(common.timestamp == 100);
299-
assert!(common.flowsets.len() == 1);
297+
assert_eq!(common.version, 5);
298+
assert_eq!(common.timestamp, 100);
299+
assert_eq!(common.flowsets.len(), 1);
300300
let flowset = &common.flowsets[0];
301-
assert!(flowset.src_addr.unwrap() == IpAddr::V4(Ipv4Addr::new(192, 168, 1, 1)));
302-
assert!(flowset.dst_addr.unwrap() == IpAddr::V4(Ipv4Addr::new(192, 168, 1, 2)));
303-
assert!(flowset.src_port.unwrap() == 1234);
304-
assert!(flowset.dst_port.unwrap() == 80);
305-
assert!(flowset.protocol_number.unwrap() == 6);
306-
assert!(flowset.protocol_type.unwrap() == crate::protocol::ProtocolTypes::Tcp);
307-
assert!(flowset.first_seen.unwrap() == 100);
308-
assert!(flowset.last_seen.unwrap() == 200);
301+
assert_eq!(
302+
flowset.src_addr.unwrap(),
303+
IpAddr::V4(Ipv4Addr::new(192, 168, 1, 1))
304+
);
305+
assert_eq!(
306+
flowset.dst_addr.unwrap(),
307+
IpAddr::V4(Ipv4Addr::new(192, 168, 1, 2))
308+
);
309+
assert_eq!(flowset.src_port.unwrap(), 1234);
310+
assert_eq!(flowset.dst_port.unwrap(), 80);
311+
assert_eq!(flowset.protocol_number.unwrap(), 6);
312+
assert_eq!(
313+
flowset.protocol_type.unwrap(),
314+
crate::protocol::ProtocolTypes::Tcp
315+
);
316+
assert_eq!(flowset.first_seen.unwrap(), 100);
317+
assert_eq!(flowset.last_seen.unwrap(), 200);
309318
}
310319

311320
#[test]
312-
fn it_convets_v7_to_common() {
321+
fn it_converts_v7_to_common() {
313322
let v7 = V7 {
314323
header: V7Header {
315324
version: 7,
@@ -348,18 +357,27 @@ mod common_tests {
348357

349358
let common: NetflowCommon = NetflowCommon::try_from(&v7).unwrap();
350359

351-
assert!(common.version == 7);
352-
assert!(common.timestamp == 100);
353-
assert!(common.flowsets.len() == 1);
360+
assert_eq!(common.version, 7);
361+
assert_eq!(common.timestamp, 100);
362+
assert_eq!(common.flowsets.len(), 1);
354363
let flowset = &common.flowsets[0];
355-
assert!(flowset.src_addr.unwrap() == IpAddr::V4(Ipv4Addr::new(192, 168, 1, 1)));
356-
assert!(flowset.dst_addr.unwrap() == IpAddr::V4(Ipv4Addr::new(192, 168, 1, 2)));
357-
assert!(flowset.src_port.unwrap() == 1234);
358-
assert!(flowset.dst_port.unwrap() == 80);
359-
assert!(flowset.protocol_number.unwrap() == 6);
360-
assert!(flowset.protocol_type.unwrap() == crate::protocol::ProtocolTypes::Tcp);
361-
assert!(flowset.first_seen.unwrap() == 100);
362-
assert!(flowset.last_seen.unwrap() == 200);
364+
assert_eq!(
365+
flowset.src_addr.unwrap(),
366+
IpAddr::V4(Ipv4Addr::new(192, 168, 1, 1))
367+
);
368+
assert_eq!(
369+
flowset.dst_addr.unwrap(),
370+
IpAddr::V4(Ipv4Addr::new(192, 168, 1, 2))
371+
);
372+
assert_eq!(flowset.src_port.unwrap(), 1234);
373+
assert_eq!(flowset.dst_port.unwrap(), 80);
374+
assert_eq!(flowset.protocol_number.unwrap(), 6);
375+
assert_eq!(
376+
flowset.protocol_type.unwrap(),
377+
crate::protocol::ProtocolTypes::Tcp
378+
);
379+
assert_eq!(flowset.first_seen.unwrap(), 100);
380+
assert_eq!(flowset.last_seen.unwrap(), 200);
363381
}
364382

365383
#[test]

src/static_versions/v5.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl V5 {
105105
pub fn to_be_bytes(&self) -> Vec<u8> {
106106
let header_version = self.header.version.to_be_bytes();
107107
let header_count = self.header.count.to_be_bytes();
108-
let header_sys_up_time = (self.header.sys_up_time).to_be_bytes();
108+
let header_sys_up_time = self.header.sys_up_time.to_be_bytes();
109109
let mut header_unix_timestamp = self.header.unix_secs.to_be_bytes().to_vec();
110110
let header_unix_nsecs = self.header.unix_nsecs.to_be_bytes().to_vec();
111111
header_unix_timestamp.extend_from_slice(&header_unix_nsecs);
@@ -135,8 +135,8 @@ impl V5 {
135135
let output = set.output.to_be_bytes();
136136
let d_pkts = set.d_pkts.to_be_bytes();
137137
let d_octets = set.d_octets.to_be_bytes();
138-
let first = (set.first).to_be_bytes();
139-
let last = (set.last).to_be_bytes();
138+
let first = set.first.to_be_bytes();
139+
let last = set.last.to_be_bytes();
140140
let src_port = set.src_port.to_be_bytes();
141141
let dst_ports = set.dst_port.to_be_bytes();
142142
let pad1 = set.pad1.to_be_bytes();

src/static_versions/v7.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ impl V7 {
131131
let output = set.output.to_be_bytes();
132132
let d_pkts = set.d_pkts.to_be_bytes();
133133
let d_octets = set.d_octets.to_be_bytes();
134-
let first = (set.first).to_be_bytes();
135-
let last = (set.last).to_be_bytes();
134+
let first = set.first.to_be_bytes();
135+
let last = set.last.to_be_bytes();
136136
let src_port = set.src_port.to_be_bytes();
137137
let dst_ports = set.dst_port.to_be_bytes();
138138
let flag_field_valid = set.flags_fields_valid.to_be_bytes();

src/variable_versions/data_number.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl From<DataNumber> for usize {
261261
}
262262
}
263263

264-
/// Holds the post parsed field with its relvant datatype
264+
/// Holds the post parsed field with its relevant datatype
265265
#[derive(Debug, PartialEq, PartialOrd, Clone, Serialize)]
266266
pub enum FieldValue {
267267
String(String),
@@ -402,7 +402,7 @@ impl FieldValue {
402402
}
403403
}
404404

405-
/// Helps the parser indefiy the data type to parse the field as
405+
/// Helps the parser indent the data type to parse the field as
406406
#[derive(Debug, PartialEq, Eq, Clone, Serialize)]
407407
pub enum FieldDataType {
408408
String,

src/variable_versions/ipfix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ impl IPFix {
350350

351351
result.extend_from_slice(&self.header.version.to_be_bytes());
352352
result.extend_from_slice(&self.header.length.to_be_bytes());
353-
result.extend_from_slice(&(self.header.export_time).to_be_bytes());
353+
result.extend_from_slice(&self.header.export_time.to_be_bytes());
354354
result.extend_from_slice(&self.header.sequence_number.to_be_bytes());
355355
result.extend_from_slice(&self.header.observation_domain_id.to_be_bytes());
356356

src/variable_versions/v9.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ pub struct Template {
170170
pub struct OptionsTemplate {
171171
/// As a router generates different template FlowSets to match the type of NetFlow data it is exporting, each template is given a unique ID. This uniqueness is local to the router that generated the template ID. The Template ID is greater than 255. Template IDs inferior to 255 are reserved.
172172
pub template_id: u16,
173-
/// This field gives the length in bytes of any scope fields that are contained in this options template.
173+
/// This field gives the length in bytes of any scope fields that are contained in this options' template.
174174
pub options_scope_length: u16,
175175
/// This field gives the length (in bytes) of any Options field definitions that are contained in this options template
176176
pub options_length: u16,
@@ -201,7 +201,7 @@ pub struct TemplateField {
201201
/// that defines the known field types and their lengths.
202202
/// The currently defined field types are detailed in Table 6.
203203
pub field_type_number: u16,
204-
/// Human readable type
204+
/// Human-readable type
205205
#[nom(Value(V9Field::from(field_type_number)))]
206206
pub field_type: V9Field,
207207
/// This number gives the length of the above-defined field, in bytes.

0 commit comments

Comments
 (0)