man/coap_attribute.txt.in:
man/coap_context.txt.in:
man/coap_encryption.txt.in:
man/coap_handler.txt.in:
man/coap_io.txt.in:
man/coap_keepalive.txt.in:
man/coap_logging.txt.in:
man/coap_observe.txt.in:
man/coap_pdu_setup.txt.in:
man/coap_recovery.txt.in:
man/coap_resource.txt.in:
man/coap_session.txt.in:
man/coap_tls_library.txt.in:
Make sure the full list is defined in the NAME section
[Gives a2x warnings that there are more than 10 entries, but this is OK]
Update where BUGS can be reported to.
man/Makefile.am:
Remove EXTRA_PAGES as all the names are now defined A2X_EXTRA_PAGES.
There needs to be an easy way to validate that the examples provided in the
man pages compile without errors.
This PR provides a new executable examples-code-check that can be run against
the .txt.in files that are in the man directory. It abstracts the code for
each example and then runs the compiler against that stub code reporting errors
and warnings as appropriate for subsequent fixing in the man page.
.gitignore:
Ignore the new executable and the files it generates.
Makefile.am:
configure.ac:
Remove MAN_DIR and hard code in the man directory so that examples-code-check
is always built.
autogen.sh:
Make sure that all the temporary stub code files are cleaned up.
man/Makefile.am:
Support building and clean-up of the new examples-code-check.
man/examples-code-check.c: (new)
The code that parses the man pages, looking for examples and the gets
the examples compiled, testing for errors.
The function definitions in the SYNOPSIS section are also included in the
compilation of the examples.
scripts/build.sh:
If WITH_TESTS is set, check that the man page examples compile.
man/coap_encryption.txt.in:
man/coap_io.txt.in:
man/coap_observe.txt.in:
man/coap_pdu_setup.txt.in:
man/coap_resource.txt.in:
man/coap_session.txt.in:
Correct the SYNOPSIS function definitions.
examples/coap-server.c:
Track time spent in the epoll branch for the select() and coap_io_process()
calls to correctly adjust wait_ms.
Adjust wait_ms to be the remaining amount in the current second, so that
any 'time' observers get the updated time just after the new second starts.
include/coap2/net.h:
Add in support to track that an observe is pending transmission - primarily
a saving of needing to look up if a observe needs to be sent.
include/coap2/resource.h:
Add in support to track the context that 'owns' a resource.
src/resource.c:
Track the context that 'owns' a resource in coap_add_resource().
Track the fact that when we are making a resource partially dirty by recording
that an observe is pending in coap_notify_observers().
In the epoll case, make sure that timerfd triggers immediately when a pending
observe is set so that the application will return immediately from any select()
etc. call to process the libcoap outstanding activity (in particular pending
observes) in coap_resource_notify_observers().
Only call coap_notify_observers() in coap_check_notify if there are any
observes pending.
man/coap_observe.txt.in:
Minor clarifications in the examples.
coap_session_str(3) is defined in both coap_session.txt.in and
coap_logging.txt.in. This fix removes the duplicate so that it is
only part of coap_logging.txt.in.
Other minor corrections and including definition for coap_is_tcp_supported.
man/Makefile.am:
Correct EXTRA_PAGES definition.
man/coap_session.txt.in:
Remove references to coap_session_str definitions.
Add in coap_is_tcp_supported() definition.
man/coap_tls_library.txt.in:
Correct some typos.
Replace COAP_RUN_BLOCK with COAP_IO_WAIT and COAP_RUN_NOBLOCK with
COAP_IO_NO_WAIT for naming clarity.
Instead of COAP_IO_NO_WAIT being 1, make it -1 to fix 1ms busy loop.
Handle the case when coap_io_prepare_io returns 0 to prevent indefinite
select() wait.
include/coap2/net.h:
Make the timeout_ms parameter uint32_t in coap_io_process*() functions to
make sure special case of COAP_IO_NO_BLOCK is correctly handled on different
architectures.
Update COAP_IO_NO_BLOCK to -1.
src/coap_io.c:
Fix the 1ms busy loop and potential infinite wait in the non epoll case.
man/coap_io.txt.in:
Update documentation to reflect the changes.
examples/coap-server.c:
examples/contiki/server.c:
Update to use COAP_IO WAIT and COAP_IO_NO_WAIT as appropriate.
coap_read(), coap_write() and coap_run_once() are confusing in their names
and do not really describe what they do.
For example, coap_read() does both reading and writing, coap_write() may
do some writing, but primarily is used to determine what should be monitored
and for how long to wait in the following select() or epoll_wait() calls.
coap_run_once() implies that the code is only to be run once - again confusing.
By renaming coap_read() to coap_io_do_io(), this better describes what this
function does.
By renaming coap_write() to coap_io_prepare_io() this better describes what this
function does.
By renaming coap_run_once() to coap_io_process(), this better describes what
this function does.
By renaming coap_io_do_events() to coap_io_do_epoll(), this better describes what
this function does and is associated with.
A wrapper function coap_io_prepare_epoll() has been created, using
coap_io_prepare_io() with some preset values to simplify function usage.
include/coap2/net.h:
Update with the new function names, and deprecate the old functions. Also
document the fact that coap_io_prepare_io(), coap_io_do_io(),
coap_io_prepare_epoll(), and coap_io_do_epoll() are really internal functions.
Create app_io module for Doxygen.
libcoap-2.map:
libcoap-2.sym:
Expose the new functions to applications.
examples/client.c:
examples/coap-rd.c:
examples/coap-server.c:
examples/contiki/coap-observer.c:
examples/contiki/server.c:
examples/etsi_iot_01.c:
man/coap_io.txt.in:
man/coap_observe.txt.in:
src/coap_io.c:
src/coap_io_lwip.c:
src/net.c:
src/pdu.c:
Update using the new function names.
Setting the etimer has been moved out of coap_io_process() into
coap_io_do_epoll(), making the logic easier for applications to use
coap_io_do_epoll() should they need to. This also gets rid of a
potential timing window where a pending etimer event gets missed.
coap_io_do_epoll() now calls coap_io_prepare_epoll() if the etimer has
triggered removing the need for applications using coap_io_do_epoll() to
set up their own loops if etimer is triggered.
man/coap_attribute.txt.in:
man/coap_context.txt.in:
man/coap_encryption.txt.in:
man/coap_handler.txt.in:
man/coap_logging.txt.in:
man/coap_observe.txt.in:
man/coap_pdu_setup.txt.in:
man/coap_recovery.txt.in:
man/coap_resource.txt.in:
man/coap_session.txt.in:
man/coap_tls_library.txt.in:
Add in reference to MbedTLS where appropriate.
man/coap_encryption.txt.in:
Add in PKI Key type COAP_PKI_KEY_PEM_BUF for passing in PEM information
that is held in memory instead of in a file.
https://tools.ietf.org/html/rfc7641#section-4.5 requires that non-confirmable
observe responses should be sent as confirmable at least once every 24 hours.
However there is a requirement to override this periodical confirmable sending
behavior in lossy under DDoS attack type environments.
https://tools.ietf.org/html/draft-ietf-dots-signal-channel-41#section-4.4.2.1
Add in support for, and document, a new coap_resource_init() flag
COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS to handle this non RFC7641 requirement.
examples/client.c:
Update to send SNI if coaps, but certs/PSK not defined.
examples/coap-server.c:
Add in -S option to support changing certificate/ca if there is as SNI match.
man/coap-server.txt.in:
Update man page with new -S option.
doc/main.md:
Correct copyright date
man/Makefile.am:
Update A2X_EXTRA_PAGES to include man pages that have digits in the name
man/coap_context.txt.in:
man/coap_encryption.txt.in:
man/coap_handler.txt.in:
man/coap_logging.txt.in:
man/coap_observe.txt.in:
man/coap_pdu_setup.txt.in:
man/coap_resource.txt.in:
man/coap_session.txt.in:
Update with _psk2() information.
Update examples to remove compiler warnings
man/coap-client.txt.in:
man/coap-rd.txt.in:
man/coap-server.txt.in:
Add in documentation on additional support for using / testing out the new
_psk2() functionality
man/coap_resource.txt.in:
Add in coap_resource_set_userdata() and coap_resource_get_userdata()
documentation
include/coap2/resource.h:
Re-organize order and put into appropriate doxygen groups
include/coap2/subscribe.h:
Fix Doxygen title case
src/coap_openssl.c:
Remove NULL as a valid cipher from the cipher list.
Add in TLSv1.3 ciphers if OpenSSL 1.1.1 (they are already included in
TLSv1.2 definition, but this is to document this is happening).
Remove the TLSv1.0 deprecated ciphers.
Cipher strings can now be overridden during compilation by
using -DCOAP_OPENSSL_CIPHERS=xxx compiler option where xxx is the
cipher string as defined in
https://www.openssl.org/docs/man1.1.0/man1/ciphers.html
Explicit PSK cipher strings can now be overridden during compilation
by using -DCOAP_OPENSSL_PSK_CIPHERS=xxx compiler option where xxx is the
cipher string.
Log the client ciphers presented, and the cipher chosen.
include/coap2/coap_debug.h:
src/coap_debug.c:
Add in COAP_LOG_CIPHERS as a debug level (value 9) which matches getting the
cipher information reported in GnuTLS, and is now used for OpenSSL.
man/coap-client.txt.in:
man/coap-rd.txt.in:
man/coap-server.txt.in:
Include OpenSSL for verbosity > 7.
coap_write() and coap_read() are really internal functions that are called
from within coap_run_once() separated by a select() to wait for i/o and
ideally should not be used in applications.
However, currently, coap_write() and coap_read() are needed instead of
coap_run_once() if there is no epoll support in libcoap so that if additional
non libcoap FDs need to be set up and monitored by the select() call they
then can be processed accordingly if the non libcoap FDs are set in the
select() response.
coap_io_process_with_fds() is a new function extending coap_run_once() that
allows non libcoap FDs to be monitored in the coap_run_once() internal
select() call and can then be tested by the caller of
coap_io_process_with_fds().
coap_run_once() now calls coap_io_process_with_fds() with readfds, writefds,
exceptfds set to NULL and nfds set to 0.
Note: nfds, readfds, writefds and exceptfds are ignored if there is underlying
epoll support in libcoap as epoll functions are used, not select(). Use
coap_context_get_coap_fd() to get a single FD that covers all the libcoap
FDs that can be used in the application along with other non-libcoap FDs
when there is epoll support. See coap_io(3) for further information.
include/coap2/net.h:
libcoap-2.map:
libcoap-2.sym:
man/coap_io.txt.in:
src/coap_io.c:
Include and document the new coap_io_process_with_fds() function.
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.
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 suggested in #292, several lists of #define could easily be defined
as enum instead - which allows for extra compiler checking.
The challenge was for where the (#define/enum) parameter defined in a
structure was one byte in size. Doxygen was picky and got confused, not
maintaining the fact that it was an enum if macros were used to differentiate
between using Microsoft or GCC when changing the enum size default from that
of an int.
include/coap2/coap_dtls.h:
include/coap2/coap_session.h:
include/coap2/pdu.h:
Use enums instead of #define where practical.
src/net.c:
Handle all the enum cases.
man/coap_encryption.txt.in:
man/coap_tls_library.txt.in:
Update man documentation.
examples/client.c
man/coap-client.txt.in
Update information for the -O option to indicate that a leading 0x causes
the hex text to be included as binary data.
As COAP_NACK_RST is used for
1. ICMP Port Unreachable message is received
2. CoAP reply RST message.
there needs to be a way to differentiate between these conditions.
If there is detected to be an ICMP response issue to sending a UDP
packet, report this as COAP_NACK_ICMP_ISSUE instead of COAP_NACK_RST.
If the reported issue to coap_session_disconnected() is COAP_NACK_ICMP_ISSUE,
then make sure that the packet (plain or DTLS) gets re-transmitted.
As hinted in #131 discussion, retry of the packet should be attempted,
(as per https://tools.ietf.org/html/rfc7252#section-4.2 ICMP Unreachable)
this fix will cause the plain packet to get retransmitted up to the maximum
retry count if type CON.
Likewise, DTLS will get restarted up to the maximum retry count if type CON.
examples/client.c:
Include COAP_NACK_ICMP_ISSUE in the nack_handler.
include/coap2/coap_io.h:
Add in COAP_NACK_ICMP_ISSUE to coap_nack_reason_t.
src/coap_session.c:
Update coap_session_disconnected() so that plain/DTLS can restart.
src/net.c:
Fix coap_wait_ack() to exponentially back off the re-transmit times.
Update coap_read_session() to report COAP_NACK_ICMP_ISSUE instead of
COAP_NACK_RST.
man/coap_handler.txt.in:
Update documentation
Add in support for both reliable and unreliable sessions when calling
coap_context_set_keepalive().
include/coap2/coap_session.h:
Track the last ping mid in coap_session_t.
src/coap_io.c:
src/coap_session.c:
Support both reliable and unreliable sending of pings in coap_write().
src/net.c:
Determine whether RST packet response is associated with a CoAP Empty Ping
that was sent and handle accordingly.
configure.ac:
examples/client.c:
include/coap2/net.h:
man/Makefile.am:
man/coap-client.txt.in:
man/coap.txt.in:
man/coap_handler.txt.in:
man/coap_keepalive.txt.in: (New)
man/coap_observe.txt.in:
Add in a new man page (coap_keepalive).
Update documentation to remove references to TCP and reliable only.
As coap-server now sets up 2 (or 4) endpoints, UDP and TCP based, all
subsequent endpoints are pre-pended to the ctx->endpoint list. Thus
ctx->endpoint will always be TCP based. Setting IPV6_JOIN_GROUP on a TCP
socket is a no-no.
As join() is complex function, it should be within libcoap so as to not require
detailed knowledge of how internal structures work (which really should be
opaque to the application writer).
include/coap2/net.h:
src/net.c:
libcoap-2.map:
libcoap-2.sym:
Create coap_join_mcast_group() in src/net.c (as it is a network layer
function using the (fixed) join() code. (Iterate through the ctx->endpoint list
looking for UDP based endpoints and only do the IPV6_JOIN_GROUP on them.)
There is no support for WITH_CONTIKI or WITH_LWIP at this point (returns -1).
examples/coap-server.c:
Remove join() code and replace call to join() with coap_join_mcast_group()
examples/coap-rd.c:
Remove join() code and replace call to join() with coap_join_mcast_group()
man/coap-rd.txt.in:
Correct a typo in the coap-ed man page
Currently the following complaint is in the build logs
man/Makefile.am:56: warning: ':='-style assignments are not portable
man/Makefile.am:56: warning: shell for fil in $(TXT3: non-POSIX variable name
man/Makefile.am:56: (probably a GNU make extension)
Correct issue by using
configure.ac:
AC_SUBST([DOLLAR_SIGN],[$])
man/Makefile.am:
to substiture for $ as in $(shell ...
and replace := with =
Part Three:
man/Makefile.am:
Determine additional man pages created by a2x with A2X_EXTRA_PAGES.
Set EXTRA_PAGES for the hand crafted additional man pages.
Clean out the additional installed coap_*.3 man pages using uninstall-man:
in man/Makefile.am
Add in -n option to support making require_peer_cert configurable, by default
it is enabled unless -n is set.
examples/coap-server.c:
Code changes.
man/coap-server.txt.in
Update documentation
Re-organize usage() and man pages to seperate out the PSK and PKI options
for clarity - as they may not be available for all TLS library versions
examples/client.c
examples/coap-server.c
man/coap-client.txt.in
man/coap-server.txt.in
man/coap-client.txt.in
man/coap-rd.txt.in
man/coap-server.txt.in
Document usage over -v7 for extra GnuTLS library output.
man/coap_attribute.txt.in
man/coap_context.txt.in
man/coap_encryption.txt.in
man/coap_handler.txt.in
man/coap_logging.txt.in
man/coap_observe.txt.in
man/coap_pdu_setup.txt.in
man/coap_recovery.txt.in
man/coap_resource.txt.in
man/coap_session.txt.in
man/coap_tls_library.txt.in
Include new -lcoap-@LIBCOAP_API_VERSION@-gnutls option.
Remove trailing spaces at end of line
man/coap_encryption.txt.in
Update with GnuTLS information
man/coap_logging.txt.in
Update with more information about logging levels.
man/coap_tls_library.txt.in
Include new functions coap_show_tls_version() and coap_string_tls_version()
Adding the version of the API to the include directive on the examples
to fulfill the correct information within the man pages related to the
changes made to the library source if API version related modifications
are done.
hashkey.[ch] files restored (now prefixed with coap_)
LWIP and Contiki builds now include these files
block.[ch]:
New function coap_add_data_blocked_response() to simplify GET
responses and handle adding in BLOCK2 options as appropriate.
Needs coap_hash() to generate ETag option.
net.c:
Determine if Block2 is in use, and add to coap_add_observer().
resource.[ch]:
Include Block2 request in coap_add_observer().
subscribe.h:
Include Block2 definition in coap_subscriber_t for using during
observe responses.
pdu.h:
Update comment.
coap-client.c:
No longer causes duplicate calls to coap_show_pdu()
(one in library, one in coap-client for the same PDU).
If a block'ed response received and observing, now observing continues.
(Fixes#166).
Send Observe Cancel with Block2 option if -b defined
coap-server.c:
Replaced all option setting, data addition etc. with new
coap_add_data_blocked_response() function in the GET handlers.
(Fixes#246 Issue 2).
Support PUT with BLOCK1.
(Fixes#246 Issue 1).
Add in -N option to send observe responses as non-confirmable.
Handle small wait_ms values correctly (after being decremented) for testing
whether observe should be triggered or not.
Refresh time every second by making COAP_RESOURCE_CHECK_TIME 1
Manuals:
Add in new function coap_add_data_blocked_response()
Update coap_observe with coap_delete_observer(s) functions
Correct example typo and use new function in hnd_get_time().
Add in -N option to coap-server(5)
Be more specific about COAP_RESOURCE_FLAGS_NOTIFY_NON and
COAP_RESOURCE_FLAGS_NOTIFY_CON usage for observe.
Files:
Makefile.am
Makefile.libcoap
examples/client.c
examples/coap-server.c
examples/lwip/Makefile
include/coap/block.h
include/coap/coap_hashkey.h
include/coap/pdu.h
include/coap/resource.h
include/coap/subscribe.h
libcoap-2.map
libcoap-2.sym
man/Makefile.am
man/coap-server.txt.in
man/coap_handler.txt.in
man/coap_observe.txt.in
man/coap_pdu_setup.txt.in
man/coap_resource.txt.in
src/block.c
src/coap_hashkey.c
src/net.c
src/resource.c