pub struct PacketSocket { /* private fields */ }Expand description
Wrapper around an AF_PACKET SOCK_DGRAM file descriptor.
Owns the fd and closes it on drop. Provides synchronous send/recv
methods used by the async wrappers via AsyncFd.
Implementations§
Source§impl PacketSocket
impl PacketSocket
Sourcepub fn open(interface: &str, ethertype: u16) -> Result<Self, TransportError>
pub fn open(interface: &str, ethertype: u16) -> Result<Self, TransportError>
Create and bind an AF_PACKET SOCK_DGRAM socket.
Returns an error with a clear message if CAP_NET_RAW is missing.
Sourcepub fn local_mac(&self) -> Result<[u8; 6], TransportError>
pub fn local_mac(&self) -> Result<[u8; 6], TransportError>
Get the local MAC address of the bound interface.
Sourcepub fn interface_mtu(&self) -> Result<u16, TransportError>
pub fn interface_mtu(&self) -> Result<u16, TransportError>
Get the interface MTU.
Sourcepub fn set_recv_buffer_size(&self, size: usize) -> Result<(), TransportError>
pub fn set_recv_buffer_size(&self, size: usize) -> Result<(), TransportError>
Set the socket receive buffer size.
Sourcepub fn set_send_buffer_size(&self, size: usize) -> Result<(), TransportError>
pub fn set_send_buffer_size(&self, size: usize) -> Result<(), TransportError>
Set the socket send buffer size.
Source§impl PacketSocket
impl PacketSocket
Sourcepub fn into_async(self) -> Result<AsyncPacketSocket, TransportError>
pub fn into_async(self) -> Result<AsyncPacketSocket, TransportError>
Wrap this socket in an async wrapper for tokio integration.
Trait Implementations§
Source§impl AsRawFd for PacketSocket
impl AsRawFd for PacketSocket
Source§impl Drop for PacketSocket
impl Drop for PacketSocket
Auto Trait Implementations§
impl Freeze for PacketSocket
impl RefUnwindSafe for PacketSocket
impl Send for PacketSocket
impl Sync for PacketSocket
impl Unpin for PacketSocket
impl UnsafeUnpin for PacketSocket
impl UnwindSafe for PacketSocket
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more