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.
Makes reading the code simpler.
Context is no longer used as global_lock is used in the coap_lock_lock() and
coap_lock_unlock() functions.
Part 3 of 3.
Update coap_lock_lock() and coap_lock_unlock() macros and all users.
Makes reading the code simpler.
Context is no longer used as global_lock is used in the coap_lock_lock() and
coap_lock_unlock() functions.
Part 2 of 3.
Update coap_lock_check_locked() and all users.
Makes reading the code simpler.
Context is no longer used as global_lock is used in the coap_lock_lock() and
coap_lock_unlock() functions.
Part 1 of 3.
Update coap_lock_callback(), coap_lock_callback_ret(),
coap_lock_callback_release(), coap_lock_callback_ret_release() and
coap_lock_invert() macros and all users.
If multiple clients subscribe to the same resource, one of the clients
'goes away', the server will eventually close down the session for that client
which will then remove any subscriptions, iterating through the different
resources.
If this happens at the same time that coap_resource_notify_observers() is called
in another thread, and the GET/FETCH handler is called for a common resource
and in particular for the session that is now going away, on return from the
callback the subscription may no longer exist. This PR fixes this window.
In addition, if the resource subscriber list is being traversed, then a another
call to coap_notify_observers() for the same resource will not generate a new set
unsolicited observe responses for multi-thread protection.
Update
Malformed PDUs were responsed to with a RST. Now request PDUs with invalid
lengths are also reported with a 4.02 response.
See RFC7252 5.4.3 and 5.4.1.
The checking can be overriden by using coap_register_option().
Updated the diagnostic payload for 4.02 responses to be inline with RFC 7252,
and not include the actual errant options in the response.
Add in limited caching for multiple clients requesting an Observe subscription
for the same upstream session resource so that only a single observation request
is sent upstream and any unsolicited response is sent back to all the
requesting clients.
This requires a change in the recently added handler registered to
coap_register_proxy_response_handler(), which no longer should no longer call
coap_proxy_forward_response(), but just return a PDU for forwarding on.
When initating a multicast request, multiple unicast responses can occur.
If the unicast response subsequently generates further traffic (in other words
a BLOCK1 or BLOCK2 transfer) to complete the request/response sequence, each
unicast transfer can behave differently.
Set up different coap_lg_crcv_t for each unicast response for the session.
Set up different coap_lg_xmit_t for each unicast request if doing large transmits.
Reference initial transmitted request PDU rather than maintaining copies of the
PDU in coap_lg_crcv_t or coap_lg_xmit_t.
If calculated timeout is 0 in coap_io_prepare_io_lkd(), then do not set overall
timeout to 0 so that when passed back to caller it does not get reset to the
caller's max defined timeout.
Updated some timeout check functions to update remaining timeout in a new
parameter and to return 1 if this parameter was updated, else 0. for simplicity.
It was also unsafe to set the initial max timeout value to -1 as coap_tick_t
can be int64_t.
const coap_pdu_t * parameters are passed into application (call-back handler)
code. If the application code then calls a libcoap API with a
const coap_pdu_t * parameter, it is not possible to increment the reference
counter so that multiple entities can reference the same PDU and an entity's
call to coap_delete_pdu() does not prematurely remove the PDU until all the
entities have finished.
This code allows the (const) PDU's reference counter to be incremented.
Allow re-establishment with upstream server when server restarts.
When upstream server re-connects, re-establish any (D)TLS sessions
and active observe subscriptions.
Supported by a new function coap_context_set_session_reconnect_time().
When a server cleanly closes down (calls coap_free_context()), when
a resource gets deleted, a 4.04 message is sent out (not when using
coap_persist(3)) for any active observe subscriptions. If a server knows it is
going to be restarted, then there is no need to send out a observe failed message.
When deleting a resource when normally running, it is correct to send out a 4.04
Not Found response as the resource has genuinely gone away. However, when the
server is cleaning shutting down, it is better to use 5.03 Service Unavailable to
indicate the situation may be temporary.
Add a common cleanup function to make sure all information is correctly
freed off.
Make sure that there is client session stickability to use the same proxy entry
when making new requests.
Load in the PKI trust store with a new function
coap_context_load_pki_trust_store()
By default, make the client and server applications do this unless
explicitely disabled.
This enables clients doing (D)TLS to not need to be provided with specific
certificates but can validate trust in the server provided certificates.
Note: A default trust store is not supported across all platform types or
some TLS libraries (version dependent).
Set up a coap_io_process() loop spread across multiple threads, each thread
repeatably calling coap_io_process() and so able to handle any input packets.
Note that the application handlers need to be thread-safe for application
level activity.
Add 2 new main functions
coap_io_process_loop()
coap_io_process_terminate_loop()
Add in 2 new sub functions
coap_io_process_configure_threads()
coap_io_process_remove_threads()
to set up the parallel threads.
Update example servers to include using coap_io_process_loop().
Support optional thread number logging by configuration to maintain
backwards logging format output if required.
New functions
coap_async_set_app_data2()
coap_cache_set_app_data2()
coap_context_set_app_data2()
coap_session_set_app_data2()
that, multi-thread safe, store an application data pointer and return the
previous data pointer (if any). There is an optional callback that will
be called when the respective storage object is released that can free
off as appropriate the data that was stored.
These replace the existing coap_*_set_app_data() functions and
coap_*_get_app_data() can be used to get the stored data pointer.