As "coap_key_t key" is no longer used as the key for hashing resources onto
the hashlist which gave the potential for coap hashes clashing for the
resource Uri, "str uri" being used instead, so disable the building of the
coap_hash functions.
In addition, the .sym and .map file information now has duplicate
entries removed.
Expose the new functions
coap_resource_unknown_init()
coap_get_uri_path()
coap_get_resource_from_uri_path()
Drop the functions as old hashed key is no longer supported
coap_get_resource_from_key()
coap_hash_*()
Update handle_request() to call context->unknown_resource handler (if defined)
to support "RFC7252: 5.8.3. PUT" requirements.
Allow only handlers defined for unknown_resource
Update handle_request() to return 2.02 for an unknown resource (and
context->unknown_resource is not defined) for a DELETE request
"RFC7252: 5.8.4. DELETE"
Update code to use resource's uri_path not key as the item to hash for lookups
Make use of the new function coap_string_equal() when checking for
COAP_DEFAULT_URI_WELLKNOWN resource request.
Remove now obsolete hashed key code for is_wkc().
Need to support
"RFC7252: 5.8.3. PUT
If no resource exists, then the server MAY create a new resource with that
URI, resulting in a 2.01 (Created) Response Code."
Add in the function definition for the coap_add_resource_unknown().
Add in 'is_unknown' flag into coap_resource_t.
Make the resource uri_path be the hash lookup key, not the old hashed key, to
stop hash lookup clashes.
*API Change* Update coap_delete_resource() to not use the old hashed key.
Remove coap_get_resource_from_key() function and replace it with
coap_get_resource_from_uri_path().
Make the coap_resource_set_mode() more robust against bad parameters.
Remove #ifdef COAP_RESOURCES_NOHASH logic as no longer required
Needed to handle
"RFC7252: 5.8.3. PUT
If no resource exists, then the server MAY create a new resource with that
URI, resulting in a 2.01 (Created) Response Code."
Needed for support of PUT requests to an unknown resource.
Remove structure coap_mid_cache_t as it is not used and refers to the now
obsolete coap_key_t.
Do not send back a RST is there is receipt of an empty message and using
TCP.
Otherwise, rate limit RST packets to 4 a second when receiving empty
messages
Add in the new functions
coap_session_set_max_retransmit()
coap_session_set_ack_timeout()
coap_session_set_ack_random_factor()
coap_session_get_max_transmit()
coap_session_get_ack_timeout()
coap_session_get_ack_random_factor()
Remove 'cc Rate Control' which is now in coap_session.h.
Update Q, ACK_TIMEOUT and ACK_RANDOM_FACTOR #defines to include session's
recovery parameters, now in coap_fixed_point_t.
Update calc_timeout() to include session (now called coap_calc_timeout()).
Update coap_retransmit() to use session's max_retransmit.
Add in the new functions
coap_session_set_max_retransmit()
coap_session_set_ack_timeout()
coap_session_set_ack_random_factor()
coap_session_get_max_transmit()
coap_session_get_ack_timeout()
coap_session_get_ack_random_factor()
Add in the default values in coap_make_session()
Update coap_calc_timeout() in coap_session_delay_pdu()
Include session as one of the parameters to coap_calc_timeout() as it is now
per session, which is renamed from calc_timeout() as it is now a public
function.
Support is required (RFC7252: 4.8.1. Changing the Parameters) to support
changing max_retransmit, ack_timeout and ack_random_factor values per
session instead of just using the default values.
Define struct coap_fixed_point_t to handle fixed point parameters
Added functions
coap_session_set_max_retransmit()
coap_session_set_ack_timeout()
coap_session_set_ack_random_factor()
coap_session_get_max_transmit()
coap_session_get_ack_timeout()
coap_session_get_ack_random_factor()
'cc Rate Control' moved from net.c into coap_session.h and updated to use
coap_fixed_point_t values where appropriate.
If the non-blocking connect() does not immediately complete, when the main i/o
processing loop runs and coap_read is called, coap_read_session() will assert if
COAP_SOCKET_CONNECTED is not set as there will be some TLS level packets to
process.
If WSAEWOULDBLOCK/EINPROGRESS is returned from the connect() set
COAP_SOCKET_CONNECTED in the socket flags.
This bugfix allows clients to send datagrams to IP multicast groups.
After introducing the concept of client sessions, datagram sockets
have been connected to their remote peer in coap_socket_connect_udp().
As this operation fails for multicast addresses, sending to multicast
groups was not possible anymore.
coap_socket_connect_udp() now checks whether the given server address
is a multicast address. If this is the case, connect() is not called
and the flag COAP_SOCKET_MULTICAST is set in the coap_socket_t
structure while COAP_SOCKET_CONNECTED is cleared.
The flag COAP_SOCKET_CONNECTED is now set by coap_socket_connect_udp()
and coap_socket_connect_tcp1().
coap_read_session() now allows reading from sockets that have either
the flag COAP_SOCKET_CONNECTED or COAP_SOCKET_MULTICAST set.
coap_session_t uses reference counting hence client sessions must be
released by coap_session_release() instead of directly calling
coap_session_free().
Valgrind reports Syscall param sendmsg(msg.msg_control) points to
uninitialised byte(s) due alignment padding in the CMSG macros
leaving uninitialized gaps in struct sent to the sendmsg system call.
This issue was reported including this patch on the libcoap-developers
mailing list [1].
[1] https://sourceforge.net/p/libcoap/mailman/message/36141279/
Signed-off-by: Olaf Bergmann <bergmann@tzi.org>
If a TCP connection connection fails, or a an ICMP Unreachable is received
for a UDP packet, then the file descriptor is not closed off. Eventually
all fails when no more file descriptors are allowed.
Update functions appropriately.
Move coap_new_client_session_pki() back into coap_session.h (its correct place)
Add in enum coap_asn1_privatekey_type_t
A simple structure for (D)TLS-specific unit tests has been added.
Currently, only general support and the version number as reported
by coap_get_tls_library_version() are checked.
As unit tests with IPv6 addresses keep failing on docker-based
travis CI, this changes reverts to IPv4 usage in following files:
test_wellknown.c
test_sendqueue.c