The library API lacks a way to store context for the handlers. A
LED-handler for example needs to now on which pin the specific LED
is connected in order to control it. Or a higher level API would like to save the
object pointer to the object responsible for the resource.
This change will introduce a void pointer for the user to save context.
He can then retrieve the context in the handler if needed.
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
When determing whether to do a re-transmit timeout based on
coap_dtls_get_timeout, if s->tls is not set (unable to set up TLS session,
TLS error etc.), then coap_write() assert's when calling
coap_dtls_get_timeout(). This fix just sets the timeout to 0 if s->tls is not
set.
Update coap_context_set_psk() to return on failure. Add in call to
coap_dtls_context_set_psk() function
Add in new function coap_context_set_pki()
Update #includes for compilation
Update coap_new_client_session_psk() to clean up and return on error. Add in
call to coap_dtls_context_set_psk()
Add in new function coap_new_client_session_pki()
Additional check for a call of coap_new_client_session_*() in
coap_new_endpoint()
Remove PSK specifics from coap_dtls_new_context() and put into new
coap_dtls_context_set_psk().
Create a new coap_dtls_context_set_pki() for PKI.
Include checks that either of coap_dtls_context_set_psk() or
coap_dtls_context_set_pki() have been called before setting up a (D)TLS
session
Update #includes for compilation
If the application needs to see CoAP ping requests or CoAP TCP pong responses
then this update provides calling the configured handlers at the appropriate
points.
If the application needs to see CoAP ping requests or CoAP TCP pong responses
then there needs to be a handler that can be set up that is called
appropriately.