libcoap 4.3.5-develop-93694e6
Loading...
Searching...
No Matches
coap_cache.h
Go to the documentation of this file.
1/* coap_cache.h -- Caching of CoAP requests
2*
3* Copyright (C) 2020-2026 Olaf Bergmann <bergmann@tzi.org>
4*
5 * SPDX-License-Identifier: BSD-2-Clause
6 *
7* This file is part of the CoAP library libcoap. Please see
8* README for terms of use.
9*/
10
15
16#ifndef COAP_CACHE_H_
17#define COAP_CACHE_H_
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
30
37typedef void (*coap_cache_app_data_free_callback_t)(void *data);
38
44
49
75 const coap_pdu_t *pdu,
76 coap_cache_session_based_t session_based);
77
105 const coap_pdu_t *pdu,
106 coap_cache_session_based_t session_based,
107 const uint16_t *ignore_options,
108 size_t ignore_count);
109
116
130 const uint16_t *options, size_t count);
131
156 const coap_pdu_t *pdu,
157 coap_cache_record_pdu_t record_pdu,
158 coap_cache_session_based_t session_based,
159 unsigned int idle_time);
160
169 coap_cache_entry_t *cache_entry);
170
182 const coap_cache_key_t *cache_key);
183
197 const coap_pdu_t *pdu,
198 coap_cache_session_based_t session_based);
199
209
224 void *data,
226
244 void *data,
246
257
259
260#ifdef __cplusplus
261}
262#endif
263
264#endif /* COAP_CACHE_H */
struct coap_cache_key_t coap_cache_key_t
struct coap_cache_entry_t coap_cache_entry_t
#define COAP_API
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...
COAP_API 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.
void coap_delete_cache_key(coap_cache_key_t *cache_key)
Delete the cache-key.
COAP_API 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.
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_record_pdu_t
Definition coap_cache.h:45
COAP_API 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.
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:37
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.
COAP_DEPRECATED void coap_cache_set_app_data(coap_cache_entry_t *cache_entry, void *data, coap_app_data_free_callback_t callback)
Stores data with the given cache entry.
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.
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...
COAP_API 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.
COAP_API void * coap_cache_set_app_data2(coap_cache_entry_t *cache_entry, void *data, coap_app_data_free_callback_t callback)
Stores data with the given cache_entry, returning the previously stored value or NULL.
coap_cache_session_based_t
Definition coap_cache.h:39
@ COAP_CACHE_RECORD_PDU
Definition coap_cache.h:47
@ COAP_CACHE_NOT_RECORD_PDU
Definition coap_cache.h:46
@ COAP_CACHE_IS_SESSION_BASED_NO_DATA
Definition coap_cache.h:42
@ COAP_CACHE_NOT_SESSION_BASED
Definition coap_cache.h:40
@ COAP_CACHE_IS_SESSION_BASED
Definition coap_cache.h:41
void(* coap_app_data_free_callback_t)(void *data)
Callback to free off the app data when the entry is being deleted / freed off.
#define COAP_DEPRECATED
Definition libcoap.h:66
The CoAP stack's global state is stored in a coap_context_t object.
structure for CoAP PDUs
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...