Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: more ipfix cleanup #113

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "netflow_parser"
description = "Parser for Netflow Cisco V5, V7, V9, IPFIX"
version = "0.5.4"
version = "0.5.5"
edition = "2024"
authors = ["michael.mileusnich@gmail.com"]
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let parsed = NetflowParser::default().parse_bytes(&v5_packet);
let v5_parsed: Vec<NetflowPacket> = parsed.into_iter().filter(|p| p.is_v5()).collect();
```

## Parsing out uneeded versions
## Parsing out unneeded versions
If you only care about a specific version or versions you can specfic `allowed_version`:
```rust
use netflow_parser::{NetflowParser, NetflowPacket};
Expand Down
3 changes: 3 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.5.5
* More IPFIx/V9 Cleanup.

# 0.5.4
* Reworked how padding is calculated for IPFIx.
* Fixed Vecs not being exported for DataNumber.
Expand Down
10 changes: 4 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
//! let v5_parsed: Vec<NetflowPacket> = parsed.into_iter().filter(|p| p.is_v5()).collect();
//! ```
//!
//! ## Parsing out uneeded versions
//! ## Parsing out unneeded versions
//! If you only care about a specific version or versions you can specfic `allowed_version`:
//! ```rust
//! use netflow_parser::{NetflowParser, NetflowPacket};
Expand Down Expand Up @@ -202,8 +202,6 @@ use variable_versions::v9::{V9, V9Parser};

use crate::static_versions::v5;
use crate::static_versions::v7;
use crate::variable_versions::ipfix;
use crate::variable_versions::v9;

use nom_derive::{Nom, Parse};
use serde::Serialize;
Expand Down Expand Up @@ -260,7 +258,7 @@ pub struct NetflowParser {
}

#[derive(Debug, Clone)]
pub(crate) struct ParsedNetflow {
pub struct ParsedNetflow {
pub(crate) remaining: Vec<u8>,
/// Parsed Netflow Packet
pub(crate) result: NetflowPacket,
Expand Down Expand Up @@ -397,8 +395,8 @@ impl NetflowParser {
match version {
5 => v5::parse_netflow_v5(packet),
7 => v7::parse_netflow_v7(packet),
9 => v9::parse_netflow_v9(packet, &mut self.v9_parser),
10 => ipfix::parse_netflow_ipfix(packet, &mut self.ipfix_parser),
9 => self.v9_parser.parse(packet),
10 => self.ipfix_parser.parse(packet),
_ => Err(NetflowParseError::UnknownVersion(packet.to_vec())),
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/netflow_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,14 @@ mod common_tests {
use std::collections::BTreeMap;
use std::net::{IpAddr, Ipv4Addr};

use crate::ipfix::{
Data as IPFixData, FlowSet as IPFixFlowSet, FlowSetBody as IPFixFlowSetBody,
FlowSetHeader as IPFixFlowSetHeader, Header as IPFixHeader, IPFix,
};
use crate::netflow_common::NetflowCommon;
use crate::static_versions::v5::{FlowSet as V5FlowSet, Header as V5Header, V5};
use crate::static_versions::v7::{FlowSet as V7FlowSet, Header as V7Header, V7};
use crate::variable_versions::data_number::{DataNumber, FieldValue};
use crate::variable_versions::ipfix::{
Data as IPFixData, FlowSet as IPFixFlowSet, FlowSetBody as IPFixFlowSetBody,
FlowSetHeader as IPFixFlowSetHeader, Header as IPFixHeader, IPFix,
};
use crate::variable_versions::ipfix_lookup::IPFixField;
use crate::variable_versions::v9::{
Data as V9Data, FlowSet as V9FlowSet, FlowSetBody as V9FlowSetBody,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
source: src/tests.rs
expression: parser.parse_bytes(&packet)
---
- IPFix:
header:
version: 10
length: 26
export_time: 1
sequence_number: 1
observation_domain_id: 0
flowsets: []

This file was deleted.

2 changes: 1 addition & 1 deletion src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ mod base_tests {
}

#[test]
fn it_parses_ipfix_with_no_template_fields_raises_error() {
fn it_parses_ipfix_with_no_template_fields() {
let packet = [
0, 10, 0, 26, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 2, 0, 10, 0, 8, 0, 0, 1, 1,
];
Expand Down
Loading