Commit Graph
2617 Commits
Author SHA1 Message Date
Olaf Bergmann 7791897e8f api-version-bump.sh: Added missing changes for win32
This change adds replacements for additional files in the win32
subdirectory tree according to commit 166ef51e (see [1]).

[1] https://github.com/obgm/libcoap/pull/763
2021-10-18 09:48:56 +02:00
obgm ca3d68e567 Merge pull request #763 from mrdeep1/windows-3
Windows: Update libcoap-2 objects to libcoap-3
2021-10-18 09:46:11 +02:00
Helmut Grohne 4834b86067 pkg-config: Don't use hard coded binary
libcoap3 fails to cross build from source, because configure.ac hard
codes the build architecture pkg-config.
2021-10-18 09:06:58 +02:00
Helmut Grohne d139beab67 pkg-config: Don't use hard coded binary
libcoap3 fails to cross build from source, because configure.ac hard
codes the build architecture pkg-config.
2021-10-18 09:04:24 +02:00
Jon Shallow 166ef51ed1 Windows: Update libcoap-2 objects to libcoap-3 2021-10-10 20:28:54 +01:00
obgm c190c4960f Merge pull request #732 from mrdeep1/doc_modules
doxygen: Tidy up Modules and Files tab information
2021-10-04 17:17:39 +02:00
obgm 26f6ddfd12 Merge pull request #742 from mrdeep1/psk_checks
PSK: Make PSK hint / key / identity retrieval simpler
2021-10-04 08:21:50 +02:00
Jon Shallow 31722c208a PSK: Make PSK hint / key / identity retrieval simpler
Make the retrieval of  PSK hint / key / identity items simpler, remove
duplicate coding, remove a set of memcpy() and handle all these internally
as coap_bin_const_t.

This removes the need for libcoap internally to allocate (potentially
limited) holding space for these items on the stack.

The respective (D)TLS interface modules then convert these items into
the format required for the underlying (D)TLS libraries.

If the underlying (D)TLS library indicates that there is insufficient
space for an item (defined by a max_len type parameter), then the item
is truncated to that size and a warning issued about the provided item
being too large for the underlying (D)TLS library.

The item access functions are now standalone, not indexed through
coap_context_t.
2021-10-01 17:46:56 +01:00
obgm 5d9b29ce65 Merge pull request #756 from mrdeep1/coap_pdu_parse
coap_pdu_parse: Add to public API
2021-10-01 09:33:55 +02:00
Jon Shallow d746fc24e5 coap_pdu_parse: Add to public API 2021-09-30 21:41:53 +01:00
Jon Shallow 0aeb0d6247 doxygen: Tidy up Modules and Files tab information
doc/module_api_wrap.h: New

Used to split modules into Application and Internal only.

