Commit Graph
735 Commits
Author SHA1 Message Date
Olaf Bergmann d90bc9164e fixed issue #17: COPYING and README.md named the wrong license
LICENSE.BSD is a 2-clause ("simplified") BSD license. The files
COPYING and README.md erroneously have termed it the "revised BSD
license".
2015-12-19 13:41:08 +01:00
Carsten Schoenert a0b31e74d1 configure.ac: increase dep on Autoconf 2.64 2015-12-16 16:09:34 +01:00
Olaf Bergmann a5b61409a5 coap_io.c: set local address after bind for new endpoint
This fixes a bug reported by Daniel Petrie:

"When the coap-client is used and a local address to bind to is
specified, but the local port is not specified, I get errors for the
response coming in from an unexpected interface and the response is
dropped/ignored."

The solution here is to call getsockname() after successful bind()
in coap_new_endpoint() to set ep->addr to the actual transport
address being used.
2015-10-27 13:05:03 +01:00
Olaf Bergmann 3f5a797776 net.c: fixed critical option check
The limitation of COAP_OPT_FILTER_SHORT to six entries made the
critical option check fail e.g. for Block2. This change hard-codes
the built-in critical options in coap_option_check_critical() so
that up to COAP_OPT_FILTER_SHORT short options and COAP_OPT_FILTER_LONG
long options can be registered dynamically.

Please note that registering critical options that are already known
(i.e. listed in pdu.h and checked in coap_option_check_critical())
is a waste of storage space.
2015-10-01 19:27:50 +02:00
Olaf Bergmann 2da31de732 configure.ac: fix disable options
The options --disable-documentation and --disable-examples did
not have the desired effect in some configurations. Now, if any
of documentation or examples is disabled, the manual pages in
the examples folder are not created.
2015-09-30 19:46:34 +02:00
Olaf Bergmann 683337890e bugfix: add flag for CON/NON notification messages
Two new flags COAP_RESOURCE_FLAGS_NOTIFY_NON and
COAP_RESOURCE_FLAGS_NOTIFY_CON have been added to control the
message type for notifications to send. The default type is
COAP_RESOURCE_FLAGS_NOTIFY_NON which can be changed with the
function coap_resource_set_mode().

The observer-specific flag has been removed.
2015-09-29 09:03:18 +02:00
franc0is 11daf0545a Fix coap_ticks platforms with no _POSIX_TIMERS
(cherry picked from commit bde305210e)
2015-09-09 14:04:44 +02:00
Olaf Bergmann 7f2134db6f client.c: fixed empty service parameter in getaddrinfo call
Baptiste Clenet <bapclenet@gmail.com> has pointed out that passing
an empty string causes address resolution to fail in certain cases.
This modification replaces the service parameter in the getaddrinfo
call with NULL as suggested.
2015-09-08 18:06:03 +02:00
Olaf Bergmann eef94ce673 Merge remote-tracking branch 'github-obgm/develop' into develop
Re-sync with github version of libcoap. Accidently, a PR has been
accepted that was fixed on the SF master version during the July
outage.
2015-08-23 10:49:53 +02:00
obgm a06449d25b Merge pull request #1 from cgundogan/fix_readme
README: translate oder => or
2015-07-21 11:06:07 +02:00
Cenk Gündoğan a5ac6e2917 README: translate oder => or 2015-07-20 19:20:46 +02:00
Carsten Schoenert 63924379e3 testdriver: switch linking to the shared library
The testdriver was linked against the statically generated library of
libcoap. By this the testdriver will *always* find any symbols, no
matter if it is a private or public symbol.
Due this the testing behavior isn't the same as a user would use the
shared library and can get a potentially pitfall even if the testdriver
was successful.

