Struct capsules_extra::net::udp::driver::UDPDriver

source ·
pub struct UDPDriver<'a> { /* private fields */ }

Implementations§

source§

impl<'a> UDPDriver<'a>

source

pub fn new( sender: &'a dyn UDPSender<'a>, grant: Grant<App, UpcallCount<{ upcall::COUNT }>, AllowRoCount<{ ro_allow::COUNT }>, AllowRwCount<{ rw_allow::COUNT }>>, interface_list: &'static [IPAddr], max_tx_pyld_len: usize, port_table: &'static UdpPortManager, kernel_buffer: SubSliceMut<'static, u8>, driver_send_cap: &'static dyn UdpDriverCapability, net_cap: &'static NetworkCapability ) -> UDPDriver<'a>

Trait Implementations§

source§

impl<'a> PortQuery for UDPDriver<'a>

source§

fn is_bound(&self, port: u16) -> bool

source§

impl<'a> SyscallDriver for UDPDriver<'a>

source§

fn command( &self, command_num: usize, arg1: usize, _: usize, processid: ProcessId ) -> CommandReturn

UDP control

§command_num
  • 0: Driver existence check.
  • 1: Get the interface list app_cfg (out): 16 * n bytes: the list of interface IPv6 addresses, length limited by app_cfg length. Returns INVAL if the cfg buffer is the wrong size, or not available.
  • 2: Transmit payload. Returns BUSY is this process already has a pending tx. Returns INVAL if no valid buffer has been loaded into the write buffer, or if the config buffer is the wrong length, or if the destination and source port/address pairs cannot be parsed. Otherwise, returns the result of do_next_tx_immediate(). Notably, a successful transmit can produce two different success values. If success is returned, this simply means that the packet was queued. In this case, the app still still needs to wait for a callback to check if any errors occurred before the packet was passed to the radio. However, if Success_U32 is returned with value 1, this means the the packet was successfully passed the radio without any errors, which tells the userland application that it does not need to wait for a callback to check if any errors occurred while the packet was being passed down to the radio. Any successful return value indicates that the app should wait for a send_done() callback before attempting to queue another packet. Currently, only will transmit if the app has bound to the port passed in the tx_cfg buf as the source address. If no port is bound, returns RESERVE, if it tries to send on a port other than the port which is bound, returns INVALID. Notably, the currently transmit implementation allows for starvation - an an app with a lower app id can send constantly and starve an app with a later ID.
  • 3: Bind to the address in rx_cfg. Returns Ok(()) if that addr/port combo is free, returns INVAL if the address requested is not a local interface, or if the port requested is 0. Returns BUSY if that port is already bound to by another app. This command should be called after allow() is called on the rx_cfg buffer, and before subscribe() is used to set up the recv callback. Additionally, apps can only send on ports after they have bound to said port. If this command is called and the address in rx_cfg is 0::0 : 0, this command will reset the option containing the bound port to None. Notably, the current implementation of this only allows for each app to bind to a single port at a time, as such an implementation conserves memory (and is similar to the approach applied by TinyOS and Riot). /// - 4: Returns the maximum payload that can be transmitted by apps using this driver. This represents the size of the payload buffer in the kernel. Apps can use this syscall to ensure they do not attempt to send too-large messages.
source§

fn allocate_grant(&self, processid: ProcessId) -> Result<(), Error>

Request to allocate a capsule’s grant for a specific process. Read more
source§

fn allow_userspace_readable( &self, app: ProcessId, which: usize, slice: ReadWriteProcessBuffer ) -> Result<ReadWriteProcessBuffer, (ReadWriteProcessBuffer, ErrorCode)>

System call for a process to pass a buffer (a UserspaceReadableProcessBuffer) to the kernel that the kernel can either read or write. The kernel calls this method only after it checks that the entire buffer is within memory the process can both read and write. Read more
source§

impl<'a> UDPRecvClient for UDPDriver<'a>

source§

fn receive( &self, src_addr: IPAddr, dst_addr: IPAddr, src_port: u16, dst_port: u16, payload: &[u8] )

source§

impl<'a> UDPSendClient for UDPDriver<'a>

source§

fn send_done( &self, result: Result<(), ErrorCode>, dgram: SubSliceMut<'static, u8> )

Auto Trait Implementations§

§

impl<'a> !Freeze for UDPDriver<'a>

§

impl<'a> !RefUnwindSafe for UDPDriver<'a>

§

impl<'a> !Send for UDPDriver<'a>

§

impl<'a> !Sync for UDPDriver<'a>

§

impl<'a> Unpin for UDPDriver<'a>

§

impl<'a> !UnwindSafe for UDPDriver<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> SizedTypeProperties for T

source§

#[doc(hidden)] const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.