include/coap/*.h:

Module (@defgroup) description put into group application_api or internal_api
as appropriate.

Add in @file information if missing.

src/*.c

Add in @file information.
2021-09-30 16:59:04 +01:00
obgm 2952468cc5 Merge pull request #728 from mrdeep1/client_server
client+server: Reduce code size by building libcoap for client or server only
2021-09-30 17:29:15 +02:00
Jon Shallow f026f5701e client+server: Reduce code size by building libcoap for client or server only
Add in new ./configure options --enable-client-mode or
--enable-server-mode which by default are enabled.

If --disable-client-mode is set, then disable all the client specific code.
[ COAP_CLIENT_SUPPORT is not defined ]

If --disable-server-mode is set, then disable all the server specific code.
[ COAP_SERVER_SUPPORT is not defined ]

Functions and variables are only #ifdef'd out in the include/coap3/*_internal.h
files.  They cannot be #ifdef'd out in the other include files as
COAP_CLIENT_SUPPORT and COAP_SERVER_SUPPORT are not available for application
compilations. The result of this is if, say, client only API functons are used
in a server application and COAP_CLIENT_SUPPORT is not defined, there will be
linking issues (missing functions).  Providing stub functions unecessarily
increases the code size.

For coap-server, if it is able to provide proxy support, requires both
COAP_SERVER_SUPPORT and COAP_CLIENT_SUPPORT to set up the ongoing sessions.
So, the build environment deliberatly sets SERVER_CAN_PROXY=0 if
COAP_CLIENT_SUPPORT is not available to allow linking.

Some of the tests have to be disabled if COAP_SERVER_SUPPORT or
COAP_CLIENT_SUPPORT is not set.

Code size change indications

   text    data     bss     sum   filename
 155912    1728   12080  169720   libcoap-3-notls.a
 138300    1728   12080  152108   libcoap-3-notls.a --disable-client-mode
 106734    1632   10304  118670   libcoap-3-notls.a --disable-server-mode

 180485    1733   12080  194298   libcoap-3-openssl.a
 160306    1733   12080  174119   libcoap-3-openssl.a --disable-client-mode
 125543    1637   10304  137484   libcoap-3-openssl.a --disable-server-mode

 181755    1728   12080  195563   libcoap-3-gnutls.a
 160972    1728   12080  174780   libcoap-3-gnutls.a --disable-client-mode
 127178    1632   10304  139114   libcoap-3-gnutls.a --disable-server-mode

 165879    1855   12128  179862   libcoap-3-tinydtls.a
 147022    1855   12128  161005   libcoap-3-tinydtls.a --disable-client-mode
 115618    1759   10352  127729   libcoap-3-tinydtls.a --disable-server-mode

 171690    1728   13744  187162   libcoap-3-mbedtls.a
 152099    1728   13712  167539   libcoap-3-mbedtls.a --disable-client-mode
 118786    1632   11984  132402   libcoap-3-mbedtls.a --disable-server-mode
2021-09-30 16:10:52 +01:00
obgm 1091e59ff4 Merge pull request #747 from mrdeep1/session_release
net.c: Protect against session release in coap_io_do_io()
2021-09-30 16:28:52 +02:00
obgm 9291d40f14 Merge pull request #750 from mrdeep1/log_clashes
coap_debug.h: Allow <syslog.h> to be included before and after <coap3/coap.h>
2021-09-30 16:23:15 +02:00
Jon Shallow a7f53b4d6b coap_debug.h: Allow <syslog.h> to be included before and after <coap3/coap.h>
The syslog LOG_ definitions are defined in <syslog.h> and can be defined in
coap_debug.h (wrapped by a HAVE_SYSLOG_H wrapper to prevent duplicaton).

However, the coding order of
  include <coap3/coap.h>
  include <stdio.h
works, but
  include <stdio.h
  include <coap3/coap.h>
but fails if the application build environment does not define HAVE_SYSLOG_H
(as is the case of the examples in the examples/ directory).

The former "just" happens to work as the values of the variables are the same.

This fix is to remove the coap_log_t enum and replace it by simple #define
if LOG_ALERT etc. is not already defined.

Make coap_log_t int to remove Visual Studio compile warnings.
2021-09-28 12:10:04 +01:00
obgm 0061b3fe07 Merge pull request #739 from mrdeep1/coap_can_exit
doc: Document the coap_can_exit() function
2021-09-28 12:54:54 +02:00
obgm 38fa40857a Merge pull request #701 from mrdeep1/token_handling
coap-client: Add in support for generating multiple requests
2021-09-28 09:35:31 +02:00
obgm 8dbfca8c50 Merge pull request #754 from mrdeep1/tls_no_dtls
DTLS/TLS: Support TLS when DTLS is not enabled
2021-09-28 09:27:47 +02:00
obgm 7da4e5cd14 Merge pull request #704 from mrdeep1/mbedtls_tcp
coap_mbedtls.c: Add in TLS support
2021-09-28 09:27:16 +02:00
Jon Shallow 77f8cf5970 DTLS/TLS: Support TLS when DTLS is not enabled
Add in support for when TLS is enabled, but DTLS is not enabled, specific
to Mbed TLS configurations (ESP-IDF).
2021-09-27 21:33:07 +01:00
Jon Shallow 587de900c2 coap_mbedtls.c: Add in TLS support 2021-09-27 21:20:07 +01:00
obgm 3aa11612c1 Merge pull request #751 from hmalpani/develop
coap_mbedtls.c: Fix build fail with client only mbedtls
2021-09-27 17:50:33 +02:00
Harshit Malpani 94b297aae7 coap_mbedtls.c: Fix build fail for client only mbedtls 2021-09-21 17:20:37 +05:30
Jon Shallow cc2648aef6 net.c: Protect against session release in coap_io_do_io()
Wrap the whole iteration with  coap_session_reference() /
coap_session_release() instead of the individual if() statements within.

coap_io_do_epoll() is already suitably protected.
2021-09-08 14:42:56 +01:00
Olaf Bergmann ca44071b8a net.h: do not include sys/select.h in Windows builds
Windows apparently has no select.h header, therefore it is not
included for Windows builds.
2021-09-01 09:50:45 +02:00
Olaf Bergmann e984f38b8f [DTLS] make buffer sizes for psk and psk_identity configurable
The pre-processor values COAP_DTLS_MAX_PSK and
COAP_DTLS_MAX_PSK_IDENTITY now can be set at build time. Both values
default to 64. Static buffer sizes in the TLS library wrappers are
adjusted accordingly.
2021-09-01 09:35:38 +02:00
Olaf Bergmann 54dbc3eeb8 [RIOT] coap_time.h: fix COAP_TICKS_PER_SECOND for undefined XTIMER_HZ
With ztimer usage, XTIMER_HZ is not defined anymore in xtimer.h. As a
workaround, XTIMER_HZ_BASE is used.
2021-09-01 09:34:47 +02:00
Olaf Bergmann 05e7f12d7c net.h: Include sys/select.h for fd_set 2021-09-01 09:34:47 +02:00
Jon Shallow 25a5990579 doxygen: Fix summary output for manual pages
Fix summary output on manual pages tab for coap-client, coap-rd and
coap-server.

Fix the SEE ALSO output as well in some of the other pages to be consistent.
2021-08-31 16:10:42 +01:00
Jon Shallow a5c0d12354 doc: Document the coap_can_exit() function 2021-08-04 14:14:37 +01:00
obgm 0585fb4398 Merge pull request #731 from mrdeep1/cmake_mac
CMakeLists.txt: Fix macOS builds by checking for if_nametoindex support
2021-08-02 12:22:32 +02:00
obgm 65e380ab83 Merge pull request #733 from mrdeep1/event_enum
coap_event.h: Make coap_event_t an enum
2021-08-02 12:07:55 +02:00
obgm 12eb676fff Merge pull request #736 from mrdeep1/tiny_fix
tiny.c: Fix message id generation
2021-08-02 12:04:20 +02:00
Jon Shallow a1d78d505d tiny.c: Fix message id generation 2021-08-02 10:09:21 +01:00
Jon Shallow 67f189f134 CMakeLists.txt: Fix macOS builds by checking for if_nametoindex support
Set -D__APPLE_USE_RFC_3542=1 if APPLE

Do not install uthash.h.
2021-08-02 09:21:03 +01:00
Jon Shallow 8ce139d349 coap_event.h: Make coap_event_t an enum
examples/coap-client.c:
examples/coap-server.c:

Explicitly define each enum case to remove complier warnings.
2021-07-31 17:08:10 +01:00
obgm a0754473f9 Merge pull request #729 from mrdeep1/observe_fix
resource.c: Delete previous subscription correctly
2021-07-30 17:56:23 +02:00
obgm 320a1e6e0c Merge pull request #727 from mrdeep1/async_mid
async: Correct MID usage in response
2021-07-30 17:27:49 +02:00
Jon Shallow b0ca3ae643 resource.c: Delete previous subscription correctly
Fix the coap_find_observer_cache_key() function comparison to correctly match
previously set up subscription.

Handle NULL return from coap_cache_derive_key_w_ignore().

Update diagnostic logging.

Start the reported Observe value from 2, to remove confusion with the
usage of values of 1 and 0.
2021-07-29 19:36:47 +01:00
Jon Shallow 98b9179d56 async: Correct MID usage in response
There currently are 2 requirements for async (delayed response)

1. Application support to delay separate response while doing other processing
2. Delay any response for random time if receiving multicast request

The MID is used by the client to match initial response (empty ack or
piggy-backed response).  Any subsequent response (usually the separate
response or unsolicited Observe) should have a different MID as generated by
the server (and are matched using the token).

Fix is to move the tracking of the client MID from coap_register_async()
(so 1. is supported correctly) into handle_request() for multicast requests
(so that 2. continues to be supported correctly).

coap_check_async() will then call the appropriate request handler with the
appropriate MID (application different, multicast same).
2021-07-21 15:15:13 +01:00
obgm a80d462ff5 Merge pull request #722 from mrdeep1/lg_xmit_release
RFC7959: session->lg_xmit not being released for a server
2021-07-07 17:22:08 +02:00
Jon Shallow c61748f4dd RFC7959: session->lg_xmit not being released for a server
Following transmission of a large body by a server using BLOCK2,
session->lg_xmit is not getting released. It does get released when the session
is freed off.

A client doing transmission of a large body idoes release session->lg_xmit.

Timeout lg_xmit after 4 * ACK_TIMEOUT seconds after final block is transmitted.
2021-07-07 15:27:06 +01:00
obgm 545fbc6b31 Merge pull request #721 from Delsian/develop
gnutls:  GNUTLS_CRT_RAW not defined
2021-07-07 15:08:10 +02:00
Eug Krashtan 482be755fe gnutls: GNUTLS_CRT_RAW not defined
Old version of GnuTLS, used in Raspbian,  contains no definition
for GNUTLS_CRT_RAW. This patch fixes build error:
`error: ‘GNUTLS_CRT_RAW’ undeclared`

Signed-off-by: Eug Krashtan <eug.krashtan@gmail.com>
2021-07-07 15:59:54 +03:00
obgm 208a2e8b9a Merge pull request #719 from mrdeep1/man_1
man: Update man page documentation
2021-07-06 12:30:28 +02:00
Jon Shallow e0d6477b5e man: Update man page documentation
man/coap.txt.in:

Include all the current man pages

man/coap_block.txt.in:

Clarification updates to handle questions being raised

man/coap_resource.txt.in:

Incoming PDU is now no longer NULL if triggered by Observe.
2021-07-06 11:13:47 +01:00
obgm f7c9b13dd6 Merge pull request #715 from mrdeep1/remove_slash
coap_resource_init: Leading '/' is not required for uri_path
2021-07-01 09:49:56 +02:00
Jon Shallow d52986f004 coap_resource_init: Leading '/' is not required for uri_path
Remind users in the documentation that the full path defining the resource in
the uri_path parameter does not normally need a leading '/'.

E.g. It should be "full/path/for/resource", not "/full/path/for/resource".
2021-06-30 14:05:22 +01:00
obgm 97a2c0f186 Merge pull request #716 from mrdeep1/remove_bad_code
pdu.h: Remove unassigned response code COAP_RESPONSE_CODE_OK
2021-06-30 14:21:11 +02:00