Commit Graph
555 Commits
Author SHA1 Message Date
Olaf Bergmann e15d6ff3ab moved to uthash 1.9.9
Replaced 1.9.3 version of uthash.h and utlist.h by latest files from
https://github.com/troydhanson/uthash with many fixes and improvements.
2015-02-18 15:18:55 +01:00
Olaf Bergmann 961b5e0719 fix compiler warning for strnlen()
strnlen() is used for formatting messages in debug.c. As strnlen() is
unknown in C99, the compiler emits a warning even if configure has
detected the presence of strnlen() in glibc and has set HAVE_STRNLEN
accordingly. To overcome this, the symbol _GNU_SOURCE now is set when
HAVE_STRNLEN and __GNUC__ are defined but not _GNU_SOURCE. This works
not only for glibc prior 2.10 but also for newer versions that conform
to POSIX.1-2008 (see strnlen(1)).
2015-02-18 13:18:18 +01:00
Olaf Bergmann e1dbfc1f55 reflect name change of coap_config.h.in in leading comment 2015-02-17 18:00:08 +01:00
Olaf Bergmann a3653aa389 Removed internal function check_opt_size() that is not used anymore 2015-02-17 16:03:35 +01:00
Carsten Schoenert 792ff19048 src/net.c: fixing gcc warning
The switch {} construct in the function coap_dispatch{} doesn't had a
'default:' directive so the compiler is complaining about that with a
warning.

