Commit Graph
1727 Commits
Author SHA1 Message Date
Olaf Bergmann 98cf51eae2 README.md: Added status badge for OSS-Fuzz
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/
2019-09-19 09:50:38 +02:00
obgm 1ccd3685ee Merge pull request #407 from mrdeep1/readme_update
README.md: Add in further information about libcoap
2019-09-17 12:58:37 +02:00
Jon Shallow 6e25d9df91 README.md: Add in further information about libcoap
Add in information on Documentation and Building.
Update the Package contents.

LICENCE:

Update date.
2019-09-17 11:19:58 +01:00
Olaf Bergmann 4e626d53a4 .travis.yml: Expand build matrix with EPOLL and SMALL_STACK
Some builds now have epoll support disabled and small stack enabled.
2019-09-13 14:04:05 +02:00
Olaf Bergmann 4a13437b69 scripts/build.sh: Additional options for epoll and small stack
* 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.
2019-09-13 12:44:55 +02:00
Olaf Bergmann 45b5d23665 .travis.yml: Move Contiki and LwIP to separate stage
Special handling of platforms other than POSIX reduces the build
matrix and thus speeds up CI once additional configure options
need to be checked.
2019-09-13 12:28:45 +02:00
obgm f5cf6ef5cc Merge pull request #405 from mrdeep1/small_stack
configure.ac: Make COAP_CONSTRAINED_STACK configurable
2019-09-13 11:26:18 +02:00
obgm 9893c7222b Merge pull request #402 from mrdeep1/windows_project
Fix Windows builds
2019-09-12 13:01:48 +02:00
Jon Shallow c5ab99369f Fix Windows builds
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.
2019-09-12 11:49:26 +01:00
Jon Shallow 75e3e8595d configure.ac: Make COAP_CONSTRAINED_STACK configurable
Add in support for --enable-small-stack to define
COAP_CONSTRAINED_STACK in coap_config.h
2019-09-11 15:41:14 +01:00
obgm 3266e6cfcc Merge pull request #404 from obgm/pthread-configure-check
Pthread configure check
2019-09-11 12:03:01 +02:00
Olaf Bergmann abec5b8228 coap_mutex.h: Use pthread mutexes if detected by configure
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.
2019-09-10 13:28:44 +02:00
Olaf Bergmann 07156ea048 configure.ac: Check for pthread.h and pthread_mutex_lock 2019-09-10 13:14:50 +02:00
Olaf Bergmann 30583fbed9 coap_session.h: Adjust whitespace 2019-09-09 17:17:49 +02:00
Olaf Bergmann d49d38849e Merge branch 'develop' of github.com:obgm/libcoap into develop 2019-09-09 17:17:05 +02:00
obgm 49867a8c48 Merge pull request #400 from mrdeep1/reverse_enums
Revert out changes to make 1 byte enums
2019-09-09 17:16:50 +02:00
Olaf Bergmann da1ac8572c Merge branch 'develop' of github.com:obgm/libcoap into develop 2019-09-09 14:31:25 +02:00
obgm a584864bcf Merge pull request #397 from mrdeep1/configure_epoll
Make epoll support configurable if O/S supports epoll
2019-09-09 14:31:11 +02:00
Jon Shallow 209c8a9267 Revert out changes to make 1 byte enums
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.
2019-09-09 09:59:44 +01:00
Jon Shallow 480aa73bd7 Make epoll support configurable if O/S supports epoll
Add in --with-epoll as a ./configure option
2019-09-06 13:03:52 +01:00
Olaf Bergmann 859f953c5b Merge branch 'develop' of github.com:obgm/libcoap into develop 2019-09-05 15:22:05 +02:00
obgm 228a800f9d Merge pull request #395 from mrdeep1/inline_warnings
Fix -Winline compiler warnings about inlining failed
2019-09-05 15:21:50 +02:00
Jon Shallow 9f9a197e95 Fix -Winline compiler warnings about inlining failed
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.
2019-09-05 13:54:05 +01:00
Olaf Bergmann 1fc107b62c Merge branch 'develop' of github.com:obgm/libcoap into develop 2019-09-05 14:42:53 +02:00
obgm 0138cd8f65 Merge pull request #396 from mrdeep1/bind_issue
Fix bind() address size for Mac OS X
2019-09-05 14:42:25 +02:00
Jon Shallow 22d078a854 Fix bind() address size for Mac OS X
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.
2019-09-04 16:37:10 +01:00
Olaf Bergmann 183a5326ef Merge branch 'develop' of github.com:obgm/libcoap into develop 2019-09-03 13:40:32 +02:00
obgm f0abb2d81b Merge pull request #345 from mrdeep1/obsfucate_coap_subscription_t
Make coap_subscription_t and coap_endpoint_t opaque to applications
2019-09-03 13:40:16 +02:00
Jon Shallow 2900f72a64 Make coap_subscription_t and coap_endpoint_t opaque to applications
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.
2019-09-03 11:59:07 +01:00
Olaf Bergmann ff232966ae Merge branch 'develop' of github.com:obgm/libcoap into develop 2019-09-02 16:17:46 +02:00
obgm ab6dafe8c5 Merge pull request #388 from mrdeep1/code_protect
Remove reserved identifiers from coap_config.h for specific builds
2019-09-02 16:17:16 +02:00
Jon Shallow b7d7107db3 Remove reserved identifiers from coap_config.h for specific builds
coap_config.h.contiki:
coap_config.h.lwip:
coap_config.h.windows:

