[][src]Trait packet_crafter::headers::Header

pub trait Header {
    fn make(self) -> PacketData;
fn parse(raw_data: &[u8]) -> Result<Box<Self>, ParseError>;
fn get_proto(&self) -> Protocol;
fn get_length(&self) -> u8;
fn get_min_length() -> u8; fn into_transport_header(&mut self) -> Option<&mut dyn TransportHeader> { ... } }

Required methods

fn make(self) -> PacketData

'cook' the header, returning it as a Vec<u8>. this function will calculate checksums, even though they will be over-written by the OS if the packet is sent 'down the wire', likewise with a lot of length fields and such.

The reason i decided to still calculate checksums is incase someone uses the packet for some other purpose, or if they are building/using an experimntal OS which doesn calculate checksums (or they havent built that in yet).

fn parse(raw_data: &[u8]) -> Result<Box<Self>, ParseError>

parse() should never be run from a box

, is hould only ever br un as
::parse(). this is just here to complete the implementation of Header onto boxed structs that implement header

fn get_proto(&self) -> Protocol

fn get_length(&self) -> u8

get the current length of the header in bytes. this usually just returns a fixed value as most headers dont have variable length, only really IP does and even then its rare for it to be > 20 bytes

fn get_min_length() -> u8

get the minimum length (in bytes) that this type of header can be

Loading content...

Provided methods

fn into_transport_header(&mut self) -> Option<&mut dyn TransportHeader>

attempts to coerce the header (a type which implements the Header trait) into a &mut dyn TransportHeader. Only returns Option::Some when the underlying concrete type is a UdpHeader or a TcpHeader

Loading content...

Implementations on Foreign Types

impl<T: Header> Header for Box<T>[src]

Loading content...

Implementors

impl Header for ArpHeader[src]

impl Header for EthernetHeader[src]

impl Header for IcmpHeader[src]

impl Header for IpHeader[src]

fn make(self) -> PacketData[src]

needs testing on a big endian machine

impl Header for TcpHeader[src]

impl Header for UdpHeader[src]

Loading content...