Loading...
Searching...
No Matches
Cache Support
Libcoap Internal API

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.
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_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`.
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_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.
coap_digest_ctx_t * | coap_digest_setup (void)
| Initialize a coap_digest.
void | coap_digest_free (coap_digest_ctx_t *digest_ctx)
| Free off coap_digest_ctx_t.
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.
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`.

## 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

  context | The context to use.
  cache_key | The 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

  session | The session to use.
  pdu | The CoAP request to search for.
  session_based | COAP_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

  context | The context to save the ignored options information in.
  options | The array of options to ignore.
  count | The 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_ctx | The coap_digest context.
  digest_buffer | Pointer 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_ctx | The 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_ctx | The coap_digest context.
  data | Pointer to data.
  data_len | Number 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

  context | The 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

  session | The session to use to derive the context from.
  pdu | The pdu to use to generate the cache-key.
  record_pdu | COAP_CACHE_RECORD_PDU if to take a copy of the PDU for later use, else COAP_CACHE_NOT_RECORD_PDU.
  session_based | COAP_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_time | Idle 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.