coap_cache.h
Go to the documentation of this file.
/* coap_cache.h -- Caching of CoAP requests
*
* Copyright (C) 2020 Olaf Bergmann <bergmann@tzi.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* This file is part of the CoAP library libcoap. Please see
* README for terms of use.
*/
#ifndef COAP_CACHE_H_
#define COAP_CACHE_H_
#include "coap_forward_decls.h"
typedef void (*coap_cache_app_data_free_callback_t)(void *data);
typedef enum coap_cache_session_based_t {
COAP_CACHE_NOT_SESSION_BASED,
COAP_CACHE_IS_SESSION_BASED
} coap_cache_session_based_t;
typedef enum coap_cache_record_pdu_t {
COAP_CACHE_NOT_RECORD_PDU,
COAP_CACHE_RECORD_PDU
} coap_cache_record_pdu_t;
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);
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);
void coap_delete_cache_key(coap_cache_key_t *cache_key);
int coap_cache_ignore_options(coap_context_t *context,
const uint16_t *options, size_t count);
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);
void coap_delete_cache_entry(coap_context_t *context,
coap_cache_entry_t *cache_entry);
coap_cache_entry_t *coap_cache_get_by_key(coap_context_t *context,
const coap_cache_key_t *cache_key);
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);
const coap_pdu_t *coap_cache_get_pdu(const coap_cache_entry_t *cache_entry);
void coap_cache_set_app_data(coap_cache_entry_t *cache_entry, void *data,
coap_cache_app_data_free_callback_t callback);
void *coap_cache_get_app_data(const coap_cache_entry_t *cache_entry);
#endif /* COAP_CACHE_H */
coap_forward_decls.h
COAP forward definitions.
coap_delete_cache_entry
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...
Definition: coap_cache.c:220
coap_cache_get_by_pdu
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.
Definition: coap_cache.c:201
coap_cache_get_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.
Definition: coap_cache.c:238
coap_delete_cache_key
void coap_delete_cache_key(coap_cache_key_t *cache_key)
Delete the cache-key.
Definition: coap_cache.c:138
coap_cache_record_pdu_t
coap_cache_record_pdu_t
Definition: coap_cache.h:40
coap_cache_derive_key_w_ignore
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.
Definition: coap_cache.c:68
coap_cache_app_data_free_callback_t
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.
Definition: coap_cache.h:33
coap_cache_derive_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.
Definition: coap_cache.c:129
coap_cache_get_by_key
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.
Definition: coap_cache.c:186
coap_cache_ignore_options
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.
Definition: coap_cache.c:42
coap_new_cache_entry
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.
Definition: coap_cache.c:143
coap_cache_get_app_data
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...
Definition: coap_cache.c:251
coap_cache_set_app_data
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.
Definition: coap_cache.c:243
coap_cache_session_based_t
coap_cache_session_based_t
Definition: coap_cache.h:35
COAP_CACHE_RECORD_PDU
@ COAP_CACHE_RECORD_PDU
Definition: coap_cache.h:42
COAP_CACHE_NOT_RECORD_PDU
@ COAP_CACHE_NOT_RECORD_PDU
Definition: coap_cache.h:41
COAP_CACHE_NOT_SESSION_BASED
@ COAP_CACHE_NOT_SESSION_BASED
Definition: coap_cache.h:36
COAP_CACHE_IS_SESSION_BASED
@ COAP_CACHE_IS_SESSION_BASED
Definition: coap_cache.h:37
coap_cache_entry_t
Definition: coap_cache_internal.h:38
coap_cache_key_t
Definition: coap_cache_internal.h:34
coap_context_t
The CoAP stack's global state is stored in a coap_context_t object.
Definition: coap_net_internal.h:45
coap_pdu_t
structure for CoAP PDUs token, if any, follows the fixed size header, then options until payload mark...
Definition: coap_pdu_internal.h:94
coap_session_t
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
Definition: coap_session_internal.h:48