Commit 89292313 authored by Olaf Bergmann's avatar Olaf Bergmann

dcaf.[hc]: Add function dcaf_init() for startup initialization

dcaf_init() must be called once at startup to initialize the
DCAF engine.
parent 9edb0bbd
......@@ -113,6 +113,15 @@ typedef struct dcaf_config_t {
const char *am_uri;
} dcaf_config_t;
/**
* Initializes the DCAF engine. This function must be called once at
* startup (for RIOT, this is done during auto_init if available).
*
* When MODULE_PRNG is available in RIOT, this function also sets the
* dcaf_prng to random_bytes.
*/
void dcaf_init(void);
/**
* Sets a callback function that is invoked for each PDU to check
* against a ticket's scope. If set to NULL, the library's default
......
......@@ -15,6 +15,9 @@
#ifdef RIOT_VERSION
#include "libcoap_init.h"
#ifdef MODULE_PRNG
#include "random.h"
#endif /* MODULE_PRNG */
#endif /* RIOT_VERSION */
#include "dcaf/dcaf.h"
......@@ -26,6 +29,14 @@
#include "dcaf/aif.h"
#include "dcaf/cwt.h"
void
dcaf_init(void) {
#if defined(RIOT_VERSION) && defined(MODULE_PRNG)
dcaf_set_prng(random_bytes);
#endif /* RIOT_VERSION && MODULE_PRNG */
dcaf_cbor_init();
}
static inline uint8_t
coap_get_token_len(coap_pdu_t *p) {
return p->token_length;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment