#ipfix #bindings-generator #netflow #generator #parser #code #network-protocol

netgauze-ipfix-code-generator

Generate Rust code bindings for IPFIX Information Elements

7 releases (4 breaking)

new 0.5.0 Nov 5, 2024
0.4.1 Aug 8, 2024
0.3.1 Oct 10, 2024
0.3.0 Jan 31, 2024
0.1.0 Mar 5, 2023

#469 in Network programming

Download history 15/week @ 2024-07-13 62/week @ 2024-07-20 66/week @ 2024-07-27 288/week @ 2024-08-03 29/week @ 2024-08-10 18/week @ 2024-08-17 15/week @ 2024-08-24 1/week @ 2024-08-31 2/week @ 2024-09-07 54/week @ 2024-09-14 78/week @ 2024-09-21 49/week @ 2024-09-28 99/week @ 2024-10-05 42/week @ 2024-10-12 6/week @ 2024-10-19 3/week @ 2024-10-26

162 downloads per month
Used in 2 crates (via netgauze-flow-pkt)

Apache-2.0

155KB
3K SLoC

Generate Rust code bindings for IPFIX Information Elements

Example:

To include the generated IANA and custom registry Information elements, in build.rs add the following code

use std::env;

use netgauze_ipfix_code_generator::{Config, generate, RegistrySource, RegistryType, SourceConfig};

const IPFIX_URL: &str = "https://www.iana.org/assignments/ipfix/ipfix.xml";

fn main() {
    let out_dir = env::var_os("OUT_DIR").expect("Couldn't find OUT_DIR in OS env variables");
    let manifest_dir = env!("CARGO_MANIFEST_DIR");
    let registry_path = std::path::Path::new(&manifest_dir).join("registry");
    // Add custom registry, the xml file must follow the IANA schema
    let nokia_path = registry_path
        .join("nokia.xml")
        .into_os_string()
        .into_string()
        .expect("Couldn't load nokia registry file");
    let nokia_source = SourceConfig::new(
        RegistrySource::File(nokia_path),
        RegistryType::IanaXML,
        637,
        "nokia".to_string(),
        "Nokia".to_string(),
    );
    let iana_source = SourceConfig::new(
        RegistrySource::Http(IPFIX_URL.to_string()),
        RegistryType::IanaXML,
        0,
        "iana".to_string(),
        "IANA".to_string(),
    );
    let configs = Config::new(iana_source, vec![nokia_source]);
    generate(&out_dir, &configs).unwrap();

    println!("cargo:rerun-if-changed=build.rs");
}

Dependencies

~7–18MB
~247K SLoC