Pcap and PcapNg parsing

Crates.io rustdoc Crates.io

Pcap

This crate can read Pcap files from a reader and write them to a writer.

It also provides several parsers for the Pcap file format.

Example: PcapReader

```rust use std::fs::File; use pcap_file::pcap::PcapReader;

let filein = File::open("test.pcap").expect("Error opening file"); let pcapreader = PcapReader::new(file_in).unwrap();

// Read test.pcap for pcap in pcap_reader {

 //Check if there is no error
 let pcap = pcap.unwrap();

 //Do something

} ```

PcapNg

This crate can read PcapNg files from a reader.

It also provides several parsers for the PcapNg file format.

Example: PcapNgReader

```rust use std::fs::File; use pcap_file::pcapng::PcapNgReader;

let filein = File::open("test.pcapng").expect("Error opening file"); let pcapngreader = PcapNgReader::new(file_in).unwrap();

// Read test.pcapng for pcapng in pcapng_reader {

 //Check if there is no error
 let pcapng = pcapng.unwrap();

 //Do something

} ```

Documentation

https://docs.rs/pcap-file

Installation

This crate is on crates.io. Add it to your Cargo.toml:

toml [dependencies] pcap-file = "1.0.1"

License

Licensed under MIT.

Disclaimer

To test the library I used the excellent PcapNg testing suite provided by hadrielk.