mirror of
https://github.com/openharmony/third_party_libcoap.git
synced 2026-07-01 03:23:17 -04:00
support libcoap-4.3.5
Signed-off-by: ye-xiaokang123 <yexiaokang3@huawei.com>
This commit is contained in:
@@ -5,4 +5,4 @@ Jean-Claude Michelou
|
||||
Christian Amsüss
|
||||
|
||||
For additional contributors, see
|
||||
https://github.com/obgm/libcoap/graphs/contributors
|
||||
https://github.com/obgm/libcoap/graphs/contributors
|
||||
|
||||
@@ -42,6 +42,9 @@ src = [
|
||||
"src/coap_subscribe.c",
|
||||
"src/coap_uri.c",
|
||||
"src/coap_ws.c",
|
||||
"src/coap_proxy.c",
|
||||
"src/coap_sha1.c",
|
||||
"src/coap_threadsafe.c",
|
||||
]
|
||||
|
||||
if (defined(ohos_lite)) {
|
||||
|
||||
@@ -99,6 +99,9 @@ Note: FreeBSD requires gmake instead of make when building TinyDTLS - i.e.
|
||||
# With OpenSSL
|
||||
./configure --with-openssl --enable-tests --enable-shared
|
||||
|
||||
# With wolfSSL
|
||||
./configure --with-wolfssl --enable-tests --enable-shared
|
||||
|
||||
# With GnuTLS
|
||||
./configure --with-gnutls --enable-tests --enable-shared
|
||||
|
||||
@@ -117,8 +120,6 @@ prior to running 'make'.
|
||||
RIOT
|
||||
====
|
||||
|
||||
./autogen.sh
|
||||
./configure --disable-tests --disable-documentation --disable-examples --disable-dtls
|
||||
cd examples/riot
|
||||
make
|
||||
|
||||
@@ -127,8 +128,6 @@ See examples/riot/README for further information.
|
||||
LwIP
|
||||
====
|
||||
|
||||
./autogen.sh
|
||||
./configure --disable-tests --disable-documentation --disable-examples --disable-dtls
|
||||
cd examples/lwip
|
||||
make
|
||||
|
||||
@@ -137,8 +136,6 @@ Executable is ./server. See examples/lwip/README for further information.
|
||||
Contiki-NG
|
||||
==========
|
||||
|
||||
./autogen.sh
|
||||
./configure --disable-tests --disable-documentation --disable-examples --disable-dtls
|
||||
cd examples/contiki
|
||||
make
|
||||
|
||||
|
||||
+128
-38
@@ -1,7 +1,7 @@
|
||||
# CMakeLists.txt for libcoap
|
||||
#
|
||||
# Copyright (C) 2020 Carlos Gomes Martinho <carlos.gomes_martinho@siemens.com>
|
||||
# Copyright (C) 2020-2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
# Copyright (C) 2020-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
@@ -12,18 +12,22 @@ cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(
|
||||
libcoap
|
||||
VERSION 4.3.4
|
||||
VERSION 4.3.5
|
||||
LANGUAGES CXX C)
|
||||
|
||||
set(LIBCOAP_API_VERSION 3)
|
||||
set(LIBCOAP_ABI_VERSION 3.1.1)
|
||||
set(LIBCOAP_ABI_VERSION 3.2.0)
|
||||
|
||||
set(COAP_LIBRARY_NAME "coap-${LIBCOAP_API_VERSION}")
|
||||
|
||||
if(NOT ZEPHYR_BASE)
|
||||
option(
|
||||
BUILD_SHARED_LIBS
|
||||
"Build shared libs"
|
||||
OFF)
|
||||
else()
|
||||
# provided by the zephyr build system
|
||||
endif()
|
||||
|
||||
#
|
||||
# global compiler options
|
||||
@@ -84,6 +88,7 @@ set_target_properties(${COAP_LIBRARY_NAME} PROPERTIES VERSION ${LIBCOAP_ABI_VERS
|
||||
# options to tweak the library
|
||||
#
|
||||
|
||||
if(NOT ZEPHYR_BASE)
|
||||
option(
|
||||
ENABLE_DTLS
|
||||
"enable building with DTLS support"
|
||||
@@ -94,17 +99,18 @@ set(DTLS_BACKEND
|
||||
STRING
|
||||
"\
|
||||
Name of the dtls backend, only relevant if `ENABLE_DTLS` is ON which is default. \
|
||||
Possible values: default, gnutls, openssl, tinydtls and mbedtls. \
|
||||
Possible values: default, gnutls, openssl, wolfssl, tinydtls and mbedtls. \
|
||||
If specified then this library will be searched and if found also used. \
|
||||
If not found then the cmake configuration will stop with an error. \
|
||||
If not specified, then cmake will try to use the first one found in the following order: \
|
||||
gnutls, openssl, tinydtls, mbedtls \
|
||||
gnutls, openssl, wolfssl, tinydtls, mbedtls \
|
||||
")
|
||||
set_property(
|
||||
CACHE DTLS_BACKEND
|
||||
PROPERTY STRINGS
|
||||
default
|
||||
openssl
|
||||
wolfssl
|
||||
gnutls
|
||||
tinydtls
|
||||
mbedtls)
|
||||
@@ -120,6 +126,10 @@ option(
|
||||
ENABLE_SERVER_MODE
|
||||
"compile with support for server mode code"
|
||||
ON)
|
||||
option(
|
||||
ENABLE_PROXY_CODE
|
||||
"compile with support for proxy code"
|
||||
ON)
|
||||
option(
|
||||
ENABLE_OSCORE
|
||||
"compile with support for OSCORE"
|
||||
@@ -132,6 +142,14 @@ option(
|
||||
WITH_EPOLL
|
||||
"compile with epoll support"
|
||||
ON)
|
||||
option(
|
||||
ENABLE_THREAD_SAFE
|
||||
"enable building with thread safe support"
|
||||
ON)
|
||||
option(
|
||||
ENABLE_THREAD_RECURSIVE_LOCK_CHECK
|
||||
"enable building with thread recursive lock detection"
|
||||
OFF)
|
||||
option(
|
||||
ENABLE_SMALL_STACK
|
||||
"enable if the system has small stack size"
|
||||
@@ -188,7 +206,7 @@ set(MAX_LOGGING_LEVEL
|
||||
Only build logging code up to and including the specified logging level (0 - 8)[default=8]]
|
||||
")
|
||||
set_property(
|
||||
CACHE DTLS_BACKEND
|
||||
CACHE MAX_LOGGING_LEVEL
|
||||
PROPERTY STRINGS
|
||||
"0"
|
||||
"1"
|
||||
@@ -200,6 +218,10 @@ set_property(
|
||||
"7"
|
||||
"8")
|
||||
|
||||
else() # ! ZEPHYR_BASE
|
||||
# provided by zephyr/CMakeLists.txt and zephyr/Kconfig
|
||||
endif() # ! ZEPHYR_BASE
|
||||
|
||||
if(NOT CMAKE_C_STANDARD)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
endif()
|
||||
@@ -278,9 +300,11 @@ check_function_exists(random HAVE_RANDOM)
|
||||
check_function_exists(if_nametoindex HAVE_IF_NAMETOINDEX)
|
||||
|
||||
# check for symbols
|
||||
if(WIN32 AND NOT MINGW)
|
||||
if(WIN32)
|
||||
set(HAVE_STRUCT_CMSGHDR 1)
|
||||
message(STATUS "setting HAVE_STRUCT_CMSGHDR")
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL QNX)
|
||||
set(HAVE_STRUCT_CMSGHDR 0)
|
||||
else()
|
||||
check_symbol_exists(
|
||||
CMSG_FIRSTHDR
|
||||
@@ -302,6 +326,13 @@ else()
|
||||
message(STATUS "compiling without server support")
|
||||
endif()
|
||||
|
||||
if(${ENABLE_PROXY_CODE})
|
||||
set(COAP_PROXY_SUPPORT "1")
|
||||
message(STATUS "compiling with proxy support")
|
||||
else()
|
||||
message(STATUS "compiling without proxy support")
|
||||
endif()
|
||||
|
||||
if(${ENABLE_OSCORE})
|
||||
set(COAP_OSCORE_SUPPORT "1")
|
||||
message(STATUS "compiling with OSCORE support")
|
||||
@@ -309,7 +340,7 @@ else()
|
||||
message(STATUS "compiling without OSCORE support")
|
||||
endif()
|
||||
|
||||
if(${ENABLE_WS} AND $(ENABLE_TCP))
|
||||
if(${ENABLE_WS} AND ${ENABLE_TCP})
|
||||
set(COAP_WS_SUPPORT "1")
|
||||
message(STATUS "compiling with WebSockets support")
|
||||
else()
|
||||
@@ -376,12 +407,22 @@ else()
|
||||
message(STATUS "compiling without epoll support")
|
||||
endif()
|
||||
|
||||
if(ENABLE_THREAD_SAFE)
|
||||
set(COAP_THREAD_SAFE "${ENABLE_THREAD_SAFE}")
|
||||
message(STATUS "compiling with thread safe support")
|
||||
endif()
|
||||
|
||||
if(ENABLE_THREAD_RECURSIVE_LOCK_CHECK)
|
||||
set(COAP_THREAD_RECURSIVE_CHECK "${ENABLE_THREAD_RECURSIVE_LOCK_CHECK}")
|
||||
message(STATUS "compiling with thread recursive lock detection support")
|
||||
endif()
|
||||
|
||||
if(ENABLE_SMALL_STACK)
|
||||
set(ENABLE_SMALL_STACK "${ENABLE_SMALL_STACK}")
|
||||
set(COAP_CONSTRAINED_STACK "${ENABLE_SMALL_STACK}")
|
||||
message(STATUS "compiling with small stack support")
|
||||
endif()
|
||||
|
||||
if(${MAX_LOGGING_LEVEL} MATCHES "[0-7]")
|
||||
if(${MAX_LOGGING_LEVEL} MATCHES "[0-8]")
|
||||
set(COAP_MAX_LOGGING_LEVEL ${MAX_LOGGING_LEVEL})
|
||||
message(STATUS "compiling with max logging level set to ${MAX_LOGGING_LEVEL}")
|
||||
else()
|
||||
@@ -392,6 +433,7 @@ set(WITH_GNUTLS OFF)
|
||||
set(WITH_OPENSSL OFF)
|
||||
set(WITH_TINYDTLS OFF)
|
||||
set(WITH_MBEDTLS OFF)
|
||||
set(WITH_WOLFSSL OFF)
|
||||
|
||||
function(compile_tinydtls)
|
||||
set(TINYDTLS_SOURCES_DIR ${CMAKE_CURRENT_LIST_DIR}/ext/tinydtls)
|
||||
@@ -476,33 +518,43 @@ if(ENABLE_DTLS)
|
||||
set(COAP_WITH_LIBOPENSSL 1)
|
||||
else()
|
||||
# openssl not found
|
||||
# libmbedtls (e.g. debian libmbedtls-dev)
|
||||
find_package(MbedTLS)
|
||||
if(MbedTLS_FOUND)
|
||||
set(WITH_MBEDTLS ON)
|
||||
message(STATUS "compiling with mbedtls support")
|
||||
set(COAP_WITH_LIBMBEDTLS 1)
|
||||
# wolfSSL
|
||||
find_package(wolfSSL)
|
||||
if(wolfSSL_FOUND)
|
||||
set(WITH_WOLFSSL ON)
|
||||
message(STATUS "compiling with wolfssl support")
|
||||
set(COAP_WITH_LIBWOLFSSL 1)
|
||||
else()
|
||||
# mbedtls not found
|
||||
if(USE_VENDORED_TINYDTLS)
|
||||
compile_tinydtls()
|
||||
# wolfssl not found
|
||||
# libmbedtls (e.g. debian libmbedtls-dev)
|
||||
find_package(MbedTLS)
|
||||
if(MbedTLS_FOUND)
|
||||
set(WITH_MBEDTLS ON)
|
||||
message(STATUS "compiling with mbedtls support")
|
||||
set(COAP_WITH_LIBMBEDTLS 1)
|
||||
else()
|
||||
find_package(TinyDTLS)
|
||||
if(TINYDTLS_FOUND)
|
||||
|
||||
# mbedtls not found
|
||||
if(USE_VENDORED_TINYDTLS)
|
||||
compile_tinydtls()
|
||||
else()
|
||||
# no cryto lib found
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"cannot find any cryto lib, either install one or compile without DTLS support"
|
||||
)
|
||||
find_package(TinyDTLS)
|
||||
if(TINYDTLS_FOUND)
|
||||
|
||||
else()
|
||||
# no cryto lib found
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"cannot find any cryto lib, either install one or compile without DTLS support"
|
||||
)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
endif()
|
||||
set(WITH_TINYDTLS ON)
|
||||
message(STATUS "compiling with tinydtls support")
|
||||
set(COAP_WITH_LIBTINYDTLS 1)
|
||||
|
||||
set(WITH_TINYDTLS ON)
|
||||
message(STATUS "compiling with tinydtls support")
|
||||
set(COAP_WITH_LIBTINYDTLS 1)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
@@ -516,6 +568,7 @@ if(ENABLE_DTLS)
|
||||
set(WITH_TINYDTLS OFF)
|
||||
set(WITH_MBEDTLS OFF)
|
||||
set(WITH_OPENSSL OFF)
|
||||
set(WITH_WOLFSSL OFF)
|
||||
|
||||
if(DTLS_BACKEND
|
||||
STREQUAL
|
||||
@@ -537,6 +590,15 @@ if(ENABLE_DTLS)
|
||||
set(COAP_WITH_LIBOPENSSL 1)
|
||||
endif()
|
||||
|
||||
if(DTLS_BACKEND
|
||||
STREQUAL
|
||||
"wolfssl")
|
||||
find_package(wolfSSL REQUIRED)
|
||||
set(WITH_WOLFSSL ON)
|
||||
message(STATUS "compiling with wolfssl support")
|
||||
set(COAP_WITH_LIBWOLFSSL 1)
|
||||
endif()
|
||||
|
||||
if(DTLS_BACKEND
|
||||
STREQUAL
|
||||
"mbedtls")
|
||||
@@ -567,6 +629,16 @@ if(ENABLE_DTLS)
|
||||
|
||||
endif()
|
||||
|
||||
if(WITH_WOLFSSL)
|
||||
find_library(WOLFSSL_LIBRARY wolfssl HINTS /usr/local/lib)
|
||||
find_path(WOLFSSL_INCLUDE_DIR wolfssl/wolfcrypt/settings.h HINTS /usr/local/include)
|
||||
if(WOLFSSL_LIBRARY AND WOLFSSL_INCLUDE_DIR)
|
||||
message(STATUS "compiling with wolfssl support")
|
||||
else()
|
||||
message(FATAL_ERROR "WolfSSL not found")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND git describe --tags --dirty --always
|
||||
RESULT_VARIABLE USING_GIT
|
||||
OUTPUT_VARIABLE LIBCOAP_PACKAGE_BUILD
|
||||
@@ -608,16 +680,20 @@ message(STATUS "ENABLE_CLIENT_MODE:..............${ENABLE_CLIENT_MODE}")
|
||||
message(STATUS "ENABLE_SERVER_MODE:..............${ENABLE_SERVER_MODE}")
|
||||
message(STATUS "ENABLE_OSCORE:...................${ENABLE_OSCORE}")
|
||||
message(STATUS "ENABLE_ASYNC:....................${ENABLE_ASYNC}")
|
||||
message(STATUS "ENABLE_THREAD_SAFE:..............${ENABLE_THREAD_SAFE}")
|
||||
message(STATUS "ENABLE_THREAD_RECURSIVE_CHECK....${ENABLE_THREAD_RECURSIVE_LOCK_CHECK}")
|
||||
message(STATUS "ENABLE_DOCS:.....................${ENABLE_DOCS}")
|
||||
message(STATUS "ENABLE_EXAMPLES:.................${ENABLE_EXAMPLES}")
|
||||
message(STATUS "DTLS_BACKEND:....................${DTLS_BACKEND}")
|
||||
message(STATUS "WITH_GNUTLS:.....................${WITH_GNUTLS}")
|
||||
message(STATUS "WITH_TINYDTLS:...................${WITH_TINYDTLS}")
|
||||
message(STATUS "WITH_OPENSSL:....................${WITH_OPENSSL}")
|
||||
message(STATUS "WITH_WOLFSSL:....................${WITH_WOLFSSL}")
|
||||
message(STATUS "WITH_MBEDTLS:....................${WITH_MBEDTLS}")
|
||||
message(STATUS "HAVE_LIBTINYDTLS:................${COAP_WITH_LIBTINYDTLS}")
|
||||
message(STATUS "HAVE_LIBGNUTLS:..................${COAP_WITH_LIBGNUTLS}")
|
||||
message(STATUS "HAVE_LIBOPENSSL:.................${COAP_WITH_LIBOPENSSL}")
|
||||
message(STATUS "HAVE_LIBWOLFSSL:.................${COAP_WITH_LIBWOLFSSL}")
|
||||
message(STATUS "HAVE_LIBMBEDTLS:.................${COAP_WITH_LIBMBEDTLS}")
|
||||
message(STATUS "WITH_EPOLL:......................${WITH_EPOLL}")
|
||||
message(STATUS "WITH_OBSERVE_PERSIST:............${WITH_OBSERVE_PERSIST}")
|
||||
@@ -641,12 +717,12 @@ else(ENABLE_TCP)
|
||||
endif(ENABLE_TCP)
|
||||
|
||||
# creates config header file in build directory
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/include/coap${LIBCOAP_API_VERSION}/coap.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/coap${LIBCOAP_API_VERSION}/coap.h)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake_coap_config.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/coap_config.h)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake_coap_defines.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/coap${LIBCOAP_API_VERSION}/coap_defines.h)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/tests/test_common.h.in
|
||||
${CMAKE_CURRENT_LIST_DIR}/tests/test_common.h)
|
||||
|
||||
@@ -676,20 +752,24 @@ target_sources(
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/coap_oscore.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/coap_pdu.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/coap_prng.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/coap_proxy.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/coap_resource.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/coap_session.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/coap_sha1.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/coap_str.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/coap_subscribe.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/coap_tcp.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/coap_threadsafe.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/coap_time.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/coap_uri.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/coap_ws.c
|
||||
# no need to parse those files if we do not need them
|
||||
$<$<BOOL:${COAP_WITH_LIBOPENSSL}>:${CMAKE_CURRENT_LIST_DIR}/src/coap_openssl.c>
|
||||
$<$<BOOL:${COAP_WITH_LIBWOLFSSL}>:${CMAKE_CURRENT_LIST_DIR}/src/coap_wolfssl.c>
|
||||
$<$<BOOL:${COAP_WITH_LIBTINYDTLS}>:${CMAKE_CURRENT_LIST_DIR}/src/coap_tinydtls.c>
|
||||
$<$<BOOL:${COAP_WITH_LIBGNUTLS}>:${CMAKE_CURRENT_LIST_DIR}/src/coap_gnutls.c>
|
||||
$<$<BOOL:${COAP_WITH_LIBMBEDTLS}>:${CMAKE_CURRENT_LIST_DIR}/src/coap_mbedtls.c>
|
||||
# needed for OSCORE is enabled
|
||||
# needed for OSCORE if enabled
|
||||
$<$<BOOL:${COAP_OSCORE_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/src/oscore/oscore.c>
|
||||
$<$<BOOL:${COAP_OSCORE_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/src/oscore/oscore_cbor.c>
|
||||
$<$<BOOL:${COAP_OSCORE_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/src/oscore/oscore_context.c>
|
||||
@@ -712,10 +792,12 @@ target_sources(
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/coap${LIBCOAP_API_VERSION}/coap_option.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/coap${LIBCOAP_API_VERSION}/coap_pdu.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/coap${LIBCOAP_API_VERSION}/coap_prng.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/coap${LIBCOAP_API_VERSION}/coap_proxy.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/coap${LIBCOAP_API_VERSION}/coap_resource.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/coap${LIBCOAP_API_VERSION}/coap_session.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/coap${LIBCOAP_API_VERSION}/coap_str.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/coap${LIBCOAP_API_VERSION}/coap_subscribe.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/coap${LIBCOAP_API_VERSION}/coap_supported.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/coap${LIBCOAP_API_VERSION}/coap_time.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/coap${LIBCOAP_API_VERSION}/coap_uri.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/coap${LIBCOAP_API_VERSION}/coap_ws.h)
|
||||
@@ -728,7 +810,8 @@ target_include_directories(
|
||||
$<INSTALL_INTERFACE:include/>
|
||||
$<$<AND:$<BOOL:${COAP_WITH_LIBTINYDTLS}>,$<BOOL:${USE_VENDORED_TINYDTLS}>>:${CMAKE_BINARY_DIR}/include/tinydtls>
|
||||
$<$<BOOL:${COAP_WITH_LIBGNUTLS}>:${GNUTLS_INCLUDE_DIR}>
|
||||
$<$<BOOL:${COAP_WITH_LIBMBEDTLS}>:${MBEDTLS_INCLUDE_DIRS}>)
|
||||
$<$<BOOL:${COAP_WITH_LIBMBEDTLS}>:${MBEDTLS_INCLUDE_DIRS}>
|
||||
$<$<BOOL:${COAP_WITH_LIBWOLFSSL}>:${WOLFSSL_INCLUDE_DIR}>)
|
||||
target_link_libraries(
|
||||
${COAP_LIBRARY_NAME}
|
||||
PUBLIC $<$<BOOL:${COAP_WITH_LIBOPENSSL}>:OpenSSL::SSL>
|
||||
@@ -738,12 +821,19 @@ target_link_libraries(
|
||||
$<$<BOOL:${COAP_WITH_LIBMBEDTLS}>:${MBEDTLS_LIBRARY}>
|
||||
$<$<BOOL:${COAP_WITH_LIBMBEDTLS}>:${MBEDX509_LIBRARY}>
|
||||
$<$<BOOL:${COAP_WITH_LIBMBEDTLS}>:${MBEDCRYPTO_LIBRARY}>
|
||||
$<$<BOOL:${COAP_WITH_LIBWOLFSSL}>:${WOLFSSL_LIBRARY}>
|
||||
$<$<BOOL:${MINGW}>:ws2_32>)
|
||||
|
||||
target_compile_options(
|
||||
${COAP_LIBRARY_NAME}
|
||||
PUBLIC -DLIBCOAP_PACKAGE_BUILD="${LIBCOAP_PACKAGE_BUILD}")
|
||||
|
||||
if(ZEPHYR_BASE)
|
||||
target_compile_options(
|
||||
${COAP_LIBRARY_NAME}
|
||||
PUBLIC -DMBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CFG_FILE}" -I${ZEPHYR_MBEDTLS_CMAKE_DIR}/configs)
|
||||
endif()
|
||||
|
||||
add_library(
|
||||
${PROJECT_NAME}::${COAP_LIBRARY_NAME}
|
||||
ALIAS
|
||||
@@ -873,11 +963,13 @@ install(
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib)
|
||||
|
||||
if(NOT ZEPHYR_BASE)
|
||||
install(
|
||||
EXPORT ${PROJECT_NAME}Targets
|
||||
DESTINATION ${LIBCOAP_CONFIG_INSTALL_DIR}
|
||||
NAMESPACE ${PROJECT_NAME}::
|
||||
COMPONENT dev)
|
||||
endif()
|
||||
|
||||
configure_package_config_file(
|
||||
cmake/Config.cmake.in
|
||||
@@ -899,8 +991,6 @@ install(
|
||||
COMPONENT dev
|
||||
FILES_MATCHING
|
||||
PATTERN "*.h"
|
||||
PATTERN "coap.h" EXCLUDE
|
||||
PATTERN "coap_riot.h" EXCLUDE
|
||||
PATTERN "*_internal.h" EXCLUDE
|
||||
PATTERN "oscore*" EXCLUDE)
|
||||
install(
|
||||
|
||||
+16
-3
@@ -33,8 +33,18 @@ libcoap library.
|
||||
|
||||
2. Communications
|
||||
~~~~~~~~~~~~~~~~~
|
||||
The main discussion and development platform for libcoap is the mailing list
|
||||
on Sourceforge.
|
||||
The best method to raise an Issue is to raise it at:
|
||||
|
||||
https://github.com/obgm/libcoap/issues
|
||||
|
||||
Previous issues and fixes can easily be researched here.
|
||||
|
||||
The best method to create a patch is to create a Pull Request at:
|
||||
|
||||
https://github.com/obgm/libcoap/pulls
|
||||
|
||||
Otherwise, the main discussion and development platform for libcoap is the
|
||||
mailing list on Sourceforge.
|
||||
|
||||
No matter if you just have a simple question, some specific problem or
|
||||
want to discuss some patches, please write it to the mailing list. Please
|
||||
@@ -187,6 +197,10 @@ coap_add_block(coap_pdu_t *pdu,
|
||||
header files as they are the public part of the libcoap and only use the
|
||||
@-syntax for doxygen commands (akin to javadoc).
|
||||
|
||||
* There are also man(1) pages to document how to use the APIs, held in the man/
|
||||
directory. Any API changes or new APIs should be documented here to aid
|
||||
development for other users.
|
||||
|
||||
5.5 API Changes
|
||||
---------------
|
||||
* Never break the API!
|
||||
@@ -260,4 +274,3 @@ programming person available. Do you want to write up something?
|
||||
* Missing functionality
|
||||
There are some features that are still missing inside the libcoap. For
|
||||
example some DTLS implementations and proxy functionality.
|
||||
|
||||
|
||||
@@ -1,3 +1,34 @@
|
||||
2024-05-23 Olaf Bergmann <bergmann@tzi.org>
|
||||
|
||||
Change summary for version 4.3.5:
|
||||
|
||||
* Support for wolfSSL TLS library.
|
||||
* Support for DTLS1.3 (using wolfSSL).
|
||||
* Support for Mbed TLS 3.6.0.
|
||||
* Support for EC-JPAKE (Mbed TLS)
|
||||
* TinyDTLS version update.
|
||||
* Support for RIOT using SOCK i/f.
|
||||
* Support for LwIP 2.2.0.
|
||||
* Support for LwIP using NO_SYS set to 0.
|
||||
* Support for (Posix based) Zephyr.
|
||||
* Support for QNX builds.
|
||||
* Support for ESP32 xtensa builds.
|
||||
* Updated Contiki-NG support.
|
||||
* Support for multi-thread safe libcoap usage.
|
||||
* Support for defining binary PSK for coap-client and coap-server.
|
||||
* Support for Connection-ID (CID) (Mbed TLS, wolfSSL and TinyDTLS).
|
||||
* Added new define types for defining PKI parameters.
|
||||
* Support for user definable ENGINE for OpenSSL.
|
||||
* Support for using noTLS and TinyDTLS with WebSockets.
|
||||
* Support for providing list of compilation #defines.
|
||||
* Support for proxy code running within lbcoap.
|
||||
* Cleaned up support for building .h files.
|
||||
* Additional scan-build and pre-commit checks in build tests.
|
||||
* Updated CI build tests to use latest action versions.
|
||||
* Fixes CVE-2023-35862.
|
||||
* Reported bugs fixed.
|
||||
* Documentation added and updated (Doxygen and man).
|
||||
|
||||
2023-09-18 Olaf Bergmann <bergmann@tzi.org>
|
||||
|
||||
Change summary for version 4.3.4:
|
||||
|
||||
@@ -95,4 +95,3 @@ PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure --libdir=/usr/lib64 \
|
||||
make
|
||||
sudo make install
|
||||
cd ..
|
||||
|
||||
|
||||
@@ -47,4 +47,3 @@ PKG_CONFIG_PATH=/opt/openssl/lib/pkgconfig ./configure --libdir=/usr/lib64 \
|
||||
make
|
||||
sudo make install
|
||||
cd ..
|
||||
|
||||
|
||||
@@ -87,4 +87,3 @@ cd ..
|
||||
# Verify that pkcs11 is available
|
||||
|
||||
/opt/openssl/bin/openssl engine pkcs11 -t
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2010--2023, Olaf Bergmann and others
|
||||
Copyright (c) 2010--2024, Olaf Bergmann and others
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
@@ -115,6 +115,47 @@ When compiled with Mbed TLS support, this software includes components
|
||||
that are licensed under the terms of the Apache 2.0 license
|
||||
(http://www.apache.org/licenses/LICENSE-2.0).
|
||||
|
||||
========================================================================
|
||||
wolfSSL
|
||||
|
||||
When compiled with wolfSSL support, this software includes components
|
||||
that are licensed under the terms of the GPLv2 license
|
||||
(https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
|
||||
|
||||
========================================================================
|
||||
SHA1
|
||||
|
||||
SHA1 support is taken from RFC3174 Sections 7.1 and 7.2 for use with
|
||||
WebSockets.
|
||||
|
||||
Full Copyright Statement
|
||||
|
||||
Copyright (C) The Internet Society (2001). All Rights Reserved.
|
||||
|
||||
This document and translations of it may be copied and furnished to
|
||||
others, and derivative works that comment on or otherwise explain it
|
||||
or assist in its implementation may be prepared, copied, published
|
||||
and distributed, in whole or in part, without restriction of any
|
||||
kind, provided that the above copyright notice and this paragraph are
|
||||
included on all such copies and derivative works. However, this
|
||||
document itself may not be modified in any way, such as by removing
|
||||
the copyright notice or references to the Internet Society or other
|
||||
Internet organizations, except as needed for the purpose of
|
||||
developing Internet standards in which case the procedures for
|
||||
copyrights defined in the Internet Standards process must be
|
||||
followed, or as required to translate it into languages other than
|
||||
English.
|
||||
|
||||
The limited permissions granted above are perpetual and will not be
|
||||
revoked by the Internet Society or its successors or assigns.
|
||||
|
||||
This document and the information contained herein is provided on an
|
||||
"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
|
||||
TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
|
||||
BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
|
||||
HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
========================================================================
|
||||
RIOT
|
||||
|
||||
|
||||
+26
-18
@@ -1,8 +1,8 @@
|
||||
# Makefile.am for libcoap
|
||||
#
|
||||
# Copyright (C) 2010-2023 Olaf Bergmann <bergmann@tzi.org>
|
||||
# Copyright (C) 2010-2024 Olaf Bergmann <bergmann@tzi.org>
|
||||
# Copyright (C) 2015-2017 Carsten Schoenert <c.schoenert@t-online.de>
|
||||
# Copyright (C) 2018-2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
# Copyright (C) 2018-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
@@ -33,9 +33,11 @@ EXTRA_DIST = \
|
||||
LICENSE \
|
||||
CMakeLists.txt \
|
||||
cmake_coap_config.h.in \
|
||||
cmake_coap_defines.h.in \
|
||||
cmake/Config.cmake.in \
|
||||
cmake/FindMbedTLS.cmake \
|
||||
cmake/FindTinyDTLS.cmake \
|
||||
cmake/FindwolfSSL.cmake \
|
||||
coap_config.h.contiki \
|
||||
coap_config.h.riot \
|
||||
coap_config.h.windows \
|
||||
@@ -59,7 +61,6 @@ EXTRA_DIST = \
|
||||
examples/lwip/server-coap.c \
|
||||
examples/lwip/server-coap.h \
|
||||
examples/lwip/config/coap_config.h \
|
||||
examples/lwip/config/coap_config.h.in \
|
||||
examples/lwip/config/lwipopts.h \
|
||||
examples/lwip/config/lwippools.h \
|
||||
examples/riot/examples_libcoap_client/client-coap.c \
|
||||
@@ -82,8 +83,18 @@ EXTRA_DIST = \
|
||||
examples/riot/pkg_libcoap/Makefile.dep \
|
||||
examples/riot/pkg_libcoap/Makefile.include \
|
||||
examples/riot/pkg_libcoap/Makefile.libcoap \
|
||||
examples/riot/tests_pkg_libcoap/app.config \
|
||||
examples/riot/tests_pkg_libcoap/Kconfig \
|
||||
examples/riot/tests_pkg_libcoap/libcoap-test.c \
|
||||
examples/riot/tests_pkg_libcoap/libcoap-test.h \
|
||||
examples/riot/tests_pkg_libcoap/main.c \
|
||||
examples/riot/tests_pkg_libcoap/Makefile \
|
||||
examples/riot/tests_pkg_libcoap/Makefile.ci \
|
||||
examples/riot/tests_pkg_libcoap/README.md \
|
||||
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 \
|
||||
@@ -101,19 +112,18 @@ EXTRA_DIST = \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap_netif_internal.h \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap_oscore_internal.h \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap_pdu_internal.h \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap_prng_internal.h \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap_proxy_internal.h \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap_resource_internal.h \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap_session_internal.h \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap_sha1_internal.h \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap_subscribe_internal.h \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap_tcp_internal.h \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap_threadsafe_internal.h \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap_uri_internal.h \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap_uthash_internal.h \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap_utlist_internal.h \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap_ws_internal.h \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap.h.in \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap.h.riot \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap.h.riot.in \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap.h.windows \
|
||||
include/coap$(LIBCOAP_API_VERSION)/coap.h.windows.in \
|
||||
include/oscore/oscore_cbor.h \
|
||||
include/oscore/oscore_context.h \
|
||||
include/oscore/oscore_cose.h \
|
||||
@@ -197,15 +207,19 @@ libcoap_@LIBCOAP_NAME_SUFFIX@_la_SOURCES = \
|
||||
src/coap_option.c \
|
||||
src/coap_oscore.c \
|
||||
src/coap_pdu.c \
|
||||
src/coap_proxy.c \
|
||||
src/coap_prng.c \
|
||||
src/coap_resource.c \
|
||||
src/coap_session.c \
|
||||
src/coap_sha1.c \
|
||||
src/coap_str.c \
|
||||
src/coap_subscribe.c \
|
||||
src/coap_tcp.c \
|
||||
src/coap_threadsafe.c \
|
||||
src/coap_time.c \
|
||||
src/coap_tinydtls.c \
|
||||
src/coap_uri.c \
|
||||
src/coap_wolfssl.c \
|
||||
src/coap_ws.c
|
||||
|
||||
if COAP_OSCORE_SUPPORT
|
||||
@@ -225,13 +239,14 @@ libcoap_includedir = $(includedir)/coap$(LIBCOAP_API_VERSION)/
|
||||
# $(top_srcdir)/include/coap-$(LIBCOAP_API_VERSION)/*
|
||||
|
||||
libcoap_include_HEADERS = \
|
||||
$(top_builddir)/include/coap$(LIBCOAP_API_VERSION)/coap.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/libcoap.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_address.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_async.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_block.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_cache.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_debug.h \
|
||||
$(top_builddir)/include/coap$(LIBCOAP_API_VERSION)/coap_defines.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_dtls.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_encode.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_event.h \
|
||||
@@ -243,10 +258,12 @@ libcoap_include_HEADERS = \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_oscore.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_pdu.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_prng.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_proxy.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_resource.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_session.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_str.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_subscribe.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_supported.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_time.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_uri.h \
|
||||
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_ws.h
|
||||
@@ -348,15 +365,7 @@ clean-local:
|
||||
|
||||
distclean-local:
|
||||
@rm -f src/*.o src/*.lo
|
||||
rm -f libcoap-$(LIBCOAP_API_VERSION).map
|
||||
rm -f libcoap-$(LIBCOAP_API_VERSION).sym
|
||||
rm -f libcoap-$(LIBCOAP_NAME_SUFFIX).pc
|
||||
@echo
|
||||
@echo " ---> Please note the following important advice! <---"
|
||||
@echo " The files libcoap-$(LIBCOAP_API_VERSION).{map,sym} are removed by the distclean target!"
|
||||
@echo " To regenerate this two files you need to call 'make update-map-file' first before any"
|
||||
@echo " other Make target. Otherwise the build of libcoap will fail!"
|
||||
@echo
|
||||
|
||||
## Ensure we have actual *.{map,sym} files if we create a release tarball.
|
||||
dist-local: update-map-file
|
||||
@@ -364,4 +373,3 @@ dist-local: update-map-file
|
||||
## Finaly some phony targets, just to ensure those targets are always buildable
|
||||
## no matter if the user has created same called files.
|
||||
.PHONY: update-map-file check_ctags
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
# libcoap: A C implementation of the Constrained Application Protocol (RFC 7252)
|
||||
|
||||
[](https://github.com/obgm/libcoap/actions?query=branch:main)
|
||||
[](https://github.com/obgm/libcoap/actions?query=branch:develop)
|
||||
[](https://scan.coverity.com/projects/obgm-libcoap)
|
||||
[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:libcoap)
|
||||
[](https://github.com/obgm/libcoap/actions/workflows/cifuzz.yml)
|
||||
[](https://github.com/pre-commit/pre-commit)
|
||||
|
||||
Copyright (C) 2010—2024 by Olaf Bergmann <bergmann@tzi.org> and others
|
||||
|
||||
ABOUT LIBCOAP
|
||||
=============
|
||||
|
||||
libcoap is a C implementation of a lightweight application-protocol
|
||||
for devices that are constrained their resources such as computing
|
||||
power, RF range, memory, bandwidth, or network packet sizes. This
|
||||
protocol, CoAP, is standardized by the IETF as RFC 7252. For further
|
||||
information related to CoAP, see <https://coap.space> or
|
||||
[CoAP Wiki](https://en.wikipedia.org/wiki/Constrained_Application_Protocol).
|
||||
|
||||
You might want to check out
|
||||
[libcoap-minimal](https://github.com/obgm/libcoap-minimal) for usage
|
||||
examples.
|
||||
|
||||
DOCUMENTATION
|
||||
=============
|
||||
|
||||
Documentation and further information can be found at
|
||||
<https://libcoap.net>.
|
||||
|
||||
PACKAGE CONTENTS
|
||||
================
|
||||
|
||||
This package contains a protocol parser and basic networking
|
||||
functions for platforms with support for malloc() and BSD-style
|
||||
sockets. In addition, there is support for Contiki-NG,
|
||||
Espressif/ESP-IDF, LwIP and RIOT-OS hosted environments.
|
||||
|
||||
The following RFCs are supported
|
||||
|
||||
* [RFC7252: The Constrained Application Protocol (CoAP)](https://rfc-editor.org/rfc/rfc7252)
|
||||
|
||||
* [RFC7390: Group Communication for the Constrained Application Protocol (CoAP)](https://rfc-editor.org/rfc/rfc7390)
|
||||
|
||||
* [RFC7641: Observing Resources in the Constrained Application Protocol (CoAP)](https://rfc-editor.org/rfc/rfc7641)
|
||||
|
||||
* [RFC7959: Block-Wise Transfers in the Constrained Application Protocol (CoAP)](https://rfc-editor.org/rfc/rfc7959)
|
||||
|
||||
* [RFC7967: Constrained Application Protocol (CoAP) Option for No Server Response](https://rfc-editor.org/rfc/rfc7967)
|
||||
|
||||
* [RFC8132: PATCH and FETCH Methods for the Constrained Application Protocol (CoAP)](https://rfc-editor.org/rfc/rfc8132)
|
||||
|
||||
* [RFC8323: CoAP (Constrained Application Protocol) over TCP, TLS, and WebSockets](https://rfc-editor.org/rfc/rfc8323)
|
||||
|
||||
* [RFC8516: "Too Many Requests" Response Code for the Constrained Application Protocol](https://rfc-editor.org/rfc/rfc8516)
|
||||
|
||||
* [RFC8613: Object Security for Constrained RESTful Environments (OSCORE)](https://rfc-editor.org/rfc/rfc8613)
|
||||
|
||||
* [RFC8768: Constrained Application Protocol (CoAP) Hop-Limit Option](https://rfc-editor.org/rfc/rfc8768)
|
||||
|
||||
* [RFC8974: Extended Tokens and Stateless Clients in the Constrained Application Protocol (CoAP)](https://rfc-editor.org/rfc/rfc8974)
|
||||
|
||||
* [RFC9175: CoAP: Echo, Request-Tag, and Token Processing](https://rfc-editor.org/rfc/rfc9175)
|
||||
|
||||
* [RFC9177: Constrained Application Protocol (CoAP) Block-Wise Transfer Options Supporting Robust Transmission](https://rfc-editor.org/rfc/rfc9177)
|
||||
|
||||
There is (D)TLS support for the following libraries
|
||||
|
||||
* [OpenSSL](https://www.openssl.org) (Minimum version 1.1.0) [PKI, PSK and PKCS11]
|
||||
|
||||
* [GnuTLS](https://www.gnutls.org) (Minimum version 3.3.0) [PKI, PSK, RPK(3.6.6+) and PKCS11]
|
||||
|
||||
* [Mbed TLS](https://www.trustedfirmware.org/projects/mbed-tls/) (Minimum version 2.7.10) [PKI and PSK]
|
||||
|
||||
* [wolfSSL](https://wolfssl.com) (Minimum version 5.2.0) [PKI, PSK, RPK(5.6.4+) and DTLS1.3(5.4.0+)]
|
||||
|
||||
* [TinyDTLS](https://github.com/eclipse/tinydtls) [PSK and RPK] [DTLS Only]
|
||||
|
||||
The examples directory contain a CoAP client, CoAP Resource Directory server
|
||||
and a CoAP server to demonstrate the use of this library.
|
||||
|
||||
BUILDING
|
||||
========
|
||||
|
||||
Further information can be found at <https://libcoap.net/install.html>
|
||||
and [BUILDING](https://raw.githubusercontent.com/obgm/libcoap/develop/BUILDING).
|
||||
|
||||
LICENSE INFORMATION
|
||||
===================
|
||||
|
||||
This library is published as open-source software without any warranty
|
||||
of any kind. Use is permitted under the terms of the simplified BSD
|
||||
license. It includes public domain software. libcoap binaries may also
|
||||
include open-source software with their respective licensing terms.
|
||||
Please refer to
|
||||
[LICENSE](https://raw.githubusercontent.com/obgm/libcoap/develop/LICENSE)
|
||||
for further details.
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
"Name": "libcoap: C-Implementation of CoAP",
|
||||
"License": "BSD 2-Clause License",
|
||||
"License File": "LICENSE",
|
||||
"Version Number": "4.3.4",
|
||||
"Version Number": "4.3.5",
|
||||
"Owner": "",
|
||||
"Upstream URL": "https://github.com/obgm/libcoap",
|
||||
"Description": "libcoap is a C implementation of a lightweight application-protocol for devices that are constrained their resources such as computing power, RF range, memory, bandwidth, or network packet sizes."
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
[](https://github.com/obgm/libcoap/actions/workflows/cifuzz.yml)
|
||||
[](https://github.com/pre-commit/pre-commit)
|
||||
|
||||
Copyright (C) 2010—2023 by Olaf Bergmann <bergmann@tzi.org> and others
|
||||
Copyright (C) 2010—2024 by Olaf Bergmann <bergmann@tzi.org> and others
|
||||
|
||||
ABOUT LIBCOAP
|
||||
=============
|
||||
@@ -73,6 +73,8 @@ There is (D)TLS support for the following libraries
|
||||
|
||||
* [Mbed TLS](https://www.trustedfirmware.org/projects/mbed-tls/) (Minimum version 2.7.10) [PKI and PSK]
|
||||
|
||||
* [wolfSSL](https://wolfssl.com) (Minimum version 5.2.0) [PKI, PSK, RPK(5.6.4+) and DTLS1.3(5.4.0+)]
|
||||
|
||||
* [TinyDTLS](https://github.com/eclipse/tinydtls) [PSK and RPK] [DTLS Only]
|
||||
|
||||
The examples directory contain a CoAP client, CoAP Resource Directory server
|
||||
@@ -94,4 +96,3 @@ include open-source software with their respective licensing terms.
|
||||
Please refer to
|
||||
[LICENSE](https://raw.githubusercontent.com/obgm/libcoap/develop/LICENSE)
|
||||
for further details.
|
||||
|
||||
|
||||
@@ -24,4 +24,3 @@ Classification of issues:
|
||||
* MINOR ISSUES
|
||||
==============
|
||||
-> Adding a logo for libcoap
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ depcomp
|
||||
doc/Doxyfile doc/doxyfile.stamp doc/doxygen_sqlite3.db doc/Makefile doc/Makefile.in
|
||||
examples/*.o examples/coap-client examples/coap-server examples/coap-rd
|
||||
examples/Makefile examples/Makefile.in
|
||||
include/coap3/coap.h
|
||||
install-sh
|
||||
libcoap-*.pc libtool ltmain.sh
|
||||
man/coap*.[357] man/coap*.txt man/Makefile man/Makefile.in
|
||||
|
||||
@@ -19,6 +19,7 @@ FROM debian:testing-slim
|
||||
RUN apt-get update && apt-get install -y autoconf automake gcc g++ gdb libtool libtool-bin make \
|
||||
pkg-config libssl-dev libgnutls28-dev libmbedtls-dev
|
||||
RUN apt-get install -y iproute2 lsof net-tools inetutils-ping netcat-openbsd less vim
|
||||
RUN apt-get install -y adduser
|
||||
RUN apt-get clean
|
||||
|
||||
COPY --from=0 /usr/local/include/coap3 /usr/local/include/coap3
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@ohos/libcoap",
|
||||
"description": "libcoap is a C implementation of a lightweight application-protocol.",
|
||||
"version": "4.3.4",
|
||||
"version": "4.3.5",
|
||||
"license": "BSD-2-Clause",
|
||||
"publishAs": "code-segment",
|
||||
"segment": {
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
# FindWolfSSL.cmake
|
||||
# -----------------
|
||||
#
|
||||
# Find the wolfSSL library.
|
||||
#
|
||||
# Imported Targets
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# This module defines the following :prop_tgt:`IMPORTED` targets:
|
||||
#
|
||||
# ``wolfssl``
|
||||
# The wolfSSL library, if found.
|
||||
#
|
||||
# Result Variables
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# This module will set the following variables in your project:
|
||||
#
|
||||
# ``wolfSSL_FOUND``
|
||||
# System has the wolfSSL library.
|
||||
# ``WOLFSSL_INCLUDE_DIR``
|
||||
# The wolfSSL include directory.
|
||||
# ``WOLFSSL_LIBRARIES``
|
||||
# All wolfSSL libraries.
|
||||
#
|
||||
# Hints
|
||||
# ^^^^^
|
||||
#
|
||||
# Set ``WOLFSSL_ROOT_DIR`` to the root directory of a wolfSSL installation.
|
||||
|
||||
if(WOLFSSL_ROOT_DIR)
|
||||
set(_WOLFSSL_EXTRA_FIND_ARGS "NO_CMAKE_FIND_ROOT_PATH")
|
||||
endif()
|
||||
|
||||
find_path(
|
||||
WOLFSSL_INCLUDE_DIR
|
||||
NAMES wolfssl/ssl.h
|
||||
PATH_SUFFIXES include
|
||||
HINTS ${PROJECT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${WOLFSSL_ROOT_DIR}
|
||||
${_WOLFSSL_EXTRA_FIND_ARGS})
|
||||
|
||||
find_library(
|
||||
WOLFSSL_LIBRARIES
|
||||
NAMES wolfssl
|
||||
PATH_SUFFIXES lib
|
||||
HINTS ${PROJECT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${WOLFSSL_ROOT_DIR}
|
||||
${_WOLFSSL_EXTRA_FIND_ARGS})
|
||||
|
||||
if(WOLFSSL_LIBRARIES)
|
||||
set(wolfSSL_FOUND TRUE)
|
||||
else()
|
||||
set(wolfSSL_FOUND FALSE)
|
||||
if(wolfSSL_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "wolfSSL could not be found")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
wolfSSL
|
||||
FOUND_VAR
|
||||
wolfSSL_FOUND
|
||||
REQUIRED_VARS
|
||||
WOLFSSL_INCLUDE_DIR
|
||||
WOLFSSL_LIBRARIES
|
||||
VERSION_VAR)
|
||||
|
||||
if(NOT TARGET wolfssl)
|
||||
add_library(
|
||||
wolfssl
|
||||
UNKNOWN
|
||||
IMPORTED)
|
||||
set_target_properties(
|
||||
wolfssl
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${WOLFSSL_INCLUDE_DIR}"
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${WOLFSSL_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
message(STATUS "WOLFSSL_INCLUDE_DIR: ${WOLFSSL_INCLUDE_DIR}")
|
||||
message(STATUS "WOLFSSL_LIBRARIES: ${WOLFSSL_LIBRARIES}")
|
||||
message(STATUS "WOLFSSL_ROOT_DIR: ${WOLFSSL_ROOT_DIR}")
|
||||
+42
-70
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* cmake_coap_config.h -- cmake configuration for libcoap
|
||||
*
|
||||
* Copyright (C) 2020 Carlos Gomes Martinho <carlos.gomes_martinho@siemens.com>
|
||||
* Copyright (C) 2021-2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
* Copyright (C) 2020 Carlos Gomes Martinho <carlos.gomes_martinho@siemens.com>
|
||||
* Copyright (C) 2021-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -17,53 +17,7 @@
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have <ws2tcpip.h> header file. */
|
||||
#cmakedefine HAVE_WS2TCPIP_H @HAVE_WS2TCPIP_H@
|
||||
|
||||
/* Define to 1 if the system has small stack size. */
|
||||
#cmakedefine COAP_CONSTRAINED_STACK @COAP_CONSTRAINED_STACK@
|
||||
|
||||
/* Define to 1 if you have <winsock2.h> header file. */
|
||||
#cmakedefine HAVE_WINSOCK2_H @HAVE_WINSOCK2_H@
|
||||
|
||||
/* Define to 1 if the library has client support. */
|
||||
#cmakedefine COAP_CLIENT_SUPPORT @COAP_CLIENT_SUPPORT@
|
||||
|
||||
/* Define to 1 if the library has server support. */
|
||||
#cmakedefine COAP_SERVER_SUPPORT @COAP_SERVER_SUPPORT@
|
||||
|
||||
/* Define to 1 if the library is to have observe persistence. */
|
||||
#cmakedefine COAP_WITH_OBSERVE_PERSIST @COAP_WITH_OBSERVE_PERSIST@
|
||||
|
||||
/* Define to 1 if the system has epoll support. */
|
||||
#cmakedefine COAP_EPOLL_SUPPORT @COAP_EPOLL_SUPPORT@
|
||||
|
||||
/* Define to 1 if the library has OSCORE support. */
|
||||
#cmakedefine COAP_OSCORE_SUPPORT @COAP_OSCORE_SUPPORT@
|
||||
|
||||
/* Define to 1 if the library has WebSockets support. */
|
||||
#cmakedefine COAP_WS_SUPPORT @COAP_WS_SUPPORT@
|
||||
|
||||
/* Define to 1 if the library has async separate response support. */
|
||||
#cmakedefine COAP_ASYNC_SUPPORT @COAP_ASYNC_SUPPORT@
|
||||
|
||||
/* Define to 0-8 for maximum logging level. */
|
||||
#cmakedefine COAP_MAX_LOGGING_LEVEL @COAP_MAX_LOGGING_LEVEL@
|
||||
|
||||
/* Define to 1 to build without TCP support. */
|
||||
#cmakedefine01 COAP_DISABLE_TCP
|
||||
|
||||
/* Define to 1 to build with IPv4 support. */
|
||||
#cmakedefine COAP_IPV4_SUPPORT @COAP_IPV4_SUPPORT@
|
||||
|
||||
/* Define to 1 to build with IPv6 support. */
|
||||
#cmakedefine COAP_IPV6_SUPPORT @COAP_IPV6_SUPPORT@
|
||||
|
||||
/* Define to 1 to build with Unix socket support. */
|
||||
#cmakedefine COAP_AF_UNIX_SUPPORT @COAP_AF_UNIX_SUPPORT@
|
||||
|
||||
/* Define to 1 to build with Q-Block (RFC 9177) support. */
|
||||
#cmakedefine COAP_Q_BLOCK_SUPPORT @COAP_Q_BLOCK_SUPPORT@
|
||||
#include <coap@LIBCOAP_API_VERSION@/coap_defines.h>
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#cmakedefine HAVE_ARPA_INET_H @HAVE_ARPA_INET_H@
|
||||
@@ -71,30 +25,36 @@
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#cmakedefine HAVE_ASSERT_H @HAVE_ASSERT_H@
|
||||
|
||||
/* Define to 1 if you have the <byteswap.h> header file. */
|
||||
#cmakedefine HAVE_BYTESWAP_H @HAVE_BYTESWAP_H@
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#cmakedefine HAVE_DLFCN_H @HAVE_DLFCN_H@
|
||||
|
||||
/* Define to 1 if you have the <sys/epoll.h> header file. */
|
||||
#cmakedefine HAVE_EPOLL_H @HAVE_EPOLL_H@
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#cmakedefine HAVE_ERRNO_H @HAVE_ERRNO_H@
|
||||
|
||||
/* Define to 1 if you have the <float.h> header file. */
|
||||
#cmakedefine HAVE_FLOAT_H @HAVE_FLOAT_H@
|
||||
|
||||
/* Define to 1 if you have the `getaddrinfo' function. */
|
||||
#cmakedefine HAVE_GETADDRINFO @HAVE_GETADDRINFO@
|
||||
|
||||
/* Define to 1 if you have the `getrandom' function. */
|
||||
#cmakedefine HAVE_GETRANDOM @HAVE_GETRANDOM@
|
||||
|
||||
/* Define to 1 if you have the <ifaddrs.h> header file. */
|
||||
#cmakedefine HAVE_IFADDRS_H @HAVE_IFADDRS_H@
|
||||
|
||||
/* Define to 1 if you have the `if_nametoindex' function. */
|
||||
#cmakedefine HAVE_IF_NAMETOINDEX @HAVE_IF_NAMETOINDEX@
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#cmakedefine HAVE_INTTYPES_H @HAVE_INTTYPES_H@
|
||||
|
||||
/* Define to 1 if you have the <erno.h> header file. */
|
||||
#cmakedefine HAVE_ERRNO_H @HAVE_ERRNO_H@
|
||||
|
||||
/* Define to 1 if the system has openssl */
|
||||
#cmakedefine COAP_WITH_LIBOPENSSL @COAP_WITH_LIBOPENSSL@
|
||||
|
||||
/* Define to 1 if the system has libgnutls28 */
|
||||
#cmakedefine COAP_WITH_LIBGNUTLS @COAP_WITH_LIBGNUTLS@
|
||||
|
||||
/* Define to 1 if the system has libtinydtls */
|
||||
#cmakedefine COAP_WITH_LIBTINYDTLS @COAP_WITH_LIBTINYDTLS@
|
||||
|
||||
/* Define to 1 if the system has libmbedtls */
|
||||
#cmakedefine COAP_WITH_LIBMBEDTLS @COAP_WITH_LIBMBEDTLS@
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#cmakedefine HAVE_LIMITS_H @HAVE_LIMITS_H@
|
||||
|
||||
@@ -107,9 +67,6 @@
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#cmakedefine HAVE_MEMSET @HAVE_MEMSET@
|
||||
|
||||
/* Define to 1 if you have the `if_nametoindex' function. */
|
||||
#cmakedefine HAVE_IF_NAMETOINDEX @HAVE_IF_NAMETOINDEX@
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#cmakedefine HAVE_NETDB_H @HAVE_NETDB_H@
|
||||
|
||||
@@ -131,6 +88,12 @@
|
||||
/* Define to 1 if you have the `socket' function. */
|
||||
#cmakedefine HAVE_SOCKET @HAVE_SOCKET@
|
||||
|
||||
/* Define to 1 if you have the <stdbool.h> header file. */
|
||||
#cmakedefine HAVE_STDBOOL_H @HAVE_STDBOOL_H@
|
||||
|
||||
/* Define to 1 if you have the <stddef.h> header file. */
|
||||
#cmakedefine HAVE_STDDEF_H @HAVE_STDDEF_H@
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#cmakedefine HAVE_STDINT_H @HAVE_STDINT_H@
|
||||
|
||||
@@ -152,9 +115,6 @@
|
||||
/* Define to 1 if you have the `strrchr' function. */
|
||||
#cmakedefine HAVE_STRRCHR @HAVE_STRRCHR@
|
||||
|
||||
/* Define to 1 if you have the `getrandom' function. */
|
||||
#cmakedefine HAVE_GETRANDOM @HAVE_GETRANDOM@
|
||||
|
||||
/* Define to 1 if you have the `randon' function. */
|
||||
#cmakedefine HAVE_RANDOM @HAVE_RANDOM@
|
||||
|
||||
@@ -170,6 +130,9 @@
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#cmakedefine HAVE_SYS_STAT_H @HAVE_SYS_STAT_H@
|
||||
|
||||
/* Define to 1 if you have the <sys/sysctl.h> header file. */
|
||||
#cmakedefine HAVE_SYS_SYSCTL_H @HAVE_SYS_SYSCTL_H@
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#cmakedefine HAVE_SYS_TIME_H @HAVE_SYS_TIME_H@
|
||||
|
||||
@@ -182,9 +145,18 @@
|
||||
/* Define to 1 if you have the <time.h> header file. */
|
||||
#cmakedefine HAVE_TIME_H @HAVE_TIME_H@
|
||||
|
||||
/* Define to 1 if you have the <sys/timerfd.h> header file. */
|
||||
#cmakedefine HAVE_TIMERFD_H @HAVE_TIMERFD_H@
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@
|
||||
|
||||
/* Define to 1 if you have <winsock2.h> header file. */
|
||||
#cmakedefine HAVE_WINSOCK2_H @HAVE_WINSOCK2_H@
|
||||
|
||||
/* Define to 1 if you have <ws2tcpip.h> header file. */
|
||||
#cmakedefine HAVE_WS2TCPIP_H @HAVE_WS2TCPIP_H@
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* cmake_coap_defines.h -- optional #defines used for building libcoap
|
||||
*
|
||||
* Copyright (C) 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.
|
||||
*/
|
||||
|
||||
#ifndef COAP_DEFINES_H_
|
||||
#define COAP_DEFINES_H_
|
||||
|
||||
/* Define to 1 to build with Unix socket support. */
|
||||
#cmakedefine COAP_AF_UNIX_SUPPORT @COAP_AF_UNIX_SUPPORT@
|
||||
|
||||
/* Define to 1 if the library has async separate response support. */
|
||||
#cmakedefine COAP_ASYNC_SUPPORT @COAP_ASYNC_SUPPORT@
|
||||
|
||||
/* Define to 1 if the library has client support. */
|
||||
#cmakedefine COAP_CLIENT_SUPPORT @COAP_CLIENT_SUPPORT@
|
||||
|
||||
/* Define to 1 if the system has small stack size. */
|
||||
#cmakedefine COAP_CONSTRAINED_STACK @COAP_CONSTRAINED_STACK@
|
||||
|
||||
/* Define to 1 to build without TCP support. */
|
||||
#cmakedefine01 COAP_DISABLE_TCP
|
||||
|
||||
/* Define to 1 if the system has epoll support. */
|
||||
#cmakedefine COAP_EPOLL_SUPPORT @COAP_EPOLL_SUPPORT@
|
||||
|
||||
/* Define to 1 to build with IPv4 support. */
|
||||
#cmakedefine COAP_IPV4_SUPPORT @COAP_IPV4_SUPPORT@
|
||||
|
||||
/* Define to 1 to build with IPv6 support. */
|
||||
#cmakedefine COAP_IPV6_SUPPORT @COAP_IPV6_SUPPORT@
|
||||
|
||||
/* Define to 0-8 for maximum logging level. */
|
||||
#cmakedefine COAP_MAX_LOGGING_LEVEL @COAP_MAX_LOGGING_LEVEL@
|
||||
|
||||
/* Define to 1 if the library has OSCORE support. */
|
||||
#cmakedefine COAP_OSCORE_SUPPORT @COAP_OSCORE_SUPPORT@
|
||||
|
||||
/* Define to 1 if the library has proxy support. */
|
||||
#cmakedefine COAP_PROXY_SUPPORT @COAP_PROXY_SUPPORT@
|
||||
|
||||
/* Define to 1 to build with Q-Block (RFC 9177) support. */
|
||||
#cmakedefine COAP_Q_BLOCK_SUPPORT @COAP_Q_BLOCK_SUPPORT@
|
||||
|
||||
/* Define to 1 if the library has server support. */
|
||||
#cmakedefine COAP_SERVER_SUPPORT @COAP_SERVER_SUPPORT@
|
||||
|
||||
/* Define to 1 if the library has thread deadlock detection support. */
|
||||
#cmakedefine COAP_THREAD_RECURSIVE_CHECK @COAP_THREAD_RECURSIVE_CHECK@
|
||||
|
||||
/* Define to 1 if the library has thread safe support. */
|
||||
#cmakedefine COAP_THREAD_SAFE @COAP_THREAD_SAFE@
|
||||
|
||||
/* Define to 1 if the system has libgnutls28 */
|
||||
#cmakedefine COAP_WITH_LIBGNUTLS @COAP_WITH_LIBGNUTLS@
|
||||
|
||||
/* Define to 1 if the system has libmbedtls */
|
||||
#cmakedefine COAP_WITH_LIBMBEDTLS @COAP_WITH_LIBMBEDTLS@
|
||||
|
||||
/* Define to 1 if the system has openssl */
|
||||
#cmakedefine COAP_WITH_LIBOPENSSL @COAP_WITH_LIBOPENSSL@
|
||||
|
||||
/* Define to 1 if the system has libtinydtls */
|
||||
#cmakedefine COAP_WITH_LIBTINYDTLS @COAP_WITH_LIBTINYDTLS@
|
||||
|
||||
/* Define to 1 if the system has wolfSSL */
|
||||
#cmakedefine COAP_WITH_LIBWOLFSSL @COAP_WITH_LIBWOLFSSL@
|
||||
|
||||
/* Define to 1 if the library is to have observe persistence. */
|
||||
#cmakedefine COAP_WITH_OBSERVE_PERSIST @COAP_WITH_OBSERVE_PERSIST@
|
||||
|
||||
/* Define to 1 if the library has WebSockets support. */
|
||||
#cmakedefine COAP_WS_SUPPORT @COAP_WS_SUPPORT@
|
||||
|
||||
#endif /* COAP_DEFINES_H_ */
|
||||
+36
-2
@@ -1,3 +1,14 @@
|
||||
/*
|
||||
* coap_config.h.contiki -- Contiki configuration for libcoap
|
||||
*
|
||||
* Copyright (C) 2021-2024 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*/
|
||||
|
||||
#ifndef COAP_CONFIG_H_
|
||||
#define COAP_CONFIG_H_
|
||||
|
||||
@@ -7,6 +18,11 @@
|
||||
/* Define to 1 if libcoap supports server mode code. */
|
||||
#define COAP_SERVER_SUPPORT 1
|
||||
|
||||
#if COAP_CLIENT_SUPPORT && COAP_SERVER_SUPPORT
|
||||
/* Define to 1 if libcoap supports proxy code. */
|
||||
#define COAP_PROXY_SUPPORT 1
|
||||
#endif /* COAP_CLIENT_SUPPORT && COAP_SERVER_SUPPORT */
|
||||
|
||||
/* Define to 1 if the system has small stack size. */
|
||||
#define COAP_CONSTRAINED_STACK 1
|
||||
|
||||
@@ -34,6 +50,12 @@
|
||||
/* Define to 1 to build with Q-Block (RFC9177) support. */
|
||||
/* #undef COAP_Q_BLOCK_SUPPORT 1 */
|
||||
|
||||
/* Define to 1 to build with thread recursive lock detection support. */
|
||||
/* #undef COAP_THREAD_RECURSIVE_CHECK 1 */
|
||||
|
||||
/* Define to 1 if libcoap has thread safe support. */
|
||||
/* #undef COAP_THREAD_SAFE 1 */
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#define HAVE_ASSERT_H 1
|
||||
|
||||
@@ -76,23 +98,35 @@
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#define HAVE_SNPRINTF 1
|
||||
|
||||
#ifndef PACKAGE_BUGREPORT
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "libcoap-developers@lists.sourceforge.net"
|
||||
#endif /* PACKAGE_BUGREPORT */
|
||||
|
||||
#ifndef PACKAGE_NAME
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "libcoap"
|
||||
#endif /* PACKAGE_NAME */
|
||||
|
||||
#ifndef PACKAGE_STRING
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "libcoap 4.3.4"
|
||||
#define PACKAGE_STRING "libcoap 4.3.5"
|
||||
#endif /* PACKAGE_STRING */
|
||||
|
||||
#ifndef PACKAGE_TARNAME
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "libcoap"
|
||||
#endif /* PACKAGE_TARNAME */
|
||||
|
||||
#ifndef PACKAGE_URL
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL "https://libcoap.net/"
|
||||
#endif /* PACKAGE_URL */
|
||||
|
||||
#ifndef PACKAGE_VERSION
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "4.3.4"
|
||||
#define PACKAGE_VERSION "4.3.5"
|
||||
#endif /* PACKAGE_VERSION */
|
||||
|
||||
#define WITH_CONTIKI 1
|
||||
|
||||
|
||||
+79
-12
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* coap_config.h.riot -- RIOT configuration for libcoap
|
||||
*
|
||||
* Copyright (C) 2021-2023 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
* Copyright (C) 2021-2024 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -18,12 +18,33 @@
|
||||
#define COAP_CONSTRAINED_STACK 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* For systems that define int as being 2 bytes, need to make sure the
|
||||
* minimum configuration is set up (overridden if explicitely defined).
|
||||
*/
|
||||
#include <limits.h>
|
||||
|
||||
#if (UINT_MAX <= 65535)
|
||||
#define COAP_DISABLE_TCP 1
|
||||
#define COAP_AF_UNIX_SUPPORT 0
|
||||
#define COAP_OSCORE_SUPPORT 0
|
||||
#define COAP_WITH_OBSERVE_PERSIST 0
|
||||
#define COAP_WS_SUPPORT 0
|
||||
#define COAP_Q_BLOCK_SUPPORT 0
|
||||
#define COAP_MAX_LOGGING_LEVEL 0
|
||||
#endif /* UINT_MAX < 65536 */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_LOGGING_LEVEL
|
||||
#ifndef COAP_MAX_LOGGING_LEVEL
|
||||
/* Define to 1 to build without TCP support. */
|
||||
/* Define 0-8 for max logging levels. */
|
||||
#define COAP_MAX_LOGGING_LEVEL CONFIG_LIBCOAP_MAX_LOGGING_LEVEL
|
||||
#endif /* COAP_MAX_LOGGING_LEVEL */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_LOGGING_LEVEL */
|
||||
#else /* ! CONFIG_LIBCOAP_MAX_LOGGING_LEVEL */
|
||||
#ifndef COAP_MAX_LOGGING_LEVEL
|
||||
/* Define 0-8 for max logging levels. */
|
||||
#define COAP_MAX_LOGGING_LEVEL 4
|
||||
#endif /* COAP_MAX_LOGGING_LEVEL */
|
||||
#endif /* ! CONFIG_LIBCOAP_MAX_LOGGING_LEVEL */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_IPV4_SUPPORT
|
||||
#ifndef COAP_IPV4_SUPPORT
|
||||
@@ -51,7 +72,12 @@
|
||||
/* Define to 1 to build without TCP support. */
|
||||
#define COAP_DISABLE_TCP 0
|
||||
#endif /* COAP_DISABLE_TCP */
|
||||
#endif /* CONFIG_LIBCOAP_TCP_SUPPORT */
|
||||
#else /* ! CONFIG_LIBCOAP_TCP_SUPPORT */
|
||||
#ifndef COAP_DISABLE_TCP
|
||||
/* Define to 1 to build without TCP support. */
|
||||
#define COAP_DISABLE_TCP 1
|
||||
#endif /* ! COAP_DISABLE_TCP */
|
||||
#endif /* ! CONFIG_LIBCOAP_TCP_SUPPORT */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_OSCORE_SUPPORT
|
||||
#ifndef COAP_OSCORE_SUPPORT
|
||||
@@ -95,6 +121,15 @@
|
||||
#endif /* COAP_SERVER_SUPPORT */
|
||||
#endif /* CONFIG_LIBCOAP_SERVER_SUPPORT */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_PROXY_SUPPORT
|
||||
#if COAP_CLIENT_SUPPORT && COAP_SERVER_SUPPORT
|
||||
#ifndef COAP_PROXY_SUPPORT
|
||||
/* Define to 1 if the library has proxy code support. */
|
||||
#define COAP_PROXY_SUPPORT 1
|
||||
#endif /* COAP_CLIENT_SUPPORT && COAP_SERVER_SUPPORT */
|
||||
#endif /* COAP_PROXY_SUPPORT */
|
||||
#endif /* CONFIG_LIBCOAP_PROXY_SUPPORT */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_ASYNC_SUPPORT
|
||||
#ifndef COAP_ASYNC_SUPPORT
|
||||
/* Define to 1 to build with support for async separate responses. */
|
||||
@@ -102,6 +137,20 @@
|
||||
#endif /* COAP_ASYNC_SUPPORT */
|
||||
#endif /* CONFIG_LIBCOAP_ASYNC_SUPPORT */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_THREAD_SAFE
|
||||
#ifndef COAP_THREAD_SAFE
|
||||
/* Define to 1 if libcoap has thread safe support. */
|
||||
#define COAP_THREAD_SAFE 1
|
||||
#endif /* COAP_THREAD_SAFE */
|
||||
#endif /* CONFIG_LIBCOAP_THREAD_SAFE */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_THREAD_RECURSIVE_CHECK
|
||||
#ifndef COAP_THREAD_RECURSIVE_CHECK
|
||||
/* Define to 1 to build with thread recursive lock detection support. */
|
||||
#define COAP_THREAD_RECURSIVE_CHECK 1
|
||||
#endif /* COAP_THREAD_RECURSIVE_CHECK */
|
||||
#endif /* CONFIG_LIBCOAP_THREAD_RECURSIVE_CHECK */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_STRING_SIZE
|
||||
#ifndef COAP_MAX_STRING_SIZE
|
||||
#define COAP_MAX_STRING_SIZE CONFIG_LIBCOAP_MAX_STRING_SIZE
|
||||
@@ -228,7 +277,7 @@
|
||||
/* #undef AC_APPLE_UNIVERSAL_BUILD */
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
/* #undef HAVE_ARPA_INET_H */
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#define HAVE_ASSERT_H 1
|
||||
@@ -256,13 +305,13 @@
|
||||
/* #undef HAVE_NETDB_H */
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
/* #define HAVE_NETINET_IN_H */
|
||||
|
||||
/* Define to 1 if you have the `select' function. */
|
||||
/* #undef HAVE_SELECT */
|
||||
|
||||
/* Define to 1 if you have the `socket' function. */
|
||||
#define HAVE_SOCKET 1
|
||||
/* #undef HAVE_SOCKET */
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
@@ -286,7 +335,7 @@
|
||||
#define HAVE_STRRCHR 1
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
/* #undef HAVE_SYS_SOCKET_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
/* #undef HAVE_SYS_STAT_H */
|
||||
@@ -306,17 +355,35 @@
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
#ifndef PACKAGE_BUGREPORT
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "libcoap-developers@lists.sourceforge.net"
|
||||
#endif /* PACKAGE_BUGREPORT */
|
||||
|
||||
#ifndef PACKAGE_NAME
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "libcoap"
|
||||
#endif /* PACKAGE_NAME */
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "4.3.4"
|
||||
|
||||
#ifndef PACKAGE_STRING
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "libcoap 4.3.4"
|
||||
#define PACKAGE_STRING "libcoap 4.3.5"
|
||||
#endif /* PACKAGE_STRING */
|
||||
|
||||
#ifndef PACKAGE_TARNAME
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "libcoap"
|
||||
#endif /* PACKAGE_TARNAME */
|
||||
|
||||
#ifndef PACKAGE_URL
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL "https://libcoap.net/"
|
||||
#endif /* PACKAGE_URL */
|
||||
|
||||
#ifndef PACKAGE_VERSION
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "4.3.5"
|
||||
#endif /* PACKAGE_VERSION */
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
@@ -1,345 +0,0 @@
|
||||
/*
|
||||
* coap_config.h.riot -- RIOT configuration for libcoap
|
||||
*
|
||||
* Copyright (C) 2021-2023 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*/
|
||||
|
||||
#ifndef COAP_CONFIG_H_
|
||||
#define COAP_CONFIG_H_
|
||||
|
||||
#define WITH_POSIX 1
|
||||
|
||||
#ifndef COAP_CONSTRAINED_STACK
|
||||
#define COAP_CONSTRAINED_STACK 1
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_LOGGING_LEVEL
|
||||
#ifndef COAP_MAX_LOGGING_LEVEL
|
||||
/* Define to 1 to build without TCP support. */
|
||||
#define COAP_MAX_LOGGING_LEVEL CONFIG_LIBCOAP_MAX_LOGGING_LEVEL
|
||||
#endif /* COAP_MAX_LOGGING_LEVEL */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_LOGGING_LEVEL */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_IPV4_SUPPORT
|
||||
#ifndef COAP_IPV4_SUPPORT
|
||||
/* Define to 1 to build with IPv4 support. */
|
||||
#define COAP_IPV4_SUPPORT 1
|
||||
#endif /* COAP_IPV4_SUPPORT */
|
||||
#endif /* CONFIG_LIBCOAP_IPV4_SUPPORT */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_IPV6_SUPPORT
|
||||
#ifndef COAP_IPV6_SUPPORT
|
||||
/* Define to 1 to build with IPv6 support. */
|
||||
#define COAP_IPV6_SUPPORT 1
|
||||
#endif /* COAP_IPV6_SUPPORT */
|
||||
#endif /* CONFIG_LIBCOAP_IPV6_SUPPORT */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_AF_UNIX_SUPPORT
|
||||
#ifndef COAP_AF_UNIX_SUPPORT
|
||||
/* Define to 1 to build with Unix socket support. */
|
||||
#define COAP_AF_UNIX_SUPPORT 1
|
||||
#endif /* COAP_AF_UNIX_SUPPORT */
|
||||
#endif /* CONFIG_LIBCOAP_AF_UNIX_SUPPORT */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_TCP_SUPPORT
|
||||
#ifndef COAP_DISABLE_TCP
|
||||
/* Define to 1 to build without TCP support. */
|
||||
#define COAP_DISABLE_TCP 0
|
||||
#endif /* COAP_DISABLE_TCP */
|
||||
#endif /* CONFIG_LIBCOAP_TCP_SUPPORT */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_OSCORE_SUPPORT
|
||||
#ifndef COAP_OSCORE_SUPPORT
|
||||
/* Define to 1 if the library has OSCORE support. */
|
||||
#define COAP_OSCORE_SUPPORT 1
|
||||
#endif /* COAP_OSCORE_SUPPORT */
|
||||
#endif /* CONFIG_LIBCOAP_OSCORE_SUPPORT */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_WITH_OBSERVE_PERSIST
|
||||
#ifndef COAP_WITH_OBSERVE_PERSIST
|
||||
/* Define to 1 if the library has Observe persist support. */
|
||||
#define COAP_WITH_OBSERVE_PERSIST 0
|
||||
#endif /* COAP_WITH_OBSERVE_PERSIST */
|
||||
#endif /* CONFIG_LIBCOAP_WITH_OBSERVE_PERSIST */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_WS_SUPPORT
|
||||
#ifndef COAP_WS_SUPPORT
|
||||
/* Define to 1 if the library has WebSockets support. */
|
||||
#define COAP_WS_SUPPORT 0
|
||||
#endif /* COAP_WS_SUPPORT */
|
||||
#endif /* CONFIG_LIBCOAP_WS_SUPPORT */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_Q_BLOCK_SUPPORT
|
||||
#ifndef COAP_Q_BLOCK_SUPPORT
|
||||
/* Define to 1 to build with Q-Block (RFC9177) support. */
|
||||
#define COAP_Q_BLOCK_SUPPORT 0
|
||||
#endif /* COAP_Q_BLOCK_SUPPORT */
|
||||
#endif /* CONFIG_LIBCOAP_Q_BLOCK_SUPPORT */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_CLIENT_SUPPORT
|
||||
#ifndef COAP_CLIENT_SUPPORT
|
||||
/* Define to 1 if the library has client support. */
|
||||
#define COAP_CLIENT_SUPPORT 1
|
||||
#endif /* COAP_CLIENT_SUPPORT */
|
||||
#endif /* CONFIG_LIBCOAP_CLIENT_SUPPORT */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_SERVER_SUPPORT
|
||||
#ifndef COAP_SERVER_SUPPORT
|
||||
/* Define to 1 if the library has server support. */
|
||||
#define COAP_SERVER_SUPPORT 1
|
||||
#endif /* COAP_SERVER_SUPPORT */
|
||||
#endif /* CONFIG_LIBCOAP_SERVER_SUPPORT */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_ASYNC_SUPPORT
|
||||
#ifndef COAP_ASYNC_SUPPORT
|
||||
/* Define to 1 to build with support for async separate responses. */
|
||||
#define COAP_ASYNC_SUPPORT 1
|
||||
#endif /* COAP_ASYNC_SUPPORT */
|
||||
#endif /* CONFIG_LIBCOAP_ASYNC_SUPPORT */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_STRING_SIZE
|
||||
#ifndef COAP_MAX_STRING_SIZE
|
||||
#define COAP_MAX_STRING_SIZE CONFIG_LIBCOAP_MAX_STRING_SIZE
|
||||
#endif /* COAP_MAX_STRING_SIZE */
|
||||
#endif /* CONFIG_LIBCOAP_OSCORE_SUPPORT */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_ENDPOINTS
|
||||
#ifndef COAP_MAX_ENDPOINTS
|
||||
#define COAP_MAX_ENDPOINTS CONFIG_LIBCOAP_MAX_ENDPOINTS
|
||||
#endif /* COAP_MAX_ENDPOINTS */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_ENDPOINTS */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_RESOURCES
|
||||
#ifndef COAP_MAX_RESOURCES
|
||||
#define COAP_MAX_RESOURCES CONFIG_LIBCOAP_MAX_RESOURCES
|
||||
#endif /* COAP_MAX_RESOURCES */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_RESOURCES */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_ATTRIBUTE_SIZE
|
||||
#ifndef COAP_MAX_ATTRIBUTE_SIZE
|
||||
#define COAP_MAX_ATTRIBUTE_SIZE CONFIG_LIBCOAP_MAX_ATTRIBUTE_SIZE
|
||||
#endif /* COAP_MAX_ATTRIBUTE_SIZE */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_ATTRIBUTE_SIZE */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_ATTRIBUTES
|
||||
#ifndef COAP_MAX_ATTRIBUTES
|
||||
#define COAP_MAX_ATTRIBUTES CONFIG_LIBCOAP_MAX_ATTRIBUTES
|
||||
#endif /* COAP_MAX_ATTRIBUTES */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_ATTRIBUTES */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_PACKETS
|
||||
#ifndef COAP_MAX_PACKETS
|
||||
#define COAP_MAX_PACKETS CONFIG_LIBCOAP_MAX_PACKETS
|
||||
#endif /* COAP_MAX_PACKETS */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_PACKETS */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_NODES
|
||||
#ifndef COAP_MAX_NODES
|
||||
#define COAP_MAX_NODES CONFIG_LIBCOAP_MAX_NODES
|
||||
#endif /* COAP_MAX_NODES */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_NODES */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_CONTEXTS
|
||||
#ifndef COAP_MAX_CONTEXTS
|
||||
#define COAP_MAX_CONTEXTS CONFIG_LIBCOAP_MAX_CONTEXTS
|
||||
#endif /* COAP_MAX_CONTEXTS */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_CONTEXTS */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_PDUS
|
||||
#ifndef COAP_MAX_PDUS
|
||||
#define COAP_MAX_PDUS CONFIG_LIBCOAP_MAX_PDUS
|
||||
#endif /* COAP_MAX_PDUS */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_PDUS */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_DTLS_SESSIONS
|
||||
#ifndef COAP_MAX_DTLS_SESSIONS
|
||||
#define COAP_MAX_DTLS_SESSIONS CONFIG_LIBCOAP_MAX_DTLS_SESSIONS
|
||||
#endif /* COAP_MAX_DTLS_SESSIONS */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_DTLS_SESSIONS */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_SESSIONS
|
||||
#ifndef COAP_MAX_SESSIONS
|
||||
#define COAP_MAX_SESSIONS CONFIG_LIBCOAP_MAX_SESSIONS
|
||||
#endif /* COAP_MAX_SESSIONS */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_SESSIONS */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_OPTION_SIZE
|
||||
#ifndef COAP_MAX_OPTION_SIZE
|
||||
#define COAP_MAX_OPTION_SIZE CONFIG_LIBCOAP_MAX_OPTION_SIZE
|
||||
#endif /* COAP_MAX_OPTION_SIZE */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_OPTION_SIZE */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_OPTIONS
|
||||
#ifndef COAP_MAX_OPTIONS
|
||||
#define COAP_MAX_OPTIONS CONFIG_LIBCOAP_MAX_OPTIONS
|
||||
#endif /* COAP_MAX_OPTIONS */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_OPTIONS */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_CACHE_KEYS
|
||||
#ifndef COAP_MAX_CACHE_KEYS
|
||||
#define COAP_MAX_CACHE_KEYS CONFIG_LIBCOAP_MAX_CACHE_KEYS
|
||||
#endif /* COAP_MAX_CACHE_KEYS */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_CACHE_KEYS */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_CACHE_ENTRIES
|
||||
#ifndef COAP_MAX_CACHE_ENTRIES
|
||||
#define COAP_MAX_CACHE_ENTRIES CONFIG_LIBCOAP_MAX_CACHE_ENTRIES
|
||||
#endif /* COAP_MAX_CACHE_ENTRIES */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_CACHE_ENTRIES */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_LG_CRCVS
|
||||
#ifndef COAP_MAX_LG_CRCVS
|
||||
#define COAP_MAX_LG_CRCVS CONFIG_LIBCOAP_MAX_LG_CRCVS
|
||||
#endif /* COAP_MAX_LG_CRCVS */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_LG_CRCVS */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_LG_SRCVS
|
||||
#ifndef COAP_MAX_LG_SRCVS
|
||||
#define COAP_MAX_LG_SRCVS CONFIG_LIBCOAP_MAX_LG_SRCVS
|
||||
#endif /* COAP_MAX_LG_SRCVS */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_LG_SRCVS */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_MAX_LG_XMITS
|
||||
#ifndef COAP_MAX_LG_XMITS
|
||||
#define COAP_MAX_LG_XMITS CONFIG_LIBCOAP_MAX_LG_XMITS
|
||||
#endif /* COAP_MAX_LG_XMITS */
|
||||
#endif /* CONFIG_LIBCOAP_MAX_LG_XMITS */
|
||||
|
||||
#ifndef COAP_DISABLE_TCP
|
||||
#if MODULE_SOCK_TCP
|
||||
#define COAP_DISABLE_TCP 0
|
||||
#else /* ! MODULE_SOCK_TCP */
|
||||
#define COAP_DISABLE_TCP 1
|
||||
#endif /* ! MODULE_SOCK_TCP */
|
||||
#endif /* COAP_DISABLE_TCP */
|
||||
|
||||
#ifdef MODULE_TINYDTLS
|
||||
#ifndef COAP_WITH_LIBTINYDTLS
|
||||
#define COAP_WITH_LIBTINYDTLS 1
|
||||
#endif /* ! COAP_WITH_LIBTINYDTLS */
|
||||
#endif /* MODULE_TINYDTLS */
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
/* #undef AC_APPLE_UNIVERSAL_BUILD */
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#define HAVE_ASSERT_H 1
|
||||
|
||||
/* Define to 1 if you have the `getaddrinfo' function. */
|
||||
/* #undef HAVE_GETADDRINFO */
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
/* #undef HAVE_LIMITS_H */
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
|
||||
to 0 otherwise. */
|
||||
#undef HAVE_MALLOC
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
/* #undef HAVE_MEMORY_H */
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
/* #undef HAVE_NETDB_H */
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the `select' function. */
|
||||
/* #undef HAVE_SELECT */
|
||||
|
||||
/* Define to 1 if you have the `socket' function. */
|
||||
#define HAVE_SOCKET 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the `strcasecmp' function. */
|
||||
#define HAVE_STRCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the `strnlen' function. */
|
||||
#define HAVE_STRNLEN 1
|
||||
|
||||
/* Define to 1 if you have the `strrchr' function. */
|
||||
#define HAVE_STRRCHR 1
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
/* #undef HAVE_SYS_STAT_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/unistd.h> header file. */
|
||||
#define HAVE_SYS_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the <time.h> header file. */
|
||||
#define HAVE_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "@PACKAGE_NAME@"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "@PACKAGE_VERSION@"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "@PACKAGE_STRING@"
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
/* # undef WORDS_BIGENDIAN */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Define to rpl_malloc if the replacement function should be used. */
|
||||
/* #undef malloc */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
/* #undef ssize_t */
|
||||
|
||||
#endif /* COAP_CONFIG_H_ */
|
||||
+32
-3
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* coap_config.h.windows -- Windows configuration for libcoap
|
||||
*
|
||||
* Copyright (C) 2017-2023 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
* Copyright (C) 2017-2024 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -108,6 +108,13 @@
|
||||
#define COAP_SERVER_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#if COAP_CLIENT_SUPPORT && COAP_SERVER_SUPPORT
|
||||
#ifndef COAP_PROXY_SUPPORT
|
||||
/* Define if libcoap supports proxy code. */
|
||||
#define COAP_PROXY_SUPPORT 1
|
||||
#endif
|
||||
#endif /* COAP_CLIENT_SUPPORT && COAP_SERVER_SUPPORT */
|
||||
|
||||
#ifndef COAP_WITH_OBSERVE_PERSIST
|
||||
/* Define to build support for persisting observes. */
|
||||
#define COAP_WITH_OBSERVE_PERSIST 0
|
||||
@@ -138,23 +145,45 @@
|
||||
#define COAP_ASYNC_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#ifndef COAP_THREAD_SAFE
|
||||
/* Define to 1 if libcoap has thread safe support. */
|
||||
#define COAP_THREAD_SAFE 0
|
||||
#endif
|
||||
|
||||
#ifndef COAP_THREAD_RECURSIVE_CHECK
|
||||
/* Define to 1 to build with thread recursive lock detection support. */
|
||||
#define COAP_THREAD_RECURSIVE_CHECK 0
|
||||
#endif
|
||||
|
||||
#ifndef PACKAGE_BUGREPORT
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "libcoap-developers@lists.sourceforge.net"
|
||||
#endif /* PACKAGE_BUGREPORT */
|
||||
|
||||
#ifndef PACKAGE_NAME
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "libcoap"
|
||||
#endif /* PACKAGE_NAME */
|
||||
|
||||
#ifndef PACKAGE_STRING
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "libcoap 4.3.4"
|
||||
#define PACKAGE_STRING "libcoap 4.3.5"
|
||||
#endif /* PACKAGE_STRING */
|
||||
|
||||
#ifndef PACKAGE_TARNAME
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "libcoap"
|
||||
#endif /* PACKAGE_TARNAME */
|
||||
|
||||
#ifndef PACKAGE_URL
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL "https://libcoap.net/"
|
||||
#endif /* PACKAGE_URL */
|
||||
|
||||
#ifndef PACKAGE_VERSION
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "4.3.4"
|
||||
#define PACKAGE_VERSION "4.3.5"
|
||||
#endif /* PACKAGE_VERSION */
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
/*
|
||||
* coap_config.h.windows -- Windows configuration for libcoap
|
||||
*
|
||||
* Copyright (C) 2017-2023 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*/
|
||||
|
||||
#ifndef COAP_CONFIG_H_
|
||||
#define COAP_CONFIG_H_
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
/* Define to 1 if you have <ws2tcpip.h> header file. */
|
||||
#define HAVE_WS2TCPIP_H 1
|
||||
|
||||
/* Define to 1 if you have <winsock2.h> header file. */
|
||||
#define HAVE_WINSOCK2_H 1
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#define HAVE_ASSERT_H 1
|
||||
|
||||
/* Define to 1 if you have the `getaddrinfo' function. */
|
||||
#define HAVE_GETADDRINFO 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define to 1 if you have the `malloc' function. */
|
||||
#define HAVE_MALLOC 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* Define to 1 if you have the `select' function. */
|
||||
#define HAVE_SELECT 1
|
||||
|
||||
/* Define to 1 if you have the `socket' function. */
|
||||
#define HAVE_SOCKET 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the `strnlen' function. */
|
||||
#define HAVE_STRNLEN 1
|
||||
|
||||
/* Define to 1 if you have the `strrchr' function. */
|
||||
#define HAVE_STRRCHR 1
|
||||
|
||||
/* Define to 1 if the system has the type `struct cmsghdr'. */
|
||||
#define HAVE_STRUCT_CMSGHDR 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <time.h> header file. */
|
||||
#define HAVE_TIME_H 1
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1900) && !defined(snprintf)
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#ifndef COAP_DISABLE_TCP
|
||||
/* Define to 1 to build without TCP support. */
|
||||
#define COAP_DISABLE_TCP 0
|
||||
#endif
|
||||
|
||||
#ifndef COAP_IPV4_SUPPORT
|
||||
/* Define to 1 to build with IPv4 support. */
|
||||
#define COAP_IPV4_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#ifndef COAP_IPV6_SUPPORT
|
||||
/* Define to 1 to build with IPv6 support. */
|
||||
#define COAP_IPV6_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#ifndef COAP_AF_UNIX_SUPPORT
|
||||
/* Define to 1 to build with Unix socket support. */
|
||||
#define COAP_AF_UNIX_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#ifndef COAP_CLIENT_SUPPORT
|
||||
/* Define if libcoap supports client mode code. */
|
||||
#define COAP_CLIENT_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#ifndef COAP_SERVER_SUPPORT
|
||||
/* Define if libcoap supports server mode code. */
|
||||
#define COAP_SERVER_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#ifndef COAP_WITH_OBSERVE_PERSIST
|
||||
/* Define to build support for persisting observes. */
|
||||
#define COAP_WITH_OBSERVE_PERSIST 0
|
||||
#endif
|
||||
|
||||
#ifndef COAP_WS_SUPPORT
|
||||
/* Define to 1 to build with WebSockets support. */
|
||||
#define COAP_WS_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#ifndef COAP_Q_BLOCK_SUPPORT
|
||||
/* Define to 1 to build with Q-Block (RFC9177) support. */
|
||||
#define COAP_Q_BLOCK_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#ifndef COAP_MAX_LOGGING_LEVEL
|
||||
/* Define to 0-8 for maximum logging level. */
|
||||
#define COAP_MAX_LOGGING_LEVEL 8
|
||||
#endif
|
||||
|
||||
#ifndef COAP_OSCORE_SUPPORT
|
||||
/* Define to 1 to build with OSCORE support. */
|
||||
#define COAP_OSCORE_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#ifndef COAP_ASYNC_SUPPORT
|
||||
/* Define to 1 to build with support for async separate responses. */
|
||||
#define COAP_ASYNC_SUPPORT 1
|
||||
#endif
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "@PACKAGE_NAME@"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "@PACKAGE_STRING@"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "@PACKAGE_TARNAME@"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL "@PACKAGE_URL@"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "@PACKAGE_VERSION@"
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
/* # undef WORDS_BIGENDIAN */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Define this to 1 for ancillary data on MacOS */
|
||||
/* #undef __APPLE_USE_RFC_3542 */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
/* #undef ssize_t */
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* COAP_CONFIG_H_ */
|
||||
+274
-46
@@ -1,8 +1,8 @@
|
||||
# configure.ac for the libcoap package
|
||||
#
|
||||
# Copyright (C) 2010-2023 Olaf Bergmann <bergmann@tzi.org>
|
||||
# Copyright (C) 2010-2024 Olaf Bergmann <bergmann@tzi.org>
|
||||
# Copyright (C) 2015-2018 Carsten Schoenert <c.schoenert@t-online.de>
|
||||
# Copyright (C) 2018-2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
# Copyright (C) 2018-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
@@ -15,12 +15,19 @@
|
||||
# defined later.
|
||||
m4_define([libcoap_major_version], [4])
|
||||
m4_define([libcoap_minor_version], [3])
|
||||
m4_define([libcoap_micro_version], [4])
|
||||
m4_define([libcoap_micro_version], [5])
|
||||
|
||||
# define an appending release state if needed, for example for pre-releases
|
||||
# like 'alpha' or 'rc1', for a full release keep the value empty!
|
||||
m4_define([libcoap_release_state], [])
|
||||
|
||||
# Define the previous full libcoap software release version here.
|
||||
# Used if libcoap_release_state is not empty for LIBCOAP_VERSION and LIBCOAP_PACKAGE_BASE.
|
||||
# Set to libcoap software version when libcoap_release_state is reset to empty.
|
||||
m4_define([libcoap_pre_major_version], [4])
|
||||
m4_define([libcoap_pre_minor_version], [3])
|
||||
m4_define([libcoap_pre_micro_version], [4])
|
||||
|
||||
# concatenate the full libcoap version string
|
||||
m4_define([libcoap_version], [m4_format([%s.%s.%s%s], libcoap_major_version, libcoap_minor_version, libcoap_micro_version, libcoap_release_state)])
|
||||
|
||||
@@ -71,7 +78,7 @@ LT_INIT([shared static])
|
||||
# 'revision' (short 'r') = 0
|
||||
# 'age' (short 'a') = 0
|
||||
#
|
||||
# Update the libtool versioning only after the release of a public release of libcoap.
|
||||
# Update the libtool versioning only just before the release of a public release of libcoap.
|
||||
# Go through the following checklist from top to bottom and check your needs, following
|
||||
# the reminded changes if you can say "Yes" for specific check.
|
||||
#
|
||||
@@ -140,13 +147,13 @@ LT_INIT([shared static])
|
||||
#
|
||||
# CAUTION
|
||||
#
|
||||
# You will need to manually update VERSION and LIBCOAP_ABI_VERSION in CMakeLists.txt
|
||||
# if changes are made to libcoap_xx_version and LT_LIBCOAP_xx respectively.
|
||||
# You will need to manually update various configuration files by running the
|
||||
# ./configure built script file scripts/fix_version.sh .
|
||||
#
|
||||
|
||||
LT_LIBCOAP_CURRENT=4
|
||||
LT_LIBCOAP_REVISION=1
|
||||
LT_LIBCOAP_AGE=1
|
||||
LT_LIBCOAP_CURRENT=5
|
||||
LT_LIBCOAP_REVISION=0
|
||||
LT_LIBCOAP_AGE=2
|
||||
LIBCOAP_SO_VERSION=$LT_LIBCOAP_CURRENT.$LT_LIBCOAP_REVISION.$LT_LIBCOAP_AGE
|
||||
|
||||
# Announce the libtool version
|
||||
@@ -169,14 +176,45 @@ LIBCOAP_ABI_VERSION=$LT_TEMP.$LT_LIBCOAP_AGE.$LT_LIBCOAP_REVISION
|
||||
AC_SUBST(LIBCOAP_ABI_VERSION)
|
||||
AC_SUBST(LIBCOAP_API_VERSION)
|
||||
|
||||
# Define a numeric version string
|
||||
m4_define([version_number],
|
||||
[m4_format([%u%03u%03u],
|
||||
libcoap_major_version,
|
||||
libcoap_minor_version,
|
||||
libcoap_micro_version)])
|
||||
LIBCOAP_VERSION=version_number
|
||||
AC_SUBST(LIBCOAP_VERSION)
|
||||
LT_TEMP=libcoap_release_state
|
||||
if test "x$LT_TEMP" = "x"; then
|
||||
# Define a numeric version string
|
||||
m4_define([version_number],
|
||||
[m4_format([%u%03u%03u],
|
||||
libcoap_major_version,
|
||||
libcoap_minor_version,
|
||||
libcoap_micro_version)])
|
||||
LIBCOAP_VERSION=version_number
|
||||
AC_SUBST(LIBCOAP_VERSION)
|
||||
|
||||
# Define a base version string
|
||||
m4_define([base_version],
|
||||
[m4_format([%u.%u.%u],
|
||||
libcoap_major_version,
|
||||
libcoap_minor_version,
|
||||
libcoap_micro_version)])
|
||||
LIBCOAP_PACKAGE_BASE=base_version
|
||||
AC_SUBST(LIBCOAP_PACKAGE_BASE)
|
||||
else
|
||||
# Doing a rc1 etc., so not a full release, use previous full version numbers
|
||||
# Define a numeric version string
|
||||
m4_define([version_number],
|
||||
[m4_format([%u%03u%03u],
|
||||
libcoap_pre_major_version,
|
||||
libcoap_pre_minor_version,
|
||||
libcoap_pre_micro_version)])
|
||||
LIBCOAP_VERSION=version_number
|
||||
AC_SUBST(LIBCOAP_VERSION)
|
||||
|
||||
# Define a base version string
|
||||
m4_define([base_version],
|
||||
[m4_format([%u.%u.%u],
|
||||
libcoap_pre_major_version,
|
||||
libcoap_pre_minor_version,
|
||||
libcoap_pre_micro_version)])
|
||||
LIBCOAP_PACKAGE_BASE=base_version
|
||||
AC_SUBST(LIBCOAP_PACKAGE_BASE)
|
||||
fi
|
||||
|
||||
# Adding some default warning options for code QS
|
||||
# see https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
|
||||
@@ -364,6 +402,7 @@ AM_CONDITIONAL(BUILD_MANPAGES, [test "x$build_manpages" = "xyes"])
|
||||
gnutls_version_required=3.3.0
|
||||
openssl_version_required=1.1.0
|
||||
mbedtls_version_required=2.7.10
|
||||
wolfssl_version_required=5.2.0
|
||||
tinydtls_version_required=0.8.6
|
||||
|
||||
AC_ARG_ENABLE([dtls],
|
||||
@@ -384,6 +423,12 @@ AC_ARG_WITH([openssl],
|
||||
[with_openssl="$withval"],
|
||||
[with_openssl="no"])
|
||||
|
||||
AC_ARG_WITH([wolfssl],
|
||||
[AS_HELP_STRING([--with-wolfssl],
|
||||
[Use wolfSSL for DTLS functions])],
|
||||
[with_wolfssl="$withval"],
|
||||
[with_wolfssl="no"])
|
||||
|
||||
AC_ARG_WITH([mbedtls],
|
||||
[AS_HELP_STRING([--with-mbedtls],
|
||||
[Use Mbed TLS for DTLS functions])],
|
||||
@@ -402,11 +447,11 @@ AC_ARG_WITH([submodule-tinydtls],
|
||||
[with_submodule_tinydtls="$withval"],
|
||||
[with_submodule_tinydtls="explicit_fallback"])
|
||||
|
||||
if test "x$with_gnutls" = "xyes" -o "x$with_openssl" = "xyes" -o "x$with_mbedtls" = "xyes" -o "x$with_tinydtls" = "xyes"; then
|
||||
if test "x$with_gnutls" = "xyes" -o "x$with_openssl" = "xyes" -o "x$with_wolfssl" = "xyes" -o "x$with_mbedtls" = "xyes" -o "x$with_tinydtls" = "xyes"; then
|
||||
if test "x$build_dtls" = "xno"; then
|
||||
# Give an advice that '--with_gnutls', '--with_openssl', '--with-mbedtls' or '--with-tinydtls' was used but
|
||||
# Give an advice that '--with_gnutls', '--with_openssl', '--with_wolfssl', '--with-mbedtls' or '--with-tinydtls' was used but
|
||||
# DTLS support isn't configured.
|
||||
AC_MSG_WARN([==> Using the configure options '--with-gnutls', '--with-openssl', '--with-mbedtls' or '--with-tinydtls' without '--enable-dtls' is useless and will be ignored.])
|
||||
AC_MSG_WARN([==> Using the configure options '--with-gnutls', '--with-openssl', '--with_wolfssl', '--with-mbedtls' or '--with-tinydtls' without '--enable-dtls' is useless and will be ignored.])
|
||||
fi
|
||||
fi
|
||||
if test "x$with_submodule_tinydtls" = "xyes"; then
|
||||
@@ -426,6 +471,9 @@ if test "x$build_dtls" = "xyes"; then
|
||||
if test "x$with_openssl" = "xyes"; then
|
||||
TLSCOUNT=`expr $TLSCOUNT + 1`
|
||||
fi
|
||||
if test "x$with_wolfssl" = "xyes"; then
|
||||
TLSCOUNT=`expr $TLSCOUNT + 1`
|
||||
fi
|
||||
if test "x$with_mbedtls" = "xyes"; then
|
||||
TLSCOUNT=`expr $TLSCOUNT + 1`
|
||||
fi
|
||||
@@ -450,19 +498,87 @@ if test "x$build_dtls" = "xyes"; then
|
||||
[have_openssl="yes"],
|
||||
[have_openssl="no"])
|
||||
|
||||
# Mbed TLS [does not have mbedtls.pc pkg-config file]
|
||||
AC_CHECK_LIB(mbedtls, mbedtls_version_get_string,
|
||||
[have_mbedtls="yes"; MbedTLS_CFLAGS="" ; MbedTLS_LIBS="-lmbedtls -lmbedcrypto -lmbedx509"],
|
||||
[have_mbedtls="no"], -lmbedx509 -lmbedcrypto)
|
||||
# wolfSSL
|
||||
PKG_CHECK_MODULES([wolfSSL],
|
||||
[wolfssl],
|
||||
[have_wolfssl="yes"],
|
||||
[have_wolfssl="no"])
|
||||
|
||||
# Mbed TLS
|
||||
if test "x${MbedTLS_CFLAGS+set}" = "xset"; then
|
||||
mbedtls_cflags_overridden="yes"
|
||||
else
|
||||
mbedtls_cflags_overridden="no"
|
||||
fi
|
||||
|
||||
if test "x${MbedTLS_LIBS+set}" = "xset"; then
|
||||
mbedtls_libs_overridden="yes"
|
||||
else
|
||||
mbedtls_libs_overridden="no"
|
||||
fi
|
||||
|
||||
# If MbedTLS_CFLAGS and MbedTLS_LIBS are overridden, pkg-config will always assume the library was found, even
|
||||
# though MbedTLS doesn't necessarily have a pkg-config file. Therefore, we might as well use the "old" way to
|
||||
# determine whether we can link MbedTLS (and which version we have).
|
||||
if test "x$mbedtls_libs_overridden" = "xyes" -a "x$mbedtls_cflags_overridden" = "xyes"; then
|
||||
have_mbedtls="no"
|
||||
mbedtls_has_pkgconfig="no"
|
||||
else
|
||||
# Attempt to find MbedTLS using pkg-config.
|
||||
|
||||
# When statically linking against libcoap, all transitive dependencies need to be specified as linker flags
|
||||
# as well. Use pkg-config --static for that.
|
||||
if test "x$enable_static" = "xyes"; then
|
||||
KEEP_PKG_CONFIG=$PKG_CONFIG
|
||||
PKG_CONFIG="$PKG_CONFIG --static"
|
||||
PKG_CHECK_MODULES([MbedTLS],
|
||||
[mbedtls],
|
||||
[have_mbedtls="yes"; mbedtls_has_pkgconfig="yes"],
|
||||
[have_mbedtls="no"; mbedtls_has_pkgconfig="no"])
|
||||
PKG_CONFIG=$KEEP_PKG_CONFIG
|
||||
else
|
||||
PKG_CHECK_MODULES([MbedTLS],
|
||||
[mbedtls],
|
||||
[have_mbedtls="yes"; mbedtls_has_pkgconfig="yes"],
|
||||
[have_mbedtls="no"; mbedtls_has_pkgconfig="no"])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$have_mbedtls" = "xno"; then
|
||||
# Attempt to find mbedtls without pkg-config.
|
||||
|
||||
# default linker flags (default CFLAGS are empty, so they don't need to be set).
|
||||
if test "x$mbedtls_libs_overridden" == "xno"; then
|
||||
MbedTLS_LIBS="-lmbedtls -lmbedcrypto -lmbedx509"
|
||||
fi
|
||||
|
||||
# check whether we can find MbedTLS
|
||||
local_MbedTLS_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="$MbedTLS_CFLAGS $CFLAGS"
|
||||
local_MbedTLS_save_LIBS=$LIBS
|
||||
LIBS="$MbedTLS_LIBS $LIBS"
|
||||
AC_CHECK_LIB(mbedtls, mbedtls_version_get_string,
|
||||
[have_mbedtls="yes"],
|
||||
[have_mbedtls="no"])
|
||||
LIBS=$local_MbedTLS_save_LIBS
|
||||
CFLAGS=$local_MbedTLS_save_CFLAGS
|
||||
fi
|
||||
|
||||
# here, we know whether we can find MbedTLS, but need to determine the version.
|
||||
if test "x$have_mbedtls" = "xyes"; then
|
||||
if test "x$cross_compiling" = "xyes" ; then
|
||||
if test "x$mbedtls_has_pkgconfig" = "xyes"; then
|
||||
# If pkg-config found mbedtls, use it to determine the version.
|
||||
mbedtls_version=`$PKG_CONFIG --modversion mbedtls`;
|
||||
elif test "x$cross_compiling" = "xyes" ; then
|
||||
# Have no option but to do this
|
||||
mbedtls_version=$mbedtls_version_required
|
||||
else
|
||||
# Get actual library version
|
||||
AC_LANG_PUSH(C)
|
||||
# Get actual library version by compiling a test program.
|
||||
local_MbedTLS_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="$MbedTLS_CFLAGS $CFLAGS"
|
||||
local_MbedTLS_save_LIBS=$LIBS
|
||||
LIBS="$MbedTLS_LIBS $LIBS"
|
||||
AC_LANG_PUSH(C)
|
||||
AC_LINK_IFELSE([dnl
|
||||
AC_LANG_SOURCE(
|
||||
[[#include <stdio.h>
|
||||
@@ -476,8 +592,9 @@ if test "x$build_dtls" = "xyes"; then
|
||||
[mbedtls_version=$(./conftest$EXEEXT)],
|
||||
[AC_MSG_WARN(Failed to determine Mbed TLS version)
|
||||
have_mbedtls=no])
|
||||
LIBS=$local_MbedTLS_save_LIBS
|
||||
AC_LANG_POP(C)
|
||||
LIBS=$local_MbedTLS_save_LIBS
|
||||
CFLAGS=$local_MbedTLS_save_CFLAGS
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -509,6 +626,7 @@ if test "x$build_dtls" = "xyes"; then
|
||||
gnutls_version=`$PKG_CONFIG --modversion gnutls`
|
||||
AX_CHECK_GNUTLS_VERSION
|
||||
have_openssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_wolfssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_mbedtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
fi
|
||||
@@ -527,6 +645,26 @@ if test "x$build_dtls" = "xyes"; then
|
||||
openssl_version=`$PKG_CONFIG --modversion openssl`
|
||||
AX_CHECK_OPENSSL_VERSION
|
||||
have_gnutls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_wolfssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_mbedtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
fi
|
||||
|
||||
# The user wants to use explicit wolfSSL if '--with-wolfssl' was set.
|
||||
if test "x$with_wolfssl" = "xyes"; then
|
||||
# Some more sanity checking.
|
||||
if test "x$have_wolfssl" != "xyes"; then
|
||||
AC_MSG_ERROR([==> You want to build libcoap with DTLS support by the wolfSSL library but pkg-config file 'wolfssl.pc' could not be found!
|
||||
Install the package(s) that contains the development files for wolfSSL,
|
||||
or select a different TLS library or disable the DTLS support using '--disable-dtls'.])
|
||||
fi
|
||||
AC_MSG_NOTICE([The use of wolfSSL was explicitly requested with configure option '--with-wolfssl'!])
|
||||
|
||||
# check for valid wolfSSL version
|
||||
wolfssl_version=`$PKG_CONFIG --modversion wolfssl`
|
||||
AX_CHECK_WOLFSSL_VERSION
|
||||
have_gnutls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_openssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_mbedtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
fi
|
||||
@@ -541,11 +679,11 @@ if test "x$build_dtls" = "xyes"; then
|
||||
fi
|
||||
AC_MSG_NOTICE([The use of Mbed TLS was explicitly requested with configure option '--with-mbedtls'!])
|
||||
|
||||
# check for valid Mbed TLS version (mbedtls.pc does not exist - hmm)
|
||||
# mbedtls_version determined previously
|
||||
AX_CHECK_MBEDTLS_VERSION
|
||||
have_gnutls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_openssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_wolfssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
fi
|
||||
|
||||
@@ -597,6 +735,7 @@ if test "x$build_dtls" = "xyes"; then
|
||||
|
||||
have_gnutls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_openssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_wolfssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_mbedtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
fi
|
||||
|
||||
@@ -609,6 +748,7 @@ if test "x$build_dtls" = "xyes"; then
|
||||
AC_MSG_NOTICE([Using auto selected library GnuTLS for DTLS support!])
|
||||
with_gnutls_auto="yes"
|
||||
have_openssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_wolfssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_mbedtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
|
||||
@@ -618,10 +758,22 @@ if test "x$build_dtls" = "xyes"; then
|
||||
AX_CHECK_OPENSSL_VERSION
|
||||
AC_MSG_NOTICE([Using auto selected library OpenSSL for DTLS support!])
|
||||
with_openssl_auto="yes"
|
||||
have_wolfssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_gnutls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_mbedtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
|
||||
# ... and if not found, check if wolfSSL is suitable.
|
||||
elif test "x$have_wolfssl" = "xyes"; then
|
||||
wolfssl_version=`$PKG_CONFIG --modversion wolfssl`
|
||||
AX_CHECK_WOLFSSL_VERSION
|
||||
AC_MSG_NOTICE([Using auto selected library wolfSSL for DTLS support!])
|
||||
with_wolfssl_auto="yes"
|
||||
have_gnutls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_openssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_mbedtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
|
||||
# ... and if not found check Mbed TLS is suitable.
|
||||
elif test "x$have_mbedtls" = "xyes"; then
|
||||
# Mbed TLS [does not have mbedtls.pc pkg-config file]
|
||||
@@ -630,6 +782,7 @@ if test "x$build_dtls" = "xyes"; then
|
||||
AC_MSG_NOTICE([Using auto selected library Mbed TLS for DTLS support!])
|
||||
with_mbedtls_auto="yes"
|
||||
have_gnutls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_wolfssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_openssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
|
||||
@@ -641,13 +794,13 @@ if test "x$build_dtls" = "xyes"; then
|
||||
have_gnutls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_mbedtls="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
have_openssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
|
||||
have_wolfssl="no" # don't confuse AC_MSG_RESULT at the end of the script
|
||||
|
||||
# Note that the TinyDTLS submodule is used only when explicitly requested.
|
||||
# Giving out an error message if we haven't found at least one crypto library.
|
||||
else
|
||||
AC_MSG_ERROR([==> Option '--enable-dtls' is set but none of the needed cryptography libraries GnuTLS, OpenSSL, Mbed TLS or TinyDTLS could be found!
|
||||
Install at least one of the package(s) that contains the development files for GnuTLS (>= $gnutls_version_required), OpenSSL(>= $openssl_version_required), Mbed TLS(>= $mbedtls_version_required), or TinyDTLS(>= $tinydtls_version_required)
|
||||
AC_MSG_ERROR([==> Option '--enable-dtls' is set but none of the needed cryptography libraries GnuTLS, OpenSSL, wolfSSL, Mbed TLS or TinyDTLS could be found!
|
||||
Install at least one of the package(s) that contains the development files for GnuTLS (>= $gnutls_version_required), OpenSSL(>= $openssl_version_required), wolfSSL(>= $wolfssl_version_required), Mbed TLS(>= $mbedtls_version_required), or TinyDTLS(>= $tinydtls_version_required)
|
||||
or disable the DTLS support using '--disable-dtls'.])
|
||||
fi
|
||||
fi
|
||||
@@ -663,6 +816,11 @@ if test "x$build_dtls" = "xyes"; then
|
||||
DTLS_LIBS="$OpenSSL_LIBS"
|
||||
AC_DEFINE(COAP_WITH_LIBOPENSSL, [1], [Define to 1 if the system has libssl1.1.])
|
||||
fi
|
||||
if test "x$with_wolfssl" = "xyes" -o "x$with_wolfssl_auto" = "xyes"; then
|
||||
DTLS_CFLAGS="$wolfSSL_CFLAGS"
|
||||
DTLS_LIBS="$wolfSSL_LIBS"
|
||||
AC_DEFINE(COAP_WITH_LIBWOLFSSL, [1], [Define to 1 if the system has libwolfssl.])
|
||||
fi
|
||||
if test "x$with_mbedtls" = "xyes" -o "x$with_mbedtls_auto" = "xyes"; then
|
||||
DTLS_CFLAGS="$MbedTLS_CFLAGS"
|
||||
DTLS_LIBS="$MbedTLS_LIBS"
|
||||
@@ -680,6 +838,8 @@ fi
|
||||
# Define the Library name extension for the TLS the library was linked against
|
||||
if test "x$with_openssl" = "xyes" -o "x$with_openssl_auto" = "xyes"; then
|
||||
LIBCOAP_DTLS_LIB_EXTENSION_NAME=-openssl
|
||||
elif test "x$with_wolfssl" = "xyes" -o "x$with_wolfssl_auto" = "xyes"; then
|
||||
LIBCOAP_DTLS_LIB_EXTENSION_NAME=-wolfssl
|
||||
elif test "x$with_gnutls" = "xyes" -o "x$with_gnutls_auto" = "xyes"; then
|
||||
LIBCOAP_DTLS_LIB_EXTENSION_NAME=-gnutls
|
||||
elif test "x$with_mbedtls" = "xyes" -o "x$with_mbedtls_auto" = "xyes"; then
|
||||
@@ -966,6 +1126,26 @@ if test "x$with_epoll" = "xyes"; then
|
||||
AC_DEFINE(COAP_EPOLL_SUPPORT, 1, [Define to 1 if the system has epoll support.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([thread-safe],
|
||||
[AS_HELP_STRING([--enable-thread-safe],
|
||||
[Enable building with thread safe support [default=yes]])],
|
||||
[enable_thread_safe="$enableval"],
|
||||
[enable_thread_safe="yes"])
|
||||
|
||||
if test "x$enable_thread_safe" = "xyes"; then
|
||||
AC_DEFINE(COAP_THREAD_SAFE, 1, [Define to 1 if libcoap has thread safe support])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([thread-recursive-lock-detection],
|
||||
[AS_HELP_STRING([--enable-thread-recursive-lock-detection],
|
||||
[Enable building with thread recursive locking detection support [default=yes]])],
|
||||
[enable_recursive_detection="$enableval"],
|
||||
[enable_recursive_detection="yes"])
|
||||
|
||||
if test "x$enable_recursive_detection" = "xyes"; then
|
||||
AC_DEFINE(COAP_THREAD_RECURSIVE_CHECK, 1, [Define to 1 detect recursive locking detection support])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([small-stack],
|
||||
[AS_HELP_STRING([--enable-small-stack],
|
||||
[Use small-stack if the available stack space is restricted [default=no]])],
|
||||
@@ -1001,6 +1181,22 @@ if test "x$enable_server_mode" != "xyes" -a "x$enable_client_mode" != "xyes" ; t
|
||||
AC_MSG_ERROR([==> One or both of '--enable-server-mode' and '--enable-client-mode' need to be set!])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([proxy-code],
|
||||
[AS_HELP_STRING([--enable-proxy-code],
|
||||
[Enable CoAP proxy supporting code [default=yes]])],
|
||||
[enable_proxy_code="$enableval"],
|
||||
[enable_proxy_code="yes"])
|
||||
|
||||
if test "x$enable_proxy_code" = "xyes"; then
|
||||
if test "x$enable_server_mode" != "xyes" -o "x$enable_client_mode" != "xyes" ; then
|
||||
AC_MSG_WARN([==> Both of '--enable-server-mode' and '--enable-client-mode' need to be set for --enable-proxy-code!])
|
||||
enable_proxy_code="no"
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_proxy_code" = "xyes"; then
|
||||
AC_DEFINE(COAP_PROXY_SUPPORT, 1, [Define to 1 if libcoap supports proxy code.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([max-logging-level],
|
||||
[AS_HELP_STRING([--enable-max-logging-level],
|
||||
[Only build logging code up to and including the specified logging level [default=8]])],
|
||||
@@ -1100,9 +1296,19 @@ case $host in
|
||||
LIBS="${LIBS} -lws2_32"
|
||||
;;
|
||||
|
||||
*-qnx*)
|
||||
AC_MSG_RESULT([QNX])
|
||||
ADDITIONAL_CFLAGS="-D_QNX_SOURCE"
|
||||
;;
|
||||
|
||||
*xtensa-esp32-elf*)
|
||||
AC_MSG_RESULT([XtensaEsp32Elf])
|
||||
ADDITIONAL_CFLAGS="-D_GNU_SOURCE -DWITH_POSIX"
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_WARN([==> Currently unsupported operating system '${host}' !])
|
||||
AC_MSG_ERROR([==> If you can provide patches to support your operating system please write to 'libcoap-developers@lists.sourceforge.net'.])
|
||||
AC_MSG_ERROR([==> If you can provide patches to support your operating system please raise a Pull Request at 'https://github.com/obgm/libcoap/pulls'.])
|
||||
esac
|
||||
|
||||
# Exporting the PREDEFINED_CFLAGS definition
|
||||
@@ -1121,14 +1327,8 @@ CFLAGS="$CFLAGS $ADDITIONAL_CFLAGS"
|
||||
#
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
coap_config.h.riot
|
||||
coap_config.h.windows
|
||||
doc/Makefile
|
||||
examples/Makefile
|
||||
examples/lwip/config/coap_config.h
|
||||
include/coap$LIBCOAP_API_VERSION/coap.h
|
||||
include/coap$LIBCOAP_API_VERSION/coap.h.riot
|
||||
include/coap$LIBCOAP_API_VERSION/coap.h.windows
|
||||
man/coap.txt
|
||||
man/coap_address.txt
|
||||
man/coap_async.txt
|
||||
@@ -1144,6 +1344,7 @@ man/coap_handler.txt
|
||||
man/coap_init.txt
|
||||
man/coap_io.txt
|
||||
man/coap_keepalive.txt
|
||||
man/coap_locking.txt
|
||||
man/coap_logging.txt
|
||||
man/coap_lwip.txt
|
||||
man/coap_observe.txt
|
||||
@@ -1151,10 +1352,12 @@ man/coap_oscore.txt
|
||||
man/coap_pdu_access.txt
|
||||
man/coap_pdu_setup.txt
|
||||
man/coap_persist.txt
|
||||
man/coap_proxy.txt
|
||||
man/coap_recovery.txt
|
||||
man/coap_resource.txt
|
||||
man/coap_session.txt
|
||||
man/coap_string.txt
|
||||
man/coap_supported.txt
|
||||
man/coap_tls_library.txt
|
||||
man/coap_uri.txt
|
||||
man/coap_websockets.txt
|
||||
@@ -1162,7 +1365,9 @@ man/coap-client.txt
|
||||
man/coap-oscore-conf.txt
|
||||
man/coap-server.txt
|
||||
man/coap-rd.txt
|
||||
man/coap-tls-engine-conf.txt
|
||||
man/Makefile
|
||||
scripts/fix_version.sh
|
||||
tests/test_common.h
|
||||
tests/Makefile
|
||||
tests/oss-fuzz/Makefile.ci
|
||||
@@ -1195,6 +1400,11 @@ if test "x$enable_client_mode" = "xyes"; then
|
||||
else
|
||||
AC_MSG_RESULT([ build with client support : "no"])
|
||||
fi
|
||||
if test "x$enable_client_mode" = "xyes"; then
|
||||
AC_MSG_RESULT([ build with proxy support : "yes"])
|
||||
else
|
||||
AC_MSG_RESULT([ build with proxy support : "no"])
|
||||
fi
|
||||
if test "x$build_ipv4" != "xno"; then
|
||||
AC_MSG_RESULT([ build with IPv4 support : "yes"])
|
||||
else
|
||||
@@ -1218,20 +1428,30 @@ fi
|
||||
if test "x$with_gnutls" = "xyes" -o "x$with_gnutls_auto" = "xyes"; then
|
||||
AC_MSG_RESULT([ build DTLS support : "yes"])
|
||||
AC_MSG_RESULT([ --> GnuTLS around : "yes" (found GnuTLS $gnutls_version)])
|
||||
AC_MSG_RESULT([ GNUTLS_CFLAGS : "$GnuTLS_CFLAGS"])
|
||||
AC_MSG_RESULT([ GNUTLS_LIBS : "$GnuTLS_LIBS"])
|
||||
AC_MSG_RESULT([ GnuTLS_CFLAGS : "$GnuTLS_CFLAGS"])
|
||||
AC_MSG_RESULT([ GnuTLS_LIBS : "$GnuTLS_LIBS"])
|
||||
fi
|
||||
if test "x$with_openssl" = "xyes" -o "x$with_openssl_auto" = "xyes"; then
|
||||
AC_MSG_RESULT([ build DTLS support : "yes"])
|
||||
AC_MSG_RESULT([ --> OpenSSL around : "yes" (found OpenSSL $openssl_version)])
|
||||
AC_MSG_RESULT([ OPENSSL_CFLAGS : "$OpenSSL_CFLAGS"])
|
||||
AC_MSG_RESULT([ OPENSSL_LIBS : "$OpenSSL_LIBS"])
|
||||
AC_MSG_RESULT([ OpenSSL_CFLAGS : "$OpenSSL_CFLAGS"])
|
||||
AC_MSG_RESULT([ OpenSSL_LIBS : "$OpenSSL_LIBS"])
|
||||
fi
|
||||
if test "x$with_wolfssl" = "xyes" -o "x$with_wolfssl_auto" = "xyes"; then
|
||||
AC_MSG_RESULT([ build DTLS support : "yes"])
|
||||
AC_MSG_RESULT([ --> wolfSSL around : "yes" (found wolfSSL $wolfssl_version)])
|
||||
AC_MSG_RESULT([ wolfSSL_CFLAGS : "$wolfSSL_CFLAGS"])
|
||||
AC_MSG_RESULT([ wolfSSL_LIBS : "$wolfSSL_LIBS"])
|
||||
fi
|
||||
if test "x$with_mbedtls" = "xyes" -o "x$with_mbedtls_auto" = "xyes"; then
|
||||
AC_MSG_RESULT([ build DTLS support : "yes"])
|
||||
AC_MSG_RESULT([ --> Mbed TLS around : "yes" (found Mbed TLS $mbedtls_version)])
|
||||
AC_MSG_RESULT([ MBEDTLS_CFLAGS : "$MbedTLS_CFLAGS"])
|
||||
AC_MSG_RESULT([ MBEDTLS_LIBS : "$MbedTLS_LIBS"])
|
||||
if test "x$mbedtls_has_pkgconfig" = "xyes"; then
|
||||
AC_MSG_RESULT([ --> Mbed TLS around : "yes" (found Mbed TLS $mbedtls_version using pkg-config)])
|
||||
else
|
||||
AC_MSG_RESULT([ --> Mbed TLS around : "yes" (found Mbed TLS $mbedtls_version without pkg-config)])
|
||||
fi
|
||||
AC_MSG_RESULT([ MbedTLS_CFLAGS : "$MbedTLS_CFLAGS"])
|
||||
AC_MSG_RESULT([ MbedTLS_LIBS : "$MbedTLS_LIBS"])
|
||||
fi
|
||||
if test "x$with_tinydtls" = "xyes"; then
|
||||
AC_MSG_RESULT([ build DTLS support : "yes"])
|
||||
@@ -1280,6 +1500,8 @@ if test "x$enable_max_logging_level" != "x8"; then
|
||||
else
|
||||
AC_MSG_RESULT([ enable max logging level : "none"])
|
||||
fi
|
||||
AC_MSG_RESULT([ enable thread safe code : "$enable_thread_safe"])
|
||||
AC_MSG_RESULT([ enable recursive lock check : "$enable_recursive_detection"])
|
||||
if test "x$build_doxygen" = "xyes"; then
|
||||
AC_MSG_RESULT([ build doxygen pages : "yes"])
|
||||
AC_MSG_RESULT([ --> Doxygen around : "yes" ($DOXYGEN $doxygen_version)])
|
||||
@@ -1328,3 +1550,9 @@ if test "x$enable_static" = "xyes"; then
|
||||
else
|
||||
AC_MSG_RESULT([ build static library : "no"])
|
||||
fi
|
||||
|
||||
mkdir -p include/coap$LIBCOAP_API_VERSION
|
||||
LT_TEMP=`grep -B2 " COAP_" coap_config.h > include/coap$LIBCOAP_API_VERSION/coap_defines.h`
|
||||
if test "x$LT_TEMP" != "x" ; then
|
||||
AC_MSG_ERROR([Unable to build coap_defines.h])
|
||||
fi
|
||||
|
||||
+1
-1
@@ -2210,7 +2210,7 @@ INCLUDE_FILE_PATTERNS =
|
||||
# recursively expanded use the := operator instead of the = operator.
|
||||
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
|
||||
|
||||
PREDEFINED = @PREDEFINED_CFLAGS@
|
||||
PREDEFINED = @PREDEFINED_CFLAGS@ __DOXYGEN__
|
||||
|
||||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
||||
# tag can be used to specify a list of macro names that should be expanded. The
|
||||
|
||||
+10
-6
@@ -1,7 +1,7 @@
|
||||
# doc/Makefile.am
|
||||
#
|
||||
# Copyright (C) 2015-2018 Carsten Schoenert <c.schoenert@t-online.de>
|
||||
# 2018-2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
# 2018-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
@@ -82,10 +82,10 @@ man-page-build: upg-page-build man-page-start
|
||||
##
|
||||
for FILE in $${MAN_FILES} ; do \
|
||||
BASE=`basename $${FILE} | cut -d. -f 1` ;\
|
||||
MANUAL=`egrep -B 1 "^====" $${FILE} | head -1` ;\
|
||||
SUMMARY=`egrep -B 2 "^SYNOPSIS" $${FILE} | ${SED} 's/coap-//g' | cut -d\- -f2 | cut -c2- | head -1` ;\
|
||||
MANUAL=`${EGREP} -B 1 "^====" $${FILE} | head -1` ;\
|
||||
SUMMARY=`${EGREP} -B 2 "^SYNOPSIS" $${FILE} | ${SED} 's/coap-//g' | cut -d\- -f2 | cut -c2- | head -1` ;\
|
||||
if [ -z "$${SUMMARY}" ] ; then \
|
||||
SUMMARY=`egrep -B 2 "^DESCRIPTION" $${FILE} | ${SED} 's/coap-//g' | cut -d\- -f2 | cut -c2- | head -1` ;\
|
||||
SUMMARY=`${EGREP} -B 2 "^DESCRIPTION" $${FILE} | ${SED} 's/coap-//g' | cut -d\- -f2 | cut -c2- | head -1` ;\
|
||||
fi ;\
|
||||
##
|
||||
## Fix and copy .html file across
|
||||
@@ -126,14 +126,18 @@ man-page-build: upg-page-build man-page-start
|
||||
echo ' <tab type="usergroup" visible="yes" url="@ref man_individual" title="Individual Man Pages">' >> $(top_builddir)/doc/insert_file ;\
|
||||
for FILE in $${MAN3_FILES} ; do \
|
||||
BASE=`basename $${FILE} | cut -d. -f 1` ;\
|
||||
LIST=`${SED} -ne '/^NAME/,/^SYNOPSIS/p;/^SYNOPSIS/q' $${FILE} | ${SED} -ne '/coap_/{ s/ *, *//g ; p }' | egrep -v "^$${BASE}$$"` ;\
|
||||
LIST=`${SED} -ne '/^NAME/,/^SYNOPSIS/p;/^SYNOPSIS/q' $${FILE} | ${SED} -ne '/coap_/{ s/ *, *//g ; p }' | ${EGREP} -v "^$${BASE}$$"` ;\
|
||||
for ENTRY in $${LIST} ; do \
|
||||
MANUAL="$${ENTRY}(3)" ;\
|
||||
## Build the manual insert page
|
||||
echo "/// @page man_$${ENTRY} $${MANUAL}" > $(top_builddir)/doc/man_tmp/$${MANUAL}.dox ;\
|
||||
echo "/// @htmlinclude $${ENTRY}.html $${MANUAL}" >> $(top_builddir)/doc/man_tmp/$${MANUAL}.dox ;\
|
||||
## Create html file
|
||||
cat $(top_builddir)/man/$${BASE}.html | ${SED} "s/Function: $${ENTRY}(/<a class=\"anchor\" id=\"$${ENTRY}\"><\/a>\0/" > $(top_builddir)/doc/man_html/$${ENTRY}.html ;\
|
||||
cat $(top_builddir)/man/$${BASE}.html |\
|
||||
${SED} "s/Function: $${ENTRY}(/<a class=\"anchor\" id=\"$${ENTRY}\"><\/a>\0/" |\
|
||||
${SED} "s/Structure $${ENTRY}</<a class=\"anchor\" id=\"$${ENTRY}\"><\/a>\0/" |\
|
||||
${SED} "s/SECTION: [A-Za-z /]*: $${ENTRY}</<a class=\"anchor\" id=\"$${ENTRY}\"><\/a>\0/" \
|
||||
> $(top_builddir)/doc/man_html/$${ENTRY}.html ;\
|
||||
## Update scratch_insert_file for sorting later
|
||||
echo "$${ENTRY}" >> $(top_builddir)/doc/scratch_insert_file ;\
|
||||
done ;\
|
||||
|
||||
+3
-1
@@ -4,7 +4,7 @@ libcoap {#mainpage}
|
||||
A C implementation of the Constrained Application Protocol (RFC 7252)
|
||||
=====================================================================
|
||||
|
||||
Copyright (C) 2010--2023 by Olaf Bergmann <bergmann@tzi.org> and others
|
||||
Copyright (C) 2010--2024 by Olaf Bergmann <bergmann@tzi.org> and others
|
||||
|
||||
About libcoap
|
||||
=============
|
||||
@@ -56,6 +56,8 @@ There is (D)TLS support for the following libraries
|
||||
|
||||
* [Mbed TLS](https://www.trustedfirmware.org/projects/mbed-tls/) (Minimum version 2.7.10) [PKI and PSK]
|
||||
|
||||
* [wolfSSL](https://wolfssl.com) (Minimum version 5.2.0) [PKI, PSK, RPK(5.6.4+) and DTLS1.3(5.4.0+)]
|
||||
|
||||
* [TinyDTLS](https://github.com/eclipse/tinydtls) [PSK and RPK] [DTLS Only]
|
||||
|
||||
Documentation
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* doc/module_api_wrap.h
|
||||
*
|
||||
* Copyright (C) 2021-2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
* Copyright (C) 2021-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# examples/Makefile.am
|
||||
#
|
||||
# Copyright (C) 2015 Carsten Schoenert <c.schoenert@t-online.de>
|
||||
# Copyright (C) 2018-2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
# Copyright (C) 2018-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
@@ -56,11 +56,6 @@ if BUILD_ADD_DEFAULT_NAMES
|
||||
noinst_PROGRAMS += coap-server coap-rd
|
||||
endif # BUILD_ADD_DEFAULT_NAMES
|
||||
|
||||
if ! HAVE_CLIENT_SUPPORT
|
||||
coap_server_CPPFLAGS=-DSERVER_CAN_PROXY=0
|
||||
coap_server@LIBCOAP_DTLS_LIB_EXTENSION_NAME@_CPPFLAGS=-DSERVER_CAN_PROXY=0
|
||||
endif # ! HAVE_CLIENT_SUPPORT
|
||||
|
||||
endif # HAVE_SERVER_SUPPORT
|
||||
|
||||
coap_client_SOURCES = coap-client.c
|
||||
|
||||
@@ -40,4 +40,3 @@ Optional Tests
|
||||
[-] TD_COAP_OBS_03 Client detection of deregistration (Max-Age)
|
||||
[-] TD_COAP_OBS_04 Server detection of deregistration (client OFF)
|
||||
[-] TD_COAP_OBS_05 Server detection of deregistration (explicit RST)
|
||||
|
||||
|
||||
+185
-95
@@ -2,7 +2,7 @@
|
||||
|
||||
/* coap-client -- simple CoAP client
|
||||
*
|
||||
* Copyright (C) 2010--2023 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
* Copyright (C) 2010--2024 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -76,6 +76,7 @@ static coap_uri_t proxy = { {0, NULL}, 0, {0, NULL}, {0, NULL}, 0 };
|
||||
static int proxy_scheme_option = 0;
|
||||
static int uri_host_option = 0;
|
||||
static unsigned int ping_seconds = 0;
|
||||
static int setup_cid = 0;
|
||||
|
||||
#define REPEAT_DELAY_MS 1000
|
||||
static size_t repeat_count = 1;
|
||||
@@ -152,6 +153,9 @@ int doing_observe = 0;
|
||||
|
||||
static coap_oscore_conf_t *oscore_conf = NULL;
|
||||
static int doing_oscore = 0;
|
||||
static int doing_tls_engine = 0;
|
||||
static char *tls_engine_conf = NULL;
|
||||
static int ec_jpake = 0;
|
||||
|
||||
static int quit = 0;
|
||||
|
||||
@@ -318,6 +322,7 @@ event_handler(coap_session_t *session COAP_UNUSED,
|
||||
case COAP_EVENT_OSCORE_DECODE_ERROR:
|
||||
case COAP_EVENT_WS_PACKET_SIZE:
|
||||
case COAP_EVENT_WS_CLOSED:
|
||||
case COAP_EVENT_BAD_PACKET:
|
||||
quit = 1;
|
||||
break;
|
||||
case COAP_EVENT_DTLS_CONNECTED:
|
||||
@@ -331,7 +336,6 @@ event_handler(coap_session_t *session COAP_UNUSED,
|
||||
case COAP_EVENT_XMIT_BLOCK_FAIL:
|
||||
case COAP_EVENT_SERVER_SESSION_NEW:
|
||||
case COAP_EVENT_SERVER_SESSION_DEL:
|
||||
case COAP_EVENT_BAD_PACKET:
|
||||
case COAP_EVENT_MSG_RETRANSMITTED:
|
||||
case COAP_EVENT_WS_CONNECTED:
|
||||
case COAP_EVENT_KEEPALIVE_FAILURE:
|
||||
@@ -357,7 +361,6 @@ nack_handler(coap_session_t *session COAP_UNUSED,
|
||||
switch (reason) {
|
||||
case COAP_NACK_TOO_MANY_RETRIES:
|
||||
case COAP_NACK_NOT_DELIVERABLE:
|
||||
case COAP_NACK_RST:
|
||||
case COAP_NACK_TLS_FAILED:
|
||||
case COAP_NACK_WS_FAILED:
|
||||
case COAP_NACK_TLS_LAYER_FAILED:
|
||||
@@ -365,8 +368,15 @@ nack_handler(coap_session_t *session COAP_UNUSED,
|
||||
coap_log_err("cannot send CoAP pdu\n");
|
||||
quit = 1;
|
||||
break;
|
||||
case COAP_NACK_ICMP_ISSUE:
|
||||
case COAP_NACK_RST:
|
||||
coap_log_info("received RST pdu response\n");
|
||||
quit = 1;
|
||||
break;
|
||||
case COAP_NACK_BAD_RESPONSE:
|
||||
coap_log_info("received bad response pdu\n");
|
||||
quit = 1;
|
||||
break;
|
||||
case COAP_NACK_ICMP_ISSUE:
|
||||
default:
|
||||
;
|
||||
}
|
||||
@@ -488,7 +498,7 @@ usage(const char *program, const char *version) {
|
||||
program = ++p;
|
||||
|
||||
fprintf(stderr, "%s v%s -- a small CoAP implementation\n"
|
||||
"Copyright (C) 2010-2023 Olaf Bergmann <bergmann@tzi.org> and others\n\n"
|
||||
"Copyright (C) 2010-2024 Olaf Bergmann <bergmann@tzi.org> and others\n\n"
|
||||
"Build: %s\n"
|
||||
"%s\n"
|
||||
, program, version, lib_build,
|
||||
@@ -496,20 +506,20 @@ usage(const char *program, const char *version) {
|
||||
fprintf(stderr, "%s\n", coap_string_tls_support(buffer, sizeof(buffer)));
|
||||
fprintf(stderr, "\n"
|
||||
"Usage: %s [-a addr] [-b [num,]size] [-e text] [-f file] [-l loss]\n"
|
||||
"\t\t[-m method] [-o file] [-p port] [-r] [-s duration] [-t type]\n"
|
||||
"\t\t[-v num] [-w] [-A type] [-B seconds]\n"
|
||||
"\t\t[-m method] [-o file] [-p port] [-q tls_engine_conf_file] [-r]\n"
|
||||
"\t\t[-s duration] [-t type] [-v num] [-w] [-A type] [-B seconds]\n"
|
||||
"\t\t[-E oscore_conf_file[,seq_file]] [-G count] [-H hoplimit]\n"
|
||||
"\t\t[-K interval] [-N] [-O num,text] [-P scheme://address[:port]\n"
|
||||
"\t\t[-T token] [-U] [-V num] [-X size]\n"
|
||||
"\t\t[[-h match_hint_file] [-k key] [-u user]]\n"
|
||||
"\t\t[[-d count]]\n"
|
||||
"\t\t[[h match_hint_file] [-k key] [-u user] [-2]]\n"
|
||||
"\t\t[[-c certfile] [-j keyfile] [-n] [-C cafile]\n"
|
||||
"\t\t[-J pkcs11_pin] [-M raw_pk] [-R trust_casfile]\n"
|
||||
"\t\t[-S match_pki_sni_file]] URI\n"
|
||||
"\t\t[-J pkcs11_pin] [-M raw_pk] [-R trust_casfile]] URI\n"
|
||||
"\tURI can be an absolute URI or a URI prefixed with scheme and host\n\n"
|
||||
"General Options\n"
|
||||
"\t-a addr\t\tThe local interface address to use\n"
|
||||
"\t-b [num,]size\tBlock size to be used in GET/PUT/POST requests\n"
|
||||
"\t \t\t(value must be a multiple of 16 not larger than 1024)\n"
|
||||
"\t \t\t(value must be 16, 32, 64, 128, 256, 512 or 1024)\n"
|
||||
"\t \t\tIf num is present, the request chain will start at\n"
|
||||
"\t \t\tblock num\n"
|
||||
"\t-e text\t\tInclude text as payload (use percent-encoding for\n"
|
||||
@@ -524,7 +534,9 @@ usage(const char *program, const char *version) {
|
||||
"\t \t\tdefault is 'get'\n"
|
||||
"\t-o file\t\tOutput received data to this file (use '-' for STDOUT)\n"
|
||||
"\t-p port\t\tSend from the specified port\n"
|
||||
"\t-r \t\tUse reliable protocol (TCP or TLS); requires TCP support\n"
|
||||
"\t-q tls_engine_conf_file\n"
|
||||
"\t \t\ttls_engine_conf_file contains TLS ENGINE configuration.\n"
|
||||
"\t \t\tSee coap-tls-engine-conf(5) for definitions.\n"
|
||||
"\t-s duration\tSubscribe to / Observe resource for given duration\n"
|
||||
"\t \t\tin seconds\n"
|
||||
"\t-t type\t\tContent format for given resource for PUT/POST\n"
|
||||
@@ -548,7 +560,7 @@ usage(const char *program, const char *version) {
|
||||
"\t-K interval\tSend a ping after interval seconds of inactivity\n"
|
||||
"\t-L value\tSum of one or more COAP_BLOCK_* flag valuess for block\n"
|
||||
"\t \t\thandling methods. Default is 1 (COAP_BLOCK_USE_LIBCOAP)\n"
|
||||
"\t \t\t(Sum of one or more of 1,2 and 16)\n"
|
||||
"\t \t\t(Sum of one or more of 1,2,4,8,16 and 32)\n"
|
||||
"\t-N \t\tSend NON-confirmable message\n"
|
||||
"\t-O num,text\tAdd option num with contents text to request. If the\n"
|
||||
"\t \t\ttext begins with 0x, then the hex text (two [0-9a-f] per\n"
|
||||
@@ -557,7 +569,8 @@ usage(const char *program, const char *version) {
|
||||
"\t \t\tScheme, address and optional port to define how to\n"
|
||||
"\t \t\tconnect to a CoAP proxy (automatically adds Proxy-Uri\n"
|
||||
"\t \t\toption to request) to forward the request to.\n"
|
||||
"\t \t\tScheme is one of coap, coaps, coap+tcp and coaps+tcp\n"
|
||||
"\t \t\tScheme is one of coap, coaps, coap+tcp, coaps+tcp,\n"
|
||||
"\t \t\tcoap+ws, and coaps+ws\n"
|
||||
"\t-T token\tDefine the initial starting token (up to 24 characters)\n"
|
||||
"\t-U \t\tNever include Uri-Host or Uri-Port options\n"
|
||||
"\t-V num \t\tVerbosity level (default 3, maximum is 7) for (D)TLS\n"
|
||||
@@ -565,6 +578,13 @@ usage(const char *program, const char *version) {
|
||||
"\t-X size\t\tMaximum message size to use for TCP based connections\n"
|
||||
"\t \t\t(default is 8388864). Maximum value of 2^32 -1\n"
|
||||
,program, wait_seconds);
|
||||
fprintf(stderr,
|
||||
"DTLS Options (if supported by underlying (D)TLS library)\n"
|
||||
"\t-d count\n"
|
||||
"\t \t\tFor DTLS, enable use of Connection-ID. If count\n"
|
||||
"\t \t\tis not 0, then the client will changes its source port\n"
|
||||
"\t \t\tevery count packets to test CID\n"
|
||||
);
|
||||
fprintf(stderr,
|
||||
"PSK Options (if supported by underlying (D)TLS library)\n"
|
||||
"\t-h match_hint_file\n"
|
||||
@@ -576,8 +596,11 @@ usage(const char *program, const char *version) {
|
||||
"\t \t\t hint_to_match,use_user,with_key\n"
|
||||
"\t \t\tNote: -k and -u still need to be defined for the default\n"
|
||||
"\t \t\tin case there is no match\n"
|
||||
"\t-k key \t\tPre-shared key for the specified user identity\n"
|
||||
"\t-k key \t\tPre-shared key for the specified user identityt. If the\n"
|
||||
"\t \t\tkey begins with 0x, then the hex text (two [0-9a-f] per\n"
|
||||
"\t \t\tbyte) is converted to binary data\n"
|
||||
"\t-u user\t\tUser identity to send for pre-shared key mode\n"
|
||||
"\t-2 \t\tUse EC-JPAKE negotiation (if supported)\n"
|
||||
"PKI Options (if supported by underlying (D)TLS library)\n"
|
||||
"\tNote: If any one of '-c certfile', '-j keyfile' or '-C cafile' is in\n"
|
||||
"\tPKCS11 URI naming format (pkcs11: prefix), then any remaining non\n"
|
||||
@@ -591,7 +614,8 @@ usage(const char *program, const char *version) {
|
||||
"\t \t\tcertificate in '-c certfile' if the parameter is\n"
|
||||
"\t \t\tdifferent from certfile in '-c certfile'\n"
|
||||
"\t-n \t\tDisable remote peer certificate checking\n"
|
||||
"\t-C cafile\tPEM file or PKCS11 URI for the CA certificate that was\n"
|
||||
"\t-C cafile\tPEM file or PKCS11 URI for the CA certificate and any\n"
|
||||
"\t \t\tintermediate CAs that was\n"
|
||||
"\t \t\tused to sign the server certfile. Ideally the client\n"
|
||||
"\t \t\tcertificate should be signed by the same CA so that\n"
|
||||
"\t \t\tmutual authentication can take place. The contents of\n"
|
||||
@@ -612,7 +636,7 @@ usage(const char *program, const char *version) {
|
||||
"\t \t\tUsing '-R trust_casfile' disables common CA mutual\n"
|
||||
"\t \t\tauthentication which can only be done by using\n"
|
||||
"\t \t\t'-C cafile'.\n"
|
||||
"\t \t\tUsing the -C or -R options will will trigger the\n"
|
||||
"\t \t\tUsing the -C or -R options will trigger the\n"
|
||||
"\t \t\tvalidation of the server certificate unless overridden\n"
|
||||
"\t \t\tby the -n option\n"
|
||||
);
|
||||
@@ -628,6 +652,7 @@ usage(const char *program, const char *version) {
|
||||
"\tcoap-client -m get coaps://%%2Funix%%2Fdomain%%2Fpath%%2Fdtls/.well-known/core\n"
|
||||
"\tcoap-client -m get coaps+tcp://%%2Funix%%2Fdomain%%2Fpath%%2Ftls/.well-known/core\n"
|
||||
"\tcoap-client -m get -T cafe coap://[::1]/time\n"
|
||||
"\tcoap-client -m get -T cafe -P coap://upstream-proxy coap://[::1]/time\n"
|
||||
"\techo -n 1000 | coap-client -m put -T cafe coap://[::1]/time -f -\n"
|
||||
);
|
||||
}
|
||||
@@ -810,6 +835,28 @@ cmdline_oscore(char *arg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
cmdline_tls_engine(char *arg) {
|
||||
uint8_t *buf;
|
||||
size_t length;
|
||||
coap_str_const_t file_mem;
|
||||
|
||||
/* Need a rw var to free off later and file_mem.s is a const */
|
||||
buf = read_file_mem(arg, &length);
|
||||
if (buf == NULL) {
|
||||
fprintf(stderr, "Openssl ENGINE configuration file error: %s\n", arg);
|
||||
return 0;
|
||||
}
|
||||
file_mem.s = buf;
|
||||
file_mem.length = length;
|
||||
if (!coap_tls_engine_configure(&file_mem)) {
|
||||
coap_free(buf);
|
||||
return 0;
|
||||
}
|
||||
coap_free(buf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets global URI options according to the URI passed as @p arg.
|
||||
* This function returns 0 on success or -1 on error.
|
||||
@@ -888,8 +935,8 @@ again:
|
||||
} else if (size > 1024) {
|
||||
coap_log_warn("Maximum block size is 1024\n");
|
||||
return 0;
|
||||
} else if ((size % 16) != 0) {
|
||||
coap_log_warn("Block size %u is not a multiple of 16\n", size);
|
||||
} else if (size != ((1 << (coap_fls(size >> 4) - 1) << 4))) {
|
||||
coap_log_warn("Block size %u invalid\n", size);
|
||||
return 0;
|
||||
}
|
||||
if (size)
|
||||
@@ -908,7 +955,10 @@ set_blocksize(void) {
|
||||
unsigned int opt_length;
|
||||
|
||||
if (method != COAP_REQUEST_DELETE) {
|
||||
if (method == COAP_REQUEST_GET || method == COAP_REQUEST_FETCH) {
|
||||
block.m = (1ull << (block.szx + 4)) < payload.length;
|
||||
|
||||
if (!block.m &&
|
||||
(method == COAP_REQUEST_GET || method == COAP_REQUEST_FETCH)) {
|
||||
if (coap_q_block_is_supported() && block_mode & COAP_BLOCK_TRY_Q_BLOCK)
|
||||
opt = COAP_OPTION_Q_BLOCK2;
|
||||
else
|
||||
@@ -1222,6 +1272,12 @@ static ssize_t
|
||||
cmdline_read_key(char *arg, unsigned char **buf, size_t maxlen) {
|
||||
size_t len = strnlen(arg, maxlen);
|
||||
if (len) {
|
||||
/* read hex string alternative when arg starts with "0x" */
|
||||
if (len >= 4 && arg[0] == '0' && arg[1] == 'x') {
|
||||
/* As the command line option is part of our environment we can do
|
||||
* the conversion in place. */
|
||||
len = convert_hex_string(arg + 2, (uint8_t *)arg);
|
||||
}
|
||||
*buf = (unsigned char *)arg;
|
||||
return len;
|
||||
}
|
||||
@@ -1336,7 +1392,6 @@ setup_pki(coap_context_t *ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
memset(client_sni, 0, sizeof(client_sni));
|
||||
memset(&dtls_pki, 0, sizeof(dtls_pki));
|
||||
dtls_pki.version = COAP_DTLS_PKI_SETUP_VERSION;
|
||||
if (ca_file || root_ca_file) {
|
||||
@@ -1362,17 +1417,28 @@ setup_pki(coap_context_t *ctx) {
|
||||
dtls_pki.verify_peer_cert = verify_peer_cert;
|
||||
}
|
||||
dtls_pki.is_rpk_not_cert = is_rpk_not_cert;
|
||||
dtls_pki.use_cid = setup_cid;
|
||||
dtls_pki.validate_cn_call_back = verify_cn_callback;
|
||||
if ((uri.host.length == 3 && memcmp(uri.host.s, "::1", 3) != 0) ||
|
||||
(uri.host.length == 9 && memcmp(uri.host.s, "127.0.0.1", 9) != 0))
|
||||
memcpy(client_sni, uri.host.s, min(uri.host.length, sizeof(client_sni)-1));
|
||||
else
|
||||
memcpy(client_sni, "localhost", 9);
|
||||
|
||||
if (proxy.host.length) {
|
||||
snprintf(client_sni, sizeof(client_sni), "%*.*s", (int)proxy.host.length, (int)proxy.host.length,
|
||||
proxy.host.s);
|
||||
} else {
|
||||
snprintf(client_sni, sizeof(client_sni), "%*.*s", (int)uri.host.length, (int)uri.host.length,
|
||||
uri.host.s);
|
||||
}
|
||||
dtls_pki.client_sni = client_sni;
|
||||
if ((key_file && strncasecmp(key_file, "pkcs11:", 7) == 0) ||
|
||||
(cert_file && strncasecmp(cert_file, "pkcs11:", 7) == 0) ||
|
||||
(ca_file && strncasecmp(ca_file, "pkcs11:", 7) == 0)) {
|
||||
if (doing_tls_engine) {
|
||||
dtls_pki.pki_key.key_type = COAP_PKI_KEY_DEFINE;
|
||||
dtls_pki.pki_key.key.define.public_cert.s_byte = cert_file;
|
||||
dtls_pki.pki_key.key.define.private_key.s_byte = key_file ? key_file : cert_file;
|
||||
dtls_pki.pki_key.key.define.ca.s_byte = ca_file;
|
||||
dtls_pki.pki_key.key.define.public_cert_def = COAP_PKI_KEY_DEF_ENGINE;
|
||||
dtls_pki.pki_key.key.define.private_key_def = COAP_PKI_KEY_DEF_ENGINE;
|
||||
dtls_pki.pki_key.key.define.ca_def = COAP_PKI_KEY_DEF_ENGINE;
|
||||
dtls_pki.pki_key.key.define.user_pin = pkcs11_pin;
|
||||
} else if ((key_file && strncasecmp(key_file, "pkcs11:", 7) == 0) ||
|
||||
(cert_file && strncasecmp(cert_file, "pkcs11:", 7) == 0) ||
|
||||
(ca_file && strncasecmp(ca_file, "pkcs11:", 7) == 0)) {
|
||||
dtls_pki.pki_key.key_type = COAP_PKI_KEY_PKCS11;
|
||||
dtls_pki.pki_key.key.pkcs11.public_cert = cert_file;
|
||||
dtls_pki.pki_key.key.pkcs11.private_key = key_file ?
|
||||
@@ -1411,16 +1477,21 @@ setup_psk(const uint8_t *identity,
|
||||
static coap_dtls_cpsk_t dtls_psk;
|
||||
static char client_sni[256];
|
||||
|
||||
memset(client_sni, 0, sizeof(client_sni));
|
||||
memset(&dtls_psk, 0, sizeof(dtls_psk));
|
||||
dtls_psk.version = COAP_DTLS_CPSK_SETUP_VERSION;
|
||||
dtls_psk.validate_ih_call_back = verify_ih_callback;
|
||||
dtls_psk.ec_jpake = ec_jpake;
|
||||
dtls_psk.use_cid = setup_cid;
|
||||
if (valid_ihs.count) {
|
||||
dtls_psk.validate_ih_call_back = verify_ih_callback;
|
||||
}
|
||||
dtls_psk.ih_call_back_arg = &dtls_psk.psk_info;
|
||||
if (uri.host.length)
|
||||
memcpy(client_sni, uri.host.s,
|
||||
min(uri.host.length, sizeof(client_sni) - 1));
|
||||
else
|
||||
memcpy(client_sni, "localhost", 9);
|
||||
if (proxy.host.length) {
|
||||
snprintf(client_sni, sizeof(client_sni), "%*.*s", (int)proxy.host.length, (int)proxy.host.length,
|
||||
proxy.host.s);
|
||||
} else {
|
||||
snprintf(client_sni, sizeof(client_sni), "%*.*s", (int)uri.host.length, (int)uri.host.length,
|
||||
uri.host.s);
|
||||
}
|
||||
dtls_psk.client_sni = client_sni;
|
||||
dtls_psk.psk_info.identity.s = identity;
|
||||
dtls_psk.psk_info.identity.length = identity_len;
|
||||
@@ -1503,62 +1574,60 @@ get_session(coap_context_t *ctx,
|
||||
coap_session_t *session = NULL;
|
||||
|
||||
is_mcast = coap_is_mcast(dst);
|
||||
if (local_addr || coap_is_af_unix(dst)) {
|
||||
if (coap_is_af_unix(dst)) {
|
||||
coap_address_t bind_addr;
|
||||
if (coap_is_af_unix(dst)) {
|
||||
coap_address_t bind_addr;
|
||||
|
||||
if (local_addr) {
|
||||
if (!coap_address_set_unix_domain(&bind_addr,
|
||||
(const uint8_t *)local_addr,
|
||||
strlen(local_addr))) {
|
||||
fprintf(stderr, "coap_address_set_unix_domain: %s: failed\n",
|
||||
local_addr);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
char buf[COAP_UNIX_PATH_MAX];
|
||||
|
||||
/* Need a unique address */
|
||||
snprintf(buf, COAP_UNIX_PATH_MAX,
|
||||
"/tmp/coap-client.%d", (int)getpid());
|
||||
if (!coap_address_set_unix_domain(&bind_addr, (const uint8_t *)buf,
|
||||
strlen(buf))) {
|
||||
fprintf(stderr, "coap_address_set_unix_domain: %s: failed\n",
|
||||
buf);
|
||||
remove(buf);
|
||||
return NULL;
|
||||
}
|
||||
(void)remove(buf);
|
||||
}
|
||||
session = open_session(ctx, proto, &bind_addr, dst,
|
||||
identity, identity_len, key, key_len);
|
||||
} else {
|
||||
coap_addr_info_t *info_list = NULL;
|
||||
coap_addr_info_t *info;
|
||||
coap_str_const_t local;
|
||||
uint16_t port = local_port ? atoi(local_port) : 0;
|
||||
|
||||
local.s = (const uint8_t *)local_addr;
|
||||
local.length = strlen(local_addr);
|
||||
/* resolve local address where data should be sent from */
|
||||
info_list = coap_resolve_address_info(&local, port, port, port, port,
|
||||
AI_PASSIVE | AI_NUMERICHOST | AI_NUMERICSERV | AI_ALL,
|
||||
1 << scheme,
|
||||
COAP_RESOLVE_TYPE_LOCAL);
|
||||
if (!info_list) {
|
||||
fprintf(stderr, "coap_resolve_address_info: %s: failed\n", local_addr);
|
||||
if (local_addr) {
|
||||
if (!coap_address_set_unix_domain(&bind_addr,
|
||||
(const uint8_t *)local_addr,
|
||||
strlen(local_addr))) {
|
||||
fprintf(stderr, "coap_address_set_unix_domain: %s: failed\n",
|
||||
local_addr);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
char buf[COAP_UNIX_PATH_MAX];
|
||||
|
||||
/* iterate through results until success */
|
||||
for (info = info_list; info != NULL; info = info->next) {
|
||||
session = open_session(ctx, proto, &info->addr, dst,
|
||||
identity, identity_len, key, key_len);
|
||||
if (session)
|
||||
break;
|
||||
/* Need a unique address */
|
||||
snprintf(buf, COAP_UNIX_PATH_MAX,
|
||||
"/tmp/coap-client.%d", (int)getpid());
|
||||
if (!coap_address_set_unix_domain(&bind_addr, (const uint8_t *)buf,
|
||||
strlen(buf))) {
|
||||
fprintf(stderr, "coap_address_set_unix_domain: %s: failed\n",
|
||||
buf);
|
||||
remove(buf);
|
||||
return NULL;
|
||||
}
|
||||
coap_free_address_info(info_list);
|
||||
(void)remove(buf);
|
||||
}
|
||||
session = open_session(ctx, proto, &bind_addr, dst,
|
||||
identity, identity_len, key, key_len);
|
||||
} else if (local_addr) {
|
||||
coap_addr_info_t *info_list = NULL;
|
||||
coap_addr_info_t *info;
|
||||
coap_str_const_t local;
|
||||
uint16_t port = local_port ? atoi(local_port) : 0;
|
||||
|
||||
local.s = (const uint8_t *)local_addr;
|
||||
local.length = strlen(local_addr);
|
||||
/* resolve local address where data should be sent from */
|
||||
info_list = coap_resolve_address_info(&local, port, port, port, port,
|
||||
AI_PASSIVE | AI_NUMERICHOST | AI_NUMERICSERV | AI_ALL,
|
||||
1 << scheme,
|
||||
COAP_RESOLVE_TYPE_LOCAL);
|
||||
if (!info_list) {
|
||||
fprintf(stderr, "coap_resolve_address_info: %s: failed\n", local_addr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* iterate through results until success */
|
||||
for (info = info_list; info != NULL; info = info->next) {
|
||||
session = open_session(ctx, proto, &info->addr, dst,
|
||||
identity, identity_len, key, key_len);
|
||||
if (session)
|
||||
break;
|
||||
}
|
||||
coap_free_address_info(info_list);
|
||||
} else if (local_port) {
|
||||
coap_address_t bind_addr;
|
||||
|
||||
@@ -1600,8 +1669,7 @@ main(int argc, char **argv) {
|
||||
uint8_t *data = NULL;
|
||||
size_t data_len = 0;
|
||||
coap_addr_info_t *info_list = NULL;
|
||||
#define BUFSIZE 100
|
||||
static unsigned char buf[BUFSIZE];
|
||||
uint8_t cid_every = 0;
|
||||
#ifndef _WIN32
|
||||
struct sigaction sa;
|
||||
#endif
|
||||
@@ -1610,14 +1678,15 @@ main(int argc, char **argv) {
|
||||
coap_startup();
|
||||
|
||||
while ((opt = getopt(argc, argv,
|
||||
"a:b:c:e:f:h:j:k:l:m:no:p:rs:t:u:v:wA:B:C:E:G:H:J:K:L:M:NO:P:R:T:UV:X:")) != -1) {
|
||||
"a:b:c:d:e:f:h:j:k:l:m:no:p:q:rs:t:u:v:wA:B:C:E:G:H:J:K:L:M:NO:P:R:T:UV:X:2")) != -1) {
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
strncpy(node_str, optarg, NI_MAXHOST - 1);
|
||||
node_str[NI_MAXHOST - 1] = '\0';
|
||||
break;
|
||||
case 'b':
|
||||
cmdline_blocksize(optarg);
|
||||
if (!cmdline_blocksize(optarg))
|
||||
goto failed;
|
||||
break;
|
||||
case 'B':
|
||||
wait_seconds = atoi(optarg);
|
||||
@@ -1631,6 +1700,10 @@ main(int argc, char **argv) {
|
||||
case 'R':
|
||||
root_ca_file = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
cid_every = atoi(optarg);
|
||||
setup_cid = 1;
|
||||
break;
|
||||
case 'e':
|
||||
if (!cmdline_input(optarg, &payload))
|
||||
payload.length = 0;
|
||||
@@ -1758,6 +1831,13 @@ main(int argc, char **argv) {
|
||||
goto failed;
|
||||
}
|
||||
break;
|
||||
case 'q':
|
||||
tls_engine_conf = optarg;
|
||||
doing_tls_engine = 1;
|
||||
break;
|
||||
case '2':
|
||||
ec_jpake = 1;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0], LIBCOAP_PACKAGE_VERSION);
|
||||
goto failed;
|
||||
@@ -1825,6 +1905,11 @@ main(int argc, char **argv) {
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (doing_tls_engine) {
|
||||
if (!cmdline_tls_engine(tls_engine_conf))
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (doing_oscore) {
|
||||
if (get_oscore_conf() == NULL)
|
||||
goto failed;
|
||||
@@ -1839,6 +1924,12 @@ main(int argc, char **argv) {
|
||||
coap_register_nack_handler(ctx, nack_handler);
|
||||
if (the_token.length > COAP_TOKEN_DEFAULT_MAX)
|
||||
coap_context_set_max_token_size(ctx, the_token.length);
|
||||
if (cid_every) {
|
||||
if (!coap_context_set_cid_tuple_change(ctx, cid_every)) {
|
||||
coap_log_warn("coap_context_set_cid_tuple_change: "
|
||||
"Unable to set CID tuple change\n");
|
||||
}
|
||||
}
|
||||
|
||||
session = get_session(ctx,
|
||||
node_str[0] ? node_str : NULL,
|
||||
@@ -1865,10 +1956,9 @@ main(int argc, char **argv) {
|
||||
coap_session_init_token(session, the_token.length, the_token.s);
|
||||
|
||||
/* Convert provided uri into CoAP options */
|
||||
if (coap_uri_into_options(&uri, !uri_host_option && !proxy.host.length ?
|
||||
&dst : NULL,
|
||||
&optlist, create_uri_opts,
|
||||
buf, sizeof(buf)) < 0) {
|
||||
if (!coap_uri_into_optlist(proxy.host.length ? &proxy : &uri, !uri_host_option ?
|
||||
&dst : NULL,
|
||||
&optlist, create_uri_opts)) {
|
||||
coap_log_err("Failed to create options for URI\n");
|
||||
goto failed;
|
||||
}
|
||||
|
||||
+12
-14
@@ -3,7 +3,7 @@
|
||||
/* coap -- simple implementation of the Constrained Application Protocol (CoAP)
|
||||
* as defined in RFC 7252
|
||||
*
|
||||
* Copyright (C) 2010--2015,2022-2023 Olaf Bergmann <bergmann@tzi.org>
|
||||
* Copyright (C) 2010--2015,2022-2024 Olaf Bergmann <bergmann@tzi.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -514,20 +514,18 @@ hnd_post_rd(coap_resource_t *resource COAP_UNUSED,
|
||||
|
||||
{
|
||||
/* split path into segments and add Location-Path options */
|
||||
unsigned char _b[LOCSIZE];
|
||||
unsigned char *b = _b;
|
||||
size_t buflen = sizeof(_b);
|
||||
int nseg;
|
||||
coap_optlist_t *optlist_chain = NULL;
|
||||
|
||||
nseg = coap_split_path(loc, loc_size, b, &buflen);
|
||||
while (nseg--) {
|
||||
coap_add_option(response,
|
||||
COAP_OPTION_LOCATION_PATH,
|
||||
coap_opt_length(b),
|
||||
coap_opt_value(b));
|
||||
b += coap_opt_size(b);
|
||||
}
|
||||
/* add Location-Path */
|
||||
if (!coap_path_into_optlist(loc, loc_size, COAP_OPTION_LOCATION_PATH,
|
||||
&optlist_chain))
|
||||
goto error;
|
||||
if (!coap_add_optlist_pdu(response, &optlist_chain))
|
||||
goto error;
|
||||
|
||||
coap_delete_optlist(optlist_chain);
|
||||
}
|
||||
error:
|
||||
coap_free(loc);
|
||||
}
|
||||
|
||||
@@ -559,7 +557,7 @@ usage(const char *program, const char *version) {
|
||||
program = ++p;
|
||||
|
||||
fprintf(stderr, "%s v%s -- CoRE Resource Directory implementation\n"
|
||||
"(c) 2011-2012,2019-2023 Olaf Bergmann <bergmann@tzi.org> and others\n\n"
|
||||
"(c) 2011-2012,2019-2024 Olaf Bergmann <bergmann@tzi.org> and others\n\n"
|
||||
"Build: %s\n"
|
||||
"%s\n"
|
||||
, program, version, lib_build,
|
||||
|
||||
+404
-764
File diff suppressed because it is too large
Load Diff
@@ -31,3 +31,9 @@ server: $(CONTIKI)
|
||||
clean:
|
||||
$(MAKE) -f Makefile.contiki CONTIKI=$(CONTIKI) TARGET=$(TARGET) clean
|
||||
rm -rf build
|
||||
|
||||
distclean:
|
||||
$(MAKE) -f Makefile.contiki CONTIKI=$(CONTIKI) TARGET=$(TARGET) distclean
|
||||
|
||||
viewconf:
|
||||
$(MAKE) -f Makefile.contiki CONTIKI=$(CONTIKI) TARGET=$(TARGET) viewconf
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../../coap_config.h.contiki
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* coap_config.h.contiki -- Contiki configuration for libcoap
|
||||
*
|
||||
* Copyright (C) 2021-2024 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*/
|
||||
|
||||
#ifndef COAP_CONFIG_H_
|
||||
#define COAP_CONFIG_H_
|
||||
|
||||
/* Define to 1 if libcoap supports client mode code. */
|
||||
#define COAP_CLIENT_SUPPORT 1
|
||||
|
||||
/* Define to 1 if libcoap supports server mode code. */
|
||||
#define COAP_SERVER_SUPPORT 1
|
||||
|
||||
#if COAP_CLIENT_SUPPORT && COAP_SERVER_SUPPORT
|
||||
/* Define to 1 if libcoap supports proxy code. */
|
||||
#define COAP_PROXY_SUPPORT 1
|
||||
#endif /* COAP_CLIENT_SUPPORT && COAP_SERVER_SUPPORT */
|
||||
|
||||
/* Define to 1 if the system has small stack size. */
|
||||
#define COAP_CONSTRAINED_STACK 1
|
||||
|
||||
/* Define to 1 to build without TCP support. */
|
||||
#define COAP_DISABLE_TCP 1
|
||||
|
||||
/* Define to 1 to build support for IPv4 packets. */
|
||||
/* #undef COAP_IPV4_SUPPORT 1 */
|
||||
|
||||
/* Define to 1 to build support for IPv6 packets. */
|
||||
#define COAP_IPV6_SUPPORT 1
|
||||
|
||||
/* Define to 1 to build support for Unix socket packets. */
|
||||
/* #undef COAP_AF_UNIX_SUPPORT 1 */
|
||||
|
||||
/* Define to 1 to build with support for async separate responses. */
|
||||
#define COAP_ASYNC_SUPPORT 1
|
||||
|
||||
/* Define to 1 to build support for persisting observes. */
|
||||
/* #undef COAP_WITH_OBSERVE_PERSIST 1 */
|
||||
|
||||
/* Define to 1 to build with WebSockets support. */
|
||||
/* #undef COAP_WS_SUPPORT 1 */
|
||||
|
||||
/* Define to 1 to build with Q-Block (RFC9177) support. */
|
||||
/* #undef COAP_Q_BLOCK_SUPPORT 1 */
|
||||
|
||||
/* Define to 1 to build with thread recursive lock detection support. */
|
||||
/* #undef COAP_THREAD_RECURSIVE_CHECK 1 */
|
||||
|
||||
/* Define to 1 if libcoap has thread safe support. */
|
||||
/* #undef COAP_THREAD_SAFE 1 */
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#define HAVE_ASSERT_H 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* Define to 1 if you have the <stddef.h> header file. */
|
||||
#define HAVE_STDDEF_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the `strcasecmp' function. */
|
||||
#define HAVE_STRCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the `strnlen' function. */
|
||||
#define HAVE_STRNLEN 1
|
||||
|
||||
/* Define to 1 if you have the `strrchr' function. */
|
||||
#define HAVE_STRRCHR 1
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#define HAVE_SNPRINTF 1
|
||||
|
||||
#ifndef PACKAGE_BUGREPORT
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "libcoap-developers@lists.sourceforge.net"
|
||||
#endif /* PACKAGE_BUGREPORT */
|
||||
|
||||
#ifndef PACKAGE_NAME
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "libcoap"
|
||||
#endif /* PACKAGE_NAME */
|
||||
|
||||
#ifndef PACKAGE_STRING
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "libcoap 4.3.5"
|
||||
#endif /* PACKAGE_STRING */
|
||||
|
||||
#ifndef PACKAGE_TARNAME
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "libcoap"
|
||||
#endif /* PACKAGE_TARNAME */
|
||||
|
||||
#ifndef PACKAGE_URL
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL "https://libcoap.net/"
|
||||
#endif /* PACKAGE_URL */
|
||||
|
||||
#ifndef PACKAGE_VERSION
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "4.3.5"
|
||||
#endif /* PACKAGE_VERSION */
|
||||
|
||||
#define WITH_CONTIKI 1
|
||||
|
||||
#define HASH_NONFATAL_OOM 1
|
||||
|
||||
#ifndef HEAPMEM_CONF_ARENA_SIZE
|
||||
#define HEAPMEM_CONF_ARENA_SIZE 6144
|
||||
#endif
|
||||
|
||||
#endif /* COAP_CONFIG_H_ */
|
||||
+11
-9
@@ -170,10 +170,10 @@ hnd_post_test(coap_resource_t *resource COAP_UNUSED,
|
||||
const uint8_t *data;
|
||||
|
||||
#define BUFSIZE 20
|
||||
int res;
|
||||
unsigned char _buf[BUFSIZE];
|
||||
unsigned char *buf = _buf;
|
||||
size_t buflen = BUFSIZE;
|
||||
coap_optlist_t *optlist_chain = NULL;
|
||||
|
||||
coap_get_data(request, &len, &data);
|
||||
|
||||
@@ -208,18 +208,20 @@ hnd_post_test(coap_resource_t *resource COAP_UNUSED,
|
||||
coap_add_payload(r, test_payload);
|
||||
|
||||
/* add Location-Path */
|
||||
res = coap_split_path(uri->s, uri->length, buf, &buflen);
|
||||
if (!coap_path_into_optlist(uri->s, uri->length, COAP_OPTION_LOCATION_PATH,
|
||||
&optlist_chain))
|
||||
goto error;
|
||||
if (!coap_add_optlist_pdu(response, &optlist_chain))
|
||||
goto error;
|
||||
|
||||
while (res--) {
|
||||
coap_add_option(response, COAP_OPTION_LOCATION_PATH,
|
||||
coap_opt_length(buf), coap_opt_value(buf));
|
||||
|
||||
buf += coap_opt_size(buf);
|
||||
}
|
||||
coap_delete_optlist(optlist_chain);
|
||||
|
||||
coap_pdu_set_code(response, COAP_RESPONSE_CODE_CREATED);
|
||||
}
|
||||
return;
|
||||
|
||||
error:
|
||||
coap_delete_optlist(optlist_chain);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -509,7 +511,7 @@ init_resources(coap_context_t *ctx) {
|
||||
coap_register_request_handler(r, COAP_REQUEST_GET, hnd_get_separate);
|
||||
|
||||
coap_add_attr(r, coap_make_str_const("ct"), coap_make_str_const("0"), 0);
|
||||
coap_add_attr(r, coap_make_str_const("rt"), coap_make_str_const("seperate"), 0);
|
||||
coap_add_attr(r, coap_make_str_const("rt"), coap_make_str_const("separate"), 0);
|
||||
coap_add_resource(ctx, r);
|
||||
}
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ function TD_COAP_CORE_11 {
|
||||
# Client sends a confirmable GET request to server's resource
|
||||
#
|
||||
# check: sent request contains Type=0(CON) and Code=1(GET), Option
|
||||
# type=URI-Path (one for each path segment)
|
||||
# type=Uri-Path (one for each path segment)
|
||||
#
|
||||
# check: Server sends response containing Code=69(2.05 content),
|
||||
# Payload=Content of the requested resource, Content type option
|
||||
@@ -365,7 +365,7 @@ function TD_COAP_CORE_12 {
|
||||
# (e.g. ?first=1&second=2&third=3) to server's resource
|
||||
#
|
||||
# check: sent request contains Type=0(CON) and Code=1(GET), Option
|
||||
# type=URI-Query (More than one query parameter)
|
||||
# type=Uri-Query (More than one query parameter)
|
||||
#
|
||||
# check: Server sends response containing Type=0/2(Con/ACK),
|
||||
# Code=69(2.05 content), Payload=Content of the requested resource,
|
||||
@@ -500,7 +500,7 @@ function TD_COAP_LINK_01 {
|
||||
# Client retrieves Server's list of resource of a specific Type 1
|
||||
#
|
||||
# check: client sends GET request for /.well-known/core resource
|
||||
# containing URI-Query indicating "rt=Type1"
|
||||
# containing Uri-Query indicating "rt=Type1"
|
||||
#
|
||||
# check: server sends response containing content-type option
|
||||
# indicating 40 (application/link-format), payload indicating only the
|
||||
|
||||
+18
-40
@@ -1,6 +1,6 @@
|
||||
# Makefile
|
||||
#
|
||||
# Copyright (C) 2010-2023 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
# Copyright (C) 2010-2024 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
@@ -15,10 +15,9 @@ LIBCOAP_API_VERSION = $(shell if [ -f $(libcoap_dir)/configure.ac ]; then \
|
||||
|
||||
coap_include_dir = $(libcoap_dir)/include/coap$(LIBCOAP_API_VERSION)
|
||||
|
||||
WITH_LWIP_BRANCH=STABLE-2_1_3_RELEASE
|
||||
WITH_LWIP_CONTRIB_BRANCH=STABLE-2_1_0_RELEASE
|
||||
WITH_LWIP_BRANCH=STABLE-2_2_0_RELEASE
|
||||
# Update to latest TinyDTLS submodule as defined for libcoap
|
||||
WITH_TINYDTLS_BRANCH=f1d47d533b70ac10e4ff0ae3a088dfe4f265d242
|
||||
WITH_TINYDTLS_BRANCH=4a6a78236043da7f8af9ad7be8488aeed6884eda
|
||||
|
||||
# Need to determine which library clock_gettime() resides in (as found by ./autogen.sh)
|
||||
LDLIBS := $(shell if [ -f $(libcoap_dir)/config.log ] ; then \
|
||||
@@ -29,10 +28,8 @@ LDLIBS := $(shell if [ -f $(libcoap_dir)/config.log ] ; then \
|
||||
# some of the built objects.
|
||||
#
|
||||
all: lwip \
|
||||
lwip-contrib \
|
||||
check-version \
|
||||
check-tinydtls \
|
||||
$(coap_include_dir)/coap.h \
|
||||
lib-server \
|
||||
server \
|
||||
lib-client \
|
||||
@@ -47,11 +44,6 @@ lwip:
|
||||
(cd lwip ; git checkout $(WITH_LWIP_BRANCH))
|
||||
$(MAKE)
|
||||
|
||||
lwip-contrib:
|
||||
git clone --depth 1 https://git.savannah.nongnu.org/git/lwip/lwip-contrib.git -b $(WITH_LWIP_CONTRIB_BRANCH)
|
||||
(cd lwip-contrib ; git checkout $(WITH_LWIP_CONTRIB_BRANCH))
|
||||
$(MAKE)
|
||||
|
||||
check-version:
|
||||
@(if [ -d lwip ] ; then \
|
||||
cd lwip ; \
|
||||
@@ -65,18 +57,6 @@ check-version:
|
||||
fi ; \
|
||||
fi ; \
|
||||
fi)
|
||||
@(if [ -d lwip-contrib ] ; then \
|
||||
cd lwip-contrib ; \
|
||||
TAG=`git describe --tags`; \
|
||||
if [ "$$TAG" != ${WITH_LWIP_CONTRIB_BRANCH} ] ; then \
|
||||
if [ "$$TAG" != "tags/${WITH_LWIP_CONTRIB_BRANCH}" ] ; then \
|
||||
echo "Updating lwip-contib to ${WITH_LWIP_CONTRIB_BRANCH}" ; \
|
||||
cd .. ; \
|
||||
rm -rf lwip-contrib ; \
|
||||
${MAKE}; \
|
||||
fi ; \
|
||||
fi ; \
|
||||
fi)
|
||||
|
||||
# base libcoap git has empty ext/tinydtls
|
||||
check-tinydtls:
|
||||
@@ -114,21 +94,21 @@ check-tinydtls:
|
||||
${MAKE} ; \
|
||||
fi)
|
||||
|
||||
# lwip and coap opts (include early to shadow the lwip-contrib/ports/unix/proj/minimal/ file and any ../../config.h)
|
||||
# lwip and coap opts (include early to shadow the lwip/contrib/ports/unix/proj/minimal/ file and any ../../config.h)
|
||||
CFLAGS += -DWITH_LWIP -iquote./config $(EXTRA_CFLAGS)
|
||||
|
||||
# lwip library
|
||||
|
||||
CFLAGS += -Ilwip/src/include/ -Ilwip/src/include/ipv4/ \
|
||||
-Ilwip-contrib/ports/unix/port/include/ \
|
||||
-Ilwip-contrib/ports/unix/proj/minimal/
|
||||
-Ilwip/contrib/ports/unix/port/include/ \
|
||||
-Ilwip/contrib/ports/unix/proj/minimal/
|
||||
|
||||
LWIP_SRC = def.c init.c tapif.c etharp.c netif.c timeouts.c stats.c udp.c \
|
||||
tcp.c pbuf.c ip4_addr.c ip4.c inet_chksum.c tcp_in.c tcp_out.c \
|
||||
icmp.c raw.c ip4_frag.c sys_arch.c ethernet.c ip.c mem.c memp.c
|
||||
vpath %.c lwip/src/core/ lwip-contrib/ports/unix/proj/minimal/ \
|
||||
lwip/src/netif/ lwip/src/core/ipv4/ lwip-contrib/ports/unix/port/ \
|
||||
lwip-contrib/ports/unix/port/netif/
|
||||
icmp.c raw.c ip4_frag.c sys_arch.c ethernet.c ip.c mem.c memp.c tcpip.c
|
||||
vpath %.c lwip/src/core/ lwip/contrib/ports/unix/proj/minimal/ \
|
||||
lwip/src/netif/ lwip/src/core/ipv4/ lwip/contrib/ports/unix/port/ \
|
||||
lwip/contrib/ports/unix/port/netif/ lwip/src/api/
|
||||
# CFLAGS += -DLWIP_UNIX_LINUX
|
||||
|
||||
# if ipv6 is used
|
||||
@@ -166,12 +146,16 @@ COAP_SRC = coap_address.c \
|
||||
coap_option.c \
|
||||
coap_oscore.c \
|
||||
coap_pdu.c \
|
||||
coap_prng.c \
|
||||
coap_proxy.c \
|
||||
coap_resource.c \
|
||||
coap_session.c \
|
||||
coap_subscribe.c \
|
||||
coap_tinydtls.c \
|
||||
coap_sha1.c \
|
||||
coap_str.c \
|
||||
coap_subscribe.c \
|
||||
coap_tcp.c \
|
||||
coap_threadsafe.c \
|
||||
coap_tinydtls.c \
|
||||
coap_uri.c \
|
||||
coap_ws.c
|
||||
|
||||
@@ -219,13 +203,7 @@ SN_OBJS = ${SN_APP_OBJ} ${SN_LWIP_OBJ} ${SN_COAP_OBJ}
|
||||
CD_OBJS = ${CD_APP_OBJ} ${CD_LWIP_OBJ} ${CD_COAP_OBJ} ${CD_DTLS_OBJ}
|
||||
SD_OBJS = ${SD_APP_OBJ} ${SD_LWIP_OBJ} ${SD_COAP_OBJ} ${SD_DTLS_OBJ}
|
||||
|
||||
$(coap_include_dir)/coap.h:
|
||||
@(if [ ! -f $(coap_include_dir)/coap.h ] ; then \
|
||||
(cd $(libcoap_dir) ; ./autogen.sh ; ./configure --disable-dtls --disable-man) ; \
|
||||
${MAKE}; \
|
||||
fi)
|
||||
|
||||
${SN_OBJS} ${SD_OBJS}: $(coap_include_dir)/coap.h server-coap.h
|
||||
${SN_OBJS} ${SD_OBJS}: server-coap.h
|
||||
|
||||
server: ${SN_OBJS}
|
||||
$(CC) $(CFLAGS) ${SN_OBJS} -o server ${LDLIBS}
|
||||
@@ -233,7 +211,7 @@ server: ${SN_OBJS}
|
||||
server-dtls: ${SD_OBJS}
|
||||
$(CC) $(CFLAGS) ${SD_OBJS} -o server-dtls ${LDLIBS}
|
||||
|
||||
${CN_OBJS} ${CD_OBJS}: $(coap_include_dir)/coap.h client-coap.h
|
||||
${CN_OBJS} ${CD_OBJS}: client-coap.h
|
||||
|
||||
client: ${CN_OBJS}
|
||||
$(CC) $(CFLAGS) ${CN_OBJS} -o client ${LDLIBS}
|
||||
|
||||
@@ -52,16 +52,16 @@ interface will need IP forwarding enabled
|
||||
$ sudo sysctl -w net.ipv4.conf.default.forwarding=1
|
||||
|
||||
Then you will need IP forwarding enabled on your public interface
|
||||
(where eth0 is replaced by your public facing interface name)
|
||||
(where ens32 is replaced by your public facing interface name)
|
||||
for response packets
|
||||
|
||||
$ sudo sysctl -w net.eth0.conf.default.forwarding=1
|
||||
$ sudo sysctl -w net.ipv4.conf.ens32.forwarding=1
|
||||
|
||||
As well as the interface connecting to the internet will need a NAT rule to
|
||||
masquerade the internal IP address (192.168.114.2) to the IP of the outgoing
|
||||
interface (where eth0 is replaced by your public facing interface name)
|
||||
interface (where ens32 is replaced by your public facing interface name)
|
||||
|
||||
$ iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
||||
$ sudo iptables -t nat -A POSTROUTING -o ens32 -j MASQUERADE
|
||||
|
||||
The client supports the following options
|
||||
"-k PSK" option where PSK defines the DTLS PSK to use (default is "secretPSK").
|
||||
|
||||
+24
-20
@@ -2,7 +2,7 @@
|
||||
* client-coap.c -- LwIP example
|
||||
*
|
||||
* Copyright (C) 2013-2016 Christian Amsüss <chrysn@fsfe.org>
|
||||
* Copyright (C) 2018-2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
* Copyright (C) 2018-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
#include "coap_config.h"
|
||||
|
||||
#include <coap3/coap.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -76,7 +77,7 @@ nack_handler(coap_session_t *session COAP_UNUSED,
|
||||
|
||||
static int
|
||||
resolve_address(const char *host, const char *service, coap_address_t *dst,
|
||||
int scheme_hint_bits) {
|
||||
coap_proto_t *proto, int scheme_hint_bits) {
|
||||
|
||||
coap_addr_info_t *addr_info;
|
||||
coap_str_const_t str_host;
|
||||
@@ -92,6 +93,7 @@ resolve_address(const char *host, const char *service, coap_address_t *dst,
|
||||
if (addr_info) {
|
||||
ret = 1;
|
||||
*dst = addr_info->addr;
|
||||
*proto = addr_info->proto;
|
||||
}
|
||||
|
||||
coap_free_address_info(addr_info);
|
||||
@@ -118,6 +120,7 @@ client_coap_init(coap_lwip_input_wait_handler_t input_wait, void *input_arg,
|
||||
const char *use_psk = "secretPSK";
|
||||
const char *use_id = "abc";
|
||||
coap_pdu_type_t pdu_type = COAP_MESSAGE_CON;
|
||||
coap_proto_t proto;
|
||||
|
||||
/* Initialize libcoap library */
|
||||
coap_startup();
|
||||
@@ -155,40 +158,34 @@ client_coap_init(coap_lwip_input_wait_handler_t input_wait, void *input_arg,
|
||||
/* Parse the URI */
|
||||
len = coap_split_uri((const unsigned char *)use_uri, strlen(use_uri), &uri);
|
||||
LWIP_ASSERT("Failed to parse uri", len == 0);
|
||||
LWIP_ASSERT("Unsupported URI type", uri.scheme == COAP_URI_SCHEME_COAP ||
|
||||
uri.scheme == COAP_URI_SCHEME_COAPS);
|
||||
if (uri.scheme == COAP_URI_SCHEME_COAPS) {
|
||||
LWIP_ASSERT("DTLS not supported", coap_dtls_is_supported());
|
||||
}
|
||||
|
||||
snprintf(portbuf, sizeof(portbuf), "%d", uri.port);
|
||||
snprintf((char *)buf, sizeof(buf), "%*.*s", (int)uri.host.length,
|
||||
(int)uri.host.length, (const char *)uri.host.s);
|
||||
/* resolve destination address where server should be sent */
|
||||
len = resolve_address((const char *)buf, portbuf, &dst, 1 << uri.scheme);
|
||||
len = resolve_address((const char *)buf, portbuf, &dst, &proto, 1 << uri.scheme);
|
||||
LWIP_ASSERT("Failed to resolve address", len > 0);
|
||||
|
||||
main_coap_context = coap_new_context(NULL);
|
||||
LWIP_ASSERT("Failed to initialize context", main_coap_context != NULL);
|
||||
|
||||
coap_context_set_block_mode(main_coap_context, COAP_BLOCK_USE_LIBCOAP);
|
||||
#if NO_SYS
|
||||
coap_lwip_set_input_wait_handler(main_coap_context, input_wait, input_arg);
|
||||
#else /* ! NO_SYS */
|
||||
(void)input_wait;
|
||||
(void)input_arg;
|
||||
#endif /* ! NO_SYS */
|
||||
|
||||
if (uri.scheme == COAP_URI_SCHEME_COAP) {
|
||||
session = coap_new_client_session(main_coap_context, NULL, &dst,
|
||||
COAP_PROTO_UDP);
|
||||
} else {
|
||||
if (proto == COAP_PROTO_DTLS || proto == COAP_PROTO_TLS ||
|
||||
proto == COAP_PROTO_WSS) {
|
||||
static coap_dtls_cpsk_t dtls_psk;
|
||||
static char client_sni[256];
|
||||
|
||||
memset(client_sni, 0, sizeof(client_sni));
|
||||
memset(&dtls_psk, 0, sizeof(dtls_psk));
|
||||
dtls_psk.version = COAP_DTLS_CPSK_SETUP_VERSION;
|
||||
if (uri.host.length)
|
||||
memcpy(client_sni, uri.host.s,
|
||||
min(uri.host.length, sizeof(client_sni) - 1));
|
||||
else
|
||||
memcpy(client_sni, "localhost", 9);
|
||||
snprintf(client_sni, sizeof(client_sni), "%*.*s", (int)uri.host.length, (int)uri.host.length,
|
||||
uri.host.s);
|
||||
dtls_psk.client_sni = client_sni;
|
||||
dtls_psk.psk_info.identity.s = (const uint8_t *)use_id;
|
||||
dtls_psk.psk_info.identity.length = strlen(use_id);
|
||||
@@ -197,10 +194,17 @@ client_coap_init(coap_lwip_input_wait_handler_t input_wait, void *input_arg,
|
||||
|
||||
session = coap_new_client_session_psk2(main_coap_context, NULL, &dst,
|
||||
COAP_PROTO_DTLS, &dtls_psk);
|
||||
} else {
|
||||
session = coap_new_client_session(main_coap_context, NULL, &dst,
|
||||
proto);
|
||||
}
|
||||
|
||||
LWIP_ASSERT("Failed to create session", session != NULL);
|
||||
|
||||
if (proto == COAP_PROTO_WS || proto == COAP_PROTO_WSS) {
|
||||
coap_ws_set_host_request(session, &uri.host);
|
||||
}
|
||||
|
||||
coap_register_response_handler(main_coap_context, message_handler);
|
||||
coap_register_nack_handler(main_coap_context, nack_handler);
|
||||
|
||||
@@ -211,8 +215,8 @@ client_coap_init(coap_lwip_input_wait_handler_t input_wait, void *input_arg,
|
||||
coap_session_max_pdu_size(session));
|
||||
LWIP_ASSERT("Failed to create PDU", pdu != NULL);
|
||||
|
||||
len = coap_uri_into_options(&uri, &dst, &optlist, 1, buf, sizeof(buf));
|
||||
LWIP_ASSERT("Failed to create options", len == 0);
|
||||
res = coap_uri_into_optlist(&uri, &dst, &optlist, 1);
|
||||
LWIP_ASSERT("Failed to create options", res == 1);
|
||||
|
||||
/* Add option list (which will be sorted) to the PDU */
|
||||
if (optlist) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* server-coap.h -- LwIP example
|
||||
*
|
||||
* Copyright (C) 2013-2016 Christian Amsüss <chrysn@fsfe.org>
|
||||
* Copyright (C) 2022-2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
* Copyright (C) 2022-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
|
||||
+18
-13
@@ -53,9 +53,7 @@ static void
|
||||
handle_sigint(int signum) {
|
||||
(void)signum;
|
||||
|
||||
client_coap_finished();
|
||||
printf("Client Application finished.\n");
|
||||
exit(0);
|
||||
quit = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -64,13 +62,23 @@ handle_sigint(int signum) {
|
||||
*/
|
||||
static int
|
||||
wait_for_input(void *arg, uint32_t milli_secs) {
|
||||
struct netif *netif = (struct netif *)arg;
|
||||
int ret;
|
||||
|
||||
(void)milli_secs;
|
||||
/*
|
||||
* Poll netif, pass any read packet to lwIP
|
||||
* Has internal timeout of 1000 msec (sometimes less) based on
|
||||
* sys_timeouts_sleeptime().
|
||||
*/
|
||||
#if NO_SYS
|
||||
struct netif *netif = (struct netif *)arg;
|
||||
ret = tapif_select(netif);
|
||||
|
||||
sys_check_timeouts();
|
||||
#else /* ! NO_SYS */
|
||||
(void)arg;
|
||||
ret = 0;
|
||||
#endif /* ! NO_SYS */
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -92,7 +100,13 @@ main(int argc, char **argv) {
|
||||
IP4_ADDR(&netmask, 255,255,255,0);
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
#if NO_SYS
|
||||
lwip_init();
|
||||
#else /* ! NO_SYS */
|
||||
#include <lwip/tcpip.h>
|
||||
(void)lock_tcpip_core;
|
||||
tcpip_init(NULL, NULL);
|
||||
#endif /* ! NO_SYS */
|
||||
|
||||
printf("TCP/IP initialized.\n");
|
||||
|
||||
@@ -128,15 +142,6 @@ main(int argc, char **argv) {
|
||||
printf("Client Application started.\n");
|
||||
|
||||
while (!quit && !no_more) {
|
||||
/*
|
||||
* Poll netif, pass any read packet to lwIP
|
||||
* Has internal timeout of 100 msec (sometimes less) based on
|
||||
* sys_timeouts_sleeptime().
|
||||
*/
|
||||
tapif_select(&netif);
|
||||
|
||||
sys_check_timeouts();
|
||||
|
||||
no_more = client_coap_poll();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* coap_config.h.lwip -- LwIP configuration for libcoap
|
||||
* coap_config.h -- LwIP configuration for libcoap
|
||||
*
|
||||
* Copyright (C) 2021-2023 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
* Copyright (C) 2021-2024 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -33,7 +33,11 @@
|
||||
|
||||
#ifndef COAP_DISABLE_TCP
|
||||
/* Define to 1 to build without TCP support. */
|
||||
#if LWIP_TCP
|
||||
#define COAP_DISABLE_TCP 0
|
||||
#else /* ! LWIP_TCP */
|
||||
#define COAP_DISABLE_TCP 1
|
||||
#endif /* ! LWIP_TCP */
|
||||
#endif
|
||||
|
||||
#ifndef COAP_ASYNC_SUPPORT
|
||||
@@ -56,11 +60,49 @@
|
||||
#define COAP_Q_BLOCK_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#define PACKAGE_NAME "libcoap"
|
||||
#define PACKAGE_VERSION "4.3.4"
|
||||
#define PACKAGE_STRING "libcoap 4.3.4"
|
||||
#ifndef COAP_THREAD_SAFE
|
||||
/* Define to 1 if libcoap has thread safe support. */
|
||||
#define COAP_THREAD_SAFE 0
|
||||
#endif
|
||||
|
||||
#ifndef COAP_THREAD_RECURSIVE_CHECK
|
||||
/* Define to 1 to build with thread recursive lock detection support. */
|
||||
#define COAP_THREAD_RECURSIVE_CHECK 0
|
||||
#endif
|
||||
|
||||
#ifndef PACKAGE_BUGREPORT
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "libcoap-developers@lists.sourceforge.net"
|
||||
#endif /* PACKAGE_BUGREPORT */
|
||||
|
||||
#ifndef PACKAGE_NAME
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "libcoap"
|
||||
#endif /* PACKAGE_NAME */
|
||||
|
||||
#ifndef PACKAGE_STRING
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "libcoap 4.3.5"
|
||||
#endif /* PACKAGE_STRING */
|
||||
|
||||
#ifndef PACKAGE_TARNAME
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "libcoap"
|
||||
#endif /* PACKAGE_TARNAME */
|
||||
|
||||
#ifndef PACKAGE_URL
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL "https://libcoap.net/"
|
||||
#endif /* PACKAGE_URL */
|
||||
|
||||
#ifndef PACKAGE_VERSION
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "4.3.5"
|
||||
#endif /* PACKAGE_VERSION */
|
||||
|
||||
#ifndef assert
|
||||
#define assert(x) LWIP_ASSERT("CoAP assert failed", x)
|
||||
#endif /* assert */
|
||||
|
||||
/* it's just provided by libc. i hope we don't get too many of those, as
|
||||
* actually we'd need autotools again to find out what environment we're
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* coap_config.h.lwip -- LwIP configuration for libcoap
|
||||
*
|
||||
* Copyright (C) 2021-2023 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*/
|
||||
|
||||
#ifndef COAP_CONFIG_H_
|
||||
#define COAP_CONFIG_H_
|
||||
|
||||
#include <lwip/opt.h>
|
||||
#include <lwip/debug.h>
|
||||
#include <lwip/def.h> /* provide ntohs, htons */
|
||||
|
||||
#define WITH_LWIP 1
|
||||
|
||||
#if LWIP_IPV4
|
||||
#define COAP_IPV4_SUPPORT 1
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
#if LWIP_IPV6
|
||||
#define COAP_IPV6_SUPPORT 1
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
#ifndef COAP_CONSTRAINED_STACK
|
||||
/* Define to 1 to minimize stack usage. */
|
||||
#define COAP_CONSTRAINED_STACK 1
|
||||
#endif
|
||||
|
||||
#ifndef COAP_DISABLE_TCP
|
||||
/* Define to 1 to build without TCP support. */
|
||||
#define COAP_DISABLE_TCP 1
|
||||
#endif
|
||||
|
||||
#ifndef COAP_ASYNC_SUPPORT
|
||||
/* Define to 1 to build with support for async separate responses. */
|
||||
#define COAP_ASYNC_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#ifndef COAP_WITH_OBSERVE_PERSIST
|
||||
/* Define to 1 to build support for persisting observes. */
|
||||
#define COAP_WITH_OBSERVE_PERSIST 0
|
||||
#endif
|
||||
|
||||
#ifndef COAP_WS_SUPPORT
|
||||
/* Define to 1 to build with WebSockets support. */
|
||||
#define COAP_WS_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#ifndef COAP_Q_BLOCK_SUPPORT
|
||||
/* Define to 1 to build with Q-Block (RFC9177) support. */
|
||||
#define COAP_Q_BLOCK_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#define PACKAGE_NAME "@PACKAGE_NAME@"
|
||||
#define PACKAGE_VERSION "@PACKAGE_VERSION@"
|
||||
#define PACKAGE_STRING "@PACKAGE_STRING@"
|
||||
|
||||
#define assert(x) LWIP_ASSERT("CoAP assert failed", x)
|
||||
|
||||
/* it's just provided by libc. i hope we don't get too many of those, as
|
||||
* actually we'd need autotools again to find out what environment we're
|
||||
* building in */
|
||||
#define HAVE_STRNLEN 1
|
||||
|
||||
#define HAVE_LIMITS_H
|
||||
|
||||
#define HAVE_NETDB_H
|
||||
|
||||
#define HAVE_SNPRINTF
|
||||
|
||||
#define HAVE_ERRNO_H
|
||||
|
||||
#endif /* COAP_CONFIG_H_ */
|
||||
@@ -2,7 +2,7 @@
|
||||
* lwipopts.h -- LwIP example
|
||||
*
|
||||
* Copyright (C) 2013-2016 Christian Amsüss <chrysn@fsfe.org>
|
||||
* Copyright (C) 2018-2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
* Copyright (C) 2018-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -10,7 +10,14 @@
|
||||
* of use.
|
||||
*/
|
||||
|
||||
#define NO_SYS 1
|
||||
/*
|
||||
* NO_SYS = 0
|
||||
* Use lwIP OS-awareness (multi threaded, semaphores, mutexes and mboxes).
|
||||
*
|
||||
* NO_SYS = 1
|
||||
* Use lwIP without OS-awareness (no thread, semaphores, mutexes or mboxes).
|
||||
*/
|
||||
#define NO_SYS 0
|
||||
#define LWIP_SOCKET (NO_SYS==0)
|
||||
#define LWIP_NETCONN (NO_SYS==0)
|
||||
#define LWIP_NETIF_API (NO_SYS==0)
|
||||
@@ -23,9 +30,8 @@
|
||||
#define LWIP_IPV6_MLD 0
|
||||
#define LWIP_ICMP6 (LWIP_IPV6==1)
|
||||
|
||||
#ifndef LWIP_RAND
|
||||
#define LWIP_RAND() ((u32_t)rand())
|
||||
#endif
|
||||
/* Set to 1 if TCP support is required */
|
||||
#define LWIP_TCP 0
|
||||
|
||||
#ifndef netif_get_index
|
||||
#define netif_get_index(netif) ((u8_t)((netif)->num + 1))
|
||||
@@ -34,8 +40,14 @@
|
||||
#if NO_SYS
|
||||
#define LOCK_TCPIP_CORE()
|
||||
#define UNLOCK_TCPIP_CORE()
|
||||
#else
|
||||
#define COAP_THREAD_SAFE 1
|
||||
#define COAP_THREAD_RECURSIVE_CHECK 0
|
||||
#define LWIP_TCPIP_CORE_LOCKING 1
|
||||
#endif
|
||||
|
||||
#define MEMP_NUM_SYS_TIMEOUT 10
|
||||
|
||||
#define MEMP_USE_CUSTOM_POOLS 1
|
||||
#define MEM_SIZE (4 * 1024)
|
||||
/* Support a 1500 MTU packet */
|
||||
|
||||
@@ -16,8 +16,11 @@
|
||||
#include "coap3/coap_resource.h"
|
||||
#include "coap3/coap_subscribe.h"
|
||||
#ifdef COAP_WITH_LIBTINYDTLS
|
||||
|
||||
#ifndef LWIP_TINYDTLS_LOCAL_FIX
|
||||
#define LWIP_TINYDTLS_LOCAL_FIX
|
||||
|
||||
#if defined(WITH_LWIP_NO_SOCKET)
|
||||
#include <lwip/ip_addr.h>
|
||||
/* Local copies of struct to simplify #include nightmare */
|
||||
typedef struct {
|
||||
@@ -26,6 +29,11 @@ typedef struct {
|
||||
ip_addr_t addr; /**< session IP address */
|
||||
int ifindex; /**< network interface index */
|
||||
} l_session_t;
|
||||
#else /* ! WITH_LWIP_NO_SOCKET */
|
||||
typedef struct {
|
||||
char dummy[36];
|
||||
} l_session_t;
|
||||
#endif /* ! WITH_LWIP_NO_SOCKET */
|
||||
|
||||
typedef struct l_coap_tiny_context_t {
|
||||
struct dtls_context_t *dtls_context;
|
||||
@@ -43,11 +51,19 @@ typedef struct l_coap_tiny_context_t {
|
||||
#endif
|
||||
|
||||
#ifndef MEMP_NUM_COAPENDPOINT
|
||||
#if COAP_DISABLE_TCP
|
||||
#ifdef COAP_WITH_LIBTINYDTLS
|
||||
#define MEMP_NUM_COAPENDPOINT 2
|
||||
#else /* ! COAP_WITH_LIBTINYDTLS */
|
||||
#define MEMP_NUM_COAPENDPOINT 1
|
||||
#endif /* ! COAP_WITH_LIBTINYDTLS */
|
||||
#else /* ! COAP_DISABLE_TCP */
|
||||
#ifdef COAP_WITH_LIBTINYDTLS
|
||||
#define MEMP_NUM_COAPENDPOINT 4
|
||||
#else /* ! COAP_WITH_LIBTINYDTLS */
|
||||
#define MEMP_NUM_COAPENDPOINT 2
|
||||
#endif /* ! COAP_WITH_LIBTINYDTLS */
|
||||
#endif /* ! COAP_DISABLE_TCP */
|
||||
#endif
|
||||
|
||||
/* 1 is sufficient as this is very short-lived */
|
||||
@@ -88,11 +104,19 @@ typedef struct l_coap_tiny_context_t {
|
||||
#endif
|
||||
|
||||
#ifndef MEMP_NUM_COAPSTRING
|
||||
#define MEMP_NUM_COAPSTRING 10
|
||||
#define MEMP_NUM_COAPSTRING 12
|
||||
#endif
|
||||
|
||||
#ifndef MEMP_LEN_COAPSTRING
|
||||
#ifdef COAP_WS_SUPPORT
|
||||
#define MEMP_LEN_COAPSTRING 176
|
||||
#else /* ! COAP_WS_SUPPORT */
|
||||
#ifdef COAP_WITH_LIBTINYDTLS
|
||||
#define MEMP_LEN_COAPSTRING 120
|
||||
#else /* COAP_WITH_TINYDTLS */
|
||||
#define MEMP_LEN_COAPSTRING 40
|
||||
#endif /* COAP_WITH_TINYDTLS */
|
||||
#endif /* ! COAP_WS_SUPPORT */
|
||||
#endif
|
||||
|
||||
#ifndef MEMP_NUM_COAPCACHE_KEYS
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* server-coap.c -- LwIP example
|
||||
*
|
||||
* Copyright (C) 2013-2016 Christian Amsüss <chrysn@fsfe.org>
|
||||
* Copyright (C) 2018-2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
* Copyright (C) 2018-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
#include "coap_config.h"
|
||||
|
||||
#include <coap3/coap.h>
|
||||
#include "server-coap.h"
|
||||
|
||||
@@ -41,8 +42,7 @@ hnd_get_time(coap_resource_t *resource, coap_session_t *session,
|
||||
* when query ?ticks is given. */
|
||||
|
||||
/* if my_clock_base was deleted, we pretend to have no such resource */
|
||||
response->code =
|
||||
my_clock_base ? COAP_RESPONSE_CODE(205) : COAP_RESPONSE_CODE(404);
|
||||
coap_pdu_set_code(response, my_clock_base ? COAP_RESPONSE_CODE(205) : COAP_RESPONSE_CODE(404));
|
||||
|
||||
if (my_clock_base)
|
||||
coap_add_option(response, COAP_OPTION_CONTENT_FORMAT,
|
||||
@@ -219,5 +219,4 @@ server_coap_poll(void) {
|
||||
last_time = time_now;
|
||||
coap_resource_notify_observers(time_resource, NULL);
|
||||
}
|
||||
coap_check_notify(main_coap_context);
|
||||
}
|
||||
|
||||
+25
-13
@@ -48,13 +48,13 @@
|
||||
static ip4_addr_t ipaddr, netmask, gw;
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
static int quit = 0;
|
||||
|
||||
void
|
||||
handle_sigint(int signum) {
|
||||
(void)signum;
|
||||
|
||||
server_coap_finished();
|
||||
printf("Server Application finished.\n");
|
||||
exit(0);
|
||||
quit = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -63,13 +63,25 @@ handle_sigint(int signum) {
|
||||
*/
|
||||
static int
|
||||
wait_for_input(void *arg, uint32_t milli_secs) {
|
||||
#if NO_SYS
|
||||
struct netif *netif = (struct netif *)arg;
|
||||
#endif /* NO_SYS */
|
||||
int ret;
|
||||
|
||||
(void)milli_secs;
|
||||
/*
|
||||
* Poll netif, pass any read packet to lwIP
|
||||
* Has internal timeout of 1000 msec (sometimes less) based on
|
||||
* sys_timeouts_sleeptime().
|
||||
*/
|
||||
#if NO_SYS
|
||||
ret = tapif_select(netif);
|
||||
|
||||
sys_check_timeouts();
|
||||
#else /* ! NO_SYS */
|
||||
(void)arg;
|
||||
ret = 0;
|
||||
#endif /* ! NO_SYS */
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -90,7 +102,13 @@ main(int argc, char **argv) {
|
||||
IP4_ADDR(&netmask, 255,255,255,0);
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
#if NO_SYS
|
||||
lwip_init();
|
||||
#else /* ! NO_SYS */
|
||||
#include <lwip/tcpip.h>
|
||||
(void)lock_tcpip_core;
|
||||
tcpip_init(NULL, NULL);
|
||||
#endif /* ! NO_SYS */
|
||||
|
||||
printf("TCP/IP initialized.\n");
|
||||
|
||||
@@ -132,18 +150,12 @@ main(int argc, char **argv) {
|
||||
|
||||
printf("Server Application started.\n");
|
||||
|
||||
while (1) {
|
||||
/*
|
||||
* Poll netif, pass any read packet to lwIP
|
||||
* Has internal timeout of 100 msec (sometimes less) based on
|
||||
* sys_timeouts_sleeptime().
|
||||
*/
|
||||
tapif_select(&netif);
|
||||
|
||||
sys_check_timeouts();
|
||||
|
||||
while (!quit) {
|
||||
server_coap_poll();
|
||||
}
|
||||
server_coap_finished();
|
||||
printf("Server Application finished.\n");
|
||||
exit(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* A server for use in the RFC 8613 OSCORE interop testing.
|
||||
* https://core-wg.github.io/oscore/test-spec5.html
|
||||
*
|
||||
* Copyright (C) 2022-2023 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
* Copyright (C) 2022-2024 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -82,7 +82,7 @@ handle_sigint(int signum COAP_UNUSED) {
|
||||
|
||||
#define INDEX "This is a OSCORE test server made with libcoap " \
|
||||
"(see https://libcoap.net)\n" \
|
||||
"Copyright (C) 2023 Olaf Bergmann <bergmann@tzi.org> " \
|
||||
"Copyright (C) 2022-2024 Olaf Bergmann <bergmann@tzi.org> " \
|
||||
"and others\n\n"
|
||||
|
||||
static void
|
||||
@@ -379,7 +379,7 @@ usage(const char *program, const char *version) {
|
||||
program = ++p;
|
||||
|
||||
fprintf(stderr, "%s v%s -- OSCORE interop implementation\n"
|
||||
"(c) 2023 Olaf Bergmann <bergmann@tzi.org> and others\n\n"
|
||||
"(c) 2022-2024 Olaf Bergmann <bergmann@tzi.org> and others\n\n"
|
||||
"Build: %s\n"
|
||||
"%s\n"
|
||||
, program, version, lib_build,
|
||||
|
||||
@@ -6,6 +6,19 @@
|
||||
#
|
||||
# By default, this script should be run in the examples directory.
|
||||
#
|
||||
# 3 separate servers are set up, listening on different ports (defaults shown)
|
||||
# Server B with security context B (interop/b_server.conf) on port 5683
|
||||
# Server D with security context D (interop/d_server.conf) on port 5685
|
||||
# Server N with No security context on port 5687
|
||||
#
|
||||
# The clients are run with security contexts A (interop/a_client.conf) and
|
||||
# C (interop/c_client.conf), and where appropriate, modifications to the
|
||||
# appropriate base security contexts (called here E (interop/e_client.conf),
|
||||
# F (interop/f_client.conf) and G (interop/g_client.conf)).
|
||||
#
|
||||
# Ports used can be modified (for listening and sending) using
|
||||
# the -B, -D and -N options for the respective servers.
|
||||
#
|
||||
# Run as
|
||||
# ./oscore_testcases.sh [-h remote-target-IP] [-B port-B-OSCORE] \
|
||||
# [-D port-D-OSCORE] [-N port-NO-OSCORE] \
|
||||
@@ -25,6 +38,9 @@
|
||||
# -N port-N-OSCORE
|
||||
# Port that the server listening on providing no security profile
|
||||
#
|
||||
# -S
|
||||
# Start up the servers only for the different profiles
|
||||
#
|
||||
# -s executable-for-interop-server
|
||||
# Exectuable to use for the interop server if not the default of ./oscore-interop-server.
|
||||
#
|
||||
@@ -59,7 +75,7 @@ PARTIAL_LOGS=no
|
||||
# Full Logs
|
||||
FULL_LOGS=no
|
||||
|
||||
while getopts "c:h:s:B:D:FN:P" OPTION; do
|
||||
while getopts "c:h:s:B:D:FN:PS" OPTION; do
|
||||
case $OPTION in
|
||||
c)
|
||||
CLIENT="$OPTARG"
|
||||
@@ -85,11 +101,15 @@ while getopts "c:h:s:B:D:FN:P" OPTION; do
|
||||
P)
|
||||
PARTIAL_LOGS=yes
|
||||
;;
|
||||
S)
|
||||
SERVERS_ONLY=yes
|
||||
;;
|
||||
*)
|
||||
echo Error in options detected
|
||||
echo Run as
|
||||
echo "$0 [-h remote-target-IP] [-B port-B-OSCORE]"
|
||||
echo " [-D port-D-OSCORE] [-N port-NO-OSCORE]"
|
||||
echo " [-S]"
|
||||
echo " [-s executable-for-interop-server]"
|
||||
echo " [-c executable-for-client]"
|
||||
echo " [-P] [-F]"
|
||||
@@ -106,9 +126,9 @@ timecheck () {
|
||||
|
||||
NO_PASS=0
|
||||
NO_FAIL=0
|
||||
# passfail count egrep-expression
|
||||
# passfail count grep-expression
|
||||
passfail () {
|
||||
PASS=`cat /tmp/client_out | egrep "$2" | wc -l`
|
||||
PASS=`cat /tmp/client_out | grep -E "$2" | wc -l`
|
||||
if [ "$PASS" = "$1" ] ; then
|
||||
echo Pass
|
||||
let "NO_PASS=$NO_PASS+1"
|
||||
@@ -119,15 +139,25 @@ passfail () {
|
||||
if [ "$FULL_LOGS" = yes ] ; then
|
||||
cat /tmp/client_out
|
||||
elif [ "$PARTIAL_LOGS" = yes ] ; then
|
||||
cat /tmp/client_out | egrep -v " DEBG | OSC "
|
||||
cat /tmp/client_out | grep -E -v " DEBG | OSC "
|
||||
fi
|
||||
}
|
||||
|
||||
$SERVER -E $INDIR/interop/b_server.conf -v8 -p $S_PORT_B > /tmp/server_b 2>&1 &
|
||||
$SERVER -E $INDIR/interop/d_server.conf -v8 -p $S_PORT_D > /tmp/server_d 2>&1 &
|
||||
$SERVER -v8 -p $S_PORT_N > /tmp/server_n 2>&1 &
|
||||
if [ "$TARGET_IP" = "127.0.0.1" -o "$SERVERS_ONLY" = yes ]; then
|
||||
killall -9 `basename $SERVER` > /dev/null 2>&1
|
||||
|
||||
sleep 1
|
||||
$SERVER -E $INDIR/interop/b_server.conf -v8 -p $S_PORT_B > /tmp/server_b 2>&1 &
|
||||
$SERVER -E $INDIR/interop/d_server.conf -v8 -p $S_PORT_D > /tmp/server_d 2>&1 &
|
||||
$SERVER -v8 -p $S_PORT_N > /tmp/server_n 2>&1 &
|
||||
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
if [ "$SERVERS_ONLY" = yes ] ; then
|
||||
echo Servers are running, output in /tmp/server_b, /tmp/server_d, and /tmp/server_n
|
||||
ps -ef | grep oscore-interop-server | grep -E -v "grep "
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Reset sequence number counters
|
||||
rm -f /tmp/client_a
|
||||
@@ -135,7 +165,7 @@ rm -f /tmp/client_c
|
||||
|
||||
# Test 0 General checkout
|
||||
echo -n "Test 0 - "
|
||||
timecheck 10 $CLIENT -w -v8 coap://$TARGET_IP:$S_PORT_B/oscore/hello/coap 2>&1 | egrep -v " DEBG | OSC " > /tmp/client_out
|
||||
timecheck 10 $CLIENT -w -v8 coap://$TARGET_IP:$S_PORT_B/oscore/hello/coap 2>&1 | grep -E -v " DEBG | OSC " > /tmp/client_out
|
||||
passfail 1 "^Hello World"
|
||||
|
||||
# Test 1
|
||||
@@ -244,9 +274,11 @@ echo -n "Test 17 - "
|
||||
timeout 10 $CLIENT -w -v8 coap://$TARGET_IP:$S_PORT_N/oscore/hello/1 > /tmp/client_out 2>&1
|
||||
passfail 1 "^4.01 Unauthorized"
|
||||
|
||||
KILL_SERVER=`basename $SERVER`
|
||||
if [ ! -z "$KILL_SERVER" ] ; then
|
||||
killall $KILL_SERVER
|
||||
if [ "$TARGET_IP" = "127.0.0.1" ]; then
|
||||
KILL_SERVER=`basename $SERVER`
|
||||
if [ ! -z "$KILL_SERVER" ] ; then
|
||||
killall $KILL_SERVER
|
||||
fi
|
||||
fi
|
||||
|
||||
echo
|
||||
|
||||
+25
-4
@@ -1,6 +1,6 @@
|
||||
# Makefile
|
||||
#
|
||||
# Copyright (C) 2010-2023 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
# Copyright (C) 2010-2024 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
@@ -10,7 +10,7 @@
|
||||
RIOT=RIOT
|
||||
TARGET?=native
|
||||
|
||||
all: RIOT pkg examples client server
|
||||
all: RIOT pkg examples client server tests
|
||||
|
||||
RIOT:
|
||||
git clone --depth 1 https://github.com/RIOT-OS/RIOT.git $@
|
||||
@@ -24,13 +24,25 @@ pkg:
|
||||
git pull --unshallow > /dev/null 2>&1 ; \
|
||||
if [ ! -z "$${RIOT_HASH}" ] ; then \
|
||||
(cd pkg_libcoap/patches ; git format-patch -n $${RIOT_HASH}) ; \
|
||||
fi \
|
||||
fi ; \
|
||||
COMMIT_FILE=pkg_libcoap/patches/9999-Not-Yet-Commited.patch ; \
|
||||
WC=`git diff HEAD -p --stat | wc -l` ; \
|
||||
if [ "$${WC}" != 0 ] ; then \
|
||||
echo "From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001" > $${COMMIT_FILE} ; \
|
||||
echo "From: Internal <test@test.com>" >> $${COMMIT_FILE} ; \
|
||||
echo "Date: `date`" >> $${COMMIT_FILE} ; \
|
||||
echo "Subject: [PATCH 1/1] RIOT: To commit" >> $${COMMIT_FILE} ; \
|
||||
echo "" >> $${COMMIT_FILE} ; \
|
||||
echo "---" >> $${COMMIT_FILE} ; \
|
||||
git diff HEAD -p --stat >> $${COMMIT_FILE} ; \
|
||||
echo "9999-Not-Yet-Commited.patch" ; \
|
||||
fi ; \
|
||||
fi
|
||||
rm -rf RIOT/pkg/libcoap && mkdir RIOT/pkg/libcoap
|
||||
cd pkg_libcoap && cp -r * ../RIOT/pkg/libcoap
|
||||
@HAVE_KCONFIG=`grep libcoap/Kconfig RIOT/pkg/Kconfig | wc -l` ; \
|
||||
if [ "$${HAVE_KCONFIG}" = 0 ] ; then \
|
||||
sed -i '/rsource "libcose\/Kconfig"/irsource "libcoap\/Kconfig"' RIOT/pkg/Kconfig ; \
|
||||
sed -i '/rsource "flashdb\/Kconfig"/irsource "libcoap\/Kconfig"' RIOT/pkg/Kconfig ; \
|
||||
fi
|
||||
|
||||
examples:
|
||||
@@ -38,6 +50,8 @@ examples:
|
||||
cd examples_libcoap_client && cp -r * ../RIOT/examples/libcoap-client
|
||||
rm -rf RIOT/examples/libcoap-server && mkdir RIOT/examples/libcoap-server
|
||||
cd examples_libcoap_server && cp -r * ../RIOT/examples/libcoap-server
|
||||
rm -rf RIOT/tests/pkg/libcoap && mkdir -p RIOT/tests/pkg/libcoap
|
||||
cd tests_pkg_libcoap && cp -r * ../RIOT/tests/pkg/libcoap
|
||||
|
||||
client: RIOT pkg examples
|
||||
$(MAKE) -C RIOT/examples/libcoap-client/ RIOT_CI_BUILD=1
|
||||
@@ -45,7 +59,14 @@ client: RIOT pkg examples
|
||||
server: RIOT pkg examples
|
||||
$(MAKE) -C RIOT/examples/libcoap-server/ RIOT_CI_BUILD=1
|
||||
|
||||
tests: RIOT pkg examples
|
||||
$(MAKE) -C RIOT/tests/pkg/libcoap/ RIOT_CI_BUILD=1
|
||||
|
||||
run_tests:
|
||||
$(MAKE) -C RIOT/tests/pkg/libcoap/ test
|
||||
|
||||
clean:
|
||||
rm -rf RIOT/pkg/libcoap
|
||||
rm -rf RIOT/examples/libcoap-client
|
||||
rm -rf RIOT/examples/libcoap-server
|
||||
rm -rf RIOT/tests/pkg/libcoap
|
||||
|
||||
@@ -11,7 +11,7 @@ This will
|
||||
* update the RIOT environment with pkg/libcoap, examples/libcoap-client
|
||||
and examples/libcoap-server taken from pkg_libcoap/, examples_client/
|
||||
and examples_server respectively/.
|
||||
(updates RIOT's libcoap code to the latest commited version in your
|
||||
(updates RIOT's libcoap code to the latest commited version in your
|
||||
environment).
|
||||
* build the client application
|
||||
* build the server application
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
if USEMODULE_LIBCOAP
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
#
|
||||
menu "libcoap-client"
|
||||
depends on USEPKG_LIBCOAP
|
||||
|
||||
config LIBCOAP_CLIENT_URI
|
||||
string "CoAP URI to connect to"
|
||||
default "coap://[fe80::405:5aff:fe15:9b7f]/.well-known/core"
|
||||
@@ -10,10 +16,5 @@ config LIBCOAP_USE_PSK_ID
|
||||
string "User ID to use for PSK communications"
|
||||
default "user_abc"
|
||||
depends on USEMODULE_TINYDTLS
|
||||
config LIBCOAP_SERVER_SUPPORT
|
||||
bool "Set to y if server support is required"
|
||||
default n
|
||||
config LIBCOAP_CLIENT_SUPPORT
|
||||
bool "Set to y if client support is required"
|
||||
default y
|
||||
endif # USEMODULE_LIBCOAP
|
||||
|
||||
endmenu # libcoap-client
|
||||
|
||||
@@ -38,6 +38,8 @@ USEMODULE += prng_sha1prng
|
||||
|
||||
# libcoap support
|
||||
USEPKG += libcoap
|
||||
# Uncomment to enable libcoap OSCORE support
|
||||
# USEMODULE += libcoap_oscore
|
||||
|
||||
# Configure if DNS is required
|
||||
# USEMODULE += sock_dns
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
airfy-beacon \
|
||||
arduino-duemilanove \
|
||||
arduino-leonardo \
|
||||
arduino-mega2560 \
|
||||
arduino-nano \
|
||||
arduino-uno \
|
||||
atmega256rfr2-xpro \
|
||||
atmega328p \
|
||||
atmega328p-xplained-mini \
|
||||
atmega8 \
|
||||
atxmega-a3bu-xplained \
|
||||
b-l072z-lrwan1 \
|
||||
blackpill-stm32f103c8 \
|
||||
blackpill-stm32f103cb \
|
||||
@@ -9,6 +19,7 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
calliope-mini \
|
||||
cc2650-launchpad \
|
||||
cc2650stk \
|
||||
derfmega128 \
|
||||
hifive1 \
|
||||
hifive1b \
|
||||
i-nucleo-lrwan1 \
|
||||
@@ -16,6 +27,9 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
lsn50 \
|
||||
maple-mini \
|
||||
microbit \
|
||||
microduino-corerf \
|
||||
msb-430 \
|
||||
msb-430h \
|
||||
nrf51dk \
|
||||
nrf51dongle \
|
||||
nrf6310 \
|
||||
@@ -32,10 +46,13 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
nucleo-l031k6 \
|
||||
nucleo-l053r8 \
|
||||
nucleo-l073rz \
|
||||
olimex-msp430-h1611 \
|
||||
olimex-msp430-h2618 \
|
||||
opencm904 \
|
||||
samd10-xmini \
|
||||
saml10-xpro \
|
||||
saml11-xpro \
|
||||
samr21-xpro \
|
||||
slstk3400a \
|
||||
spark-core \
|
||||
stk3200 \
|
||||
@@ -45,5 +62,9 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
stm32g0316-disco \
|
||||
stm32l0538-disco \
|
||||
stm32mp157c-dk2 \
|
||||
telosb \
|
||||
waspmote-pro \
|
||||
yunjia-nrf51822 \
|
||||
z1 \
|
||||
zigduino \
|
||||
#
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
CONFIG_LIBCOAP_CLIENT_SUPPORT=y
|
||||
|
||||
CONFIG_LIBCOAP_CLIENT_URI="coap://[fe80::405:5aff:fe15:9b7f]/.well-known/core"
|
||||
|
||||
CONFIG_LIBCOAP_USE_PSK="secretPSK"
|
||||
CONFIG_LIBCOAP_USE_PSK_ID="user_abc"
|
||||
|
||||
CONFIG_KCONFIG_USEPKG_LIBCOAP=y
|
||||
# Logging levels are defined in pkg/libcoap using Kconfig
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* client-coap.c -- RIOT client example
|
||||
*
|
||||
* Copyright (C) 2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
* Copyright (C) 2023-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -9,17 +9,12 @@
|
||||
* of use.
|
||||
*/
|
||||
|
||||
#include "coap_config.h"
|
||||
#include <coap3/coap.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include "client-coap.h"
|
||||
#include "macros/utils.h"
|
||||
#include "net/utils.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <thread.h>
|
||||
#include <debug.h>
|
||||
#include <coap3/coap.h>
|
||||
#include "client-coap.h"
|
||||
#include <stdio.h>
|
||||
#include "macros/utils.h"
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_CLIENT_URI
|
||||
#define COAP_CLIENT_URI CONFIG_LIBCOAP_CLIENT_URI
|
||||
@@ -43,211 +38,233 @@ static coap_context_t *main_coap_context = NULL;
|
||||
static coap_optlist_t *optlist = NULL;
|
||||
|
||||
static int quit = 0;
|
||||
static int is_mcast = 0;
|
||||
|
||||
#define DEFAULT_WAIT_TIME 15
|
||||
|
||||
unsigned int wait_seconds = DEFAULT_WAIT_TIME; /* default timeout in seconds */
|
||||
|
||||
static coap_response_t
|
||||
message_handler(coap_session_t *session,
|
||||
const coap_pdu_t *sent,
|
||||
const coap_pdu_t *received,
|
||||
const coap_mid_t id) {
|
||||
const uint8_t *data;
|
||||
size_t len;
|
||||
size_t offset;
|
||||
size_t total;
|
||||
const coap_mid_t id)
|
||||
{
|
||||
const uint8_t *data;
|
||||
size_t len;
|
||||
size_t offset;
|
||||
size_t total;
|
||||
|
||||
(void)session;
|
||||
(void)sent;
|
||||
(void)id;
|
||||
if (coap_get_data_large(received, &len, &data, &offset, &total)) {
|
||||
printf("%*.*s", (int)len, (int)len, (const char *)data);
|
||||
if (len + offset == total) {
|
||||
printf("\n");
|
||||
quit = 1;
|
||||
(void)session;
|
||||
(void)sent;
|
||||
(void)id;
|
||||
if (coap_get_data_large(received, &len, &data, &offset, &total)) {
|
||||
printf("%*.*s", (int)len, (int)len, (const char *)data);
|
||||
if (len + offset == total) {
|
||||
printf("\n");
|
||||
quit = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return COAP_RESPONSE_OK;
|
||||
return COAP_RESPONSE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
nack_handler(coap_session_t *session COAP_UNUSED,
|
||||
const coap_pdu_t *sent COAP_UNUSED,
|
||||
const coap_nack_reason_t reason,
|
||||
const coap_mid_t id COAP_UNUSED) {
|
||||
const coap_mid_t id COAP_UNUSED)
|
||||
{
|
||||
|
||||
switch (reason) {
|
||||
case COAP_NACK_TOO_MANY_RETRIES:
|
||||
case COAP_NACK_NOT_DELIVERABLE:
|
||||
case COAP_NACK_RST:
|
||||
case COAP_NACK_TLS_FAILED:
|
||||
case COAP_NACK_TLS_LAYER_FAILED:
|
||||
case COAP_NACK_WS_LAYER_FAILED:
|
||||
case COAP_NACK_WS_FAILED:
|
||||
coap_log_err("cannot send CoAP pdu\n");
|
||||
quit = 1;
|
||||
break;
|
||||
case COAP_NACK_ICMP_ISSUE:
|
||||
case COAP_NACK_BAD_RESPONSE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
switch (reason) {
|
||||
case COAP_NACK_TOO_MANY_RETRIES:
|
||||
case COAP_NACK_NOT_DELIVERABLE:
|
||||
case COAP_NACK_RST:
|
||||
case COAP_NACK_TLS_FAILED:
|
||||
case COAP_NACK_TLS_LAYER_FAILED:
|
||||
case COAP_NACK_WS_LAYER_FAILED:
|
||||
case COAP_NACK_WS_FAILED:
|
||||
coap_log_err("cannot send CoAP pdu\n");
|
||||
quit = 1;
|
||||
break;
|
||||
case COAP_NACK_ICMP_ISSUE:
|
||||
case COAP_NACK_BAD_RESPONSE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
resolve_address(const char *host, const char *service, coap_address_t *dst,
|
||||
int scheme_hint_bits) {
|
||||
uint16_t port = service ? atoi(service) : 0;
|
||||
int ret = 0;
|
||||
coap_str_const_t str_host;
|
||||
coap_addr_info_t *addr_info;
|
||||
int scheme_hint_bits)
|
||||
{
|
||||
uint16_t port = service ? atoi(service) : 0;
|
||||
int ret = 0;
|
||||
coap_str_const_t str_host;
|
||||
coap_addr_info_t *addr_info;
|
||||
|
||||
str_host.s = (const uint8_t *)host;
|
||||
str_host.length = strlen(host);
|
||||
addr_info = coap_resolve_address_info(&str_host, port, port, port, port,
|
||||
AF_UNSPEC, scheme_hint_bits,
|
||||
COAP_RESOLVE_TYPE_REMOTE);
|
||||
if (addr_info) {
|
||||
ret = 1;
|
||||
*dst = addr_info->addr;
|
||||
}
|
||||
str_host.s = (const uint8_t *)host;
|
||||
str_host.length = strlen(host);
|
||||
addr_info = coap_resolve_address_info(&str_host, port, port, port, port,
|
||||
AF_UNSPEC, scheme_hint_bits,
|
||||
COAP_RESOLVE_TYPE_REMOTE);
|
||||
if (addr_info) {
|
||||
ret = 1;
|
||||
*dst = addr_info->addr;
|
||||
is_mcast = coap_is_mcast(dst);
|
||||
}
|
||||
|
||||
coap_free_address_info(addr_info);
|
||||
return ret;
|
||||
coap_free_address_info(addr_info);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
client_coap_init(int argc, char **argv) {
|
||||
coap_session_t *session = NULL;
|
||||
coap_pdu_t *pdu;
|
||||
coap_address_t dst;
|
||||
coap_mid_t mid;
|
||||
int len;
|
||||
coap_uri_t uri;
|
||||
char portbuf[8];
|
||||
client_coap_init(int argc, char **argv)
|
||||
{
|
||||
coap_session_t *session = NULL;
|
||||
coap_pdu_t *pdu;
|
||||
coap_address_t dst;
|
||||
coap_mid_t mid;
|
||||
int len;
|
||||
coap_uri_t uri;
|
||||
char portbuf[8];
|
||||
unsigned int wait_ms = 0;
|
||||
int result = -1;
|
||||
#define BUFSIZE 100
|
||||
unsigned char buf[BUFSIZE];
|
||||
int res;
|
||||
const char *coap_uri = COAP_CLIENT_URI;
|
||||
unsigned char buf[BUFSIZE];
|
||||
int res;
|
||||
const char *coap_uri = COAP_CLIENT_URI;
|
||||
|
||||
if (argc > 1) {
|
||||
coap_uri = argv[1];
|
||||
}
|
||||
if (argc > 1) {
|
||||
coap_uri = argv[1];
|
||||
}
|
||||
|
||||
/* Initialize libcoap library */
|
||||
coap_startup();
|
||||
/* Initialize libcoap library */
|
||||
coap_startup();
|
||||
|
||||
coap_set_log_level(COAP_MAX_LOGGING_LEVEL);
|
||||
coap_set_log_level(COAP_MAX_LOGGING_LEVEL);
|
||||
|
||||
/* Parse the URI */
|
||||
len = coap_split_uri((const unsigned char *)coap_uri, strlen(coap_uri), &uri);
|
||||
if (len != 0) {
|
||||
coap_log_warn("Failed to parse uri %s\n", coap_uri);
|
||||
goto fail;
|
||||
}
|
||||
/* Parse the URI */
|
||||
len = coap_split_uri((const unsigned char *)coap_uri, strlen(coap_uri), &uri);
|
||||
if (len != 0) {
|
||||
coap_log_warn("Failed to parse uri %s\n", coap_uri);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
snprintf(portbuf, sizeof(portbuf), "%d", uri.port);
|
||||
snprintf((char *)buf, sizeof(buf), "%*.*s", (int)uri.host.length,
|
||||
(int)uri.host.length, (const char *)uri.host.s);
|
||||
/* resolve destination address where packet should be sent */
|
||||
len = resolve_address((const char *)buf, portbuf, &dst, 1 << uri.scheme);
|
||||
if (len <= 0) {
|
||||
coap_log_warn("Failed to resolve address %*.*s\n", (int)uri.host.length,
|
||||
(int)uri.host.length, (const char *)uri.host.s);
|
||||
goto fail;
|
||||
}
|
||||
snprintf(portbuf, sizeof(portbuf), "%d", uri.port);
|
||||
snprintf((char *)buf, sizeof(buf), "%*.*s", (int)uri.host.length,
|
||||
(int)uri.host.length, (const char *)uri.host.s);
|
||||
/* resolve destination address where packet should be sent */
|
||||
len = resolve_address((const char *)buf, portbuf, &dst, 1 << uri.scheme);
|
||||
if (len <= 0) {
|
||||
coap_log_warn("Failed to resolve address %*.*s\n", (int)uri.host.length,
|
||||
(int)uri.host.length, (const char *)uri.host.s);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
main_coap_context = coap_new_context(NULL);
|
||||
if (!main_coap_context) {
|
||||
coap_log_warn("Failed to initialize context\n");
|
||||
goto fail;
|
||||
}
|
||||
main_coap_context = coap_new_context(NULL);
|
||||
if (!main_coap_context) {
|
||||
coap_log_warn("Failed to initialize context\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
coap_context_set_block_mode(main_coap_context, COAP_BLOCK_USE_LIBCOAP);
|
||||
coap_context_set_block_mode(main_coap_context, COAP_BLOCK_USE_LIBCOAP);
|
||||
|
||||
if (uri.scheme == COAP_URI_SCHEME_COAP) {
|
||||
session = coap_new_client_session(main_coap_context, NULL, &dst,
|
||||
COAP_PROTO_UDP);
|
||||
} else if (uri.scheme == COAP_URI_SCHEME_COAP_TCP) {
|
||||
session = coap_new_client_session(main_coap_context, NULL, &dst,
|
||||
COAP_PROTO_TCP);
|
||||
if (uri.scheme == COAP_URI_SCHEME_COAP) {
|
||||
session = coap_new_client_session(main_coap_context, NULL, &dst,
|
||||
COAP_PROTO_UDP);
|
||||
}
|
||||
else if (uri.scheme == COAP_URI_SCHEME_COAP_TCP) {
|
||||
session = coap_new_client_session(main_coap_context, NULL, &dst,
|
||||
COAP_PROTO_TCP);
|
||||
#if defined (COAP_USE_PSK) && defined(COAP_USE_PSK_ID)
|
||||
} else {
|
||||
static coap_dtls_cpsk_t dtls_psk;
|
||||
static char client_sni[256];
|
||||
|
||||
memset(client_sni, 0, sizeof(client_sni));
|
||||
memset(&dtls_psk, 0, sizeof(dtls_psk));
|
||||
dtls_psk.version = COAP_DTLS_CPSK_SETUP_VERSION;
|
||||
if (uri.host.length) {
|
||||
memcpy(client_sni, uri.host.s,
|
||||
MIN(uri.host.length, sizeof(client_sni) - 1));
|
||||
}
|
||||
else {
|
||||
memcpy(client_sni, "localhost", 9);
|
||||
}
|
||||
dtls_psk.client_sni = client_sni;
|
||||
dtls_psk.psk_info.identity.s = (const uint8_t *)COAP_USE_PSK_ID;
|
||||
dtls_psk.psk_info.identity.length = strlen(COAP_USE_PSK_ID);
|
||||
dtls_psk.psk_info.key.s = (const uint8_t *)COAP_USE_PSK;
|
||||
dtls_psk.psk_info.key.length = strlen(COAP_USE_PSK);
|
||||
static coap_dtls_cpsk_t dtls_psk;
|
||||
static char client_sni[256];
|
||||
|
||||
session = coap_new_client_session_psk2(main_coap_context, NULL, &dst,
|
||||
COAP_PROTO_DTLS, &dtls_psk);
|
||||
memset(&dtls_psk, 0, sizeof(dtls_psk));
|
||||
dtls_psk.version = COAP_DTLS_CPSK_SETUP_VERSION;
|
||||
snprintf(client_sni, sizeof(client_sni), "%*.*s", (int)uri.host.length, (int)uri.host.length, uri.host.s);
|
||||
dtls_psk.client_sni = client_sni;
|
||||
dtls_psk.psk_info.identity.s = (const uint8_t *)COAP_USE_PSK_ID;
|
||||
dtls_psk.psk_info.identity.length = strlen(COAP_USE_PSK_ID);
|
||||
dtls_psk.psk_info.key.s = (const uint8_t *)COAP_USE_PSK;
|
||||
dtls_psk.psk_info.key.length = strlen(COAP_USE_PSK);
|
||||
|
||||
session = coap_new_client_session_psk2(main_coap_context, NULL, &dst,
|
||||
COAP_PROTO_DTLS, &dtls_psk);
|
||||
#else /* ! COAP_USE_PSK && ! COAP_USE_PSK_ID */
|
||||
coap_log_err("CONFIG_LIBCOAP_USE_PSK and CONFIG_LIBCOAP_USE_PSK_ID not defined\n");
|
||||
goto fail;
|
||||
coap_log_err("CONFIG_LIBCOAP_USE_PSK and CONFIG_LIBCOAP_USE_PSK_ID not defined\n");
|
||||
goto fail;
|
||||
#endif /* ! COAP_USE_PSK && ! COAP_USE_PSK_ID */
|
||||
}
|
||||
|
||||
if (!session) {
|
||||
coap_log_warn("Failed to create session\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
coap_register_response_handler(main_coap_context, message_handler);
|
||||
coap_register_nack_handler(main_coap_context, nack_handler);
|
||||
|
||||
/* construct CoAP message */
|
||||
pdu = coap_pdu_init(COAP_MESSAGE_CON,
|
||||
COAP_REQUEST_CODE_GET,
|
||||
coap_new_message_id(session),
|
||||
coap_session_max_pdu_size(session));
|
||||
if (!pdu) {
|
||||
coap_log_warn("Failed to create PDU\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
len = coap_uri_into_options(&uri, &dst, &optlist, 1, buf, sizeof(buf));
|
||||
if (len) {
|
||||
coap_log_warn("Failed to create options\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Add option list (which will be sorted) to the PDU */
|
||||
if (optlist) {
|
||||
res = coap_add_optlist_pdu(pdu, &optlist);
|
||||
if (res != 1) {
|
||||
coap_log_warn("Failed to add options to PDU\n");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/* and send the PDU */
|
||||
mid = coap_send(session, pdu);
|
||||
if (mid == COAP_INVALID_MID) {
|
||||
coap_log_warn("Failed to send PDU\n");
|
||||
goto fail;
|
||||
}
|
||||
while (!quit) {
|
||||
coap_io_process(main_coap_context, 1000);
|
||||
}
|
||||
if (!session) {
|
||||
coap_log_warn("Failed to create session\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
coap_register_response_handler(main_coap_context, message_handler);
|
||||
coap_register_nack_handler(main_coap_context, nack_handler);
|
||||
|
||||
/* construct CoAP message */
|
||||
pdu = coap_pdu_init(is_mcast ? COAP_MESSAGE_NON : COAP_MESSAGE_CON,
|
||||
COAP_REQUEST_CODE_GET,
|
||||
coap_new_message_id(session),
|
||||
coap_session_max_pdu_size(session));
|
||||
if (!pdu) {
|
||||
coap_log_warn("Failed to create PDU\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
res = coap_uri_into_optlist(&uri, &dst, &optlist, 1);
|
||||
if (res) {
|
||||
coap_log_warn("Failed to create options\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Add option list (which will be sorted) to the PDU */
|
||||
if (optlist) {
|
||||
res = coap_add_optlist_pdu(pdu, &optlist);
|
||||
if (res != 1) {
|
||||
coap_log_warn("Failed to add options to PDU\n");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
if (is_mcast) {
|
||||
/* Allow for other servers to respond within DEFAULT_LEISURE RFC7252 8.2 */
|
||||
wait_seconds = coap_session_get_default_leisure(session).integer_part + 1;
|
||||
}
|
||||
wait_ms = wait_seconds * 1000;
|
||||
|
||||
/* and send the PDU */
|
||||
mid = coap_send(session, pdu);
|
||||
if (mid == COAP_INVALID_MID) {
|
||||
coap_log_warn("Failed to send PDU\n");
|
||||
goto fail;
|
||||
}
|
||||
while (!quit || is_mcast) {
|
||||
result = coap_io_process(main_coap_context, 1000);
|
||||
if (result >= 0) {
|
||||
if (wait_ms > 0) {
|
||||
if ((unsigned)result >= wait_ms) {
|
||||
coap_log_info("timeout\n");
|
||||
break;
|
||||
} else {
|
||||
wait_ms -= result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fail:
|
||||
/* Clean up library usage so client can be run again */
|
||||
quit = 0;
|
||||
coap_delete_optlist(optlist);
|
||||
optlist = NULL;
|
||||
coap_session_release(session);
|
||||
session = NULL;
|
||||
coap_free_context(main_coap_context);
|
||||
main_coap_context = NULL;
|
||||
coap_cleanup();
|
||||
/* Clean up library usage so client can be run again */
|
||||
quit = 0;
|
||||
coap_delete_optlist(optlist);
|
||||
optlist = NULL;
|
||||
coap_session_release(session);
|
||||
session = NULL;
|
||||
coap_free_context(main_coap_context);
|
||||
main_coap_context = NULL;
|
||||
coap_cleanup();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* client-coap.h -- RIOT client example
|
||||
*
|
||||
* Copyright (C) 2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
* Copyright (C) 2023-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -16,9 +16,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "coap_config.h"
|
||||
#include <coap3/coap.h>
|
||||
|
||||
/* Start up the CoAP Client */
|
||||
void client_coap_init(int argc, char **argv);
|
||||
|
||||
|
||||
@@ -32,22 +32,24 @@ static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
|
||||
extern int client_coap_init(int argc, char **argv);
|
||||
|
||||
static const shell_command_t shell_commands[] = {
|
||||
{ "coapc", "Start a libcoap client", client_coap_init },
|
||||
{ NULL, NULL, NULL }
|
||||
{ "coapc", "Start a libcoap client", client_coap_init },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
int
|
||||
main(void) {
|
||||
/* we need a message queue for the thread running the shell in order to
|
||||
* receive potentially fast incoming networking packets */
|
||||
msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);
|
||||
puts("RIOT libcoap client testing implementation");
|
||||
main(void)
|
||||
{
|
||||
/* we need a message queue for the thread running the shell in order to
|
||||
* receive potentially fast incoming networking packets */
|
||||
msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);
|
||||
puts("RIOT libcoap client testing implementation");
|
||||
|
||||
/* start shell */
|
||||
puts("All up, running the shell now");
|
||||
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
||||
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
/* start shell */
|
||||
puts("All up, running the shell now");
|
||||
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
||||
|
||||
/* should be never reached */
|
||||
return 0;
|
||||
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
|
||||
/* should be never reached */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
if USEMODULE_LIBCOAP
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
#
|
||||
menu "libcoap-server"
|
||||
depends on USEPKG_LIBCOAP
|
||||
|
||||
config LIBCOAP_USE_PSK
|
||||
string "Secret to use for PSK communications"
|
||||
default "secretPSK"
|
||||
depends on USEMODULE_TINYDTLS
|
||||
config LIBCOAP_SERVER_SUPPORT
|
||||
bool "Set to y if server support is required"
|
||||
default y
|
||||
config LIBCOAP_CLIENT_SUPPORT
|
||||
bool "Set to y if ongoing proxy support is required"
|
||||
default n
|
||||
endif # USEMODULE_LIBCOAP
|
||||
if LIBCOAP_CLIENT_SUPPORT
|
||||
config LIBCOAP_USE_PSK_ID
|
||||
string "User ID to use for ongoing PSK communications"
|
||||
default "user_abc"
|
||||
depends on USEMODULE_TINYDTLS
|
||||
endif # LIBCOAP_CLIENT_SUPPORT
|
||||
|
||||
endmenu # libcoap-server
|
||||
|
||||
@@ -39,8 +39,9 @@ USEMODULE += prng_sha1prng
|
||||
|
||||
# libcoap support
|
||||
USEPKG += libcoap
|
||||
# Uncomment to enable libcoap OSCORE support
|
||||
# USEMODULE += libcoap_oscore
|
||||
|
||||
USEMODULE += sock_udp
|
||||
# Configure if DNS is required
|
||||
USEMODULE += sock_dns
|
||||
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
airfy-beacon \
|
||||
arduino-duemilanove \
|
||||
arduino-leonardo \
|
||||
arduino-mega2560 \
|
||||
arduino-nano \
|
||||
arduino-uno \
|
||||
atmega256rfr2-xpro \
|
||||
atmega328p \
|
||||
atmega328p-xplained-mini \
|
||||
atmega8 \
|
||||
atxmega-a3bu-xplained \
|
||||
b-l072z-lrwan1 \
|
||||
blackpill-stm32f103c8 \
|
||||
blackpill-stm32f103cb \
|
||||
@@ -9,6 +19,7 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
calliope-mini \
|
||||
cc2650-launchpad \
|
||||
cc2650stk \
|
||||
derfmega128 \
|
||||
hifive1 \
|
||||
hifive1b \
|
||||
i-nucleo-lrwan1 \
|
||||
@@ -16,6 +27,9 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
lsn50 \
|
||||
maple-mini \
|
||||
microbit \
|
||||
microduino-corerf \
|
||||
msb-430 \
|
||||
msb-430h \
|
||||
nrf51dk \
|
||||
nrf51dongle \
|
||||
nrf6310 \
|
||||
@@ -32,10 +46,13 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
nucleo-l031k6 \
|
||||
nucleo-l053r8 \
|
||||
nucleo-l073rz \
|
||||
olimex-msp430-h1611 \
|
||||
olimex-msp430-h2618 \
|
||||
opencm904 \
|
||||
samd10-xmini \
|
||||
saml10-xpro \
|
||||
saml11-xpro \
|
||||
samr21-xpro \
|
||||
slstk3400a \
|
||||
spark-core \
|
||||
stk3200 \
|
||||
@@ -45,5 +62,9 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
stm32g0316-disco \
|
||||
stm32l0538-disco \
|
||||
stm32mp157c-dk2 \
|
||||
telosb \
|
||||
waspmote-pro \
|
||||
yunjia-nrf51822 \
|
||||
z1 \
|
||||
zigduino \
|
||||
#
|
||||
|
||||
@@ -2,5 +2,7 @@ CONFIG_LIBCOAP_SERVER_SUPPORT=y
|
||||
|
||||
CONFIG_LIBCOAP_USE_PSK="secretPSK"
|
||||
|
||||
CONFIG_KCONFIG_USEPKG_LIBCOAP=y
|
||||
# Logging levels are defined in pkg/libcoap using Kconfig
|
||||
|
||||
CONFIG_DTLS_PEER_MAX=2
|
||||
CONFIG_DTLS_HANDSHAKE_MAX=2
|
||||
|
||||
@@ -32,22 +32,24 @@ static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
|
||||
extern int server_coap_init(int argc, char **argv);
|
||||
|
||||
static const shell_command_t shell_commands[] = {
|
||||
{ "coaps", "Start a libcoap server", server_coap_init },
|
||||
{ NULL, NULL, NULL }
|
||||
{ "coaps", "Start a libcoap server", server_coap_init },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
int
|
||||
main(void) {
|
||||
/* we need a message queue for the thread running the shell in order to
|
||||
* receive potentially fast incoming networking packets */
|
||||
msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);
|
||||
puts("RIOT libcoap server testing implementation");
|
||||
main(void)
|
||||
{
|
||||
/* we need a message queue for the thread running the shell in order to
|
||||
* receive potentially fast incoming networking packets */
|
||||
msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);
|
||||
puts("RIOT libcoap server testing implementation");
|
||||
|
||||
/* start shell */
|
||||
puts("All up, running the shell now");
|
||||
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
||||
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
/* start shell */
|
||||
puts("All up, running the shell now");
|
||||
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
||||
|
||||
/* should be never reached */
|
||||
return 0;
|
||||
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
|
||||
/* should be never reached */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* server-coap.c -- RIOT example
|
||||
*
|
||||
* Copyright (C) 2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
* Copyright (C) 2023-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "coap_config.h"
|
||||
#include <coap3/coap.h>
|
||||
#include "server-coap.h"
|
||||
#include <stdio.h>
|
||||
#include "macros/utils.h"
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_USE_PSK
|
||||
@@ -33,259 +34,270 @@ static coap_resource_t *time_resource = NULL; /* just for testing */
|
||||
static void
|
||||
hnd_get_time(coap_resource_t *resource, coap_session_t *session,
|
||||
const coap_pdu_t *request, const coap_string_t *query,
|
||||
coap_pdu_t *response) {
|
||||
unsigned char buf[40];
|
||||
size_t len;
|
||||
coap_tick_t now;
|
||||
coap_tick_t t;
|
||||
coap_pdu_t *response)
|
||||
{
|
||||
unsigned char buf[40];
|
||||
size_t len;
|
||||
coap_tick_t now;
|
||||
coap_tick_t t;
|
||||
|
||||
(void)resource;
|
||||
(void)session;
|
||||
(void)request;
|
||||
/* FIXME: return time, e.g. in human-readable by default and ticks
|
||||
* when query ?ticks is given. */
|
||||
(void)resource;
|
||||
(void)session;
|
||||
(void)request;
|
||||
/* FIXME: return time, e.g. in human-readable by default and ticks
|
||||
* when query ?ticks is given. */
|
||||
|
||||
/* if my_clock_base was deleted, we pretend to have no such resource */
|
||||
coap_pdu_set_code(response, my_clock_base ? COAP_RESPONSE_CODE_CONTENT :
|
||||
COAP_RESPONSE_CODE_NOT_FOUND);
|
||||
if (my_clock_base) {
|
||||
coap_add_option(response, COAP_OPTION_CONTENT_FORMAT,
|
||||
coap_encode_var_safe(buf, sizeof(buf),
|
||||
COAP_MEDIATYPE_TEXT_PLAIN),
|
||||
buf);
|
||||
}
|
||||
|
||||
coap_add_option(response, COAP_OPTION_MAXAGE,
|
||||
coap_encode_var_safe(buf, sizeof(buf), 0x01), buf);
|
||||
|
||||
if (my_clock_base) {
|
||||
|
||||
/* calculate current time */
|
||||
coap_ticks(&t);
|
||||
now = my_clock_base + (t / COAP_TICKS_PER_SECOND);
|
||||
|
||||
if (query != NULL
|
||||
&& coap_string_equal(query, coap_make_str_const("ticks"))) {
|
||||
/* output ticks */
|
||||
len = snprintf((char *)buf, sizeof(buf), "%u", (unsigned int)now);
|
||||
coap_add_data(response, len, buf);
|
||||
/* if my_clock_base was deleted, we pretend to have no such resource */
|
||||
coap_pdu_set_code(response, my_clock_base ? COAP_RESPONSE_CODE_CONTENT :
|
||||
COAP_RESPONSE_CODE_NOT_FOUND);
|
||||
if (my_clock_base) {
|
||||
coap_add_option(response, COAP_OPTION_CONTENT_FORMAT,
|
||||
coap_encode_var_safe(buf, sizeof(buf),
|
||||
COAP_MEDIATYPE_TEXT_PLAIN),
|
||||
buf);
|
||||
}
|
||||
|
||||
coap_add_option(response, COAP_OPTION_MAXAGE,
|
||||
coap_encode_var_safe(buf, sizeof(buf), 0x01), buf);
|
||||
|
||||
if (my_clock_base) {
|
||||
|
||||
/* calculate current time */
|
||||
coap_ticks(&t);
|
||||
now = my_clock_base + (t / COAP_TICKS_PER_SECOND);
|
||||
|
||||
if (query != NULL
|
||||
&& coap_string_equal(query, coap_make_str_const("ticks"))) {
|
||||
/* output ticks */
|
||||
len = snprintf((char *)buf, sizeof(buf), "%u", (unsigned int)now);
|
||||
coap_add_data(response, len, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
init_coap_resources(coap_context_t *ctx) {
|
||||
coap_resource_t *r;
|
||||
init_coap_resources(coap_context_t *ctx)
|
||||
{
|
||||
coap_resource_t *r;
|
||||
|
||||
#if 0
|
||||
r = coap_resource_init(NULL, 0, 0);
|
||||
coap_register_handler(r, COAP_REQUEST_GET, hnd_get_index);
|
||||
|
||||
coap_add_attr(r, coap_make_str_const("ct"), coap_make_str_const("0"), 0);
|
||||
coap_add_attr(r, coap_make_str_const("title"), coap_make_str_const("\"General Info\""), 0);
|
||||
coap_add_resource(ctx, r);
|
||||
#endif
|
||||
/* store clock base to use in /time */
|
||||
my_clock_base = clock_offset;
|
||||
|
||||
r = coap_resource_init(coap_make_str_const("time"), 0);
|
||||
if (!r) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
coap_resource_set_get_observable(r, 1);
|
||||
time_resource = r;
|
||||
coap_register_handler(r, COAP_REQUEST_GET, hnd_get_time);
|
||||
#if 0
|
||||
coap_register_handler(r, COAP_REQUEST_PUT, hnd_put_time);
|
||||
coap_register_handler(r, COAP_REQUEST_DELETE, hnd_delete_time);
|
||||
#endif
|
||||
coap_add_attr(r, coap_make_str_const("ct"), coap_make_str_const("0"), 0);
|
||||
/* coap_add_attr(r, coap_make_str_const("title"),
|
||||
coap_make_str_const("\"Internal Clock\""), 0); */
|
||||
coap_add_attr(r, coap_make_str_const("rt"), coap_make_str_const("\"ticks\""), 0);
|
||||
coap_add_attr(r, coap_make_str_const("if"), coap_make_str_const("\"clock\""), 0);
|
||||
|
||||
coap_add_resource(ctx, r);
|
||||
#if 0
|
||||
if (coap_async_is_supported()) {
|
||||
r = coap_resource_init(coap_make_str_const("async"), 0);
|
||||
coap_register_handler(r, COAP_REQUEST_GET, hnd_get_async);
|
||||
r = coap_resource_init(NULL, 0, 0);
|
||||
coap_register_handler(r, COAP_REQUEST_GET, hnd_get_index);
|
||||
|
||||
coap_add_attr(r, coap_make_str_const("ct"), coap_make_str_const("0"), 0);
|
||||
coap_add_attr(r, coap_make_str_const("title"), coap_make_str_const("\"General Info\""), 0);
|
||||
coap_add_resource(ctx, r);
|
||||
}
|
||||
#endif
|
||||
/* store clock base to use in /time */
|
||||
my_clock_base = clock_offset;
|
||||
|
||||
r = coap_resource_init(coap_make_str_const("time"), 0);
|
||||
if (!r) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
coap_resource_set_get_observable(r, 1);
|
||||
time_resource = r;
|
||||
coap_register_handler(r, COAP_REQUEST_GET, hnd_get_time);
|
||||
#if 0
|
||||
coap_register_handler(r, COAP_REQUEST_PUT, hnd_put_time);
|
||||
coap_register_handler(r, COAP_REQUEST_DELETE, hnd_delete_time);
|
||||
#endif
|
||||
coap_add_attr(r, coap_make_str_const("ct"), coap_make_str_const("0"), 0);
|
||||
/* coap_add_attr(r, coap_make_str_const("title"),
|
||||
coap_make_str_const("\"Internal Clock\""), 0); */
|
||||
coap_add_attr(r, coap_make_str_const("rt"), coap_make_str_const("\"ticks\""), 0);
|
||||
coap_add_attr(r, coap_make_str_const("if"), coap_make_str_const("\"clock\""), 0);
|
||||
|
||||
coap_add_resource(ctx, r);
|
||||
#if 0
|
||||
if (coap_async_is_supported()) {
|
||||
r = coap_resource_init(coap_make_str_const("async"), 0);
|
||||
coap_register_handler(r, COAP_REQUEST_GET, hnd_get_async);
|
||||
|
||||
coap_add_attr(r, coap_make_str_const("ct"), coap_make_str_const("0"), 0);
|
||||
coap_add_resource(ctx, r);
|
||||
}
|
||||
#endif
|
||||
|
||||
return;
|
||||
return;
|
||||
error:
|
||||
coap_log_crit("cannot create resource\n");
|
||||
coap_log_crit("cannot create resource\n");
|
||||
}
|
||||
|
||||
static int
|
||||
init_coap_context_endpoints(const char *use_psk) {
|
||||
coap_address_t listenaddress;
|
||||
gnrc_netif_t *netif = gnrc_netif_iter(NULL);
|
||||
ipv6_addr_t addr;
|
||||
char addr_str[INET6_ADDRSTRLEN + 8];
|
||||
int scheme_hint_bits = 1 << COAP_URI_SCHEME_COAP;
|
||||
coap_addr_info_t *info = NULL;
|
||||
coap_addr_info_t *info_list = NULL;
|
||||
coap_str_const_t local;
|
||||
int have_ep = 0;
|
||||
init_coap_context_endpoints(const char *use_psk)
|
||||
{
|
||||
coap_address_t listenaddress;
|
||||
gnrc_netif_t *netif = gnrc_netif_iter(NULL);
|
||||
ipv6_addr_t addr;
|
||||
char addr_str[INET6_ADDRSTRLEN + 8];
|
||||
int scheme_hint_bits = 1 << COAP_URI_SCHEME_COAP;
|
||||
coap_addr_info_t *info = NULL;
|
||||
coap_addr_info_t *info_list = NULL;
|
||||
coap_str_const_t local;
|
||||
int have_ep = 0;
|
||||
|
||||
/* Get the first address on the interface */
|
||||
if (gnrc_netif_ipv6_addrs_get(netif, &addr, sizeof(addr)) < 0) {
|
||||
puts("Unable to get first address of the interface");
|
||||
return 0;
|
||||
}
|
||||
|
||||
coap_address_init(&listenaddress);
|
||||
listenaddress.addr.sin6.sin6_family = AF_INET6;
|
||||
memcpy(&listenaddress.addr.sin6.sin6_addr, &addr,
|
||||
sizeof(listenaddress.addr.sin6.sin6_addr));
|
||||
coap_print_ip_addr(&listenaddress, addr_str, sizeof(addr_str));
|
||||
coap_log_info("Server IP [%s]\n", addr_str);
|
||||
|
||||
main_coap_context = coap_new_context(NULL);
|
||||
if (!main_coap_context) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (use_psk && coap_dtls_is_supported()) {
|
||||
coap_dtls_spsk_t setup_data;
|
||||
|
||||
/* Need PSK set up before setting up endpoints */
|
||||
memset(&setup_data, 0, sizeof(setup_data));
|
||||
setup_data.version = COAP_DTLS_SPSK_SETUP_VERSION;
|
||||
setup_data.psk_info.key.s = (const uint8_t *)use_psk;
|
||||
setup_data.psk_info.key.length = strlen(use_psk);
|
||||
coap_context_set_psk2(main_coap_context, &setup_data);
|
||||
scheme_hint_bits |= 1 << COAP_URI_SCHEME_COAPS;
|
||||
}
|
||||
|
||||
local.s = (uint8_t *)addr_str;
|
||||
local.length = strlen(addr_str);
|
||||
info_list = coap_resolve_address_info(&local, COAP_DEFAULT_PORT,
|
||||
COAPS_DEFAULT_PORT,
|
||||
0, 0,
|
||||
0,
|
||||
scheme_hint_bits,
|
||||
COAP_RESOLVE_TYPE_REMOTE);
|
||||
for (info = info_list; info != NULL; info = info->next) {
|
||||
coap_endpoint_t *ep;
|
||||
|
||||
ep = coap_new_endpoint(main_coap_context, &info->addr, info->proto);
|
||||
if (!ep) {
|
||||
coap_log_warn("cannot create endpoint for proto %u\n",
|
||||
info->proto);
|
||||
} else {
|
||||
have_ep = 1;
|
||||
/* Get the first address on the interface */
|
||||
if (gnrc_netif_ipv6_addrs_get(netif, &addr, sizeof(addr)) < 0) {
|
||||
puts("Unable to get first address of the interface");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
coap_free_address_info(info_list);
|
||||
if (!have_ep) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
coap_address_init(&listenaddress);
|
||||
listenaddress.riot.family = AF_INET6;
|
||||
memcpy(&listenaddress.riot.addr.ipv6, &addr,
|
||||
sizeof(listenaddress.riot.addr.ipv6));
|
||||
coap_print_ip_addr(&listenaddress, addr_str, sizeof(addr_str));
|
||||
coap_log_info("Server IP [%s]\n", addr_str);
|
||||
|
||||
main_coap_context = coap_new_context(NULL);
|
||||
if (!main_coap_context) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (use_psk && coap_dtls_is_supported()) {
|
||||
coap_dtls_spsk_t setup_data;
|
||||
|
||||
/* Need PSK set up before setting up endpoints */
|
||||
memset(&setup_data, 0, sizeof(setup_data));
|
||||
setup_data.version = COAP_DTLS_SPSK_SETUP_VERSION;
|
||||
setup_data.psk_info.key.s = (const uint8_t *)use_psk;
|
||||
setup_data.psk_info.key.length = strlen(use_psk);
|
||||
coap_context_set_psk2(main_coap_context, &setup_data);
|
||||
scheme_hint_bits |= 1 << COAP_URI_SCHEME_COAPS;
|
||||
}
|
||||
|
||||
local.s = (uint8_t *)addr_str;
|
||||
local.length = strlen(addr_str);
|
||||
info_list = coap_resolve_address_info(&local, COAP_DEFAULT_PORT,
|
||||
COAPS_DEFAULT_PORT,
|
||||
0, 0,
|
||||
0,
|
||||
scheme_hint_bits,
|
||||
COAP_RESOLVE_TYPE_REMOTE);
|
||||
for (info = info_list; info != NULL; info = info->next) {
|
||||
coap_endpoint_t *ep;
|
||||
|
||||
ep = coap_new_endpoint(main_coap_context, &info->addr, info->proto);
|
||||
if (!ep) {
|
||||
coap_log_warn("cannot create endpoint for proto %u\n",
|
||||
info->proto);
|
||||
}
|
||||
else {
|
||||
have_ep = 1;
|
||||
}
|
||||
}
|
||||
coap_free_address_info(info_list);
|
||||
if (!have_ep) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void *
|
||||
server_coap_run(void *arg) {
|
||||
(void)arg;
|
||||
server_coap_run(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
|
||||
/* Initialize libcoap library */
|
||||
coap_startup();
|
||||
/* Initialize libcoap library */
|
||||
coap_startup();
|
||||
|
||||
coap_set_log_level(COAP_MAX_LOGGING_LEVEL);
|
||||
coap_set_log_level(COAP_MAX_LOGGING_LEVEL);
|
||||
|
||||
if (!init_coap_context_endpoints(COAP_USE_PSK)) {
|
||||
goto fail;
|
||||
}
|
||||
if (!init_coap_context_endpoints(COAP_USE_PSK)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Limit the number of idle sessions to save RAM */
|
||||
coap_context_set_max_idle_sessions(main_coap_context, 2);
|
||||
clock_offset = 1; /* Need a non-zero value */
|
||||
init_coap_resources(main_coap_context);
|
||||
/* Limit the number of idle sessions to save RAM */
|
||||
coap_context_set_max_idle_sessions(main_coap_context, 2);
|
||||
clock_offset = 1; /* Need a non-zero value */
|
||||
init_coap_resources(main_coap_context);
|
||||
|
||||
coap_log_info("libcoap server ready\n");
|
||||
/* Keep on processing ... */
|
||||
while (quit == 0) {
|
||||
coap_io_process(main_coap_context, 1000);
|
||||
}
|
||||
coap_log_info("libcoap server ready\n");
|
||||
/* Keep on processing ... */
|
||||
while (quit == 0) {
|
||||
coap_io_process(main_coap_context, 1000);
|
||||
}
|
||||
fail:
|
||||
/* Clean up library usage so client can be run again */
|
||||
coap_free_context(main_coap_context);
|
||||
main_coap_context = NULL;
|
||||
coap_cleanup();
|
||||
running = 0;
|
||||
quit = 0;
|
||||
coap_log_info("libcoap server stopped\n");
|
||||
return NULL;
|
||||
/* Clean up library usage so client can be run again */
|
||||
coap_free_context(main_coap_context);
|
||||
main_coap_context = NULL;
|
||||
coap_cleanup();
|
||||
running = 0;
|
||||
quit = 0;
|
||||
coap_log_info("libcoap server stopped\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char server_stack[THREAD_STACKSIZE_MAIN +
|
||||
THREAD_EXTRA_STACKSIZE_PRINTF];
|
||||
THREAD_EXTRA_STACKSIZE_PRINTF];
|
||||
|
||||
static
|
||||
void
|
||||
start_server(void) {
|
||||
kernel_pid_t server_pid;
|
||||
start_server(void)
|
||||
{
|
||||
kernel_pid_t server_pid;
|
||||
|
||||
/* Only one instance of the server */
|
||||
if (running) {
|
||||
puts("Error: server already running");
|
||||
/* Only one instance of the server */
|
||||
if (running) {
|
||||
puts("Error: server already running");
|
||||
return;
|
||||
}
|
||||
|
||||
/* The server is initialized */
|
||||
server_pid = thread_create(server_stack,
|
||||
sizeof(server_stack),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
server_coap_run, NULL, "libcoap_server");
|
||||
|
||||
/* Uncommon but better be sure */
|
||||
if (server_pid == EINVAL) {
|
||||
puts("ERROR: Thread invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
if (server_pid == EOVERFLOW) {
|
||||
puts("ERROR: Thread overflow!");
|
||||
return;
|
||||
}
|
||||
|
||||
running = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
/* The server is initialized */
|
||||
server_pid = thread_create(server_stack,
|
||||
sizeof(server_stack),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
server_coap_run, NULL, "libcoap_server");
|
||||
|
||||
/* Uncommon but better be sure */
|
||||
if (server_pid == EINVAL) {
|
||||
puts("ERROR: Thread invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
if (server_pid == EOVERFLOW) {
|
||||
puts("ERROR: Thread overflow!");
|
||||
return;
|
||||
}
|
||||
|
||||
running = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
stop_server(void) {
|
||||
/* check if server is running at all */
|
||||
if (running == 0) {
|
||||
puts("Error: libcoap server is not running");
|
||||
return;
|
||||
}
|
||||
stop_server(void)
|
||||
{
|
||||
/* check if server is running at all */
|
||||
if (running == 0) {
|
||||
puts("Error: libcoap server is not running");
|
||||
return;
|
||||
}
|
||||
|
||||
quit = 1;
|
||||
quit = 1;
|
||||
|
||||
puts("Stopping server...");
|
||||
puts("Stopping server...");
|
||||
}
|
||||
|
||||
void
|
||||
server_coap_init(int argc, char **argv) {
|
||||
if (argc < 2) {
|
||||
printf("usage: %s start|stop\n", argv[0]);
|
||||
server_coap_init(int argc, char **argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
printf("usage: %s start|stop\n", argv[0]);
|
||||
return;
|
||||
}
|
||||
if (strcmp(argv[1], "start") == 0) {
|
||||
start_server();
|
||||
}
|
||||
else if (strcmp(argv[1], "stop") == 0) {
|
||||
stop_server();
|
||||
}
|
||||
else {
|
||||
printf("Error: invalid command. Usage: %s start|stop\n", argv[0]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (strcmp(argv[1], "start") == 0) {
|
||||
start_server();
|
||||
} else if (strcmp(argv[1], "stop") == 0) {
|
||||
stop_server();
|
||||
} else {
|
||||
printf("Error: invalid command. Usage: %s start|stop\n", argv[0]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* server-coap.h -- RIOT client example
|
||||
*
|
||||
* Copyright (C) 2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
* Copyright (C) 2023-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -16,9 +16,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "coap_config.h"
|
||||
#include <coap3/coap.h>
|
||||
|
||||
/* Start up the CoAP Server */
|
||||
void server_coap_init(int argc, char **argv);
|
||||
|
||||
|
||||
@@ -4,17 +4,12 @@
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
#
|
||||
menuconfig KCONFIG_USEPKG_LIBCOAP
|
||||
bool "Configure libcoap"
|
||||
menu "libcoap"
|
||||
depends on USEPKG_LIBCOAP
|
||||
help
|
||||
Configure libcoap package via Kconfig.
|
||||
|
||||
if KCONFIG_USEPKG_LIBCOAP
|
||||
|
||||
choice LIBCOAP_DEBUG_LEVEL
|
||||
bool "Set CoAP debugging level"
|
||||
default LIBCOAP_LOG_DEBUG
|
||||
default LIBCOAP_LOG_INFO
|
||||
help
|
||||
Set CoAP debugging level
|
||||
|
||||
@@ -57,6 +52,7 @@ config LIBCOAP_IPV4_SUPPORT
|
||||
Enable IPv4 functionality for CoAP.
|
||||
|
||||
If this option is disabled, redundant CoAP IPv4 code is removed.
|
||||
[RIOT sock gnrc does not support this]
|
||||
|
||||
config LIBCOAP_IPV6_SUPPORT
|
||||
bool "Enable IPv6 support within CoAP"
|
||||
@@ -66,6 +62,8 @@ config LIBCOAP_IPV6_SUPPORT
|
||||
|
||||
If this option is disabled, redundant CoAP IPv6 code is removed.
|
||||
|
||||
if USEMODULE_SOCK_TCP
|
||||
|
||||
config LIBCOAP_TCP_SUPPORT
|
||||
bool "Enable TCP support within CoAP"
|
||||
default n
|
||||
@@ -74,15 +72,22 @@ config LIBCOAP_TCP_SUPPORT
|
||||
are to be used. Note that RIOT TCP support also needs to be enabled.
|
||||
|
||||
If this option is disabled, redundant CoAP TCP code is removed.
|
||||
[RIOT sock gnrc does not support this]
|
||||
|
||||
endif # USEMODULE_SOCK_TCP
|
||||
|
||||
if USEMODULE_LIBCOAP_OSCORE
|
||||
|
||||
config LIBCOAP_OSCORE_SUPPORT
|
||||
bool "Enable OSCORE support within CoAP"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Enable OSCORE functionality for CoAP.
|
||||
|
||||
If this option is disabled, redundant CoAP OSCORE code is removed.
|
||||
|
||||
endif # MODULE_LIBCOAP_OSCORE
|
||||
|
||||
config LIBCOAP_OBSERVE_PERSIST
|
||||
bool "Enable Observe persist support within CoAP"
|
||||
default n
|
||||
@@ -115,6 +120,23 @@ config LIBCOAP_ASYNC_SUPPORT
|
||||
|
||||
If this option is disabled, redundent CoAP async separate responses code is removed.
|
||||
|
||||
config LIBCOAP_THREAD_SAFE
|
||||
bool "Enable thread safe support within CoAP"
|
||||
default n
|
||||
help
|
||||
Enable thread safe support within CoAP.
|
||||
|
||||
If this option is disabled, libcoap is not thread safe,
|
||||
|
||||
config LIBCOAP_THREAD_RECURSIVE_CHECK
|
||||
bool "Enable thread recursive lock detection if thread safe support is enabled"
|
||||
depends on LIBCOAP_THREAD_SAFE
|
||||
default n
|
||||
help
|
||||
Enable thread recursive lock detection if thread safe support is enabled.
|
||||
|
||||
If this option is disabled, there is no multi thread recursive detection.
|
||||
|
||||
config LIBCOAP_CLIENT_SUPPORT
|
||||
bool "Enable Client functionality within CoAP"
|
||||
default n
|
||||
@@ -129,6 +151,16 @@ config LIBCOAP_CLIENT_SUPPORT
|
||||
If both this option and LIBCOAP_SERVER_SUPPORT are disabled, then
|
||||
both are automatically enabled for backwards compatability.
|
||||
|
||||
if LIBCOAP_CLIENT_SUPPORT
|
||||
|
||||
config LIBCOAP_MAX_LG_CRCVS
|
||||
int "Max number of client large receives supported"
|
||||
default 1
|
||||
help
|
||||
The maximum number of supported client large receives.
|
||||
|
||||
endif # LIBCOAP_CLIENT_SUPPORT
|
||||
|
||||
config LIBCOAP_SERVER_SUPPORT
|
||||
bool "Enable Server functionality within CoAP"
|
||||
default n
|
||||
@@ -141,21 +173,12 @@ config LIBCOAP_SERVER_SUPPORT
|
||||
If both this option and LIBCOAP_CLIENT_SUPPORT are disabled, then
|
||||
both are automatically enabled for backwards compatability.
|
||||
|
||||
config LIBCOAP_MAX_STRING_SIZE
|
||||
int "Max size of string memory allocation"
|
||||
default 64
|
||||
help
|
||||
The maximum size of a supported string.
|
||||
|
||||
config LIBCOAP_MAX_STRINGS
|
||||
int "Max number of strings supported"
|
||||
default 16
|
||||
help
|
||||
The maximum number of supported strings.
|
||||
if LIBCOAP_SERVER_SUPPORT
|
||||
|
||||
config LIBCOAP_MAX_ENDPOINTS
|
||||
int "Max number of endpoints supported"
|
||||
default 4
|
||||
default 4 if LIBCOAP_TCP_SUPPORT
|
||||
default 2
|
||||
help
|
||||
The maximum number of supported endpoints.
|
||||
|
||||
@@ -177,6 +200,57 @@ config LIBCOAP_MAX_ATTRIBUTES
|
||||
help
|
||||
The maximum number of supported resource attributes.
|
||||
|
||||
config LIBCOAP_MAX_CACHE_KEYS
|
||||
int "Max number of cache keys supported"
|
||||
default 2
|
||||
help
|
||||
The maximum number of supported cache keys.
|
||||
|
||||
config LIBCOAP_MAX_CACHE_ENTRIES
|
||||
int "Max number of cache entries supported"
|
||||
default 2
|
||||
help
|
||||
The maximum number of supported cache entries.
|
||||
|
||||
config LIBCOAP_MAX_LG_SRCVS
|
||||
int "Max number of server large receives supported"
|
||||
default 2
|
||||
help
|
||||
The maximum number of supported server large receives.
|
||||
|
||||
endif # LIBCOAP_SERVER_SUPPORT
|
||||
|
||||
config LIBCOAP_PROXY_SUPPORT
|
||||
bool "Enable Proxy functionality within CoAP"
|
||||
depends on LIBCOAP_CLIENT_SUPPORT && LIBCOAP_SERVER_SUPPORT
|
||||
default n
|
||||
help
|
||||
Enable Proxy functionality (ability to receive requests, pass
|
||||
them to an upstream server and send back responses to client)
|
||||
for CoAP.
|
||||
|
||||
If this option is disabled, redundant CoAP proxy only code is
|
||||
removed.
|
||||
|
||||
config LIBCOAP_MAX_LG_XMITS
|
||||
int "Max number of large transmits supported"
|
||||
default 2 if LIBCOAP_SERVER_SUPPORT
|
||||
default 1
|
||||
help
|
||||
The maximum number of supported large transmits.
|
||||
|
||||
config LIBCOAP_MAX_STRING_SIZE
|
||||
int "Max size of string memory allocation"
|
||||
default 64
|
||||
help
|
||||
The maximum size of a supported string.
|
||||
|
||||
config LIBCOAP_MAX_STRINGS
|
||||
int "Max number of strings supported"
|
||||
default 16
|
||||
help
|
||||
The maximum number of supported strings.
|
||||
|
||||
config LIBCOAP_MAX_PACKETS
|
||||
int "Max number of packets supported"
|
||||
default 4
|
||||
@@ -185,7 +259,7 @@ config LIBCOAP_MAX_PACKETS
|
||||
|
||||
config LIBCOAP_MAX_NODES
|
||||
int "Max number of nodes supported"
|
||||
default 16
|
||||
default 4
|
||||
help
|
||||
The maximum number of supported nodes.
|
||||
|
||||
@@ -197,7 +271,7 @@ config LIBCOAP_MAX_CONTEXTS
|
||||
|
||||
config LIBCOAP_MAX_PDUS
|
||||
int "Max number of PDUs supported"
|
||||
default 16
|
||||
default 4
|
||||
help
|
||||
The maximum number of supported PDUs.
|
||||
|
||||
@@ -217,7 +291,7 @@ config LIBCOAP_MAX_OPTION_SIZE
|
||||
int "Max size of option memory allocation"
|
||||
default 16
|
||||
help
|
||||
The maximum size of a supported options.
|
||||
The maximum size of a supported option.
|
||||
|
||||
config LIBCOAP_MAX_OPTIONS
|
||||
int "Max number of options supported"
|
||||
@@ -225,34 +299,4 @@ config LIBCOAP_MAX_OPTIONS
|
||||
help
|
||||
The maximum number of supported options.
|
||||
|
||||
config LIBCOAP_MAX_CACHE_KEYS
|
||||
int "Max number of cache keys supported"
|
||||
default 2
|
||||
help
|
||||
The maximum number of supported cache keys.
|
||||
|
||||
config LIBCOAP_MAX_CACHE_ENTRIES
|
||||
int "Max number of cache entries supported"
|
||||
default 2
|
||||
help
|
||||
The maximum number of supported cache entries.
|
||||
|
||||
config LIBCOAP_MAX_LG_CRCVS
|
||||
int "Max number of client large receives supported"
|
||||
default 1
|
||||
help
|
||||
The maximum number of supported client large receives.
|
||||
|
||||
config LIBCOAP_MAX_LG_SRCVS
|
||||
int "Max number of server large receives supported"
|
||||
default 2
|
||||
help
|
||||
The maximum number of supported server large receives.
|
||||
|
||||
config LIBCOAP_MAX_LG_XMITS
|
||||
int "Max number of large transmits supported"
|
||||
default 2
|
||||
help
|
||||
The maximum number of supported large trqnsmits.
|
||||
|
||||
endif # KCONFIG_USEPKG_LIBCOAP
|
||||
endmenu # libcoap
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
PKG_NAME=libcoap
|
||||
PKG_URL=https://github.com/obgm/libcoap
|
||||
PKG_VERSION=f67f44516a19ab8e430323c9ee00753a6e191ee1
|
||||
PKG_VERSION=0d240530b4beba90cc86c488e17bd0090437a0dd
|
||||
PKG_LICENSE=BSD-2-Clause
|
||||
|
||||
LIBCOAP_BUILD_DIR=$(BINDIR)/pkg/$(PKG_NAME)
|
||||
@@ -9,7 +9,15 @@ LIBCOAP_INCLUDE_DIR=$(RIOTBASE)/build/pkg/$(PKG_NAME)/include/coap3
|
||||
|
||||
include $(RIOTBASE)/pkg/pkg.mk
|
||||
|
||||
all:
|
||||
@cp $(LIBCOAP_SOURCE_DIR)/coap_config.h.riot $(LIBCOAP_SOURCE_DIR)/coap_config.h
|
||||
@cp $(LIBCOAP_INCLUDE_DIR)/coap.h.riot $(LIBCOAP_INCLUDE_DIR)/coap.h
|
||||
"$(MAKE)" -C $(LIBCOAP_SOURCE_DIR)/src -f $(CURDIR)/Makefile.libcoap
|
||||
ifneq (,$(filter libcoap_oscore,$(USEMODULE)))
|
||||
all: libcoap libcoap_oscore
|
||||
else
|
||||
all: libcoap
|
||||
endif
|
||||
|
||||
libcoap:
|
||||
$(QQ)@cp $(LIBCOAP_SOURCE_DIR)/coap_config.h.riot $(LIBCOAP_SOURCE_DIR)/coap_config.h
|
||||
$(QQ)"$(MAKE)" -C $(LIBCOAP_SOURCE_DIR)/src -f $(CURDIR)/Makefile.libcoap
|
||||
|
||||
libcoap_oscore:
|
||||
$(QQ)"$(MAKE)" -C $(LIBCOAP_SOURCE_DIR)/src/oscore -f $(CURDIR)/Makefile.oscore
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
USEMODULE += posix_sockets
|
||||
USEMODULE += posix_headers
|
||||
USEMODULE += posix_inet
|
||||
USEMODULE += posix_select
|
||||
USEMODULE += sock_udp
|
||||
CFLAGS += -DPOSIX_SETSOCKOPT
|
||||
USEMODULE += sock_aux_local
|
||||
USEMODULE += sock_async_event
|
||||
|
||||
ifneq (,$(filter libcoap,$(USEPKG)))
|
||||
USEMODULE += libcoap
|
||||
endif
|
||||
|
||||
ifneq (,$(filter libcoap_oscore,$(USEPKG)))
|
||||
USEMODULE += libcoap_oscore
|
||||
endif
|
||||
|
||||
@@ -24,11 +24,14 @@ SRC := coap_address.c \
|
||||
coap_oscore.c \
|
||||
coap_pdu.c \
|
||||
coap_prng.c \
|
||||
coap_proxy.c \
|
||||
coap_resource.c \
|
||||
coap_session.c \
|
||||
coap_sha1.c \
|
||||
coap_str.c \
|
||||
coap_subscribe.c \
|
||||
coap_tcp.c \
|
||||
coap_threadsafe.c \
|
||||
coap_tinydtls.c \
|
||||
coap_uri.c \
|
||||
coap_ws.c
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
MODULE := libcoap_oscore
|
||||
|
||||
SRC := \
|
||||
oscore.c \
|
||||
oscore_cbor.c \
|
||||
oscore_context.c \
|
||||
oscore_cose.c \
|
||||
oscore_crypto.c
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
@@ -0,0 +1,17 @@
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
#
|
||||
menu "tests_libcoap"
|
||||
depends on USEPKG_LIBCOAP
|
||||
|
||||
config LIBCOAP_USE_PSK
|
||||
string "Secret to use for PSK communications"
|
||||
default "secretPSK"
|
||||
depends on USEMODULE_TINYDTLS
|
||||
config LIBCOAP_USE_PSK_ID
|
||||
string "Identifier (user) to use for PSK communications"
|
||||
default "test_user"
|
||||
depends on USEMODULE_TINYDTLS
|
||||
|
||||
endmenu # tests_libcoap
|
||||
@@ -0,0 +1,35 @@
|
||||
# Include common testing definitions
|
||||
include ../Makefile.pkg_common
|
||||
|
||||
# This test depends on tap device setup not being set
|
||||
PORT=
|
||||
|
||||
# Include packages that pull up and auto-init the link layer.
|
||||
# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present
|
||||
USEMODULE += netdev_default
|
||||
USEMODULE += auto_init_gnrc_netif
|
||||
USEMODULE += gnrc_netif_single
|
||||
|
||||
# Additional networking modules that can be dropped if not needed
|
||||
USEMODULE += netutils
|
||||
|
||||
# Specify the mandatory networking modules for IPv6 and UDP
|
||||
USEMODULE += gnrc_ipv6_default
|
||||
|
||||
USEMODULE += memarray
|
||||
|
||||
# a cryptographically secure implementation of PRNG is needed for tinydtls
|
||||
CFLAGS += -DWITH_RIOT_SOCK
|
||||
CFLAGS += -DDTLS_PEER_MAX=2 -DDTLS_HANDSHAKE_MAX=2 -DNETQ_MAXCNT=5
|
||||
USEPKG += tinydtls
|
||||
USEMODULE += prng_sha1prng
|
||||
|
||||
# libcoap support
|
||||
USEPKG += libcoap
|
||||
|
||||
USEMODULE += ztimer64_xtimer_compat
|
||||
|
||||
# libcoap needs some space
|
||||
CFLAGS += -DTHREAD_STACKSIZE_MAIN=\(3*THREAD_STACKSIZE_DEFAULT\)
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
@@ -0,0 +1,70 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
airfy-beacon \
|
||||
arduino-duemilanove \
|
||||
arduino-leonardo \
|
||||
arduino-mega2560 \
|
||||
arduino-nano \
|
||||
arduino-uno \
|
||||
atmega256rfr2-xpro \
|
||||
atmega328p \
|
||||
atmega328p-xplained-mini \
|
||||
atmega8 \
|
||||
atxmega-a3bu-xplained \
|
||||
b-l072z-lrwan1 \
|
||||
blackpill-stm32f103c8 \
|
||||
blackpill-stm32f103cb \
|
||||
bluepill-stm32f030c8 \
|
||||
bluepill-stm32f103c8 \
|
||||
bluepill-stm32f103cb \
|
||||
calliope-mini \
|
||||
cc2650-launchpad \
|
||||
cc2650stk \
|
||||
derfmega128 \
|
||||
hifive1 \
|
||||
hifive1b \
|
||||
i-nucleo-lrwan1 \
|
||||
im880b \
|
||||
lsn50 \
|
||||
maple-mini \
|
||||
microbit \
|
||||
microduino-corerf \
|
||||
msb-430 \
|
||||
msb-430h \
|
||||
nrf51dk \
|
||||
nrf51dongle \
|
||||
nrf6310 \
|
||||
nucleo-f030r8 \
|
||||
nucleo-f031k6 \
|
||||
nucleo-f042k6 \
|
||||
nucleo-f070rb \
|
||||
nucleo-f072rb \
|
||||
nucleo-f103rb \
|
||||
nucleo-f302r8 \
|
||||
nucleo-f303k8 \
|
||||
nucleo-f334r8 \
|
||||
nucleo-l011k4 \
|
||||
nucleo-l031k6 \
|
||||
nucleo-l053r8 \
|
||||
nucleo-l073rz \
|
||||
olimex-msp430-h1611 \
|
||||
olimex-msp430-h2618 \
|
||||
opencm904 \
|
||||
samd10-xmini \
|
||||
saml10-xpro \
|
||||
saml11-xpro \
|
||||
samr21-xpro \
|
||||
slstk3400a \
|
||||
spark-core \
|
||||
stk3200 \
|
||||
stm32f030f4-demo \
|
||||
stm32f0discovery \
|
||||
stm32f7508-dk \
|
||||
stm32g0316-disco \
|
||||
stm32l0538-disco \
|
||||
stm32mp157c-dk2 \
|
||||
telosb \
|
||||
waspmote-pro \
|
||||
yunjia-nrf51822 \
|
||||
z1 \
|
||||
zigduino \
|
||||
#
|
||||
@@ -0,0 +1,7 @@
|
||||
# libcoap test example
|
||||
|
||||
This test is to check that the libcoap client and server logic talk to
|
||||
each other.
|
||||
|
||||
THe client request generates a CoAP request, which is sent to the server
|
||||
who responds back to the client.
|
||||
@@ -0,0 +1,11 @@
|
||||
CONFIG_LIBCOAP_SERVER_SUPPORT=y
|
||||
CONFIG_LIBCOAP_CLIENT_SUPPORT=y
|
||||
|
||||
CONFIG_LIBCOAP_USE_PSK="secretPSK"
|
||||
CONFIG_LIBCOAP_USE_PSK_ID="test_user"
|
||||
|
||||
# Logging levels are defined in pkg/libcoap using Kconfig
|
||||
CONFIG_LIBCOAP_LOG_ALERT=y
|
||||
|
||||
CONFIG_DTLS_PEER_MAX=2
|
||||
CONFIG_DTLS_HANDSHAKE_MAX=2
|
||||
@@ -0,0 +1,327 @@
|
||||
/*
|
||||
* libcoap-test.c -- RIOT example
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "coap_config.h"
|
||||
#include <coap3/coap.h>
|
||||
#include "libcoap-test.h"
|
||||
#include <stdio.h>
|
||||
#include "macros/utils.h"
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_USE_PSK
|
||||
#define COAP_USE_PSK CONFIG_LIBCOAP_USE_PSK
|
||||
#else /* CONFIG_LIBCOAP_USE_PSK */
|
||||
#define COAP_USE_PSK NULL
|
||||
#endif /* CONFIG_LIBCOAP_USE_PSK */
|
||||
|
||||
#ifdef CONFIG_LIBCOAP_USE_PSK_ID
|
||||
#define COAP_USE_PSK_ID CONFIG_LIBCOAP_USE_PSK_ID
|
||||
#else /* CONFIG_LIBCOAP_USE_PSK_ID */
|
||||
#define COAP_USE_PSK_ID NULL
|
||||
#endif /* CONFIG_LIBCOAP_USE_PSK_ID */
|
||||
|
||||
static int quit;
|
||||
|
||||
#define INDEX "This is a DTLS loopback test client/server made with libcoap\n"
|
||||
|
||||
static void
|
||||
hnd_get_index(coap_resource_t *resource, coap_session_t *session,
|
||||
const coap_pdu_t *request, const coap_string_t *query,
|
||||
coap_pdu_t *response)
|
||||
{
|
||||
coap_pdu_set_code(response, COAP_RESPONSE_CODE_CONTENT);
|
||||
coap_add_data_large_response(resource, session, request, response,
|
||||
query, COAP_MEDIATYPE_TEXT_PLAIN,
|
||||
0x7fff, 0, strlen(INDEX),
|
||||
(const uint8_t *)INDEX, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
init_coap_resources(coap_context_t *ctx)
|
||||
{
|
||||
coap_resource_t *r;
|
||||
|
||||
r = coap_resource_init(NULL, 0);
|
||||
if (r == NULL) {
|
||||
goto error;
|
||||
}
|
||||
coap_register_handler(r, COAP_REQUEST_GET, hnd_get_index);
|
||||
|
||||
coap_add_resource(ctx, r);
|
||||
|
||||
return;
|
||||
error:
|
||||
coap_log_crit("cannot create resource\n");
|
||||
}
|
||||
|
||||
static int
|
||||
init_coap_endpoints(coap_context_t *ctx, const char *use_psk)
|
||||
{
|
||||
char addr_str[INET6_ADDRSTRLEN + 8];
|
||||
int scheme_hint_bits = 1 << COAP_URI_SCHEME_COAP;
|
||||
coap_addr_info_t *info = NULL;
|
||||
coap_addr_info_t *info_list = NULL;
|
||||
coap_str_const_t local;
|
||||
int have_ep = 0;
|
||||
|
||||
if (use_psk && coap_dtls_is_supported()) {
|
||||
coap_dtls_spsk_t setup_data;
|
||||
|
||||
/* Need PSK set up before setting up endpoints */
|
||||
memset(&setup_data, 0, sizeof(setup_data));
|
||||
setup_data.version = COAP_DTLS_SPSK_SETUP_VERSION;
|
||||
setup_data.psk_info.key.s = (const uint8_t *)use_psk;
|
||||
setup_data.psk_info.key.length = strlen(use_psk);
|
||||
coap_context_set_psk2(ctx, &setup_data);
|
||||
scheme_hint_bits |= 1 << COAP_URI_SCHEME_COAPS;
|
||||
}
|
||||
|
||||
local.s = (uint8_t *)"::1";
|
||||
local.length = strlen(addr_str);
|
||||
info_list = coap_resolve_address_info(&local, COAP_DEFAULT_PORT,
|
||||
COAPS_DEFAULT_PORT,
|
||||
0, 0,
|
||||
0,
|
||||
scheme_hint_bits,
|
||||
COAP_RESOLVE_TYPE_REMOTE);
|
||||
for (info = info_list; info != NULL; info = info->next) {
|
||||
coap_endpoint_t *ep;
|
||||
|
||||
ep = coap_new_endpoint(ctx, &info->addr, info->proto);
|
||||
if (!ep) {
|
||||
coap_log_warn("cannot create endpoint for proto %u\n",
|
||||
info->proto);
|
||||
}
|
||||
else {
|
||||
have_ep = 1;
|
||||
}
|
||||
}
|
||||
coap_free_address_info(info_list);
|
||||
if (!have_ep) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
coap_server_init(coap_context_t *ctx)
|
||||
{
|
||||
if (!init_coap_endpoints(ctx, COAP_USE_PSK)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
init_coap_resources(ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
resolve_address(const char *host, const char *service, coap_address_t *dst,
|
||||
int scheme_hint_bits)
|
||||
{
|
||||
uint16_t port = service ? atoi(service) : 0;
|
||||
int ret = 0;
|
||||
coap_str_const_t str_host;
|
||||
coap_addr_info_t *addr_info;
|
||||
|
||||
str_host.s = (const uint8_t *)host;
|
||||
str_host.length = strlen(host);
|
||||
addr_info = coap_resolve_address_info(&str_host, port, port, port, port,
|
||||
AF_UNSPEC, scheme_hint_bits,
|
||||
COAP_RESOLVE_TYPE_REMOTE);
|
||||
if (addr_info) {
|
||||
ret = 1;
|
||||
*dst = addr_info->addr;
|
||||
}
|
||||
|
||||
coap_free_address_info(addr_info);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static coap_response_t
|
||||
message_handler(coap_session_t *session,
|
||||
const coap_pdu_t *sent,
|
||||
const coap_pdu_t *received,
|
||||
const coap_mid_t id)
|
||||
{
|
||||
const uint8_t *data;
|
||||
size_t len;
|
||||
size_t offset;
|
||||
size_t total;
|
||||
|
||||
(void)session;
|
||||
(void)sent;
|
||||
(void)id;
|
||||
if (coap_get_data_large(received, &len, &data, &offset, &total)) {
|
||||
printf("%*.*s", (int)len, (int)len, (const char *)data);
|
||||
if (len + offset == total) {
|
||||
printf("\n");
|
||||
quit = 1;
|
||||
}
|
||||
}
|
||||
return COAP_RESPONSE_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
coap_client_init(coap_context_t *ctx)
|
||||
{
|
||||
coap_session_t *session = NULL;
|
||||
coap_pdu_t *pdu;
|
||||
coap_address_t dst;
|
||||
coap_mid_t mid;
|
||||
int len;
|
||||
coap_uri_t uri;
|
||||
char portbuf[8];
|
||||
coap_optlist_t *optlist = NULL;
|
||||
|
||||
#define BUFSIZE 100
|
||||
unsigned char buf[BUFSIZE];
|
||||
int res;
|
||||
const char *coap_uri = "coaps://[::1]";
|
||||
|
||||
/* Parse the URI */
|
||||
len = coap_split_uri((const unsigned char *)coap_uri, strlen(coap_uri), &uri);
|
||||
if (len != 0) {
|
||||
coap_log_warn("Failed to parse uri %s\n", coap_uri);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
snprintf(portbuf, sizeof(portbuf), "%d", uri.port);
|
||||
snprintf((char *)buf, sizeof(buf), "%*.*s", (int)uri.host.length,
|
||||
(int)uri.host.length, (const char *)uri.host.s);
|
||||
/* resolve destination address where packet should be sent */
|
||||
len = resolve_address((const char *)buf, portbuf, &dst, 1 << uri.scheme);
|
||||
if (len <= 0) {
|
||||
coap_log_warn("Failed to resolve address %*.*s\n", (int)uri.host.length,
|
||||
(int)uri.host.length, (const char *)uri.host.s);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (uri.scheme == COAP_URI_SCHEME_COAP) {
|
||||
session = coap_new_client_session(ctx, NULL, &dst,
|
||||
COAP_PROTO_UDP);
|
||||
}
|
||||
else if (uri.scheme == COAP_URI_SCHEME_COAP_TCP) {
|
||||
goto fail;
|
||||
}
|
||||
else if (uri.scheme == COAP_URI_SCHEME_COAPS_TCP) {
|
||||
goto fail;
|
||||
}
|
||||
else if (uri.scheme == COAP_URI_SCHEME_COAPS) {
|
||||
#if defined (COAP_USE_PSK) && defined(COAP_USE_PSK_ID)
|
||||
static coap_dtls_cpsk_t dtls_psk;
|
||||
static char client_sni[256];
|
||||
|
||||
memset(client_sni, 0, sizeof(client_sni));
|
||||
memset(&dtls_psk, 0, sizeof(dtls_psk));
|
||||
dtls_psk.version = COAP_DTLS_CPSK_SETUP_VERSION;
|
||||
if (uri.host.length) {
|
||||
memcpy(client_sni, uri.host.s,
|
||||
MIN(uri.host.length, sizeof(client_sni) - 1));
|
||||
}
|
||||
else {
|
||||
memcpy(client_sni, "localhost", 9);
|
||||
}
|
||||
dtls_psk.client_sni = client_sni;
|
||||
dtls_psk.psk_info.identity.s = (const uint8_t *)COAP_USE_PSK_ID;
|
||||
dtls_psk.psk_info.identity.length = strlen(COAP_USE_PSK_ID);
|
||||
dtls_psk.psk_info.key.s = (const uint8_t *)COAP_USE_PSK;
|
||||
dtls_psk.psk_info.key.length = strlen(COAP_USE_PSK);
|
||||
|
||||
session = coap_new_client_session_psk2(ctx, NULL, &dst,
|
||||
COAP_PROTO_DTLS, &dtls_psk);
|
||||
#else /* ! COAP_USE_PSK && ! COAP_USE_PSK_ID */
|
||||
coap_log_err("CONFIG_LIBCOAP_USE_PSK and CONFIG_LIBCOAP_USE_PSK_ID not defined\n");
|
||||
goto fail;
|
||||
#endif /* ! COAP_USE_PSK && ! COAP_USE_PSK_ID */
|
||||
}
|
||||
|
||||
if (!session) {
|
||||
coap_log_warn("Failed to create session\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
coap_register_response_handler(ctx, message_handler);
|
||||
|
||||
/* construct CoAP message */
|
||||
pdu = coap_pdu_init(COAP_MESSAGE_CON,
|
||||
COAP_REQUEST_CODE_GET,
|
||||
coap_new_message_id(session),
|
||||
coap_session_max_pdu_size(session));
|
||||
if (!pdu) {
|
||||
coap_log_warn("Failed to create PDU\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
res = coap_uri_into_optlist(&uri, &dst, &optlist, 1);
|
||||
if (res != 1) {
|
||||
coap_log_warn("Failed to create options\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Add option list (which will be sorted) to the PDU */
|
||||
if (optlist) {
|
||||
res = coap_add_optlist_pdu(pdu, &optlist);
|
||||
if (res != 1) {
|
||||
coap_log_warn("Failed to add options to PDU\n");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/* and send the PDU */
|
||||
mid = coap_send(session, pdu);
|
||||
if (mid == COAP_INVALID_MID) {
|
||||
coap_log_warn("Failed to send PDU\n");
|
||||
goto fail;
|
||||
}
|
||||
coap_delete_optlist(optlist);
|
||||
return 1;
|
||||
|
||||
fail:
|
||||
coap_delete_optlist(optlist);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
libcoap_test_run(void)
|
||||
{
|
||||
coap_context_t *coap_context;
|
||||
|
||||
/* Initialize libcoap library */
|
||||
coap_startup();
|
||||
|
||||
coap_set_log_level(COAP_MAX_LOGGING_LEVEL);
|
||||
|
||||
coap_context = coap_new_context(NULL);
|
||||
if (!coap_context) {
|
||||
goto fail;
|
||||
}
|
||||
coap_context_set_block_mode(coap_context, COAP_BLOCK_USE_LIBCOAP);
|
||||
|
||||
/* Set up server logic */
|
||||
coap_server_init(coap_context);
|
||||
coap_log_info("libcoap test server ready\n");
|
||||
|
||||
/* Set up and initiate client logic */
|
||||
coap_client_init(coap_context);
|
||||
coap_log_info("libcoap test client started\n");
|
||||
|
||||
/* Keep on processing until response is back in ... */
|
||||
while (quit == 0) {
|
||||
coap_io_process(coap_context, 1000);
|
||||
}
|
||||
fail:
|
||||
/* Clean up library usage so client can be run again */
|
||||
coap_free_context(coap_context);
|
||||
|
||||
coap_cleanup();
|
||||
coap_log_info("libcoap test stopped\n");
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* libcoap-test.h -- RIOT client example
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef LIBCOAP_TEST_H
|
||||
#define LIBCOAP_TEST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Start up the CoAP Server */
|
||||
void libcoap_test_run(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBCOAP_TEST_H */
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Freie Universität Berlin
|
||||
* Copyright (C) 2018 Inria
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup examples
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Example test application for libcoap
|
||||
*
|
||||
* @author Raul Fuentes <>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "shell.h"
|
||||
#include "msg.h"
|
||||
|
||||
#include "libcoap-test.h"
|
||||
#include "coap3/coap.h"
|
||||
|
||||
#define MAIN_QUEUE_SIZE (8)
|
||||
static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
/* we need a message queue for the thread running the shell in order to
|
||||
* receive potentially fast incoming networking packets */
|
||||
msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);
|
||||
|
||||
libcoap_test_run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2020 Otto-von-Guericke-Universität Magdeburg
|
||||
#
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
|
||||
import sys
|
||||
from testrunner import run
|
||||
|
||||
|
||||
def testfunc(child):
|
||||
child.expect_exact("This is a DTLS loopback test client/server made with libcoap\r\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(run(testfunc))
|
||||
@@ -1,12 +1,13 @@
|
||||
# Makefile for libcoap standalone examples
|
||||
#
|
||||
# Copyright (C) 2021-2023 Olaf Bergmann <bergmann@tzi.org>
|
||||
# Copyright (C) 2021-2024 Olaf Bergmann <bergmann@tzi.org>
|
||||
#
|
||||
# This file is part of the CoAP C library libcoap. Please see README and
|
||||
# COPYING for terms of use.
|
||||
|
||||
# Set external variable LIBCOAP if you need a specific libcoap library.
|
||||
# E.g. libcoap-3-openssl, libcoap-3-gnutls, libcoap-3-mbedtls or libcoap-3-notls
|
||||
# E.g. libcoap-3-openssl, libcoap-3-gnutls, libcoap-3-mbedtls, libcoap-3-wolfssl
|
||||
# or libcoap-3-notls
|
||||
#
|
||||
LIBCOAP?=libcoap-3
|
||||
|
||||
|
||||
@@ -5,5 +5,3 @@ The provided code is the same as used to build the installed binaries
|
||||
coap-client and coap-server.
|
||||
|
||||
Simply 'cd' into this directory and then run 'make' to build the executables.
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#/bin/bash
|
||||
|
||||
#
|
||||
# This is a helper script to get what the current build configuration is
|
||||
#
|
||||
|
||||
TAGS=0
|
||||
if [ -f config.log ] ; then
|
||||
echo "Last ./configure build"
|
||||
echo ""
|
||||
cat config.log | grep -E " libcoap| host s" | cut -d\ -f7-
|
||||
cat config.log | grep -E "result: " | cut -d\ -f3- | cut -d\ -f7-
|
||||
echo ""
|
||||
TAGS=1
|
||||
fi
|
||||
for f in `find . -name CMakeCache.txt -print` ; do
|
||||
DIR=`dirname $f`
|
||||
echo "Last cmake build in $DIR"
|
||||
echo ""
|
||||
(cd $DIR ; cmake -LH . | cut -d\ -f2- | grep -E "\.\." | grep -E "^[A-Z][A-Z]")
|
||||
echo ""
|
||||
TAGS=1
|
||||
done
|
||||
|
||||
if [ "$TAGS" = 0 ] ; then
|
||||
echo "Current git source"
|
||||
echo ""
|
||||
git describe --tags --dirty --always
|
||||
echo ""
|
||||
fi
|
||||
+16
-8
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* coap.h -- main header file for CoAP stack of libcoap
|
||||
*
|
||||
* Copyright (C) 2010-2012,2015-2023 Olaf Bergmann <bergmann@tzi.org>
|
||||
* 2015 Carsten Schoenert <c.schoenert@t-online.de>
|
||||
* Copyright (C) 2010-2012,2015-2024 Olaf Bergmann <bergmann@tzi.org>
|
||||
* 2015 Carsten Schoenert <c.schoenert@t-online.de>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -25,23 +25,26 @@
|
||||
#define LIBCOAP_PACKAGE_NAME "libcoap"
|
||||
|
||||
/* Define the full name and version of libcoap. */
|
||||
#define LIBCOAP_PACKAGE_STRING "libcoap 4.3.4"
|
||||
#define LIBCOAP_PACKAGE_STRING "libcoap 4.3.5"
|
||||
|
||||
/* Define the home page for libcoap. */
|
||||
#define LIBCOAP_PACKAGE_URL "https://libcoap.net/"
|
||||
|
||||
/* Define the version of libcoap this file belongs to. */
|
||||
#define LIBCOAP_PACKAGE_VERSION "4.3.4"
|
||||
#define LIBCOAP_PACKAGE_VERSION "4.3.5"
|
||||
|
||||
/* Define the numeric version identifier for libcoap */
|
||||
#define LIBCOAP_VERSION (4003004U)
|
||||
#define LIBCOAP_VERSION (4003005ULL)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "coap3/libcoap.h"
|
||||
#ifdef COAP_SUPPORT_SOCKET_BROADCAST
|
||||
#include "securec.h"
|
||||
#endif
|
||||
|
||||
#include "coap3/coap_forward_decls.h"
|
||||
#include "coap3/coap_address.h"
|
||||
#include "coap3/coap_async.h"
|
||||
@@ -52,22 +55,27 @@ extern "C" {
|
||||
#include "coap3/coap_encode.h"
|
||||
#include "coap3/coap_event.h"
|
||||
#include "coap3/coap_io.h"
|
||||
#include "coap3/coap_internal.h"
|
||||
#include "coap3/coap_layers_internal.h"
|
||||
#include "coap3/coap_mem.h"
|
||||
#include "coap3/coap_net.h"
|
||||
#include "coap3/coap_netif_internal.h"
|
||||
#include "coap3/coap_option.h"
|
||||
#include "coap3/coap_oscore.h"
|
||||
#include "coap3/coap_pdu.h"
|
||||
#include "coap3/coap_prng.h"
|
||||
#include "coap3/coap_proxy.h"
|
||||
#include "coap3/coap_resource.h"
|
||||
#include "coap3/coap_str.h"
|
||||
#include "coap3/coap_subscribe.h"
|
||||
#include "coap3/coap_supported.h"
|
||||
#include "coap3/coap_time.h"
|
||||
#include "coap3/coap_uri.h"
|
||||
#include "coap3/coap_ws.h"
|
||||
|
||||
#ifdef COAP_SUPPORT_SOCKET_BROADCAST
|
||||
#include "coap3/coap_internal.h"
|
||||
#include "coap3/coap_layers_internal.h"
|
||||
#include "coap3/coap_netif_internal.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* coap.h -- main header file for CoAP stack of libcoap
|
||||
*
|
||||
* Copyright (C) 2010-2012,2015-2023 Olaf Bergmann <bergmann@tzi.org>
|
||||
* 2015 Carsten Schoenert <c.schoenert@t-online.de>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file coap.h
|
||||
* @brief Primary include file
|
||||
*/
|
||||
|
||||
#ifndef COAP_H_
|
||||
#define COAP_H_
|
||||
|
||||
/* Define the address where bug reports for libcoap should be sent. */
|
||||
#define LIBCOAP_PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
|
||||
|
||||
/* Define the full name of libcoap. */
|
||||
#define LIBCOAP_PACKAGE_NAME "@PACKAGE_NAME@"
|
||||
|
||||
/* Define the full name and version of libcoap. */
|
||||
#define LIBCOAP_PACKAGE_STRING "@PACKAGE_STRING@"
|
||||
|
||||
/* Define the home page for libcoap. */
|
||||
#define LIBCOAP_PACKAGE_URL "@PACKAGE_URL@"
|
||||
|
||||
/* Define the version of libcoap this file belongs to. */
|
||||
#define LIBCOAP_PACKAGE_VERSION "@PACKAGE_VERSION@"
|
||||
|
||||
/* Define the numeric version identifier for libcoap */
|
||||
#define LIBCOAP_VERSION (@LIBCOAP_VERSION@U)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "coap@LIBCOAP_API_VERSION@/libcoap.h"
|
||||
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_forward_decls.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_address.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_async.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_block.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_cache.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_debug.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_dtls.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_encode.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_event.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_io.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_mem.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_net.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_option.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_oscore.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_pdu.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_prng.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_resource.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_str.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_subscribe.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_time.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_uri.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_ws.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* COAP_H_ */
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* coap.h -- main header file for CoAP stack of libcoap (RIOT)
|
||||
*
|
||||
* Copyright (C) 2010-2012,2015-2017 Olaf Bergmann <bergmann@tzi.org>
|
||||
* 2015 Carsten Schoenert <c.schoenert@t-online.de>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*/
|
||||
|
||||
#ifndef COAP_H_
|
||||
#define COAP_H_
|
||||
|
||||
/* Define the address where bug reports for libcoap should be sent. */
|
||||
#define LIBCOAP_PACKAGE_BUGREPORT "libcoap-developers@lists.sourceforge.net"
|
||||
|
||||
/* Define the full name of libcoap. */
|
||||
#define LIBCOAP_PACKAGE_NAME "libcoap"
|
||||
|
||||
/* Define the full name and version of libcoap. */
|
||||
#define LIBCOAP_PACKAGE_STRING "libcoap 4.3.4"
|
||||
|
||||
/* Define the home page for libcoap. */
|
||||
#define LIBCOAP_PACKAGE_URL "https://libcoap.net/"
|
||||
|
||||
/* Define the version of libcoap this file belongs to. */
|
||||
#define LIBCOAP_PACKAGE_VERSION "4.3.4"
|
||||
|
||||
/* Define the numeric version identifier for libcoap */
|
||||
#define LIBCOAP_VERSION (4003004U)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "libcoap.h"
|
||||
|
||||
#include "coap_forward_decls.h"
|
||||
#include "coap_address.h"
|
||||
#include "coap_async.h"
|
||||
#include "coap_block.h"
|
||||
#include "coap_cache.h"
|
||||
#include "coap_debug.h"
|
||||
#include "coap_dtls.h"
|
||||
#include "coap_encode.h"
|
||||
#include "coap_event.h"
|
||||
#include "coap_io.h"
|
||||
#include "coap_mem.h"
|
||||
#include "coap_net.h"
|
||||
#include "coap_option.h"
|
||||
#include "coap_oscore.h"
|
||||
#include "coap_pdu.h"
|
||||
#include "coap_prng.h"
|
||||
#include "coap_resource.h"
|
||||
#include "coap_str.h"
|
||||
#include "coap_subscribe.h"
|
||||
#include "coap_time.h"
|
||||
#include "coap_uri.h"
|
||||
#include "coap_ws.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* COAP_H_ */
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* coap.h -- main header file for CoAP stack of libcoap (RIOT)
|
||||
*
|
||||
* Copyright (C) 2010-2012,2015-2017 Olaf Bergmann <bergmann@tzi.org>
|
||||
* 2015 Carsten Schoenert <c.schoenert@t-online.de>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*/
|
||||
|
||||
#ifndef COAP_H_
|
||||
#define COAP_H_
|
||||
|
||||
/* Define the address where bug reports for libcoap should be sent. */
|
||||
#define LIBCOAP_PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
|
||||
|
||||
/* Define the full name of libcoap. */
|
||||
#define LIBCOAP_PACKAGE_NAME "@PACKAGE_NAME@"
|
||||
|
||||
/* Define the full name and version of libcoap. */
|
||||
#define LIBCOAP_PACKAGE_STRING "@PACKAGE_STRING@"
|
||||
|
||||
/* Define the home page for libcoap. */
|
||||
#define LIBCOAP_PACKAGE_URL "@PACKAGE_URL@"
|
||||
|
||||
/* Define the version of libcoap this file belongs to. */
|
||||
#define LIBCOAP_PACKAGE_VERSION "@PACKAGE_VERSION@"
|
||||
|
||||
/* Define the numeric version identifier for libcoap */
|
||||
#define LIBCOAP_VERSION (@LIBCOAP_VERSION@U)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "libcoap.h"
|
||||
|
||||
#include "coap_forward_decls.h"
|
||||
#include "coap_address.h"
|
||||
#include "coap_async.h"
|
||||
#include "coap_block.h"
|
||||
#include "coap_cache.h"
|
||||
#include "coap_debug.h"
|
||||
#include "coap_dtls.h"
|
||||
#include "coap_encode.h"
|
||||
#include "coap_event.h"
|
||||
#include "coap_io.h"
|
||||
#include "coap_mem.h"
|
||||
#include "coap_net.h"
|
||||
#include "coap_option.h"
|
||||
#include "coap_oscore.h"
|
||||
#include "coap_pdu.h"
|
||||
#include "coap_prng.h"
|
||||
#include "coap_resource.h"
|
||||
#include "coap_str.h"
|
||||
#include "coap_subscribe.h"
|
||||
#include "coap_time.h"
|
||||
#include "coap_uri.h"
|
||||
#include "coap_ws.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* COAP_H_ */
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* coap.h -- main header file for CoAP stack of libcoap (Windows)
|
||||
*
|
||||
* Copyright (C) 2010-2012,2015-2023 Olaf Bergmann <bergmann@tzi.org>
|
||||
* 2015 Carsten Schoenert <c.schoenert@t-online.de>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*/
|
||||
|
||||
#ifndef COAP_H_
|
||||
#define COAP_H_
|
||||
|
||||
/* Define the address where bug reports for libcoap should be sent. */
|
||||
#define LIBCOAP_PACKAGE_BUGREPORT "libcoap-developers@lists.sourceforge.net"
|
||||
|
||||
/* Define the full name of libcoap. */
|
||||
#define LIBCOAP_PACKAGE_NAME "libcoap"
|
||||
|
||||
/* Define the full name and version of libcoap. */
|
||||
#define LIBCOAP_PACKAGE_STRING "libcoap 4.3.4"
|
||||
|
||||
/* Define the home page for libcoap. */
|
||||
#define LIBCOAP_PACKAGE_URL "https://libcoap.net/"
|
||||
|
||||
/* Define the version of libcoap this file belongs to. */
|
||||
#define LIBCOAP_PACKAGE_VERSION "4.3.4"
|
||||
|
||||
/* Define the numeric version identifier for libcoap */
|
||||
#define LIBCOAP_VERSION (4003004U)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "coap3/libcoap.h"
|
||||
|
||||
#include "coap3/coap_forward_decls.h"
|
||||
#include "coap3/coap_address.h"
|
||||
#include "coap3/coap_async.h"
|
||||
#include "coap3/coap_block.h"
|
||||
#include "coap3/coap_cache.h"
|
||||
#include "coap3/coap_debug.h"
|
||||
#include "coap3/coap_dtls.h"
|
||||
#include "coap3/coap_encode.h"
|
||||
#include "coap3/coap_event.h"
|
||||
#include "coap3/coap_io.h"
|
||||
#include "coap3/coap_mem.h"
|
||||
#include "coap3/coap_net.h"
|
||||
#include "coap3/coap_option.h"
|
||||
#include "coap3/coap_oscore.h"
|
||||
#include "coap3/coap_pdu.h"
|
||||
#include "coap3/coap_prng.h"
|
||||
#include "coap3/coap_resource.h"
|
||||
#include "coap3/coap_str.h"
|
||||
#include "coap3/coap_subscribe.h"
|
||||
#include "coap3/coap_time.h"
|
||||
#include "coap3/coap_uri.h"
|
||||
#include "coap3/coap_ws.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* COAP_H_ */
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* coap.h -- main header file for CoAP stack of libcoap (Windows)
|
||||
*
|
||||
* Copyright (C) 2010-2012,2015-2023 Olaf Bergmann <bergmann@tzi.org>
|
||||
* 2015 Carsten Schoenert <c.schoenert@t-online.de>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*/
|
||||
|
||||
#ifndef COAP_H_
|
||||
#define COAP_H_
|
||||
|
||||
/* Define the address where bug reports for libcoap should be sent. */
|
||||
#define LIBCOAP_PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
|
||||
|
||||
/* Define the full name of libcoap. */
|
||||
#define LIBCOAP_PACKAGE_NAME "@PACKAGE_NAME@"
|
||||
|
||||
/* Define the full name and version of libcoap. */
|
||||
#define LIBCOAP_PACKAGE_STRING "@PACKAGE_STRING@"
|
||||
|
||||
/* Define the home page for libcoap. */
|
||||
#define LIBCOAP_PACKAGE_URL "@PACKAGE_URL@"
|
||||
|
||||
/* Define the version of libcoap this file belongs to. */
|
||||
#define LIBCOAP_PACKAGE_VERSION "@PACKAGE_VERSION@"
|
||||
|
||||
/* Define the numeric version identifier for libcoap */
|
||||
#define LIBCOAP_VERSION (@LIBCOAP_VERSION@U)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "coap@LIBCOAP_API_VERSION@/libcoap.h"
|
||||
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_forward_decls.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_address.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_async.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_block.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_cache.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_debug.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_dtls.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_encode.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_event.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_io.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_mem.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_net.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_option.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_oscore.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_pdu.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_prng.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_resource.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_str.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_subscribe.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_time.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_uri.h"
|
||||
#include "coap@LIBCOAP_API_VERSION@/coap_ws.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* COAP_H_ */
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* coap_address.h -- representation of network addresses
|
||||
*
|
||||
* Copyright (C) 2010-2011,2015-2016,2022-2023 Olaf Bergmann <bergmann@tzi.org>
|
||||
* Copyright (C) 2010-2011,2015-2016,2022-2024 Olaf Bergmann <bergmann@tzi.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -58,10 +58,6 @@ coap_address_set_port(coap_address_t *addr, uint16_t port) {
|
||||
|
||||
#define _coap_is_mcast_impl(Address) ip_addr_ismulticast(&(Address)->addr)
|
||||
|
||||
#ifdef COAP_SUPPORT_SOCKET_BROADCAST
|
||||
#define _coap_is_bcast_impl(Address) ip_addr_isbroadcast(&(Address)->addr)
|
||||
#endif
|
||||
|
||||
#elif defined(WITH_CONTIKI)
|
||||
|
||||
#include "uip.h"
|
||||
@@ -96,11 +92,46 @@ coap_address_set_port(coap_address_t *addr, uint16_t port) {
|
||||
|
||||
#define _coap_is_mcast_impl(Address) uip_is_addr_mcast(&((Address)->addr))
|
||||
|
||||
#ifdef COAP_SUPPORT_SOCKET_BROADCAST
|
||||
#define _coap_is_bcast_impl(Address) (0)
|
||||
#endif
|
||||
#elif defined(RIOT_VERSION)
|
||||
|
||||
#else /* ! WITH_LWIP && ! WITH_CONTIKI */
|
||||
#include "net/sock.h"
|
||||
#include "net/af.h"
|
||||
|
||||
#ifndef INET6_ADDRSTRLEN
|
||||
#define INET6_ADDRSTRLEN IPV6_ADDR_MAX_STR_LEN
|
||||
#endif /* !INET6_ADDRSTRLEN */
|
||||
|
||||
struct coap_address_t {
|
||||
struct _sock_tl_ep riot;
|
||||
};
|
||||
|
||||
#define _coap_address_isany_impl(A) 0
|
||||
|
||||
#define _coap_address_equals_impl(A, B) \
|
||||
((A)->riot.family == (B)->riot.family && \
|
||||
(A)->riot.port == (B)->riot.port && \
|
||||
memcmp(&(A)->riot, &(B)->riot, (A)->riot.family == AF_INET6 ? \
|
||||
sizeof((A)->riot.addr.ipv6) : sizeof((A)->riot.addr.ipv4)) == 0)
|
||||
|
||||
#define _coap_is_mcast_impl(Address) ((Address)->riot.addr.ipv6[0] == 0xff)
|
||||
|
||||
/**
|
||||
* Returns the port from @p addr in host byte order.
|
||||
*/
|
||||
COAP_STATIC_INLINE uint16_t
|
||||
coap_address_get_port(const coap_address_t *addr) {
|
||||
return addr->riot.port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the port field of @p addr to @p port (in host byte order).
|
||||
*/
|
||||
COAP_STATIC_INLINE void
|
||||
coap_address_set_port(coap_address_t *addr, uint16_t port) {
|
||||
addr->riot.port = port;
|
||||
}
|
||||
|
||||
#else /* ! WITH_LWIP && ! WITH_CONTIKI && ! RIOT_VERSION */
|
||||
|
||||
#ifdef _WIN32
|
||||
#define sa_family_t short
|
||||
@@ -239,7 +270,7 @@ int coap_address_set_unix_domain(coap_address_t *addr,
|
||||
const uint8_t *host, size_t host_len);
|
||||
|
||||
/* Convenience function to copy IPv6 addresses without garbage. */
|
||||
#if defined(WITH_LWIP) || defined(WITH_CONTIKI)
|
||||
#if defined(WITH_LWIP) || defined(WITH_CONTIKI) || defined(RIOT_VERSION)
|
||||
COAP_STATIC_INLINE void
|
||||
coap_address_copy(coap_address_t *dst, const coap_address_t *src) {
|
||||
memcpy(dst, src, sizeof(coap_address_t));
|
||||
@@ -248,7 +279,7 @@ coap_address_copy(coap_address_t *dst, const coap_address_t *src) {
|
||||
void coap_address_copy(coap_address_t *dst, const coap_address_t *src);
|
||||
#endif /* ! WITH_LWIP && ! WITH_CONTIKI */
|
||||
|
||||
#if defined(WITH_LWIP) || defined(WITH_CONTIKI)
|
||||
#if defined(WITH_LWIP) || defined(WITH_CONTIKI) || defined(RIOT_VERSION)
|
||||
/**
|
||||
* Compares given address objects @p a and @p b. This function returns @c 1 if
|
||||
* addresses are equal, @c 0 otherwise. The parameters @p a and @p b must not be
|
||||
@@ -273,7 +304,7 @@ coap_address_isany(const coap_address_t *a) {
|
||||
return _coap_address_isany_impl(a);
|
||||
}
|
||||
|
||||
#if !defined(WITH_LWIP) && !defined(WITH_CONTIKI)
|
||||
#if !defined(WITH_LWIP) && !defined(WITH_CONTIKI) && !defined(RIOT_VERSION)
|
||||
|
||||
/**
|
||||
* Checks if given address @p a denotes a multicast address. This function
|
||||
@@ -293,7 +324,7 @@ int coap_is_bcast(const coap_address_t *a);
|
||||
*/
|
||||
int coap_is_af_unix(const coap_address_t *a);
|
||||
|
||||
#else /* WITH_LWIP || WITH_CONTIKI */
|
||||
#else /* WITH_LWIP || WITH_CONTIKI || RIOT_VERSION */
|
||||
|
||||
/**
|
||||
* Checks if given address @p a denotes a multicast address. This function
|
||||
@@ -314,13 +345,6 @@ coap_is_af_unix(const coap_address_t *a) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef COAP_SUPPORT_SOCKET_BROADCAST
|
||||
COAP_STATIC_INLINE int
|
||||
coap_is_bcast(const coap_address_t *a) {
|
||||
return a && _coap_is_bcast_impl(a);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WITH_LWIP || WITH_CONTIKI */
|
||||
#endif /* WITH_LWIP || WITH_CONTIKI || RIOT_VERSION */
|
||||
|
||||
#endif /* COAP_ADDRESS_H_ */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* coap_asn1_internal.h -- ASN.1 functions for libcoap
|
||||
*
|
||||
* Copyright (C) 2020-2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
* Copyright (C) 2020-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -86,6 +86,19 @@ coap_asn1_tag_t asn1_tag_c(const uint8_t **ptr, int *constructed, int *cls);
|
||||
coap_binary_t *get_asn1_tag(coap_asn1_tag_t ltag, const uint8_t *ptr,
|
||||
size_t tlen, asn1_validate validate);
|
||||
|
||||
/**
|
||||
* Abstract SPKI public key from the ASN1.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param data Pointer to ASN1 object containing EC Private Key
|
||||
* @param size Length of ASN1 object
|
||||
*
|
||||
* @return The publick key (to be freed off by caller)
|
||||
* or @c NULL if not found
|
||||
*/
|
||||
coap_binary_t *get_asn1_spki(const uint8_t *data, size_t size);
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* COAP_ASN1_INTERNAL_H_ */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* coap_async.h -- state management for asynchronous messages
|
||||
*
|
||||
* Copyright (C) 2010-2023 Olaf Bergmann <bergmann@tzi.org>
|
||||
* Copyright (C) 2010-2024 Olaf Bergmann <bergmann@tzi.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -29,12 +29,6 @@
|
||||
* cannot be delivered immediately.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns @c 1 if libcoap was built with separate messages enabled,
|
||||
* @c 0 otherwise.
|
||||
*/
|
||||
int coap_async_is_supported(void);
|
||||
|
||||
/**
|
||||
* Allocates a new coap_async_t object and fills its fields according to
|
||||
* the given @p request. This function returns a pointer to the registered
|
||||
@@ -53,9 +47,9 @@ int coap_async_is_supported(void);
|
||||
* @return A pointer to the registered coap_async_t object or @c
|
||||
* NULL in case of an error.
|
||||
*/
|
||||
coap_async_t *coap_register_async(coap_session_t *session,
|
||||
const coap_pdu_t *request,
|
||||
coap_tick_t delay);
|
||||
COAP_API coap_async_t *coap_register_async(coap_session_t *session,
|
||||
const coap_pdu_t *request,
|
||||
coap_tick_t delay);
|
||||
|
||||
/**
|
||||
* Update the delay timeout, so changing when the registered @p async triggers.
|
||||
@@ -67,7 +61,7 @@ coap_async_t *coap_register_async(coap_session_t *session,
|
||||
* @param delay The amount of time to delay before sending response, 0 means
|
||||
* wait forever.
|
||||
*/
|
||||
void coap_async_set_delay(coap_async_t *async, coap_tick_t delay);
|
||||
COAP_API void coap_async_set_delay(coap_async_t *async, coap_tick_t delay);
|
||||
|
||||
/**
|
||||
* Trigger the registered @p async.
|
||||
@@ -77,7 +71,7 @@ void coap_async_set_delay(coap_async_t *async, coap_tick_t delay);
|
||||
*
|
||||
* @param async The async object to trigger.
|
||||
*/
|
||||
void coap_async_trigger(coap_async_t *async);
|
||||
COAP_API void coap_async_trigger(coap_async_t *async);
|
||||
|
||||
/**
|
||||
* Releases the memory that was allocated by coap_register_async() for the
|
||||
@@ -86,7 +80,7 @@ void coap_async_trigger(coap_async_t *async);
|
||||
* @param session The session to use.
|
||||
* @param async The object to delete.
|
||||
*/
|
||||
void coap_free_async(coap_session_t *session, coap_async_t *async);
|
||||
COAP_API void coap_free_async(coap_session_t *session, coap_async_t *async);
|
||||
|
||||
/**
|
||||
* Retrieves the object identified by @p token from the list of asynchronous
|
||||
@@ -99,7 +93,7 @@ void coap_free_async(coap_session_t *session, coap_async_t *async);
|
||||
* @return A pointer to the object identified by @p token or @c NULL if
|
||||
* not found.
|
||||
*/
|
||||
coap_async_t *coap_find_async(coap_session_t *session, coap_bin_const_t token);
|
||||
COAP_API coap_async_t *coap_find_async(coap_session_t *session, coap_bin_const_t token);
|
||||
|
||||
/**
|
||||
* Set the application data pointer held in @p async. This overwrites any
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* coap_async_internal.h -- state management for asynchronous messages
|
||||
*
|
||||
* Copyright (C) 2010-2023 Olaf Bergmann <bergmann@tzi.org>
|
||||
* Copyright (C) 2010-2024 Olaf Bergmann <bergmann@tzi.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -41,6 +41,30 @@ struct coap_async_t {
|
||||
void *appdata; /**< User definable data pointer */
|
||||
};
|
||||
|
||||
/**
|
||||
* Allocates a new coap_async_t object and fills its fields according to
|
||||
* the given @p request. This function returns a pointer to the registered
|
||||
* coap_async_t object or @c NULL on error. Note that this function will
|
||||
* return @c NULL in case that an object with the same identifier is already
|
||||
* registered.
|
||||
*
|
||||
* When the delay expires, a copy of the @p request will get sent to the
|
||||
* appropriate request handler.
|
||||
*
|
||||
* Note: This function must be called in the locked state.
|
||||
*
|
||||
* @param session The session that is used for asynchronous transmissions.
|
||||
* @param request The request that is handled asynchronously.
|
||||
* @param delay The amount of time to delay before sending response, 0 means
|
||||
* wait forever.
|
||||
*
|
||||
* @return A pointer to the registered coap_async_t object or @c
|
||||
* NULL in case of an error.
|
||||
*/
|
||||
coap_async_t *coap_register_async_lkd(coap_session_t *session,
|
||||
const coap_pdu_t *request,
|
||||
coap_tick_t delay);
|
||||
|
||||
/**
|
||||
* Checks if there are any pending Async requests - if so, send them off.
|
||||
* Otherewise return the time remaining for the next Async to be triggered
|
||||
@@ -54,6 +78,58 @@ struct coap_async_t {
|
||||
*/
|
||||
coap_tick_t coap_check_async(coap_context_t *context, coap_tick_t now);
|
||||
|
||||
/**
|
||||
* Retrieves the object identified by @p token from the list of asynchronous
|
||||
* transactions that are registered with @p context. This function returns a
|
||||
* pointer to that object or @c NULL if not found.
|
||||
*
|
||||
* Note: This function must be called in the locked state.
|
||||
*
|
||||
* @param session The session that is used for asynchronous transmissions.
|
||||
* @param token The PDU's token of the object to retrieve.
|
||||
*
|
||||
* @return A pointer to the object identified by @p token or @c NULL if
|
||||
* not found.
|
||||
*/
|
||||
coap_async_t *coap_find_async_lkd(coap_session_t *session, coap_bin_const_t token);
|
||||
|
||||
/**
|
||||
* Trigger the registered @p async.
|
||||
*
|
||||
* A copy of the original request will get sent to the appropriate request
|
||||
* handler.
|
||||
*
|
||||
* Note: This function must be called in the locked state.
|
||||
*
|
||||
* @param async The async object to trigger.
|
||||
*/
|
||||
void coap_async_trigger_lkd(coap_async_t *async);
|
||||
|
||||
/**
|
||||
* Update the delay timeout, so changing when the registered @p async triggers.
|
||||
*
|
||||
* When the new delay expires, a copy of the original request will get sent to
|
||||
* the appropriate request handler.
|
||||
*
|
||||
* Note: This function must be called in the locked state.
|
||||
*
|
||||
* @param async The object to update.
|
||||
* @param delay The amount of time to delay before sending response, 0 means
|
||||
* wait forever.
|
||||
*/
|
||||
void coap_async_set_delay_lkd(coap_async_t *async, coap_tick_t delay);
|
||||
|
||||
/**
|
||||
* Releases the memory that was allocated by coap_register_async() for the
|
||||
* object @p async.
|
||||
*
|
||||
* Note: This function must be called in the locked state.
|
||||
*
|
||||
* @param session The session to use.
|
||||
* @param async The object to delete.
|
||||
*/
|
||||
void coap_free_async_lkd(coap_session_t *session, coap_async_t *async);
|
||||
|
||||
/**
|
||||
* Removes and frees off all of the async entries for the given context.
|
||||
*
|
||||
|
||||
+38
-40
@@ -2,7 +2,7 @@
|
||||
* coap_block.h -- block transfer
|
||||
*
|
||||
* Copyright (C) 2010-2012,2014-2015 Olaf Bergmann <bergmann@tzi.org>
|
||||
* Copyright (C) 2022-2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
* Copyright (C) 2022-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -62,14 +62,12 @@ typedef struct {
|
||||
#define COAP_BLOCK_SINGLE_BODY 0x02 /* Deliver the data as a single body */
|
||||
#define COAP_BLOCK_TRY_Q_BLOCK 0x04 /* Try Q-Block method */
|
||||
#define COAP_BLOCK_USE_M_Q_BLOCK 0x08 /* Use M bit when recovering Q-Block2 */
|
||||
#define COAP_BLOCK_NO_PREEMPTIVE_RTAG 0x10 /* Don't use pre-emptive Request-Tags */
|
||||
/* Note 0x40 and 0x80 are internally defined elsewhere */
|
||||
|
||||
/**
|
||||
* Returns @c 1 if libcoap was built with option Q-BlockX support,
|
||||
* @c 0 otherwise.
|
||||
*/
|
||||
int coap_q_block_is_supported(void);
|
||||
#define COAP_BLOCK_NO_PREEMPTIVE_RTAG 0x10 /* (cl) Don't use pre-emptive Request-Tags */
|
||||
#define COAP_BLOCK_STLESS_FETCH 0x20 /* (cl) Assume server supports stateless FETCH */
|
||||
#define COAP_BLOCK_STLESS_BLOCK2 0x40 /* (svr)Server is stateless for handling Block2 */
|
||||
#define COAP_BLOCK_NOT_RANDOM_BLOCK1 0x80 /* (svr)Disable server handling random order
|
||||
block1 */
|
||||
/* WARNING: Added defined values must not encroach into 0xff000000 which are defined elsewhere */
|
||||
|
||||
/**
|
||||
* Returns the value of the least significant byte of a Block option @p opt.
|
||||
@@ -331,12 +329,12 @@ typedef void (*coap_release_large_data_t)(coap_session_t *session,
|
||||
*
|
||||
* @return @c 1 if addition is successful, else @c 0.
|
||||
*/
|
||||
int coap_add_data_large_request(coap_session_t *session,
|
||||
coap_pdu_t *pdu,
|
||||
size_t length,
|
||||
const uint8_t *data,
|
||||
coap_release_large_data_t release_func,
|
||||
void *app_ptr);
|
||||
COAP_API int coap_add_data_large_request(coap_session_t *session,
|
||||
coap_pdu_t *pdu,
|
||||
size_t length,
|
||||
const uint8_t *data,
|
||||
coap_release_large_data_t release_func,
|
||||
void *app_ptr);
|
||||
|
||||
/**
|
||||
* Associates given data with the @p response pdu that is passed as fourth
|
||||
@@ -388,18 +386,18 @@ int coap_add_data_large_request(coap_session_t *session,
|
||||
*
|
||||
* @return @c 1 if addition is successful, else @c 0.
|
||||
*/
|
||||
int coap_add_data_large_response(coap_resource_t *resource,
|
||||
coap_session_t *session,
|
||||
const coap_pdu_t *request,
|
||||
coap_pdu_t *response,
|
||||
const coap_string_t *query,
|
||||
uint16_t media_type,
|
||||
int maxage,
|
||||
uint64_t etag,
|
||||
size_t length,
|
||||
const uint8_t *data,
|
||||
coap_release_large_data_t release_func,
|
||||
void *app_ptr);
|
||||
COAP_API int coap_add_data_large_response(coap_resource_t *resource,
|
||||
coap_session_t *session,
|
||||
const coap_pdu_t *request,
|
||||
coap_pdu_t *response,
|
||||
const coap_string_t *query,
|
||||
uint16_t media_type,
|
||||
int maxage,
|
||||
uint64_t etag,
|
||||
size_t length,
|
||||
const uint8_t *data,
|
||||
coap_release_large_data_t release_func,
|
||||
void *app_ptr);
|
||||
|
||||
/**
|
||||
* Set the context level CoAP block handling bits for handling RFC7959.
|
||||
@@ -419,24 +417,24 @@ int coap_add_data_large_response(coap_resource_t *resource,
|
||||
* @param context The coap_context_t object.
|
||||
* @param block_mode Zero or more COAP_BLOCK_ or'd options
|
||||
*/
|
||||
void coap_context_set_block_mode(coap_context_t *context,
|
||||
uint8_t block_mode);
|
||||
COAP_API void coap_context_set_block_mode(coap_context_t *context,
|
||||
uint32_t block_mode);
|
||||
|
||||
/**
|
||||
* Cancel an observe that is being tracked by the client large receive logic.
|
||||
* (coap_context_set_block_mode() has to be called)
|
||||
* This will trigger the sending of an observe cancel pdu to the server.
|
||||
* Set the context level maximum block size that the server supports when sending
|
||||
* or receiving packets with Block1 or Block2 options.
|
||||
* This maximum block size flows down to a session when a session is created.
|
||||
*
|
||||
* @param session The session that is being used for the observe.
|
||||
* @param token The original token used to initiate the observation.
|
||||
* @param message_type The COAP_MESSAGE_ type (NON or CON) to send the observe
|
||||
* cancel pdu as.
|
||||
* Note: This function must be called before the session is set up.
|
||||
*
|
||||
* @return @c 1 if observe cancel transmission initiation is successful,
|
||||
* else @c 0.
|
||||
* Note: COAP_BLOCK_USE_LIBCOAP must be set using coap_context_set_block_mode()
|
||||
* if libcoap is to do this work.
|
||||
*
|
||||
* @param context The coap_context_t object.
|
||||
* @param max_block_size The maximum block size a server supports. Can be 0
|
||||
* (reset), or must be 16, 32, 64, 128, 256, 512 or 1024.
|
||||
*/
|
||||
int coap_cancel_observe(coap_session_t *session, coap_binary_t *token,
|
||||
coap_pdu_type_t message_type);
|
||||
COAP_API int coap_context_set_max_block_size(coap_context_t *context, size_t max_block_size);
|
||||
|
||||
/**@}*/
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* coap_block_internal.h -- Structures, Enums & Functions that are not
|
||||
* exposed to application programming
|
||||
*
|
||||
* Copyright (C) 2010-2023 Olaf Bergmann <bergmann@tzi.org>
|
||||
* Copyright (C) 2021-2023 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
* Copyright (C) 2010-2024 Olaf Bergmann <bergmann@tzi.org>
|
||||
* Copyright (C) 2021-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
@@ -30,10 +30,37 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define STATE_TOKEN_BASE(t) ((t) & 0xffffffffffffULL)
|
||||
#define STATE_TOKEN_RETRY(t) ((uint64_t)(t) >> 48)
|
||||
#define STATE_TOKEN_FULL(t,r) (STATE_TOKEN_BASE(t) + ((uint64_t)(r) << 48))
|
||||
|
||||
#if COAP_Q_BLOCK_SUPPORT
|
||||
#define COAP_BLOCK_SET_MASK (COAP_BLOCK_USE_LIBCOAP | \
|
||||
COAP_BLOCK_SINGLE_BODY | \
|
||||
COAP_BLOCK_TRY_Q_BLOCK | \
|
||||
COAP_BLOCK_USE_M_Q_BLOCK | \
|
||||
COAP_BLOCK_NO_PREEMPTIVE_RTAG | \
|
||||
COAP_BLOCK_STLESS_FETCH | \
|
||||
COAP_BLOCK_STLESS_BLOCK2 | \
|
||||
COAP_BLOCK_NOT_RANDOM_BLOCK1)
|
||||
#else /* ! COAP_Q_BLOCK_SUPPORT */
|
||||
#define COAP_BLOCK_SET_MASK (COAP_BLOCK_USE_LIBCOAP | \
|
||||
COAP_BLOCK_SINGLE_BODY | \
|
||||
COAP_BLOCK_NO_PREEMPTIVE_RTAG | \
|
||||
COAP_BLOCK_STLESS_FETCH | \
|
||||
COAP_BLOCK_STLESS_BLOCK2 | \
|
||||
COAP_BLOCK_NOT_RANDOM_BLOCK1)
|
||||
#endif /* ! COAP_Q_BLOCK_SUPPORT */
|
||||
|
||||
#define COAP_BLOCK_MAX_SIZE_MASK 0x7000000 /* (svr)Mask to get the max supported block size */
|
||||
#define COAP_BLOCK_MAX_SIZE_SHIFT 24 /* (svr)Mask shift to get the max supported block size */
|
||||
#define COAP_BLOCK_MAX_SIZE_GET(a) (((a) & COAP_BLOCK_MAX_SIZE_MASK) >> COAP_BLOCK_MAX_SIZE_SHIFT)
|
||||
#define COAP_BLOCK_MAX_SIZE_SET(a) (((a) << COAP_BLOCK_MAX_SIZE_SHIFT) & COAP_BLOCK_MAX_SIZE_MASK)
|
||||
|
||||
#if COAP_Q_BLOCK_SUPPORT
|
||||
/* Internal use only and are dropped when setting block_mode */
|
||||
#define COAP_BLOCK_HAS_Q_BLOCK 0x40 /* Set when Q_BLOCK supported */
|
||||
#define COAP_BLOCK_PROBE_Q_BLOCK 0x80 /* Set when Q_BLOCK probing */
|
||||
#define COAP_BLOCK_HAS_Q_BLOCK 0x40000000 /* Set when Q_BLOCK supported */
|
||||
#define COAP_BLOCK_PROBE_Q_BLOCK 0x80000000 /* Set when Q_BLOCK probing */
|
||||
|
||||
#define set_block_mode_probe_q(block_mode) \
|
||||
do { \
|
||||
@@ -127,6 +154,7 @@ struct coap_lg_xmit_t {
|
||||
coap_l_block1_t b1;
|
||||
coap_l_block2_t b2;
|
||||
} b;
|
||||
coap_lg_crcv_t *lg_crcv; /**< The lg_crcv associated with this blocked xmit */
|
||||
coap_pdu_t pdu; /**< skeletal PDU */
|
||||
coap_tick_t last_payload; /**< Last time MAX_PAYLOAD was sent or 0 */
|
||||
coap_tick_t last_sent; /**< Last time any data sent */
|
||||
@@ -163,6 +191,8 @@ struct coap_lg_crcv_t {
|
||||
coap_bin_const_t **obs_token; /**< Tokens used in setting up Observe
|
||||
(to handle large FETCH) */
|
||||
size_t obs_token_cnt; /**< number of tokens used to set up Observe */
|
||||
uint16_t o_block_option; /**< Block CoAP option used when initiating Observe */
|
||||
uint8_t o_blk_size; /**< Block size used when initiating Observe */
|
||||
uint64_t state_token; /**< state token */
|
||||
coap_pdu_t pdu; /**< skeletal PDU */
|
||||
coap_rblock_t rec_blocks; /** < list of received blocks */
|
||||
@@ -179,6 +209,7 @@ struct coap_lg_srcv_t {
|
||||
uint8_t observe[3]; /**< Observe data (if set) (only 24 bits) */
|
||||
uint8_t observe_length;/**< Length of observe data */
|
||||
uint8_t observe_set; /**< Set if this is an observe receive PDU */
|
||||
uint8_t no_more_seen; /**< Set if block with more not set seen */
|
||||
uint8_t rtag_set; /**< Set if RTag is in receive PDU */
|
||||
uint8_t rtag_length; /**< RTag length */
|
||||
uint8_t rtag[8]; /**< RTag for block checking */
|
||||
@@ -187,13 +218,10 @@ struct coap_lg_srcv_t {
|
||||
uint8_t szx; /**< size of individual blocks */
|
||||
size_t total_len; /**< Length as indicated by SIZE1 option */
|
||||
coap_binary_t *body_data; /**< Used for re-assembling entire body */
|
||||
size_t amount_so_far; /**< Amount of data seen so far */
|
||||
coap_resource_t *resource; /**< associated resource */
|
||||
coap_str_const_t *uri_path; /** set to uri_path if unknown resource */
|
||||
coap_rblock_t rec_blocks; /** < list of received blocks */
|
||||
#if COAP_Q_BLOCK_SUPPORT
|
||||
coap_bin_const_t *last_token; /**< last used token */
|
||||
#endif /* COAP_Q_BLOCK_SUPPORT */
|
||||
coap_mid_t last_mid; /**< Last received mid for this set of packets */
|
||||
coap_tick_t last_used; /**< Last time data sent or 0 */
|
||||
uint16_t block_option; /**< Block option in use */
|
||||
@@ -282,6 +310,72 @@ coap_lg_xmit_t *coap_find_lg_xmit_response(const coap_session_t *session,
|
||||
const coap_pdu_t *request,
|
||||
const coap_resource_t *resource,
|
||||
const coap_string_t *query);
|
||||
|
||||
/**
|
||||
* Associates given data with the @p response pdu that is passed as fourth
|
||||
* parameter.
|
||||
*
|
||||
* This function will fail if data has already been added to the @p pdu.
|
||||
*
|
||||
* If all the data can be transmitted in a single PDU, this is functionally
|
||||
* the same as coap_add_data() except @p release_func (if not NULL) will get
|
||||
* invoked after data transmission. The Content-Format, Max-Age and ETag
|
||||
* options may be added in as appropriate.
|
||||
*
|
||||
* Used by a server request handler to create the response.
|
||||
*
|
||||
* If the data spans multiple PDUs, then the data will get transmitted using
|
||||
* (Q-)Block2 (response) option with the addition of the Size2 and ETag
|
||||
* options. The underlying library will handle the transmission of the
|
||||
* individual blocks. Once the body of data has been transmitted (or a
|
||||
* failure occurred), then @p release_func (if not NULL) will get called so the
|
||||
* application can de-allocate the @p data based on @p app_data. It is the
|
||||
* responsibility of the application not to change the contents of @p data
|
||||
* until the data transfer has completed.
|
||||
*
|
||||
* There is no need for the application to include the (Q-)Block2 option in the
|
||||
* @p pdu.
|
||||
*
|
||||
* coap_add_data_large_response_lkd() (or the alternative coap_add_data_large_*()
|
||||
* functions) must be called only once per PDU and must be the last PDU update
|
||||
* before returning from the request handler function.
|
||||
*
|
||||
* Note: COAP_BLOCK_USE_LIBCOAP must be set by coap_context_set_block_mode()
|
||||
* for libcoap to work correctly when using this function.
|
||||
*
|
||||
* Note: This function must be called in the locked state.
|
||||
*
|
||||
* @param resource The resource the data is associated with.
|
||||
* @param session The coap session.
|
||||
* @param request The requesting pdu.
|
||||
* @param response The response pdu.
|
||||
* @param query The query taken from the (original) requesting pdu.
|
||||
* @param media_type The content format of the data.
|
||||
* @param maxage The maxmimum life of the data. If @c -1, then there
|
||||
* is no maxage.
|
||||
* @param etag ETag to use if not 0.
|
||||
* @param length The total length of the data.
|
||||
* @param data The entire data block to transmit.
|
||||
* @param release_func The function to call to de-allocate @p data or NULL if
|
||||
* the function is not required.
|
||||
* @param app_ptr A Pointer that the application can provide for when
|
||||
* release_func() is called.
|
||||
*
|
||||
* @return @c 1 if addition is successful, else @c 0.
|
||||
*/
|
||||
int coap_add_data_large_response_lkd(coap_resource_t *resource,
|
||||
coap_session_t *session,
|
||||
const coap_pdu_t *request,
|
||||
coap_pdu_t *response,
|
||||
const coap_string_t *query,
|
||||
uint16_t media_type,
|
||||
int maxage,
|
||||
uint64_t etag,
|
||||
size_t length,
|
||||
const uint8_t *data,
|
||||
coap_release_large_data_t release_func,
|
||||
void *app_ptr);
|
||||
|
||||
#endif /* COAP_SERVER_SUPPORT */
|
||||
|
||||
#if COAP_CLIENT_SUPPORT
|
||||
@@ -316,7 +410,7 @@ int coap_block_drop_resp_q_block2_crcv(coap_session_t *session,
|
||||
|
||||
/**
|
||||
* The function checks that the code in a newly formed lg_xmit created by
|
||||
* coap_add_data_large_response() is updated.
|
||||
* coap_add_data_large_response_lkd() is updated.
|
||||
*
|
||||
* @param session The session.
|
||||
* @param request The request PDU to to check.
|
||||
@@ -330,7 +424,97 @@ void coap_check_code_lg_xmit(const coap_session_t *session,
|
||||
const coap_resource_t *resource,
|
||||
const coap_string_t *query);
|
||||
|
||||
/**
|
||||
* Set the context level CoAP block handling bits for handling RFC7959.
|
||||
* These bits flow down to a session when a session is created and if the peer
|
||||
* does not support something, an appropriate bit may get disabled in the
|
||||
* session block_mode.
|
||||
* The session block_mode then flows down into coap_crcv_t or coap_srcv_t where
|
||||
* again an appropriate bit may get disabled.
|
||||
*
|
||||
* Note: This function must be called before the session is set up.
|
||||
*
|
||||
* Note: COAP_BLOCK_USE_LIBCOAP must be set if libcoap is to do all the
|
||||
* block tracking and requesting, otherwise the application will have to do
|
||||
* all of this work (the default if coap_context_set_block_mode() is not
|
||||
* called).
|
||||
*
|
||||
* @param context The coap_context_t object.
|
||||
* @param block_mode Zero or more COAP_BLOCK_ or'd options
|
||||
*/
|
||||
void coap_context_set_block_mode_lkd(coap_context_t *context,
|
||||
uint32_t block_mode);
|
||||
|
||||
/**
|
||||
* Set the context level maximum block size that the server supports when sending
|
||||
* or receiving packets with Block1 or Block2 options.
|
||||
* This maximum block size flows down to a session when a session is created.
|
||||
*
|
||||
* Note: This function must be called before the session is set up.
|
||||
*
|
||||
* Note: This function must be called before the session is set up.
|
||||
*
|
||||
* Note: COAP_BLOCK_USE_LIBCOAP must be set using coap_context_set_block_mode()
|
||||
* if libcoap is to do this work.
|
||||
*
|
||||
* @param context The coap_context_t object.
|
||||
* @param max_block_size The maximum block size a server supports. Can be 0
|
||||
* (reset), or must be 16, 32, 64, 128, 256, 512 or 1024.
|
||||
*/
|
||||
int coap_context_set_max_block_size_lkd(coap_context_t *context, size_t max_block_size);
|
||||
|
||||
#if COAP_CLIENT_SUPPORT
|
||||
/**
|
||||
* Associates given data with the @p pdu that is passed as second parameter.
|
||||
*
|
||||
* This function will fail if data has already been added to the @p pdu.
|
||||
*
|
||||
* If all the data can be transmitted in a single PDU, this is functionally
|
||||
* the same as coap_add_data_lkd() except @p release_func (if not NULL) will get
|
||||
* invoked after data transmission.
|
||||
*
|
||||
* Used for a client request.
|
||||
*
|
||||
* If the data spans multiple PDUs, then the data will get transmitted using
|
||||
* (Q-)Block1 option with the addition of the Size1 and Request-Tag options.
|
||||
* The underlying library will handle the transmission of the individual blocks.
|
||||
* Once the body of data has been transmitted (or a failure occurred), then
|
||||
* @p release_func (if not NULL) will get called so the application can
|
||||
* de-allocate the @p data based on @p app_data. It is the responsibility of
|
||||
* the application not to change the contents of @p data until the data
|
||||
* transfer has completed.
|
||||
*
|
||||
* There is no need for the application to include the (Q-)Block1 option in the
|
||||
* @p pdu.
|
||||
*
|
||||
* coap_add_data_large_request_lkd() (or the alternative coap_add_data_large_*()
|
||||
* functions) must be called only once per PDU and must be the last PDU update
|
||||
* before the PDU is transmitted. The (potentially) initial data will get
|
||||
* transmitted when coap_send() is invoked.
|
||||
*
|
||||
* Note: COAP_BLOCK_USE_LIBCOAP must be set by coap_context_set_block_mode()
|
||||
* for libcoap to work correctly when using this function.
|
||||
*
|
||||
* Note: This function must be called in the locked state.
|
||||
*
|
||||
* @param session The session to associate the data with.
|
||||
* @param pdu The PDU to associate the data with.
|
||||
* @param length The length of data to transmit.
|
||||
* @param data The data to transmit.
|
||||
* @param release_func The function to call to de-allocate @p data or @c NULL
|
||||
* if the function is not required.
|
||||
* @param app_ptr A Pointer that the application can provide for when
|
||||
* release_func() is called.
|
||||
*
|
||||
* @return @c 1 if addition is successful, else @c 0.
|
||||
*/
|
||||
int coap_add_data_large_request_lkd(coap_session_t *session,
|
||||
coap_pdu_t *pdu,
|
||||
size_t length,
|
||||
const uint8_t *data,
|
||||
coap_release_large_data_t release_func,
|
||||
void *app_ptr);
|
||||
|
||||
/**
|
||||
* The function checks if the token needs to be updated before PDU is
|
||||
* presented to the application (only relevant to clients).
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user