Embedded Wireless Framework
Data Structures | Macros | Typedefs | Functions
Adapter UDP API

UDP functions to bind, connect, send, receive and close sockets. More...

Data Structures

struct  _ewf_socket_udp
 The UDP socket structure definition. More...
 
struct  _ewf_adapter_api_udp
 The UDP API type. More...
 

Macros

#define EWF_VALIDATE_UDP_SOCKET_POINTER(socket_ptr)
 
#define EWF_ADAPTER_UDP_SOCKET_QUERY_IS_BOUND   ("?IsBound")
 
#define EWF_ADAPTER_UDP_SOCKET_QUERY_USES_TLS   ("?UsesTLS")
 
#define EWF_ADAPTER_UDP_SOCKET_QUERY_SENT_BYTES   ("?SentBytes")
 
#define EWF_ADAPTER_UDP_SOCKET_QUERY_RECEIVED_BYTES   ("?ReceivedBytes")
 

Typedefs

typedef struct _ewf_socket_udp ewf_socket_udp
 The UDP socket type.
 
typedef ewf_result(* ewf_adapter_udp_receive_callback) (ewf_socket_udp *socket_ptr, const char *server, uint32_t port, const char *buffer, uint32_t length)
 A function pointer type for TCP receive callbacks. More...
 
typedef struct _ewf_adapter_api_udp ewf_adapter_api_udp
 The UDP API type.
 

Functions

ewf_result ewf_adapter_udp_open (ewf_adapter *adapter_ptr, ewf_socket_udp *socket_ptr)
 Open a UDP socket. More...
 
ewf_result ewf_adapter_udp_close (ewf_socket_udp *socket_ptr)
 Close a UDP socket. More...
 
ewf_result ewf_adapter_udp_control (ewf_socket_udp *socket_ptr, const char *control_str, uint8_t *buffer_ptr, uint32_t *buffer_length_ptr)
 Control an UDP socket This is mainly used to funnel implementation specific functionality. More...
 
ewf_result ewf_adapter_udp_set_dtls_configuration (ewf_socket_udp *socket_ptr, uint32_t dtls_configuration_id)
 Set the DTLS configuration for the socket. More...
 
ewf_result ewf_adapter_udp_bind (ewf_socket_udp *socket_ptr, uint32_t local_port)
 Binds an UDP socket to a local port. More...
 
ewf_result ewf_adapter_udp_shutdown (ewf_socket_udp *socket_ptr)
 Shutdown a UDP socket. More...
 
ewf_result ewf_adapter_udp_send_to (ewf_socket_udp *socket_ptr, const char *remote_address_str, uint32_t remote_port, const uint8_t *buffer_ptr, uint32_t buffer_length)
 Send data over a UDP socket. More...
 
ewf_result ewf_adapter_udp_receive_from (ewf_socket_udp *socket_ptr, char *remote_address, uint32_t *remote_address_length_ptr, uint32_t *remote_port_ptr, uint8_t *buffer_ptr, uint32_t *buffer_length_ptr, bool wait)
 Receive data over a UDP socket. More...
 
ewf_result ewf_adapter_udp_receive_callback_set (ewf_socket_udp *socket_ptr, ewf_adapter_udp_receive_callback callback)
 Register a user UDP receive callback function. More...
 

Detailed Description

UDP functions to bind, connect, send, receive and close sockets.

Macro Definition Documentation

◆ EWF_VALIDATE_UDP_SOCKET_POINTER

#define EWF_VALIDATE_UDP_SOCKET_POINTER (   socket_ptr)
Value:
do { \
if ((socket_ptr == NULL) || \
(socket_ptr->adapter_ptr == NULL)) \
{ \
EWF_LOG_ERROR("The UDP socket pointer is invalid.\n"); \
} \
} while(0)
@ EWF_RESULT_INVALID_FUNCTION_ARGUMENT
Definition: ewf.h:69

Typedef Documentation

◆ ewf_adapter_udp_receive_callback

typedef ewf_result(* ewf_adapter_udp_receive_callback) (ewf_socket_udp *socket_ptr, const char *server, uint32_t port, const char *buffer, uint32_t length)

A function pointer type for TCP receive callbacks.

Parameters
[in]adapter_ptra pointer to an adapter structure
Returns
ewf_result success and error conditions

Function Documentation

◆ ewf_adapter_udp_bind()

