Commit Graph
32 Commits
Author SHA1 Message Date
Olaf Bergmann 1baa8163b5 coap_time.[hc]: make ticks relative to global offset for POSIX
For POSIX platforms, ticks have been absolute which caused an
overflow on 32-bit architectures. This modification makes values
returned by coap_ticks() relative to a global offset stored
internally in coap_clock_offset.
2015-06-28 15:04:52 +02:00
Olaf Bergmann 155adae29a coap_io.c: Include multicast addresses in is_local_if()
is_local_if() checks if a message's destination address matches
a local interface. As multicast requests are allowed on either
interface, this function now returns true when the destination
address is a multicast address.
2015-06-10 18:25:32 +02:00
Olaf Bergmann ababd3f7f2 net.c: Removed misleading comment
The behavior of coap_send_impl() has been changed long time ago
but this comment was still there.
2015-06-10 18:06:30 +02:00
Olaf Bergmann 91f37ae1a7 coap_io.c: select outbound interface when responding to multicast requests
coap_network_send() uses the address given by local_interface as
source address of outgoing IP packets. For responses to requests
that have been received via IP multicast, this address is a
multicast group and thus must not be set as source in the IP header.

As a workaround, this change clears the address and ifindex so that
the kernel selects a suitable outbound interface.
2015-06-10 17:59:52 +02:00
Olaf Bergmann d989bb174c net.c: Suppress RST and error responses for multicast requests
When a request has been received via IP multicast, negative
responses including RST should not be sent. This modification
uses the new result code COAP_DROPPED_RESPONSE to indicate that
the response was intentionally suppressed. As the error handling
code only checks for COAP_INVALID_TID, no error messages will
be emitted due to this new behavior.
2015-06-10 17:55:36 +02:00
Olaf Bergmann 3c84f5c012 net.c, pdu.h: ensure that valid transaction ids are positive
The calculation of transaction ids did not ensure that the result
is always greater or equal zero. To avoid conflicts with the error
codes returned by coap_send(), the calculation now masks out the
lower half.
2015-06-10 17:46:53 +02:00
Olaf Bergmann 83a06c7969 net.c: removed debug output from function no_response() 2015-06-10 13:07:06 +02:00
Olaf Bergmann 3e10a49c43 debug.c: added option No-Response to list of known option types
With this change, the new No-Response option is recognized by the
helper function msg_option_string() called from coap_show_pdu() for
pretty-printing CoAP messages.
2015-06-07 12:21:58 +02:00
Olaf Bergmann e4e2e57218 option.[hc]: new option filter implementation
The implementation of option filters based on coap_opt_filter_t
has changed to improve support for long option numbers. An option
filter is now a sparse field of a fixed size that can hold up to
COAP_OPT_FILTER_LONG options with a number larger than 255, and
up to COAP_OPT_FILTER_SHORT options with a number of 255 or less.

The space taken by coap_opt_filter_t is
2 * ((((COAP_OPT_FILTER_SHORT + 1) >> 1) + COAP_OPT_FILTER_LONG) + 1),
or 12 bytes with the default settings for COAP_OPT_FILTER_SHORT == 6
and COAP_OPT_FILTER_LONG == 2.

Three new functions have been added to the option filter API:
* coap_option_filter_set() to store an option number in a filter,
* coap_option_filter_get() to check if a filter contains a given
  option number, and
* coap_option_filter_unset() to remove an option number from a
  filter.

The previously existing functions coap_option_setb(), coap_option_getb(),
and coap_option_clrb() continue to work on the new option filter
unchanged but now are deprecated.
2015-06-07 12:21:58 +02:00
Olaf Bergmann 6db8e5172d net.c: fixed calculation of mask bit for no-response option
* The shift in function no_response was off by one bit.
* The response code must be checked, not the request method.
2015-06-07 12:21:58 +02:00
Olaf Bergmann bf9a3c7a1b net.c: Implementation of No-Response option
Response suppression according to draft-tcs-coap-no-response-option-11.
2015-06-07 12:21:58 +02:00
Olaf Bergmann 81d4297b50 option.[hc]: Fix type of option parameter
Since CoAP options can have a numeric type between 0 and 65535, the
type parameter of coap_check_option() must be at least 16 bits.
2015-06-07 12:21:57 +02:00
Olaf Bergmann 519da113a3 debug.c: improved output of zero-length option values
The function print_readable() did not add a terminating zero in case
len == 0. Now, the output buffer will always have a terminating '\0'
when buf has at least one byte free (i. e. buflen > 0). Note that the
function result does not include the trailing zero-byte.
2015-06-07 12:15:30 +02:00
Olaf Bergmann 312fc9251b debug.c: made output of coap_show_pdu() more readable
The new format[0] was inspired by the discussion[1] on the IETF CoRE
mailing list. Changes include:

* Print human-readable message type and method/response code
* Output token included in {...} even if token is empty
* Print human-readable option types
* Print human-readable option values where possible
* Print human-readable Content-Format and Block options
* Print hex string included in <<...>> for binary content,
  human-readable string included in '...' for text content
