Commit Graph
38 Commits
Author SHA1 Message Date
Jon Shallow 91000861e1 tinydtls: Update to latest main branch 2023-08-14 09:35:36 +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 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 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 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 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 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 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 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 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
Olaf Bergmann 50c892fc81 lwip/Makefile: renamed debug.c to coap_debug.c 2019-01-07 09:56:12 +01:00
Olaf Bergmann 726a0f74cf lwip/Makefile: fix include path
need to use include/coap2 after API number increment
2018-10-04 14:27:00 +02:00
Jon Shallow 469357b824 BLOCK option support in coap-server
hashkey.[ch] files restored (now prefixed with coap_)
LWIP and Contiki builds now include these files

block.[ch]:
New function coap_add_data_blocked_response() to simplify GET
responses and handle adding in BLOCK2 options as appropriate.
Needs coap_hash() to generate ETag option.

net.c:
Determine if Block2 is in use, and add to coap_add_observer().

resource.[ch]:
Include Block2 request in coap_add_observer().

subscribe.h:
Include Block2 definition in coap_subscriber_t for using during
observe responses.

pdu.h:
Update comment.

coap-client.c:
No longer causes duplicate calls to coap_show_pdu()
(one in library, one in coap-client for the same PDU).

If a block'ed response received and observing, now observing continues.
(Fixes #166).

Send Observe Cancel with Block2 option if -b defined

coap-server.c:
Replaced all option setting, data addition etc. with new
coap_add_data_blocked_response() function in the GET handlers.
(Fixes #246 Issue 2).

Support PUT with BLOCK1.
(Fixes #246 Issue 1).

Add in -N option to send observe responses as non-confirmable.

Handle small wait_ms values correctly (after being decremented) for testing
whether observe should be triggered or not.

Refresh time every second by making COAP_RESOURCE_CHECK_TIME 1

Manuals:
Add in new function coap_add_data_blocked_response()
Update coap_observe with coap_delete_observer(s) functions

Correct example typo and use new function in hnd_get_time().

Add in -N option to coap-server(5)

Be more specific about COAP_RESOURCE_FLAGS_NOTIFY_NON and
COAP_RESOURCE_FLAGS_NOTIFY_CON usage for observe.

Files:
Makefile.am
Makefile.libcoap
examples/client.c
examples/coap-server.c
examples/lwip/Makefile
include/coap/block.h
include/coap/coap_hashkey.h
include/coap/pdu.h
include/coap/resource.h
include/coap/subscribe.h
libcoap-2.map
libcoap-2.sym
man/Makefile.am
man/coap-server.txt.in
man/coap_handler.txt.in
man/coap_observe.txt.in
man/coap_pdu_setup.txt.in
man/coap_resource.txt.in
src/block.c
src/coap_hashkey.c
src/net.c
src/resource.c
2018-09-24 20:49:57 +01:00
Jon Shallow d766f9d8ee Update code to build LwIP and Contiki from the examples directory
Update code to use new APIs
[Some code changes modelled on PR #202, some code being moved between files]
Remove #ifdef WITH_LWIP from coap_io.c as file is not used
Add in resource time to lwip
Update for Travis build
Report on Contiki memory allocate failures to ease debugging
Make the different memory type counts configurable by using the -D option
included in a CFLAGS definition to the ./configure command line

.travis.yml
BUILDING
Makefile.libcoap
examples/contiki/Makefile
examples/contiki/README     new
examples/contiki/server.c
examples/contiki/.gitignore (new)
examples/lwip/Makefile
examples/lwip/README
examples/lwip/lwipopts.h
examples/lwip/server-coap.c
examples/lwip/server.c
include/coap/address.h
include/coap/coap_io.h
include/coap/lwippools.h
include/coap/pdu.h
scripts/build.sh
src/address.c
src/coap_io.c
src/coap_io_lwip.c
src/coap_session.c
src/mem.c
src/net.c
src/pdu.c
2018-07-27 15:30:37 +01:00
chrysn d43d92e40b examples/lwip: depend on coap.h
The handcrafted Makefile will not attempt to build the coap.h, but will
indicate to the user how to generate it.
2016-06-22 12:51:46 +02:00
chrysn 6b6840599a lwip: cleanups of leftover variables and similar compiler warnings
note on coap_read removal: as the lwip implementation currently launches
the package handling right from the recv callback, a coap_read function
is not meaningful (as it is in posix or contiki where it actively
fetches the messages from the network buffer).
2016-06-22 12:38:01 +02:00
chrysn 909d863a4e lwip: Use latest version
This drops the cumbersome mintapif mechanisms from server.c, fixes
header troubles that have popped up probably during the header cleanups,
drops old workarounds and enables IPv6.
2016-06-22 12:37:27 +02:00
Olaf Bergmann 6bf7cdcc45 examples/lwip/Makefile: fixed lwip branch
This example now uses LwIP release 1.4.1 as the devel branch seems
to have disappeared from the git repository. Moreover, we just do
a shallow clone so maybe the server does not kick us that often.
2016-02-16 16:22:45 +01:00
Olaf Bergmann 0afbf5ecba examples/lwip/Makefile: fixed lwip build flags
Since configure does not set WITH_LWIP, we need to tell the compiler.
This change also replaces the deprecated -I. -I- by -iquote.
2016-02-16 15:13:52 +01:00
Olaf Bergmann 78b96e606d Fix lwip example 2015-03-03 22:03:37 +01:00
chrysn 330014445a lwip example updates
* resolve file resolution conflicts between lwip and libcoap in favor of
  lwip by rearranging the makefile

* cover the config.h of a configured base libcoap with the local one
  using the deprecated -I- gcc switch

* enable etharp (no idea why it wouldn't work ootb, the complete
  server.c lwip-contrib copy needs to be reviewed)

* disable optimizations for easier debugging, enable -g3 for macro
  expansions
2015-01-15 13:34:21 +01:00
chrysn af2096a047 add coap to the lwip example 2013-12-09 15:38:55 +01:00
chrysn 691a87d812 minimal server for lwip demo (no coap yet) 2013-12-09 15:38:49 +01:00