Commit Graph
183 Commits
Author SHA1 Message Date
Jon Shallow 707aed35d3 Doxygen: Hyperlink man page functions
Where functions are referred to in the man pages, hyperlink them for
easy cross reference.
2022-08-26 17:37:41 +01:00
Jon Shallow 46feac2455 Misc: Tidy up documentation and space usage 2022-08-24 17:55:43 +02:00
Olaf Bergmann ea89cb842c coap_cache.txt.in: Fix typo in function name 2022-08-22 15:31:11 +02:00
Jon Shallow 43bfbea924 Copyright: Update dates to 2022 where appropriate 2022-08-18 13:23:36 +01:00
Jon Shallow 37731524a0 RFC8516: Document support 2022-08-18 13:22:18 +01:00
Jon Shallow f4507e6e9a Block: Report event on large xmit failures
Add in new event COAP_EVENT_XMIT_BLOCK_FAIL which gets triggered on
detecting transmission failure of large body using BlockX.

Track the last time a lg_xmit was sent, so it can be timed out on failure.

Correctly track the next lg_xmit timeout time (and lg_crcv, lg_srcv) so that
the lg_xmit can be expired.
2022-08-13 14:28:38 +01:00
Jon Shallow 0f0cac71f5 Observe: Support disabling observe cancellation on session close
Add in a new function coap_session_set_no_observe_cancel() to support this.
2022-08-08 10:19:38 +01:00
Jon Shallow 415fbdb7cd RFC9175: Add in support for the Echo and Request-Tag options
A unique Request-Tag is added to any PUT/POST/FETCH request that contains
a large body.  The server is then able to differentiate between concurrent
sending of large data using the same session.

If a server responds with a 4.01 and includes an Echo option, then the libcoap
client retransmits the request adding in the received Echo option with the same
value.

If the server responds normally with an Echo option, then the next request
from the libcoap client (internally added by libcoap) will contain that Echo
option.

It is the responsibility of the server application to add in the Echo
option if required and validate the next request unless the Echo is triggered
by OSCORE (RFC8613 Appendix B.1.2).
2022-06-22 15:08:47 +02:00
Jon Shallow 88ae9563e6 mcast support: Support multicast granular to the resource level
Add in new function coap_mcast_per_resource() to enable granularity of
handling multicast requests differently at the resource level.

The granularity is handled by how the flags variable is set up in
coap_resource_init().  These additional flags are ignored if
function coap_mcast_per_resource() has not been invoked.

Added 2 functions coap_resource_unknown_init2() and
coap_resource_proxy_uri_init2() that support defining the mcast flags as
per coap_resource_init().

Responses are now delayed rather than the request being delayed before being
passed to the request handler.

Update coap-server with the -r option to enable multicast on specific
resources.

Do not reset wait_ms in coap-client for Block2 transfers.
2022-06-22 15:08:26 +02:00
Jon Shallow 5a10ce4890 Congestion Control: add in RFC7252 configuration flexibility
Create where appropriate default values for the Congestion control base
values and update the derived CC values accordingly.

Move derived value #define to coap_session_internal.h.

Update coap_session_t to hold the new CC values.

Update documentation for the new CC functions that update / get the
appropriate values.

NOTE: PROBING_WAIT is not currently checked in the code.
2022-06-17 12:15:19 +02:00
Jon Shallow 279755b1df coap_send: Make error checks for coap_send() more rigorous
Always delete PDUs on error before return from coap_send() (aligning with
previous documentation).

Check that the socket is still available before continuing with the PDU
transmission in coap_send().

Update documentation to be clearer on non-usage of PDU on return from
coap_send().

Trap coap_send() errors in coap-client.

Move event handlers setup code to earlier in coap-client to trap events
early on in the CoAP setup process.
2022-06-17 11:34:41 +02:00
mrdeep1 4cad453197 Merge pull request #778 from mrdeep1/coap_io_prepare_io
coap_io_prepare_io: Re-order function code for correctly updating sockets[]
2022-06-14 10:22:06 +01:00
mrdeep1 c74b3efcb4 Merge pull request #744 from mrdeep1/cache_caution
Caching: Highlight requirements ignoring certain CoAP Options
2022-06-07 20:28:34 +01:00
Jon Shallow 445a9481de RFC7390: Update support for RFC7390
Update documentation and add in missing content-format.
2022-05-26 21:10:29 +01:00
Jon Shallow 21fd838dc7 coap_io_prepare_io: Re-order function code for correctly updating sockets[]
Two cases for not updating active sockets[] with file descriptors from a
session (non epoll code)
  coap_retransmit() can release a session
  coap_dtls_handle_timeout() can disconnect a session

