From cbfb491b1dc5fb23106fbae0dc495fa896ed64fb Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Mon, 20 May 2024 10:28:20 +0100 Subject: [PATCH] coap_libcoap_build.h: Add in specific library build header Gives the ability to add in additional library build checks through the use of #define etc. that is not available to applications or other host o/s support. Preparatory work for further locking checks. --- Makefile.am | 1 + include/coap3/coap_libcoap_build.h | 34 ++++++++++++++++++++++++++++++ src/coap_address.c | 2 +- src/coap_asn1.c | 2 +- src/coap_async.c | 2 +- src/coap_block.c | 2 +- src/coap_cache.c | 2 +- src/coap_debug.c | 2 +- src/coap_dtls.c | 2 +- src/coap_encode.c | 2 +- src/coap_event.c | 2 +- src/coap_gnutls.c | 2 +- src/coap_hashkey.c | 2 +- src/coap_io.c | 2 +- src/coap_io_contiki.c | 2 +- src/coap_io_lwip.c | 2 +- src/coap_io_riot.c | 2 +- src/coap_layers.c | 2 +- src/coap_mbedtls.c | 2 +- src/coap_mem.c | 2 +- src/coap_net.c | 2 +- src/coap_netif.c | 2 +- src/coap_notls.c | 2 +- src/coap_openssl.c | 2 +- src/coap_option.c | 2 +- src/coap_oscore.c | 2 +- src/coap_pdu.c | 2 +- src/coap_prng.c | 2 +- src/coap_resource.c | 2 +- src/coap_session.c | 2 +- src/coap_sha1.c | 2 +- src/coap_str.c | 2 +- src/coap_subscribe.c | 2 +- src/coap_tcp.c | 2 +- src/coap_time.c | 2 +- src/coap_tinydtls.c | 2 +- src/coap_uri.c | 2 +- src/coap_wolfssl.c | 2 +- src/coap_ws.c | 2 +- src/oscore/oscore.c | 2 +- src/oscore/oscore_cbor.c | 2 +- src/oscore/oscore_context.c | 2 +- src/oscore/oscore_cose.c | 2 +- src/oscore/oscore_crypto.c | 2 +- 44 files changed, 77 insertions(+), 42 deletions(-) create mode 100644 include/coap3/coap_libcoap_build.h diff --git a/Makefile.am b/Makefile.am index 194f67a5..ed5925ea 100644 --- a/Makefile.am +++ b/Makefile.am @@ -94,6 +94,7 @@ EXTRA_DIST = \ examples/riot/tests_pkg_libcoap/tests/01-run.py \ examples/riot/README \ Makefile.libcoap \ + include/coap$(LIBCOAP_API_VERSION)/coap_libcoap_build.h \ include/coap$(LIBCOAP_API_VERSION)/coap_internal.h \ include/coap$(LIBCOAP_API_VERSION)/coap_riot.h \ include/coap$(LIBCOAP_API_VERSION)/coap_asn1_internal.h \ diff --git a/include/coap3/coap_libcoap_build.h b/include/coap3/coap_libcoap_build.h new file mode 100644 index 00000000..8d9ddd7a --- /dev/null +++ b/include/coap3/coap_libcoap_build.h @@ -0,0 +1,34 @@ +/* + * coap_libcoap_build.h -- libcoap library build specifics + * + * Copyright (C) 2019-2024 Jon Shallow + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/* + * All libcoap library files should include this file which then pulls in all + * of the other appropriate header files. + * + * Here can be added in specific checks to make sure that the libcoap library + * is built as expected. + * + * Note: This file should never be included in application code. + */ + +/** + * @file coap_libcoap_build.h + * @brief Library specific build wrapper for coap_internal.h + */ + +#ifndef COAP_LIBCOAP_BUILD_H_ +#define COAP_LIBCOAP_BUILD_H_ + +#include "coap_config.h" + +#include "coap_internal.h" + +#endif /* COAP_LIBCOAP_BUILD_H_ */ diff --git a/src/coap_address.c b/src/coap_address.c index bc337676..71ce0574 100644 --- a/src/coap_address.c +++ b/src/coap_address.c @@ -13,7 +13,7 @@ * @brief Handling of network addresses */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #if !defined(WITH_CONTIKI) && !defined(WITH_LWIP) && !defined(RIOT_VERSION) #ifdef HAVE_ARPA_INET_H diff --git a/src/coap_asn1.c b/src/coap_asn1.c index 9ebde641..c3b2e86c 100644 --- a/src/coap_asn1.c +++ b/src/coap_asn1.c @@ -13,7 +13,7 @@ * @brief CoAP specific ASN.1 handling */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" size_t asn1_len(const uint8_t **ptr) { diff --git a/src/coap_async.c b/src/coap_async.c index 78811094..ba39206b 100644 --- a/src/coap_async.c +++ b/src/coap_async.c @@ -13,7 +13,7 @@ * @brief State handling for asynchronous messages */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #if COAP_ASYNC_SUPPORT #include diff --git a/src/coap_block.c b/src/coap_block.c index 2182bad5..fa20114d 100644 --- a/src/coap_block.c +++ b/src/coap_block.c @@ -13,7 +13,7 @@ * @brief CoAP Block handling */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #ifndef min #define min(a,b) ((a) < (b) ? (a) : (b)) diff --git a/src/coap_cache.c b/src/coap_cache.c index 9f86c24b..7a9cedf1 100644 --- a/src/coap_cache.c +++ b/src/coap_cache.c @@ -13,7 +13,7 @@ * @brief CoAP Cache handling */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #if COAP_SERVER_SUPPORT /* Determines if the given option_type denotes an option type that can diff --git a/src/coap_debug.c b/src/coap_debug.c index e7548d95..6a905d73 100644 --- a/src/coap_debug.c +++ b/src/coap_debug.c @@ -13,7 +13,7 @@ * @brief Debug utilities */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #if defined(HAVE_STRNLEN) && defined(__GNUC__) && !defined(_GNU_SOURCE) #define _GNU_SOURCE 1 diff --git a/src/coap_dtls.c b/src/coap_dtls.c index a5c1f6b6..3cff9709 100644 --- a/src/coap_dtls.c +++ b/src/coap_dtls.c @@ -15,7 +15,7 @@ * @brief CoAP (D)TLS handling functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #ifdef _WIN32 #define strcasecmp _stricmp diff --git a/src/coap_encode.c b/src/coap_encode.c index 841b52ce..442227be 100644 --- a/src/coap_encode.c +++ b/src/coap_encode.c @@ -13,7 +13,7 @@ * @brief Encoding and decoding Coap data types functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" /* Carsten suggested this when fls() is not available: */ #ifndef HAVE_FLS diff --git a/src/coap_event.c b/src/coap_event.c index 2d7974a0..482f1e69 100644 --- a/src/coap_event.c +++ b/src/coap_event.c @@ -14,7 +14,7 @@ * @brief Event handling */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" /* * This replaces coap_set_event_handler() so that handler registration is diff --git a/src/coap_gnutls.c b/src/coap_gnutls.c index 5fd562da..b144e476 100644 --- a/src/coap_gnutls.c +++ b/src/coap_gnutls.c @@ -48,7 +48,7 @@ * 3.6.6 or later is required to support Raw Public Key(RPK) */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #ifdef COAP_WITH_LIBGNUTLS diff --git a/src/coap_hashkey.c b/src/coap_hashkey.c index 0be896b4..3541d305 100644 --- a/src/coap_hashkey.c +++ b/src/coap_hashkey.c @@ -13,7 +13,7 @@ * @brief Hashkey functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" void coap_hash_impl(const unsigned char *s, size_t len, coap_key_t h) { diff --git a/src/coap_io.c b/src/coap_io.c index 91b79643..3d799685 100644 --- a/src/coap_io.c +++ b/src/coap_io.c @@ -13,7 +13,7 @@ * @brief Network I/O functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #ifdef HAVE_STDIO_H # include diff --git a/src/coap_io_contiki.c b/src/coap_io_contiki.c index c2137374..b8a0889a 100644 --- a/src/coap_io_contiki.c +++ b/src/coap_io_contiki.c @@ -14,7 +14,7 @@ * @brief Contiki-NG-specific functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #include "contiki-net.h" static void prepare_io(coap_context_t *ctx); diff --git a/src/coap_io_lwip.c b/src/coap_io_lwip.c index d232d7c6..9f2468c2 100644 --- a/src/coap_io_lwip.c +++ b/src/coap_io_lwip.c @@ -14,7 +14,7 @@ * @brief LwIP specific functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #include #include #include diff --git a/src/coap_io_riot.c b/src/coap_io_riot.c index 5a299255..15289deb 100644 --- a/src/coap_io_riot.c +++ b/src/coap_io_riot.c @@ -13,7 +13,7 @@ * @brief RIOT specific I/O functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #include "net/gnrc.h" #include "net/gnrc/ipv6.h" diff --git a/src/coap_layers.c b/src/coap_layers.c index 01835050..644fd3fd 100644 --- a/src/coap_layers.c +++ b/src/coap_layers.c @@ -13,7 +13,7 @@ * @brief Layer Handling */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" /* * Layer index table. A whole protocol chunk gets copied into coap_socket_t. diff --git a/src/coap_mbedtls.c b/src/coap_mbedtls.c index 13b825c4..8c715811 100644 --- a/src/coap_mbedtls.c +++ b/src/coap_mbedtls.c @@ -32,7 +32,7 @@ * */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #ifdef COAP_WITH_LIBMBEDTLS diff --git a/src/coap_mem.c b/src/coap_mem.c index 87d56511..bdd70952 100644 --- a/src/coap_mem.c +++ b/src/coap_mem.c @@ -13,7 +13,7 @@ * @brief Memory handling functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #ifndef WITH_LWIP #if COAP_MEMORY_TYPE_TRACK diff --git a/src/coap_net.c b/src/coap_net.c index 01aff8af..7a0c0487 100644 --- a/src/coap_net.c +++ b/src/coap_net.c @@ -13,7 +13,7 @@ * @brief CoAP context functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #include "coap3/coap_mutex_internal.h" #include diff --git a/src/coap_netif.c b/src/coap_netif.c index 5e7a425f..ca3f9fc1 100644 --- a/src/coap_netif.c +++ b/src/coap_netif.c @@ -14,7 +14,7 @@ * @brief CoAP Netif handling functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #include "coap3/coap_session_internal.h" /* diff --git a/src/coap_notls.c b/src/coap_notls.c index b164a718..02239e2f 100644 --- a/src/coap_notls.c +++ b/src/coap_notls.c @@ -15,7 +15,7 @@ * @brief NoTLS specific interface functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #if !defined(COAP_WITH_LIBOPENSSL) int diff --git a/src/coap_openssl.c b/src/coap_openssl.c index 0e1aa59f..cfbb8515 100644 --- a/src/coap_openssl.c +++ b/src/coap_openssl.c @@ -15,7 +15,7 @@ * @brief OpenSSL specific interface functions. */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #ifdef COAP_WITH_LIBOPENSSL diff --git a/src/coap_option.c b/src/coap_option.c index aec9c07a..aa4cdf3e 100644 --- a/src/coap_option.c +++ b/src/coap_option.c @@ -14,7 +14,7 @@ * @brief CoAP option handling functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #include #include diff --git a/src/coap_oscore.c b/src/coap_oscore.c index 322c0e48..bd06af0c 100644 --- a/src/coap_oscore.c +++ b/src/coap_oscore.c @@ -18,7 +18,7 @@ * @brief CoAP OSCORE handling */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #if COAP_OSCORE_SUPPORT #include diff --git a/src/coap_pdu.c b/src/coap_pdu.c index f1f81e06..a23195b2 100644 --- a/src/coap_pdu.c +++ b/src/coap_pdu.c @@ -13,7 +13,7 @@ * @brief CoAP PDU handling */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #if defined(HAVE_LIMITS_H) #include diff --git a/src/coap_prng.c b/src/coap_prng.c index f9d94b05..7525ee4e 100644 --- a/src/coap_prng.c +++ b/src/coap_prng.c @@ -14,7 +14,7 @@ * @brief Pseudo Random Number functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #ifdef HAVE_GETRANDOM #include diff --git a/src/coap_resource.c b/src/coap_resource.c index 59d38a15..a879a904 100644 --- a/src/coap_resource.c +++ b/src/coap_resource.c @@ -13,7 +13,7 @@ * @brief Server resource handling functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #if COAP_SERVER_SUPPORT #include diff --git a/src/coap_session.c b/src/coap_session.c index e057aa48..47a53086 100644 --- a/src/coap_session.c +++ b/src/coap_session.c @@ -14,7 +14,7 @@ * @brief Session handling functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #ifndef COAP_SESSION_C_ #define COAP_SESSION_C_ diff --git a/src/coap_sha1.c b/src/coap_sha1.c index b71915ba..c2b16ca5 100644 --- a/src/coap_sha1.c +++ b/src/coap_sha1.c @@ -63,7 +63,7 @@ * Reformatted as appropriate. */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #if COAP_WS_SUPPORT && !defined(COAP_WITH_LIBOPENSSL) && !defined(COAP_WITH_LIBGNUTLS) && !defined(COAP_WITH_LIBMBEDTLS) && !defined(COAP_WITH_LIBWOLFSSL) /* diff --git a/src/coap_str.c b/src/coap_str.c index 0f969e3b..89fd1cf5 100644 --- a/src/coap_str.c +++ b/src/coap_str.c @@ -13,7 +13,7 @@ * @brief String handling functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #include diff --git a/src/coap_subscribe.c b/src/coap_subscribe.c index 7214f6ea..2d4beb4c 100644 --- a/src/coap_subscribe.c +++ b/src/coap_subscribe.c @@ -14,7 +14,7 @@ * @brief Subscription handling functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #ifndef min #define min(a,b) ((a) < (b) ? (a) : (b)) diff --git a/src/coap_tcp.c b/src/coap_tcp.c index 379874b0..d7147687 100644 --- a/src/coap_tcp.c +++ b/src/coap_tcp.c @@ -14,7 +14,7 @@ * @brief CoAP TCP handling functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" int coap_tcp_is_supported(void) { diff --git a/src/coap_time.c b/src/coap_time.c index 539a5735..99805a81 100644 --- a/src/coap_time.c +++ b/src/coap_time.c @@ -13,7 +13,7 @@ * @brief Clock handling functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #ifdef HAVE_TIME_H #include diff --git a/src/coap_tinydtls.c b/src/coap_tinydtls.c index d1bf244f..1a8c2992 100644 --- a/src/coap_tinydtls.c +++ b/src/coap_tinydtls.c @@ -15,7 +15,7 @@ * @brief TinyDTLS specific handling functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #ifdef COAP_WITH_LIBTINYDTLS diff --git a/src/coap_uri.c b/src/coap_uri.c index 77e234c1..db3cea7c 100644 --- a/src/coap_uri.c +++ b/src/coap_uri.c @@ -13,7 +13,7 @@ * @brief URI handling functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #if defined(HAVE_LIMITS_H) #include diff --git a/src/coap_wolfssl.c b/src/coap_wolfssl.c index f6af82e6..ff6df7cd 100644 --- a/src/coap_wolfssl.c +++ b/src/coap_wolfssl.c @@ -16,7 +16,7 @@ * @brief wolfSSL specific interface functions. */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #ifdef COAP_WITH_LIBWOLFSSL diff --git a/src/coap_ws.c b/src/coap_ws.c index a91ccc52..e65cc1dd 100644 --- a/src/coap_ws.c +++ b/src/coap_ws.c @@ -15,7 +15,7 @@ * @brief CoAP WebSocket handling functions */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #if COAP_WS_SUPPORT #include diff --git a/src/oscore/oscore.c b/src/oscore/oscore.c index fe0195c7..26179b33 100644 --- a/src/oscore/oscore.c +++ b/src/oscore/oscore.c @@ -44,7 +44,7 @@ * */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" /* oscore_cs_params * returns cbor array [[param_type], [paramtype, param]] diff --git a/src/oscore/oscore_cbor.c b/src/oscore/oscore_cbor.c index 818149f6..7d31946e 100644 --- a/src/oscore/oscore_cbor.c +++ b/src/oscore/oscore_cbor.c @@ -44,7 +44,7 @@ * */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #include static void diff --git a/src/oscore/oscore_context.c b/src/oscore/oscore_context.c index f9cd8562..a0b024e0 100644 --- a/src/oscore/oscore_context.c +++ b/src/oscore/oscore_context.c @@ -43,7 +43,7 @@ * Jon Shallow */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #include diff --git a/src/oscore/oscore_cose.c b/src/oscore/oscore_cose.c index a4b869c0..cdf3a41b 100644 --- a/src/oscore/oscore_cose.c +++ b/src/oscore/oscore_cose.c @@ -43,7 +43,7 @@ * */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #include "stdio.h" struct cose_curve_desc { diff --git a/src/oscore/oscore_crypto.c b/src/oscore/oscore_crypto.c index be1c1340..38b8e057 100644 --- a/src/oscore/oscore_crypto.c +++ b/src/oscore/oscore_crypto.c @@ -44,7 +44,7 @@ * Jon Shallow */ -#include "coap3/coap_internal.h" +#include "coap3/coap_libcoap_build.h" #include #include