* Use '::' as payload delimiter if message contains a payload

[0] http://www.ietf.org/mail-archive/web/core/current/msg06069.html
[1] http://www.ietf.org/mail-archive/web/core/current/msg06062.html
2015-06-07 12:15:30 +02:00
Bergmann ab8f4a9e45 coap_time.c: Apple does not support clock_gettime()
Although _POSIX_TIMERS is defined on MacOSX no clock_gettime() is
provided, so we have to fall back to gettimeofday().
2015-03-13 14:03:12 +01:00
Olaf Bergmann 83b19e6f16 resource.c: always include utlist.h and mem.h for all platforms 2015-03-11 16:12:55 +01:00
Olaf Bergmann 2250db4c95 address.[hc]: make coap_address_equals() not inline on POSIX
gcc-4.8 -Winline keeps complaining about the function's size, so
it is now placed into address.c.
2015-03-11 16:08:58 +01:00
Olaf Bergmann 3a78280982 mem.c: Added missing include for coap_resource_t and coap_attr_t 2015-03-11 15:28:10 +01:00
Olaf Bergmann ecda1426ac resource.c: Increase use of coap_malloc_type() and coap_free_type()
coap_malloc_type() and coap_free_type() provide an abstract API for
dynamic memory management on different platforms. resource.c still
is in transition and needs more cleanup.
2015-03-11 14:59:40 +01:00
Olaf Bergmann 65620fde3e resource.[hc]: Replaced custom list structures by utlist macros.
The CoAP resource management is based on uthash and utlist for
platform POSIX but used a custom list implementation for Contiki.
This modification replaces the list handling by utlist macros
entirely. A set of convenience macros has been defined to access
the resources stored in a CoAP context with respect to the
preprocessor symbol COAP_RESOURCES_NOHASH.
2015-03-11 14:28:24 +01:00
Olaf Bergmann 55c6efeca8 coap_split_uri: Check if port number is in valid range
This change is made to resolve the failed URI parser test
t_parse_uri5()
2015-03-09 18:01:34 +01:00
Olaf Bergmann 3e99d6634e Fixed documentation of coap_split_path_impl() 2015-03-09 17:56:08 +01:00
Olaf Bergmann 0c53e63a3d Fixed URI parser bug and removed broken parser iterator
The parser iterator did not break up URIs correctly. As this
cannot be fixed easily, the parser iterator has been removed.
coap_split_path_impl() now operates directly on the message
buffer instead of the iterator abstraction.

This bug also caused t_parse_uri12() in the URI test suite
to fail.
2015-03-09 17:49:21 +01:00
Olaf Bergmann 8894f2ffec Fixed a couple of warnings from doxygen. 2015-03-09 14:53:01 +01:00
Olaf Bergmann 4ca91190d6 Revised time-related functions to get rid of clock_offset for POSIX platform.
* Removed tne preprocessor defines for coap_tick() and coap_clock_init() --
  this made the code less readable and seemed to be of little use.

* Introduced the new type coap_time_t to represent wall clock time. On POSIX,
  this is the number of seconds since the epoch, while on embedded systems
  without a real time clock, this could be the number of seconds since the
  last reboot. The new function coap_ticks_to_rt() is used to convert
  coap_tick_t to coap_time.h. Currently, this is a division by COAP_TICKS_PER_SECOND
  on all platforms.

* POSIX: coap_tick_t is now defined as unsigned long to avoid overflows in
  coap_ticks().
2015-03-08 15:14:43 +01:00
Olaf Bergmann 853049fe47 Make private functions static 2015-03-04 14:57:26 +01:00
Olaf Bergmann 71de08ac5f Fix warnings in resource.c
Internal functions are now static. print_wellknown() is exported
as coap_print_wellknown() to make it accessible from net.c and
for unit tests.
2015-03-04 14:55:26 +01:00
Olaf Bergmann e297a0ca76 Fix warnings in net.[hc]
Internal functions are now static. wellknown_response() is exported
as coap_wellknown_response() to make it accessible for unit tests.
2015-03-04 14:43:42 +01:00
Olaf Bergmann 78b96e606d Fix lwip example 2015-03-03 22:03:37 +01:00
Olaf Bergmann 53f35526db Define SOL_IP to IPPROTO_IP for platforms that do not have it 2015-03-03 19:21:44 +01:00
Carsten Schoenert 0d1fa72073 src/coap_io.c: fix definition of struct in*_pktinfo
On some systems we must the struct in_pktinfo and in6_pktinfo defining
by ourself. But on POSIX systems the definition is made by the header
netinet/in.h, so check if there is a flag HAVE_NETINET_IN_H been set and
skip the self made definition.
2015-03-03 19:21:43 +01:00
Carsten Schoenert fc9b47167a moving library related files to new folders
In preparation for changing the make buildsystem to a fully autotools
controlled system moving the core libcoap source files to a better logical
place.

All the library related header files moving to include/coap/ to get
all the public and local header files in a separate place. Also moving
the C source files of the libcoap library to the folder src/.
2015-03-03 19:21:43 +01:00