Commit Graph
23 Commits
Author SHA1 Message Date
Jon Shallow b442140bb3 Oscore: Change HAVE_OSCORE define to COAP_OSCORE_SUPPORT for clarity
Prevents possibility of name clashes when integrating with other code.
2023-06-14 12:55:25 +01: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 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
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 91737ccb46 versioning: Include api version in non-posix coap_config.h/coap.h .in files
Add in some new .in files, but still keep original files in distribution
files.

Essentially, use coap@LIBCOAP_API_VERSION@ (or equivalent) instead of
coap2. so resultant files have the correct value.

coap_config.h.lwip.in: (new)
coap_config.h.riot.in: (new)
include/coap2/coap.h.windows.in: (new)

As per https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html, many of the
coap2/ prefixes are not required for #include, so these have been removed.

Make sure that the test suite accesses the latest source version of
coap@LIBCOAP_API_VERSION@/coap.h by creating a tests/test_common.h.in that
makes the correct tests/test_common.h which is included in all of the test
suite files.
2021-04-07 13:01:42 +01:00
obgm ae752e9e7a Merge pull request #612 from mrdeep1/coap_unused
COAP_UNUSED: Remove UNUSED and UNUSED_PARAM and use COAP_UNUSED instead
2021-03-08 18:43:45 +01: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 4a264b2b4c COAP_UNUSED: Remove UNUSED and UNUSED_PARAM and use COAP_UNUSED instead
Remove the UNUSED and UNUSED_PARAM definitions and use a single definition
of COAP_UNUSED as defined in libcoap.h

Replace all UNUSED / UNUSED_PARAM usages with COAP_UNUSED.
2021-03-05 11:49:34 +00:00
Olaf Bergmann 7858c57919 Add unit tests for coap_encode/decode_var_safe/safe8 2019-10-02 16:57:57 +02:00
Olaf Bergmann 8f9ca22e05 tests: add unit tests for session handling
This change adds an initial set of unit tests for sessions:

* reference counting and release
* timeout calculation
2018-03-06 16:45:28 +01:00
Olaf Bergmann c74e1da5a9 tests: add unit test boilerplate for (D)TLS
A simple structure for (D)TLS-specific unit tests has been added.
Currently, only general support and the version number as reported
by coap_get_tls_library_version() are checked.
2018-02-14 17:28:37 +01:00
jcmichelou 9b647d5d05 Add visual studio 2015 solution and project files for building libcoap on windows.
Merge changes from PR #47 related to windows platform support.
Add full windows platform support including correct error checking and working regression tests and examples.
Remove need to build applications using libcoap with -DWITH_POSIX and to include coap_config.h. This applies to the examples as well.
2017-05-05 20:29:10 +02:00
Olaf Bergmann 83c17e8f17 testdriver.c: Remove comment on known bugs
With commit eec9ad2, the two outstanding bugs in the test suite
have been fixed.
2015-06-07 12:21:57 +02:00
Olaf Bergmann eb2251f06f Update boilerplate text in testdriver
The errors in the URI parser test suite have been fixed,
making the description in testdriver.c obsolete.
2015-03-09 18:30:20 +01:00
Olaf Bergmann fa3f09cdb7 Fix warnings in unit tests 2015-03-04 15:10:09 +01:00
Olaf Bergmann 652bdd5f63 resolved conflict after cherry-picking from branch relative-timestamps 2014-02-05 15:04:39 +01:00
Olaf Bergmann 05713f48e8 Unit tests for the new functionality of coap_print_link() and print_wellknown() 2014-01-07 17:37:49 +01:00
Olaf Bergmann ada296efaf added new test cases for error response generation
test t_error_response8 will fail when COAP_MAX_OPT < 2000
2013-09-03 14:07:16 +02:00
Olaf Bergmann 3e0c8280c9 more tests 2013-01-15 16:51:12 +01:00
Olaf Bergmann cd10925056 modified option parser 2013-01-11 11:32:22 +01:00
Olaf Bergmann 019a922918 document known bugs 2013-01-07 17:48:09 +01:00
Olaf Bergmann c6412f2038 Rework of option parser to support "Klaus encoding" (coap-13), unit tests
The subdirectory "tests" now contains a growing set of unit tests for the
libcoap API. To use this, you will need CUnit (see http://cunit.sourceforge.net)
and must configure with the option --with-tests.
2013-01-07 17:37:49 +01:00