capsules_extra::net::udp::udp_send

Trait UDPSender

Source
pub trait UDPSender<'a> {
    // Required methods
    fn set_client(&self, client: &'a dyn UDPSendClient);
    fn send_to(
        &'a self,
        dest: IPAddr,
        dst_port: u16,
        buf: SubSliceMut<'static, u8>,
        net_cap: &'static NetworkCapability,
    ) -> Result<(), SubSliceMut<'static, u8>>;
    fn driver_send_to(
        &'a self,
        dest: IPAddr,
        dst_port: u16,
        src_port: u16,
        buf: SubSliceMut<'static, u8>,
        driver_send_cap: &dyn UdpDriverCapability,
        net_cap: &'static NetworkCapability,
    ) -> Result<(), SubSliceMut<'static, u8>>;
    fn send(
        &'a self,
        dest: IPAddr,
        udp_header: UDPHeader,
        buf: SubSliceMut<'static, u8>,
        net_cap: &'static NetworkCapability,
    ) -> Result<(), SubSliceMut<'static, u8>>;
    fn get_binding(&self) -> Option<UdpPortBindingTx>;
    fn is_bound(&self) -> bool;
    fn set_binding(&self, binding: UdpPortBindingTx) -> Option<UdpPortBindingTx>;
}
Expand description

This trait represents the bulk of the UDP functionality.

The two variants of sending a packet (either via the send_to or send methods) represent whether the caller wants to construct a custom UDPHeader or not. Calling send_to tells the UDP layer to construct a default UDPHeader and forward the payload to the respective destination and port.

Required Methods§

Source

fn set_client(&self, client: &'a dyn UDPSendClient)

This function sets the client for the UDPSender instance

§Arguments

client - Implementation of UDPSendClient to be set as the client for the UDPSender instance

Source

fn send_to( &'a self, dest: IPAddr, dst_port: u16, buf: SubSliceMut<'static, u8>, net_cap: &'static NetworkCapability, ) -> Result<(), SubSliceMut<'static, u8>>

This function constructs a UDPHeader and sends the payload to the provided destination IP address and destination port from the src port contained in the UdpPortBindingTx.

§Arguments

dest - IPv6 address to send the UDP packet to dst_port - Destination port to send the packet to buf - UDP payload binding - type that specifies what port the sender is bound to.

§Return Value

Any synchronous errors are returned via the returned Result<(), ErrorCode> value; asynchronous errors are delivered via the callback.

Source

fn driver_send_to( &'a self, dest: IPAddr, dst_port: u16, src_port: u16, buf: SubSliceMut<'static, u8>, driver_send_cap: &dyn UdpDriverCapability, net_cap: &'static NetworkCapability, ) -> Result<(), SubSliceMut<'static, u8>>

This function is identical to send_to() except that it takes in an explicit src_port instead of a binding. This allows it to be used by the userspace driver, above which apps are bound to multiple ports

§Arguments

dest - IPv6 address to send the UDP packet to dst_port - Destination port to send the packet to src_port - Port to send the packet from buf - UDP payload

§Return Value

Any synchronous errors are returned via the returned Result<(), ErrorCode> value; asynchronous errors are delivered via the callback.

Source

fn send( &'a self, dest: IPAddr, udp_header: UDPHeader, buf: SubSliceMut<'static, u8>, net_cap: &'static NetworkCapability, ) -> Result<(), SubSliceMut<'static, u8>>

This function constructs an IP packet from the completed UDPHeader and buffer, and sends it to the provided IP address

§Arguments

dest - IP address to send the UDP packet to udp_header - Completed UDP header to be sent to the destination buf - A byte array containing the UDP payload

§Return Value

Returns any synchronous errors or success. Note that any asynchrounous errors are returned via the callback.

Source

fn get_binding(&self) -> Option<UdpPortBindingTx>

Source

fn is_bound(&self) -> bool

Source

fn set_binding(&self, binding: UdpPortBindingTx) -> Option<UdpPortBindingTx>

Implementors§

Source§

impl<'a, T: IP6Sender<'a>> UDPSender<'a> for UDPSendStruct<'a, T>

Below is the implementation of the UDPSender traits for the UDPSendStruct.