libcoap 4.3.5-develop-19cef11

Internal API for Cache-Key and Cache-Entry support. More...

+ Collaboration diagram for Cache Support:

Data Structures

struct  coap_digest_t
 
struct  coap_cache_key_t
 
struct  coap_cache_entry_t
 

Typedefs

typedef struct coap_digest_t coap_digest_t
 
typedef void coap_digest_ctx_t
 

Functions

void coap_expire_cache_entries (coap_context_t *context)
 Expire coap_cache_entry_t entries. More...
 
coap_cache_entry_tcoap_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. More...
 
coap_cache_entry_tcoap_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. More...
 
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. More...
 
coap_cache_entry_tcoap_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. More...
 
coap_digest_ctx_tcoap_digest_setup (void)
 Initialize a coap_digest. More...
 
void coap_digest_free (coap_digest_ctx_t *digest_ctx)
 Free off coap_digest_ctx_t. More...
 
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. More...
 
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. More...
 

Detailed Description

Internal API for Cache-Key and Cache-Entry support.

Typedef Documentation

◆ coap_digest_ctx_t

typedef void coap_digest_ctx_t

Definition at line 142 of file coap_cache_internal.h.

◆ coap_digest_t

typedef struct coap_digest_t coap_digest_t

Function Documentation

◆ coap_cache_get_by_key_lkd()

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.

This function returns the corresponding cache-entry or NULL if not found.

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

Parameters
contextThe context to use.
cache_keyThe cache-key to get the hashed coap-entry.
Returns
The cache-entry for cache_key or NULL if not found.

◆ coap_cache_get_by_pdu_lkd()

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.

This function returns the corresponding cache-entry or NULL if not found.

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

Parameters
sessionThe session to use.
pduThe CoAP request to search for.
session_basedCOAP_CACHE_IS_SESSION_BASED if session based cache-key to be used, else COAP_CACHE_NOT_SESSION_BASED.
Returns
The cache-entry for request or NULL if not found.

◆ coap_cache_ignore_options_lkd()

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.

Options that are defined as Non-Cache and the Observe option are always ignored.

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

Parameters
contextThe context to save the ignored options information in.
optionsThe array of options to ignore.
countThe number of options to ignore. Use 0 to reset the options matching.
Returns
1 if successful, else 0.

◆ coap_digest_final()

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.

Internal function.

Parameters
digest_ctxThe coap_digest context.
digest_bufferPointer to digest buffer to update
Returns
1 success, 0 failure.
+ Here is the caller graph for this function:

◆ coap_digest_free()

void coap_digest_free ( coap_digest_ctx_t digest_ctx)

Free off coap_digest_ctx_t.

Always done by coap_digest_final()

Internal function.

Parameters
digest_ctxThe coap_digest context.

◆ coap_digest_setup()

coap_digest_ctx_t * coap_digest_setup ( void  )

Initialize a coap_digest.

Internal function.

Returns
The digest context or NULL if failure.
+ Here is the caller graph for this function:

◆ coap_digest_update()

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.

Internal function.

Parameters
digest_ctxThe coap_digest context.
dataPointer to data.
data_lenNumber of bytes.
Returns
1 success, 0 failure.
+ Here is the caller graph for this function:

◆ coap_expire_cache_entries()

void coap_expire_cache_entries ( coap_context_t context)

Expire coap_cache_entry_t entries.

Internal function.

Parameters
contextThe context holding the coap-entries to exire
+ Here is the caller graph for this function:

◆ coap_new_cache_entry_lkd()

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.

If session_based is set, then this cache-entry will get deleted when the session is freed off. If record_pdu is set, then the copied PDU will get freed off when this cache-entry is deleted.

The cache-entry is maintained on a context hash list.

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

Parameters
sessionThe session to use to derive the context from.
pduThe pdu to use to generate the cache-key.
record_pduCOAP_CACHE_RECORD_PDU if to take a copy of the PDU for later use, else COAP_CACHE_NOT_RECORD_PDU.
session_basedCOAP_CACHE_IS_SESSION_BASED if to associate this cache-entry with the the session (which is embedded in the cache-entry), else COAP_CACHE_NOT_SESSION_BASED.
idle_timeIdle time in seconds before cache-entry is expired. If set to 0, it does not expire (but will get deleted if the session is deleted and it is session_based).
Returns
The returned cache-key or NULL if failure.