Crates.io | net-parser-rs |
lib.rs | net-parser-rs |
version | 0.3.0 |
source | src |
created_at | 2018-11-16 22:41:50.774342 |
updated_at | 2020-06-09 16:24:16.374034 |
description | Basic network parser leveraging Rust and nom for safe and efficient packet parsing. Design influenced by pktparse-rs. |
homepage | |
repository | https://github.com/protectwise/net-parser-rs/ |
max_upload_size | |
id | 97144 |
size | 25,817,766 |
Basic network parser leveraging Rust and nom for safe and efficient packet parsing. Design influenced by pktparse-rs.
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");