Issue reproducable with (coap-server also running)
coap-client -b32 coap+tcp://[::1]
and note the partial response.
examples/client.c:
Set doing_getting_block if processing Block2 responses.
Add in a doing_getting_block test to not break out of the main while(){} loop.
[coap_can_exit() always returns 1 for TCP connections as there is nothing on
the session->delayqueue]
Platforms that do not have getaddrinfo() most likely do not have
the netdb.h include file as well.
This change includes netdb.h only if HAVE_NETDB_H is defined
(usually by configure).
The libcoap repository contains hand-crafted configuration files
for various platform such as Windows, Contiki, and LwIP. These
are now excluded from .gitignore to be able to track changes.
On RIOT, inet_ntop() expects the size parameter to reflect the
length of the given address. A larger value causes inet_ntop()
to return ENOSPC.
This change passes the address size as a workaround, or the actual
number of remaining bytes in the output buffer in case less than
address size bytes remain.
Adding in new structures to .h files that are typedef'd to not include
"struct" which are then referenced by other .h files can easily set up
recursive requirements that cannot be fulfilled.
In particular, adding in a new typedef'd struct to coap_dtls.h cannot
easily be used by coap_session.h
include/coap2/coap_dtls.h:
In coap_dtls.h, forward reference the (outside of the file) structures
and then prefix the coap_*_t entries with "struct", so making the
entries "struct coap_*_t" entries as appropriate
As coap-server now sets up 2 (or 4) endpoints, UDP and TCP based, all
subsequent endpoints are pre-pended to the ctx->endpoint list. Thus
ctx->endpoint will always be TCP based. Setting IPV6_JOIN_GROUP on a TCP
socket is a no-no.
As join() is complex function, it should be within libcoap so as to not require
detailed knowledge of how internal structures work (which really should be
opaque to the application writer).
include/coap2/net.h:
src/net.c:
libcoap-2.map:
libcoap-2.sym:
Create coap_join_mcast_group() in src/net.c (as it is a network layer
function using the (fixed) join() code. (Iterate through the ctx->endpoint list
looking for UDP based endpoints and only do the IPV6_JOIN_GROUP on them.)
There is no support for WITH_CONTIKI or WITH_LWIP at this point (returns -1).
examples/coap-server.c:
Remove join() code and replace call to join() with coap_join_mcast_group()
examples/coap-rd.c:
Remove join() code and replace call to join() with coap_join_mcast_group()
man/coap-rd.txt.in:
Correct a typo in the coap-ed man page
When there is a limited stack size, having large data items on the stack
can easily cause stack overflows.
This makes integration with any constrained stack O/S a lot easier.
include/coap2/coap_mutex.h:
Create coap_ mutex functions which are platform independent to protect
the (now) static variables if compiled with "-DCOAP_CONSTRAINED_STACK=1"
Makefile.am:
Include include/coap2/coap_mutex.h for distribution
coap_config.h.contiki:
coap_config.h.lwip:
As CONTIKI and LWIP have constrained stacks, set
"#define COAP_CONSTRAINED_STACK 1"
src/coap_debug.c:
src/coap_io.c:
src/net.c:
coap_show_pdu()
coap_log_impl()
coap_run_once()
coap_read_session()
coap_read_endpoint()
Move large data items out of the functions' stack and make them static
variables (defined within the function) if COAP_CONSTRAINED_STACK is defined.
Protect the usage of these static variables by mutexes.
Note: if "-DCOAP_CONSTRAINED_STACK=0" is used, then the stack will not
be constrained.
Following on from #324 where coap_session_mfree() had to be moved in
coap_session_free() to correctly allow for tinydtls cleanup, session->endpoint
and session->context should not be cleared out prior to call of
coap_sesson_free() in coap_free_endpoint().
src/coap_session.c:
Remove lines setting session->endpoint and session->context to NULL
The tinyDTLS source repository now lives at GitHub [1]. This
change updates the submodule URI and includes the latest commits
from the development branch.
[1] https://github.com/eclipse/tinydtls
While #321 prevented a core dump, that fix still caused memory corruption.
src/coap_gnutls.c:
Correct the code to correctly NULL terminate the created username.
As a server, idle sessions are left around in case the client wants to do
further work using the same 5 tuple IP information.
With constrained systems, the number of sessions is limited, and so it is
easy to run out of sessions.
src/coap_session.c:
If there is an idle session, context->max_idle_sessions is not set and
a new session cannot be created, free off the oldest session and retry
the creation again.
examples/contiki/README:
examples/lwip/README:
Tidy up the documentation
In coap_session_free(), as coap_session_mfree() is called after
the session has been deleted out the endpoint or context sessions,
dtls_send_to_peer() is unable to find the session to send out the
Alert/Warning Close Notify message packet.
src/coap_session.c:
Move coap_session_mfree() to before setting deleting session out of endpoint or context sessions in coap_session_free().
Note: TinyDTLS has been separately updated to not report ALRT on a
Close Notify - see https://github.com/eclipse/tinydtls/pull/5.
Currently the following complaint is in the build logs
man/Makefile.am:56: warning: ':='-style assignments are not portable
man/Makefile.am:56: warning: shell for fil in $(TXT3: non-POSIX variable name
man/Makefile.am:56: (probably a GNU make extension)
Correct issue by using
configure.ac:
AC_SUBST([DOLLAR_SIGN],[$])
man/Makefile.am:
to substiture for $ as in $(shell ...
and replace := with =
When building tinydtls version, Travis fails with the following error
tests/testdriver: error while loading shared libraries: libtinydtls.so:
cannot open shared object file: No such file or directory
The new version of TinyDTLS now builds a libtinydtls.so file which is
linked against in preference to libtinydtls.a when using -ltinydtls,
but Travis does not have an installed version libtinydtls.so to load
during execution of tests/testbriver - hence failure.
scripts/build.sh:
Add in LD_LIBRARY_PATH=ext/tinydtls if building tinydtls.
BUILDING:
configure.ac:
With libtinydtls.so being available, there is no need to enforce
--disable-shared for tinydtls. Remove this requirement.
If --disable-shared is set, link in with libtinydtls.a.
When compiling libcoap with format truncation warnings enabled,
GCC warns about the potential issue with "%u.%02u" format string,
since the first argument may produce more than one byte of output:
error: '%02u' directive output may be truncated writing 2 bytes
into a region of size between 0 and 3 [-Werror=format-truncation=]
The first argument (class) is limited to 3 bits according to the
specification. Mask the higher bits to fix the warning.
packet is allocated on the stack in coap_read_session(), and so is
uninitialized when processed by coap_network_read(). If there is not an
appropriate cmsg entry in mhdr.msg_control when returning from recvmsg()
packet->ifindex (nor for that matter packet->dst) does not get updated.
src/coap_io.c:
Preset mhdr.msg_control initial cmsghdr with invalid information and an
oversize length so that underlying recvmsg() implementations (e.g. minimal
IoT implementations) that do not update mhdr.msg_control's data, or do not
update it with the destination IP of the packet are correctly handled.
Part Three:
man/Makefile.am:
Determine additional man pages created by a2x with A2X_EXTRA_PAGES.
Set EXTRA_PAGES for the hand crafted additional man pages.
Clean out the additional installed coap_*.3 man pages using uninstall-man:
in man/Makefile.am
memset the node when a new optlist node is created, because the node->next maybe not NULL, so if it creates a new optlist node, and delete it, and then create it again, error will be occurred