18 const uint16_t *cache_ignore_options) {
22 if ((option_type & 0x1e) == 0x1c)
32 for (i = 0; i < cache_ignore_count; i++) {
33 if (cache_ignore_options[i] == option_type) {
43 const uint16_t *options,
71 const uint16_t *cache_ignore_options,
72 size_t cache_ignore_count) {
96 cache_ignore_options)) {
123 memcpy(cache_key->
key, digest.
key,
sizeof(cache_key->
key));
146 unsigned int idle_timeout) {
176 if (idle_timeout > 0) {
225 HASH_DELETE(hh, ctx->
cache, cache_entry);
227 if (cache_entry->
pdu) {
239 return cache_entry->
pdu;
261 HASH_ITER(hh, ctx->
cache, cp, ctmp) {
static int is_cache_key(uint16_t option_type, size_t cache_ignore_count, const uint16_t *cache_ignore_options)
Pulls together all the internal only header files.
void coap_digest_free(coap_digest_ctx_t *digest_ctx)
Free off coap_digest_ctx_t.
coap_digest_ctx_t * coap_digest_setup(void)
Initialize a coap_digest.
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 *ctx)
Expire coap_cache_entry_t entries.
void coap_delete_cache_entry(coap_context_t *ctx, 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_cache_entry_t * coap_cache_get_by_pdu(coap_session_t *session, const coap_pdu_t *request, coap_cache_session_based_t session_based)
Searches for a cache-entry corresponding to pdu.
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.
void coap_delete_cache_key(coap_cache_key_t *cache_key)
Delete the cache-key.
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 *cache_ignore_options, size_t cache_ignore_count)
Calculates a cache-key for the given CoAP 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.
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_cache_entry_t * coap_cache_get_by_key(coap_context_t *ctx, const coap_cache_key_t *cache_key)
Searches for a cache-entry identified by cache_key.
int coap_cache_ignore_options(coap_context_t *ctx, 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_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_timeout)
Create a new cache-entry hash keyed by cache-key derived from the 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...
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
void coap_ticks(coap_tick_t *t)
Sets t to the internal time with COAP_TICKS_PER_SECOND resolution.
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.
#define coap_log(level,...)
Logging function.
coap_opt_t * coap_option_next(coap_opt_iterator_t *oi)
Updates the iterator oi to point to the next option.
#define COAP_OPT_ALL
Pre-defined filter that includes all options.
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.
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.
#define COAP_OPTION_OBSERVE
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.
@ COAP_REQUEST_CODE_FETCH
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.
COAP_STATIC_INLINE void * coap_malloc(size_t size)
Wrapper function to coap_malloc_type() for backwards compatibility.
COAP_STATIC_INLINE void coap_free(void *object)
Wrapper function to coap_free_type() for backwards compatibility.
void coap_free_type(coap_memory_tag_t type, void *p)
Releases the memory that was allocated by coap_malloc_type().
size_t coap_opt_size(const coap_opt_t *opt)
Returns the size of the given option, taking into account a possible option jump.
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_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
structure for CoAP PDUs token, if any, follows the fixed size header, then options until payload mark...
uint8_t * token
first byte of token, 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