include/coap2/net.h:
src/net.c:
Update code using #587 as a base to fix potential issues.
Fixes CID 1502429
CMakeLists.txt:
cmake_coap_config.h.in:
Test for <net/if.h>
examples/coap-rd.c:
examples/coap-server.c:
man/coap-rd.txt.in:
man/coap-server.txt.in:
Add in -G option to support specifying interface to use for multicasting.
Otherwise, the interface allocated by the O/S is used depending on the
address (if any) bound to.
man/Makefile.am:
man/coap_context.txt.in:
Document the coap_join_mcast_group_intf() function.
src/coap_debug.c:
Make sure that coap_print_addr() returns a NULL terminated buffer.
This change renames `coap_join_mcast_group` to `coap_join_mcast_group_intf`
and adds an extra `const char *ifname` parameter to specify the interface
name.
A `coap_join_mcast_group` macro is defined to maintain backwards API
compatibility.
`coap_is_mcast` has been modified to recognize IPv6-mapped IPv4 multicast
addresses. Without this `coap_network_send` treats these addresses as
unicast which makes `semdmsg` fail with EINVAL.
Examples have been updated to use the new call.
Fixes
CID 1502435:
CID 1502432:
CID 1502423:
False Positives
CID 1502434: Cant see why code is not reached
CID 1502433: Could make blk_size uint8_t:3 I guess.
CID 1502430: Dont know why it is complaining
CID 1502427:
CID 1502426: Code looks fine to me - context->session could be set.
CID 1502424:
Fixed by other PRs
CID 1502422: #610
CID 1502431: #610
CID 1502428: #610
CID 1502429: #587 with my additional fixes
src/coap_tinydtls.c:
Replace UNUSED with COAP_UNUSED that got missed from a merge.
man/examples-code-check.c:
src/pdu.c:
tests/oss-fuzz/pdu_parse_target.c:
Fix trailing white space.
win32/libcoap.vcxproj:
win32/testdriver/testdriver.vcxproj:
Correct include/coap2 paths.
If the response code was set after calling coap_add_data_large_response(),
the continuing blocks were sent with code 0.00.
Now check following call to response handler that the correct code is held
within the lg_xmit information.
Remove the UNUSED and UNUSED_PARAM definitions and use a single definition
of COAP_UNUSED as defined in libcoap.h
Replace all UNUSED / UNUSED_PARAM usages with COAP_UNUSED.
Correctly track the tokens so that the token that application sees in the
response is the same token as used in the initial request.
Update coap-server so that response data can be sent back to echo the data
that was in the request.
Fixes
CID 1502431
CID 1502428
CID 1502422
Change some of the types of variables, and cast change sizes where known to
be safe.
There still are some C4116 warning and a couple of C4090 warning which are OK,
so disabled by a #pragma.
.github/workflows/main.yml:
Build all the cmake TLS variants.
CMakeLists.txt:
Add in missing file.
examples/tiny.c:
include/coap2/encode.h:
Move COAP_PSEUDOFP_ENCODE_8_4 functions from encode.h to tiny.c.
Fix COAP_PSEUDOFP_ENCODE_8_4_DOWN 'ls' ordering complaint.
man/examples-code-check.c:
Fix compile warning, allow 'Unused but set variables' in examples and set
-Werror when compling the examples.
examples/lwip/Makefile:
Remove compilation option -fpack-struct
Merging #552 and #554 into develop caused Observe CON 2.05 initial block
response not to get an ACK from the client and so the Observe response kept
getting re-transmitted and caused other CON traffic to get queued up.
Troubleshooting highlighted an issue when a PUT/POST was updating the contents
of a resource and an Observe was active sending many payloads in a body.
src/net.c:
Make sure that an ACK is sent (if appropriate) when working with a block based
response.
examples/coap-server.c:
Give dynamic data associated with a resource a reference count, and only free
off the data when the reference count has dropped to 0.
The ACK 0.00 is being returned by the server for reliable conections and the
client is then reporting that CON 0.00 is invalid (CON, NON, ACK and RST are
all resported as CON in a received reliable PDU).
coap-client coap+tcp://127.0.0.1/async?1 -v9
demonstrates the issue.
src/net.c:
Update no_response() to return RESPONSE_DROP for both reliable and
non-confirmable if the application handler returns with the response code set
to 0.00 in the PDU. This then generally simplifies the code around when
calling no_response().
Check for valid multicast responses.
If the response is confirmable and piggybacked and being dropped, convert the
response to an empty ACK so the client does not continue to retry sending the
request.
Update coap_opt_filter_t to be a structure rather than a 16bit array that is
aliased with the real structure format.
Update code to use pointers where appropriate.
Refactor coap_pdu_parse_opt() to additionally output the block options in
hex for debugging if there is an error.
Fix the two tests that are now reported with the updated code.
[Other PDU test are reporting information, but only at LOG_DEBUG which is
not output]
Result of a rebase confusion.
include/coap2/resource.h:
Remove duplicates that are also in coap_subscriber_internal.h.
libcoap-2.map:
libcoap-2.sym:
Remove the now internal only functions.
If cert_chain_verify_depth is 0 and cert_chain_validation is set in
coap_dtls_pki_t, then a Cert + its signing CA should be valid (no intermediary
CAs).
src/coap_gnutls.c:
src/coap_mbedtls.c:
src/coap_openssl.c:
Correct set and check cert_chain_verify_depth.
src/coap_openssl.c:
Fix building on openssl-1.1.0
.github/workflows/main.yml:
Do a 'make check' for matrix builds.
Move documentation into separate job to reduce matrix build times
Add in CMake job.
Add in distribution job.
Add in tinydtls job.
Add in contiki/lwip job.
scripts/github_dist.sh:
Do the distribution checks using a script.
examples/etsi_iot_01.c:
examples/tiny.c:
Fix include coap.h directory in old examples.
README.md:
Update status badges to get only the branch actions and remove CMake
status badge.
Create a new include/coap2/coap_resource_internal.h to hold all the information
not available to applications.
Makefile.am:
Include coap_resource_internal.h in EXTRA_DIST.
Remove functions no longer visible from CTAGS_IGNORE.
examples/coap-rd.c:
examples/contiki/server.c:
examples/etsi_iot_01.c:
tests/test_wellknown.c
Replace direct access to coap_resource_t variables with functions as
appropriate.
include/coap2/resource.h:
include/coap2/subscribe.h:
include/coap2/coap_resource_internal.h: (New)
include/coap2/coap_subscribe_internal.h:
Move coap_resource_t, coap_addr_t, non API #defines and non API functions from
resource.h into coap_resource_internal.h, coap_subscribe_internal.h and
subscribe.h.
Replace inline functions accessing coap_resource_t with actual function
definitions.
Add new functions coap_resource_release_userdata_handler() and
coap_attr_get_value().
include/coap2/block.h:
Use coap_resource_t typedef.
include/coap2/coap_forward_decls.h:
Include coap_resource_t and coap_addr_t typedefs. Also typedef coap_context_t
to get rid of #include circular requirements.
include/coap2/coap_internal.h:
win32/libcoap.vcxproj:
win32/libcoap.vcxproj.filters:
Include coap_resource_internal.h.
include/coap2/net.h:
Remove "typedef struct coap_context_t" and do this in coap_forward_decls.h.
src/resource.c:
Update with the replaced inline functions. Add in the new functions
coap_resource_release_userdata_handler() and coap_attr_get_value().
libcoap-2.map:
libcoap-2.sym:
Update with new function visibility.
man/Makefile.am:
man/coap_attribute.txt.in:
man/coap_observe.txt.in:
man/coap_resource.txt.in:
Update with the new coap_resource_t and coap_attr_t usage.
In handle_response() the ACK is sent before calling ctx->response_handler() so
if the response_handler() wants to send RST the server ignores it as the ACK
has already been received.
By updating coap_response_handler_t to return a value, this can be used to
send the ACK (return of COAP_RESPONSE_OK) or a RST (return of COAP_RESPONSE_FAIL)
after ctx->response_handler() is called.
include/coap2/net.h:
man/coap_handler.txt.in:
Create a new enum coap_response_t for use as the return value for
coap_response_handler_t.
Update coap_response_handler_t and associated documentation.
src/net.c:
Send CoAP ACK or RST depending on return value of ctx->response_handler().
examples/client.c:
Update message_handler() to use the new coap_response_handler_t return values
(coap_response_t).