22 #ifndef NET_NANOCOAP_CACHE_H
23 #define NET_NANOCOAP_CACHE_H
40 #ifndef CONFIG_NANOCOAP_CACHE_ENTRIES
41 #define CONFIG_NANOCOAP_CACHE_ENTRIES (8)
47 #ifndef CONFIG_NANOCOAP_CACHE_KEY_LENGTH
48 #define CONFIG_NANOCOAP_CACHE_KEY_LENGTH (8)
54 #ifndef CONFIG_NANOCOAP_CACHE_RESPONSE_SIZE
55 #define CONFIG_NANOCOAP_CACHE_RESPONSE_SIZE (128)
85 #if IS_USED(MODULE_GCOAP) || defined(DOXYGEN)
117 #if IS_USED(MODULE_NANOCOAP_CACHE)
181 unsigned request_method,
POSIX.1-2008 compliant version of the assert macro.
size_t nanocoap_cache_used_count(void)
Returns the number of cached entries.
nanocoap_cache_entry_t * nanocoap_cache_add_by_req(const coap_pkt_t *req, const coap_pkt_t *resp, size_t resp_len)
Creates a new or gets an existing cache entry using the request packet.
int(* nanocoap_cache_update_strategy_t)(clist_node_t *node)
Typedef for the cache update strategy on element access.
void nanocoap_cache_key_blockreq_options_generate(const coap_pkt_t *req, void *cache_key)
Generates a cache key based on only the options in req without any of the blockwise options included ...
nanocoap_cache_entry_t * nanocoap_cache_request_lookup(const coap_pkt_t *req)
Performs a cache lookup based on the req.
int(* nanocoap_cache_replacement_strategy_t)(void)
Typedef for the cache replacement strategy on full cache list.
int nanocoap_cache_del(const nanocoap_cache_entry_t *ce)
Deletes the provided cache entry ce.
void nanocoap_cache_key_options_generate(const coap_pkt_t *req, void *cache_key)
Generates a cache key based on only the options in req.
#define CONFIG_NANOCOAP_CACHE_RESPONSE_SIZE
Size of the buffer to store responses in the cache.
size_t nanocoap_cache_free_count(void)
Returns the number of unused cache entries.
nanocoap_cache_entry_t * nanocoap_cache_add_by_key(const uint8_t *cache_key, unsigned request_method, const coap_pkt_t *resp, size_t resp_len)
Creates a new or gets an existing cache entry using the cache key.
void nanocoap_cache_key_generate(const coap_pkt_t *req, uint8_t *cache_key)
Generates a cache key based on the request req.
ssize_t nanocoap_cache_key_compare(uint8_t *cache_key1, uint8_t *cache_key2)
Compares two cache keys.
static void nanocoap_cache_init(void)
Initializes the internal state of the nanocoap cache.
nanocoap_cache_entry_t * nanocoap_cache_process(const uint8_t *cache_key, unsigned request_method, const coap_pkt_t *resp, size_t resp_len)
Determines if a response is cacheable and modifies the cache as reflected in RFC7252,...
nanocoap_cache_entry_t * nanocoap_cache_key_lookup(const uint8_t *cache_key)
Performs a cache lookup based on the cache key of a request.
static bool nanocoap_cache_entry_is_stale(const nanocoap_cache_entry_t *ce, uint32_t now)
Check if the Max-Age of a cache entry has passed.
#define CONFIG_NANOCOAP_CACHE_KEY_LENGTH
The length of the cache key in bytes.
time_point now()
Returns the current time saved in a time point.
Header definitions for the SHA256 hash function.
CoAP PDU parsing context structure.
Cache container that holds a coap_pkt_t struct.
uint8_t request_method
the method of the initial request
coap_pkt_t response_pkt
packet representation of the response
uint32_t max_age
absolute system time in seconds until which this cache entry is considered valid.
size_t response_len
length of the message in response
clist_node_t node
needed for clist_t, must be the first struct member!
bool truncated
the cached response is truncated