Commit Graph
409 Commits
Author SHA1 Message Date
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
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
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
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
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
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 a5c0d12354 doc: Document the coap_can_exit() function 2021-08-04 14:14:37 +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
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
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
Jon Shallow 60c69557f3 pdu.h: Remove unassigned response code COAP_RESPONSE_CODE_OK 2021-06-30 12:11:54 +01:00
Olaf Bergmann 1da37b9abb Bump version to 4.3.0 2021-06-21 10:39:42 +02:00
Olaf Bergmann 64505862d1 update release version to rc4 in configuration 2021-06-15 10:27:25 +02: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
Olaf Bergmann 677b0c8330 coap.h.windows{,.in}: Remove bits.h 2021-06-08 15:53:23 +02:00
Olaf Bergmann db79086c67 Cleanup: Remove unused header file bits.h
The functions in bits.h have not been used anymore and can be removed.
2021-06-08 15:26:52 +02:00
Olaf Bergmann 44075adb52 uthash: Update URIs to uthash homepage
* Update uthash.h and utlist.h from upstream. These files now include
  the fixed URI to the uthash homepage.
* Update uthash URI in the LICENSE file.
2021-06-08 14:57:16 +02:00
Jon Shallow 8d73044579 coap_send(): Consolidate coap_send() and coap_send_large() for applications
As it is not that intuitive when to use coap_send() or coap_send_large()
in applications, rename libcoap usage of coap_send() to coap_send_internal()
and then all usages of coap_send_large() to coap_send() so that only
coap_send() is required in applications.

Documentation updated accordingly.
2021-05-29 14:08:00 +01:00
Jon Shallow 58fca65ceb net.c: coap_option_check_critical() not updating 'unknown' by ref
'unknown' is updated by coap_option_check_critical if there is a critical
option, but as it is not passed in by reference, any caller does not see
any change to 'unknown'.

Pass in 'unknown' by reference.

Issue got missed in change e2e7830
2021-05-26 14:57:48 +01:00
Jon Shallow f726d0460a Observe: Support FETCH with data for triggered responses
The original requesting PDU is now kept with the Observe request along with
its data and used whenever an additional response needs to be generated.

Abstracted information from the requesting PDU is no longer kept in
coap_subscription_t as it can be obtained from the kept PDU.

No longer any need to check for request PDU in request handlers as it is now
always provided.

coap_resource_notify_observers() now ignores the query parameter, as a
cache_key is now used for request matching.
2021-05-21 13:08:11 +01:00
Jon Shallow aaf4d874d4 TLS Support: Move common TLS support descriptions into libcoap
Added new function coap_string_tls_support() for outputting what key types the
TLS library supports to remove duplicated code out of the examples.
2021-05-12 18:02:37 +01:00
Olaf Bergmann 4214760117 update release version to rc3 in configuration 2021-04-30 09:46:10 +02:00
Olaf Bergmann 2cae4ff662 coap_resource_internal.h: include uthash.h 2021-04-29 12:41:33 +02:00
Olaf Bergmann 07ac47ae73 resource.h: remove uthash from public API
As the uthash macros have been moved to coap_resource_internal.h by
PR #582 [1], see commit da18643, the convenience macros and uthash.h
inclusion can be removed from resource.h

