Commit Graph
252 Commits
Author SHA1 Message Date
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 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 132a830b59 Merge pull request #165 from mrdeep1/DTLS-Connection
DTLS session setup retries to establish DTLS many times before failure
2018-04-13 17:53:20 +02:00
Jon Shallow 2582d085f8 examples/client.c: Run at least once per sec to aid debugging 2018-04-13 14:08:08 +01:00
Jon Shallow ef6c72bf44 examples/Makefile.am: Update for new libcoap library naming 2018-04-13 08:43:37 +01:00
Jon Shallow d015c50091 coap-{client|rd|server}.txt.in: Move from examples to man directory 2018-04-07 11:34:44 +01:00
Jon Shallow 20cd610c03 examples/Makefile.am: Remove building man pages
Delete building man pages as they are now a part of the man directory
2018-04-07 11:34:44 +01:00
Jon Shallow 849deb2610 examples/contiki/coap-observer.c: Use COAP_OPTION_OBSERVE
As it is Observe that we are talking about here.
2018-04-04 16:46:04 +01:00
Jon Shallow 80cae52441 examples/coap-server.c: Update inline with new Observe functions
As we are talking about Observe here
2018-04-04 16:46:04 +01:00
Jon Shallow 97486e7112 examples/client.c: Change COAP_OPTION_SUBSCRIPTION to COAP_OPTION_OBSERVE
As we are talking about Observe here
2018-04-04 16:46:04 +01:00
Jon Shallow 6bbf993dbe examples/coap-rd.c: Update resource hashing from key to uri_path
Resources are now hashed by uri_path, not key.
2018-03-14 09:32:58 +00:00
Jon Shallow 45a95c776d examples/coap-client.txt.in: Add in coap+tcp to the documentation 2018-03-09 14:52:14 +00:00
Jon Shallow b2205d2e40 examples/coap-server.c: Re-order code (move fill_keystore) to support PKI
fill_keystore() now needs to be before coap_new_endpoint() is called.
2018-02-12 11:58:59 +00:00
Olaf Bergmann e5064a47e7 client.c: removed dead code in message_handler()
Coverity scan has detected dead code that has been removed in this
change. (CID 1382575)
2017-11-03 15:15:06 +01:00
Olaf Bergmann edca08249b coap-server.c: fixed memory leak in get_context()
When getaddrinfo() failed, the context object was not released before
returning NULL. Coverity scan has detected this with CID 1458398.
2017-11-03 14:18:19 +01:00
Olaf Bergmann 29692faa86 coap-server.c: fix use after free in check_async()
As coap_send() automatically releases the specified pdu, it must
not be accessed after coap_send() has returned.

This change fixes CID 1458399 reported by Coverity scan.
2017-11-03 14:12:22 +01:00
jcmichelou 3f77c117ea resource: Fix issues #90, #91 and #92
The value of the observe option is kept for each resource rather than being global to the context.
The value of the observe option must wrap to be stay below 2^24.
The value of the observe option must be different from the initial value when a notification is sent.
2017-10-25 20:22:01 +02:00
jcmichelou d89c99f5f8 uri: Add coap+tcp:// and coaps+tcp:// schemes. 2017-10-21 16:52:02 +02:00
jcmichelou cd804ba3bf client.c: Make observation timeout work with TCP. 2017-10-21 16:11:15 +02:00
jcmichelou f81cb43fd3 session, pdu: Enforce maximum message size. 2017-10-21 16:11:12 +02:00
jcmichelou dfff930805 io, net: Add TCP accept/connect/read/write 2017-10-21 16:11:12 +02:00
jcmichelou bcfd7a0753 pdu: add support for TCP-style headers
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.
2017-10-21 16:11:11 +02:00
obgm c1254c1be8 Merge pull request #111 from spinetix/build-fixes
Assorted build fixes
2017-09-21 12:48:10 +02:00
Diego Santa Cruz 9b12571804 Makefile.am: fix building outside of source tree
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.
2017-09-20 10:48:54 +02:00
cladmi 57a3b59060 coap-server: fix unused 'request' parameter 2017-09-12 15:48:58 +02:00
jcmichelou 30619691e2 resource.[ch], uri.c[ch]: Query string dependent observe.
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.
2017-09-08 19:50:34 +02:00
Olaf Bergmann 5c079b72d9 coap_session.[hc]: make message id session-local
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.
2017-08-18 14:15:20 +02:00
John Carter d7ebf14395 coap-server.c: fixed wait time for coap_run_once() invocation
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>
2017-08-08 12:23:41 +02:00
Olaf Bergmann e77c3565cb client.c: show outgoing and received PDUs in log level INFO
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.
2017-08-03 15:24:36 +02:00
Olaf Bergmann f2ebb4f926 coap-rd.c: removed unused signal handler 2017-08-02 21:30:46 +02:00
Olaf Bergmann 8f37e20f85 coap-server.c: removed parameter local_if from check_async()
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.
2017-08-02 21:26:55 +02:00
Olaf Bergmann 5f7f043ad6 client.c: fix compiler warning for unused transaction id
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.
2017-08-02 21:20:25 +02:00
Olaf Bergmann 8423ebbe8b client.c: allow empty user names
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.
2017-08-02 21:17:07 +02:00
Olaf Bergmann 44f392d29a client.c: added new method names from RFC 8132
Updated the method names for coap-client option '-m' to include
FETCH, PATCH, IPATCH (see [1]).

[1] https://tools.ietf.org/html/rfc8132
2017-07-18 11:43:23 +02:00
Olaf Bergmann 5687681d71 {tests/examples}/Makefile.am: add DTLS variables for static linkage
Statically linked executables require DTLS_CFLAGS and DTLS_LIBS.
2017-07-10 15:33:39 +02:00
jcmichelou 7fb4ace2b7 Fix for the signedness warning with gcc.
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.
2017-06-29 18:12:46 +02:00
jcmichelou b2fe4a64de Make MTU configurable.
Use static or stack storage for coap_packet_t.
2017-06-26 17:34:01 +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 adf1238eae Add DTLS retransmit and recovery.
Add lossy networks debug option in examples.
2017-06-21 20:40:15 +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 78148d0c20 Merge develop into win32 2017-06-10 16:19:12 +02:00
Olaf Bergmann 6d7ba61ae0 libcoap-1.pc: fix pkg-config include path
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))
2017-06-01 12:33:04 +02:00
jcmichelou 9e8a693ffd Fix typo on ipv6 notation for the multicast group address for coap. 2017-05-05 20:48:18 +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