Commit Graph
235 Commits
Author SHA1 Message Date
Jon Shallow ded6d04e1d doc: Fix typos 2023-08-12 14:06:42 +01:00
Carsten Schoenert 36941566d6 man: Small typo fixes for coap[-client,-oscore]
Typo fixup for
seperator -> separator
particularily -> particularly
2023-07-31 08:54:16 +01:00
Jon Shallow 3f8bb33807 coap_resolve_address_info: Add in support for defining WebSocket ports 2023-07-26 13:01:42 +01:00
Jon Shallow 084c866c69 coap_startup: Make coap_startup() first function call in examples
This then makes sure that all things libcoap are properly initialized
before use, and coders realize they need to do this.

Note: coap_new_context() continues to make sure that coap_startup()
is invoked if not done previously, but this may be too late.
2023-07-25 13:50:18 +01:00
Jon Shallow d17f47ab54 coap_address_t: Update functions documentation and add coap_is_af_unix() 2023-07-17 09:43:35 +01:00
Jon Shallow 57013f3377 RFC9177: Add in Q-Block support
examples/coap-client.c:
examples/coap-server.c:

Add in Q-Block intelligence.

include/coap3/block.h
include/coap3/coap_block_internal.h
include/coap3/coap_event.h

Add in Q-Block references.
Add in new functions
coap_block_check_q_block1_xmit()
coap_block_check_q_block2_xmit()
coap_send_q_blocks()
coap_send_q_block1()
coap_send_q_block2()
coap_block_drop_resp_q_block_xmit()
coap_block_drop_resp_q_block2_crcv()
coap_q_block_is_supported()

include/coap3/coap_session.h:

Add in new Congestion Control defaults and ability to configure them.

include/coap3/pdu.h:

Add in the new options.

libcoap-3.map:
libcoap-3.sym:

Expose external Congestion Control functions.

man/coap-client.txt.in:
man/coap-server.txt.in:
man/coap_block.txt.in:
man/coap_handler.txt.in:
man/coap_recovery.txt.in:
man/coap.txt.in:

Add in Q-Block information.

src/block.c:

Add in the new functions to support Q-Block.

src/coap_debug.c:

Output the new options as appropriate.

src/coap_io.c:

Check for Q-Block transmission timeouts.

src/coap_session.c:

Add in the Congestion Control support.

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

Add in Q-Block support.

configure.ac
CMakeLists.txt

Add in support for enabling/disabling Q-Block support (enabled by default).
2023-07-11 11:04:04 +01:00
Jon Shallow 52dcc5201b Reliable PDUs: coap_show_pdu(): Do not show all the non-reliable headers 2023-07-05 10:53:00 +01:00
Jon Shallow 9920d3e295 pre-commit: Add in initial support
Add in github workflow.

Add in .pre-commit-config.yaml.

Updated man directory using pre-commit.

Others to follow.
2023-07-03 08:57:09 +01:00
Jon Shallow 5ac47de1a4 examples-code-check.c: Report on missing man pages
Set optional 2nd parameter to libcoap-3.sym to generate missing output.
2023-06-28 21:18:22 +01:00
Jon Shallow 31f692b8b2 man: Document WebSockets support 2023-06-28 21:16:11 +01:00
Jon Shallow 1dfae51f30 man: Fix coap_attribute() example 2023-06-28 10:25:51 +01:00
Jon Shallow 295afa9f95 man: Document deprecated functions
New: man/coap_deprecated.txt.in
2023-06-28 09:53:22 +01:00
Jon Shallow 63d5248d88 examples-code-check.c: Disable potential compile warning
Fixes snprintf() warning of writing into smaller buffer.
2023-06-12 13:16:21 +01:00
Jon Shallow e386160474 man: Correct man page errors
Update examples-code-check.c to cross-check NAME and SYNOPSIS entries.

Update examples-code-check.c to cross-check SYNOPSIS and RETURN VALUE entries.

Make the formating style of RETURN VALUES consistent.
2023-06-12 09:44:41 +01:00
Jon Shallow 21bd1df95b examples: Remove references to sockaddr* structures
This means that apps need to have no knowledge of what IP support is available.

