Crate pcap_file [] [src]

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

Also provides a Packet struct which represents a pcap packet with its header.

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 {

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

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

Reexports

pub use errors::*;

Modules

errors

Contains error_chain error handling materials

peek_reader

Structs

Packet

Represents a pcap packet.

PacketHeader

Describes a pcap packet header.

PcapHeader

Struct that represents the global Pcap header of a Pcap file

PcapReader

This struct wraps another reader and enables it to read a Pcap formated stream.

PcapWriter

This struct wraps another writer and enables it to write a Pcap formated stream.

Enums

DataLink

Represents each possible Pcap datalink

Endianness

Represents the endianness of the global header