22#define SEARCH_PAIR(head,out,field1,val1,field2,val2,field3,val3) \
23 SEARCH_PAIR3(head,out,field1,val1,field2,val2,field3,val3,next)
25#define SEARCH_PAIR3(head,out,field1,val1,field2,val2,field3,val3,next) \
27 LL_FOREACH2(head,out,next) { \
28 if ((out)->field1 == (val1) && (out)->field2 == (val2) && \
29 ((val2) == 0 || memcmp((out)->field3, (val3), (val2)) == 0)) break; \
44 async = coap_register_async_lkd(session, request, delay);
60 SEARCH_PAIR(session->
context->async_state, s,
73 outbuflen = strlen(outbuf);
74 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
75 "%02x", request->
token[i]);
77 coap_log_debug(
"asynchronous state for token '%s' already registered\n", outbuf);
89 LL_PREPEND(session->
context->async_state, s);
95 coap_free_async_lkd(session, s);
106 coap_async_set_delay_lkd(s, delay);
114 coap_async_trigger_lkd(async);
120 assert(async != NULL);
132 coap_async_set_delay_lkd(async, delay);
141 assert(async != NULL);
145 async->delay = now + delay;
164 tmp = coap_find_async_lkd(session, token);
174 SEARCH_PAIR(session->
context->async_state, tmp,
176 pdu->actual_token.length, token.
length,
177 pdu->actual_token.s, token.
s);
184 LL_DELETE(context->async_state,s);
199 coap_free_async_lkd(session, async);
205 coap_free_async_sub(session->
context, async);
212 LL_FOREACH_SAFE(context->async_state, astate, tmp) {
213 coap_free_async_sub(context, astate);
215 context->async_state = NULL;
220 async->appdata = app_data;
225 return async->appdata;
struct coap_async_t coap_async_t
Async Entry information.
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.
Library specific build wrapper for coap_internal.h.
void * coap_malloc_type(coap_memory_tag_t type, size_t size)
Allocates a chunk of size bytes and returns a pointer to the newly allocated memory.
void coap_free_type(coap_memory_tag_t type, void *p)
Releases the memory that was allocated by coap_malloc_type().
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
#define COAP_TICKS_PER_SECOND
Use ms resolution on POSIX systems.
void coap_free_async(coap_session_t *session, coap_async_t *async)
Releases the memory that was allocated by coap_register_async() for the object async.
coap_async_t * coap_find_async(coap_session_t *session, coap_bin_const_t token)
Retrieves the object identified by token from the list of asynchronous transactions that are register...
void * coap_async_get_app_data(const coap_async_t *async)
Gets the application data pointer held in async.
void coap_async_set_app_data(coap_async_t *async, void *app_data)
Set the application data pointer held in async.
COAP_API void coap_async_trigger(coap_async_t *async)
Trigger the registered async.
coap_async_t * coap_register_async(coap_session_t *session, const coap_pdu_t *request, coap_tick_t delay)
Allocates a new coap_async_t object and fills its fields according to the given request.
void coap_async_set_delay(coap_async_t *async, coap_tick_t delay)
Update the delay timeout, so changing when the registered async triggers.
void coap_ticks(coap_tick_t *)
Returns the current value of an internal tick counter.
#define coap_lock_unlock(c)
Dummy for no thread-safe code.
#define coap_lock_lock(c, failed)
Dummy for no thread-safe code.
#define coap_lock_check_locked(c)
Dummy for no thread-safe code.
#define coap_log_debug(...)
const char * coap_session_str(const coap_session_t *session)
Get session description.
#define coap_log_crit(...)
coap_pdu_t * coap_pdu_duplicate_lkd(const coap_pdu_t *old_pdu, coap_session_t *session, size_t token_length, const uint8_t *token, coap_opt_filter_t *drop_options)
Duplicate an existing PDU.
#define COAP_PDU_IS_REQUEST(pdu)
void coap_delete_pdu(coap_pdu_t *pdu)
Dispose of an CoAP PDU and frees associated storage.
int coap_get_data(const coap_pdu_t *pdu, size_t *len, const uint8_t **data)
Retrieves the length and data pointer of specified PDU.
int coap_add_data(coap_pdu_t *pdu, size_t len, const uint8_t *data)
Adds given data to the pdu that is passed as first parameter.
void coap_session_release_lkd(coap_session_t *session)
Decrement reference counter on a session.
coap_session_t * coap_session_reference_lkd(coap_session_t *session)
Increment reference counter on a session.
int coap_async_is_supported(void)
Check whether ASYNC (separate responses) is available.
CoAP binary data definition with const data.
size_t length
length of binary data
const uint8_t * s
read-only binary data
The CoAP stack's global state is stored in a coap_context_t object.
uint8_t * token
first byte of token (or extended length bytes prefix), if any, or options
coap_bin_const_t actual_token
Actual token in pdu.
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
coap_context_t * context
session's context