use netflow_parser::NetflowParser;
use netflow_parser::variable_versions::enterprise_registry::EnterpriseFieldDef;
use netflow_parser::variable_versions::field_value::FieldDataType;
fn main() {
let custom_fields = vec![
EnterpriseFieldDef::new(
12345, 1, "acmeCustomMetric",
FieldDataType::UnsignedDataNumber,
),
EnterpriseFieldDef::new(12345, 2, "acmeApplicationName", FieldDataType::String),
EnterpriseFieldDef::new(12345, 3, "acmeSourceIpAddress", FieldDataType::Ip4Addr),
EnterpriseFieldDef::new(
12345,
4,
"acmeTimestampMillis",
FieldDataType::DurationMillis,
),
];
let mut _parser = NetflowParser::builder()
.with_cache_size(1000)
.register_enterprise_fields(custom_fields)
.build()
.expect("Failed to build parser");
println!("Parser created with custom enterprise fields registered!");
println!("Enterprise fields for enterprise number 12345:");
println!(" - Field 1: acmeCustomMetric (UnsignedDataNumber)");
println!(" - Field 2: acmeApplicationName (String)");
println!(" - Field 3: acmeSourceIpAddress (IPv4 Address)");
println!(" - Field 4: acmeTimestampMillis (Duration in milliseconds)");
println!();
println!("When IPFIX packets with these enterprise fields are parsed,");
println!("they will be automatically decoded using the specified data types");
println!("instead of being treated as raw bytes.");
let mut _parser2 = NetflowParser::builder()
.register_enterprise_field(EnterpriseFieldDef::new(
54321,
1,
"vendorSpecificField",
FieldDataType::Ip6Addr,
))
.build()
.expect("Failed to build parser");
println!();
println!("Second parser created with a single enterprise field for enterprise 54321");
}