Skip to content

Commit 3d62759

Browse files
mikemiles-devmikemiles-dev
and
mikemiles-dev
authored
Protocol Types Fix and Readme updates (#81)
* Protocol Types Fix and Readme updates --------- Co-authored-by: mikemiles-dev <[email protected]>
1 parent 0471ad7 commit 3d62759

File tree

6 files changed

+38
-9
lines changed

6 files changed

+38
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "netflow_parser"
33
description = "Parser for Netflow Cisco V5, V7, V9, IPFIX"
4-
version = "0.4.2"
4+
version = "0.4.3"
55
edition = "2021"
66
77
license = "MIT OR Apache-2.0"

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# netflow_parser
22

3+
## Description
4+
35
A Netflow Parser library for Cisco V5, V7, V9, IPFIX written in Rust.
46
Supports chaining of multple versions in the same stream. ({v5 packet}, {v7packet}, {v5packet}, {v9packet}, etc.)
57

6-
# References
8+
## References
79
See: <https://en.wikipedia.org/wiki/NetFlow>
810

9-
# Description
10-
1111
## Example
1212

1313
### V5

RELEASES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.4.3
2+
* Fixed bug in NetflowCommon where ProtocolType was never set.
3+
* Minior Readme Changes.
4+
15
# 0.4.2
26
* Increased coverage.
37
* Reworked Readme.

SECURITY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
| Version | Supported |
66
| ------- | ------------------ |
7+
| 0.4.3 | :white_check_mark: |
78
| 0.4.2 | :white_check_mark: |
89
| 0.4.1 | :white_check_mark: |
910
| 0.4.0 | :white_check_mark: |

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//! # netflow_parser
22
//!
3+
//! ## Description
4+
//!
35
//! A Netflow Parser library for Cisco V5, V7, V9, IPFIX written in Rust.
46
//! Supports chaining of multple versions in the same stream. ({v5 packet}, {v7packet}, {v5packet}, {v9packet}, etc.)
57
//!
6-
//! # References
8+
//! ## References
79
//! See: <https://en.wikipedia.org/wiki/NetFlow>
810
//!
9-
//! # Description
10-
//!
1111
//! ## Example
1212
//!
1313
//! ### V5

src/netflow_common.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,15 @@ impl From<&V9> for NetflowCommon {
168168
FieldValue::DataNumber(DataNumber::U32(seen)) => Some(*seen),
169169
_ => None,
170170
}),
171-
protocol_type: None,
171+
protocol_type: values
172+
.iter()
173+
.find(|(k, _)| *k == V9Field::Protocol)
174+
.and_then(|(_, v)| match v {
175+
FieldValue::DataNumber(DataNumber::U8(proto)) => {
176+
Some(ProtocolTypes::from(*proto))
177+
}
178+
_ => None,
179+
}),
172180
});
173181
}
174182
}
@@ -249,7 +257,15 @@ impl From<&IPFix> for NetflowCommon {
249257
FieldValue::DataNumber(DataNumber::U32(seen)) => Some(*seen),
250258
_ => None,
251259
}),
252-
protocol_type: None,
260+
protocol_type: values
261+
.iter()
262+
.find(|(k, _)| *k == IPFixField::ProtocolIdentifier)
263+
.and_then(|(_, v)| match v {
264+
FieldValue::DataNumber(DataNumber::U8(proto)) => {
265+
Some(ProtocolTypes::from(*proto))
266+
}
267+
_ => None,
268+
}),
253269
});
254270
}
255271
}
@@ -485,6 +501,10 @@ mod common_tests {
485501
assert_eq!(flowset.src_port.unwrap(), 1234);
486502
assert_eq!(flowset.dst_port.unwrap(), 80);
487503
assert_eq!(flowset.protocol_number.unwrap(), 6);
504+
assert_eq!(
505+
flowset.protocol_type.unwrap(),
506+
crate::protocol::ProtocolTypes::Tcp
507+
);
488508
assert_eq!(flowset.first_seen.unwrap(), 100);
489509
assert_eq!(flowset.last_seen.unwrap(), 200);
490510
}
@@ -582,6 +602,10 @@ mod common_tests {
582602
assert_eq!(flowset.src_port.unwrap(), 1234);
583603
assert_eq!(flowset.dst_port.unwrap(), 80);
584604
assert_eq!(flowset.protocol_number.unwrap(), 6);
605+
assert_eq!(
606+
flowset.protocol_type.unwrap(),
607+
crate::protocol::ProtocolTypes::Tcp
608+
);
585609
assert_eq!(flowset.first_seen.unwrap(), 100);
586610
assert_eq!(flowset.last_seen.unwrap(), 200);
587611
}

0 commit comments

Comments
 (0)