Files
libcoap/src/coap_event.c
T
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

33 lines
745 B
C

/*
* coap_event.c -- libcoap Event API
*
* Copyright (C) 2016 Olaf Bergmann <bergmann@tzi.org>
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
*/
#include "coap_event.h"
#include "net.h"
/*
* This replaces coap_set_event_handler() so that handler registration is
* consistent in the naming.
*/
void
coap_register_event_handler(struct coap_context_t *context,
coap_event_handler_t hnd) {
context->handle_event = hnd;
}
void
coap_set_event_handler(struct coap_context_t *context,
coap_event_handler_t hnd) {
context->handle_event = hnd;
}
void
coap_clear_event_handler(struct coap_context_t *context) {
context->handle_event = NULL;
}