#[repr(C)]pub struct IcmpTimestampMsgPart {
pub originate_timestamp: [u8; 4],
pub receive_timestamp: [u8; 4],
pub transmit_timestamp: [u8; 4],
}Expand description
Represents the variable length portion of a Timestamp Request/Reply message (RFC 792) that follows the ICMP header.
Timestamps are milliseconds since midnight UT and are stored in network byte order.
§Example
use aya_ebpf::programs::TcContext;
use network_types::eth::EthHdr;
use network_types::icmp::{Icmpv4Hdr, IcmpError, Icmpv4HdrData, IcmpTimestampMsgPart};
use network_types::ip::Ipv4Hdr;
fn handle_icmp_timestamp(ctx: &TcContext) -> Result<u32, IcmpError> {
// Parse the ICMP header from start of payload
let icmp_start = ctx.data() + EthHdr::LEN + Ipv4Hdr::LEN;
let icmp_hdr: *mut Icmpv4Hdr = icmp_start as *mut Icmpv4Hdr;
// Timestamp request/reply share the same echo layout; ensure the type matches
match unsafe { (*icmp_hdr).data()? } {
Icmpv4HdrData::Timestamp(id_seq)
| Icmpv4HdrData::TimestampReply(id_seq) => {
let timestamps_ptr_location = icmp_start + Icmpv4Hdr::LEN;
let timestamps: *const IcmpTimestampMsgPart =
timestamps_ptr_location as *const IcmpTimestampMsgPart;
let _id = id_seq.id();
let _sequence = id_seq.sequence();
unsafe {
let _orig = (*timestamps).originate_timestamp();
let _recv = (*timestamps).receive_timestamp();
let _xmit = (*timestamps).transmit_timestamp();
// Use the timestamp fields as needed.
}
},
_ => {},
}
Ok(0)
}Fields§
§originate_timestamp: [u8; 4]§receive_timestamp: [u8; 4]§transmit_timestamp: [u8; 4]Implementations§
Source§impl IcmpTimestampMsgPart
impl IcmpTimestampMsgPart
pub const LEN: usize
Sourcepub fn originate_timestamp(&self) -> u32
pub fn originate_timestamp(&self) -> u32
Returns the originate timestamp in host byte order (milliseconds since midnight UT)
Sourcepub fn set_originate_timestamp(&mut self, timestamp: u32)
pub fn set_originate_timestamp(&mut self, timestamp: u32)
Sets the originate timestamp field (milliseconds since midnight UT). The value will be stored in network byte order.
Sourcepub fn receive_timestamp(&self) -> u32
pub fn receive_timestamp(&self) -> u32
Returns the receive timestamp in host byte order (milliseconds since midnight UT)
Sourcepub fn set_receive_timestamp(&mut self, timestamp: u32)
pub fn set_receive_timestamp(&mut self, timestamp: u32)
Sets the receive timestamp field (milliseconds since midnight UT). The value will be stored in network byte order.
Sourcepub fn transmit_timestamp(&self) -> u32
pub fn transmit_timestamp(&self) -> u32
Returns the transmit timestamp in host byte order (milliseconds since midnight UT)
Sourcepub fn set_transmit_timestamp(&mut self, timestamp: u32)
pub fn set_transmit_timestamp(&mut self, timestamp: u32)
Sets the transmit timestamp field (milliseconds since midnight UT). The value will be stored in network byte order.
Trait Implementations§
Source§impl Clone for IcmpTimestampMsgPart
impl Clone for IcmpTimestampMsgPart
Source§fn clone(&self) -> IcmpTimestampMsgPart
fn clone(&self) -> IcmpTimestampMsgPart
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for IcmpTimestampMsgPart
impl Debug for IcmpTimestampMsgPart
Source§impl<'de, WincodeConfig: Config> SchemaRead<'de, WincodeConfig> for IcmpTimestampMsgPart
impl<'de, WincodeConfig: Config> SchemaRead<'de, WincodeConfig> for IcmpTimestampMsgPart
type Dst = IcmpTimestampMsgPart
Source§fn read(
reader: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> ReadResult<()>
fn read( reader: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> ReadResult<()>
Source§impl<WincodeConfig: Config> SchemaWrite<WincodeConfig> for IcmpTimestampMsgPart
impl<WincodeConfig: Config> SchemaWrite<WincodeConfig> for IcmpTimestampMsgPart
Source§impl<WincodeConfig: Config> ZeroCopy<WincodeConfig> for IcmpTimestampMsgPart
impl<WincodeConfig: Config> ZeroCopy<WincodeConfig> for IcmpTimestampMsgPart
Source§fn from_bytes<'de>(bytes: &'de [u8], config: C) -> Result<&'de Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
fn from_bytes<'de>(bytes: &'de [u8], config: C) -> Result<&'de Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
crate::ZeroCopy::from_bytes, but allows the caller to provide a custom configuration.Source§fn from_bytes_mut<'de>(
bytes: &'de mut [u8],
config: C,
) -> Result<&'de mut Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
fn from_bytes_mut<'de>(
bytes: &'de mut [u8],
config: C,
) -> Result<&'de mut Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
crate::ZeroCopy::from_bytes_mut, but allows the caller to provide a custom configuration.impl Copy for IcmpTimestampMsgPart
Auto Trait Implementations§
impl Freeze for IcmpTimestampMsgPart
impl RefUnwindSafe for IcmpTimestampMsgPart
impl Send for IcmpTimestampMsgPart
impl Sync for IcmpTimestampMsgPart
impl Unpin for IcmpTimestampMsgPart
impl UnsafeUnpin for IcmpTimestampMsgPart
impl UnwindSafe for IcmpTimestampMsgPart
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
Source§impl<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
impl<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
Source§impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
Source§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Reader into a new Self::Dst.Source§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Reader into dst.Source§impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
Source§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Reader into a new Self::Dst.Source§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Reader into dst.Source§impl<T, C> Serialize<C> for T
impl<T, C> Serialize<C> for T
Source§fn serialize_into(
dst: impl Writer,
src: &Self::Src,
config: C,
) -> Result<(), WriteError>
fn serialize_into( dst: impl Writer, src: &Self::Src, config: C, ) -> Result<(), WriteError>
Writer.