If an app request call-back modifies any data associated with a resource,
then multiple threads can attempt to unsafely modify the data at the same time.
Lock the resource when calling the app request handler (as global_lock is
unlocked) to prevent concurrent changes to the resource information.
If the app request handler is definately known to not modify the resource
information, then COAP_RESOURCE_SAFE_REQUEST_HANDLER can be set in the flags
for coap_resource_init(). Usually if there is a PUT, POST, PATCH or IPATCH
handler it is unsafe to set this. Setting this will reduce lock contention.
This is similar to coap_debug_set_packet_loss() which drops packets that are
to be sent, but emulates network reported errors by reporting ECONNREFUSED.
Analyzer run time does not like A -= B or A +=B even if A and B are uint32_t as there is potential
for overflow.
Analyzer run time does not like overflow when doing coap_tick_t - coap_tick_t.
Analyzer run time does not like (uint8_t << 24) as uint8_t is promoted as int, not u_int.
Analyzer run time does not like while(A--) {} even if A is uint32_t, as A is always decremented on
the test, even if the value of A is 0.
Fix potential overflow when analyzing an asn.1 tag.
Fix potential overflow when doing decode_segment() on a % hex value.
Include common system header files in coap_internal.h based on HAVE_*H
definitions.
Remove these system header files from include/*/*.h.
Add in system header files where appropriate in various apps.
Function coap_context_set_max_body_size() added.
For servers, if body size is too large, a 4.13 response is generated.
For clients, if the body size is too large, the server gets a RST and
no date is passed to the application. A new event COAP_EVENT_BLOCK_ISSUE
is generated.
Add in new functions
coap_new_client_session3()
coap_new_client_session_pki3()
coap_new_client_session_psk3()
coap_new_client_session_oscore3()
coap_new_client_session_oscore_pki3()
coap_new_client_session_oscore_psk3()
which effectively does coap_session_set_app_data2() and
coap_ws_set_host_request() early on in the session set up cycle.
Make sure all application callbacks are called with a coap_lock_callback*()
wrapper.
Rename callback variables within the internal structures with a _cb suffix for
ease of review.
The first coap_send(pdu) is held back until after the optional tests for
Extended Token or Q-Block support are complete with the return from coap_send()
containing the held back pdu's mid.
If there are any errors with this PDU when subsequentially sent, the
event COAP_EVENT_FIRST_PDU_FAIL gets raised.
Add in new function coap_add_data_large_request_app() that provides a call-back
to get individual blocks rather than having a large buffer held in
(contrained) memory.
If we correctly determine the presence of the sys/time.h and time.h
files using the HAVE_TIME_H and HAVE_SYS_TIME_H macros, then the LWIP
compilation will result in a duplicate function error. Perhaps previous
versions of LWIP did not have these files, in which case everything
would have worked correctly.
These changes add the necessary ifdefs and keep the optimal timer
function for LWIP.
Adds missed #include <time.h> lines to examples and documentation.
Adds the detection of the sys/select.h header to the CMake and autoconf.
For the libcoap COAP_ compile time options configured in coap_defines.h or
coap_config.h make sure that #ifdef, #ifndef or defined() are not used and
replaced with #if as appropriate so that if the COAP_ compile time option
is defined as 0, the correct code gets built.
Add #if wrappers to source files that are platform specific or OSCORE.
Some of the Zephyr include files need to be C++, not C based. The 'extern "C"'
wrapper in include/coap3/coap.h means that all #include are treated as being C.
Remove 'extern "C"' wrapper from include/coap3/coap.h and add wrapper to
include files after #include and before any function / structure definitions.
Add in a C++ build test for CI.
Let libcoap do the necessary multi-thread locking during resource
generation, lookup and deletion.
Supported using a new handler set up by coap_register_dynamic_resource_handler().
Server to Client is already supported, this provides the reverse with
coap_session_set_type_server().
Add in call-home support to coap-client and coap-server for testing.
Addition of a new event COAP_EVENT_SERVER_SESSION_CONNECTED.
Changes:
- Remove duplicate OBSERVE_PERSIST configuration block
Improve example build:
- Make virtual environment activation optional in Makefile
- Remove --fresh flag unsupported in newer west versions
- Copy mbedTLS config header to workspace include directory
- Add TARGET check for mbedTLS before configuring include directories
- Add mbedTLS linking to coap-3 target
Add POSIX API support:
- Enable CONFIG_POSIX_API=y in examples/zephyr
- Replace direct Linux/Windows system calls with Zephyr POSIX API
equivalents
- Add Zephyr's sys_rand_get() to coap_prng_default()
- Define missing network macros (IN_MULTICAST, IN6_IS_ADDR_MULTICAST,
etc.)
- Add FIONBIO and OPTVAL_T/OPTVAL_GT macro definitions for Zephyr
- Add native Zephyr timing functions to replace missing mbedTLS timing
support
- Fix fd_set mapping using zephyr/net/socket_select.h
- Exclude strnlen redefinition conflicts for Zephyr
- Add proper IPv6 packet info and address mapped definitions
(Patch) Add DNS resolution and net setup to example client:
- Enable CONFIG_DNS_RESOLVER for hostname resolution
- Add Linux networking setup instructions for native_sim board
- Configure static IP gateway and DNS server (8.8.8.8)
- Add DHCP vs static IP configuration documentation
Co-authored-by: mrdeep1
Multiple threads can call coap_check_async() when one of them does a callback
into application space. Only allow one thread to be scanning async_state.