Commit Graph
2046 Commits
Author SHA1 Message Date
obgm 85c6e0038c Merge pull request #602 from mrdeep1/fix_rebase
resource.h: Remove function definitions that are duplicated
2021-02-26 09:16:43 +01:00
obgm 9f1d96a829 Merge pull request #600 from mrdeep1/github_workflows
workflow: Add in distribution and CMake checks
2021-02-26 08:46:53 +01:00
Jon Shallow 669400665d resource.h: Remove function definitions that are duplicated
Result of a rebase confusion.

include/coap2/resource.h:

Remove duplicates that are also in coap_subscriber_internal.h.

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

Remove the now internal only functions.
2021-02-25 16:35:59 +00:00
Jon Shallow dc6c5e6b00 workflow: Add in distribution and CMake checks
.github/workflows/main.yml:

Do a 'make check' for matrix builds.
Move documentation into separate job to reduce matrix build times
Add in CMake job.
Add in distribution job.
Add in tinydtls job.
Add in contiki/lwip job.

scripts/github_dist.sh:

Do the distribution checks using a script.

examples/etsi_iot_01.c:
examples/tiny.c:

Fix include coap.h directory in old examples.

README.md:

Update status badges to get only the branch actions and remove CMake
status badge.
2021-02-24 18:15:25 +00:00
obgm cea89718e9 Merge pull request #582 from mrdeep1/obfuscate_resource
coap_resource_t: Obfuscate coap_resource_t from applications.
2021-02-24 17:53:29 +01:00
Jon Shallow da18643702 coap_resource_t: Obfuscate coap_resource_t from applications.
Create a new include/coap2/coap_resource_internal.h to hold all the information
not available to applications.

Makefile.am:

Include coap_resource_internal.h in EXTRA_DIST.
Remove functions no longer visible from CTAGS_IGNORE.

examples/coap-rd.c:
examples/contiki/server.c:
examples/etsi_iot_01.c:
tests/test_wellknown.c

Replace direct access to coap_resource_t variables with functions as
appropriate.

include/coap2/resource.h:
include/coap2/subscribe.h:
include/coap2/coap_resource_internal.h: (New)
include/coap2/coap_subscribe_internal.h:

Move coap_resource_t, coap_addr_t, non API #defines and non API functions from
resource.h into coap_resource_internal.h, coap_subscribe_internal.h and
subscribe.h.

Replace inline functions accessing coap_resource_t with actual function
definitions.

Add new functions coap_resource_release_userdata_handler() and
coap_attr_get_value().

include/coap2/block.h:

Use coap_resource_t typedef.

include/coap2/coap_forward_decls.h:

Include coap_resource_t and coap_addr_t typedefs.  Also typedef coap_context_t
to get rid of #include circular requirements.

include/coap2/coap_internal.h:
win32/libcoap.vcxproj:
win32/libcoap.vcxproj.filters:

Include coap_resource_internal.h.

include/coap2/net.h:

Remove "typedef struct coap_context_t" and do this in coap_forward_decls.h.

src/resource.c:

Update with the replaced inline functions. Add in the new functions
coap_resource_release_userdata_handler() and coap_attr_get_value().

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

Update with new function visibility.

man/Makefile.am:
man/coap_attribute.txt.in:
man/coap_observe.txt.in:
man/coap_resource.txt.in:

Update with the new coap_resource_t and coap_attr_t usage.
2021-02-24 16:34:27 +00:00
obgm b0e47d71d0 Merge pull request #580 from mrdeep1/with_observe
Observe: Remove WITHOUT_OBSERVE conditional statements in the library.
2021-02-24 09:52:33 +01:00
obgm 8724c0c372 Merge pull request #578 from mrdeep1/icmp_issue_nack_handler
ICMP reporting: Call nack handler when ICMP unreachable is received
2021-02-24 09:22:57 +01:00
obgm 35dbc32708 Merge pull request #577 from mrdeep1/observer_fix
Observe: Fix coap_free_context() assert when active observe
2021-02-24 09:14:42 +01:00
obgm 7c54bd748f Merge pull request #554 from mrdeep1/add_data_large
RFC7641: Move block handling logic down into libcoap
2021-02-24 09:09:01 +01:00
Jon Shallow 4cd633e763 RFC7641: Add in example support using updated libcoap handling of blocks
Remove block handling logic from coap-client and coap-server and make use of the
new libcoap functionality.

Add in new -L option to be able to define how libcoap is to work with block
handling.  Update documentation accordingly.
2021-02-23 18:01:14 +00:00
Jon Shallow 9cb2f62a3e RFC7641: Move block handling logic down into libcoap
This change removes the need for applications having to know about handling
requests for the next block etc.  It also gives the application the ability
to pass a large body of data to be transmitted and be told when this body is
no longer required.

