libcoap 4.3.4-develop-9f1418e
coap_threadsafe_internal.h
Go to the documentation of this file.
1/*
2 * coap_threadsafe_internal.h -- Mapping of threadsafe functions
3 *
4 * Copyright (C) 2023-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
5 *
6 * SPDX-License-Identifier: BSD-2-Clause
7 *
8 * This file is part of the CoAP library libcoap. Please see README for terms
9 * of use.
10 */
11
17#ifndef COAP_THREADSAFE_INTERNAL_H_
18#define COAP_THREADSAFE_INTERNAL_H_
19
20#if COAP_THREAD_SAFE
21
22/* *INDENT-OFF* */
23#ifndef COAP_THREAD_IGNORE_LOCKED_MAPPING
24
25#define coap_add_data_large_request(a,b,c,d,e,f) coap_add_data_large_request_locked(a,b,c,d,e,f)
26#define coap_add_data_large_response(a,b,c,d,e,f,g,h,i,j,k,l) coap_add_data_large_response_locked(a,b,c,d,e,f,g,h,i,j,k,l)
27#define coap_add_resource(c,r) coap_add_resource_locked(c,r)
28#define coap_async_trigger(a) coap_async_trigger_locked(a)
29#define coap_async_set_delay(a,d) coap_async_set_delay_locked(a,d)
30#define coap_cache_get_by_key(s,c) coap_cache_get_by_key_locked(s,c)
31#define coap_cache_get_by_pdu(s,r,b) coap_cache_get_by_pdu_locked(s,r,b)
32#define coap_cache_ignore_options(c,o,n) coap_cache_ignore_options_locked(c,o,n)
33#define coap_can_exit(c) coap_can_exit_locked(c)
34#define coap_cancel_observe(s,t,v) coap_cancel_observe_locked(s,t,v)
35#define coap_check_notify(s) coap_check_notify_locked(s)
36#define coap_context_oscore_server(c,o) coap_context_oscore_server_locked(c,o)
37#define coap_context_set_block_mode(c,b) coap_context_set_block_mode_locked(c,b)
38#define coap_context_set_max_block_size(c,m) coap_context_set_max_block_size_locked(c,m)
39#define coap_context_set_pki(c,s) coap_context_set_pki_locked(c,s)
40#define coap_context_set_pki_root_cas(c,f,d) coap_context_set_pki_root_cas_locked(c,f,d)
41#define coap_context_set_psk(c,h,k,l) coap_context_set_psk_locked(c,h,k,l)
42#define coap_context_set_psk2(c,s) coap_context_set_psk2_locked(c,s)
43#define coap_find_async(s,t) coap_find_async_locked(s,t)
44#define coap_delete_oscore_recipient(s,r) coap_delete_oscore_recipient_locked(s,r)
45#define coap_delete_resource(c,r) coap_delete_resource_locked(c,r)
46#define coap_free_context(c) coap_free_context_locked(c)
47#define coap_free_endpoint(e) coap_free_endpoint_locked(e)
48#define coap_get_resource_from_uri_path(c,u) coap_get_resource_from_uri_path_locked(c,u)
49#define coap_io_do_epoll(c,e,n) coap_io_do_epoll_locked(c,e,n)
50#define coap_io_do_io(c,n) coap_io_do_io_locked(c,n)
51#define coap_io_pending(c) coap_io_pending_locked(c)
52#define coap_io_prepare_epoll(c,n) coap_io_prepare_epoll_locked(c,n)
53#define coap_io_prepare_io(c,s,m,n,t) coap_io_prepare_io_locked(c,s,m,n,t)
54#define coap_io_process(s,t) coap_io_process_locked(s,t)
55#ifdef HAVE_SYS_SELECT_H
56#define coap_io_process_with_fds(s,t,n,r,w,e) coap_io_process_with_fds_locked(s,t,n,r,w,e)
57#endif /* HAVE_SYS_SELECT_H */
58#define coap_join_mcast_group_intf(c,g,i) coap_join_mcast_group_intf_locked(c,g,i)
59#define coap_new_cache_entry(s,p,r,b,i) coap_new_cache_entry_locked(s,p,r,b,i)
60#define coap_new_client_session(c,l,s,p) coap_new_client_session_locked(c,l,s,p)
61#define coap_new_client_session_oscore(c,l,s,p,o) coap_new_client_session_oscore_locked(c,l,s,p,o)
62#define coap_new_client_session_oscore_pki(c,l,s,p,d,o) coap_new_client_session_oscore_pki_locked(c,l,s,p,d,o)
63#define coap_new_client_session_oscore_psk(c,l,s,p,d,o) coap_new_client_session_oscore_psk_locked(c,l,s,p,d,o)
64#define coap_new_client_session_pki(c,l,s,p,d) coap_new_client_session_pki_locked(c,l,s,p,d)
65#define coap_new_client_session_psk(c,l,s,p,i,k,m) coap_new_client_session_psk_locked(c,l,s,p,i,k,m)
66#define coap_new_client_session_psk2(c,l,s,p,d) coap_new_client_session_psk2_locked(c,l,s,p,d)
67#define coap_new_endpoint(c,l,t) coap_new_endpoint_locked(c,l,t)
68#define coap_new_message_id(s) coap_new_message_id_locked(s)
69#define coap_new_oscore_recipient(c,r) coap_new_oscore_recipient_locked(c,r)
70#define coap_new_pdu(t,c,s) coap_new_pdu_locked(t,c,s)
71#define coap_persist_observe_add(c,p,l,a,r,o) coap_persist_observe_add_locked(c,p,l,a,r,o)
72#define coap_persist_startup(c,d,o,m,s) coap_persist_startup_locked(c,d,o,m,s)
73#define coap_persist_stop(c) coap_persist_stop_locked(c)
74#define coap_pdu_duplicate(o,s,l,t,d) coap_pdu_duplicate_locked(o,s,l,t,d)
75#define coap_register_async(s,r,d) coap_register_async_locked(s,r,d)
76#define coap_register_option(c,t) coap_register_option_locked(c,t)
77#define coap_resource_notify_observers(r,q) coap_resource_notify_observers_locked(r,q)
78#define coap_resource_set_dirty(r,q) coap_resource_set_dirty_locked(r,q)
79#define coap_send(s,p) coap_send_locked(s,p)
80#define coap_send_ack(s,r) coap_send_ack_locked(s,r)
81#define coap_send_error(s,r,c,o) coap_send_error_locked(s,r,c,o)
82#define coap_send_message_type(s,r,t) coap_send_message_type_locked(s,r,t)
83#define coap_send_rst(s,r) coap_send_rst_locked(s,r)
84#define coap_session_max_pdu_size(s) coap_session_max_pdu_size_locked(s)
85#define coap_session_reference(s) coap_session_reference_locked(s)
86#define coap_session_release(s) coap_session_release_locked(s)
87#define coap_session_disconnected(s,r) coap_session_disconnected_locked(s,r)
88#define coap_session_send_ping(s) coap_session_send_ping_locked(s)
89
90#endif /* ! COAP_THREAD_IGNORE_LOCKED_MAPPING */
91
92/* Locked equivalend functions */
93
94int coap_add_data_large_request_locked(coap_session_t *session,
95 coap_pdu_t *pdu,
96 size_t length,
97 const uint8_t *data,
98 coap_release_large_data_t release_func,
99 void *app_ptr);
100int coap_add_data_large_response_locked(coap_resource_t *resource,
101 coap_session_t *session,
102 const coap_pdu_t *request,
103 coap_pdu_t *response,
104 const coap_string_t *query,
105 uint16_t media_type,
106 int maxage,
107 uint64_t etag,
108 size_t length,
109 const uint8_t *data,
110 coap_release_large_data_t release_func,
111 void *app_ptr);
112void coap_add_resource_locked(coap_context_t *context, coap_resource_t *resource);
113void coap_async_trigger_locked(coap_async_t *async);
114void coap_async_set_delay_locked(coap_async_t *async, coap_tick_t delay);
115coap_cache_entry_t *coap_cache_get_by_key_locked(coap_context_t *context,
116 const coap_cache_key_t *cache_key);
117coap_cache_entry_t *coap_cache_get_by_pdu_locked(coap_session_t *session,
118 const coap_pdu_t *request,
119 coap_cache_session_based_t session_based);
120int coap_cache_ignore_options_locked(coap_context_t *ctx,
121 const uint16_t *options,
122 size_t count);
123int coap_can_exit_locked(coap_context_t *context);
124int coap_cancel_observe_locked(coap_session_t *session, coap_binary_t *token,
125 coap_pdu_type_t type);
126void coap_check_notify_locked(coap_context_t *context);
127int coap_context_oscore_server_locked(coap_context_t *context,
128 coap_oscore_conf_t *oscore_conf);
129void coap_context_set_block_mode_locked(coap_context_t *context,
130 uint32_t block_mode);
131int coap_context_set_max_block_size_locked(coap_context_t *context,
132 size_t max_block_size);
133int coap_context_set_pki_locked(coap_context_t *ctx,
134 const coap_dtls_pki_t *setup_data);
135int coap_context_set_pki_root_cas_locked(coap_context_t *ctx,
136 const char *ca_file, const char *ca_dir);
137int coap_context_set_psk_locked(coap_context_t *ctx, const char *hint,
138 const uint8_t *key, size_t key_len);
139int coap_context_set_psk2_locked(coap_context_t *ctx,
140 coap_dtls_spsk_t *setup_data);
141int coap_delete_oscore_recipient_locked(coap_context_t *context,
142 coap_bin_const_t *recipient_id);
143int coap_delete_resource_locked(coap_context_t *context, coap_resource_t *resource);
144coap_async_t *coap_find_async_locked(coap_session_t *session, coap_bin_const_t token);
145void coap_free_context_locked(coap_context_t *context);
146void coap_free_endpoint_locked(coap_endpoint_t *ep);
147coap_resource_t *coap_get_resource_from_uri_path_locked(coap_context_t *context,
148 coap_str_const_t *uri_path);
149void coap_io_do_epoll_locked(coap_context_t *ctx, struct epoll_event *events,
150 size_t nevents);
151void coap_io_do_io_locked(coap_context_t *ctx, coap_tick_t now);
152int coap_io_pending_locked(coap_context_t *context);
153unsigned int coap_io_prepare_epoll_locked(coap_context_t *ctx, coap_tick_t now);
154unsigned int coap_io_prepare_io_locked(coap_context_t *ctx,
155 coap_socket_t *sockets[],
156 unsigned int max_sockets,
157 unsigned int *num_sockets,
158 coap_tick_t now);
159int coap_join_mcast_group_intf_locked(coap_context_t *ctx, const char *group_name,
160 const char *ifname);
161coap_subscription_t *coap_persist_observe_add_locked(coap_context_t *context,
162 coap_proto_t e_proto,
163 const coap_address_t *e_listen_addr,
164 const coap_addr_tuple_t *s_addr_info,
165 const coap_bin_const_t *raw_packet,
166 const coap_bin_const_t *oscore_info);
167int coap_persist_startup_locked(coap_context_t *context,
168 const char *dyn_resource_save_file,
169 const char *observe_save_file,
170 const char *obs_cnt_save_file,
171 uint32_t save_freq);
172void coap_persist_stop_locked(coap_context_t *context);
173int coap_io_process_locked(coap_context_t *ctx, uint32_t timeout_ms);
174#ifdef HAVE_SYS_SELECT_H
175int coap_io_process_with_fds_locked(coap_context_t *ctx, uint32_t timeout_ms,
176 int nfds, fd_set *readfds, fd_set *writefds,
177 fd_set *exceptfds);
178#endif /* HAVE_SYS_SELECT_H */
179coap_async_t *coap_register_async_locked(coap_session_t *session, const coap_pdu_t *request,
180 coap_tick_t delay);
181size_t coap_session_max_pdu_size_locked(const coap_session_t *session);
182coap_cache_entry_t *coap_new_cache_entry_locked(coap_session_t *session, const coap_pdu_t *pdu,
183 coap_cache_record_pdu_t record_pdu,
184 coap_cache_session_based_t session_based,
185 unsigned int idle_timeout);
186coap_session_t *coap_new_client_session_locked(coap_context_t *ctx,
187 const coap_address_t *local_if,
188 const coap_address_t *server,
189 coap_proto_t proto);
190coap_session_t *coap_new_client_session_oscore_locked(coap_context_t *ctx,
191 const coap_address_t *local_if,
192 const coap_address_t *server,
193 coap_proto_t proto,
194 coap_oscore_conf_t *oscore_conf);
195coap_session_t *coap_new_client_session_oscore_pki_locked(coap_context_t *ctx,
196 const coap_address_t *local_if,
197 const coap_address_t *server,
198 coap_proto_t proto,
199 coap_dtls_pki_t *pki_data,
200 coap_oscore_conf_t *oscore_conf);
201coap_session_t *coap_new_client_session_oscore_psk_locked(coap_context_t *ctx,
202 const coap_address_t *local_if,
203 const coap_address_t *server,
204 coap_proto_t proto,
205 coap_dtls_cpsk_t *psk_data,
206 coap_oscore_conf_t *oscore_conf);
207coap_session_t *coap_new_client_session_pki_locked(coap_context_t *ctx,
208 const coap_address_t *local_if,
209 const coap_address_t *server,
210 coap_proto_t proto,
211 coap_dtls_pki_t *setup_data);
212coap_session_t *coap_new_client_session_psk_locked(coap_context_t *ctx,
213 const coap_address_t *local_if,
214 const coap_address_t *server,
215 coap_proto_t proto, const char *identity,
216 const uint8_t *key, unsigned key_len);
217coap_session_t *coap_new_client_session_psk2_locked(coap_context_t *ctx,
218 const coap_address_t *local_if,
219 const coap_address_t *server,
220 coap_proto_t proto,
221 coap_dtls_cpsk_t *setup_data);
222coap_endpoint_t *coap_new_endpoint_locked(coap_context_t *context,
223 const coap_address_t *listen_addr,
224 coap_proto_t proto);
225uint16_t coap_new_message_id_locked(coap_session_t *session);
226int coap_new_oscore_recipient_locked(coap_context_t *context,
227 coap_bin_const_t *recipient_id);
228coap_pdu_t *coap_new_pdu_locked(coap_pdu_type_t type, coap_pdu_code_t code,
229 coap_session_t *session);
230coap_pdu_t *coap_pdu_duplicate_locked(const coap_pdu_t *old_pdu,
231 coap_session_t *session,
232 size_t token_length,
233 const uint8_t *token,
234 coap_opt_filter_t *drop_options);
235void coap_register_option_locked(coap_context_t *ctx, uint16_t type);
236int coap_resource_notify_observers_locked(coap_resource_t *r,
237 const coap_string_t *query);
238int coap_resource_set_dirty_locked(coap_resource_t *r,
239 const coap_string_t *query);
240coap_mid_t coap_send_locked(coap_session_t *session, coap_pdu_t *pdu);
241coap_mid_t coap_send_ack_locked(coap_session_t *session, const coap_pdu_t *request);
242coap_mid_t coap_send_error_locked(coap_session_t *session, const coap_pdu_t *request,
244coap_mid_t coap_send_message_type_locked(coap_session_t *session,
245 const coap_pdu_t *request,
246 coap_pdu_type_t type);
247coap_mid_t coap_send_rst_locked(coap_session_t *session, const coap_pdu_t *request);
248void coap_session_disconnected_locked(coap_session_t *session,
249 coap_nack_reason_t reason);
250coap_session_t *coap_session_reference_locked(coap_session_t *session);
251void coap_session_release_locked(coap_session_t *session);
252coap_mid_t coap_session_send_ping_locked(coap_session_t *session);
253
254/* *INDENT-ON* */
255
256#endif /* COAP_THREAD_SAFE */
257
258#endif /* COAP_THREADSAFE_INTERNAL_H_ */
struct coap_async_t coap_async_t
Async Entry information.
coap_nack_reason_t
Definition: coap_io.h:69
void(* coap_release_large_data_t)(coap_session_t *session, void *app_ptr)
Callback handler for de-allocating the data based on app_ptr provided to coap_add_data_large_*() func...
Definition: coap_block.h:292
coap_cache_record_pdu_t
Definition: coap_cache.h:42
coap_cache_session_based_t
Definition: coap_cache.h:37
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
Definition: coap_time.h:143
int coap_mid_t
coap_mid_t is used to store the CoAP Message ID of a CoAP PDU.
Definition: coap_pdu.h:263
coap_proto_t
CoAP protocol types.
Definition: coap_pdu.h:312
coap_pdu_code_t
Set of codes available for a PDU.
Definition: coap_pdu.h:326
coap_pdu_type_t
CoAP PDU message type definitions.
Definition: coap_pdu.h:68
Multi-purpose address abstraction.
Definition: coap_address.h:148
CoAP binary data definition with const data.
Definition: coap_str.h:64
CoAP binary data definition.
Definition: coap_str.h:56
The CoAP stack's global state is stored in a coap_context_t object.
The structure used for defining the Client PSK setup data to be used.
Definition: coap_dtls.h:381
The structure used for defining the PKI setup data to be used.
Definition: coap_dtls.h:287
The structure used for defining the Server PSK setup data to be used.
Definition: coap_dtls.h:468
Abstraction of virtual endpoint that can be attached to coap_context_t.
The structure used to hold the OSCORE configuration information.
structure for CoAP PDUs
Abstraction of resource that can be attached to coap_context_t.
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
CoAP string data definition with const data.
Definition: coap_str.h:46
CoAP string data definition.
Definition: coap_str.h:38
Number of notifications that may be sent non-confirmable before a confirmable message is sent to dete...