Add code to better support the Proxy-Uri: and Proxy-Scheme: CoAP Options.
examples/client.c:
Make sure that the Proxy-Uri: option is added (if set) when clearing down an
observation (fixes#112).
Check that Proxy-Uri: option has a maximum data length of 1034 bytes.
Handle user defined Proxy-Scheme: option correctly.
Update -P option to include scheme to be used when connecting to the proxy.
examples/coap-server.c:
Add in hnd_proxy_uri() handler function. This has support for a direct or ongoing
proxy connection for the coap* protocols. The ongoing connection is set up as a
different CoAP session and is assocated with the incoming session for relaying
requests / responses.
Internal functions taken from client.c are used where appropriate.
Proxy support code has a SERVER_CAN_PROXY wrapper, so footprint can easily be
reduced if required.
New -P and -u options added to support ongoing connections.
include/coap2/net.h:
Add in tracking the proxy uri handler into coap_context_t.
include/coap2/resource.h:
Track whether a resource definition is for Proxy-Uri:/Proxy-Scheme:.
Define the coap_resource_proxy_uri_init() function for handling the Proxy-Uri:
option or Proxy-Scheme: option in an incoming request.
include/coap2/uri.h:
Add in COAP_URI_SCHEME_HTTP and COAP_URI_SCHEME_HTTPS as valid Proxy-Uri:
schemes.
Define the coap_split_proxy_uri() function (similar to coap_split_uri() but
supports the proxy extras. Both now use a common sub function internally.
libcoap-2.map:
libcoap-2.sym:
Expose the new coap_resource_proxy_uri_init() and coap_split_proxy_uri()
functions.
man/Makefile.am:
Handle coap_resource_get_userdata(3) now being over the 10 definition limit
in man/coap_resource.txt.in.
man/coap-client.txt.in:
Update documentation for the -P option.
man/coap-server.txt.in:
Document the new -P proxy option.
Document the new -u user option.
man/coap_resource.txt.in:
Include documentation for coap_resource_proxy_uri_init().
src/coap_debug.c:
Output the Proxy-Scheme: Option as text.
src/net.c:
Sanity check and handle COAP_OPTION_PROXY_URI and COAP_OPTION_PROXY_SCHEME
in handle_request().
src/resource.c:
Add in coap_resource_proxy_uri_init() function.
Handle the addition of a proxy uri handler in coap_add_resource().
src/uri.c:
Rename coap_split_uri() to coap_split_uri_sub() and add in extra proxy
handling support based on input parameters.
Create new coap_split_uri() and coap_split_proxy_uri() which call
coap_split_uri_sub() appropriately.
TODO:
Remove reference to Proxy support required
src/coap_gnutls.c:
Fix a double deallocate found during testing
src/coap_asn1.c: (New)
include/coap2/coap_asn1_internal.h: (New)
Created and common asn1 functions added in
Makefile.am:
include/coap2/coap_internal.h:
Reference the new files.
src/coap_gnutls.c:
src/coap_tinydtls.c:
Updated to use new common asn1 functions.
Support of COAP_PKI_KEY_PEM requires reading files which may not be supported
in libcoap running in a non Posix environment.
Remove RPK support when using PKI key type COAP_PKI_KEY_PEM. Update
coap-server and coap-client to read the optional .pem files into memory and
use PKI key type COAP_PKI_KEY_PEM_BUF instead.
Currently OpenSSL and MBedTLS do not support RFC7250. See
https://en.wikipedia.org/wiki/Comparison_of_TLS_implementations#Extensions
last column.
GnuTLS >= 3.6.6 required.
TinyDTLS update required.
New option is_rpk_not_cert added to PKI setup structure which is enabled
in coap-client and coap-server by the -M option and the use of a PUBLIC KEY
instead of a CERTIFICATE in the cert file. If file is EC PRIVATE KEY, then
it can be used for both the public and private key files.
man/coap-client.txt.in:
man/coap-server.txt.in:
Document -M option.
man/coap_encryption.txt.in:
man/coap-server.txt.in:
man/coap_context.txt.in:
Add in documentation for RPK.
examples/client.c:
examples/coap-server.c:
Add in support for is_rpk_not_cert and -M option.
Stop sending ::1 for SNI - use localhost instead.
include/coap2/coap_dtls.h:
Add in is_rpk_not_cert option.
include/coap2/str.h:
src/str.c:
libcoap-2.map:
libcoap-2.sym:
Add in coap_new_binary() and coap_delete_binary() functions.
src/coap_openssl.c:
Report RPK is not supported if invoked.
Check that all received data is used up for error recovery.
src/coap_mbedtls.c:
Report RPK is not supported if invoked.
Handle more MbedTLS generated errors.
Check that all received data is used up for error recovery.
src/coap_gnutls.c:
Add in support for RPK.
Add in sending Hello Verify if not cookie match in Client Hello
Check that all received data is used up for error recovery.
src/coap_tinydtls.c:
Add in support for RPK.
HOWTO.pkcs11:
Update for use with RPK.
Use .der file for '-C ca_file' definitions as later GnuTLS needs CA
to be trusted in HSM.
PR #476 added in coap_insert_option() which could be called by
coap_add_option() with with a coap_log() message set to LOG_DEBUG.
When PR #539 was merged in, this upped the logging level to LOG_WARNING which
now causes test/testdriver to report unecessary messages.
Logging level reverted to LOG_DEBUG.
This updates the initial work done for adding in cache support
include/coap2/coap_cache.h: (new)
include/coap2/coap_cache_internal.h: (new)
src/coap_cache.c: (new)
New files to support cache support.
CMakeLists.txt:
Makefile.amMakefile.am:
Makefile.libcoap:
configure.ac:
examples/lwip/Makefile:
include/coap2/coap.h.in:
include/coap2/coap.h.windows:
win32/libcoap.vcxproj:
win32/libcoap.vcxproj.filters:
Add in the new files.
examples/client.c:
Fix valgrind reported memory leak.
examples/coap-server.c:
Add in new example_data resource that uses the new caching logic.
Update hnd_put() to use the new cache logic for BLOCK1 PUTs.
include/coap2/coap_forward_decls.h:
include/coap2/coap_internal.h:
include/coap2/coap_session.h:
include/coap2/net.h:
Add in new cache support.
libcoap-2.map:
libcoap-2.sym:
Include the new functions.
man/Makefile.am:
man/coap.txt.in:
man/coap_cache.txt.in: (new)
Update documentation.
src/coap_io.c:
Idle timeout cache entries.
src/coap_session.c:
Delete cache entry when session is deleted.
src/net.c:
Delete cache entries when context is freed off.
src/coap_gnutls.c:
src/coap_mbedtls.c:
src/coap_notls.c:
src/coap_openssl.c:
src/coap_tinydtls.c:
Add in SHA256 digest support.
Add in coap_new_binary() and coap_delete_binary() functions which operate
in the same way as coap_new_string() and coap_delete_string() but work on
coap_binary_t objects.
include/coap2/str.h:
src/str.c:
Add in the coap_new_binary(), coap_resize_binary() and coap_delete_binary()
functions.
configure.ac:
man/Makefile.am:
man/coap.txt.in:
man/coap_string.txt.in: (new)
Add in documentation for the coap_string functions.
libcoap-2.map:
libcoap-2.sym:
Update with new functions.
coap_config.h.contiki:
include/coap2/lwippools.h:
include/coap2/mem.h:
src/mem.c:
Add support for fixed memory allocations for Cacke-Key and Cache-Entry
include/coap2/pdu.h:
src/pdu.c:
tests/test_pdu.c:
Change parameter max_delta to max_opt to better reflect actual usage.
include/coap2/pdu.h:
src/pdu.c:
Remove unneeded COAP_OPT_LONG and COAP_OPT_END definitions.
Remove unused function coap_add_option_later().
src/pdu.c:
Update coap_pdu_parse_opt() to sanity check the valid lengths of all the
known options.
src/coap_io_lwip.c:
src/net.c:
Ignore packets < 4 bytes
Send back a RST for UDP/DTLS if malformed PDU.
src/option.c:
Clean up coap_option_filter_get() documentation.
If a client TCP connection connects, EPOLLOUT remains enabled so epoll_wait()
always returns immediately causing a loop until there is other data traffic.
This fix is to enable EPOLLIN and disable EPOLLOUT if COAP_SOCKET_WANT_WRITE
is not set at point of connection successful.
Make sure that gnutls_priority_set_direct() is called after
gnutls_priority_set().
Output alert information if an alert occurred.
Handle valgrind slowing things down, causing packet retries.
All this is handled by libcoap with coap-client having the ability to define
an initial Hop Count value for testing. No other application support is
required.
Incoming requests are checked for the Hop Limit option - if found, the value
is decremented in the PDU before passing it up to the application. If it
decrements to 0, a 5.08 response is generated.
coap_add_option() checks if this is a Proxy option for a request. If so, and
Hop Limit option does not exist, then the Hop Limit option is inserted into
the PDU with the default value (16).
coap_send() checks if it is a 5.08 response and if so, prepends the diagnostic
data with the IP address of the transmitting interface. If the IP address
already exists, then the PDU is dropped as the return path for the 5.08 response
is looping. An alternative method for return path looping check is also
used by initially setting, then testing and then decrementing the Hop Limit
value as response packets pass back through the proxies. If a proxy does not
copy the Hop Limit options when returning the 5.08 response, then the IP address
duplication is used.
Makefile.am:
Hide the coap_insert_option(), coap_update_option and coap_pdu_check_resize()
function from applications.
README.md:
Add in RFC8768 is supported by libcoap.
examples/client.c:
Add in the -H hoplimit option.
include/coap2/pdu.h:
Add in the default Hop-Limit: option COAP_OPTION_HOP_LIMIT.
Re-organize the COAP_OPTION_ descriptions to include
the C, U, N, R, E, I and U flags.
Expose the internal coap_pdu_check_resize() function so src/net.c can use it.
Define the two new internal functions coap_insert_option() and
coap_update_option() and expose them so that the test suites can use them.
man/coap-client.txt.in:
Document the new -H hoplimit option.
man/coap.txt.in:
Include the new RFC8768.
man/coap_pdu_setup.txt.in:
Update documentation for the CoAP options.
src/coap_debug.c:
Add in support for printing out COAP_OPTION_HOP_LIMIT.
src/net.c:
Make sure that COAP_OPTION_HOP_LIMIT is not returned in an error response.
Decrement received Hop-limit in handle_request() and generate 5.08 response
if appropriate.
Update coap_send() to prepend IP in 5.08 response.
Support COAP_OPTION_HOP_LIMIT being used in the 5.08 response message.
src/pdu.c:
Report on CoAP options that are repeated, but not defined as repeatable.
Define new (5.08) Hop Limit Reached error response.
Add in new internal coap_insert_option() function. This now means that
callers of coap_add_option() no longer have to have the options in the
correct order.
Add in new internal coap_update_option() function that updates the value of
an option.
Make coap_pdu_check_resize() non-static.
tests/test_pdu.c:
Check that options are getting inserted in the correct order when using
coap_insert_option(), even though they are provided in a random order.
Test the coap_update_option() function.
Support observe for both GET and FETCH.
Correct coap-client programatic addition of observe establish option which
"happened" to work previously because COAP_OBSERVE_ESTABLISH was 0.
coap_add_token() can error for multiple reasons when building the response
PDU - but then the response PDU is not deleted on error if it exists.
The PDU is now deleted on coap_add_token() error.