Move the restransmit test code to before any updates to socket[].

Update coap_dtls_handle_timeout() to return a value indicating a DTLS timeout
has occurred.  At the same time move the coap_dtls_handle_timeout() checks
into the first sessions iteration loop, removing having to iterate through the
sessions twice if DTLS.
2022-05-20 11:10:32 +01:00
obgm abbe3edd5a Merge pull request #795 from mrdeep1/async_fix
async: Handle changes to delay when using epoll
2022-05-06 14:47:39 +02:00
Jon Shallow 069a0786ce CSM: Support different XMT and RCV Max-Message-Size
Track the RCV mtu size separately from the XMT mtu, so that sufficiently
large PDUs can be built for receiving incoming data.

Wait until reliable session is complete and the initial CSM have been exchanged
before building any new PDUs for transmission so that they can hold the
appropriate amount of Max-Message-Size data.

Add in support into coap-server and coap-client for defining the
Max-Message-Size to use by adding in 2 new functions
coap_context_set_csm_max_message_size() and
coap_context_get_csm_max_message_size().

Add in flexibility into coap-server to control the initial example_data size.

Requires #844 to prevent recursive mutex locking when initiating proxy ongoing
session to upstream server.
2022-05-04 10:01:37 +01:00
Hugo Hakim Damer d9c19c378f event.h: Add events for server session state management
This commit adds two new events (`COAP_EVENT_SERVER_SESSION_NEW`
and `COAP_EVENT_SERVER_SESSION_DEL`), which are triggered when the
IO loop creates or deletes server-side sessions.
2022-04-29 09:18:51 +02:00
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
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 19928e81bd builds: Set CFLAGS += -Werror in all linux subdirectory compilations 2022-02-18 14:23:43 +00: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
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
Jon Shallow 726b9630e5 coap_block.txt.in: Clarify / more make readable the block handling information 2022-02-08 14:16:27 +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
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
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
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
Jon Shallow 17aaa81b5a Caching: Highlight requirements ignoring certain CoAP Options
When using the cache logic to build up the data of a body transferred over
several blocks, the BLOCK options must be excluded when deriving the cache key.

Update documentation reminding the user of the need to do this.
2021-12-22 13:38:04 +00:00
Jon Shallow 74582eddde resource.c: Support deleting resources that have not yet been added
Support deleting a resource both before and after calling
coap_delete_resource().

Make the coap_delete_resource() usage in examples less complex.
2021-12-22 12:59:32 +00:00
Jon Shallow e8e33f0424 coap-server: Add in POST support for unknown request handler 2021-12-07 21:30:35 +00:00
Jon Shallow 73389b8192 handlers: Clarify which handlers are client only, server only or both
Add in additional handler coap_register_request_handler() in addition to
coap_register_handler() but now only refer to and use
coap_register_request_handler() to aid readability.
2021-11-05 15:39:22 +00:00
obgm c821148b98 Merge pull request #746 from mrdeep1/doc_summary
doxygen: Fix summary output for manual pages
2021-10-18 09:50:22 +02: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
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
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
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 9447930cde async: Fix building with './configure --disable-async'
Correct some parameters for the dummy coap_async_*() functions.

Update some documentation for clarity.
2021-06-14 13:04:35 +01:00
Jon Shallow 4bbf25ba33 coap-client: Add in support for generating multiple requests
Demonstrate Token usage for tracking the multiple requests so
that it is easy to see how to extend this for bespoke applications.
2021-06-10 10:35:13 +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
obgm 25fe796cab Merge pull request #692 from mrdeep1/blocked_response
man pages: Update to use the coap_block(3) functions
2021-06-03 11:05:40 +02:00
obgm 027907a658 Merge pull request #691 from mrdeep1/raising_issues
man pages: Indicate where to raise issues
2021-06-03 11:03:33 +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 3a68e8eefc man pages: Update to use the coap_block(3) functions
Use the updated functions that cause libcoap to do all of the
RFC7959 work in the man examples.
2021-05-29 13:45:25 +01:00
obgm 62b2be4da1 Merge pull request #667 from mrdeep1/dtls_default
configure.ac: Add in --enable-add-default-names option
2021-05-28 18:06:24 +02:00