This logic is enabled in libcoap by setting COAP_BLOCK_USE_LIBCOAP using
coap_context_set_block_mode()

This change breaks down into 4 specific areas

1) Client doing a PUT/POST etc. of a large amount of data (BLOCK1).

coap_add_data_large_request() is used which provides a 'finished with data'
callback function as well as adding required options to the PDUs.  This
function calls coap_add_data_large_internal().

Internal coap_handle_response_send_block() sends off the subsequent blocks
(using session->lg_xmit).

2) Server receiving PUT/POST etc. of a large amount of data (BLOCK1).

Internal coap_handle_request_get_block() acknowledges the appropriate blocks
(using session->lg_srcv) and either passes in the individual blocks or the body
depending on whether COAP_BLOCK_SINGLE_BODY is set or not using
coap_context_set_block_mode().

3) Server sending a large data response to GET / observe (BLOCK2)

coap_add_data_large_response() is used which provides a 'finished with data'
callback function.  This function calls coap_add_data_large_internal() as well
as filling in the necessary options for each PDU.

Interal coap_handle_request_send_block() will then send the next requested block
(using session->lg_xmit).

4) Client receiving a large data response (BLOCK2)

coap_send_large() for the initial request sets this up.

Internal coap_handle_response_get_block() will then request the next block when
previous block received (using session->lg_crcv) and either passes the
individual blocks or the body depending on COAP_BLOCK_SINGLE_BODY being set in
coap_context_set_block_mode().

----

The following new internal functions have been added

coap_handle_request_get_block()
coap_handle_request_send_block()
coap_handle_response_get_block()
coap_handle_response_send_block()
coap_add_data_large_internal()

The following new functions have been added.

coap_add_data_large_request()
coap_add_data_large_response()
coap_context_set_block_mode()
coap_get_data_large()
coap_pdu_duplicate()
coap_send_large()
coap_session_init_token()
coap_session_new_token()

The coap_session_init_token() and coap_session_new_token() were added to make
the handling of unique tokens for each request/response easier.
https://datatracker.ietf.org/doc/html/draft-ietf-core-echo-request-tag-10#section-4

New files

include/coap2/coap_block_internal.h:
man/coap_block.txt.in:

New memory types

COAP_LG_XMIT
COAP_LG_SRCV
COAP_LG_CRCV
2021-02-23 18:01:04 +00:00
obgm b7fed2a706 Merge pull request #571 from Delsian/develop
refactor: replace magic numbers with defines
2021-02-23 17:50:06 +01:00
Olaf Bergmann 528c0293b7 README.md: Update build status badges
As travis-ci gets not triggered anymore, continuous integration has
been changed in commit 57a5a7e0 to use GitHub Actions. This change
updates the build status badges to report the GitHub Actions result
for the branches master and develop.
2021-02-23 10:56:28 +01:00
Eug Krashtan 6b58bfa96c examples: replace magic numbers with defines
CoAP response codes in examples represented by non-human-readable magic
numbers. It makes code harder to read, understand, and maintain.
Magic numbers there where replaced by human-readable enums.

Signed-off-by: Eug Krashtan <eug.krashtan@gmail.com>
2021-02-22 21:20:31 +02:00
obgm f249117691 Merge pull request #579 from mrdeep1/keepalive_doc
DOC: Clarify coap_keepalive(3) documentation
2021-02-22 17:54:59 +01:00
obgm e42d7b7725 Merge pull request #598 from mrdeep1/mbedtls_version
configure.ac: Determine Mbed TLS library version for validity
2021-02-22 14:11:46 +01:00
Jon Shallow febed37ebf configure.ac: Determine Mbed TLS library version for validity
configure.ac:

Add in explicit library version checking as .pc file is not available.

m4/ac_check_cryptolibs.m4:

Add in AX_CHECK_MBEDTLS_VERSION for checking version compatibility.

configure.ac:
src/coap_mbedtls.c:

Correct brand name to Mbed TLS.
2021-02-20 11:08:29 +00:00
obgm 9f778cabca Merge pull request #583 from mrdeep1/doxygen_update
doxygen: Tidy up comments and add in missing modules
2021-02-19 16:04:13 +01:00
obgm 6a087687e8 Merge pull request #574 from mrdeep1/mbedTLS_naming
Mbed TLS: Update MbedTLS and mbedTLS to Mbed TLS to reflect brand name
2021-02-19 10:00:16 +01:00
obgm a15b3006d4 Merge pull request #561 from mrdeep1/tls_options
PKI: Make (D)TLS operation consistent across all TLS libraries
2021-02-19 09:48:55 +01:00
Jon Shallow 05d30e5ef1 PKI: Make (D)TLS operation consistent across all TLS libraries
The use of the verify_peer_cert and require_peer_cert variables in the
coap_dtls_pki_t structure was giving inconsistent results across all the
TLS libraries.  This primarily was down to the large numbers of options
available to control the TLS handshakes in OpenSSL compared to the limited
control available to mbedTLS port which followed later. require_peer_cert is
not easy to control in mbedTLS as it is an implicit configuration based on how
other, not always related, items were configured.

