#pcap #packet #network

net-parser-rs

Basic network parser leveraging Rust and nom for safe and efficient packet parsing. Design influenced by pktparse-rs.

4 releases (2 breaking)

0.3.0 Jun 9, 2020
0.2.0 Apr 6, 2020
0.1.1 Nov 16, 2018
0.1.0 Nov 16, 2018

#678 in Network programming

Download history 6/week @ 2021-10-04 12/week @ 2021-10-11 9/week @ 2021-10-18 60/week @ 2021-10-25 3/week @ 2021-11-01 37/week @ 2021-11-08 41/week @ 2021-11-15 6/week @ 2021-11-22 18/week @ 2021-11-29 10/week @ 2021-12-06 2/week @ 2021-12-13 22/week @ 2021-12-20 1/week @ 2021-12-27 72/week @ 2022-01-03 25/week @ 2022-01-10 45/week @ 2022-01-17

143 downloads per month
Used in suricata-ipc

MIT license

4MB
2.5K SLoC

Network Packet Parser (net-parser-rs)

Basic network parser leveraging Rust and nom for safe and efficient packet parsing. Design influenced by pktparse-rs.

Getting Started

Add net-parser-rs to your dependencies

[dependencies]
net-parser-rs="0.3"
    #![feature(try_from)]
    extern crate net_parser_rs;

    use net_parser_rs::CaptureParser;
    use std::*;

    //Parse a file with global header and packet records
    let file_bytes = include_bytes!("capture.pcap");
    let records = CaptureParser::parse_file(file_bytes).expect("Could not parse");

    //Parse a sequence of one or more packet records
    let records = CaptureParser::parse_records(record_bytes).expect("Could not parse");

    //Parse a single packet
    let packet = CaptureParser::parse_record(packet_bytes).expect("Could not parse");

    //Convert a packet into flow information
    use net_parser_rs::flow::*;

    let flow = packet.extract_flow().expect("Could not extract flow");

Dependencies

^