Updates coap_uri_into_options() and coap_resolve_address_info()
which have only been recently added to develop branch and are not in any
previous release.
2023-06-09 12:04:09 +01:00
Jon Shallow 9a196ce418 coap_string(3): Include missing return types 2023-06-08 17:44:06 +01:00
Jon Shallow b9d53ed3d4 keepalive: Fix timeouts when network issues
If keepalive is enabled, make sure that they continue when a server
stops / starts.  Limit the retry timeouts to the number of seconds
defined by coap_context_set_keepalive() so that interim NAT devices
are always kept "warm".

Addded in a new event COAP_EVENT_KEEPALIVE_FAILURE and updated docs
accordingly.
2023-05-05 10:35:39 +01:00
Jon Shallow 3ebbcde43a mcast_ips: Restore mcast ip for mcast sessions for each new coap_send()
If the server is responding to a mcast request with a packet that is a
part of larger body (i.e. responding with Block2 option) the requests
for the missing packets have to be using unicast, which continues
to be supported.

The application can determine the unicast remote address before the next
coap_send() by using coap_session_get_addr_remote().

Add in a new function coap_session_get_addr_mcast() to get the mcast IP
if the client session was set up to talk to a mcast address.
2023-05-01 16:28:44 +01:00
Jon Shallow ca609d221c Persist: Support tracking observe information over server restarts
Add in optional callbacks for when dynamic resources are setup and deleted.

Add in optional callbacks for when observe subscriptions start and stop.

Add in optional callbacks for when the observe counter is updated (can be
ratelimited) for a resource as well as track when a resource is deleted.

Add is support for new functions

Main functions with libcoap tracking support are
 coap_persist_startup()
 coap_persist_stop()

coap-server has -t option to track observe information.

UDP sessions supported, as well as OSCORE over UDP.

Documentation updated

libcoap tracking support (as opposed to application tracking) is configurable.
2023-04-22 11:07:21 +01:00
Jon Shallow e533b980fa coap_resolve_address_info: Move logic into function, simplifying server apps
Add in new function coap_get_available_scheme_hint_bits() to help as well.
2023-04-22 10:45:17 +01:00
Jon Shallow 964bd69481 MinGW: Initial compile environment support 2023-04-12 10:06:46 +01:00
Jon Shallow aee4c3fa6e logging: Support defining maximum logging level
This allows for code reduction if not all logging levels are required.

Done by defining ./configure --enable-max-logging-level=X, where X can have
the value of 0 through 8 inclusive.

COAP_LOG_EMERG is always logged.

Can save up to 40k bytes.
2023-04-12 09:55:13 +01:00
Jon Shallow 391803aebf WebSockets: Add in support for WebSockets layer
Follows RFC6455, as specified in RFC8323.

Make support configurable.

Add in example support.

Update other code to be aware of WebSockets as a CoAP protocol.
2023-04-10 14:38:56 +01:00
Jon Shallow 546f4203b1 examples: Clean up memory usage on error close down
Makes valgrind testing easier.

Note that it is unsafe to call coap_free_context() from with an atexit()
handler.
2023-04-08 18:02:16 +01:00
Jon Shallow 786149fb12 Unix Domain: Add in support for Unix Domains
Support the AF_UNIX address family for transporting CoAP internally within
an appliance.
2023-02-10 19:52:48 +00:00
Jon Shallow 47a83549a8 RFC8974: Add in support for Extended Tokens
Add in new function coap_context_set_max_token_size() to define
the maximum supported token size.

Track changes to PDU to support extended tokens.

Update documentation.
2023-02-04 11:08:32 +00:00
Jon Shallow 0a5d80ad66 coap_address.[ch]: Add coap_resolve_address_info() and coap_free_address_info()
coap_resolve_address_info() emulates getaddrinfo() but has the extensibility to
support other socket types based on the address to resolve.

coap-client, coap-server and lwip/client updated to use this new functionality.

