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
Move the MinGW #if tests to after where mswsock.h is included.
Tidy up documentation.
Tested against MSYS2 UCRT64, CLANG64, MINGW32 and MINGW64 on Windows 11.
Fixed a couple of minor build issues found.
In particular for TCP support.
Also added in retrying to get the lwip git 3 times for the CI tests as the
lwip host server is currently not that reliable, returning 502 gateway errors.
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.
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().
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.
For embedded applications that can call the 'main()' function multiple
times, they need to have any statically (globally) defined variables
reset to their default values.
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.
Tidy up naming to reduce confusion between supported proxy types.
Provides simpler proxy examples.
Fixes issue with COAP_PROXY_REVERSE_STRIP.
Support upstream server using AF_UNIX.
If the ACK (not empty) response gets lost, the repeated CON request will just
get the cached response without invoking further analysis.
This stops things like OSCORE reporting retry issues.
This functionality needs to be enabled by setting the COAP_BLOCK_CACHE_RESPONSE
bit when calling coap_context_set_block_mode(). If not enabled, then, for OSCORE
the response is sent as a separate response (empty ACK followed by CON response),
which is how code previous to this PR works.
If coap_context_set_keepalive() is set in the server, CoAP keepalive packets
will get sent for any CoAP session that is curently observing a resource.
If the keepalive times out, then the observation(s) are canceled and the
server session is deleted.
If an Observe is de-registered, but an unsolicited Observe response is received
before the de-register response is received, then the unsolicited response
failed to get decrypted.
New examples/zephyr directory that contains a sample coap-client.
Building the coap-client assumes that the zephyrproject has already been
installed and set up (default directory ~/zephyrproject).
Update stateless token to track 20 bits - the largest no of blocks
as per RFC7959.
Make output of data detail configurable for coap_show_pdu().
Add in new function coap_enable_pdu_data_output() to do this.
Add -x option to coap-client and coap-server to enable this dropping
of data detail.
./autogen.sh and ./configure no longer need to be run prior to running
make for Contiki, LwIP or RIOT from the appropriate examples sub-directory.
scripts/fix_version.sh now handles updating coap.h for the different
LIBCOAP_ and PACKAGE_ definitions.
Tidy up the general proxy logic by moving common functionality
into libcoap.
New functions coap_proxy_forward_request(), coap_proxy_forward_response()
and coap_proxy_is_supported() added.
New --enable-proxy-code support added to configure.
New ENABLE_PROXY_CODE support added to CMakeLists.txt.
Support for common shared connection to next hop.
Support for round-robin balancing across multiple next hops.
Only support changing the client's source port if the DTLS library
has support / configured for CID.
Used when debugging server handling source address changes and CID
is in use.
Add in support for TinyDTLS (Client only) if TinyDTLS is patched
appropriately (not currently available on TinyDTLS main branch).
Add in new function coap_dtls_cid_is_supported().
'make distclean' removes header files built from the .in files, which
means that they are not available for different OS builds.
The same is true for CMakeLists.txt.
Remove the need for the .in files and update for libcoap revisions
by using a new script scripts/fix_version.sh created from
scripts/fix_version.sh.in.
CI has been updated to check revisions have been updated in the
appropriate places.
Do not remove libcoap-3.sym and libcoap-3.map when doing 'make distclean'
as they are git tracked files.