Commit Graph
2395 Commits
Author SHA1 Message Date
Jon Shallow aa391b5b76 async: Handle changes to delay when using epoll
Add in new function coap_async_trigger() to immediately release an async
session, rather than using coap_async_set_delay(async, 1).

Add new internal function coap_update_epoll_timer() to reduce code
duplication and use it for the async logic.

Move doing coap_io_prepare_epoll() for every epoll event to just doing it once
outside of the loop.

Update documentation.
2022-04-07 13:14:49 +01:00
obgm 20eac7bd2f Merge pull request #773 from mrdeep1/client_repeat_delay
coap-client.c: Delay sending each request using -G by 1 second
2022-04-07 13:58:12 +02:00
obgm f188ae57d8 Merge pull request #840 from mrdeep1/add_data_leak
block.c: Fix data leak in coap_add_data_large_internal
2022-04-07 13:57:22 +02:00
Jon Shallow 65cba25cc7 coap-client.c: Delay sending each request using -G by 1 second
This then allows any (D)TLS to be set up between sending off the requests and
better demonstrates how this can be done in user code.

Allocate separate data for each post/put PDU.

Hold off on starting timer for next transmission until after response has
been received from the server (handles relatively slow DTLS startup).
2022-04-07 09:45:28 +01:00
Jon Shallow d57d44aa14 block.c: Fix data leak in coap_add_data_large_internal 2022-04-07 09:42:27 +01:00
Olaf Bergmann eb7656850f pdu.h: Add Content-Format for application/ace+cbor
RFC 9200 defines the new media type application/ace+cbor for
Authentication and Authorization in Constrained Environments.  The
CoAP Content-Format value for this media type is registered as value
19.
2022-03-15 13:01:04 +01:00
obgm fe0f4ba236 Merge pull request #835 from mrdeep1/mbedtls_fix
coap_mbedtls.c: Fix return brace location
2022-03-04 08:31:36 +01:00
Jon Shallow c8458f262a coap_mbedtls.c: Fix return brace location 2022-03-03 22:02:51 +00:00
obgm 6afee4a9ec Merge pull request #807 from mrdeep1/mbedtls_tcp_fixes
coap_mbedtls.c: Make TLS error recovery more rigorous
2022-02-24 08:42:21 +01:00
Jon Shallow 583c29fd47 coap_mbedtls.c: Make TLS error recovery more rigorous
Support self-signed certificates that have expired.

Correct variable ret initialization in coap_tls_read().

Catch some additional MbedTLS SSL error codes in do_mbedtls_handshake().
2022-02-23 09:30:30 +00:00
obgm 0ae4d62ff4 Merge pull request #828 from laukik-hase/feature/mbedtls_3x_rng_alt
`coap_prng.c`: Added alternate RNG implementation
2022-02-23 10:04:48 +01:00
obgm ecb931db24 Merge pull request #822 from laukik-hase/feature/mbedtls-3.1.0
`coap_mbedtls.c`: Upgrade to mbedTLS `v3.1.0`
2022-02-23 09:54:40 +01:00
Laukik Hase 02deef8da6 coap_prng.c: Added alternate RNG implementation
- For targets having their own hardware entropy/RNG implementation
  using mbedtls_hardware_poll()
- This change was made as since mbedtls-3.x, passing a RNG function
  to all functions that accept a f_rng parameter is mandatory
2022-02-23 09:40:20 +05:30
Laukik Hase 916a534e17 coap_mbedtls.c: Upgrade to mbedTLS v3.x
- Added MBEDTLS_ALLOW_PRIVATE_ACCESS to access private struct
  members wherever required
- Updated deprecated functions from hashing module
  (E.g. mbedtls_sha256_starts_ret() -> mbedtls_sha256_starts())
- Added mandatory RNG parameter for some functions
  (mbedtls_pk_parse_keyfile(), mbedtls_pk_parse_key())
- Remove support for parsing SSLv2 ClientHello
2022-02-22 15:56:27 +05:30
obgm 9727399c0b Merge pull request #832 from obgm/fix-block2-nullref
block.c: Fix possible null-pointer dereference
2022-02-21 17:41:49 +01:00
obgm ee171b2b8c Merge pull request #826 from mrdeep1/proxy_critical_options
Proxy: Support unknown Critical but Safe-To-Forward options
2022-02-21 17:40:03 +01:00
obgm 52c96ba9b3 Merge pull request #829 from mrdeep1/vs_openssl
coap_openssl.c: Support Microsoft VS builds
2022-02-21 14:44:41 +01:00
Olaf Bergmann b42c184f74 block.c: Fix possible null-pointer dereference
Commit 9cb2f62a3 [1] has introduced library-internal handling of
Block1 and Block2 requests. To add the data to the response body the
function coap_add_data_large_internal() is used.

