libcoap 4.3.5-develop-ea01661
Loading...
Searching...
No Matches
coap_io.c File Reference

Network I/O functions. More...

+ Include dependency graph for coap_io.c:

Go to the source code of this file.

Data Structures

struct  in6_pktinfo
 
struct  in_pktinfo
 

Macros

#define MSG_NOSIGNAL   0
 
#define SOL_IP   IPPROTO_IP
 
#define COAP_SOL_IP   SOL_IP
 
#define iov_len_t   size_t
 
#define SIN6(A)   ((struct sockaddr_in6 *)(A))
 

Functions

void coap_socket_close (coap_socket_t *sock)
 Function interface to close off a socket (for both TCP and UDP).
 
void coap_update_io_timer (coap_context_t *context, coap_tick_t delay)
 Update when to continue with I/O processing, unless packets come in in the meantime.
 
ssize_t coap_socket_write (coap_socket_t *sock, const uint8_t *data, size_t data_len)
 Function interface for data stream sending off a socket.
 
ssize_t coap_socket_read (coap_socket_t *sock, uint8_t *data, size_t data_len)
 Function interface for data stream receiving off a socket.
 
ssize_t coap_socket_send (coap_socket_t *sock, coap_session_t *session, const uint8_t *data, size_t datalen)
 Function interface for data transmission.
 
void coap_packet_get_memmapped (coap_packet_t *packet, unsigned char **address, size_t *length)
 Given a packet, set msg and msg_len to an address and length of the packet's data in memory.
 
ssize_t coap_socket_recv (coap_socket_t *sock, coap_packet_t *packet)
 Function interface for reading data.
 
COAP_API unsigned int coap_io_prepare_epoll (coap_context_t *ctx, coap_tick_t now)
 Any now timed out delayed packet is transmitted, along with any packets associated with requested observable response.
 
unsigned int coap_io_prepare_epoll_lkd (coap_context_t *ctx, coap_tick_t now)
 Any now timed out delayed packet is transmitted, along with any packets associated with requested observable response.
 
COAP_API unsigned int coap_io_prepare_io (coap_context_t *ctx, coap_socket_t *sockets[], unsigned int max_sockets, unsigned int *num_sockets, coap_tick_t now)
 Iterates through all the coap_socket_t structures embedded in endpoints or sessions associated with the ctx to determine which are wanting any read, write, accept or connect I/O (COAP_SOCKET_WANT_xxx is set).
 
unsigned int coap_io_prepare_io_lkd (coap_context_t *ctx, coap_socket_t *sockets[], unsigned int max_sockets, unsigned int *num_sockets, coap_tick_t now)
 Iterates through all the coap_socket_t structures embedded in endpoints or sessions associated with the ctx to determine which are wanting any read, write, accept or connect I/O (COAP_SOCKET_WANT_xxx is set).
 
COAP_API unsigned int coap_io_get_fds (coap_context_t *ctx, coap_fd_t read_fds[], unsigned int *have_read_fds, unsigned int max_read_fds, coap_fd_t write_fds[], unsigned int *have_write_fds, unsigned int max_write_fds, unsigned int *rem_timeout_ms)
 
static int coap_add_fd (coap_fd_t fd, coap_fd_t this_fds[], unsigned int *have_this_fds, unsigned int max_this_fds)
 
unsigned int coap_io_get_fds_lkd (coap_context_t *ctx, coap_fd_t read_fds[], unsigned int *have_read_fds, unsigned int max_read_fds, coap_fd_t write_fds[], unsigned int *have_write_fds, unsigned int max_write_fds, unsigned int *rem_timeout_ms)
 
COAP_API int coap_io_process (coap_context_t *ctx, uint32_t timeout_ms)
 The main I/O processing function.
 
int coap_io_process_lkd (coap_context_t *ctx, uint32_t timeout_ms)
 The main I/O processing function.
 