require_peer_cert was used by the server to control whether the client could
use anonymous certificates or not.  This is now controlled by verify_peer_cert.

require_peer_cert variable has been replaced with check_common_ca, so that
the OpenSSL functionality can continue, but enable GnuTLS / mbedTLS to
produce the same results.  This allows peers to mutually authenticate (because
the peer certs are signed by the same common CA) or not which was in effect
controlled by verify_peer_cert previously.

If check_common_ca is set, then allow_self_signed is ignored.

If is_rpk_not_cert is set, then all certificate validation is ignored.

In the examples, use of the -R option unsets check_common_ca, so disables
mutual authentication support by having a common CA.  This was needed as
mbedTLS and GnuTLS only have a single trust store for CAs.

configure.ac:

Increase the number of mbed libraries to use when checking for mbedTLS.

examples/client.c:
examples/coap-rd.c:
examples/coap-server.c:

Add in -n (unset verify_peer_cert) option. In the case of coap-server and
coap-rd, make -n refer to verify_peer_cert.
Add in TLS library capabilites in usage().

Update usage() documentation as appropriate, with some changes to fit
everything into a 80 column output.

include/coap2/coap_dtls.h:
include/coap2/net.h:

Update with variable changes, and make the coap_dtls_pki_t parameter const for
the *_context_set_pki() functions.

man/coap-client.txt.in:
man/coap-rd.txt.in:
man/coap-server.txt.in:

Update documentation to reflect the examples option usage.

man/coap_context.txt.in:
man/coap_encryption.txt.in:
man/coap_session.txt.in:

Update with the new variable name and document as appropriate.

src/coap_gnutls.c
src/coap_mbedtls.c
src/coap_notls.c
src/coap_openssl.c
coap_tinydtls.c

Update to make variable usage consistent. Update logging from LOG_WARNING to
LOG_INFO where there is an override of a PKI check failure by one of the
coap_dtls_pki_t variables.

Timing window closed for TLS where the peer does not like a certificate, sends
fatal alert and closes connection.  local then fails on writing the next
handshake - but now also reads in alert and reports on it.

src/coap_io.c:

Update logging from LOG_WARNING to LOG_INFO for EPIPE or ECONNRESET errors in
coap_socket_write().

src/net.c:

Handle the const coap_dtls_pki_t parameter in coap_context_set_pki() function.
2021-02-18 16:51:32 +00:00
obgm df6615bef5 Merge pull request #597 from mrdeep1/easier_troubleshoot
message id: Report everywhere the hex value for consistency
2021-02-16 10:08:23 +01:00
Jon Shallow 2e6cb55a50 message id: Report everywhere the hex value for consistency
coap_show_pdu() reports the Message ID (mid) as a hex value prefixes by i:.
Elsewhere it is reported as an integer or unsigned making those entries
difficult to match up with the reported PDU.

examples/coap-rd.c:
examples/etsi_iot_01.c:
src/async.c:
src/coap_session.c:
src/net.c:

Replace tid=%d, message %d and transaction %d with mid=0x%x for clarity.
2021-02-15 09:47:02 +00:00
obgm 475654021e Merge pull request #595 from mrdeep1/coap_prng_impl
coap_prng.c: Fix missing coap_prng_impl function.
2021-02-15 10:05:33 +01:00
Jon Shallow b0d46deef6 coap_prng.c: Fix missing coap_prng_impl function.
PR #590 unfortunately broke the standard builds.
2021-02-13 10:57:34 +00:00
obgm 9b45575cdf Merge pull request #586 from timgates42/bugfix_typo_updated
docs: fix simple typo, udated -> updated
2021-02-12 15:28:24 +01:00
obgm 85b45e0249 Merge pull request #590 from wenwu-glagle/pull_request
Fix some compile error in windows visual studio
2021-02-12 15:25:28 +01:00
Olaf Bergmann 4185e6215f [CI] main.yml: Enable building on all relevant events and branches 2021-02-12 13:01:39 +01:00
Olaf Bergmann 961afc742e [CI] main.yml: Set -Werror in compile matrix 2021-02-12 12:44:50 +01:00
Olaf Bergmann 16ea2dca63 [CI] main.yml: Enable more checks 2021-02-12 12:44:47 +01:00
Olaf Bergmann 391be3176e [CI] main.yml: Run unit tests with valgrind 2021-02-12 12:40:44 +01:00
Olaf Bergmann 57a5a7e089 [CI] main.yml: basic build steps 2021-02-12 12:09:01 +01:00
Olaf Bergmann 5bcb0a1578 Revert ".github: removed consistently failing github workflow"
This reverts commit 610c3f6bf2.
2021-02-12 12:09:01 +01:00
Olaf Bergmann 2df4850180 net.c: Suppress warning for -Wunused-result
On systems where read() is declared with the attribute
warn_unused_result, a cast to void is not sufficient to suppress the
resulting warning. This change therefore checks the result explicitly.
2021-02-12 12:06:51 +01:00
Olaf Bergmann f681525272 coap-server.c: fix typecast warning for verify_cn_callback
This change fixes a warning output by clang for the cast from void* to
the potentially smaller enum coap_dtls_role_t (-Wvoid-pointer-to-enum-cast).
2021-01-13 15:56:28 +01:00
Olaf Bergmann 238fded2d8 pdu.c: fix heap overflow in coap_pdu_parse_opt()
coap_opt_length() must be called next_option_safe() to avoid
out-of-bound reads for malformed options.

