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.
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.
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.
* 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
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).
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).
This change contains a quick and dirty workaround for the following
bug that has been reported by Andrea Azzarà:
"When sending a file with a POST to a CoAP server, such as
./coap-client -m post coap://vs0.inf.ethz.ch:5683/large-create/ -b 64
-t 0 -f test
the M bit is not correctly set to 1."
Since the local_interface was added to the request handler callback,
the examples rd.c and etsi_iot_01.c were broken. This change fixes
rd.c and abandons etsi_iot_01.c (as it is very outdated).
Incoming messages are matched to nodes in the retransmission
queue by comparing a hash value over (message id, port, ip addr).
For IPv4, the entire sockaddr_in structure was compared which
is potentially wrong (see merge request #7 from Dag Björklund).
Hopefully, this fixes the encountered issue.