Commit Graph
196 Commits
Author SHA1 Message Date
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
Olaf Bergmann 771f013b6e coap-server.c: fixed resource check time calculation
This change is a fix for issue #72 [1].

[1] https://github.com/obgm/libcoap/issues/72
2017-04-12 22:40:34 +02:00
Pawel Winogrodzki 9adc4eb6a7 Fixing /W4 warnings for Windows builds.
Removing all of the /W4 level warnings from the code.
No functional changes.

Signed-off-by: Pawel Winogrodzki <pawelwi@microsoft.com>
2017-03-20 15:48:33 -07:00
Olaf Bergmann 6d882f6ed5 client.c: fix TOCTOU for file input
The function cmdline_input_from_file() allocates a chunk of memory
to hold the contents of the given file. As libcoap does not offer
an interface to realloc(), we have to determine the required buffer
size before starting to read from the file, leading to a classical
TOCTOU condition.

This change mitigates the defect by first opening the file and then
calling fstat(). Note that the subsequent fread() call takes the
size of the pre-allocated buffer into account.
2016-12-02 13:43:45 +01:00
Olaf Bergmann 53183e63b2 coap-server.c: discard result of coap_get_data()
coap_get_data() sets the given result parameter size to 0 if no
data is available. The function's result therefore can be neglected
in hnd_put_time().
2016-12-02 13:35:32 +01:00
Olaf Bergmann d9cb9c826c client.c: abort on invalid URI at command line
cmdline_uri() now aborts operation if an invalid URI was passed
as argument.
2016-12-02 13:22:07 +01:00
Joakim Nohlgård f7a17c975e examples/client: Fix Block1 handling for growing block sizes
Only increment block size if it can be done without causing gaps or
overlaps in the byte sequence.

The patch adds a check for alignment to ensure that no gaps appear when
a server responds with a larger block size than the original request
was using.

Ignore the block number sent by the server since that may or may not be
valid. Always recompute based on how many bytes have been sent so far.

Rationale:

Erbium (Contiki CoAP) responds to Block1 request with a Block1 option
containing the server's maximum supported Block1 size (Contiki
configuration option REST_MAX_CHUNK_SIZE). However, the block number
in the Block1 option is the same number as the block number of the
original request.
2016-12-02 09:52:17 +01:00
Olaf Bergmann 85733a6acb client.c: Added missing option -U in usage info
The new option '-U' was missing in the usage information of
coap-client and the corresponding part of the manual page.
2016-11-19 17:39:48 +01:00
Ken Bannister 572e7110e0 Allow client example to not generate Uri-Host and Uri-Port options.
* Via new command line option, -U.
2016-11-19 17:34:44 +01:00
Carsten Schoenert 18f2309759 make: enable out of tree build
The build environment was lacking the possibility to get libcoap
buildable out of tree, simply checkable by the running 'make distcheck'.
Without this fix the users are impossible to build libcoap in a own
folder that's independed from the source containing folder. Typical use
case would be:

  $ mkdir libcoap-build && cd libcoap-build
  $ /path/to/libcoap-source/configure \
      --srcdir=/path/to/libcoap-source \
      --prefix=/somethere/to-install

This commit enables the out of tree build by adding and changing some
needed variables.
2016-10-26 10:46:50 +02:00
Olaf Bergmann d737344b52 client.c: use function parameter in cmdline_subscribe()
cmdline_subscribe() has used the global variable optarg instead of
the local argument that was passed to this function. Changing this
as intended also makes __attribute__((unused)) unneeded.
2016-09-22 12:43:27 +02:00
Olaf Bergmann 2c36cf4ade client.c: fixed malformed mode-line 2016-09-22 12:41:19 +02:00
chrysn d43d92e40b examples/lwip: depend on coap.h
The handcrafted Makefile will not attempt to build the coap.h, but will
indicate to the user how to generate it.
2016-06-22 12:51:46 +02:00
chrysn 6b6840599a lwip: cleanups of leftover variables and similar compiler warnings
note on coap_read removal: as the lwip implementation currently launches
the package handling right from the recv callback, a coap_read function
is not meaningful (as it is in posix or contiki where it actively
fetches the messages from the network buffer).
2016-06-22 12:38:01 +02:00
chrysn 909d863a4e lwip: Use latest version
This drops the cumbersome mintapif mechanisms from server.c, fixes
header troubles that have popped up probably during the header cleanups,
drops old workarounds and enables IPv6.
2016-06-22 12:37:27 +02:00
Olaf Bergmann 392deff2d7 Makefile.contiki: Added -Os to remove undefined symbol
handle_periodic_timer() in rpl-timers.c relies on the optimizer to
remove the if(0)-guarded call to rpl_ns_periodic() when storing
mode is selected. This does not happen with clang's default options
and thus leads to an error for the undefined reference at link time.

