Commit Graph
315 Commits
Author SHA1 Message Date
obgm b8c66fb401 Merge pull request #537 from mrdeep1/deprecated_warnings
Deprecated: Replace deprecated functions in library
2020-10-20 14:46:04 +02:00
Olaf Bergmann 605f990ef6 option.[hc]: remove unused function coap_opt_delta() 2020-10-20 13:16:19 +02:00
Olaf Bergmann b1ee9c8912 options: fix integer overflow in option parser
As the numeric range of CoAP option codes is [0..65804], the data
type for representing these codes must be uint32_t rather than
uint16_t.

Fixes OSS-Fuzz 26371. [1]

[1] https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26371
2020-10-20 13:16:00 +02:00
obgm 4ca959ca53 Merge pull request #499 from mrdeep1/coap_cache
coap_cache: Add in Cache Key and Cache Entry support
2020-10-14 16:32:35 +02:00
Jon Shallow 1a349d5cb4 coap_cache: Add in Cache Key and Cache Entry support
This updates the initial work done for adding in cache support

include/coap2/coap_cache.h: (new)
include/coap2/coap_cache_internal.h: (new)
src/coap_cache.c: (new)

New files to support cache support.

CMakeLists.txt:
Makefile.amMakefile.am:
Makefile.libcoap:
configure.ac:
examples/lwip/Makefile:
include/coap2/coap.h.in:
include/coap2/coap.h.windows:
win32/libcoap.vcxproj:
win32/libcoap.vcxproj.filters:

Add in the new files.

examples/client.c:

Fix valgrind reported memory leak.

examples/coap-server.c:

Add in new example_data resource that uses the new caching logic.
Update hnd_put() to use the new cache logic for BLOCK1 PUTs.

include/coap2/coap_forward_decls.h:
include/coap2/coap_internal.h:
include/coap2/coap_session.h:
include/coap2/net.h:

Add in new cache support.

libcoap-2.map:
libcoap-2.sym:

Include the new functions.

man/Makefile.am:
man/coap.txt.in:
man/coap_cache.txt.in: (new)

Update documentation.

src/coap_io.c:

Idle timeout cache entries.

src/coap_session.c:

Delete cache entry when session is deleted.

src/net.c:

Delete cache entries when context is freed off.

src/coap_gnutls.c:
src/coap_mbedtls.c:
src/coap_notls.c:
src/coap_openssl.c:
src/coap_tinydtls.c:

Add in SHA256 digest support.
2020-10-14 10:04:12 -04:00
Olaf Bergmann 0b142f9eda coap_cache: initial caching code 2020-10-14 09:33:37 -04:00
Jon Shallow e0a6593728 memory: Add in support for creating coap_binary_t objects
Add in coap_new_binary() and coap_delete_binary() functions which operate
in the same way as coap_new_string() and coap_delete_string() but work on
coap_binary_t objects.

include/coap2/str.h:
src/str.c:

Add in the coap_new_binary(), coap_resize_binary() and coap_delete_binary()
functions.

configure.ac:
man/Makefile.am:
man/coap.txt.in:
man/coap_string.txt.in: (new)

Add in documentation for the coap_string functions.

libcoap-2.map:
libcoap-2.sym:

Update with new functions.

coap_config.h.contiki:
include/coap2/lwippools.h:
include/coap2/mem.h:
src/mem.c:

Add support for fixed memory allocations for Cacke-Key and Cache-Entry
2020-10-14 09:33:37 -04:00
Jon Shallow 4d039eb01d Options: Sanity check CoAP options in the PDU
include/coap2/pdu.h:
src/pdu.c:
tests/test_pdu.c:

Change parameter max_delta to max_opt to better reflect actual usage.

include/coap2/pdu.h:
src/pdu.c:

Remove unneeded COAP_OPT_LONG and COAP_OPT_END definitions.

Remove unused function coap_add_option_later().

src/pdu.c:

Update coap_pdu_parse_opt() to sanity check the valid lengths of all the
known options.

src/coap_io_lwip.c:
src/net.c:

Ignore packets < 4 bytes
Send back a RST for UDP/DTLS if malformed PDU.

src/option.c:

Clean up coap_option_filter_get() documentation.
2020-10-14 09:26:27 -04:00
obgm 10db554d3e Merge pull request #523 from mrdeep1/doxygen_warnings
Doxygen: Clean up documentation errors
2020-10-14 13:35:36 +02:00
obgm 9ee4895797 Merge pull request #540 from mrdeep1/fetch_observe
Observe: Support FETCH
2020-09-10 18:08:46 +02:00
Jon Shallow 26cd2446a8 Deprecated: Replace deprecated functions in library
examples/contiki/coap-observer.c:
examples/etsi_iot_01.c:
include/coap2/coap_prng.h:
include/coap2/net.h:
src/coap_debug.c:
src/coap_openssl.c:
src/coap_session.c:
src/net.c:
src/option.c:
tests/test_error_response.c:
tests/test_options.c:

prng -> coap_prng
prng_init -> coap_prng_init
coap_option_setb -> coap_option_filter_set
coap_option_clrb -> coap_option_filter_unset
coap_option_getb -> coap_option_filter_get

include/coap2/coap.h.windows:
win32/libcoap.vcxproj:
win32/libcoap.vcxproj.filters:

prng.h -> coap_prng.h

include/coap2/option.h:

Add in COAP_DEPRECATED in deprecated functions.
2020-09-08 17:21:34 +01:00
Jon Shallow 7033555d29 RFC8768: Add in support for CoAP Option Hop Limit loop detection
All this is handled by libcoap with coap-client having the ability to define
an initial Hop Count value for testing. No other application support is
required.

Incoming requests are checked for the Hop Limit option - if found, the value
is decremented in the PDU before passing it up to the application. If it
decrements to 0, a 5.08 response is generated.

coap_add_option() checks if this is a Proxy option for a request. If so, and
Hop Limit option does not exist, then the Hop Limit option is inserted into
the PDU with the default value (16).

coap_send() checks if it is a 5.08 response and if so, prepends the diagnostic
data with the IP address of the transmitting interface. If the IP address
already exists, then the PDU is dropped as the return path for the 5.08 response
is looping.  An alternative method for return path looping check is also
used by initially setting, then testing and then decrementing the Hop Limit
value as response packets pass back through the proxies.  If a proxy does not
copy the Hop Limit options when returning the 5.08 response, then the IP address
duplication is used.

Makefile.am:

Hide the coap_insert_option(), coap_update_option and coap_pdu_check_resize()
function from applications.

README.md:

Add in RFC8768 is supported by libcoap.

examples/client.c:

Add in the -H hoplimit option.

include/coap2/pdu.h:

Add in the default Hop-Limit: option COAP_OPTION_HOP_LIMIT.
Re-organize the COAP_OPTION_ descriptions to include
the C, U, N, R, E, I and U flags.
Expose the internal coap_pdu_check_resize() function so src/net.c can use it.
Define the two new internal functions coap_insert_option() and
coap_update_option() and expose them so that the test suites can use them.

man/coap-client.txt.in:

Document the new -H hoplimit option.

man/coap.txt.in:

Include the new RFC8768.

man/coap_pdu_setup.txt.in:

Update documentation for the CoAP options.

src/coap_debug.c:

Add in support for printing out COAP_OPTION_HOP_LIMIT.

src/net.c:

Make sure that COAP_OPTION_HOP_LIMIT is not returned in an error response.
Decrement received Hop-limit in handle_request() and generate 5.08 response
if appropriate.
Update coap_send() to prepend IP in 5.08 response.
Support COAP_OPTION_HOP_LIMIT being used in the 5.08 response message.

src/pdu.c:

Report on CoAP options that are repeated, but not defined as repeatable.
Define new (5.08) Hop Limit Reached error response.

Add in new internal coap_insert_option() function. This now means that
callers of coap_add_option() no longer have to have the options in the
correct order.

Add in new internal coap_update_option() function that updates the value of
an option.

Make coap_pdu_check_resize() non-static.

tests/test_pdu.c:

Check that options are getting inserted in the correct order when using
coap_insert_option(), even though they are provided in a random order.

Test the coap_update_option() function.
2020-09-07 12:34:04 +01:00
Jon Shallow e85e3abb82 Observe: Support FETCH
Support observe for both GET and FETCH.

Correct coap-client programatic addition of observe establish option which
"happened" to work previously because COAP_OBSERVE_ESTABLISH was 0.
2020-08-19 11:24:08 +01:00
Jon Shallow 9443d9034a PKCS11: Add in PKCS11 support for PKI
Add in a new PKI_KEY type for PKCS11 URI to get the PKI information from a
smart card or HSM device.

Currently only OpenSSL and GnuTLS are supported.

Makefile.am:

Do not expose coap_dtls_shutdown() function.

examples/client.c:
examples/coap-server.c:

Add in support for using pkcs11: URIs for defining the Certificates and
Private Keys.

include/coap2/coap_dtls.h:

