In the same way that coap_split_uri() allows coaps:// scheme even if DTLS is
not available, it should allow coap+tcp:// and coaps+tcp:// scheme and let
other functions check whether TCP/TLS is available or not.
examples/client.c:
Verify if TCP is supported for scheme coap+tcp://.
src/coap_session.c:
Verify that the underlying CoAP transport protocol is supported in
coap_session_create_client().
Add verify for TCP protocol in coap_new_endpoint(), as well as always check
if TLS is supported.
src/uri.c:
Always allow coap+tcp:// and coaps+tcp:// in coap_split_uri() as a parsed
scheme in same way that coaps:// is always allowed.
Makefile.libcoap:
Include coap_tcp.c to include coap_tcp_is_supported() function.
examples/lwip/Makefile:
Include coap_tcp.o to include coap_tcp_is_supported() function.
Eliminate the matrix description which overides the jobs.
If both keywords are present, matrix takes precedence. This made
subsequent stages specified in the jobs section to be ignored.
Fixes#452
coap_read(), coap_write() and coap_run_once() are confusing in their names
and do not really describe what they do.
For example, coap_read() does both reading and writing, coap_write() may
do some writing, but primarily is used to determine what should be monitored
and for how long to wait in the following select() or epoll_wait() calls.
coap_run_once() implies that the code is only to be run once - again confusing.
By renaming coap_read() to coap_io_do_io(), this better describes what this
function does.
By renaming coap_write() to coap_io_prepare_io() this better describes what this
function does.
By renaming coap_run_once() to coap_io_process(), this better describes what
this function does.
By renaming coap_io_do_events() to coap_io_do_epoll(), this better describes what
this function does and is associated with.
A wrapper function coap_io_prepare_epoll() has been created, using
coap_io_prepare_io() with some preset values to simplify function usage.
include/coap2/net.h:
Update with the new function names, and deprecate the old functions. Also
document the fact that coap_io_prepare_io(), coap_io_do_io(),
coap_io_prepare_epoll(), and coap_io_do_epoll() are really internal functions.
Create app_io module for Doxygen.
libcoap-2.map:
libcoap-2.sym:
Expose the new functions to applications.
examples/client.c:
examples/coap-rd.c:
examples/coap-server.c:
examples/contiki/coap-observer.c:
examples/contiki/server.c:
examples/etsi_iot_01.c:
man/coap_io.txt.in:
man/coap_observe.txt.in:
src/coap_io.c:
src/coap_io_lwip.c:
src/net.c:
src/pdu.c:
Update using the new function names.
Setting the etimer has been moved out of coap_io_process() into
coap_io_do_epoll(), making the logic easier for applications to use
coap_io_do_epoll() should they need to. This also gets rid of a
potential timing window where a pending etimer event gets missed.
coap_io_do_epoll() now calls coap_io_prepare_epoll() if the etimer has
triggered removing the need for applications using coap_io_do_epoll() to
set up their own loops if etimer is triggered.
get_context() creates a new context object and adds coap_endpoint_t
objects for all listen addresses. The function now clears the
context object and returns NULL when no endpoint was created,
causing the server to exit immediately.
`coap-server(1)` segfaults when invoked as:
$ coap-server -A '2001:db8::1'
Feb 09 18:28:49 WARN coap_socket_bind_udp: bind: Address not available
Segmentation fault
In this case, the `ep->context->endpoint` is NULL but
`coap_free_endpoint` still attempts to access it. To prevent this
invocation from causing a segmentation fault, check if
`ep->context->endpoint` is NULL before accessing it.
Makefile.am:
include coap_tcp_internal.h in EXTRA_DIST
libcoap-2.map
libcoap-2.sym:
Don't expose previously static coap_socket_format_errno().
src/coap_gnutls.c:
src/coap_openssl.c:
src/coap_tinydtls.c:
Correct ENABLE_TCP (never defined) to !COAP_DISABLE_TCP.
Conditionally compile in TLS code as appropriate.
src/coap_io.c:
Correct #endif description.
src/coap_session.c:
Conditionally compile in TLS code as appropriate.
src/coap_tcp.c
Merge in appropriate parts of https://github.com/obgm/libcoap/pull/396 and
https://github.com/obgm/libcoap/pull/345 fixes.
include/coap2/coap_tcp.h:
include/coap2/coap_tcp_internal.h:
Rename include/coap2/coap_tcp.h to include/coap2/coap_tcp_internal.h and
remove reference to coap_tcp_is_supported().
include/coap2/coap.h.in:
Remove reference to coap_tcp.h.
coap_config.h.windows:
Include #define COAP_DISABLE_TCP 0.
include/coap2/coap.h.windows:
Reorder #includes
include/coap2/coap_internal.h:
Add #include coap_tcp_internal.h
include/coap2/coap_io.h:
Add in definition of coap_tcp_is_supported().
win32/libcoap.vcxproj:
win32/libcoap.vcxproj.filters:
Include src/coap_tcp.c and include/coap2/coap_tcp_internal.h.
The pre-processor flag COAP_DISABLE_TCP controls if TCP support is
compiled into the library. If set to 1, some bytes can be saved
by omitting TCP-specific code. By default, this flag is set to 0.
The new configure option '--disable-tcp' will set this flag to 1.
Add in -m option to enable using COAP_PKI_KEY_PEM_BUF instead of
COAP_PKI_KEY_PEM when defining certificates. This is done by reading in
the contents of the file into a temporary buffer and the buffer is
passed in instead of the filename to the PKI logic.
man/coap_attribute.txt.in:
man/coap_context.txt.in:
man/coap_encryption.txt.in:
man/coap_handler.txt.in:
man/coap_logging.txt.in:
man/coap_observe.txt.in:
man/coap_pdu_setup.txt.in:
man/coap_recovery.txt.in:
man/coap_resource.txt.in:
man/coap_session.txt.in:
man/coap_tls_library.txt.in:
Add in reference to MbedTLS where appropriate.
man/coap_encryption.txt.in:
Add in PKI Key type COAP_PKI_KEY_PEM_BUF for passing in PEM information
that is held in memory instead of in a file.
Existing COAP_PKI_KEY_PEM key type reads the PEM file from disk.
COAP_PKI_KEY_PEM_BUF key type has the same PEM content format, but provided
in a memory buffer. The buffer should be NULL terminated and the size of
the buffer passed in should include the NULL terminator.
src/coap_gnutls.c:
Add in support for COAP_PKI_KEY_PEM_BUF.
Make use of COAP_DTLS_RETRANSMIT_MS and COAP_DTLS_RETRANSMIT_TOTAL_MS rather
than hard coded numbers.
src/coap_openssl.c:
Add in support for COAP_PKI_KEY_PEM_BUF.
Add in MbedTLS library support as another alternative TLS library
Makefile.am:
Include new src/coap_mbedtls.c file.
configure.ac:
Add in --with-mbedtls support which generates HAVE_MBEDTLS in coap_config.h.
include/coap2/coap_dtls.h:
Add in TLS Library type COAP_TLS_LIBRARY_MBEDTLS and make COAP_TLS_LIBRARY_*
defines an enum.
Add in PKI Key type COAP_PKI_KEY_PEM_BUF for passing in PEM information
that is held in memory instead of in a file.
Add in #define COAP_DTLS_RETRANSMIT_MS, COAP_DTLS_RETRANSMIT_TOTAL_MS
and COAP_DTLS_RETRANSMIT_COAP_TICKS
src/coap_debug.c:
Output MbedTLS information if appropriate.
src/coap_mbedtls.c: (New)
Contains the MbedTLS interface code.
src/coap_notls.c:
Do not use code if MbedTLS is being built.
tests/test_tls.c:
Include MbedTLS library checks.
README.md:
Include MbedTLS as a valid (D)TLS library.
https://tools.ietf.org/html/rfc7641#section-4.5 requires that non-confirmable
observe responses should be sent as confirmable at least once every 24 hours.
However there is a requirement to override this periodical confirmable sending
behavior in lossy under DDoS attack type environments.
https://tools.ietf.org/html/draft-ietf-dots-signal-channel-41#section-4.4.2.1
Add in support for, and document, a new coap_resource_init() flag
COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS to handle this non RFC7641 requirement.
coap_dtls_get_timeout() may continue to return 'now' if the underlying
GnuTLS library gets confused by duplicate packets and so clears out
the data is to be retransmitted flag. If there is a DTLS timeout retry, the
underlying logic does not reset 'last retransmit' on retrying the re-send
of the (now) non-existent data, so causing a spin in the coap_write() logic.
src/coap_gnutls.c:
This fix is to return 'now+dtls_timout' on the second and subsequents attempts
to return 'now'.
include/coap2/coap_dtls.h:
Make use of the new #defines that #353 is using so that this code compiles.
PR #338 broke the PKI/PSK selection order for the encryption type
to use when trying to include the SNI even if PSK or PKI had not
been configured - even though coaps or coaps+tcp was in use. If
PSK had been defined, then it failed.
This fix puts the creation of the correct type of session into a separate function
which is then called from 2 places.
In ea72c3d7, the r->partiallydirty is set to 0 before the limitation.
A new request will be dropped when the last request hasn't received its
ACK.
The force clear operation of 'r->dirty' after 'LL_FOREACH' loop will
drop new request too.
resource.c:
In coap_notify_observers(), outstanding CON requests limitation, set
'r->partiallydirty' & 'obs->dirty' to 1 before 'continue'.
examples/client.c:
Update to send SNI if coaps, but certs/PSK not defined.
examples/coap-server.c:
Add in -S option to support changing certificate/ca if there is as SNI match.
man/coap-server.txt.in:
Update man page with new -S option.
doc/main.md:
Correct copyright date
man/Makefile.am:
Update A2X_EXTRA_PAGES to include man pages that have digits in the name
man/coap_context.txt.in:
man/coap_encryption.txt.in:
man/coap_handler.txt.in:
man/coap_logging.txt.in:
man/coap_observe.txt.in:
man/coap_pdu_setup.txt.in:
man/coap_resource.txt.in:
man/coap_session.txt.in:
Update with _psk2() information.
Update examples to remove compiler warnings
man/coap-client.txt.in:
man/coap-rd.txt.in:
man/coap-server.txt.in:
Add in documentation on additional support for using / testing out the new
_psk2() functionality