Struct t2plugin::packet::Packet

source ·
#[repr(C)]
pub struct Packet {
Show 18 fields pub status: u64, pub packet_raw_len: u32, pub packet_l2_len: u32, pub packet_len: u32, pub snap_len: u32, pub snap_l2_len: u32, pub snap_l3_len: u32, pub snap_l4_len: u16, pub snap_l7_len: u16, pub packet_l7_len: u16, pub l2_hdr_len: u16, pub l3_hdr_len: u16, pub l4_hdr_len: u16, pub inner_vlan: u16, pub src_port: u16, pub dst_port: u16, pub l2_type: u16, pub outer_l2_type: u16, /* private fields */
}
Expand description

Represents a packet with its different headers and associated lengths.

Fields§

§status: u64

Per packet status bits.

§packet_raw_len: u32

On wire full packet length (from the per-packet PCAP header).

§packet_l2_len: u32

On wire packet length starting from layer2.

§packet_len: u32

Packet length depending on Tranalyzer2 PACKETLENGTH value, see networkHeaders.h for details.

§snap_len: u32

Packet snapped length

§snap_l2_len: u32

Packet snapped length starting from layer 2.

§snap_l3_len: u32

Packet snapped length starting from layer 3.

§snap_l4_len: u16

Packet snapped length starting from layer 4.

§snap_l7_len: u16

Packet snapped length starting from layer 7.

§packet_l7_len: u16

Packet payload length: layer 7 length.

§l2_hdr_len: u16

Length of the layer 2 header (Ethernet, …).

§l3_hdr_len: u16

Length of the layer 3 header (IPv4, IPv6, …).

§l4_hdr_len: u16

Length of the layer 4 header (TCP, UDP, ICMP, …).

§inner_vlan: u16

Inner VLAN ID

§src_port: u16

Source port in host order.

§dst_port: u16

Destination port in host order.

§l2_type: u16

Type of the layer 2 header.

§outer_l2_type: u16

Outer type of the layer 2 header.

Implementations§

source§

impl Packet

source

pub fn timestamp(&self) -> f64

Timestamp of when the packet was captured (as the number of seconds since 1970-01-01).

source

pub fn ethernethdr(&self) -> Option<&EthernetHeader>

Returns an EthernetHeader if the packet contains an Ethernet header and is long enough. Returns None otherwise.

source

pub fn ip4hdr(&self) -> Option<&Ip4Header>

Returns an Ip4Header if the packet contains an IPv4 header and is long enough. Returns None otherwise.

source

pub fn ip6hdr(&self) -> Option<&Ip6Header>

Returns an Ip4Header if the packet contains an IPv6 header and is long enough. Returns None otherwise.

source

pub fn tcphdr(&self) -> Option<&TcpHeader>

Returns a TcpHeader if the packet contains a TCP header and is long enough. Returns None otherwise.

source

pub fn udphdr(&self) -> Option<&UdpHeader>

Returns a UdpHeader if the packet contains a UDP header and is long enough. Returns None otherwise.

source

pub fn icmphdr(&self) -> Option<&IcmpHeader>

Returns an IcmpHeader if the packet contains an ICMP header and is long enough. Returns None otherwise.

source

pub fn l7_header(&self) -> &[u8]

Returns the layer 7 as a slice of bytes.

This is how the layer 7 is typically accessed in content processing plugins.

source

pub fn raw_l2_header(&self) -> &[u8]

Returns the layer 2 header as a slice of bytes.

source

pub fn raw_l3_header(&self) -> &[u8]

Returns the layer 3 header as a slice of bytes.

This function can be used to access the IP options as a Rust inferface is not yet implemented for IPv4 options and IPv6 extension headers.

source

pub fn raw_l4_header(&self) -> &[u8]

Returns the layer 4 header as a slice of bytes.

This function can be used to access TCP options as a Rust interface is not yet implemented.

source

pub fn l3_type(&self) -> L3Type

Type of the layer 3 header as defined in L3Type.

source

pub fn l4_type(&self) -> L4Type

Type of the layer 4 header as defined in L4Type.

Auto Trait Implementations§

§

impl RefUnwindSafe for Packet

§

impl !Send for Packet

§

impl !Sync for Packet

§

impl Unpin for Packet

§

impl UnwindSafe for Packet

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.