Commit Graph
15 Commits
Author SHA1 Message Date
Jon Shallow fda991f541 Fix mcast registrations when using TCP
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
2019-04-12 13:54:50 +01:00
Jon Shallow 8dcdbfb477 endpoint->hello information memory leak when coap_free_endpoint() called
Information set up in the pseudo session held in endpoint->hello is not freed
off when coap_free_endpoint() is called.

A solution is to split coap_session_free() into two parts with
coap_session_free() calling a new function coap_session_mfree().

Then coap_mfree_endpoint() can call coap_session_mfree() to free off the
endpoint specific hello information.

Makefile.am

Add coap_mfree_endpoint and coap_session_mfree to the CTAGS_IGNORE list.

libcoap-2.{map|sym}

Remove coap_mfree_endpoint as it is not a public function

include/coap2/coap_session.h

Add in new coap_session_mfree() function definition

src/coap_io.c

Call coap_session_mfree() from within coap_mfree_endpoint()

src/coap_session.c

Move some of the functionality out of coap_session_free() into a new
function coap_session_mfree() and  call coap_session_mfree().
2018-12-18 15:56:48 +00:00
Jon Shallow d8b399cfc9 New coap_show_tls_version() and coap_string_tls_version() functions
These new functions can be used to either update a buffer with, or coap_log()
out the current runtime TLS library along with the version of the library
that libcoap was built against.

include/coap2/debug.h
src/debug.c
libcoap-2.map
libcoap-2.sym

Support for the new functions coap_show_tls_version() and coap_string_tls_version().
2018-11-27 11:42:21 +00:00
Jon Shallow 469357b824 BLOCK option support in coap-server
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
2018-09-24 20:49:57 +01:00
obgm 395815e26d Merge pull request #236 from mrdeep1/dtls_event
openssl.c: Global dtls_event variable causing confusion when events happen
2018-09-24 16:28:19 +02:00
jcmichelou f0a85e2278 build: Rebuild symbols list 2018-09-24 15:53:07 +02:00
jcmichelou 4e73052872 session: Improve event reporting, add auto-ping and csm timeout.
Add new event types to report the TCP connection status and CSM exchange
status to the application. Add optional auto send of ping messages for
reliable client sessions. Add default timeout of 30s for receiving a CSM
message from the remote host after connect.
2018-09-24 15:42:40 +02:00
Jon Shallow 2466853075 openssl.c: Global dtls_event variable causing confusion when events happen
dtls_event is a static variable, declared outside of all the functions which
tracks (D)TLS errors for generating events etc.

If there are multiple SSL sessions being set up to the same server (as per
Happy Eyeballs for the DOTS protocol) it is possible to asynchronously get
dtls_event updated and the wrong SSL session then acts on it.

Make dtls_event a part of coap_session_t to maintain seperation.

Preset dtls_event to -1 in coap_make_session().

Update coap_event_handler() to have the 3rd parameter as
coap_session_t *session instead of void *arg as the parameter is always session.
Updated coap_event_handler_t to have session as the 3rd parameter.

Add in new registration handler coap_register_event_handler() to be consistent
with all the other coap_register_XXX_handler()s.
Consequently, coap_set_event_handler() and coap_clear_enent_handler() are
deprecated.

Update coap_handler(3) to include new coap_register_event_handler().
(PR #183 event definitions are included presumptive on #183 getting merged)
2018-08-28 13:32:05 +01:00
Jon Shallow e2c3571598 libcoap-2.{map|sym}: Add in coap_context_set_pki_root_cas()
Also, remove coap_endpoint_new_dtls_session() as it is an internal function
2018-07-24 14:49:13 +01:00
Jon Shallow fd421dd119 debug.c: Make coap_show_pdu() use coap_log() or fprintf()
coap_show_pdu()'s API is now coap_show_pdu(coap_log_t, coap_pdu_t*)
New function void coap_set_show_pdu_output(int use_fprintf)
Default is use fprintf() instead of coap_log()

The output buffer size can be configuring -DCOAP_DEBUG_BUF_SIZE

Output COAP_OPTION_SIZE2 option as well

For binary data, output ascii readable equivalent immediately under the
hex output for ease of debugging.

include/coap/debug.h
src/debug.c

Update coap_show_pdu() API
New function coap_set_show_pdu_output()
Update coap_show_pdu() code

include/coap/pdu.h

Define the coap debug output debug buffer size
COAP_DEBUG_BUF_SIZE

examples/client.c
examples/contiki/coap-observer.c
src/net.c
tests/test_wellknown.c
tests/test_pdu.c

Update coap_show_pdu() calls

libcoap-2.map
libcoap-2.sym

New function coap_set_show_pdu_output()
2018-07-20 18:58:55 +01:00
Jon Shallow c7e9359f02 Make coap_encode_var_bytes() by replacing with coap_encode_var_safe()
Update code / examples / man pages with the updated function.

include/coap/libcoap.h:
Add in new define COAP_DEPRECATED to generate compiler warnings when used

include/coap/encode.h
New coap_encode_var_safe() function that includes the size of the output
buffer as a parameter.

Make coap_encode_var_bytes() a wrapper for coap_encode_var_safe() and
mark it as COAP_DEPRECATED for backwards compatability

src/encode.c:
New coap_encode_var_safe() function that includes the size of the output
buffer as a parameter.

examples/coap-server.c:
examples/contiki/server.c:
Make the ticks resource consistent in case
2018-06-05 09:41:58 +01:00
Jon Shallow 34dbf512b0 libcoap-2.{sym|map}: Add in coap_new_str_const() and coap_delete_str_const() 2018-05-25 16:38:08 +01:00
Olaf Bergmann 99fbe78a47 resource.h: get rid of -Winline warning
As gcc 7 complains that coap_register_handler() is too large to
be inlined automatically, the function definition now has been
moved to resource.c.

This change also updates the symbol mappings accordingly.
2018-05-18 13:40:05 +02:00
Jon Shallow 7c94b4497d libcoap-1.{map|sym}: Include new optlist functions 2018-05-17 18:45:39 +01:00
Jon Shallow fcf30a6afc libcoap-2.{map,sym}: Add in files 2018-04-13 08:43:37 +01:00