mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-11 19:30:40 +03:00
This updates the initial work done for adding in cache support include/coap2/coap_cache.h: (new) include/coap2/coap_cache_internal.h: (new) src/coap_cache.c: (new) New files to support cache support. CMakeLists.txt: Makefile.amMakefile.am: Makefile.libcoap: configure.ac: examples/lwip/Makefile: include/coap2/coap.h.in: include/coap2/coap.h.windows: win32/libcoap.vcxproj: win32/libcoap.vcxproj.filters: Add in the new files. examples/client.c: Fix valgrind reported memory leak. examples/coap-server.c: Add in new example_data resource that uses the new caching logic. Update hnd_put() to use the new cache logic for BLOCK1 PUTs. include/coap2/coap_forward_decls.h: include/coap2/coap_internal.h: include/coap2/coap_session.h: include/coap2/net.h: Add in new cache support. libcoap-2.map: libcoap-2.sym: Include the new functions. man/Makefile.am: man/coap.txt.in: man/coap_cache.txt.in: (new) Update documentation. src/coap_io.c: Idle timeout cache entries. src/coap_session.c: Delete cache entry when session is deleted. src/net.c: Delete cache entries when context is freed off. src/coap_gnutls.c: src/coap_mbedtls.c: src/coap_notls.c: src/coap_openssl.c: src/coap_tinydtls.c: Add in SHA256 digest support.
Example of libcoap running on lwIP
==================================
To run the example, do
$ make
$ sudo ./server
(and in a second terminal)
$ sudo ip a a dev tap0 192.168.113.1/24
and query `coap://192.168.113.2/time?ticks` with any coap tool,
or query `coap://[aaaa::1000]/.well-known/core`
This will
* download lwip and lwip-contrib from the upstream git sources
* build the server application
* run the server application, creating a virtual network device tap0 (unless
that exists)
* configure your network interface to make the server accessible.
* return the appropriate response from the server to the client.
The server creates a resource for 'time' with a query 'ticks'. This is
reported for `.well-known/core`. The work flow for adding more resources does
not differ from regular libcoap usage. If you seem to run out of memory
creating the resources, tweak the number of pre-allocated resources
in `include/coap/lwippools.h`.