This change calls the function independent of a Block2 request unless
request is NULL. The response code is set to 500 if
coap_add_data_large_internal() failed.

Fixes Coverity-Id 1514379

[1] https://github.com/obgm/libcoap/commit/9cb2f62a3eef2e0aeb682615b785d4734b473bd4
2022-02-21 14:10:16 +01:00
Jon Shallow df72a53f2d coap_openssl.c: Support Microsoft VS builds
Correct reported errors

Update workflow for ms-build to include OpenSSL.
2022-02-21 12:37:44 +00:00
Olaf Bergmann 0f76881802 autogen.sh: Fix missing file ar-lib
After autogen.sh --clean, all auto-generated files need to be
re-created. Before this has happened, autoreconf complains
with

  configure.ac: error: required file 'ar-lib' not found

and signals an error on exit.

This change fixes the issue by touching ar-lib to force creation of an
empty file if it does not exist. Because autoreconf is called with the
options --force --install, this file will get replaced afterwards.
2022-02-21 13:04:49 +01:00
obgm ce88036fc4 Merge pull request #830 from mrdeep1/distribution
doc/Makefile.am: Include module_api_wrap.h in a distribution
2022-02-21 11:02:39 +01:00
obgm 9a0d1c2fe4 Merge pull request #831 from mrdeep1/warn_error
builds: Set CFLAGS += -Werror in all linux subdirectory compilations
2022-02-21 11:01:35 +01:00
Jon Shallow 19928e81bd builds: Set CFLAGS += -Werror in all linux subdirectory compilations 2022-02-18 14:23:43 +00:00
Jon Shallow b2ad43319a doc/Makefile.am: Include module_api_wrap.h in a distribution 2022-02-18 13:34:24 +00:00
Jon Shallow dfc678c33b Proxy: Support unknown Critical but Safe-To-Forward options
The CoAP Proxy may not know how to handle a Critical option, but if it
is safe to forward it should be able to handle this.

RFRC7252 5.4.1
   Critical/elective rules apply to non-proxying endpoints.  A proxy
   processes options based on Unsafe/Safe-to-Forward classes as defined
   in Section 5.7.

If this is an incoming proxy type request special case any
critical options that are safe to forward.

Track ongoing sessions from an enabled proxy server so unknown critical
response options can be passed back to the originating requestor.

Update coap-server to handle Proxy-Scheme for proxying.

Update tests to use critical option 25 instead of 9.
2022-02-18 12:51:35 +00:00
obgm 69b865cd3b Merge pull request #823 from mrdeep1/pdu_setup_docs
coap_pdu_setup.txt.in: Clarify / more make readable the pdu setup information
2022-02-16 09:15:32 +01:00
Jon Shallow 93f2738c45 coap_pdu_setup.txt.in: Clarify / more make readable the pdu setup information 2022-02-14 17:05:00 +00:00
obgm a5eb61d25d Merge pull request #824 from mrdeep1/windows_2022
github workflow: Support windows-2022
2022-02-10 11:15:30 +01:00
obgm f9c3e13a18 Merge pull request #804 from mrdeep1/insert_option
pdu.c: Fix coap_insert_option with delta = 269
2022-02-10 10:21:43 +01:00
Jon Shallow 5b32d716fa github workflow: Support windows-2022
The provided host for windows-latest is migrating across from
windows-2019 to windows-2022 on github.  This allows things to be built on
a windows-2022 system.
2022-02-09 21:44:37 +00:00
Jon Shallow bd9ced550e pdu.c: Fix coap_insert_option with delta = 269
Fix off-by-one error for option delta = 269.

Correct / clarify the tests in coap_insert_option() when working out extended
option delta for inserting new option.
2022-02-09 16:51:39 +00:00
Olaf Bergmann ba585f848f [OSS-Fuzz] pdu_parse_target.c: Check result of coap_pdu_parse()
When coap_pdu_parse() returns 0, the contents of pdu are undefined and
must not be processed. This change proceeds fuzzer tests only if parsing
succeeded.

Fixes OSS-Fuzz issue 44503 [1]

[1] https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44503
2022-02-09 16:34:35 +01:00
Olaf Bergmann a2e0046c80 [OSS-Fuzz] pdu_parse_target.c: Fix compiler warning
Declare prototype for internal function coap_pdu_encode_header().
2022-02-09 16:32:00 +01:00
obgm afb4f2b7a1 Merge pull request #812 from mrdeep1/multiple_sessions
sessions: Prevent multiple client session confusion
2022-02-09 12:38:35 +01:00
Jon Shallow b3d503cbff sessions: Prevent multiple client session confusion
Prevent multiple coap_new_client_session*() calls that are connecting to
the same server/port being bound to the same local ip/port.

