Commit Graph
118 Commits
Author SHA1 Message Date
jcmichelou 0a0cd1fb4e Make retransmit timeout relative in tinydtls. 2017-06-22 16:06:11 +02:00
jcmichelou 9490a0c8ab Fix bug in setting the OpenSSL log level make its use consistent with tinydtls
Rename session.c and session.h to coap_session.c and coap_session.h
Use length to PSK hint and identity
Improve packet loss testing
2017-06-22 16:02:03 +02:00
jcmichelou 99925a1a97 Add init function for DTLS library.
Match dummy functions in coap_notls.c with their prototypes.
2017-06-21 20:57:12 +02:00
jcmichelou adf1238eae Add DTLS retransmit and recovery.
Add lossy networks debug option in examples.
2017-06-21 20:40:15 +02:00
jcmichelou 2f24ee8cdd Call dtls_close when session is closed to send a notify alert to the remote peer. 2017-06-21 15:45:02 +02:00
jcmichelou ae13e5127b Compile with tinydtls and remove warning message with gcc. 2017-06-19 20:37:11 +02:00
jcmichelou b389a5f6aa Add skeleton support for tinydtls with new API. 2017-06-19 16:58:12 +02:00
jcmichelou 8353417afb Added session management with simpler DTLS lib API.
Added DTLS support with OpenSSL.
2017-06-18 20:09:47 +02:00
jcmichelou 5b1a8f67bf Implement coap_session_t concept for POSIX. 2017-06-15 18:42:42 +02:00
jcmichelou b2ab881ad4 Fix the result of dtls branch merge so that all the examples work (DTLS support not enabled yet) 2017-06-13 14:38:30 +02:00
jcmichelou 1c79a4b977 Merge remote-tracking branch 'remotes/obgm/dtls' into dtls-dev with tinydtls support
# Conflicts:
#	Makefile.am
#	configure.ac
#	examples/client.c
#	examples/coap-rd.c
#	examples/coap-server.c
#	include/coap/address.h
#	include/coap/coap_io.h
#	include/coap/net.h
#	include/coap/prng.h
#	libcoap-1.map
#	libcoap-1.sym
#	src/net.c
#	src/platform/posix/coap_io.c
2017-06-12 17:26:25 +02:00
jcmichelou fdf3dabb0c Activate dual-stacked BSD socket logic on linux after validation. 2017-06-10 16:46:37 +02:00
jcmichelou 78148d0c20 Merge develop into win32 2017-06-10 16:19:12 +02:00
Chanhee 69197feb15 coap_io_lwip.c: fix typos in comments
Few typos are fixed.
2017-06-01 19:58:35 +09:00
jcmichelou 85ca4aab36 Fix size_t downcast to unsigned long warning. 2017-05-17 19:42:15 +02:00
jcmichelou ab958ca586 Activate dual-stacked code first only on windows since on linux it is dependent on the version of the kernel. 2017-05-12 20:02:32 +02:00
jcmichelou 78ed10b758 Add explicit platform-independent support for dual-stacked sockets (ipv6 sockets are implicitly dual-stacked on Linux by default, but not on Windows).
Correctly map / unmap ipv4 addresses into ipv6 addresses so that ipv4 queries to an ipv6 dual-stacked server actually do work.
2017-05-08 19:32:28 +02:00
jcmichelou ba68ba85c0 Do not make exported symbols different between release and debug builds, this breaks the ABI of the DLL.
Do not make reference to NDEBUG in public headers to modify the ABI. This macro is defined automatically in all windows projects and will create a lot of confusion.
2017-05-07 18:18:33 +02:00
jcmichelou 95d8e2c8e0 Use C-style prototypes for coap_statup and coap_cleanup 2017-05-06 18:25:10 +02:00
jcmichelou 3042a287bc Fix a problem with the use of control structures in sendmsg / recvmsg. These are not struct sockaddr, they are ip_pktinfo or ipv6_pktinfo, so local_interface->addr.size is irrelevant, even causing an overflow with writing zero bytes outside of the control structure on the stack, even though it happens to work because the buffer is large enough.
Prevent invalid addresses from being used as source address with sendmsg. On linux, they are just ignored, so it is the same as not specifying one, but on windows they cause an error. In both case it is simpler not to include any control info if the intent is to let the interface be chosen by the network stack.
2017-05-06 16:56:32 +02:00
jcmichelou 9b3cf894fc Use crypto secure version of rand to generate the message ids on windows. 2017-05-05 20:46:29 +02:00
jcmichelou 9b647d5d05 Add visual studio 2015 solution and project files for building libcoap on windows.
Merge changes from PR #47 related to windows platform support.
Add full windows platform support including correct error checking and working regression tests and examples.
Remove need to build applications using libcoap with -DWITH_POSIX and to include coap_config.h. This applies to the examples as well.
2017-05-05 20:29:10 +02:00
Olaf Bergmann dc91eb9a1a client.c: allow user name and key to be empty
RFC 4279 allows psk_identity and psk to have a length of zero, so
-u and -k now are optional for coaps: resources.
2017-04-12 21:32:30 +02:00
Olaf Bergmann ac94964b45 pdu.h: new methods FETCH, PATCH, iPATCH from RFC 8132 2017-04-07 10:14:22 +02:00
Pawel Winogrodzki 6112604569 Makingcoap_transaction_id() always use the peer for ID generation. 2017-04-04 02:32:45 -07:00
Pawel Winogrodzki b130109c04 Applying agreed changes. 2017-03-29 02:51:21 -07:00
Pawel Winogrodzki 4b112431ff Changing u_short to uint16_t inside pdu.c. 2017-03-28 17:15:37 -07:00
Pawel Winogrodzki d6d7df8bfe Fixing comments inside coap_time.c and net.c. 2017-03-28 17:04:46 -07:00
Pawel Winogrodzki 48fb2443df Fixing coap_io.c comments. 2017-03-28 16:54:23 -07:00
Pawel Winogrodzki 8090dc7ba8 Fixing other sources needing <limits.h>. 2017-03-20 17:07:29 -07:00
Pawel Winogrodzki 45805772ca Adding <limits.h> to pdu.c.
It seems that POSIX builds didn't understand what
"USHRT_MAX" means and that macro is defined inside limits.h.
2017-03-20 16:59:06 -07:00
Pawel Winogrodzki a42894b053 Removing unnecessary line in coap_time.c. 2017-03-20 16:54:37 -07:00
Pawel Winogrodzki fc3e33b011 Fixing invalid coap_io.c line. 2017-03-20 16:41:27 -07:00
Pawel Winogrodzki 9adc4eb6a7 Fixing /W4 warnings for Windows builds.
Removing all of the /W4 level warnings from the code.
No functional changes.

