18#if COAP_SERVER_SUPPORT
23is_cache_key(uint16_t option_type,
size_t cache_ignore_count,
24 const uint16_t *cache_ignore_options) {
28 if ((option_type & 0x1e) == 0x1c)
38 for (i = 0; i < cache_ignore_count; i++) {
39 if (cache_ignore_options[i] == option_type) {
49 const uint16_t *options,
61 const uint16_t *options,
88 const uint16_t *cache_ignore_options,
89 size_t cache_ignore_count) {
111 if (is_cache_key(opt_iter.
number, cache_ignore_count,
112 cache_ignore_options)) {
114 sizeof(opt_iter.
number))) {
142 memcpy(cache_key->
key, digest.
key,
sizeof(cache_key->
key));
168 unsigned int idle_timeout) {
182 unsigned int idle_timeout) {
215 if (idle_timeout > 0) {
288 HASH_DELETE(hh, ctx->
cache, cache_entry);
290 if (cache_entry->
pdu) {
302 return cache_entry->
pdu;
324 HASH_ITER(hh, ctx->
cache, cp, ctmp) {
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().
uint8_t coap_opt_t
Use byte-oriented access methods here because sliding a complex struct coap_opt_t over the data buffe...
coap_cache_entry_t * coap_cache_get_by_pdu_lkd(coap_session_t *session, const coap_pdu_t *pdu, coap_cache_session_based_t session_based)
Searches for a cache-entry corresponding to pdu.
void coap_digest_free(coap_digest_ctx_t *digest_ctx)
Free off coap_digest_ctx_t.
int coap_cache_ignore_options_lkd(coap_context_t *context, const uint16_t *options, size_t count)
Define the CoAP options that are not to be included when calculating the cache-key.
coap_cache_entry_t * coap_cache_get_by_key_lkd(coap_context_t *context, const coap_cache_key_t *cache_key)
Searches for a cache-entry identified by cache_key.
coap_cache_entry_t * coap_new_cache_entry_lkd(coap_session_t *session, const coap_pdu_t *pdu, coap_cache_record_pdu_t record_pdu, coap_cache_session_based_t session_based, unsigned int idle_time)
Create a new cache-entry hash keyed by cache-key derived from the PDU.
int coap_digest_final(coap_digest_ctx_t *digest_ctx, coap_digest_t *digest_buffer)
Finalize the coap_digest information into the provided digest_buffer.
int coap_digest_update(coap_digest_ctx_t *digest_ctx, const uint8_t *data, size_t data_len)
Update the coap_digest information with the next chunk of data.
void coap_expire_cache_entries(coap_context_t *context)
Expire coap_cache_entry_t entries.
coap_digest_ctx_t * coap_digest_setup(void)
Initialize a coap_digest.
void coap_delete_cache_entry(coap_context_t *context, coap_cache_entry_t *cache_entry)
Remove a cache-entry from the hash list and free off all the appropriate contents apart from app_data...
COAP_API int coap_cache_ignore_options(coap_context_t *context, const uint16_t *options, size_t count)
Define the CoAP options that are not to be included when calculating the cache-key.
void coap_delete_cache_key(coap_cache_key_t *cache_key)
Delete the cache-key.
COAP_API coap_cache_entry_t * coap_cache_get_by_key(coap_context_t *context, const coap_cache_key_t *cache_key)
Searches for a cache-entry identified by cache_key.
coap_cache_key_t * coap_cache_derive_key(const coap_session_t *session, const coap_pdu_t *pdu, coap_cache_session_based_t session_based)
Calculates a cache-key for the given CoAP PDU.
COAP_API coap_cache_entry_t * coap_cache_get_by_pdu(coap_session_t *session, const coap_pdu_t *pdu, coap_cache_session_based_t session_based)
Searches for a cache-entry corresponding to pdu.
void(* coap_cache_app_data_free_callback_t)(void *data)
Callback to free off the app data when the cache-entry is being deleted / freed off.
const coap_pdu_t * coap_cache_get_pdu(const coap_cache_entry_t *cache_entry)
Returns the PDU information stored in the coap_cache entry.
coap_cache_key_t * coap_cache_derive_key_w_ignore(const coap_session_t *session, const coap_pdu_t *pdu, coap_cache_session_based_t session_based, const uint16_t *ignore_options, size_t ignore_count)
Calculates a cache-key for the given CoAP PDU.
void * coap_cache_get_app_data(const coap_cache_entry_t *cache_entry)
Returns any application-specific data that has been stored with cache_entry using the function coap_c...
COAP_API coap_cache_entry_t * coap_new_cache_entry(coap_session_t *session, const coap_pdu_t *pdu, coap_cache_record_pdu_t record_pdu, coap_cache_session_based_t session_based, unsigned int idle_time)
Create a new cache-entry hash keyed by cache-key derived from the PDU.
void coap_cache_set_app_data(coap_cache_entry_t *cache_entry, void *data, coap_cache_app_data_free_callback_t callback)
Stores data with the given cache entry.
coap_cache_session_based_t
@ COAP_CACHE_IS_SESSION_BASED
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_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_callback(c, func)
Dummy for no thread-safe code.
#define coap_lock_check_locked(c)
Dummy for no thread-safe code.
#define coap_log_warn(...)
coap_opt_t * coap_option_next(coap_opt_iterator_t *oi)
Updates the iterator oi to point to the next option.
uint32_t coap_opt_length(const coap_opt_t *opt)
Returns the length of the given option.
coap_opt_iterator_t * coap_option_iterator_init(const coap_pdu_t *pdu, coap_opt_iterator_t *oi, const coap_opt_filter_t *filter)
Initializes the given option iterator oi to point to the beginning of the pdu's option list.
#define COAP_OPT_ALL
Pre-defined filter that includes all options.
const uint8_t * coap_opt_value(const coap_opt_t *opt)
Returns a pointer to the value of the given option.
int coap_pdu_resize(coap_pdu_t *pdu, size_t new_size)
Dynamically grows the size of pdu to new_size.
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.
coap_pdu_t * coap_pdu_init(coap_pdu_type_t type, coap_pdu_code_t code, coap_mid_t mid, size_t size)
Creates a new CoAP PDU with at least enough storage space for the given size maximum message size.
#define COAP_OPTION_OBSERVE
@ COAP_REQUEST_CODE_FETCH
coap_cache_app_data_free_callback_t callback
unsigned int idle_timeout
coap_cache_key_t * cache_key
The CoAP stack's global state is stored in a coap_context_t object.
uint16_t * cache_ignore_options
CoAP options to ignore when creating a cache-key.
size_t cache_ignore_count
The number of CoAP options to ignore when creating a cache-key.
coap_cache_entry_t * cache
CoAP cache-entry cache.
Iterator to run through PDU options.
coap_option_num_t number
decoded option number
uint8_t * token
first byte of token (or extended length bytes prefix), if any, or options
coap_pdu_code_t code
request method (value 1–31) or response code (value 64-255)
uint8_t * data
first byte of payload, if any
coap_mid_t mid
message id, if any, in regular host byte order
size_t used_size
used bytes of storage for token, options and payload
size_t alloc_size
allocated storage for token, options and payload
coap_pdu_type_t type
message type
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