src/net.c: In function 'coap_dispatch':
src/net.c:1545:5: warning: switch missing default case [-Wswitch-default]
     switch (rcvd->pdu->hdr->type) {
     ^
2015-02-16 17:33:42 +01:00
Olaf Bergmann f1138cc567 Remove dead code from subscribe.[hc]
After the subscription mechanism was re-structured, most of the
code in subscribe.c has been dead and is now removed to avoid confusion.
2015-02-16 17:24:59 +01:00
Olaf Bergmann b87f45eeb2 remove unused code from Contiki server example 2015-02-16 17:04:57 +01:00
Olaf Bergmann 9898a1627f Moved the observing client coap-observer.c into examples/contiki 2015-02-16 16:41:01 +01:00
Olaf Bergmann a4e534d62a Deleted coap-server.c for Contiki
The Contiki example server is now examples/contiki/server.c.
2015-02-16 16:38:39 +01:00
Olaf Bergmann af4aeb2042 Added sample radvd.conf for testing the minimal-net server 2015-02-16 16:31:20 +01:00
Olaf Bergmann 4635435771 Created a self-contained Contiki server example
Directory examples/contiki now contains a small example server for
Contiki and a Makefile for platform minimal-net.

Build:

  make contiki     # clones Contiki
  make server      # creates the minimal-net coap server

Run:

Unfortunately, you have to run the server with sudo unless you
set CAP_NET_ADMIN for both, the server executable, and ifconfig
(sudo setcap cap_net_admin+pei ...).

  sudo ./server

Then, add the server's interface address to the tap0 device and
optionally set a default route:

  sudo ip -6 a a aaaa::1000 dev tap0
  sudo ip -6 r a aaaa::/64 dev tap0

Although everything should work now, it does not. I had to send
router advertisements on tap0:

  sudo radvd -C ./radvd.conf

Note that on Debian (and Ubuntu, and ...), radvd will not start
when IPv6 forwarding is disabled (which is usually the case on
end systems). Trying to enable like this did not work for me:

  sudo sysctl -w net.ipv6.conf.tap0.forwarding=1
  sudo sysctl -w net.ipv6.conf.tap0.mc_forwarding=1

Workaround (ugly): get the radvd sources, compile them and use that.
2015-02-16 16:30:28 +01:00
Olaf Bergmann 77209c6e15 Contiki: Removed size from coap_address_t 2015-02-16 13:42:29 +01:00
Olaf Bergmann b29709f138 Contiki: set port and size for local interface in coap_new_endpoint()
FIXME: size field from coap_endpoint_t should be removed as only
POSIX has different address sizes.
2015-02-16 13:34:39 +01:00
Olaf Bergmann d52f338215 another type fix 2015-02-16 13:33:41 +01:00
Olaf Bergmann 9d352431b2 fixed wrong type in debug message 2015-02-16 13:32:54 +01:00
Olaf Bergmann 8c3cdf5e72 renamed config.h to coap_config.h.lwip, part 2 2015-02-15 22:51:42 +01:00
Olaf Bergmann e46961a5a2 changed config.h.lwip to coap_config.h.lwip 2015-02-15 22:47:54 +01:00
Olaf Bergmann 8ca0840b41 changed name of config.h to coap_config.h 2015-02-15 22:45:51 +01:00
Olaf Bergmann 3ea54a6c8b include stdio.h for printf() 2015-02-15 22:45:13 +01:00
Olaf Bergmann 005d9bf767 more cleanup of Contiki-specific code 2015-02-15 22:44:37 +01:00
Olaf Bergmann 4dc004dc88 internalize definition of coap_packet_t for POSIX only
Contiki and lwIP need to know the size of struct coap_packet_t to
set up their memory pool. Therefore, it must be defined in coap_io.h.
2015-02-15 22:41:57 +01:00
Olaf Bergmann 9785dc777d replaced memb_alloc() stuff for PDUs by coap_malloc_type() 2015-02-15 22:37:45 +01:00
Olaf Bergmann f6b45cb674 Contiki: implement coap_malloc_type() for COAP_PDU
To get rid of the awful (and buggy!) ALIGNPTR stuff that used to
be in coap_pdu_clear(), a new memory type COAP_PDU_BUF has been
introduced for Contiki. This allows storing the message payload
in its own memory chunk similar to the way it is stored for lwIP.
2015-02-15 22:32:56 +01:00
Olaf Bergmann 436912fd44 moved block size check into block.c 2015-02-15 20:41:50 +01:00
Carsten Schoenert 54f31e5763 src/net.c: changing the selection of the union member
On POSIX systems we always have a file device as integer. So picking up
the 'socketfd' within the struct. Otherwise the compiler doesn't really
now what member to pick and gives up.

 src/net.c: In function 'coap_new_context':
 src/net.c:369:13: error: incompatible types when assigning to type 'int' from type 'union <anonymous>'
    c->sockfd = c->endpoint->handle;
              ^
2015-02-14 20:46:49 +01:00
Olaf Bergmann ebb00c4dfe Merge remote-tracking branch 'coap-lwip/chrysn-lwip-fixes' into develop
Conflicts:
	coap_io.h
	mem.h
	net.c
	pdu.c
2015-02-14 20:45:48 +01:00
Olaf Bergmann 5695e73cbe added client option -a
This option allows to bind the client's listen interface.
2015-02-14 20:32:54 +01:00
chrysn cf722e4a63 lwip pdus: update documentation 2015-01-16 12:06:30 +01:00
chrysn d28834a96f lwip port: re-introduce zero-copy pdu creation
this sidesteps the copying parts of coap_parse_pdu, using the directo
allocation of the pdu payload data from the package's pbuf, whose
reference is consumed.
2015-01-16 12:04:40 +01:00
chrysn 4f6c81a5a6 lwip packets: allow pbuf to be extracted 2015-01-16 12:04:03 +01:00
chrysn 6caf836023 lwip pdu implementation: shift from contiguous to memp + pbuf
the old implementation stuffed the pdu struct in front of the
transport-level pbuf, and preserved it on the stack while the packages
were sent.

this had two advantages:

* saving ram
* preserving the other implementation's structure of pdu->hdr == pdu+1
  (ie. starting right after the pdu struct)

but two disadvantages:

* bad readability and pointer juggling in the send routine
* relying on the send function to block until the package is out (which
  works for simple implementations of lwip drivers but not dma etc)

if something really assumes the contiguous memory structure, it will
show (unfortunately by corrupting other pdu structs), and chances are
people use ->hdr anyway.
2015-01-16 12:03:25 +01:00
chrysn 00beb7f1f7 (regroup coap_handle_message code to have pdu handling in one place) 2015-01-16 09:19:58 +01:00
chrysn 8a41533a87 document coap_pdu_t.hdr 2015-01-16 09:15:48 +01:00
chrysn 4cadf731a2 lwip port: store context in endpoint
this is required for the packages incoming via an endpoint to find their
way back to the context.

the relationship between context and endpoint is still to be documented.
2015-01-16 08:45:28 +01:00
chrysn 2680f038b0 lwip port: remove context struct members that are now in endpoint 2015-01-16 08:45:10 +01:00
chrysn fc18a4992b lwip: implement coap_packet_copy_source 2015-01-16 08:44:12 +01:00
chrysn 990098ab50 endpoint adaptions for lwip
possibly, endpoints should be made implementation-private just as
packets are
2015-01-15 13:34:21 +01:00
chrysn 330014445a lwip example updates
* resolve file resolution conflicts between lwip and libcoap in favor of
  lwip by rearranging the makefile

* cover the config.h of a configured base libcoap with the local one
  using the deprecated -I- gcc switch

* enable etharp (no idea why it wouldn't work ootb, the complete
  server.c lwip-contrib copy needs to be reviewed)

* disable optimizations for easier debugging, enable -g3 for macro
  expansions
2015-01-15 13:34:21 +01:00
chrysn c5f48ea4be implement receiving routines for lwip in independent file 2015-01-15 13:34:21 +01:00
chrysn 13d9ee291b provide lwip memory resources for more coap_malloc_type 2015-01-15 13:34:21 +01:00
chrysn bafa1ca05e coap_malloc_type implementation for lwip based on memp
those things need to reside in mem.h (instead of living implementation
dependently inside mem.c) because coap_malloc_type(MY_TYPE, ...) is
converted to memp_malloc(MEMP_MY_TYPE) and thus needs to be done in the
preprocessor. (the alternative would be to switch on the MY_TYPE enum,
which would be harder to maintain).
2015-01-15 13:34:21 +01:00
chrysn 850e895bac drop lwip-isms that can go away with coap_io from net.c 2015-01-15 13:34:21 +01:00
chrysn 7e37762227 coap_cancel: fix COAP_RESOURCES_NOHASH 2015-01-15 13:34:21 +01:00
chrysn 421170b704 use coap_malloc_type to ease lwip porting 2015-01-15 13:34:21 +01:00
chrysn 0ca090fbb6 make the internals of coap_packet_t private
they are now only accessed using helper functions, for a package looks
different in lwip.

in addition, the local_interface is now passed to coap_handle_message
not as an argument (because that would mean mixing different arguments
in the population of the node's local interface), but as a part of the
incoming package (as assigned in coap_network_read).
2015-01-15 13:33:35 +01:00
chrysn bfbb84f962 disable matching-interface check and debugging
this violates the pending package layering and needs to be further
investigated.
2015-01-15 13:23:37 +01:00
chrysn 003c78bfdb lwip example: no explicit call to coap_dispatch
this was done for posix in d5dc48d
2015-01-13 10:50:03 +01:00
chrysn d09f2e29b9 make lwip port buildable again
this fixes

* add coap_tick_diff_t from 3f3c8dc63f
* add COAP_PACKAGE_NAME etc required since 122200d3fd
2015-01-13 10:13:57 +01:00
Olaf Bergmann d48ab449fd added client option -a
This option allows to bind the client's listen interface.
2014-11-06 15:14:15 +01:00
Olaf Bergmann 99108e82d9 fixed alignment bug in PDU memory 2014-11-05 23:47:18 +01:00