OSS-Fuzz [1] is a decentralized fuzzing service for open-source
software projects. This badge shows the status of libcoap wrt to the
latest fuzzer runs.
[1] https://google.github.io/oss-fuzz/
* Passing EPOLL=no disables the epoll interface usage. Other values
default to yes, i.e. epoll is used if available.
* Passing SMALL_STACK=yes enables some values stored in static
variables instead pushing on the stack. This usually requires
mutex support in the operating system.
coap_config.h.windows:
Windows has struct cmsghdr so use it.
Update libcoap versions.
include/coap2/coap.h.windows:
Update libcoap versions.
Bring in line with build include/coap2/coap.h.
include/coap2/coap_session.h:
Include coap_forward_decls.h so things build correctly.
win32/libcoap.vcxproj:
win32/libcoap.vcxproj.filters:
Add in missing include files.
On systems that support pthread mutexes, stack usage can be minimized
with the use of static variables. Concurrent access is protected
on these systems with mutexes. Platforms that do not have pthread
support must map the coap_mutex_* macros accordingly.
include/coap2/coap_dtls.h
include/coap2/coap_session.h
include/coap2/pdu.h
man/coap_encryption.txt.in
src/net.c
Revert out all the #define -> enum in #386 that require the enum to be
one byte long.
This is compiler version dependent when doing static inline expansions.
examples/client.c:
Make hex2char() just static.
examples/etsi_iot_01.c:
Make coap_add_payload() just static.
include/coap2/address.h:
src/address.c:
Make coap_address_init() an actual function.
libcoap-2.map:
libcoap-2.sym:
Expose coap_address_init() as a function.
Makefile.libcoap:
Include address.c as one of the libcoap files for Contiki.
examples/lwip/Makefile:
Include address.o as one of the libcoap files for LwIP.
It appears that MAC OX X (10.13.2) builds do not like the size of the sa to
be larger than the size of struct sockaddr_in when working with IP v4
addresses.
src/coap_io.c
Update the bind() calls to use the correct address size for IP v4.
include/coap2/coap_subscribe_internal.h and
include/coap2/coap_session_internal.h contain the information not exposed
to applications.
This internal information was moved out of the respective
include/coap2/subscribe.h and include/coap2/coap_session.h files comprising of
the coap_subscription_t and coap_endpoint_t definitions.
To ease inter .h file dependencies, a new file
include/coap2/coap_forward_decls.h is added to include forward declarations
for both libcoap and applications.
Makefile.am:
Include include/coap2/coap_*internal.h as files for distribution, but not
installed for applications to use.
Include include/coap2/coap_forward_decls.h, so it is installed for
applications.
include/coap2/coap.h.in:
Include "coap_forward_decls.h"
include/coap2/coap_forward_decls.h: (New)
Forward declare structures and typedef the structures defined in
coap_internal.h.
include/coap2/coap_internal.h: (New)
Includes all the required #include files that libcoap internally needs.
include/coap2/coap_session_internal.h: (New)
Include the coap_endpoint_t information taken from
include/coap2/coap_session.h.
include/coap2/coap_session.h:
Remove coap_endpoint_t definition.
include/coap2/lwippools.h:
Add in coap_forward_decls.h and coap_internal.h to handle the LwIP memory
allocations.
include/coap2/resource.h:
Add in "block.h" to allow things to build.
include/coap2/coap_subscribe_internal.h: (New)
Include the coap_subscription_t information taken from
include/coap2/subscribe.h.
include/coap2/subscribe.h:
Remove coap_subscription_t definition.
libcoap-2.map:
libcoap-2.sym:
Updated, removing coap_subscription_init().
src/address.c:
src/asyn.c:
src/block.c:
src/coap_debug.c:
src/coap_event.c:
src/coap_gnutls.c:
src/coap_hashkey.c:
src/coap_io.c:
src/coap_io_lwip.c:
src/coap_notls.c:
src/coap_openssl.c:
src/coap_session.c:
src/coap_time.c:
src/coap_tinydtls.c:
src/encode.c:
src/mem.c:
src/net.c:
src/option.c:
src/pdu.c:
src/resource.c:
src/str.c:
src/subscribe.c:
src/uri.c:
Add in '#include "coap_internal.h"' to the source files.
Remove other libcoap #include files.
win32/libcoap.vcxproj:
win32/libcoap.vcxproj.filters:
Update for Windows build (not tested).
examples/contiki/server.c:
src/coap_io.c:
Remove knowledge of endpoint from the server and update Contiki's
version of coap_run_once() to do the work instead.
====
Other structures (plus some internal required #defines) will follow as
separate PRs.
As no f[v]printf() functions are available on Contiki, the given
file descriptor is not used. This change fixes the corresponding
compiler compiler warning.
When COAP_DEBUG_BUF_SIZE is smaller than the buffer size for holding
temporary strings in coap_show_pdu(), the compiler will emit a
warning as snprintf() truncates the output string. Moreover, this
will result in a missing terminating zero.
This fix adjusts the temporary buffer size if COAP_DEBUG_BUF_SIZE
is very small (i.e., on Contiki), and sets the last character in
outbuf to \000 when necessary.
If epoll is available, use it within libcoap to speed things up, as well as
present to applications a file descriptor that can be used in a select() or
returned as an event in a epoll_wait() call.
Whenever coap_new_context() is called. set up a new epoll infrastructure with
epoll_create() and destroy it with coap_free_context().
For each new endpoint or session, add the socket fd to epoll. When the socket
is closed, remove the socket fd from epoll.
Whenever a socket wants a write, the appropriate epoll event gets EPOLLOUT
added and when the write happens reset the event back to just EPOLLIN.
As there may be a packet retry event sometime in the future, a timerfd is
created and added to the epoll structure (done in coap_new_context) which gets
freed off in coap_free_context. If coap_run_once() determines that there is
a future retry, timerfd is informed of when the event is to occur. When
timerfd times out, the application file descriptor will indicate a read is
available.
A new function coap_context_get_coap_fd(ctx) returns the application file
descriptor. The only other API change is that if wait_ms is set to 1 for
coap_run_once(ctx, wait_ms), there is no waiting for a new packet to arrive.
coap_run_once() is called, whether epoll support is available or not, to
process all the underlying required i/o.
If there is no epoll support, coap_run_once() continues to use the old
select() method, otherwise it will use epoll_wait(). If there is epoll
support, a modified version of coap_read() (coap_io_do_events()) is
used instead.
Makefile.am:
Do not expose coap_epoll_ctl_mod() and coap_io_do_events() to applications.
configure.ac:
Test for the presence of sys/epoll.h and sys/timerfd.h and if so setup
COAP_EPOLL_SUPPORT to be used for #ifdef testing.
Include new man page coap_io.txt.
examples/coap-server.c:
Include support for using this new exposed file descriptor.
include/coap2/coap_io.h:
Define COAP_MAX_EPOLL_EVENTS (to limit the number of events processed at once)
and include coap_endpoint_t and coap_session_t in coap_socket_t.
Include (internal) definition for coap_epoll_ctl_mod()
include/coap2/net.h:
Add epfd and eptimerfd to coap_context_t.
Define coap_context_get_coap_fd() for applications to use.
Include (internal) definition for coap_io_do_events().
Define COAP_RUN_BLOCK and COAP_RUN_NONBLOCK.
libcoap-2.map:
libcoap-2.sym:
Include coap_context_get_coap_fd.
configure.ac:
man/Makefile.am:
man/coap.txt.in:
man/coap_io.txt.in: (New)
Include the new coap_in(3) man page that documents coap_run_once() and
coap_context_get_coap_fd().
src/coap_io.c:
src/coap_openssl.c:
src/coap_session.c:
src/net.c:
Add in the epoll support.
src/net.c:
Add in coap_context_get_coap_fd() function.
As pointed out in issue #368 [1], C++ officially forbids aggregate
initialization for non-aggegrates. This change therefore introduces
an alternative version (which works for both C and C++) to provide
the required functionality.
str.c:
str.h:
Make coap_make_str_const() a function.
examples/coap-server.c:
Fix parameter type in coap_add_attr() call.
src/resource.c:
Static variables can no longer make use of coap_make_str_const().
libcoap-2.map:
libcoap-2.sym:
Make coap_make_str_const() appication visible.
Fixes#368.
[1] https://github.com/obgm/libcoap/issues/368
Update
examples/client.c:
examples/coap-rd.c:
examples/coap-server.c:
examples/etsi_iot_01.c:
examples/tiny.c:
Make the applications ignore SIGPIPE.
examples/coap-rd.c:
Support clean exit for SIGTERM / SIGQUIT for valgrind testing.