ewf_result ewf_adapter_udp_bind ( ewf_socket_udp socket_ptr,
uint32_t  local_port 
)

Binds an UDP socket to a local port.

Parameters
[in]socket_ptra pointer to an UDP socket
[in]local_portthe port number to bind to
Returns
ewf_result success and error conditions

◆ ewf_adapter_udp_close()

ewf_result ewf_adapter_udp_close ( ewf_socket_udp socket_ptr)

Close a UDP socket.

Parameters
[in]socket_ptra pointer to an UDP socket
Returns
ewf_result success and error conditions

◆ ewf_adapter_udp_control()

ewf_result ewf_adapter_udp_control ( ewf_socket_udp socket_ptr,
const char *  control_str,
uint8_t *  buffer_ptr,
uint32_t *  buffer_length_ptr 
)

Control an UDP socket This is mainly used to funnel implementation specific functionality.

Parameters
[in]socket_ptra pointer to a UDP socket
[in]control_stra pointer to NULL terminated string with the control string to execute
[in]buffer_ptra pointer to a buffer with additional data for the command
[in]buffer_length_ptrthe length of the buffer pointer by buffer_ptr on call, the size used on return
Returns
ewf_result success and error conditions

◆ ewf_adapter_udp_open()

ewf_result ewf_adapter_udp_open ( ewf_adapter adapter_ptr,
ewf_socket_udp socket_ptr 
)

Open a UDP socket.

Parameters
[in]adapter_ptra pointer to an adapter structure
[in]socket_ptra pointer to an UDP socket
Returns
ewf_result success and error conditions

◆ ewf_adapter_udp_receive_callback_set()

ewf_result ewf_adapter_udp_receive_callback_set ( ewf_socket_udp socket_ptr,
ewf_adapter_udp_receive_callback  callback 
)

Register a user UDP receive callback function.

Parameters
[in]socket_ptra pointer to an UDP socket
[in]callbackthe function pointer to the user callback
Returns
ewf_result success and error conditions

◆ ewf_adapter_udp_receive_from()

ewf_result ewf_adapter_udp_receive_from ( ewf_socket_udp socket_ptr,
char *  remote_address,
uint32_t *  remote_address_length_ptr,
uint32_t *  remote_port_ptr,
uint8_t *  buffer_ptr,
uint32_t *  buffer_length_ptr,
bool  wait 
)

Receive data over a UDP socket.

Parameters
[in]socket_ptra pointer to an UDP socket
[in,out]remote_addressthe address or name of the remote host from which the data was received, or NULL if not needed
[in,out]remote_address_length_ptrthe buffer length on input, the size of the remote string on output, or NULL if not needed
[in,out]remote_port_ptra pointer to a variable to hold the port number from which the data was received, or NULL if not needed
[in,out]buffer_ptra pointer to the buffer that is going to receive the data
[in,out]buffer_length_ptra pointer to an unsigned holds the size of the buffer on entry and the buffer_length and on return
[in]waita boolean indicating if the function should wait until data is available, true wait, false return immediately
Returns
ewf_result success and error conditions

◆ ewf_adapter_udp_send_to()

ewf_result ewf_adapter_udp_send_to ( ewf_socket_udp socket_ptr,
const char *  remote_address_str,
uint32_t  remote_port,
const uint8_t *  buffer_ptr,
uint32_t  buffer_length 
)

Send data over a UDP socket.

Parameters
[in]socket_ptra pointer to an UDP socket
[in]remote_address_stra pointer to a NULL terminated string with the address to send to
[in]remote_portthe remote port number to send to
[in]buffer_ptra pointer to the data to be sent
[in]buffer_lengththe number of bytes to be sent
Returns
ewf_result success and error conditions

◆ ewf_adapter_udp_set_dtls_configuration()

ewf_result ewf_adapter_udp_set_dtls_configuration ( ewf_socket_udp socket_ptr,
uint32_t  dtls_configuration_id 
)

Set the DTLS configuration for the socket.

Parameters
[in]socket_ptra pointer to an UDP socket
Returns
ewf_result success and error conditions

◆ ewf_adapter_udp_shutdown()

ewf_result ewf_adapter_udp_shutdown ( ewf_socket_udp socket_ptr)

Shutdown a UDP socket.

Parameters
[in]socket_ptrA pointer to a UDP socket
Returns
ewf_result success and error conditions