Commit Graph
849 Commits
Author SHA1 Message Date
Olaf Bergmann 25863042ae tinydtls: updated to latest version with cross-compilation fixes
This update enables cross-compilation by specifying the option
--host to configure. For example, building libcoap with tinydtls
for raspberry pi now can be done as follows (given that you have
the required compiler; on Debian, apt-get install gcc-arm-linux-gnueabihf
should do):

  git submodule update --init --recursive
  ./autogen.sh
  ./configure --host=arm-linux-gnueabihf --disable-shared --disable-documentation
  make
coap-tinydtls
2017-04-18 16:44:35 +02:00
tijuca 1ba4fd0cec Cross compilation issue (#31)
The error that happen while cross compiling is quite logical if you
know what the check AC_FUNC_MALLOC is made for. The behavior isn't
really wrong (for me) because autoconf can't really test the created
code due it's for another platform. Some nice explanation about the
whole problem can be found here:
http://wiki.buici.com/xwiki/bin/view/Programing+C+and+C%2B%2B/Autoconf+and+RPL_MALLOC

As long as libcoap uses malloc from the libc we need a check for
the proper implementation for this cases. So removing AC_FUNC_MALLOC
isn't solving the problem. We need at least a check for a malloc
functionality which can be done by AC_CHECK_FUNC(S).

(cherry picked from commit 04d806fe4d)
2017-04-18 16:39:27 +02:00
Olaf Bergmann b5ffd36bb8 Updated tinydtls to version 0.8.6 2017-04-12 21:34:51 +02:00
Olaf Bergmann dc91eb9a1a client.c: allow user name and key to be empty
RFC 4279 allows psk_identity and psk to have a length of zero, so
-u and -k now are optional for coaps: resources.
2017-04-12 21:32:30 +02:00
Olaf Bergmann 538170628a coap_dtls.c: Fixed dummy functions for --disable-dtls build
When compiled without support for DTLS, coap_dtls.c contains a set
of dummy functions to make certain compilers and linkers happy. As
the function signature now differs from the prototype, the attribute
has been removed entirely (causing a set of warnings that report the
unused parameters.)
2016-07-18 22:03:22 +02:00
Olaf Bergmann 48e694f3ba Merge branch 'dtls' of github.com:obgm/libcoap into dtls 2016-06-15 17:41:11 +02:00
obgm f64e72bae1 Merge pull request #34 from malinengineer/dtls
dtls branch - ignored some generated files
2016-06-15 17:40:52 +02:00
Alin Micu 3038c7c250 Updated .gitmodules to ignore untracked files in the 'tinydtls' submodule 2016-06-15 18:11:45 +03:00
Alin Micu c96d47d0b0 updated the .gitignore file to ignore 'tags' files generated by ctags for a Sublime Text plugin 2016-06-15 18:05:58 +03:00
Alin Micu 0494efcba2 Updated .gitignore to ignore the *.o *.lo files in the subfolders of src as well (e.g. src/platform/posix) 2016-06-15 18:05:08 +03:00
Olaf Bergmann a692789685 net.[hc]: Added storage for application-specific data to coap_context_t
The new functions coap_set_app_data() and coap_get_app_data() can be
used to store application-specific data with a given coap_context_t
object.
2016-04-26 17:38:32 +02:00
Olaf Bergmann d3d48a99e8 libcoap-1.{map,sym}: Updated map file
Added the functions coap_dtls_set_log_level() and coap_dtls_get_log_level()
2016-04-15 13:19:33 +02:00
Olaf Bergmann 5f9579b01f client.c: Pass coap log level to DTLS library
The log level now is set by the new function coap_dtls_set_log_level().
2016-04-15 13:18:31 +02:00
Olaf Bergmann d77b4b0215 coap_dtls.[hc]: Encapsulate DTLS log level manipulation
The new function coap_dtls_set_log_level() can be used to control
the logging facility of the underlying DTLS library. The argument's
semantics are defined by the library itself.

coap_dtls_get_log_level() returns the current log level of the
underlying DTLS library.
2016-04-15 13:16:22 +02:00
Olaf Bergmann b911b3ef43 Merge branch 'dtls' of github.com:obgm/libcoap into dtls 2016-04-08 15:15:09 +02:00
Olaf Bergmann 89bf45723c Makefile.am: bugfix: replaced makefile variable by m4-expanded symbol
As automake processing prevents using makefile variables in prefixed
automake constructs such as *la_SOURCES, platform-specific locations
must be spelled out literally.

This fixes issue #30, see https://github.com/obgm/libcoap/issues/30
2016-04-08 15:14:20 +02:00
Olaf Bergmann c217ff6352 plaform/posix/{coap_io,run}.c: fixed LWS in source
Removed trailing whitespace and reformatted indentation as suggested by
Carsten in [1].

[1] https://sourceforge.net/p/libcoap/mailman/message/34988221/
2016-04-08 15:14:20 +02:00
Olaf Bergmann 5ebd003a80 coap_dtls.c: Discard DTLS session on fatal error
When a fatal error is detected for an ongoing DTLS session, any
retransmission is stopped and the session object is released.
2016-04-08 15:14:20 +02:00
Olaf Bergmann 4b9b38cdc9 configure.ac: bugfix: removed empty AC_SEARCH_LIBS 2016-04-08 15:14:20 +02:00
Olaf Bergmann b34e56cba2 coap_keystore.h: bugfix: do not expose coap_config.h in public API 2016-04-08 15:14:20 +02:00
Olaf Bergmann 4e75cc0c42 ext/tinydtls: updated to HEAD of branch develop 2016-04-08 15:14:20 +02:00
Olaf Bergmann f6472f8c84 libcoap-1.{map,sym}: updated map files 2016-04-08 15:14:20 +02:00
Olaf Bergmann 999a46d710 net.c: moved DTLS-specific code to coap_send_impl()
coap_send_impl() now decides if outbound data is passed to coap_dtls_send()
or to the registered network_send callback function.

For coap_send_confirmed() this implies that retransmitted PDUs are
passed to coap_dtls_send() as well, causing retransmissions on the
DTLS layer when the session is established. As long as the DTLS handshake
is not complete, coap_dtls_send() caches the outbound application data
for this particular PDU hence avoiding duplicate messages.
2016-04-08 15:14:20 +02:00
Olaf Bergmann 022238df4d coap-server.c: DTLS server with default credentials for PSK
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.
2016-04-08 15:14:20 +02:00
Olaf Bergmann 094f733440 client.c: added command line options for DTLS credentials
The new option -u allows setting the user name (aka PSK identity) and
-k is used to specify the corresponding secret (the PSK).
2016-04-08 15:14:20 +02:00
Olaf Bergmann 205efaed92 coap_dtls.c: bugfix: set correct error code for wrong credentials
get_psk_info() now returns appropriate error codes.
2016-04-08 15:14:20 +02:00
Olaf Bergmann a3059ab781 net.c: bugfix: call coap_read_endpoint() only when data available
coap_read_endpoint() should not be called when no data is available
on the attached endpoint.
2016-04-08 15:14:20 +02:00
Olaf Bergmann b734208ed2 coap_event.[hc]: pass library events to application
An application can register a callback function of type
coap_event_handler_t that will be called by the library on certain
events. Currently, the DTLS implementation invokes coap_handle_event()
with session-specific events such as session close or
renegotiation.
2016-04-08 15:14:20 +02:00
Olaf Bergmann 578b38dbfa coap_dtls.[hc]: improved session handling
The handling of DTLS sessions has been improved so that calling
coap_dtls_send() buffers data for later delivery in case of a
successful handshake.
2016-04-08 15:14:20 +02:00
Olaf Bergmann 655e84c040 net.[hc]: Changed interface for coap_handle_message()
The local endpoint object, peer address and data buffer address and
length now are passed as arguments to coap_handle_message(). This
change reverts a previous attempt to provide a more concise interface
for this function that hides the actual implementation-specific data.

As the DTLS implementation needs to deal with this implementation-
specific parts, it has to be made explicit, either by making the
packet abstraction public or passing the relevant parameters
explicitely to coap_handle_message(). As this has worked smoothly
before, this approach has been taken.

This change breaks the LWIP implementation (for now). It will be fixed
when integrating the DTLS code with LWIP in this branch.
2016-04-08 15:14:20 +02:00
Olaf Bergmann 90fb5fdffc dtls: Added basic keystore implementation
coap_keystore.[hc] provides a simple data structure for managing
credentials to be used during DTLS handshake. Each coap_context_t
has its own keystore object that is independent of the actual
DTLS context. Applications can access the keystore during the
entire lifetime of the coap context. The existing implementation
is not thread-safe.
2016-04-08 15:14:20 +02:00
Olaf Bergmann e3b82756c0 dtls: create DTLS session for outgoing NON messages 2016-04-08 15:14:20 +02:00
Olaf Bergmann 39698f7ba7 dtls: added initial boilerplate for dtls support
coap_dtls.h defines a generic API for DTLS communication. The
initial version will use tinydtls as implementation.
2016-04-08 15:14:20 +02:00
Olaf Bergmann 009934e298 coap_io.c: make socket non-blocking for platform posix
Making the posix sockets non-blocking was missing from coap_new_endpoint().
This wasn't much of a problem because recvmsg() was called only after
select() had indicated that data is available. Setting this flag explicitly
would also allow for peeking into the socket.
2016-04-08 15:14:20 +02:00
Olaf Bergmann 73aa574f16 coap_io.h: define flag to indicate that data is available
Non-blocking sockets can set COAP_ENDPOINT_HAS_DATA in flags to tell
coap_read() that this endpoint has new data available for reading.
2016-04-08 15:14:20 +02:00
Olaf Bergmann 3d7c0d22ea address.h: added missing includes for POSIX 2016-04-08 15:14:20 +02:00
Olaf Bergmann c031e99dfc net.h: added missing prototypes
The prototypes for coap_attach_endpoint() and coap_detach_endpoint()
were missing from this header file.
2016-04-08 15:14:20 +02:00
Olaf Bergmann 9a538f43f4 pdu.h: added coaps default port 2016-04-08 15:14:20 +02:00
Olaf Bergmann 3a127a3816 uri.[hc]: improved support for 'coaps' URI scheme 2016-04-08 15:14:20 +02:00
Olaf Bergmann 5180ae3753 Updated tinydtls 2016-04-08 15:14:20 +02:00
Olaf Bergmann d42aa27bee examples/*.c: Use coap_run*() in examples 2016-04-08 15:14:20 +02:00
Olaf Bergmann cadfe3df62 configure.ac: Test for sys/select.h 2016-04-08 15:14:20 +02:00
Olaf Bergmann 63f51418c5 run.[hc]: Add new functions for main loop
This modification provides two new functions, coap_run_once() and
coap_run(), that can be used by applications to drive the library's
I/O logic.
2016-04-08 15:14:20 +02:00
Olaf Bergmann 3d3eb02ad8 net.[hc]: allow multiple endpoints in single context
Endpoints will be attached to the context object using a new function
coap_attach_endpoint(). The sockfd component has been removed from
coap_context_t as it is accessible by the endpoint.
coap_endpoint_t has a new field 'context' that refers to the context
object the respective endpoint has been associated with, or NULL
if it is not attached to any context. An endpoint can be attached
to at least one context at a time.
2016-04-08 15:14:20 +02:00
Olaf Bergmann cfdfd030f9 coap_io.c: Moved to platform/posix/ 2016-04-08 15:14:20 +02:00
Olaf Bergmann 96d572d309 prng.c: move platform-specific PRNG invocation into separate files
This change introduces a new subtree in the library's directory structure.
Platform-specific code now should be placed into the corresponding directory
in src/platform/. To illustrate this, prng.h has been split into three
distinct files, one for each platform (contiki, lwip, posix) and moved into
the respective subdirectory.
2016-04-08 15:14:20 +02:00
Olaf Bergmann 45349d5bf3 Makefile.am: bugfix: replaced makefile variable by m4-expanded symbol
As automake processing prevents using makefile variables in prefixed
automake constructs such as *la_SOURCES, platform-specific locations
must be spelled out literally.

This fixes issue #30, see https://github.com/obgm/libcoap/issues/30
2016-04-08 15:08:10 +02:00
Olaf Bergmann 7dea55099f resource.c: bugfix: Memory leak from hash table
The function coap_delete_all_resources() did not free the hash buckets
created by HASH_ADD. Thus, the iterator must call HASH_DELETE to free
the allocated storage.

This bug has been discovered  by
Jean-Michel Julien <Jean-Michel.Julien@trilliantinc.com>
who also provided this fix. See [1] for more information.

[1] https://sourceforge.net/p/libcoap/mailman/message/34994226/
2016-04-06 12:43:27 +02:00
Olaf Bergmann ca0f3f3188 plaform/posix/{coap_io,run}.c: fixed LWS in source
Removed trailing whitespace and reformatted indentation as suggested by
Carsten in [1].

[1] https://sourceforge.net/p/libcoap/mailman/message/34988221/
2016-04-05 16:34:10 +02:00
Olaf Bergmann 4a5f381978 src/net.c: bugfix: remove observer on cancel before invoking resource handler
When a client sends a GET request with Observe: 1, it must be removed from
the list of observers before the resource handler is called. Otherwise, it
will add an Observe option to its response.
2016-04-05 14:51:48 +02:00