libcoap 4.3.5-develop-72190a8
Loading...
Searching...
No Matches
Application I/O Handling

Internal API for Application Input / Output checking. More...

+ Collaboration diagram for Application I/O Handling:

Functions

void coap_io_do_io_lkd (coap_context_t *ctx, coap_tick_t now)
 Processes any outstanding read, write, accept or connect I/O as indicated in the coap_socket_t structures (COAP_SOCKET_CAN_xxx set) embedded in endpoints or sessions associated with ctx.
 
void coap_io_do_epoll_lkd (coap_context_t *ctx, struct epoll_event *events, size_t nevents)
 Process all the epoll events.
 
int coap_io_pending_lkd (coap_context_t *context)
 Check to see if there is any i/o pending for the context.
 
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.
 
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).
 
int coap_io_process_lkd (coap_context_t *ctx, uint32_t timeout_ms)
 The main I/O processing function.
 
int coap_io_process_with_fds_lkd (coap_context_t *ctx, uint32_t timeout_ms, int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
 The main message processing loop with additional fds for internal select.
 
unsigned int coap_io_get_fds_lkd (coap_context_t *context, 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_mid_t coap_send_lkd (coap_session_t *session, coap_pdu_t *pdu)
 Sends a CoAP message to given peer.
 
int coap_send_recv_lkd (coap_session_t *session, coap_pdu_t *request_pdu, coap_pdu_t **response_pdu, uint32_t timeout_ms)
 
coap_mid_t coap_send_error_lkd (coap_session_t *session, const coap_pdu_t *request, coap_pdu_code_t code, coap_opt_filter_t *opts)
 Sends an error response with code code for request request to dst.
 
coap_mid_t coap_send_message_type_lkd (coap_session_t *session, const coap_pdu_t *request, coap_pdu_type_t type)
 Helper function to create and send a message with type (usually ACK or RST).
 
coap_mid_t coap_send_ack_lkd (coap_session_t *session, const coap_pdu_t *request)
 Sends an ACK message with code 0 for the specified request to dst.
 
coap_mid_t coap_send_rst_lkd (coap_session_t *session, const coap_pdu_t *request)
 Sends an RST message with code 0 for the specified request to dst.
 

Detailed Description

Internal API for Application Input / Output checking.

Function Documentation

◆ coap_io_do_epoll_lkd()

void coap_io_do_epoll_lkd ( coap_context_t ctx,
struct epoll_event *  events,
size_t  nevents 
)

Process all the epoll events.

Note: If epoll support is compiled into libcoap, coap_io_do_epoll_lkd() must be used instead of coap_io_do_io_lkd().

Note: This function must be called in the locked state.

Parameters
ctxThe current CoAP context.
eventsThe list of events returned from an epoll_wait() call.
neventsThe number of events.

Definition at line 2528 of file coap_net.c.

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

◆ coap_io_do_io_lkd()

void coap_io_do_io_lkd ( coap_context_t ctx,
coap_tick_t  now 
)

Processes any outstanding read, write, accept or connect I/O as indicated in the coap_socket_t structures (COAP_SOCKET_CAN_xxx set) embedded in endpoints or sessions associated with ctx.

Note: If epoll support is compiled into libcoap, coap_io_do_epoll_lkd() must be used instead of coap_io_do_io_lkd().

Note: This function must be called in the locked state.

Parameters
ctxThe CoAP context
nowCurrent time

Definition at line 2463 of file coap_net.c.

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

◆ coap_io_get_fds_lkd()

unsigned int coap_io_get_fds_lkd ( coap_context_t context,
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 
)

Definition at line 1623 of file coap_io.c.

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

◆ coap_io_pending_lkd()

int coap_io_pending_lkd ( coap_context_t context)

Check to see if there is any i/o pending for the context.

This includes Observe active (client) and partial large block transfers.

Note: This function must be called in the locked state.

coap_io_process_lkd() is called internally to try to send outstanding data as well as process any packets just received.

Parameters
contextThe CoAP context.
Returns
1 I/O still pending, 0 no I/O pending.

Definition at line 1990 of file coap_io.c.

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

◆ coap_io_prepare_epoll_lkd()

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.

In addition, it returns when the next expected I/O is expected to take place (e.g. a packet retransmit).

Note: If epoll support is compiled into libcoap, coap_io_prepare_epoll_lkd() must be used instead of coap_io_prepare_io_lkd().

Note: This function must be called in the locked state.

Parameters
ctxThe CoAP context
nowCurrent time.
Returns
timeout Maxmimum number of milliseconds that can be used by a epoll_wait() to wait for network events or 0 if wait should be forever.

Definition at line 1256 of file coap_io.c.

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

◆ coap_io_prepare_io_lkd()

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).

If set, the coap_socket_t is added to the sockets.

Any now timed out delayed packet is transmitted, along with any packets associated with requested observable response.

In addition, it returns when the next expected I/O is expected to take place (e.g. a packet retransmit).

Prior to calling coap_io_do_io_lkd(), the sockets must be tested to see if any of the COAP_SOCKET_WANT_xxx have the appropriate information and if so, COAP_SOCKET_CAN_xxx is set. This typically will be done after using a select() call.

Note: If epoll support is compiled into libcoap, coap_io_prepare_epoll_lkd() must be used instead of coap_io_prepare_io_lkd().

Note: This function must be called in the locked state.

Parameters
ctxThe CoAP context
socketsArray of socket descriptors, filled on output
max_socketsSize of socket array.
num_socketsPointer to the number of valid entries in the socket arrays on output.
nowCurrent time.
Returns
timeout Maxmimum number of milliseconds that can be used by a select() to wait for network events or 0 if wait should be forever.

Definition at line 1325 of file coap_io.c.

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

◆ coap_io_process_lkd()

int coap_io_process_lkd ( coap_context_t ctx,
uint32_t  timeout_ms 
)

The main I/O processing function.

All pending network I/O is completed, and then optionally waits for the next input packet.

This internally calls coap_io_prepare_io_lkd(), then select() for the appropriate sockets, updates COAP_SOCKET_CAN_xxx where appropriate and then calls coap_io_do_io_lkd() before returning with the time spent in the function.

Alternatively, if libcoap is compiled with epoll support, this internally calls coap_io_prepare_epoll_lkd(), then epoll_wait() for waiting for any file descriptors that have (internally) been set up with epoll_ctl() and finally coap_io_do_epoll_lkd() before returning with the time spent in the function.

Note: This function must be called in the locked state.

Parameters
ctxThe CoAP context
timeout_msMinimum number of milliseconds to wait for new packets before returning after doing any processing. If COAP_IO_WAIT, the call will block until the next internal action (e.g. packet retransmit) if any, or block until the next packet is received whichever is the sooner and do the necessary processing. If COAP_IO_NO_WAIT, the function will return immediately after processing without waiting for any new input packets to arrive.
Returns
Number of milliseconds spent in function or -1 if there was an error

Definition at line 1736 of file coap_io.c.

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

◆ coap_io_process_with_fds_lkd()

int coap_io_process_with_fds_lkd ( coap_context_t ctx,
uint32_t  timeout_ms,
int  nfds,
fd_set *  readfds,
fd_set *  writefds,
fd_set *  exceptfds 
)

The main message processing loop with additional fds for internal select.

Note: This function must be called in the locked state.

Parameters
ctxThe CoAP context
timeout_msMinimum number of milliseconds to wait for new packets before returning after doing any processing. If COAP_IO_WAIT, the call will block until the next internal action (e.g. packet retransmit) if any, or block until the next packet is received whichever is the sooner and do the necessary processing. If COAP_IO_NO_WAIT, the function will return immediately after processing without waiting for any new input packets to arrive.
nfdsThe maximum FD set in readfds, writefds or exceptfds plus one,
readfdsRead FDs to additionally check for in internal select() or NULL if not required.
writefdsWrite FDs to additionally check for in internal select() or NULL if not required.
exceptfdsExcept FDs to additionally check for in internal select() or NULL if not required.
Returns
Number of milliseconds spent in coap_io_process_with_fds_lkd, or -1 if there was an error. If defined, readfds, writefds, exceptfds are updated as returned by the internal select() call.

Definition at line 1754 of file coap_io.c.

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

◆ coap_send_ack_lkd()

coap_mid_t coap_send_ack_lkd ( coap_session_t session,
const coap_pdu_t request 
)

Sends an ACK message with code 0 for the specified request to dst.

This function returns the corresponding message id if the message was sent or COAP_INVALID_MID on error.

Note: This function must be called in the locked state.

Parameters
sessionThe CoAP session.
requestThe request to be acknowledged.
Returns
The message id if ACK was sent or COAP_INVALID_MID on error.

Definition at line 986 of file coap_net.c.

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

◆ coap_send_error_lkd()

coap_mid_t coap_send_error_lkd ( coap_session_t session,
const coap_pdu_t request,
coap_pdu_code_t  code,
coap_opt_filter_t opts 
)

Sends an error response with code code for request request to dst.

opts will be passed to coap_new_error_response() to copy marked options from the request. This function returns the message id if the message was sent, or COAP_INVALID_MID otherwise.

Note: This function must be called in the locked state.

Parameters
sessionThe CoAP session.
requestThe original request to respond to.
codeThe response code.
optsA filter that specifies the options to copy from the request.
Returns
The message id if the message was sent, or COAP_INVALID_MID otherwise.

Definition at line 1066 of file coap_net.c.

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

◆ coap_send_lkd()

coap_mid_t coap_send_lkd ( coap_session_t session,
coap_pdu_t pdu 
)

Sends a CoAP message to given peer.

The memory that is allocated for the pdu will be released by coap_send_lkd(). The caller must not use or delete the pdu after calling coap_send_lkd().

Note: This function must be called in the locked state.

Parameters
sessionThe CoAP session.
pduThe CoAP PDU to send.
Returns
The message id of the sent message or COAP_INVALID_MID on error.

Definition at line 1356 of file coap_net.c.

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

◆ coap_send_message_type_lkd()

coap_mid_t coap_send_message_type_lkd ( coap_session_t session,
const coap_pdu_t request,
coap_pdu_type_t  type 
)

Helper function to create and send a message with type (usually ACK or RST).

This function returns COAP_INVALID_MID when the message was not sent, a valid transaction id otherwise.

Note: This function must be called in the locked state.

Parameters
sessionThe CoAP session.
requestThe request that should be responded to.
typeWhich type to set.
Returns
message id on success or COAP_INVALID_MID otherwise.

Definition at line 1095 of file coap_net.c.

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

◆ coap_send_recv_lkd()

int coap_send_recv_lkd ( coap_session_t session,
coap_pdu_t request_pdu,
coap_pdu_t **  response_pdu,
uint32_t  timeout_ms 
)

Definition at line 1939 of file coap_net.c.

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

◆ coap_send_rst_lkd()

coap_mid_t coap_send_rst_lkd ( coap_session_t session,
const coap_pdu_t request 
)

Sends an RST message with code 0 for the specified request to dst.

This function returns the corresponding message id if the message was sent or COAP_INVALID_MID on error.

Note: This function must be called in the locked state.

Parameters
sessionThe CoAP session.
requestThe request to be reset.
Returns
The message id if RST was sent or COAP_INVALID_MID on error.

Definition at line 971 of file coap_net.c.

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