Crate pcap_file [] [src]

Contains all the materials needed to read and write a pcap file format.

Provides two structs, PcapReader and PcapWriter, to read and write Pcap.

Provides a Packet which contains all the data relative to one packet

Examples

use std::fs::File;
use pcap_file::{PcapReader, PcapWriter};

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

let file_out = File::create("out.pcap").expect("Error creating file");
let mut pcap_writer = PcapWriter::new(file_out).unwrap();

// Read test.pcap
for pcap in pcap_reader {
    //Write each packet of test.pcap in out.pcap
    pcap_writer.write_packet(&pcap).unwrap();
}

Reexports

pub use packet::Packet;
pub use reader::PcapReader;
pub use writer::PcapWriter;

Modules

errors

Contains error_chain error handling materials

packet

This module contains the Packet and the PacketHeader structs which represents a packet and its header.

pcap_header

This module contains informations relative to the global Pcap header.

reader

This module contains the PcapReader struct which is used to read from a pcap file

writer

This module contains the PcapWriter struct which is used to write to a pcap file