coap_address(3) updated to include the new functions.
2023-02-03 09:53:24 +00:00
Jon Shallow ba2fada8f2 documentation: Tidy up man pages
Add in new coap_address(3) man page.
Tidy up endpoint documentation.
Fix other minor nits in the documentation.
2023-01-21 13:42:59 +00: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 4882641b95 documentation: Tidy up / correct documentation 2022-12-30 10:55:29 +00:00
Jon Shallow 4821daf366 documentation: Tidy up documentation
Provide consistency across all of the man pages as per :-

Provide missing function headers for functions.

Hyper link the function definitions.

Hyper link RFC references (except in code blocks).

Use https://rfc-editor.org/rfc/rfc.... instead of
https://tools.ietf.org/html/rfc.... for the RFC links.

Use https://rfc-editor.org/rfc/rfc.... instead of
https://datatracker.ietf.org/doc/html/rfc.... for the RFC links.
2022-12-20 20:34:37 +00:00
Jon Shallow 68f1a6eff3 log_levels: Replace usage of syslog LOG_ with COAP_LOG_
This removes the reliance of syslog definitions in libcoap by using libcoap's
version.
2022-12-17 12:38:31 +00:00
Jon Shallow 4b54c0d9ef logging: Use new logging macros for examples and man pages
Drop the use of syslog LOG_DEBUG etc. for coap_log() and use the
coap_log_debug() etc. macros which make use of COAP_LOG_DEBUG etc.

Application examples updated, as well as the man page examples.
2022-12-09 14:55:39 +00:00
Jon Shallow 349a0db6da Modeline: Correct vim modline syntax for missing files
The modline entries for Vim were not correct, various options get
declared by a space in between, and also no special character at the end
of the line are allowed.
2022-12-01 20:29:35 +00:00
Carsten Schoenert dd84e5af34 Modeline: Correct vim modline syntax
The modline entries for Vim were not correct, various options get
declared by a space in between, and also no special character at the end
of the line are allowed.
2022-12-01 19:36:27 +00:00
Carsten Schoenert 89222d0cf1 Spelling: Fix typo resouce -> resource 2022-12-01 19:05:22 +00:00
Carsten Schoenert 1ef1cc2b4b Spelling: Fix typo interator -> iterator 2022-12-01 19:05:22 +00:00
Carsten Schoenert ea678ee5b3 Spelling: Fix typo determing -> determining 2022-12-01 19:05:22 +00:00
Carsten Schoenert 2221a53d9c Spelling: Fix typo compatability -> compatibility 2022-12-01 19:05:22 +00:00
Jon Shallow c9f40d7d09 request-tag: Add in support for sending Request-Tag option with every request
If multiple requests (apart from DELETE) are sent at the same time to
the same resource, and the responses need to make use of the Block2 option,
there is no way for the server to differentiate between which block set a
request (if there is a resource content change) is for unless a Request-Tag
is used.

Disable this functionality by setting COAP_BLOCK_NO_PREEMPTIVE_RTAG when
calling coap_context_set_block_mode().  Request-Tag will still be sent
with any request that includes Block1 option.
2022-11-26 12:47:21 +00:00
Jon Shallow 710a8b5288 coap_io_pending: Add in new function to check if there is any i/o pending
coap_io_pending() checks to see if there are any PDUs pending transmission,
whether there are any large (block) transmissions in progress, whether
there are still expected response packets(client) or expected request
packets(server), and whether the client is expecting further observe
responses.  If any of this is true, then it returns 1, else 0.

coap_io_pending() also invokes coap_io_process() to check that all that can
be transmitted is, as well as processes any impending input packets.

This takes coap_can_exit() a step further who only checks the transmit state.

coap_handle_response_get_block() has been updated to release the current
lg_crcv if all the fragmented body of a large transfer have been received.

Documentation updated.
2022-11-04 14:06:55 +00:00
Jon Shallow 3897d2334c Logging: Make logging consistent across (D)TLS libraries
Set up coap_log_t as an enum, using syslog variable names prefixed by
COAP_.

Add function coap_dtls_log() for logging information from (D)TLS libraries.

