26 #if defined(WITH_CONTIKI)
35 contiki_prng_impl(
unsigned char *buf,
size_t len) {
36 uint16_t v = random_rand();
37 while (len >
sizeof(v)) {
38 memcpy(buf, &v,
sizeof(v));
48 #define coap_prng(Buf,Length) contiki_prng_impl((Buf), (Length))
49 #define coap_prng_init(Value) random_init((uint16_t)(Value))
51 #elif defined(WITH_LWIP) && defined(LWIP_RAND)
54 lwip_prng_impl(
unsigned char *buf,
size_t len) {
55 u32_t v = LWIP_RAND();
56 while (len >
sizeof(v)) {
57 memcpy(buf, &v,
sizeof(v));
67 #define coap_prng(Buf,Length) lwip_prng_impl((Buf), (Length))
68 #define coap_prng_init(Value) (void)Value
int(* coap_rand_func_t)(void *out, size_t len)
Data type for random number generator function.
void coap_set_prng(coap_rand_func_t rng)
Replaces the current random number generation function with the default function rng.
int coap_prng(void *buf, size_t len)
Fills buf with len random bytes using the default pseudo random number generator.
void coap_prng_init(unsigned int seed)
Seeds the default random number generation function with the given seed.
#define COAP_STATIC_INLINE