Strip leading _ in the file protection wrappers.
2019-09-02 14:21:27 +01:00
Olaf Bergmann 1fedfc809a [Contiki] coap_debug.c: Fix warning about unused parameter
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.
2019-08-30 17:01:25 +02:00
Olaf Bergmann c8da431594 coap_debug.c: Fix format truncation 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.
2019-08-30 16:55:23 +02:00
obgm 34c5e52029 Merge pull request #347 from mrdeep1/epoll
Add in internal epoll support to expose a monitor-able file descriptor
2019-08-30 14:34:56 +02:00
Jon Shallow 0e02d751da Add in internal epoll support to expose a monitor-able file descriptor
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.
2019-08-30 11:51:15 +01:00
obgm 7ed9121a38 Merge pull request #384 from mrdeep1/coap_make_str_const
str.h: Fix coap_make_str_const() for C++
2019-08-30 12:31:28 +02:00
Jon Shallow 5d32ffe920 str.h: Fix coap_make_str_const() for C++
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
2019-08-30 10:29:17 +01:00
obgm 66100dba2f Merge pull request #393 from mrdeep1/sigpipe
Fix SIGPIPE causing unexpected exit of example applications
2019-08-29 17:40:38 +02:00
obgm b2c6040d03 Merge pull request #392 from mrdeep1/handler-doc
coap_handler.txt.in: Add in clarification notes for handler parameters
2019-08-29 17:36:17 +02:00
obgm 34e9c910d1 Merge pull request #391 from mrdeep1/multicase-enforce
net.c: Enforce non-confirmable for multicast request messages
2019-08-29 17:35:31 +02:00
obgm c73214f882 Merge pull request #390 from mrdeep1/multicast-logging
net.c: Log correct address in coap_read_session()
2019-08-29 17:33:55 +02:00
Jon Shallow 003b64ab3f Fix SIGPIPE causing unexpected exit of example applications
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.
2019-08-29 12:58:15 +01:00
obgm 16b77c3e6c Merge pull request #383 from kb2ma/develop
Client example show payload on block1 completion
2019-08-29 12:14:23 +02:00
Ken Bannister f76e5d9062 Client example show payload on block1 completion 2019-08-25 08:29:24 -04:00
Jon Shallow 82b04b8df8 net.c: Enforce non-confirmable for multicast request messages
Enforce RFC7252 8.1 "Such multicast requests MUST be Non-confirmable"
by logging the PDU error and dropping the PDU tranamission.
2019-08-22 14:19:04 +01:00
Jon Shallow 6e3e65f128 coap_handler.txt.in: Add in clarification notes for handler parameters
Document why certain parameters may be NULL.
2019-08-22 14:15:29 +01:00
Jon Shallow ddf8691b8d net.c: Log correct address in coap_read_session()
Move the coap_log() entry to after updating the session information.

Seen when coap-client is doing multicast request sends
2019-08-22 13:07:24 +01:00
obgm bee3bb2862 Merge pull request #387 from mrdeep1/doc_ordering
Order the doxygen Modules and Manual Pages listings alphabetically
2019-08-14 21:29:28 +02:00
obgm 4a6d885889 Merge pull request #386 from mrdeep1/define_enum
Convert #define to enum where possible
2019-08-14 12:53:26 +02:00