Make coap_pdu-t independent of the header style.
Use C99 sized types when applicable.
Use transaction ids in host byte order in the library.
Make coap_pdu_t payload storage grow on demand.
Add parsing and encoding of PDUs with UDP or TCP style headers.
Adapt examples and unit tests to the new PDU format.
When building outside the source tree compilation fails on
examples, because the libcoap headers expect to be all in the
same directory but coap.h is generated under the build
directory, so it is necessary to add an extra include path
for it.
Also, build directories should always appear before source
directories in the include path, so that any leftover
generated files in the source tree are ignored.
Remember the query string used during the observe request and pass it to the resource handler.
Support partial notification of observers based on the query string.
The message id in the CoAP header is used for reliability when
transferring a CoAP PDU over a non-reliable transport protocol
such as UDP. For message de-duplication, it is useful to have
a monotonously increasing number space within a session. Therefore,
the context-global value has been moved to coap_session_t.
The function coap_new_message_id() now takes a coap_session_t
object as its argument.
In the main of examples/coap-server.c wait_ms was set to
COAP_RESOURCE_CHECK_TIME * 1000, then coap_run_once() was invoked
with parameter timeout_ms as COAP_RESOURCE_CHECK_TIME * wait_ms,
i.e., squaring the resource check time.
This bug has been fixed by removing COAP_RESOURCE_CHECK_TIME from
the call to coap_run_once().
Signed-off-by: Olaf Bergmann <bergmann@tzi.org>
coap-client now prints PDUs that are sent and received in log level
INFO so that these are output with '-v6' or higher. These messages
are now visible without turning on the full debug.
coap_async_state_t now contains a reference to the session that is
associated with the respective async state. As the response must
be sent over this session, the local_if parameter of check_async()
is not used anymore and can be removed.
coap_send() now takes ownership of the coap_pdu_t object passed
as second argument. Therefore, it is no longer necessary to release
the PDU structure in case of an error.
Zero-length strings passed to -u are valid user names for DTLS.
The function cmdline_read_user() therefore returns 0 when the
argument passed with option '-u' is an empty string.
Compact coap_address_t.
Use coap_queue_t for all queues.
OpenSSL warning for close alert should be info level.
Fix OpenSSL log level not working.
Use the application defined MTU in OpenSSL.
coap_log() optimization to avoid generating the log message text before testing the log level.
coap_can_exit() should check the new retransmit queues.
Fix retransmit time sometimes not correctly computed relative to sendqueue_basetime.
Add coap_write() API call for applications with their own main loop.
This change excludes the coap subdirectory from the include path
reported by pkg-config --cflags to avoid name conflicts with other
installed packages. Applications now must add the prefix 'coap/'
to include directives for libcoap header files, e.g.
#include <coap/coap.h>
Jean-Claude Michelou has reported this problem in Bug #82 [1].
[1] https://github.com/obgm/libcoap/issues/82
A minimal Makefile now could look be written as:
PKG_LIBCOAP=libcoap-1
CPPFLAGS=$(shell pkg-config --cflags-only-I $(PKG_LIBCOAP)) -DWITH_POSIX
LDFLAGS=$(shell pkg-config --libs-only-L $(PKG_LIBCOAP))
LDLIBS=$(shell pkg-config --libs-only-l $(PKG_LIBCOAP))
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.
The function cmdline_input_from_file() allocates a chunk of memory
to hold the contents of the given file. As libcoap does not offer
an interface to realloc(), we have to determine the required buffer
size before starting to read from the file, leading to a classical
TOCTOU condition.
This change mitigates the defect by first opening the file and then
calling fstat(). Note that the subsequent fread() call takes the
size of the pre-allocated buffer into account.
Only increment block size if it can be done without causing gaps or
overlaps in the byte sequence.
The patch adds a check for alignment to ensure that no gaps appear when
a server responds with a larger block size than the original request
was using.
Ignore the block number sent by the server since that may or may not be
valid. Always recompute based on how many bytes have been sent so far.
Rationale:
Erbium (Contiki CoAP) responds to Block1 request with a Block1 option
containing the server's maximum supported Block1 size (Contiki
configuration option REST_MAX_CHUNK_SIZE). However, the block number
in the Block1 option is the same number as the block number of the
original request.
The build environment was lacking the possibility to get libcoap
buildable out of tree, simply checkable by the running 'make distcheck'.
Without this fix the users are impossible to build libcoap in a own
folder that's independed from the source containing folder. Typical use
case would be:
$ mkdir libcoap-build && cd libcoap-build
$ /path/to/libcoap-source/configure \
--srcdir=/path/to/libcoap-source \
--prefix=/somethere/to-install
This commit enables the out of tree build by adding and changing some
needed variables.
cmdline_subscribe() has used the global variable optarg instead of
the local argument that was passed to this function. Changing this
as intended also makes __attribute__((unused)) unneeded.
note on coap_read removal: as the lwip implementation currently launches
the package handling right from the recv callback, a coap_read function
is not meaningful (as it is in posix or contiki where it actively
fetches the messages from the network buffer).
This drops the cumbersome mintapif mechanisms from server.c, fixes
header troubles that have popped up probably during the header cleanups,
drops old workarounds and enables IPv6.
handle_periodic_timer() in rpl-timers.c relies on the optimizer to
remove the if(0)-guarded call to rpl_ns_periodic() when storing
mode is selected. This does not happen with clang's default options
and thus leads to an error for the undefined reference at link time.
This modification adds -Os to fix this.
The debug function for printing lladdress have been renamed and moved
to net-debug.h. This change now includes this header and uses the
appropriate macros instead.
The example server creates a new endpoint for DTLS-secured traffic.
The secure endpoint is bound to the port number of the unsecure
port plus one (i.e. if the default port number 5683 is used for
cleartext CoAP traffic, the secure port is bound to 5684).
This server uses the credentials "Client_identity" as user name and
"secretPSK" as password for testing. DO NOT USE THIS FOR PRODUCTION.