Commit Graph
66 Commits
Author SHA1 Message Date
Jon Shallow f176bf3c53 release 4.3.2rc2: Release candidate for 4.3.2 2023-08-14 09:37:23 +01:00
Jon Shallow 91000861e1 tinydtls: Update to latest main branch 2023-08-14 09:35:36 +01:00
Jon Shallow 3f8bb33807 coap_resolve_address_info: Add in support for defining WebSocket ports 2023-07-26 13:01:42 +01:00
Jon Shallow 084c866c69 coap_startup: Make coap_startup() first function call in examples
This then makes sure that all things libcoap are properly initialized
before use, and coders realize they need to do this.

Note: coap_new_context() continues to make sure that coap_startup()
is invoked if not done previously, but this may be too late.
2023-07-25 13:50:18 +01:00
Jon Shallow 2f98643a09 lwip/Makefile: make sure correct hash is used for tinydtls with tarball build 2023-07-24 13:17:39 +01:00
Jon Shallow cb78d5fd85 release 4.3.2rc1: Release candidate for 4.3.2 2023-07-22 09:29:32 +01:00
Jon Shallow e2910a5bf1 naming: Rename remaining *.[ch] files that are not prefixed with coap_
include/coap3/block.h -> include/coap3/coap_block.h
include/coap3/pdu.h -> include/coap3/coap_pdu.h
include/coap3/resource.h -> include/coap3/coap_resource.h
src/block.c -> src/coap_block.c
src/net.c -> src/coap_net.c
src/pdu.c -> src/coap_pdu.c
src/resource.c -> src/coap_resource.c
2023-07-13 08:59:22 +01:00
Jon Shallow 57013f3377 RFC9177: Add in Q-Block support
examples/coap-client.c:
examples/coap-server.c:

Add in Q-Block intelligence.

include/coap3/block.h
include/coap3/coap_block_internal.h
include/coap3/coap_event.h

Add in Q-Block references.
Add in new functions
coap_block_check_q_block1_xmit()
coap_block_check_q_block2_xmit()
coap_send_q_blocks()
coap_send_q_block1()
coap_send_q_block2()
coap_block_drop_resp_q_block_xmit()
coap_block_drop_resp_q_block2_crcv()
coap_q_block_is_supported()

include/coap3/coap_session.h:

Add in new Congestion Control defaults and ability to configure them.

include/coap3/pdu.h:

Add in the new options.

libcoap-3.map:
libcoap-3.sym:

Expose external Congestion Control functions.

man/coap-client.txt.in:
man/coap-server.txt.in:
man/coap_block.txt.in:
man/coap_handler.txt.in:
man/coap_recovery.txt.in:
man/coap.txt.in:

Add in Q-Block information.

src/block.c:

Add in the new functions to support Q-Block.

src/coap_debug.c:

Output the new options as appropriate.

src/coap_io.c:

Check for Q-Block transmission timeouts.

src/coap_session.c:

Add in the Congestion Control support.

src/net.c:
src/resource.c:

Add in Q-Block support.

configure.ac
CMakeLists.txt

Add in support for enabling/disabling Q-Block support (enabled by default).
2023-07-11 11:04:04 +01:00
Jon Shallow 3755358b7d pre-commit: Include re-styled LwIP and Contiki example files to checks 2023-07-06 11:45:47 +01:00
Jon Shallow 2f4b8843cd DTLS Libraries: Replace HAVE_<dtlslib> defines with COAP_WITH_<dtls_lib>
Prevents possibility of name clashes when integrating with other code / OS.
2023-06-15 18:54:29 +01:00
Jon Shallow 5c1e7cae34 Async: Invert WITHOUT_ASYNC define to COAP_ASYNC_SUPPORTED for clarity
Prevents possibility of name clashes when integrating with other code / OS.
2023-06-15 11:01:22 +01:00
Jon Shallow 1d81256fc1 ipv[46]: Add in configurable support for IPv4, IPv6 and AF_UNIX
Move some existing header inline code into source files.

Update coap_resolve_address_info() to remove need for client based app
code to have to understand IPv4/IPv6 code.

Remove IPv4/IPv6 specific code from examples code.
2023-06-12 14:55:09 +01:00
Jon Shallow 21bd1df95b examples: Remove references to sockaddr* structures
This means that apps need to have no knowledge of what IP support is available.

