Commit Graph
1310 Commits
Author SHA1 Message Date
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
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
jcmichelou 2c9fd4cceb win32: Do not use $(IntDir) as it confuses msbuild. 2018-05-15 16:50:51 +02:00
jcmichelou eb86b6fd4e win32: PDB file for libcoap DLL duplicated by install.
It should be installed only once, next to the DLL in bin.
2018-05-15 16:50:50 +02:00
jcmichelou a794fbd983 win32: Add configuration variables and install project for VS2017
Upgrade to VS2017. Added a property sheet with user variables to configure the
target installation directory and location of openssl library from within the
Visual Studio GUI and in a manner compatible with msbuild. This method is
inspired by the GTK project. It supports out of tree builds, and separate or
common directories for debug and release builds. The new install project copies
the library files to the selected target directory. It has all other projects
in dependency, so to build the library and utilities, you just build the
"install" target and it will take care of building the library, executable,
then copy to a tree with a unix-like structure (bin, lib, include).
Also fixes missing files in the testdriver project.
2018-05-15 16:50:49 +02:00
Olaf Bergmann a073078b3d ax_check_a2x_to_man.m4: verbose output diagnostics from a2x
a2x now is run with option '--verbose' to provide more diagnostic
output. In case of an error, the output generated by a2x is written
into config.log.
2018-05-04 15:41:46 +02:00
Olaf Bergmann 797f09d51e ax_check_a2x_to_man.m4: cleanup temporary files created for a2x test 2018-05-04 12:51:27 +02:00
Olaf Bergmann 072357c780 configure.ac: check if a2x can be used for manual page creation
This change adds a new m4 macro AX_CHECK_A2X_TO_MANPAGE that
invokes the a2x program passed in the environment variable A2X
to create a minimal manual page. If A2X is set correctly, failing
this test is a good indicator that the docbook DTD or the
docbook XSL stylesheets are missing.
2018-05-03 13:56:25 +02:00
Jon Shallow 1365dea39a src/coap_session.c: Verify tid is not being re-used in a session
Check that the same tid is not getting re-used in violation of RFC7252
in coap_session_delay_pdu()
2018-04-27 15:45:32 +01:00
Jon Shallow 7afb913ef7 src/coap_io.c: Fix re-transmission delays
There are 2 issues fixed here

Issue 1: In coap_write() (circa line 1074)
      if (XXXX && (s->last_rx_tx + session_timeout <= now || YYYY)) {
        coap_session_free(s);
      } else {
        if (XXXX) {
          coap_tick_t s_timeout = now - (s->last_rx_tx + session_timeout);

s_timeout will end up as a large number as 'now' is less than
(s->last_rx_tx + session_timeout)
Fix is to reverse the expression

Issue 2: In coap_write() (two places circa lines 1122 and 1136)
If coap_dtls_handle_timeout(s) causes the session to go away,
tls_timeout is set to 0, and so timeout does not get updated (could be 0
and so coap_write() returns 0 causing a wait for the default time in the
select() call.
Fix is to set timeout to 1 to cause a minimal time waiting in the select()
2018-04-26 14:20:47 +01:00
Olaf Bergmann 4280e75a0c coap_tinydtls.c: fix compiler warning for printf() format string 2018-04-20 10:50:48 +02:00
Olaf Bergmann e2a8ed7785 tinydtls: updated submodule to develop HEAD 2018-04-20 10:50:48 +02:00
Olaf Bergmann 50f2d74186 Merge branch 'nikosft-develop' into develop
This merge closes PR #43 [1].

[1] https://github.com/obgm/libcoap/pull/43.
2018-04-20 10:10:55 +02:00
Olaf Bergmann 837917f272 Merge branch 'develop' of https://github.com/nikosft/libcoap-fork into nikosft-develop
Resolved conflicts in file resource.h.
2018-04-20 10:10:08 +02:00
Olaf Bergmann ddfb94bc92 Merge branch 'PawelWMS-bracket_fixes' into develop
This resolves PR #76 [1].

[1] https://github.com/obgm/libcoap/pull/76
2018-04-20 10:00:34 +02:00
Olaf Bergmann 6d232dfc82 Merge branch 'bracket_fixes' of https://github.com/PawelWMS/libcoap into PawelWMS-bracket_fixes
Resolved merge conflicts (net.c, resource.c)
2018-04-20 09:53:43 +02:00