#[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
impl Packet
sourcepub fn timestamp(&self) -> f64
pub fn timestamp(&self) -> f64
Timestamp of when the packet was captured (as the number of seconds since 1970-01-01).
sourcepub fn ethernethdr(&self) -> Option<&EthernetHeader>
pub fn ethernethdr(&self) -> Option<&EthernetHeader>
Returns an EthernetHeader
if the packet contains an Ethernet header and is long enough.
Returns None
otherwise.
sourcepub fn ip4hdr(&self) -> Option<&Ip4Header>
pub fn ip4hdr(&self) -> Option<&Ip4Header>
Returns an Ip4Header
if the packet contains an IPv4 header and is long enough. Returns
None
otherwise.
sourcepub fn ip6hdr(&self) -> Option<&Ip6Header>
pub fn ip6hdr(&self) -> Option<&Ip6Header>
Returns an Ip4Header
if the packet contains an IPv6 header and is long enough. Returns
None
otherwise.
sourcepub fn tcphdr(&self) -> Option<&TcpHeader>
pub fn tcphdr(&self) -> Option<&TcpHeader>
Returns a TcpHeader
if the packet contains a TCP header and is long enough. Returns
None
otherwise.
sourcepub fn udphdr(&self) -> Option<&UdpHeader>
pub fn udphdr(&self) -> Option<&UdpHeader>
Returns a UdpHeader
if the packet contains a UDP header and is long enough. Returns
None
otherwise.
sourcepub fn icmphdr(&self) -> Option<&IcmpHeader>
pub fn icmphdr(&self) -> Option<&IcmpHeader>
Returns an IcmpHeader
if the packet contains an ICMP header and is long enough. Returns
None
otherwise.
sourcepub fn l7_header(&self) -> &[u8] ⓘ
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.
sourcepub fn raw_l2_header(&self) -> &[u8] ⓘ
pub fn raw_l2_header(&self) -> &[u8] ⓘ
Returns the layer 2 header as a slice of bytes.
sourcepub fn raw_l3_header(&self) -> &[u8] ⓘ
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.
sourcepub fn raw_l4_header(&self) -> &[u8] ⓘ
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.