Signed-off-by: Pawel Winogrodzki <pawelwi@microsoft.com>
2017-03-20 15:48:33 -07:00
Pawel Winogrodzki 445383a0b5 Fixing coap_remove_failed_observers() loop.
The loop was always exiting after analysing the first observer,
so in case there were more and the first one on the list of
observers didn't match the one we wanted to remove, the
observer never got removed.

Signed-off-by: Pawel Winogrodzki <pawelwi@microsoft.com>
2017-03-10 17:55:34 -08:00
Pawel Winogrodzki eb1fae94ed Fixing Option Delta and Option Length encoding.
Option Delta and Option Length were being encoded incorrectly
the value 269 and ended up being encoded the same way as 13.

For details please see RFC-7252 "Option Format"
( https://tools.ietf.org/html/rfc7252#page-17 ).

Signed-off-by: Pawel Winogrodzki <pawelwi@microsoft.com>
2017-03-08 11:09:27 +01:00
Olaf Bergmann 292b0f0790 address.[hc]: Fixed byteorder in coap_is_mcast() on platform posix
As IN_MULTICAST does a 32 bit comparison in host byte order,
sin_addr.s_addr needs to be converted using ntohl(). This change
also moves the coap_is_mcast() implementation to address.c because
it has become too complex for inlining.
2016-12-15 11:12:22 +01:00
Olaf Bergmann fb66920d5f net.c: Fix response code for unknown resources
John Carter has pointed out that non-GET requests for a resource
that does not exist caused a 4.05 response ("Method not allowed").
This fix corrects this behavior to return 4.04 in case a resource
does not exist and, for .well-known/core, 4.05 if anything but
a GET request was received.
2016-12-14 19:56:14 +01:00
Olaf Bergmann 6437190232 pdu.c: check for zero length before invoking memcmp()
In coap_pdu_parse(), everything but the header is copied by memcmp()
from the packet to the PDU structure. An additional check ensures
that memcmp() is invoked only when there is data to copy (i.e. the
incoming CoAP message consists of more than just the base header).
2016-12-01 17:12:42 +01:00
Olaf Bergmann beeb6b62d4 net.c: re-arrange code to avoid memory leakage
On platforms other than Contiki coap_new_context() has returned NULL
when no listen address was supplied but did not free the memory that
was previously allocated for the context object.

This change re-arranges the checks to return before allocating memory.
2016-12-01 16:50:11 +01:00
Olaf Bergmann 41af3304f0 net.c: explicitly clear pointer to free'd storage
Static code analysis tools have incorrectly reported a memory leak
in function handle_request(). To avoid this false positive, the
variable response is explicitly set to NULL after releasing the
memory with coap_delete_pdu().
2016-12-01 14:50:16 +01:00
Olaf Bergmann 4721d5d527 coap_io.c: avoid use of tainted data from recvmsg
coap_network_read() has used the address size reported by recvmsg()
in the msg_namelen field. As this value might be taken from the
incoming packet, coverity scan reports this value as a possible
security issue.

This fix sets the address size to the expected size and drops the
received packet if msg_namelen differs.
2016-12-01 14:10:31 +01:00
Joakim Nohlgård ed6ca0efd6 debug: Fix off-by-1 error in coap_show_pdu block size output 2016-12-01 13:02:28 +01:00
Olaf Bergmann 0fd7695733 pdu.c: Added missing response phrases
Some response phrases were missing in the data structure coap_error
that is used to return a humna-readable error description in a
diagnostic payload.
2016-12-01 13:01:07 +01:00
Jean-Philippe Comtois 718b2dfad5 pdu.c: correct response codes for 2.xx
Fixed response codes and reason phrase for diagnostic payloads
for 2.xx responses.
2016-12-01 12:58:16 +01:00
Olaf Bergmann 8054981362 coap_io.c: removed erraneous memcpy() in coap_network_read()
@john-carter has pointed out in bug #48 that valgrind reports
overlapping source and dest ranges in memcpy(). As the source
and destination in this memcpy() invocation are exactly the
same, it can be deleted safely.

For testing, the memcpy() has been replaced by an assert that
checks if these fields are alsways the same.
2016-11-19 17:22:12 +01:00
Olaf Bergmann 92ecd52454 coap_io.c: platform-specific network I/O for FreeBSD
Processing of ancillary data for IPv4 works different on FreeBSD. This
change uses IP_RECVDSTADDR instead of IP_PKTINFO on FreeBSD.

Setting a the source address with IP_SENDSRCADDR always failed with
error 22 (Invalid argument) for sendmsg() and thus has not been
implemented. Note that for IPv4, this is not a big problem as there
is usually only one interface address even if bound to INADDR_ANY.
2016-11-19 17:13:01 +01:00
Olaf Bergmann ad40407f88 net.c: improved support for RFC 7967 (No-Response option)
The No-Response option can be used in a request to express disinterest
or interest in certain response classes. This modification adds
No-Response handling for unicast messages and provides basic
functionality for handling multicast responses
2016-11-16 22:24:26 +01:00
Olaf Bergmann c16918dfff block.c: fixed possible buffer overflow in coap_write_block_opt()
Joel Sandin has pointed out that a buffer flow was possible in
coap_write_block_opt() as the block number is encoded without
range check into the local variable buf. As the block number is
stored in 20 bits, the buffer is enlarged to 4 bytes to fix this.

As a second counter-measure against wrong block numbers, the function
coap_get_block() is modified to check the decoded Block option.
Numbers larger than 0xFFFFF (20 bits) cause this option to be ignored.
2016-09-22 14:39:12 +02:00
Olaf Bergmann 538170628a coap_dtls.c: Fixed dummy functions for --disable-dtls build
When compiled without support for DTLS, coap_dtls.c contains a set
of dummy functions to make certain compilers and linkers happy. As
the function signature now differs from the prototype, the attribute
has been removed entirely (causing a set of warnings that report the
unused parameters.)
2016-07-18 22:03:22 +02:00