Thanks to Marten Geuking for providing a detailed bug report.
2021-01-13 15:34:09 +01:00
obgm 7e6b2a9ec3 Merge pull request #589 from mrdeep1/now_2021
Update general copyrights to 2021
2021-01-07 12:05:37 +01:00
沈文武 ad01c1d5eb Fix some compile error in windows visual studio
1. since coap_add_option_later() has been removed, so remove
coap_add_option_later in lib-coap-2.(map,sym) and pdu.h
2. [PRNG] need include coap_prng.c into visual studio project too, since new
functions for generating pseudo numbers replace the old macro-based
approach.
3. [PRNG] need define coap_prng() coap_prng_init() coap_set_prng() for
windows too since these function are exported in lib-coap-2.(map,sym)
2021-01-06 10:47:24 +08:00
Jon Shallow 12fd8a25f7 Update general copyrights to 2021
Update main copyright statements to 2021.
2021-01-04 10:37:05 +00:00
Jon Shallow f4d4cd60d8 Mbed TLS: Update MbedTLS and mbedTLS to Mbed TLS to reflect brand name
LICENSE:
README.md:
include/coap2/coap_dtls.h:
man/coap_encryption.txt.in:
man/coap_tls_library.txt.in:
src/coap_debug.c:
src/coap_mbedtls.c:

Replace MbedTLS and mbedTLS with "Mbed TLS".
2021-01-04 10:18:26 +00:00
Tim Gates 3e437e6910 docs: fix simple typo, udated -> updated
There is a small typo in include/coap2/coap_asn1_internal.h.

Should read `updated` rather than `udated`.
2020-12-20 07:32:03 +11:00
Jon Shallow 74fbbd3d55 doxygen: Tidy up comments and add in missing modules
Make documentation more consistent across doxygen output.

Add in caching module.
Add in encoding/decoding module.
Add in application i/o internal module.

Move deprecated items out of respective modules.
2020-12-16 12:26:45 +00:00
Jon Shallow a12e573046 Observe: Remove WITHOUT_OBSERVE conditional statements in the library.
As RFC7641 is now fully supported, these code segments should always be
compiled in and WITHOUT_OBSERVE wrappers are no longer required.

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

Remove WITHOUT_OBSERVE wrappers.

include/coap2/async.h:

Correct definition for coap_async_state_t and remove references for
supporting observing as this is no longer supported.
2020-12-09 11:06:49 +00:00
Jon Shallow 28ef9c4d51 DOC: Clarify coap_keepalive(3) documentation
Tidy up coap_keepalive(3) documentation.
2020-12-08 20:02:35 +00:00
Jon Shallow 704057e683 ICMP reporting: Call nack handler when ICMP unreachable is received
coap_session_disconnected() does not call the nack handler for any outstanding
CON requests when called with COAP_NACK_ICMP_ISSUE.

src/coap_session.c:

Call the nack handler if coap_session_disconnected is called with
COAP_NACK_ICMP_ISSUE.
2020-12-08 16:48:52 +00:00
Jon Shallow 9de0ff377a Observe: Fix coap_free_context() assert when active observe
src/net.c:

Call coap_delete_all_resources() (which may send a CON observe bumping a
session ref count) before coap_delete_all() to remove any CON transmissions
that are still in flight in cop_free_context().

src/resource.c:

Delete observer if GET handler does not return a 2.xx code.
2020-12-08 16:38:25 +00:00
obgm f29f053d53 Merge pull request #569 from mrdeep1/cmdline_read_user
cmdline_read_user: Fix NULL terminating code
2020-11-13 22:58:59 +01:00
Olaf Bergmann 5aa8d0c6a8 .gitignore: ignore autosave files 2020-11-13 22:57:08 +01:00
obgm 3650f6e8c3 Merge pull request #515 from mrdeep1/cygwin
Cygwin: Add in compiler support
2020-11-13 22:21:05 +01:00