Add in COAP_PKI_KEY_PKCS11 Key type.

man/coap-client.txt.in:
man/coap-server.txt.in:

Update documentation for supporting PKCS11.

man/coap_encryption.txt.in:

Add in documentation for COAP_PKI_KEY_PKCS11.
Correct some typos.

HOWTO.dual.gnutls (new):
HOWTO.dual.openssl (new):
HOWTO.dual.softhsm2 (new):
HOWTO.pkcs11 (new):

HowTo information.

src/coap_gnutls.c:
src/coap_openssl.c:

Add in PKCS11 support.

src/coap_mbedtls.c:

PKCS11 not yet supported.
Add in no-op coap_dtls_shutdown() function.

src/coap_notls.c:
src/coap_tinydtls.c:

Add in no-op coap_dtls_shutdown() function.

src/net.c:

Invoke coap_dtls_shutdown() function in coap_cleanup().

NOTE: There are memory leaks after cleanly closing down.  These are not within
libcoap as far as can be determined.  These leaks are a work in progress.
2020-07-07 09:15:58 +01:00
Jon Shallow ff023a183a Doxygen: Clean up documentation errors
include/coap2/async.h:
include/coap2/coap_prng.h:

Correct documentation errors
2020-07-01 10:23:07 +01:00
obgm 098fa85395 Merge pull request #512 from mrdeep1/tcp_fixes
TCP: Prevent incorrectly formed PDUs causing RAM exhaustion.
2020-06-30 14:04:20 +02:00
Olaf Bergmann f92bfe9af3 Renamed prng.h to coap_prng.h 2020-06-19 17:51:25 +02:00
Olaf Bergmann f17112659e [PRNG] improve pseudo number generation on platform POSIX
These new functions for generating pseudo numbers replace the old
macro-based approach:

coap_prng() replaces prng() to generate new pseudo random numbers.
This function uses getrandom() if HAVE_GETRANDOM is defined at
build time.

coap_prng_init() replaces prng_init() to seed the pseudo random
number generator. The function does nothing if HAVE_GETRANDOM is
set at build time.

coap_set_prng() can be used to register a custom pseudo number
generation function replacing the default.
2020-06-19 17:40:13 +02:00
Olaf Bergmann 48dc4538ce resource.[hc], net.c: fix use after free for query string
If a resource is observed, handle_request() passes the ownership
of a Uri-Query to the observer structure for later retrieval. In
this case, the query is not free'd in handle_request. However, if
the observer data structure ("subscription") was not created due
to insufficient memory, the query string must not be deleted as
it is used for the resource handler callback later in
handle_request(). The solution here passes ownership to the
observer only if case coap_add_observer() is successful.

This fixes CID 1483551.
2020-06-19 16:27:51 +02:00
Jon Shallow 88151d3eb7 TCP: Prevent incorrectly formed PDUs causing RAM exhaustion.
src/net.c:

Add in a sanity check that the PDU length is not more that the negotiated
CSM size for incoming data.
Track CSM remote supports block transfer.
Do not allow Block options if CSM has not negotiated block transfer.

src/coap_session.c:

Include block-wise-transfer is supported in the CSM

include/coap2/coap_session.h:

Make MTU size bigger than 32 bits as CSM mtu size can be greater than 32 bits.
Track CSM remote supports block transfer.

include/coap2/pdu.h:

Make COAP_DEFAULT_MAX_PDU_RX_SIZE a unsigned long to be bigger than 32 bits.
2020-06-16 08:28:14 +01:00
Olaf Bergmann 6b19f19562 uri.h: improved documentation 2020-06-03 10:06:25 +02:00
Olaf Bergmann 617ac895ec Merge branch 'develop' of github.com:obgm/libcoap into develop 2020-06-03 09:48:17 +02:00
Jon Shallow 9dd16a3260 RFC7872: Add in media type application/dots+cbor
include/coap2/pdu.h:
src/coap_debug.c:

