libcoap 4.3.5-develop-72190a8
|
Internal API for Application Input / Output checking. More...
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 . | |
Internal API for Application Input / Output checking.
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.
ctx | The current CoAP context. |
events | The list of events returned from an epoll_wait() call. |
nevents | The number of events. |
Definition at line 2528 of file coap_net.c.
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.
ctx | The CoAP context |
now | Current time |
Definition at line 2463 of file coap_net.c.
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 | ||
) |
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.
context | The CoAP context. |
1
I/O still pending, 0
no I/O pending. Definition at line 1990 of file coap_io.c.
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.
ctx | The CoAP context |
now | Current time. |
Definition at line 1256 of file coap_io.c.
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.
ctx | The CoAP context |
sockets | Array of socket descriptors, filled on output |
max_sockets | Size of socket array. |
num_sockets | Pointer to the number of valid entries in the socket arrays on output. |
now | Current time. |
Definition at line 1325 of file coap_io.c.
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.
ctx | The CoAP context |
timeout_ms | Minimum 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. |
-1
if there was an error Definition at line 1736 of file coap_io.c.
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.
ctx | The CoAP context |
timeout_ms | Minimum 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. |
nfds | The maximum FD set in readfds, writefds or exceptfds plus one, |
readfds | Read FDs to additionally check for in internal select() or NULL if not required. |
writefds | Write FDs to additionally check for in internal select() or NULL if not required. |
exceptfds | Except FDs to additionally check for in internal select() or NULL if not required. |
-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.
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.
session | The CoAP session. |
request | The request to be acknowledged. |
COAP_INVALID_MID
on error. Definition at line 986 of file coap_net.c.
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.
session | The CoAP session. |
request | The original request to respond to. |
code | The response code. |
opts | A filter that specifies the options to copy from the request . |
COAP_INVALID_MID
otherwise. Definition at line 1066 of file coap_net.c.
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.
session | The CoAP session. |
pdu | The CoAP PDU to send. |
COAP_INVALID_MID
on error. Definition at line 1356 of file coap_net.c.
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.
session | The CoAP session. |
request | The request that should be responded to. |
type | Which type to set. |
COAP_INVALID_MID
otherwise. Definition at line 1095 of file coap_net.c.
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.
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.
session | The CoAP session. |
request | The request to be reset. |
COAP_INVALID_MID
on error. Definition at line 971 of file coap_net.c.