Update the log output to have use Lower-case variants for the logging levels to
indicate that output is from the (D)TLS library instead of the CoAP library.

(D)TLS libraries updated to be consistent in the usage of
coap_dtls_set_log_level()/coap_dtls_get_log_level().

Add in coap_log_emerg(), coap_log_alert() etc. as wrappers to reduce the line
length required for log entries.  Updating all the coap_log() functions to
no longer use syslog variants will be a part of a separate PR.

Added in the "-V" option to the examples, with an initial default of
COAP_LOG_ERR, separating out the CoAP and (D)TLS logging levels.

Note: TinyDTLS log output will be consistent when built against a TinyDTLS
version that contains support for an external logging handler.
2022-11-03 16:02:36 +00:00
Jon Shallow 458f2d5702 TinyDTLS: Support build with DTLS_PSK not defined.
As well as adding in the DTLS_PSK wrappers in the appropriate place. add in
coap_dtls_psk_is_supported(), coap_dtls_pki_is_supported(),
coap_dtls_pkcs11_is_supported() and coap_dtls_rpk_is_supported() functions
to support better granularity of what capabilities are available in the
(D)TLS libraries.

Update coap_string_tls_support() to use these new functions.

Uppdated documentation for these new functions.
2022-11-03 09:03:52 +00:00
Jon Shallow b39e7bb3fc coap_uri: Tidy up documentation 2022-10-26 14:37:41 +01:00
Nick Miller 312a0561e4 coap_event: Add COAP_EVENT_MSG_RETRANSMITTED
Apart from debug log messages, there is no way for a user to be
notified when a message retransmission happens.

This event can be useful for diagnosing issues related to
lossy networks or unresponsive CoAP servers (e.g. user can
track total retransmissions as an indicator for general link
quality).

Assigned event ID to 0x5002 to avoid creating a new 0x6000
event group, and because it's similar to COAP_EVENT_BAD_PACKET (0x5001).
2022-10-19 16:34:07 +01:00
Jon Shallow d09d56860f coap.txt.in: Fix missing references and hyperlink RFC references
The RFC references appear without the hyperlink in the man pages,
but now appear as hyperlinked in the doxygen output.

SEE ALSO updated with missing references.
2022-10-12 21:38:42 +01:00
Jon Shallow c5c4f9bf1d uri.c: Add coap_uri_into_options() function
Simplify code for applications by providing coap_uri_into_options()
which then adds the (optional) port and splits out the path / query
as CoAP options, adding them to the optlist_chain for subsequent use.

Added a new coap_delete_uri() for completeness.

Update documentation to include the uri based functions.

Update examples to use the new coap_uri_into_options() function.
2022-10-12 15:24:02 +01:00
Jon Shallow de1bc9f3cb LwIP: Add in support for client
New demo client app.

Update some of the memory sizes.
New coap_lwip_dump_memory_pools() to dump LwIP memory pool usage.

Add in logic to handle new client sessions.

New coap_io_process() to handle LwIP which can invoke a callback handler
to wait / timeout for the next input handler.
New coap_lwip_set_input_wait_handler() to define this handler.

Update coap_io_prepare_io() to handle LwIP.

Support re-use of pbuf for PDU re-transmissions.

Make sure that NSTART is correctly obeyed.

Build the client with client only libcoap code.

Build the server with server only libcoap code.

Update LwIP source to latest stable release.

Reserve memory for a response PDU.

New coap_lwip(3) man page.

Update directory structures for config files.

Update files contained in "make dist" and check lwip rebuilds
in the github workflows.
2022-09-22 10:14:48 +01:00
Jon Shallow 2f25c950af net.c: Call nack handler for badly formatted response packet
If a response packet is received that is badly formatted, invoke the
nack handler (if defined) with COAP_NACK_BAD_RESPONSE so that the
requestor knows there is an issue, rather than timing out.

However, if the response packet is so badly formatted, or it is not
possible to find the requesting packet, then this nack event will not
trigger, but an event is triggered with COAP_EVENT_BAD_PACKET.
2022-09-20 15:12:29 +02:00