[][src]Crate radiotap

A parser for the radiotap capture format.

Examples

Parsing all fields

The easiest way to use this crate is to parse a slice of bytes into a Header struct.

// a capture off the wire or from a pcap file
let capture = &[0, 0, 0xd, 0x0, 0x5, 0, 0, 0, 0x78, 0x56, 0x34, 0x12, 0, 0, 0, 0, 0x30, // ...
// parse the radiotap header from the capture into a `Header` struct
let header = radiotap::parse(capture).unwrap();

// get the length of the entire header
let length = header.length();

// unpack the desired parsed fields
let radiotap::Header { tsft, rate, .. } = header;
if let Some(tsft) = tsft {
    assert_eq!(tsft.into_inner(), 0x12345678);
}
if let Some(rate) = rate {
    assert_eq!(rate.to_mbps(), 24.0);
}

// using the length we can get the rest of the capture
// i.e. IEEE 802.11 header and body
let rest = &capture[length..];

Parsing no fields

This crate can also be used to skip over the radiotap header without parsing any of the fields.

// a capture off the wire or from a pcap file
let capture = &[0, 0, 0xd, 0x0, 0x5, 0, 0, 0, 0x78, 0x56, 0x34, 0x12, 0, 0, 0, 0, 0x30, // ...

// create an iterator which parses the first part of the
// radiotap header, enough to get a length
let iter = radiotap::Iter::new(capture).unwrap();

// now we can get the rest of the capture
// i.e. IEEE 802.11 header and body
let rest = &capture[iter.length()..];

Modules

field

Field definitions.

Structs

Error

An error that can occur in this crate.

Field

A generic field yielded by the radiotap iterator.

Header

A parsed radiotap capture.

Iter

An iterator over a radiotap capture.

IterDefault

An iterator over a radiotap capture skipping any vendor namespaces.

Enums

ErrorKind

The kind of error that occurred.

Namespace

A radiotap namespace.

Functions

parse

Parse a radiotap header from the given capture.

Type Definitions

Result

A result type to use throughout this crate.