Commit Graph
39 Commits
Author SHA1 Message Date
Jon Shallow 4a543d1198 Extend coap_tls_version_t to include both built and runtime TLS versions
This allows an application to determine what the built version is
as well as what the runtime version of a TLS library is.

include/coap2/coap_dtls.h

Add built_version to coap_tls_version_t

src/coap_openssl.c
src/coap_tinydtls.c

Additionally populate coap_tls_version_t with build_version when
coap_get_tls_library_version() is called.

src/coap_tinydtls.c

Correct the version returned as actual TinyDTLS version instead the
binary value of a DTLS packet type.
2018-11-27 11:42:04 +00:00
Jon Shallow 04ced3e5e5 Replace debug(), info() & warn() macros with appropriate coap_log()
This then removes the need for name polution/confict of debug(), info() and
warn() when building other projects that use libcoap and need to #include the
libcoap header files

Updated:
 examples/client.c
 examples/contiki/coap-observer.c
 examples/etsi_iot_01.c
 include/coap2/debug.h
 src/async.c
 src/block.c
 src/coap_io.c
 src/coap_openssl.c
 src/coap_session.c
 src/coap_tinydtls.c
 src/debug.c
 src/mem.c
 src/net.c
 src/option.c
 src/pdu.c
 src/resource.c
 src/uri.c

If the debug() etc. macros are still required, then the change to
include/coap2/debug.h just needs to be reverted.

There are also a couple of space changes - to cause log output to be columnar
e.g "ERR" was padded to "ERR ", so that "EMRG" or "ERR " log output output was
aligned in the same way.

This is a replacement for PR#51, and partially deals with name polution issues
raised in Issue #50.

Parameter re-aligned some long strings, splitting strings across multiple lines
2018-11-10 20:27:50 +00:00
Jon Shallow f5367ef3de Delete trailing spaces from files, replace TAB with 8*SPACE
"git diff -w" shows no differences

TAB left alone in files that are not C based files or documentation
2018-09-28 17:34:07 +01:00
Jon Shallow 340a3d03b4 {coap_notls|/coap_tinydtls}.c: Update internal coap_dtls_context_set_*() functions
coap_dtls_context_set_pki_root_cas(): New function
coap_dtls_context_set_psk(): Remove unused parameters, add in server parameter
coap_dtls_context_set_pki(): Add in server parameter
coap_dtls_context_check_keys_enabled(): Add in UNUSED

src/coap_tinydtls.c:
coap_dtls_free_session() set coap_session->tls = NULL
2018-07-23 11:17:44 +01:00
Jon Shallow 7abe7714c3 coap_{notls|openssl|tinydtls}.c: Support older gcc compilers
#pragma GCC diagnostic push
 #pragma GCC diagnostic pop

is not supported by gcc version less than 4.6

[I also think the push/pop is not needed as it is at the end of the
file and only one file is complied at one time]

gcc in general does not complain about (when the only entry in the file)

static inline void dummy(void) {
}