This modification adds -Os to fix this.
2016-06-10 16:41:53 +02:00
Olaf Bergmann 68d910f4fe examples/contiki/Makefile: use --depth 1 for cloning Contiki
This change avoids cloning the entire Contiki history when building
the Contiki server example.
2016-06-10 15:10:02 +02:00
Olaf Bergmann a267d3a2b0 server.c: fixed Contiki-related debug functions
The debug function for printing lladdress have been renamed and moved
to net-debug.h. This change now includes this header and uses the
appropriate macros instead.
2016-06-10 15:07:25 +02:00
Olaf Bergmann 6bf7cdcc45 examples/lwip/Makefile: fixed lwip branch
This example now uses LwIP release 1.4.1 as the devel branch seems
to have disappeared from the git repository. Moreover, we just do
a shallow clone so maybe the server does not kick us that often.
2016-02-16 16:22:45 +01:00
Olaf Bergmann 0afbf5ecba examples/lwip/Makefile: fixed lwip build flags
Since configure does not set WITH_LWIP, we need to tell the compiler.
This change also replaces the deprecated -I. -I- by -iquote.
2016-02-16 15:13:52 +01:00
Olaf Bergmann 0f062e557e Makefile: fixed build infrastructure for Contiki examples
The new structure of libcoap allows to clone Contiki in a
subdirectory. The example build now uses Makefile to first clone
Contiki and then invoke Makefile.contiki for the actual build.
The TARGET is set to minimal-net by default but can be changed to
any other (tested) target.
2016-02-16 14:19:11 +01:00
Olaf Bergmann 4c299f9da6 Makefile.contiki: Fixed build flags for Contiki-3.0
Some configuration flags have been changed since Contiki version 3.
The Makefile.contiki for building a server example that uses libcoap
as a Contiki app has been fixed. The following builds now succeed:

make -f Makefile.contiki TARGET=minimal-net
make -f Makefile.contiki TARGET=econotag
make -f Makefile.contiki TARGET=mbxxx
2016-02-16 13:12:26 +01:00
onovo1 fe69ba5fb6 Update coap-rd.c
According to the Core Resource directory draft [1]. The discovery of the registration should be done using the /.well-known/core and including a Resource Type (rt) with the value "core.rd". Like that:
GET /.well-known/core?rt=core.rd
There is a typo in the libcoap which accept the "core-rd" instead of the "core.rd" parameter. Fixing that in this version.

[1] - https://tools.ietf.org/html/draft-ietf-core-resource-directory-05#section-5.1
2016-01-28 10:34:14 +02:00
Olaf Bergmann 7452d7d50f coap-server.c: updated URI to libcoap's homepage in resource '/' 2016-01-10 18:06:26 +01:00
Carsten Schoenert b4973f1d73 fixup argument list for uip_ds6_prefix_add
uip_ds6_prefix_add is using 6 arguments, better use explicit argument
list than let the compiler decide. Some compiler will complain if some
optionally arguments are missed.
2016-01-10 17:49:07 +01: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
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
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 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 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
Carsten Schoenert 21431bcb2f examples/Makefile.am: small fix for the path declaration 2015-06-02 20:41:37 +02:00
Carsten Schoenert 47e0c25c38 examples/Makefile.am: changing header includes
The build of the examples is complaining about a function that are not
inline'd. The compiler is mentioned this because we use the '-I'
directive for pointing to the header files. Just say the compiler also
that the header files are system headers so the false positive is going
away.
2015-03-22 14:38:36 +01:00
Carsten Schoenert da3570cb41 examples/Makefile.am: fix not needed target
The target 'install-exec-am' is obviosly wrong and not really needed.
2015-03-22 13:37:28 +01:00
Olaf Bergmann d9d20d906b rd.c: Fixed type-specifier warning
For POSIX, coap_tick_t is defined as unsigned long to support
timestamps in wallclock time. The rd uses ticks to make node
identifiers locally unique. As this is just one part of the
generated identifier, the timestamp's lower 32 bits are
sufficient.
2015-03-12 13:05:56 +01:00
Olaf Bergmann 41e3247c9b rd.c: Fixed a bunch of compiler warnings 2015-03-12 12:30:57 +01:00
Carsten Schoenert 60030d0fb4 examples: adding the examples folder to the build
After including the doc/ and the tests/ folder under the hood of the
autotools now adding the examples/ foolder too.
The user is now able to add the build of the example binarys if
configure is called with '--enable-examples' as option. The example
binarys will not be build by default!

Currently only 'coap-client', 'coap-server' and 'rd' is build.
2015-03-12 11:25:26 +01:00
Olaf Bergmann d55bd85e14 examples/contiki/server.c: Define clock_offset locally
The global variable clock_offset has been removed from libcoap, so
we have to define our own.
2015-03-11 14:37:18 +01:00
Olaf Bergmann f1b36046f2 Contiki: Make sure that COAP_RESOURCES_NOHASH is defined 2015-03-11 14:34:06 +01:00
Olaf Bergmann b9adebec93 client.c: Fixed signed/unsigned in comparisons 2015-03-10 13:47:38 +01:00
Olaf Bergmann 005d00bf5b client.c: Declare unused parameters to make -Wunused quiet 2015-03-10 13:42:40 +01:00
Olaf Bergmann 445849d5ba client.c: Made private functions static to quiet compiler warnings 2015-03-10 13:41:02 +01:00
Olaf Bergmann c38a6d9ca4 Made private functions static to quiet compiler warnings 2015-03-10 13:25:08 +01:00
Olaf Bergmann 9b1ab5eef3 server.c: Declare unused parameters to make -Wunused quiet 2015-03-10 13:06:03 +01:00