Updates coap_uri_into_options() and coap_resolve_address_info()
which have only been recently added to develop branch and are not in any
previous release.
2023-06-09 12:04:09 +01:00
Jon Shallow 6c05d34fc6 bcast: Support IPv4 broadcast as multicast
See https://datatracker.ietf.org/doc/html/draft-ietf-core-groupcomm-bis-08#section-3.9.5
2023-06-08 17:47:56 +01:00
Jon Shallow f4666c2ea9 LwIP: Support disabling LwIP's IPv6 support 2023-06-08 17:40:08 +01:00
Jon Shallow e533b980fa coap_resolve_address_info: Move logic into function, simplifying server apps
Add in new function coap_get_available_scheme_hint_bits() to help as well.
2023-04-22 10:45:17 +01:00
Jon Shallow 191cd5cf40 Layers: Move layer index table into coap_layers.c 2023-04-15 19:33:18 +01:00
Jon Shallow 305c400d6f LwIP: Fix git clone url 2023-03-24 12:53:59 +00:00
Jon Shallow c041af0b2b WebSockets: Add in libcoap infrastructure
Add in stub Websockets files.

Add in coap_crypto_hash(0 function.

Actual WebSocket support for applications will follow.
2023-03-24 09:49:00 +00:00
Jon Shallow ecf07b53b5 tls_layer: Separate out (D)TLS layer functionality
Add in new file src/coap_dtls.c.

Add in coap_(d)tls_establish() functions which are called when netif
accept / connect take place.

Add in coap_session_establish() function which is called when (D)TLS
has established as well as at the session layer if there is no (D)TLS
in preparation for properly supporting protocol layers.

Add in coap_(d)tls_close() functions which are called prior to
coap_netif_close().
2023-03-13 20:42:22 +00:00
Jon Shallow f933c6e604 netif: Create netif layer, initially provide datagram read/write
Add in skeleton coap_netif.c coap_netif_internal.h files, populated with
coap_netif_dgrm_read(), coap_netif_dgrm_read_ep(), and coap_netif_dgrm_write()
functions that are called by the CoAP and (D)TLS code which in turn call
the appropriate coap_socket_*() functions.

The coap_dtls_send() function parameters are aligned with
coap_netif_dgrm_write().
2023-03-01 13:58:06 +00:00
Jon Shallow 78304f43a0 file prefix: Update more file names to have coap_ prefix 2023-02-10 20:35:32 +00:00
Jon Shallow 95efc52a7d file prefix: Update more file names to have coap_ prefix 2023-02-09 09:47:14 +00:00
Jon Shallow 0a5d80ad66 coap_address.[ch]: Add coap_resolve_address_info() and coap_free_address_info()
coap_resolve_address_info() emulates getaddrinfo() but has the extensibility to
support other socket types based on the address to resolve.

coap-client, coap-server and lwip/client updated to use this new functionality.

coap_address(3) updated to include the new functions.
2023-02-03 09:53:24 +00:00
Jon Shallow dac6bd3b60 RFC8613: Add in OSCORE support
Based on work done in https://gitlab.informatik.uni-bremen.de/obergman/libcoap

New directories with files
 include/oscore
 src/oscore

New files
 include/coap3/coap_oscore.h
 include/coap3/coap_crypto_internal.h
 include/coap3/coap_oscore_internal.h
 man/coap-oscore-conf.txt.in
 man/coap_oscore.txt.in
 src/coap_oscore.c
 tests/test_oscore.c
 tests/test_oscore.h

Supported by new option (enabled by default)
 ./configure --enable-oscore
 cmake .. -DENABLE_OSCORE=ON

Requires a TLS library configured to do the OSCORE encryption and hashing.
2023-01-14 10:26:20 +00:00
Jon Shallow 3552b53be4 Copyright: Update copyright date to end 2023 as appropriate 2023-01-02 11:45:10 +00:00
Jon Shallow 4882641b95 documentation: Tidy up / correct documentation 2022-12-30 10:55:29 +00:00
Jon Shallow 68f1a6eff3 log_levels: Replace usage of syslog LOG_ with COAP_LOG_
This removes the reliance of syslog definitions in libcoap by using libcoap's
version.
2022-12-17 12:38:31 +00:00
Jon Shallow 48c8eb0b3c .gitignore: Ignore LwIP DTLS enabled executables 2022-12-10 15:16:52 +00:00
Jon Shallow 4b54c0d9ef logging: Use new logging macros for examples and man pages
Drop the use of syslog LOG_DEBUG etc. for coap_log() and use the
coap_log_debug() etc. macros which make use of COAP_LOG_DEBUG etc.

Application examples updated, as well as the man page examples.
2022-12-09 14:55:39 +00:00
Jon Shallow 7b39908e82 LwIP: Add in TinyDTLS support
The dtls versions of the server and client are built as
server-dtls and client-dtls.

Add in flexible option support for server and client.  These are
a subset of the coap-server and coap-client options.
2022-10-29 13:26:43 +01:00
Jon Shallow 972eecf157 LwIP: Fix unused parameter compiler warnings 2022-10-21 20:45:04 +01:00
Jon Shallow c5c4f9bf1d uri.c: Add coap_uri_into_options() function
Simplify code for applications by providing coap_uri_into_options()
which then adds the (optional) port and splits out the path / query
as CoAP options, adding them to the optlist_chain for subsequent use.

Added a new coap_delete_uri() for completeness.

Update documentation to include the uri based functions.

Update examples to use the new coap_uri_into_options() function.
2022-10-12 15:24:02 +01:00
Jon Shallow 3659e3c0cb LwIP: Support receiving ethernet MTU sized packets
Define PBUF_POOL_BUFSIZE appropriately in lwipopts.h
2022-10-12 14:37:20 +01:00
Jon Shallow 692c06d95f build: Fix client and server only builds
Also correct LwIP build directory.
2022-09-27 10:37:38 +01:00
Jon Shallow de1bc9f3cb LwIP: Add in support for client
New demo client app.

Update some of the memory sizes.
New coap_lwip_dump_memory_pools() to dump LwIP memory pool usage.

Add in logic to handle new client sessions.

New coap_io_process() to handle LwIP which can invoke a callback handler
to wait / timeout for the next input handler.
New coap_lwip_set_input_wait_handler() to define this handler.

Update coap_io_prepare_io() to handle LwIP.

Support re-use of pbuf for PDU re-transmissions.

Make sure that NSTART is correctly obeyed.

Build the client with client only libcoap code.

Build the server with server only libcoap code.

Update LwIP source to latest stable release.

Reserve memory for a response PDU.

New coap_lwip(3) man page.

Update directory structures for config files.

Update files contained in "make dist" and check lwip rebuilds
in the github workflows.
2022-09-22 10:14:48 +01:00
Jon Shallow 43bfbea924 Copyright: Update dates to 2022 where appropriate 2022-08-18 13:23:36 +01:00
Jon Shallow 347270b9ab file naming: Rename files to have coap_ prefix
Initial update - rename files that are not subject to any PRs.
2022-07-01 11:36:26 +01:00
Olaf Bergmann 60421db0a5 Add SPDX-License-Identifier to source files
This change adds 'SPDX-License-Identifier: BSD-2-Clause' [1] to
the source code files that originate in the libcoap project.

Note that not all files are tagged because they are pulled in
from other sources and thus may fall under a different license.
More information about these is contained in the LICENSE file.

[1] https://spdx.org/licenses/BSD-2-Clause.html
2021-06-08 18:14:03 +02:00
Jon Shallow 5bcd89da01 handlers: Make parameters const where appropriate
Also remove the unneeded parameters which can easily be derived - e.g context
and token.
2021-04-22 07:18:47 +01:00
Olaf Bergmann 3f7ba0afc8 Bump API version to 3, release candidate 2 2021-04-21 14:38:54 +02:00
Olaf Bergmann 60dd7aa32a [LWIP] Makefile: Fix include path for lwippools.h
Create path for pre-processor includes from LIBCOAP_API_VERSION in
configure.ac. This avoids breaking the example after API version
change.
2021-04-08 14:32:20 +02:00
Jon Shallow 0c031d7904 include: Move header files into libcoap namespace
I.E. '#include "mem.h"' becomes '#include "coap2/mem.h"'

This prevents header name clashes.

Replacement for #487
2021-03-08 16:45:02 +00:00
Jon Shallow c8ab318e48 Ubuntu 20.4: Fix builds as Ubuntu 20.4 will be used by github workflows
.github/workflows/main.yml:

Build all the cmake TLS variants.

CMakeLists.txt:

Add in missing file.

examples/tiny.c:
include/coap2/encode.h:

Move COAP_PSEUDOFP_ENCODE_8_4 functions from encode.h to tiny.c.
Fix COAP_PSEUDOFP_ENCODE_8_4_DOWN 'ls' ordering complaint.

man/examples-code-check.c:

Fix compile warning, allow 'Unused but set variables' in examples and set
-Werror when compling the examples.

examples/lwip/Makefile:

Remove  compilation option -fpack-struct
2021-03-01 15:47:55 +00: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
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 4b072cd706 DISABLE_TCP: Make TCP enabled code checking more rigorous
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.
2020-02-24 09:58:14 +00:00
Jon Shallow 9f9a197e95 Fix -Winline compiler warnings about inlining failed
This is compiler version dependent when doing static inline expansions.

examples/client.c:

Make hex2char() just static.

examples/etsi_iot_01.c:

Make coap_add_payload() just static.

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

Make coap_address_init() an actual function.

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

Expose coap_address_init() as a function.

Makefile.libcoap:

Include address.c as one of the libcoap files for Contiki.

examples/lwip/Makefile:

Include address.o as one of the libcoap files for LwIP.
2019-09-05 13:54:05 +01: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
Olaf Bergmann 50c892fc81 lwip/Makefile: renamed debug.c to coap_debug.c 2019-01-07 09:56:12 +01:00