Struct capsules_extra::net::udp::udp_port_table::UdpPortManager
source · pub struct UdpPortManager { /* private fields */ }
Expand description
The UdpPortManager maintains a reference to the port_array, which manages what ports are bound at any given moment, and user_ports, which provides a handle to userspace port bindings in the UDP driver.
Implementations§
source§impl UdpPortManager
impl UdpPortManager
pub fn new( _cap: &dyn CreatePortTableCapability, used_kernel_ports: &'static mut [Option<SocketBindingEntry>], udp_vis: &'static UdpVisibilityCapability, ) -> UdpPortManager
pub fn set_user_ports( &self, user_ports_ref: &'static dyn PortQuery, _driver_cap: &dyn UdpDriverCapability, )
sourcepub fn create_socket(&'static self) -> Result<UdpSocket, Result<(), ErrorCode>>
pub fn create_socket(&'static self) -> Result<UdpSocket, Result<(), ErrorCode>>
Called by capsules that would like to eventually be able to bind to a UDP port. This call will succeed unless MAX_NUM_BOUND_PORTS capsules have already bound to a port.
sourcepub fn is_bound(&self, port: u16) -> Result<bool, ()>
pub fn is_bound(&self, port: u16) -> Result<bool, ()>
Check if a given port is already bound, by either an app or capsule.
sourcepub fn bind(
&self,
socket: UdpSocket,
port: u16,
net_cap: &'static NetworkCapability,
) -> Result<(UdpPortBindingTx, UdpPortBindingRx), UdpSocket>
pub fn bind( &self, socket: UdpSocket, port: u16, net_cap: &'static NetworkCapability, ) -> Result<(UdpPortBindingTx, UdpPortBindingRx), UdpSocket>
Called by capsules that have already reserved a socket to attempt to bind to a UDP port. The socket is passed by value. On success, bindings is returned. On failure, the same UdpSocket is returned.
sourcepub fn unbind(
&'static self,
sender_binding: UdpPortBindingTx,
receiver_binding: UdpPortBindingRx,
) -> Result<UdpSocket, (UdpPortBindingTx, UdpPortBindingRx)>
pub fn unbind( &'static self, sender_binding: UdpPortBindingTx, receiver_binding: UdpPortBindingRx, ) -> Result<UdpSocket, (UdpPortBindingTx, UdpPortBindingRx)>
Disassociate the port from the given binding. Return the socket associated with the passed bindings. On Err, return the passed bindings.