Commit Graph
1324 Commits
Author SHA1 Message Date
obgm eba6ce8e12 Merge pull request #195 from rdewaele/forward-declaration-typo
fix typographical error in forward declaration
2018-06-04 10:33:24 +02:00
Robrecht Dewaele 9677376902 fix typographical error in forward declaration 2018-06-02 03:42:45 +02:00
Olaf Bergmann 26d5cf784a coap_{notls,openssl,tinydtls}.c: quiet 'unused function' warning
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.
2018-05-31 11:12:01 +02:00
Olaf Bergmann 8e446e732a client.c: Remove unused function set_timeout()
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.
2018-05-31 11:12:01 +02:00
obgm 282fd96fc3 Merge pull request #192 from cquijano/dtls_event_on_error
coap_tinydtls.c: On DTLS error, fire and event that could be catch by upper layers
2018-05-31 10:43:12 +02:00
Carlos Quijano 491964e9c4 coap_tinydtls.c: On DTLS error, fire and event that can be caught by upper layers 2018-05-31 10:33:56 +02:00
obgm 4cfc722bf1 Merge pull request #181 from mrdeep1/coap-server-crash
coap-server: Sanity check of input to hnd_put_time() to prevent crashes
2018-05-31 10:24:32 +02:00
Olaf Bergmann 232f2612f2 updated submodule ext/tinydtls 2018-05-28 13:26:10 +02:00
Olaf Bergmann 56caa06677 test_session.c: fix warning for taken absolute value of unsigned int
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;
2018-05-28 13:26:10 +02:00
obgm 90cd1ac193 Merge pull request #173 from mrdeep1/const_value
Remove cast-qual compiler warnings
2018-05-28 13:23:19 +02:00
Jon Shallow 34dbf512b0 libcoap-2.{sym|map}: Add in coap_new_str_const() and coap_delete_str_const() 2018-05-25 16:38:08 +01:00
Jon Shallow f7bbd4a85a man/c*.in, man/Mkefile.am: Update text and examples for -Wcast-qual warnings
General:
Embolden -lcoap linking definitions
Embolden NOTE:

man/Makefile:
Reduce data written into missing .3 files

man/coap_attribute.txt.in:
Fix a typo
2018-05-25 16:38:08 +01:00
Jon Shallow 25a8414105 src/*.c: Remove cast-qual compiler warnings
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
2018-05-25 16:38:07 +01:00
Jon Shallow b4fc68c554 include/coap/*.h: Remove cast-qual compiler warnings
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
2018-05-25 16:37:05 +01:00
Jon Shallow af84f2049b configure.ac: Add -Wcast-qual to WARNING_OPTIONS 2018-05-25 14:11:04 +01:00
Jon Shallow 7dc16ed184 tests/*.c, examples/*.c: Remove cast-qual compiler warnings
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
2018-05-25 14:11:04 +01:00
obgm 2023f0107a Merge pull request #188 from mrdeep1/flexible-menber
option.[ch]: Fix "warning: ISO C++ forbids flexible array member 'data'
2018-05-22 17:49:59 +02:00
Jon Shallow a17757ec6e async.[ch]: Fix flexible array member 'token' warning
Make token[] token[8] as the maximum size of a token is 8 bytes

Check that we do not overflow coap_async_state_t when copying in
the token.
2018-05-22 11:32:58 +01:00
Jon Shallow 856236dc6c option.[ch]: Fix "warning: ISO C++ forbids flexible array member 'data' " 2018-05-22 10:42:13 +01:00
Olaf Bergmann a2d263356e configure.ac: enable -Wwrite-strings
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
2018-05-19 09:27:50 +02:00
Jon Shallow 828967bb43 examples/coap-server.c: Sanity check of input to hnd_put_time to prevent core
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()]
2018-05-18 15:10:09 +01:00
obgm 9f68329f70 Merge pull request #178 from mrdeep1/tid-duplication
Verify tid is not being re-used in a session
2018-05-18 15:58:11 +02:00
obgm 2782082808 Merge pull request #186 from mrdeep1/response-resource-leak
Fix CID 1382587 response resource leak
2018-05-18 15:41:17 +02:00
Jon Shallow 884e7d9162 src/net.c: Fix CID 1382587 response resource leak 2018-05-18 14:07:11 +01:00
Olaf Bergmann c2301257d0 option.h: Fixed bug in doxygen comment.
s/@pdu/@p pdu/
2018-05-18 14:41:47 +02:00
Olaf Bergmann 64610da8a0 Makefile.am: fix errors for target dist
* Added missing headers for unit tests to EXTRA_DIST.
* Moved utlist.h to EXTRA_DIST.
* Use correct name for .pc pkg-config template.
2018-05-18 14:39:15 +02:00
Olaf Bergmann 99fbe78a47 resource.h: get rid of -Winline warning
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.
2018-05-18 13:40:05 +02:00
obgm 06d3a44e98 Merge pull request #177 from mrdeep1/traffic-restart
coap main loop may wait un-necessarily in select() call when in fact there is work to do
2018-05-18 13:31:12 +02:00
obgm 95d82ad41e Merge pull request #162 from mrdeep1/issue-154
Move handling of CoAP Options into libcoap, instead of it all being held in coap-client
2018-05-18 13:15:42 +02:00
Jon Shallow 02195e13a6 examples/coap_list.[ch]: Document that these files are DEPRECATED
/*
 * 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
 */