Include in coap_show_pdu() output if appropriate.
2020-06-01 11:29:03 +01:00
Olaf Bergmann 2c7c35cf74 coap.h.in: Set LIBCOAP_VERSION 2020-05-29 08:11:44 +02:00
Olaf Bergmann ffeeee1976 pdu.h: add Content-Format number for application/cwt
RFC 8392 defines the CoAP Content-Format number 61 for application/cwt
(CBOR web tokens).
2020-05-13 16:40:58 +02:00
Olaf Bergmann 93e75e44e3 [RIOT] coap_debug.h: define missing log levels
RIOT defines a subset of the syslog levels in log.h with different
numeric values. The remaining levels are defined here. Note that
output granularity differs from what would be expected when adhering
to the syslog levels.
2020-05-10 20:18:38 +02:00
Olaf Bergmann 789202ccb8 [RIOT] net.h: exclude coap_io_process_with_fds()
RIOT supports fd_set only for BOARD=native. For now,
coap_io_process_with_fds() is completely disabled on RIOT as it is not
yet implemented in coap_io_riot.c, anyway.
2020-05-10 13:46:50 +02:00
Jon Shallow 8559e40cce async: Fix session->ref assertion failure and timeout values
Calling coap_free_context() does not free off any async entries, and so
raises assertion errors when coming to freeing off sessions if any async
entries exist.

async_data_t is a union, but the size of val and ptr are not the same - so
usage can have uninitialized data - hence bad timeout values.

Makefile.am:

Do not expose coap_delete_all*() functions.

examples/coap-server.c:

Fix async_data_t issue.

examples/etsi_iot_01.c:

Fix 32 bit compiler warnings using same logic as coap-server for holding the
async timeout value.

examples/lwip/Makefile:

Include async.c for the LwIP build.

include/coap2/async.h

Define coap_delete_all_async() function.

include/coap2/net.h
include/coap2/resource.h

Document coap_delete_all*() functions as internal.

libcoap-2.map
libcoap-2.sym

Remove non-exposed coap_delete_all*() functions.

src/async.c

Provide coap_delete_all_async() function.

src/net.c

Call coap_delete_all_async() from within coap_free_context().
2020-05-07 09:44:41 +01:00
Jon Shallow f08f9ea86e TCP_DISABLE: reduce more of the dead code when --disable-tcp is in used
src/coap_session.c:
src/net.c:

Wrap more code with #if !COAP_DISABLE_TCP

include/coap2/coap_tcp_internal.h:

Wrap function definitions with #if !COAP_DISABLE_TCP to force compiler
warnings if there still is reference to TCP functions and COAP_DISABLE_TCP
is set.
2020-05-06 10:26:37 +01:00
obgm 8b31d1415a Merge pull request #488 from mrdeep1/riot_base
Merge in riot/posix_sockets branch
2020-05-05 14:25:07 +02:00
obgm 4c299ddc95 Merge pull request #444 from mrdeep1/sign-conversion
Windows C4267 errors: Fix size_t conversion warnings in windows builds
2020-05-04 17:49:45 +02:00
Jon Shallow 21e045bb8f coap-server: Make sure observe updates are sent off asap
examples/coap-server.c:

Track time spent in the epoll branch for the select() and coap_io_process()
calls to correctly adjust wait_ms.

Adjust wait_ms to be the remaining amount in the current second, so that
any 'time' observers get the updated time just after the new second starts.

include/coap2/net.h:

Add in support to track that an observe is pending transmission - primarily
a saving of needing to look up if a observe needs to be sent.

include/coap2/resource.h:

Add in support to track the context that 'owns' a resource.

src/resource.c:

Track the context that 'owns' a resource in coap_add_resource().

Track the fact that when we are making a resource partially dirty by recording
that an observe is pending in coap_notify_observers().

In the epoll case, make sure that timerfd triggers immediately when a pending
observe is set so that the application will return immediately from any select()
etc. call to process the libcoap outstanding activity (in particular pending
observes) in coap_resource_notify_observers().

Only call coap_notify_observers() in coap_check_notify if there are any
observes pending.

man/coap_observe.txt.in:

Minor clarifications in the examples.
2020-05-04 11:04:23 +01:00
Jon Shallow 893b5626e1 Report on old usage of COAP_RUN_BLOCK and COAP_RUN_NO_BLOCK
Give a hint in the compiler error message about using deprecated
COAP_RUN_BLOCK and COAP_RUN_NO_BLOCK and what they are replaced with.
2020-04-29 08:41:59 +01:00
Olaf Bergmann 842c2467c0 address.[hc]: Add convenience functions to get/set port
The layout of struct coap_address_t is platform-dependent. This
change introduces getter/setter functions to retrieve and modify
the port component:

   uint16_t coap_address_get_port(const coap_address_t *addr)
   void coap_address_set_port(coap_address_t *addr, uint16_t port)

