pub struct ParsedPacket {
pub raw: Vec<u8>,
pub ip_version: IpVersion,
pub src_ip: String,
pub dst_ip: String,
pub ttl: u8,
pub total_len: usize,
pub ip_payload_offset: usize,
pub transport: TransportProtocol,
}Expand description
A fully parsed IP packet with IP and transport layer information.
Fields§
§raw: Vec<u8>Raw bytes of the original packet.
ip_version: IpVersionIP version.
src_ip: StringSource IP address as string.
dst_ip: StringDestination IP address as string.
ttl: u8TTL (IPv4) or hop limit (IPv6).
total_len: usizeTotal packet length in bytes.
ip_payload_offset: usizeByte offset where the IP payload starts (after IP header).
transport: TransportProtocolParsed transport layer.
Implementations§
Source§impl ParsedPacket
impl ParsedPacket
Sourcepub fn parse(raw: Vec<u8>) -> Result<Self, VCLError>
pub fn parse(raw: Vec<u8>) -> Result<Self, VCLError>
Parse a raw IP packet (IPv4 or IPv6) into a ParsedPacket.
§Errors
Returns VCLError::InvalidPacket if:
- The packet is empty or too short
- The IP header is malformed
Sourcepub fn is_destined_for(&self, ip: &str) -> bool
pub fn is_destined_for(&self, ip: &str) -> bool
Returns true if the destination IP matches ip.
Sourcepub fn ip_payload(&self) -> &[u8] ⓘ
pub fn ip_payload(&self) -> &[u8] ⓘ
Returns the payload slice — bytes after the IP header.
Trait Implementations§
Source§impl Clone for ParsedPacket
impl Clone for ParsedPacket
Source§fn clone(&self) -> ParsedPacket
fn clone(&self) -> ParsedPacket
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ParsedPacket
impl RefUnwindSafe for ParsedPacket
impl Send for ParsedPacket
impl Sync for ParsedPacket
impl Unpin for ParsedPacket
impl UnsafeUnpin for ParsedPacket
impl UnwindSafe for ParsedPacket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more