examples/client.c
Add in support for using PKI certificates
examples/coap-server.c
Add in support for using PKI certificates
remove default PSK key
Add in '-h hint' option
Make Usage reflect actual options available to use
man/coap-client.txt.in
Include the missing options
Update -A option to be a single entity
Sort the options into ascending order as reported by Usage
man/coap-server.txt.in
Include the missing options
Add in '-h hint' option
tests/test_pdu.c: Create t_parse_pdu15() which shows the issue
Credit to OSS-Fuzz for finding this - work done by Bhargava Shastry with
the libcoap testing
To document that uri.port input to coap_encode_var_safe() never
has more than 16 bits, an explicit bit mask has been added. This
change is supposed to avoid the false positive CID 1469635.
cmdline_content_type() treated option numbers as 8-bit integers and
therefore could not parse values >255. Now, option numbers are
represented as uint16_t to allow for numbers between 0 and 65535.
Moreover, as RFC 7252 has made the Accept option non-repeatable,
cmdline_content_type() now will only add a single Accept option.
libcoap-minimal [1] contains small client and server examples that
illustrate the use of libcoap-2.
This change also updates the copyright year.
[1] https://github.com/obgm/libcoap-minimal
Calling strncpy() on the variable (and erroneous) calculated token
length in cmdline_token() has caused stringop-overflow warning by
GCC 8. This change fixes the error and replaces strncpy() by
memcpy() to quieten the compiler.
Update code / examples / man pages with the updated function.
include/coap/libcoap.h:
Add in new define COAP_DEPRECATED to generate compiler warnings when used
include/coap/encode.h
New coap_encode_var_safe() function that includes the size of the output
buffer as a parameter.
Make coap_encode_var_bytes() a wrapper for coap_encode_var_safe() and
mark it as COAP_DEPRECATED for backwards compatability
src/encode.c:
New coap_encode_var_safe() function that includes the size of the output
buffer as a parameter.
examples/coap-server.c:
examples/contiki/server.c:
Make the ticks resource consistent in case
#pragma GCC diagnostic push
#pragma GCC diagnostic pop
is not supported by gcc version less than 4.6
[I also think the push/pop is not needed as it is at the end of the
file and only one file is complied at one time]
gcc in general does not complain about (when the only entry in the file)
static inline void dummy(void) {
}
Also current code before fix is unlikely to work on Windows so the
additional compiler wrapper (is it clang) tests should fix this.
Depending on the TLS library being used (which may be none), the
code that depends on other TLS libraries is not compiled. Because
some compilers are not happy compiling empty modules, each of these
files contains an empty static inline function dummy() that gets
compiled instead. As clang happens to emit a warning for this
function when -Wunused-function is set, this change introduces
a GCC pragma (sic!) to suppress this warning for the dummy function.
The function is not used because most of the timer handling has
been moved to coap_run_once().
This change avoids clang to emit a warning due to -Wunused-function.
coap_add_optlist_pdu() sorted the options for insertion, but did not update
the coap_optlist_t head (whch may then no longer point to the first entry in the
sorted chain) and so when coap_delete_optlist() was called, the first few
entries of the sorted chain may not get deleted.
Fixed by making it
coap_add_optlist_pdu(coap_pdu_t *pdu, coap_optlist_t** optlist_chain)
instead of
coap_add_optlist_pdu(coap_pdu_t *pdu, coap_optlist_t* optlist_chain)
Additionally deleted options_start() and options_next() as they are not
required - Issue #184.
examples/client.c:
Fix coap_add_optlist_pdu() call
include/coap/options.h:
Fix coap_add_optlist_pdu() call
libcoap-2.{map|sym}:
Delete options_start()
man/coap_observe.txt.in:
man/coap_pdu_setup.txt.in:
Update docmentation
src/option.c:
Update coap_add_optlist_pdu()
tests/test_pdu.c:
New tests for checkout out coap_insert_optlist() and coap_add_optlist_pdu()
functions
This change replaces the call of abs(v - ref) to avoid a compiler
warning for -Wabsolute-value:
test_session.c:95:11: warning: taking the absolute value of unsigned type 'unsigned int' has no effect
[-Wabsolute-value]
return (abs(v - ref) / 100.0) <= FP_ERR_THRESHOLD;
General:
Embolden -lcoap linking definitions
Embolden NOTE:
man/Makefile:
Reduce data written into missing .3 files
man/coap_attribute.txt.in:
Fix a typo
Where appropriate in general
Replace 'unsigned char' with 'const uint8_t'
Replace 'str' with 'coap_str_c_t'
Replace str with coap_string_t
Prefix with 'const' some type casts
Remove unnecessary type casting
Remove unneeded WITH_LWIP wrappers to select coap_malloc_type() or memp_malloc()
as underlying coap_malloc_type() is correctly selected in include/coap/mem.h
src/block.c:
Replace coap_opt_const_value() with coap_opt_value()
src/coap_io.c:
Due to the definations of struct iovec and struct msghdr, and const parameters
getting passed in, as this is a write of data function, the pointers are
copied into the 2 structures to get around the cast-qual warnings
src/net.c:
Release any sessions (so that they may get freed off) in coap_free_context()
src/option.c:
coap_option_filter_get() had to be downgraded as coap_option_filter_op() is
used by set functions as well.
src/pdu.c:
Remove const out of next_option_safe() parameters
As coap_resource_init() has a const uri_path parameter passed into it, it is not
possible to have these values legally freed off if flags is set to
COAP_RESOURCE_FLAGS_RELEASE_URI.
coap_resource_init_release() has been created to handle this. However, as it
is likely to be called with a coap_string_t generated from a call to
coap_get_uri_path(), the string must be correctly freed off. Hence the
use of coap_string_t as a parameter.
coap_add_attr_release() has been added in as well, using coap_string_t* as
parameters, to allow the coap_string_t to be freed off correctly.
Add in coap_log warning if the functions coap_resource_init*() and
coap_add_attr*() are called incorrectly.
Update src
Commented out coap_opt_block_set_m() as it is not used anywhere, and needs
to get rewritten if needed.
Removed / changed references to coap_opt_const_value()
Created a new struct coap_str_const_t to handle const parameters
Add in 2 new functions to create / delete the new string type
coap_new_str_const()
coap_delete_str_const()
Added in coap_make_str_const() to help create the necessary string equivalents
of the ascii test string. Note that the byte array must be in the
local scope.
Make coap_string_equal() a macro to handle differing string types
Made uri_path a pointer in coap_resource_t
Made name and value a pointer in coap_attribute_t
Reasoning behind this was triggerred by test t_wellknown3() creating a
number of resources, all using the same string buffer, so they all ended up
with the same uri-path (last update to uri-path). In the days of hashing
uri-path for the lookup would have worked, but the wrong uri-path
presented from the resource. Now we always allocate uri-path if
application does not want it freed off - and always free it off at time
or resource removal. The same is also true for coap_add_attr().
Updated coap_resource_init(), coap_add_attr() and coap_find_attr() to
pass in string parameters, rather than use a pointer to data and a length.
Where appropriate
Replace 'unsigned char' with 'const uint8_t'
Replace 'str' with 'coap_str_const_t'
Replace 'str' with 'coap_string_t'
Prefix with 'const' some type casts
Remove 'const' prefix from some type casts
Created new 'CU_ASSERT_PTR_EQUAL_C(actual, expected)' to handle const variable matching
Where appropriate
Replace 'unsigned char' with 'const uint8_t'
Replace 'str' with 'coap_str_c_t'
Replace 'str' with 'coap_string_t'
Prefix with 'const' some type casts
Update coap_add_attr() calls inline with updated API
Update coap_resource_init() calls inline with updated API
Make use of coap_make_str_const() for defining parameters
tests*/.c
Update code to stop memory leaks (as found by valgrind)
examples/coap-rd.c
Track the fact that uri_path in coap_resource_t is now a pointer
As discussed in bug #185 [1], const strings should be protected
from being overwritten. This change adds -Wwrite-strings to the
compiler warning flags and fixes resulting warnings by making
static strings const.
[1] https://github.com/obgm/libcoap/issues/185
The input value for time in hnd_put_time() is not sanity checked for the
upper limit. If too large, gmtime() etc. functions will return a failure
(errno is EOVERFLOW).
Validate the input value to hnd_put_time(). Return 4.00 if failure
Verify return from gmtime() in hnd_get_time() before trying to convert to
ascii readable string. Return 4.04 if failure.
[Time may just be valid when updated in hnd_put_time(), but then
increments to be too large - hence check also in hnd_get_time()]
As gcc 7 complains that coap_register_handler() is too large to
be inlined automatically, the function definition now has been
moved to resource.c.
This change also updates the symbol mappings accordingly.
/*
* examples/coap_list.[ch] are DEPRECATED. You should be using
* struct coap_optlist_t instead with the following functions which are a part
* of libcoap.
*
* coap_new_optlist()
* coap_insert_optlist()
* coap_delete_optlist()
* coap_add_optlist_pdu()
*
* See 'man coap_pdu_setup' for further information.
*
* examples/coap_list.[ch] files will be removed in a future release
* They are left here to support building backward compatability of old versions
* of coap-client
*/