2018-05-17 19:02:21 +01:00
Jon Shallow 2b81487c03 src/pdu.c: Warn and prevent token being added twice
Update with new library naming
2018-05-17 19:02:21 +01:00
Jon Shallow c187fbd508 man/coap_pdu_setup.txt.in: New man page
Updated man/coap.txt.in

Updated configure.ac

Updated man/Makefile.am
Also include the man pages where there are more than 9 definitions in the
SYNOPSIS as we are limited to 10 in hte NAMES section
2018-05-17 19:00:40 +01:00
Jon Shallow fbcf0abbe8 man/*.txt.in: Update library link naming and tidy up
man/coap_attribute.txt.in: Tidy up output
man/coap_context.txt.in: Correct ports and protocols in the examples
man/coap_observe.txt.in: Update with the new optlist functions
man/coap_recovery.txt.in: Include how recovery times are calculated
man/coap_resource.txt.in: Tidy up output
man/coap_tls_library.txt.in: Tidy up output
man/coap_handler.txt.in: Update with new library naming
2018-05-17 18:58:16 +01:00
Jon Shallow 25aa689f99 include/coap/mem.h: Include COAP_OPTLIST in coap_memory_tag_t 2018-05-17 18:58:16 +01:00
Jon Shallow fb72bde960 win32/coap-client/coap-client.vcxproj*: Remove references to examples/coap_list.[ch] 2018-05-17 18:58:16 +01:00
Jon Shallow 250f6d46ef include/coap/pdu.h: Document struct coap_option is deprecated 2018-05-17 18:58:16 +01:00
Jon Shallow ac7d223d02 src/coap_tinydtls.c: Fix compiler unused parameter warning 2018-05-17 18:58:16 +01:00
Jon Shallow bf54ccd4bf src/option.c: Add in new optlist functions
Fix compiler warning for index variable being also a string function

Add in optlist functions
 coap_new_optlist()
 coap_add_optlist_pdu()
 coap_insert_optlist()
 coap_delete_optlist()
2018-05-17 18:58:06 +01:00
Jon Shallow ec65187ae1 src/coap_notls.c: Fix compiler unused parameter warning 2018-05-17 18:45:39 +01:00
Jon Shallow 7c94b4497d libcoap-1.{map|sym}: Include new optlist functions 2018-05-17 18:45:39 +01:00
Jon Shallow 3122428445 include/coap/option.h: Add in optlist structures / functions
Add in new coap_optlist_t structure
Add in the new functions
 coap_new_optlist()
 coap_add_optlist_pdu()
 coap_insert_optlist()
 coap_delete_optlist()
2018-05-17 18:45:26 +01:00
Jon Shallow ece443f107 include/coap/debug.h: Fix compiler optimizer warning 2018-05-17 18:45:26 +01:00
Jon Shallow b35a66ea3d include/coap/coap.h.in: Remove utlist.h uthash.h includes as not needed 2018-05-17 18:45:26 +01:00
Jon Shallow 89f2f68ddf examples/coap-server.c: Replace debug() with coap_log(LOG_DEBUG, )
Replace debug() with coap_log(LOG_DEBUG, )
Remove unneeded include files
Remove compiler optimizer warnings for ntohs(htons())
Fix compiler warning about unused options
2018-05-17 18:45:07 +01:00
Jon Shallow 032a46fcb3 examples/coap-rd.c: Replace debug() with coap_log(LOG_DEBUG, ) 2018-05-17 18:45:07 +01:00
Jon Shallow 843f036b16 examples/Makefile.am: Remove coap_list.c from files needed for coap-client 2018-05-17 18:45:07 +01:00
Jon Shallow c129a0abe8 examples/client.c: Make use of new optlist functions
Remove coap_list_t structure and replace with coap_optlist_t to maintain
backward code compatability.
Make use of the new coap_optlist_* functions
Use the new coap_optlist_t structure
Remove unneeded header includes
warn() -> coap_log(LOG_WARNING, )
debug() -> coap_log(LOG_DEBUG, )
2018-05-17 18:41:46 +01:00
obgm 1beff614f5 Merge pull request #168 from spinetix/spx-win32build
Improve win32 build configuration and installation.
2018-05-15 18:26:01 +02:00
jcmichelou d27790ffa5 win32: Use libcoap-2.sym and retarget to Windows SDK version 10.0.17134. 2018-05-15 17:01:41 +02:00
jcmichelou 8f5e3beab6 win32: Change DLL version number to 2-openssl 2018-05-15 16:50:52 +02:00