Update logging for session creation / removal to easily differentiate between
sessions that have the same 4-tuple.

Document that coap_new_endpoint() is not required in client based code.

If coap-client '-p port' but not '-a addr' is provided, fix code so that
the port is bound to.

Only remove outstanding CON requests with token matches if there is an
ACK response.

Update the logging to differentiate between the 6 occurrences where the mid
is removed.
2022-02-08 16:52:15 +00:00
obgm 6aa967cee1 Merge pull request #809 from mrdeep1/cmake_tinydtls
cmake_coap_config.h.in: Fix definitions for when building with tinydtls
2022-02-08 15:43:36 +01:00
obgm dc4994f1d1 Merge pull request #821 from mrdeep1/block_docs
coap_block.txt.in: Clarify / more make readable the block handling information
2022-02-08 15:42:36 +01:00
obgm 838b2d9e39 Merge pull request #813 from mrdeep1/pdu_ordering
pdu building: Enforce the application order of building a PDU
2022-02-08 15:42:01 +01:00
Jon Shallow 726b9630e5 coap_block.txt.in: Clarify / more make readable the block handling information 2022-02-08 14:16:27 +00:00
Jon Shallow 756bb04239 pdu building: Enforce the application order of building a PDU
Make coap_add_option() invalid after calling a coap_add_data*() function.
Add in internal support for adding options to PDUs that contain data with
a replacement coap_add_option_internal() function.  Call this new function
in the appropriate places in the libcoap src.

Add coap_log warnings when the application tries to build a PDU in the wrong
order and then return failure.

Update documentation re-inforcing the PDU building order.
2022-02-08 14:14:51 +00:00
obgm 0d6c7d686b Merge pull request #819 from mrdeep1/coap_access_pdu
coap_pdu_access.txt.in: Add in documentation for coap_get_uri_path()
2022-02-07 17:33:00 +01:00
obgm 6504b667d3 Merge pull request #818 from mrdeep1/proxy_uri
proxy_uri: Fix handling the resource for uri path in Proxy-Uri
2022-02-07 17:32:31 +01:00
Jon Shallow c02ca5f097 coap_pdu_access.txt.in: Add in documentation for coap_get_uri_path()
Also document the return values of the various functions.
2022-02-07 14:50:03 +00:00
Jon Shallow aaf6115594 proxy_uri: Fix handling the resource for uri path in Proxy-Uri
If the server recieving a Proxy request determines that it is the final
endpoint of the request, the resource that the request was sent to
was wrong. The update to coap_get_uri_path() fixes this issue.

There is now also parameter support for the proxy definition for the
coap-server where any defined host is treated as being the final endpoint
is in:

  coap-server -P ,

This allows any actual server to be the final endpoint of any proxy request
without have to define all the names or IP addresses that the coap-server is
known by.  Note that if there is nothing following the , (comma), anything
before the , (comma) will never be used.

Documentation updated.
2022-02-07 14:46:46 +00:00
obgm 1fceff7cc3 Merge pull request #814 from mrdeep1/build_version
versioning: Make current git describe available
2022-02-07 14:38:34 +01:00
obgm 5e793d4852 Merge pull request #816 from mrdeep1/coap_encode
coap_pdu_setup.txt.in: Better document coap_encode_var_safe8()
2022-02-07 13:24:47 +01:00
Jon Shallow a8c00f2af9 coap_pdu_setup.txt.in: Better document coap_encode_var_safe8()
Document return value can be 0 for both being valid and returning on error.
Same is true for coap_encode_var_safe().

[Error should assert() by default]
2022-02-02 21:37:54 +00:00
Jon Shallow 64e5641017 versioning: Make current git describe available
Add new function coap_package_build() which returns "git describe --tags"
if available at library build time, else standard package version.

The value of "git describe --tags" is created at run time and passed in as
a compiler -D definition.

Update copyright end dates for updated files.
2022-02-02 11:24:52 +00:00
Jon Shallow 0a16d790ce cmake_coap_config.h.in: Fix definitions for when building with tinydtls
Build the coap_config.h file in the same way that the make system does
without wrapping the definitions with ""
2022-01-01 13:26:08 +00:00
obgm 2a329e1c76 Merge pull request #771 from mrdeep1/server_post
coap-server: Add in POST support for unknown request handler
2021-12-22 15:31:37 +01:00