mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-03 00:15:49 +03:00
Update the Public API equivalent of the libcoap functions that need to be called when locked with a name suffix of _lkd. Move matching Public API functions out of coap_threadsafe.c to be coded just ahead of the newly renamed _lkd function. Properly define the _lkd function in the appropriate _internal.h file for documentation, removing the #defines from coap_threadsafe_internal.h. Tag all the Public API functions that have a _lkd function with COAP_API. COAP_API can then be defined as to what should be done for that function. Check libcoap library does not call the original Public API function when it should be calling the _lkd function by marking the Public API not _lkd functions as deprecated during the libcoap library build. [Done by the new COAP_API being defined as __attribute__((deprecated)).] Work in progress for all the functions that need to be multi-thread safe.
169 lines
12 KiB
C
169 lines
12 KiB
C
/*
|
|
* coap_threadsafe_internal.h -- Mapping of threadsafe functions
|
|
*
|
|
* Copyright (C) 2023-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*
|
|
* This file is part of the CoAP library libcoap. Please see README for terms
|
|
* of use.
|
|
*/
|
|
|
|
/**
|
|
* @file coap_threadsafe_internal.h
|
|
* @brief CoAP mapping of locking functions
|
|
*/
|
|
|
|
#ifndef COAP_THREADSAFE_INTERNAL_H_
|
|
#define COAP_THREADSAFE_INTERNAL_H_
|
|
|
|
#if COAP_THREAD_SAFE
|
|
|
|
/* *INDENT-OFF* */
|
|
#ifndef COAP_THREAD_IGNORE_LOCKED_MAPPING
|
|
|
|
#define coap_context_oscore_server(c,o) coap_context_oscore_server_locked(c,o)
|
|
#define coap_context_set_block_mode(c,b) coap_context_set_block_mode_locked(c,b)
|
|
#define coap_context_set_max_block_size(c,m) coap_context_set_max_block_size_locked(c,m)
|
|
#define coap_context_set_pki(c,s) coap_context_set_pki_locked(c,s)
|
|
#define coap_context_set_pki_root_cas(c,f,d) coap_context_set_pki_root_cas_locked(c,f,d)
|
|
#define coap_context_set_psk(c,h,k,l) coap_context_set_psk_locked(c,h,k,l)
|
|
#define coap_context_set_psk2(c,s) coap_context_set_psk2_locked(c,s)
|
|
#define coap_delete_oscore_recipient(s,r) coap_delete_oscore_recipient_locked(s,r)
|
|
#define coap_free_endpoint(e) coap_free_endpoint_locked(e)
|
|
#define coap_join_mcast_group_intf(c,g,i) coap_join_mcast_group_intf_locked(c,g,i)
|
|
#define coap_new_client_session(c,l,s,p) coap_new_client_session_locked(c,l,s,p)
|
|
#define coap_new_client_session_oscore(c,l,s,p,o) coap_new_client_session_oscore_locked(c,l,s,p,o)
|
|
#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)
|
|
#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)
|
|
#define coap_new_client_session_pki(c,l,s,p,d) coap_new_client_session_pki_locked(c,l,s,p,d)
|
|
#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)
|
|
#define coap_new_client_session_psk2(c,l,s,p,d) coap_new_client_session_psk2_locked(c,l,s,p,d)
|
|
#define coap_new_endpoint(c,l,t) coap_new_endpoint_locked(c,l,t)
|
|
#define coap_new_message_id(s) coap_new_message_id_locked(s)
|
|
#define coap_new_oscore_recipient(c,r) coap_new_oscore_recipient_locked(c,r)
|
|
#define coap_new_pdu(t,c,s) coap_new_pdu_locked(t,c,s)
|
|
#define coap_persist_observe_add(c,p,l,a,r,o) coap_persist_observe_add_locked(c,p,l,a,r,o)
|
|
#define coap_persist_startup(c,d,o,m,s) coap_persist_startup_locked(c,d,o,m,s)
|
|
#define coap_persist_stop(c) coap_persist_stop_locked(c)
|
|
#define coap_pdu_duplicate(o,s,l,t,d) coap_pdu_duplicate_locked(o,s,l,t,d)
|
|
#define coap_register_option(c,t) coap_register_option_locked(c,t)
|
|
#define coap_send(s,p) coap_send_locked(s,p)
|
|
#define coap_send_ack(s,r) coap_send_ack_locked(s,r)
|
|
#define coap_send_error(s,r,c,o) coap_send_error_locked(s,r,c,o)
|
|
#define coap_send_message_type(s,r,t) coap_send_message_type_locked(s,r,t)
|
|
#define coap_send_rst(s,r) coap_send_rst_locked(s,r)
|
|
#define coap_session_max_pdu_size(s) coap_session_max_pdu_size_locked(s)
|
|
#define coap_session_reference(s) coap_session_reference_locked(s)
|
|
#define coap_session_release(s) coap_session_release_locked(s)
|
|
#define coap_session_disconnected(s,r) coap_session_disconnected_locked(s,r)
|
|
#define coap_session_send_ping(s) coap_session_send_ping_locked(s)
|
|
|
|
#endif /* ! COAP_THREAD_IGNORE_LOCKED_MAPPING */
|
|
|
|
/* Locked equivalend functions */
|
|
|
|
int coap_context_oscore_server_locked(coap_context_t *context,
|
|
coap_oscore_conf_t *oscore_conf);
|
|
void coap_context_set_block_mode_locked(coap_context_t *context,
|
|
uint32_t block_mode);
|
|
int coap_context_set_max_block_size_locked(coap_context_t *context,
|
|
size_t max_block_size);
|
|
int coap_context_set_pki_locked(coap_context_t *ctx,
|
|
const coap_dtls_pki_t *setup_data);
|
|
int coap_context_set_pki_root_cas_locked(coap_context_t *ctx,
|
|
const char *ca_file, const char *ca_dir);
|
|
int coap_context_set_psk_locked(coap_context_t *ctx, const char *hint,
|
|
const uint8_t *key, size_t key_len);
|
|
int coap_context_set_psk2_locked(coap_context_t *ctx,
|
|
coap_dtls_spsk_t *setup_data);
|
|
int coap_delete_oscore_recipient_locked(coap_context_t *context,
|
|
coap_bin_const_t *recipient_id);
|
|
void coap_free_endpoint_locked(coap_endpoint_t *ep);
|
|
int coap_join_mcast_group_intf_locked(coap_context_t *ctx, const char *group_name,
|
|
const char *ifname);
|
|
coap_subscription_t *coap_persist_observe_add_locked(coap_context_t *context,
|
|
coap_proto_t e_proto,
|
|
const coap_address_t *e_listen_addr,
|
|
const coap_addr_tuple_t *s_addr_info,
|
|
const coap_bin_const_t *raw_packet,
|
|
const coap_bin_const_t *oscore_info);
|
|
int coap_persist_startup_locked(coap_context_t *context,
|
|
const char *dyn_resource_save_file,
|
|
const char *observe_save_file,
|
|
const char *obs_cnt_save_file,
|
|
uint32_t save_freq);
|
|
void coap_persist_stop_locked(coap_context_t *context);
|
|
size_t coap_session_max_pdu_size_locked(const coap_session_t *session);
|
|
coap_session_t *coap_new_client_session_locked(coap_context_t *ctx,
|
|
const coap_address_t *local_if,
|
|
const coap_address_t *server,
|
|
coap_proto_t proto);
|
|
coap_session_t *coap_new_client_session_oscore_locked(coap_context_t *ctx,
|
|
const coap_address_t *local_if,
|
|
const coap_address_t *server,
|
|
coap_proto_t proto,
|
|
coap_oscore_conf_t *oscore_conf);
|
|
coap_session_t *coap_new_client_session_oscore_pki_locked(coap_context_t *ctx,
|
|
const coap_address_t *local_if,
|
|
const coap_address_t *server,
|
|
coap_proto_t proto,
|
|
coap_dtls_pki_t *pki_data,
|
|
coap_oscore_conf_t *oscore_conf);
|
|
coap_session_t *coap_new_client_session_oscore_psk_locked(coap_context_t *ctx,
|
|
const coap_address_t *local_if,
|
|
const coap_address_t *server,
|
|
coap_proto_t proto,
|
|
coap_dtls_cpsk_t *psk_data,
|
|
coap_oscore_conf_t *oscore_conf);
|
|
coap_session_t *coap_new_client_session_pki_locked(coap_context_t *ctx,
|
|
const coap_address_t *local_if,
|
|
const coap_address_t *server,
|
|
coap_proto_t proto,
|
|
coap_dtls_pki_t *setup_data);
|
|
coap_session_t *coap_new_client_session_psk_locked(coap_context_t *ctx,
|
|
const coap_address_t *local_if,
|
|
const coap_address_t *server,
|
|
coap_proto_t proto, const char *identity,
|
|
const uint8_t *key, unsigned key_len);
|
|
coap_session_t *coap_new_client_session_psk2_locked(coap_context_t *ctx,
|
|
const coap_address_t *local_if,
|
|
const coap_address_t *server,
|
|
coap_proto_t proto,
|
|
coap_dtls_cpsk_t *setup_data);
|
|
coap_endpoint_t *coap_new_endpoint_locked(coap_context_t *context,
|
|
const coap_address_t *listen_addr,
|
|
coap_proto_t proto);
|
|
uint16_t coap_new_message_id_locked(coap_session_t *session);
|
|
int coap_new_oscore_recipient_locked(coap_context_t *context,
|
|
coap_bin_const_t *recipient_id);
|
|
coap_pdu_t *coap_new_pdu_locked(coap_pdu_type_t type, coap_pdu_code_t code,
|
|
coap_session_t *session);
|
|
coap_pdu_t *coap_pdu_duplicate_locked(const coap_pdu_t *old_pdu,
|
|
coap_session_t *session,
|
|
size_t token_length,
|
|
const uint8_t *token,
|
|
coap_opt_filter_t *drop_options);
|
|
void coap_register_option_locked(coap_context_t *ctx, uint16_t type);
|
|
int coap_resource_set_dirty_locked(coap_resource_t *r,
|
|
const coap_string_t *query);
|
|
coap_mid_t coap_send_locked(coap_session_t *session, coap_pdu_t *pdu);
|
|
coap_mid_t coap_send_ack_locked(coap_session_t *session, const coap_pdu_t *request);
|
|
coap_mid_t coap_send_error_locked(coap_session_t *session, const coap_pdu_t *request,
|
|
coap_pdu_code_t code, coap_opt_filter_t *opts);
|
|
coap_mid_t coap_send_message_type_locked(coap_session_t *session,
|
|
const coap_pdu_t *request,
|
|
coap_pdu_type_t type);
|
|
coap_mid_t coap_send_rst_locked(coap_session_t *session, const coap_pdu_t *request);
|
|
void coap_session_disconnected_locked(coap_session_t *session,
|
|
coap_nack_reason_t reason);
|
|
coap_session_t *coap_session_reference_locked(coap_session_t *session);
|
|
void coap_session_release_locked(coap_session_t *session);
|
|
coap_mid_t coap_session_send_ping_locked(coap_session_t *session);
|
|
|
|
/* *INDENT-ON* */
|
|
|
|
#endif /* COAP_THREAD_SAFE */
|
|
|
|
#endif /* COAP_THREADSAFE_INTERNAL_H_ */
|