pub struct RawSocket<'a, 'b: 'a> { /* private fields */ }
Expand description
A raw IP socket.
A raw socket is bound to a specific IP protocol, and owns transmit and receive packet buffers.
Implementations§
source§impl<'a, 'b> RawSocket<'a, 'b>
impl<'a, 'b> RawSocket<'a, 'b>
sourcepub fn new(
ip_version: IpVersion,
ip_protocol: IpProtocol,
rx_buffer: RawSocketBuffer<'a, 'b>,
tx_buffer: RawSocketBuffer<'a, 'b>
) -> RawSocket<'a, 'b>
pub fn new(
ip_version: IpVersion,
ip_protocol: IpProtocol,
rx_buffer: RawSocketBuffer<'a, 'b>,
tx_buffer: RawSocketBuffer<'a, 'b>
) -> RawSocket<'a, 'b>
Create a raw IP socket bound to the given IP version and datagram protocol, with the given buffers.
sourcepub fn handle(&self) -> SocketHandle
pub fn handle(&self) -> SocketHandle
Return the socket handle.
sourcepub fn ip_version(&self) -> IpVersion
pub fn ip_version(&self) -> IpVersion
Return the IP version the socket is bound to.
sourcepub fn ip_protocol(&self) -> IpProtocol
pub fn ip_protocol(&self) -> IpProtocol
Return the IP protocol the socket is bound to.
sourcepub fn send(&mut self, size: usize) -> Result<&mut [u8]>
pub fn send(&mut self, size: usize) -> Result<&mut [u8]>
Enqueue a packet to send, and return a pointer to its payload.
This function returns Err(Error::Exhausted)
if the transmit buffer is full,
and Err(Error::Truncated)
if there is not enough transmit buffer capacity
to ever send this packet.
If the buffer is filled in a way that does not match the socket’s IP version or protocol, the packet will be silently dropped.
Note: The IP header is parsed and reserialized, and may not match the header actually transmitted bit for bit.
sourcepub fn send_slice(&mut self, data: &[u8]) -> Result<()>
pub fn send_slice(&mut self, data: &[u8]) -> Result<()>
Enqueue a packet to send, and fill it from a slice.
See also send.