Commit Graph
1610 Commits
Author SHA1 Message Date
Olaf Bergmann 1b5cb7e4ab [tinydtls] Updated to latest develop version
ext/tinydtls now points to
https://github.com/eclipse/tinydtls/commit/7f8c86e501e690301630029fa9bae22424adf618
2019-04-16 18:11:07 +02:00
obgm 106eb9edc9 Merge pull request #325 from mrdeep1/constrained_stack
For limited stacks, remove large items off the stack and make them static
2019-04-16 18:05:45 +02:00
obgm 1d484849e8 Merge pull request #312 from mrdeep1/group_reg
Fix mcast registrations when using TCP
2019-04-12 15:09:20 +02:00
Jon Shallow fda991f541 Fix mcast registrations when using TCP
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
2019-04-12 13:54:50 +01:00
Jon Shallow cb18375df7 For limited stacks, remove large items off the stack and make them static
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.
2019-04-11 15:53:21 +01:00
obgm 3bd5f488df Merge pull request #332 from mrdeep1/coap_free_endpoint_fix
coap_free_endpoint does not clean up tinydtls encryption sessions
2019-04-11 14:46:00 +02:00
Jon Shallow bc789edff8 coap_free_endpoint does not clean up tinydtls encryption sessions
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
2019-04-11 10:47:17 +01:00
Olaf Bergmann 302bbffebd [tinydtls] update submodule to development HEAD 2019-04-08 16:27:17 +02:00
Olaf Bergmann affeac8983 Merge branch 'develop' of github.com:obgm/libcoap into develop 2019-04-08 14:33:31 +02:00
Olaf Bergmann 429bc1ed30 [tinydtls] Updated submodule URI to new development HEAD
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
2019-04-08 14:28:52 +02:00
obgm bab80cff21 Merge pull request #328 from mrdeep1/gnutls_psk_username_fix
Fix #321 was not correctly implemented
2019-04-08 10:23:24 +02:00
Jon Shallow a106ecc319 Fix #321 was not correctly implemented
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.
2019-04-07 17:48:46 +01:00
obgm af1d602486 Merge pull request #327 from mrdeep1/contiki_lwip
server (lwip & contiki) run out of sessions
2019-04-05 16:19:02 +02:00
obgm 303be16e86 Merge pull request #317 from mrdeep1/cmsg_checks
packet->ifindex has random values if recvmsg() does not update msg_control
2019-04-05 15:49:16 +02:00
Jon Shallow 10b1b17aec server (lwip & contiki) run out of sessions
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
2019-04-05 14:30:12 +01:00
obgm 6940fcb4c2 Merge pull request #324 from mrdeep1/session_free
dtls_send_to_peer: cannot find local interface reported on coap_session_free
2019-04-05 15:05:34 +02:00
Jon Shallow 1158541f63 dtls_send_to_peer: cannot find local interface reported on coap_session_free
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.
2019-04-05 13:56:03 +01:00
obgm 260472be04 Merge pull request #321 from mrdeep1/gnutls_psk_username_crash
Client crashes in gnutls psk setup
2019-04-01 13:33:57 +02:00
obgm 7bb644c40d Merge pull request #320 from mrdeep1/man_gnu_error
Fix GNU make extension complaint in man/Makefile.am
2019-04-01 11:59:26 +02:00
Jon Shallow d6562e8b59 Client crashes in gnutls psk setup
src/coap_gnutls.c:

Correct typo when null terminating username.
2019-03-31 20:33:46 +01:00
Jon Shallow 9028574ee3 Fix GNU make extension complaint in man/Makefile.am
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 =
2019-03-31 14:55:19 +01:00
obgm 0158bc46fa Merge pull request #318 from igrr/bugfix/format_truncation_warning
coap_debug.c: fix format warning when compiling with GCC 8
2019-03-31 15:28:22 +02:00
Olaf Bergmann e65135f49a configure.ac: Fixed comment for LT_INIT
Commit 40c1ddb enables shared and static libraries to be used for
testing hence the comment before LT_INIT was updated accordingly.
2019-03-31 14:29:21 +02:00
Olaf Bergmann be0aca2ef9 Merge branch 'mrdeep1-travis_tinydtls_build' into develop 2019-03-31 14:28:30 +02:00
Jon Shallow 40c1ddbb24 Travis tests/testdriver fails with libtinydtls.so missing error
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.
2019-03-30 13:04:04 +00:00
Ivan Grokhotkov 9783d4ed91 coap_debug.c: fix format warning when compiling with GCC 8
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.
2019-03-28 16:03:44 +08:00
Olaf Bergmann 641b5c174d [tinydtls] Updated to head of develop branch 2019-03-21 14:40:08 +01:00
Jon Shallow 9ad9ad0bb5 packet->ifindex has random values if recvmsg() does not update msg_control
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.
2019-03-20 17:06:53 +01:00
Olaf Bergmann a363e01214 coap_openssl.c: Additional NULL pointer check
This change fixes an inconsistency detected by Coverity scan
(CID 1479021).
2019-03-20 15:48:37 +01:00
obgm 175a73765d Merge pull request #307 from mrdeep1/distcheck
Fix 'make distcheck' by removing the manpage additional generated .3 files
2019-03-05 15:43:40 +01:00
Jon Shallow cdcec53a88 Fix 'make distcheck' by removing the manpage additional generated .3 files
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
2019-03-04 11:43:14 +00:00
Jon Shallow d8f4eda569 Fix 'make distcheck' by removing the manpage additional generated .3 files
Part Two:

man/coap_context.txt.in:

Remove spurious reference to coap_endpoint_str
2019-03-04 11:41:36 +00:00
Jon Shallow 64fa1e5384 Fix 'make distcheck' by removing the manpage additional generated .3 files
Part One:

Makefile.am:

Correct the name of the libcoap-*.pc in distclean-local: of Makefile.am
2019-03-04 11:39:41 +00:00
Jean-Claude Michelou e66b963744 win32/libcoap.props: use standard layout for OpenSSL headers 2019-03-02 22:11:13 +01:00
Jean-Claude Michelou 34679ff5cb client.c, coap-server.c: use signal instead of sigaction on win32 2019-03-02 22:10:07 +01:00
Jean-Claude Michelou 8c5724c712 coap.h.windows: rename debug.h to coap_debug.h 2019-03-02 22:07:07 +01:00
Olaf Bergmann cfec0d072c configure.ac: bumped version number to 4.2.0 v4.2.0 2019-03-02 11:58:05 +01:00
Olaf Bergmann 9e365770cb client.c: updated year in runtime copyright message 2019-03-02 11:57:35 +01:00
Olaf Bergmann 2922c19970 updated copyright information
Touched dates in files where significant changes occurred in 2019.
2019-03-02 11:43:59 +01:00
Olaf Bergmann 66c682d74c Merge branch 'yr2004-patch-2' into develop 2019-03-01 16:03:36 +01:00
yr2004 e269b87151 option.c: memset the node when a new optlist node is created
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
2019-03-01 16:03:00 +01:00
Olaf Bergmann da254c1f8e TODO: cleanup contents 2019-03-01 14:14:17 +01:00
Olaf Bergmann 9c939f8e9c CONTRIBUTE: nits 2019-03-01 14:14:17 +01:00
Olaf Bergmann d7e41bdc0f coap_gnutls.c: Fixed typo and updated copyright year 2019-03-01 14:13:00 +01:00
Olaf Bergmann 2de0c7d486 coap_gnutls.c: Fix out-of-bounds array access
Coverity scan found an out-of-bounds array access while reading the local array identity
(CID 1476518). This change also ensures that the result parameters are always initialized
and avoids invalid pointer dereference in case gnutls_malloc() returns NULL.
2019-03-01 14:13:00 +01:00
Olaf Bergmann 33b372d945 coap_gnutls.c: Removed dead code
Coverity found that status is always 0 when validate_cn_call_back()
is invoked (CID 1476517). This change removes the dead code by
introducing a constant that can be inferred at compile-time.
2019-03-01 14:13:00 +01:00
obgm db24e760e0 Merge pull request #304 from mrdeep1/no-ca-gnutls-3-6
Support for clients with no PKI or PSK defined for GnuTLS > 3.6 and coaps
2019-03-01 13:20:52 +01:00
Jon Shallow 3cf96472b6 Support for clients with no PKI or PSK defined for GnuTLS > 3.6 and coaps
GnuTLS 3.6.0 or later requires that gnutls_certificate_set_x509_system_trust()
is set up if PSK is not being used and PKI is not defined and the session
is to be DTLS based.

src/coap_gnutls.c:

Add in call to gnutls_certificate_set_x509_system_trust() in
setup_pki_credentials() if PKI has not been set up.
2019-03-01 11:50:38 +00:00
obgm db283b3618 Merge pull request #302 from mrdeep1/server-cleanup-on-error
GnuTLS Server: Handle session setup failures following a session setup failure
2019-03-01 12:41:07 +01:00
Jon Shallow fc7bf57a61 GnuTLS Server: Handle session setup failures following a session setup failure
src/coap_gnutls.s:

If a DTLS server session setup fails (invalid / missing certificate etc.)
and the client has sent some more of the DTLS setup exchange packets before
receiving the TLS alert packet closing things down, any subsequent new DTLS
sessions will fail.

Caused by the g_env environment getting partially polluted with information
with the subsequent DTLS setup exchange packets.

The primary fix is for coap_dtls_hello() is to clear out g_env if there is a
ClientHello packet failure (error return from do_gnutls_handshake()) as well
as if the packet is not of the form of a ClientHello, then it is simply
ignored.

(This may be what is being seen in #300)
2019-03-01 10:33:14 +00:00