Due previous changes to the public header the testdriver source needs
now the local header coap_config.h to find all needed functions so there
are small changes needed to the source files.
2015-07-04 19:35:10 +02:00
Carsten Schoenert ea9c1cbedb i/c/*.h: remove references to coap_config.h
The public header doesn't have to include a local dynamically created
header file from the autotools. This would break the usability of the
public header files.
2015-07-04 19:35:02 +02:00
Olaf Bergmann 889ba08ad0 updated map files to reflect API changes
Commit 1baa816 moved the implementation of coap_clock_init() and
coap_ticks_to_rt() to coap_time.c. This commit updates the public
API of the shared lib accordingly.
2015-06-28 15:12:27 +02:00
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 838d5ce37b configure.ac: make A2X precious
A2X is explicitly declared with AC_ARG_VAR to allow users to pass
a custom value to configure. Thus, users who do not have a2x
installed can invoke

  A2X=/bin/true ./configure --enable-examples

to prevent configure stopping on the a2x check.
2015-06-27 15:38:32 +02:00
Carsten Schoenert 842a4135a7 CONTRIBUTE: update section 6 due latest changes 2015-06-22 21:25:43 +02:00
Carsten Schoenert 19d66df457 .gitignore: adding man pages and related temp files 2015-06-22 21:25:43 +02:00
Carsten Schoenert b1099ed620 autogen.sh: rework the cleaning option
Added the new files from the examples/ folder and remove the leading '\'
from various lines, it's useless.
2015-06-22 21:25:43 +02:00
Carsten Schoenert 141eefdbb6 a2x: adding a check for needed helper
The previous commit added some asciidoc based man pages that need a2x
from the asciidoc package. To ensure the build will not break due a not
available a2x binary we better check before.
2015-06-22 21:25:43 +02:00
Carsten Schoenert 3e9afb1460 examples/*: adding example binaries man page support
This commmit adds the build of man pages for the binaries from the
example/ folder, in detail these are coap-client.5, coap-rd.5 and
coap-server.5.
The source of the man pages is written in asciidoc so the build
environment must have access to a installed asciidoc package.
2015-06-22 21:25:43 +02:00
Carsten Schoenert cb55cb44da examples/*coap-client*: whitespace cleanup, reformatting, no changes
Just some cleanup like whitespace, punctiation marking and indentation
issues.
2015-06-19 20:54:31 +02:00
Carsten Schoenert 60bb15edd7 examples/coap-server.c: whitespace cleanup, reformatting, no changes
Just some cleanup like whitespace, punctiation marking and indentation
issues.
2015-06-19 20:54:31 +02:00
Carsten Schoenert bda1a2360b examples/coap-rd.c: whitespace cleanup, reformatting, no changes
Just some cleanup like whitespace, punctiation marking and indentation
issues.
2015-06-19 20:54:30 +02:00
Carsten Schoenert 1043892391 rename the example binaries to more strict naming schema
To normalize (and in preparation for manpages) the currently used files
for the example implementation of a CoAP based client, server and a
resource directory various files and variables are rename to coap-*.
2015-06-19 20:53:47 +02:00
Carsten Schoenert 1a4113ca7e autogen.sh: adopt cleaning after API change
The pkg-config file is now named libcoap-1.pc and was forgotten to
change too in autogen.sh while changing the API versioning within the
commits 1ea9e1c and 24a83b7.
2015-06-19 20:53:47 +02:00
Carsten Schoenert f0f271778f drop previous renamed *.in files
With commit cda3b72 the migration to a fully Autotools controled build
environment was started which is now finished. The previous used *.in
files was renamed to *.in.old to hold some maybe usefull informations
from the old system. We don't need this renamed files any longer so kill
it with fire.
2015-06-19 20:52:47 +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 ee931e8f37 examples/client.c: Removed multicast join
As the client can send to multicast groups without explicitly joining,
this code is not required here and instead moved to the server
implementation.
2015-06-10 18:10:43 +02:00
Olaf Bergmann b9bcdc10ff examples/server.c: added flag -g to join multicast groups
This code is taken from client.c where it makes no sense.

TODO: leave group when the server is stopped.
2015-06-10 18:08:33 +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 e4519daf14 pdu.h: new coap_send() result code for dropped responses
The new coap_tid_t code COAP_DROPPED_RESPONSE can be used to
indicate that a response has been dropped by coap_send_impl().
2015-06-10 17:52:14 +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 774fc01ec1 tests: temporarily change log-level to remove expected warnings
Some unit tests in tests/test_options.c and tests/test_pdu.c check
for error cases, causing warning messages to be emitted by the
library code. As the expected result is checked separately, the
warnings can be suppressed to avoid confusion.
2015-06-07 12:32:09 +02:00
Olaf Bergmann 24a83b7b0e updated libcoap-1.{map,sym} to include new option filter functions
With commit e4e2e57, three new functions have been added to the
public API, hence the symbol files need an update.
2015-06-07 12:30:12 +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 8e73295b66 tests/test_options.c: Added unit tests for option filters
A new test suite 'option filter' was added to the CUnit tests to
check correctness of the new option filter implementation.
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 c5a1faad0c pdu.h: Added code for No-Response option
IANA has reserved 284 for No-Response, described in
http://www.iana.org/go/draft-tcs-coap-no-response-option

See also:
http://www.iana.org/assignments/core-parameters/core-parameters.xhtml#option-numbers

As a side-effect, COAP_MAX_OPT was set to 65535.
2015-06-07 12:21:57 +02:00
Olaf Bergmann 83c17e8f17 testdriver.c: Remove comment on known bugs
With commit eec9ad2, the two outstanding bugs in the test suite
have been fixed.
2015-06-07 12:21:57 +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
Olaf Bergmann 1ea9e1c213 Renamed libcoap-1.0.{map,sym,pc.in} to libcoap-1.{map,sym,pc.in}
As commit 8380870 has simplified the API version numbering, these
filenames must be adjusted.
2015-06-07 12:11:48 +02:00
Carsten Schoenert d01e1cad2e expand i/c/coap.h to include additional information
The header coap.h should be the only header file a user has to include
to get functions from the libcoap available. Bu we have to provide not
only the header interface to the user, the user needs also some extra
information like the libcoap version or upstream related infos.

To get these automated in to a shipped coap.h header file we simple can
use some autotool magic and expand some macros while configure is
running and pasing i/c/coap.h.in. By this we can currently add the
following macro variables:

 LIBCOAP_PACKAGE_BUGREPORT -> upstream email contact
 LIBCOAP_PACKAGE_NAME      -> the used package name (libcoap)
 LIBCOAP_PACKAGE_STRING    -> package name + version
 LIBCOAP_PACKAGE_URL       -> upstream homepage
 LIBCOAP_PACKAGE_VERSION   -> the current used version

All these macros variables are expanded from the respective macro names
from the configure run. The variables are prefixed because this with
LIBCOAP_ to not get name clashing on the user side while running the
autotools of the users project.

There are probably more predefined macros needed, but they can be easily
added later into include/coap/coap.h.in.
2015-06-02 20:41:37 +02:00