Also current code before fix is unlikely to work on Windows so the
additional compiler wrapper (is it clang) tests should fix this.
2018-06-04 10:06:37 +01:00
Olaf Bergmann 26d5cf784a coap_{notls,openssl,tinydtls}.c: quiet 'unused function' warning
Depending on the TLS library being used (which may be none), the
code that depends on other TLS libraries is not compiled. Because
some compilers are not happy compiling empty modules, each of these
files contains an empty static inline function dummy() that gets
compiled instead. As clang happens to emit a warning for this
function when -Wunused-function is set, this change introduces
a GCC pragma (sic!) to suppress this warning for the dummy function.
2018-05-31 11:12:01 +02:00
obgm 282fd96fc3 Merge pull request #192 from cquijano/dtls_event_on_error
coap_tinydtls.c: On DTLS error, fire and event that could be catch by upper layers
2018-05-31 10:43:12 +02:00
Carlos Quijano 491964e9c4 coap_tinydtls.c: On DTLS error, fire and event that can be caught by upper layers 2018-05-31 10:33:56 +02:00
Jon Shallow 25a8414105 src/*.c: Remove cast-qual compiler warnings
Where appropriate in general

Replace 'unsigned char' with 'const uint8_t'
Replace 'str' with 'coap_str_c_t'
Replace str with coap_string_t
Prefix with 'const' some type casts
Remove unnecessary type casting
Remove unneeded WITH_LWIP wrappers to select coap_malloc_type() or memp_malloc()
as underlying  coap_malloc_type() is correctly selected in include/coap/mem.h

src/block.c:
Replace coap_opt_const_value() with coap_opt_value()

src/coap_io.c:
Due to the definations of struct iovec and struct msghdr, and const parameters
getting passed in, as this is a write of data function, the pointers are
copied into the 2 structures to get around the cast-qual warnings

src/net.c:
Release any sessions (so that they may get freed off) in coap_free_context()

src/option.c:
coap_option_filter_get() had to be downgraded as coap_option_filter_op() is
used by set functions as well.

src/pdu.c:
Remove const out of next_option_safe() parameters

As coap_resource_init() has a const uri_path parameter passed into it, it is not
possible to have these values legally freed off if flags is set to
COAP_RESOURCE_FLAGS_RELEASE_URI.

coap_resource_init_release() has been created to handle this.  However, as it
is likely to be called with a coap_string_t generated from a call to
coap_get_uri_path(), the string must be correctly freed off.  Hence the
use of coap_string_t as a parameter.

coap_add_attr_release() has been added in as well, using coap_string_t* as
parameters, to allow the coap_string_t to be freed off correctly.

Add in coap_log warning if the functions coap_resource_init*() and
coap_add_attr*() are called incorrectly.

Update src
2018-05-25 16:38:07 +01:00
Jon Shallow ac7d223d02 src/coap_tinydtls.c: Fix compiler unused parameter warning 2018-05-17 18:58:16 +01:00
Olaf Bergmann 4280e75a0c coap_tinydtls.c: fix compiler warning for printf() format string 2018-04-20 10:50:48 +02:00
Jon Shallow 675edad34c coap_notls.c, coap_tinydtls.c: Fix stub functions coap_dtls_context_set_pki() 2018-02-14 21:59:21 +00:00
Jon Shallow 047c9fb082 Fix coap_notls.c, coap_tinydtls.c: after update merge from obgm/develop
Conficts created by Pull request #134
2018-02-14 19:24:58 +00:00
Jon Shallow aaa43301b7 coap_tinydtls.c: Add in PKI stub functions
Update #includes and add in stub functions
coap_dtls_context_set_pki
coap_dtls_context_set_psk
coap_dtls_context_check_keys_enabled
2018-02-12 09:50:32 +00:00
Jon Shallow 30794440af coap_tinydtls.c: Add in coap_get_tls_library_version() function
Add in coap_get_tls_library_version() for determining TLS build base + version
2018-02-10 19:38:08 +00:00
jcmichelou c93f535d4a openssl, session: Fix memory leaks. 2017-11-04 23:38:02 +01:00
jcmichelou e125888ded openssl: Handshake can also complete in SSL_accept and SSL_connect. 2017-10-21 19:16:23 +02:00
jcmichelou e713e77f54 notls, tinydtls: Add stubs for unused TLS functions. 2017-10-21 16:11:15 +02:00
jcmichelou dfff930805 io, net: Add TCP accept/connect/read/write 2017-10-21 16:11:12 +02:00
jcmichelou bcfd7a0753 pdu: add support for TCP-style headers
Make coap_pdu-t independent of the header style.
Use C99 sized types when applicable.
Use transaction ids in host byte order in the library.
Make coap_pdu_t payload storage grow on demand.
Add parsing and encoding of PDUs with UDP or TCP style headers.
Adapt examples and unit tests to the new PDU format.
2017-10-21 16:11:11 +02:00
jcmichelou 25732fc8e6 coap_session.[ch], net.c: Add handler for lost CON messages.
Add a slot for storing application-specifc data in session object.
Make the library resilient against client session released in a callback.
2017-09-08 20:02:22 +02:00
jcmichelou 87126f35c1 Add minimum timeout of 100ms for global DTLS timeout. Remove the peer from tinydtls retransmit list when the coap session is reset. 2017-07-01 17:09:14 +02:00
jcmichelou 1d2e985364 Fix missing pointer. 2017-06-30 19:26:55 +02:00
jcmichelou 42f68764f1 Safely separate the coap_address_t type from the tinydtls session_t type. 2017-06-30 19:15:00 +02:00
jcmichelou 699cf5d138 Fix handling of session events in tinydtls to call the handler only when it is safe to destroy the session object. 2017-06-30 15:08:40 +02:00
jcmichelou ab04f3924f Fix compilation warnings with gcc. 2017-06-29 19:20:39 +02:00
jcmichelou 7fb4ace2b7 Fix for the signedness warning with gcc.
Compact coap_address_t.
Use coap_queue_t for all queues.
OpenSSL warning for close alert should be info level.
Fix OpenSSL log level not working.
Use the application defined MTU in OpenSSL.
coap_log() optimization to avoid generating the log message text before testing the log level.
coap_can_exit() should check the new retransmit queues.
Fix retransmit time sometimes not correctly computed relative to sendqueue_basetime.
Add coap_write() API call for applications with their own main loop.
2017-06-29 18:12:46 +02:00
jcmichelou b2fe4a64de Make MTU configurable.
Use static or stack storage for coap_packet_t.
2017-06-26 17:34:01 +02:00
jcmichelou ca597b6986 Fix typo in coap_tindydtls 2017-06-24 16:21:28 +02:00
jcmichelou d0974cacd5 A TLS fatal alert shall always disconnect the session. 2017-06-23 16:06:04 +02:00
jcmichelou f6047c8e77 Fix gcc warning messages. 2017-06-22 16:13:38 +02:00
jcmichelou 0a0cd1fb4e Make retransmit timeout relative in tinydtls. 2017-06-22 16:06:11 +02:00
jcmichelou 9490a0c8ab Fix bug in setting the OpenSSL log level make its use consistent with tinydtls
Rename session.c and session.h to coap_session.c and coap_session.h
Use length to PSK hint and identity
Improve packet loss testing
2017-06-22 16:02:03 +02:00
jcmichelou 99925a1a97 Add init function for DTLS library.
Match dummy functions in coap_notls.c with their prototypes.
2017-06-21 20:57:12 +02:00
jcmichelou adf1238eae Add DTLS retransmit and recovery.
Add lossy networks debug option in examples.
2017-06-21 20:40:15 +02:00
jcmichelou 2f24ee8cdd Call dtls_close when session is closed to send a notify alert to the remote peer. 2017-06-21 15:45:02 +02:00
jcmichelou ae13e5127b Compile with tinydtls and remove warning message with gcc. 2017-06-19 20:37:11 +02:00
jcmichelou b389a5f6aa Add skeleton support for tinydtls with new API. 2017-06-19 16:58:12 +02:00
jcmichelou 8353417afb Added session management with simpler DTLS lib API.
Added DTLS support with OpenSSL.
2017-06-18 20:09:47 +02:00