COAP_API int coap_io_process_with_fds (coap_context_t *ctx, uint32_t timeout_ms, int enfds, fd_set *ereadfds, fd_set *ewritefds, fd_set *eexceptfds)
 The main message processing loop with additional fds for internal select.
 
int coap_io_process_with_fds_lkd (coap_context_t *ctx, uint32_t timeout_ms, int enfds, fd_set *ereadfds, fd_set *ewritefds, fd_set *eexceptfds)
 The main message processing loop with additional fds for internal select.
 
void coap_io_process_terminate_loop (void)
 Terminate all the additional threads created by coap_io_process_loop() and break out of the main thread loop to return from coap_io_process_loop().
 
COAP_API int coap_io_process_loop (coap_context_t *context, coap_io_process_thread_t main_loop_code, void *main_loop_code_arg, uint32_t timeout_ms, uint32_t thread_count)
 Do the coap_io_process() across thread_count threads.
 
int coap_io_process_loop_lkd (coap_context_t *context, coap_io_process_thread_t main_loop_code, void *main_loop_code_arg, uint32_t timeout_ms, uint32_t thread_count)
 Do the coap_io_process() across thread_count threads.
 
COAP_API int coap_io_pending (coap_context_t *context)
 Check to see if there is any i/o pending for the context.
 
int coap_io_pending_lkd (coap_context_t *context)
 Check to see if there is any i/o pending for the context.
 
const char * coap_socket_format_errno (int error)
 
const char * coap_socket_strerror (void)
 
COAP_API coap_fd_t coap_socket_get_fd (coap_socket_t *sock)
 Get the libcoap internal file descriptor for a socket.
 
COAP_API coap_socket_flags_t coap_socket_get_flags (coap_socket_t *sock)
 Get the libcoap internal flags for a socket.
 
COAP_API void coap_socket_set_flags (coap_socket_t *sock, coap_socket_flags_t flags)
 Set the libcoap internal flags for a socket.
 

Variables

volatile int coap_thread_quit = 0
 

Detailed Description

Network I/O functions.

Definition in file coap_io.c.

Macro Definition Documentation

◆ COAP_SOL_IP

#define COAP_SOL_IP   SOL_IP

Definition at line 778 of file coap_io.c.

◆ iov_len_t

#define iov_len_t   size_t

Definition at line 816 of file coap_io.c.

◆ MSG_NOSIGNAL

#define MSG_NOSIGNAL   0

◆ SIN6

#define SIN6 (   A)    ((struct sockaddr_in6 *)(A))

Definition at line 1054 of file coap_io.c.

◆ SOL_IP

#define SOL_IP   IPPROTO_IP

Definition at line 773 of file coap_io.c.

Function Documentation

◆ coap_add_fd()

static int coap_add_fd ( coap_fd_t  fd,
coap_fd_t  this_fds[],
unsigned int *  have_this_fds,
unsigned int  max_this_fds 
)
static

Definition at line 1713 of file coap_io.c.

+ Here is the caller graph for this function:

◆ coap_packet_get_memmapped()

void coap_packet_get_memmapped ( coap_packet_t packet,
unsigned char **  address,
size_t *  length 
)

Given a packet, set msg and msg_len to an address and length of the packet's data in memory.

Definition at line 1057 of file coap_io.c.

+ Here is the caller graph for this function:

◆ coap_socket_format_errno()

const char * coap_socket_format_errno ( int  error)

Definition at line 2353 of file coap_io.c.

+ Here is the caller graph for this function:

◆ coap_socket_strerror()

const char * coap_socket_strerror ( void  )

Definition at line 2364 of file coap_io.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_update_io_timer()

void coap_update_io_timer ( coap_context_t context,
coap_tick_t  delay 
)

Update when to continue with I/O processing, unless packets come in in the meantime.

Typically, this timeout triggers retransmissions.

Parameters
contextThe CoAP context.
delayThe time to delay before continuing with I/O processing.

Definition at line 533 of file coap_io.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ coap_thread_quit

volatile int coap_thread_quit = 0

Definition at line 2184 of file coap_io.c.