#[repr(C, packed(1))]pub struct UdpHeader {
pub src_port: u16,
pub dst_port: u16,
pub length: u16,
pub checksum: u16,
}Expand description
UDP header (8 bytes)
Fields§
§src_port: u16Source port
dst_port: u16Destination port
length: u16Length (header + data)
checksum: u16Checksum
Implementations§
Source§impl UdpHeader
impl UdpHeader
Sourcepub fn calculate_checksum(
&self,
src_ip: [u8; 4],
dst_ip: [u8; 4],
data: &[u8],
) -> u16
pub fn calculate_checksum( &self, src_ip: [u8; 4], dst_ip: [u8; 4], data: &[u8], ) -> u16
Calculate UDP checksum
Sourcepub fn from_bytes(bytes: &[u8]) -> Option<Self>
pub fn from_bytes(bytes: &[u8]) -> Option<Self>
Parse header from bytes
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UdpHeader
impl RefUnwindSafe for UdpHeader
impl Send for UdpHeader
impl Sync for UdpHeader
impl Unpin for UdpHeader
impl UnwindSafe for UdpHeader
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)