The respective port is given in host byte order and will be
converted to/from network byte order automatically.
2020-04-24 20:16:10 +01:00
Olaf Bergmann 5d930d8683 Makefile.am: Added new file coap_riot.h
The new header file is required by RIOT applications to execute
thread-specific startup code.
2020-04-24 20:16:10 +01:00
Olaf Bergmann 7949440ee0 [RIOT] coap_io.c: replace coap_network_read()
A RIOT-specific version of the function coap_network_read() is
now included in the new file coap_io_riot.c. This function requires
the received gnrc_pktsnip_t structure to be passed with the
coap_socket_t structure.
2020-04-24 20:16:10 +01:00
Olaf Bergmann f510b86573 coap_time.h: RIOT support based on xtimer 2020-04-24 20:16:10 +01:00
obgm 17957e1e68 Merge pull request #430 from gocarlos/develop
add cmake support to libcoap
2020-04-24 20:42:04 +02:00
Carlos Gomes Martinho e191e2d726 build: add cmake support 2020-04-22 17:07:24 +02:00
Jon Shallow afefd95ceb coap_io_process: Fix 1ms busy loop and indefinite sleep
Replace COAP_RUN_BLOCK with COAP_IO_WAIT and COAP_RUN_NOBLOCK with
COAP_IO_NO_WAIT for naming clarity.

Instead of COAP_IO_NO_WAIT being 1, make it -1 to fix 1ms busy loop.
Handle the case when coap_io_prepare_io returns 0 to prevent indefinite
select() wait.

include/coap2/net.h:

Make the timeout_ms parameter uint32_t in coap_io_process*() functions to
make sure special case of COAP_IO_NO_BLOCK is correctly handled on different
architectures.
Update COAP_IO_NO_BLOCK to -1.

src/coap_io.c:

Fix the 1ms busy loop and potential infinite wait in the non epoll case.

man/coap_io.txt.in:

Update documentation to reflect the changes.

examples/coap-server.c:
examples/contiki/server.c:

Update to use COAP_IO WAIT and COAP_IO_NO_WAIT as appropriate.
2020-02-25 22:03:46 +00:00
Jon Shallow bb38e995bc Windows C4267 errors: Fix size_t conversion warnings in windows builds
examples/client.c:
examples/coap-rd.c:
examples/coap-server.c:
include/coap2/block.h:
include/coap2/coap_hashkey.h:
src/block.c:
src/coap_debug.c:
src/coap_hashkey.c:
src/coap_io.c:
src/coap_openssl.c:
src/net.c:

Fix C4267 windows compilation warnings when using Visual Studio where
size_t variable parameters are being converted  in both size and sign.

There still are some C4116 warnings to fix.
2020-02-21 17:28:11 +00:00
Jon Shallow c3be323749 pdu.h: Remove unneeded backward compatible #defines from 2011
The # COAP_RESPONSE_nnn entries were introduced to handle a response change
introduced by draft-ietf-core-coap-04 in 2011.  These are no longer used
and can cause confusion - e.g.
 define COAP_RESPONSE_304      COAP_RESPONSE_CODE(203)  /* 2.03 Valid */
as raised in #456.  Entries now removed.
2020-02-21 17:27:48 +00:00
Jon Shallow 9cf4f10b35 Rename coap_run_once() to coap_io_process()
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.
2020-02-13 19:54:48 +00:00
Jon Shallow 15f9cf568a coap_openssl.c: OpenSSL < 1.1.1 fails to build with --disable-tcp
Missing COAP_DISABLE_TCP wrapper in OpenSSL 1.1.0 - 1.1.1 specific code

doc/main.md:

Update Copyright year.

include/coap2/coap_tcp_internal.h:

Update documentation for the internal TCP functions

src/coap_session.c
src/coap_tinydtls.c

Delete trailing space
2020-02-04 10:30:16 +00:00
Jon Shallow e9cffe9b91 Make COAP_REQUEST_* enum for clarity
Make the COAP_REQUEST_* #defines enum coap_request_t for clarity.

This should help prevent mistakes such as in #448.
2020-02-03 09:33:15 +00:00
Jon Shallow c237b15b16 Correct Disable TCP for TLS and Windows
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.
2020-01-16 15:17:10 +00:00
Olaf Bergmann b43907ef2b Conditionally disable TCP
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.
2020-01-16 13:37:24 +00:00
Jon Shallow f601ddbf78 Add in MbedTLS support
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.
2020-01-16 09:38:43 +00:00
Jon Shallow d2f7b4f23a observe: Add in support for all observe responses to be non-confirmable
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.
2020-01-13 13:14:25 +00:00
obgm 03cc5791c5 Merge pull request #417 from mrdeep1/coap_run_once_fds
coap_io.c: Add in additional FD checking support for coap_run_once()
2019-12-20 17:47:35 +01:00