[1] https://github.com/obgm/libcoap/pull/582
2021-04-29 12:41:33 +02:00
Jon Shallow 14cf0fe9e5 struct: Remove struct prefix for structures that are typedef'd 2021-04-26 16:52:14 +01:00
obgm 8c4a566313 Merge pull request #661 from mrdeep1/const_pdu
net.h: Make request PDUs const in functions
2021-04-26 17:32:48 +02:00
Jon Shallow 17b7c13435 net.h: Make request PDUs const in functions
Now that coap_method_handler_t passes in the request PDU as const, make
functions that have request PDUs as a parameter const for that parameter.
2021-04-26 08:00:26 +01:00
Jon Shallow f436961084 coap_session.c: Correct coap_session_get_max_retransmit() name
Make things consistent.
2021-04-23 09:11:19 +01:00
Jon Shallow 23f8a531b1 Nits: Fix documentation
Remove a duplicate definition.
2021-04-22 16:47:35 +01: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 2e54ca5252 pdu.[hc]: make token argument const in coap_pdu_duplicate() 2021-04-21 14:38:54 +02:00
Olaf Bergmann 3f7ba0afc8 Bump API version to 3, release candidate 2 2021-04-21 14:38:54 +02:00
Jon Shallow 84a69c7436 tls: Update coap_session_get_tls() to return actual TLS information 2021-04-21 09:25:57 +01:00
obgm 75a41b7aed Merge pull request #650 from mrdeep1/lwip_warnings
lwip: Fix compiler warnings
2021-04-21 09:52:11 +02:00
Jon Shallow ac7ad8cd46 lwip: Fix compiler warnings
There still is a #warning for inet_ntop().
2021-04-20 20:08:03 +01:00
Jon Shallow ab78bc8254 coap_dtls.h: Move internal structures and functions int coap_dtls_internal.h
This removes the functions etc. being available in the standard header files,
but not available in the dynamic library.
2021-04-20 17:05:38 +01:00
obgm 04c641f7f0 Merge pull request #639 from mrdeep1/obf_pdu_t
coap_pdu_t: Obfuscate coap_pdu_t for applications
2021-04-20 15:22:08 +02:00
Olaf Bergmann 9e3ba503ec coap_dtls.h: Fix doxygen warning
This change removes a doxygen comment starter because doxygen is
getting confused otherwise because of the immediately preceding
documentation group start.
2021-04-20 14:15:51 +02:00
Jon Shallow e4e067e5fb coap_pdu_t: Obfuscate coap_pdu_t for applications
Move coap_pdu_t to coap_pdu_internal.h.

Move internal PDU based function definitions to coap_pdu_internal.h.

Replace most references to "struct coap_pdu_t" with "coap_pdu_t".

Create new enum coap_pdu_type_t, enum coap_pdu_code_t and coap_option_num_t,
using them where appropriate for clarity of documentation.

Provide new functions to allow applications to access/update parts of
coap_pdu_t as appropriate and document as appropriate.

Update examples to use these new access functions where appropriate.
2021-04-20 10:31:14 +01:00
Olaf Bergmann fd5ecf5697 Add in configuration option for async (separate responses)
The new configuration option --disable-async now allows to switch
of support for asynchronous operations.

The new function coap_async_is_supported() can be used to check
if the library was built with async support.
2021-04-20 10:36:48 +02:00
obgm b9989ef485 Merge pull request #645 from mrdeep1/mcast_delay
Multicast: Add in response delay
2021-04-20 10:31:57 +02:00
Jon Shallow e008d905fd Multicast: Add in response delay
See https://tools.ietf.org/html/rfc7252#section-8.2

Also updated coap_find_async() to search on token instead of mid as
mid is not used in reliable transports.
2021-04-19 11:09:19 +01:00
Jon Shallow 028b3062f6 internal structs: Obfuscate coap_packet_t and coap_socket_t for applications
Move coap_socket_t and coap_packet_t to coap_io_internal.h.

Move internal io based function definitions to coap_io_internal.h.

Replace most references to "struct coap_socket_t" with "coap_socket_t" and
references to "struct coap_packet_t" with "coap_packet_t".
2021-04-16 22:08:10 +01:00
obgm d9ff2f0ff7 Merge pull request #630 from mrdeep1/obf_async_t
coap_async_state_t: Obfuscate coap_async_state_t for applications
2021-04-16 20:13:23 +02:00
Olaf Bergmann 1b15bf244f coap_net_internal.h: add missing doxygen group end marker 2021-04-16 18:27:55 +02:00