24 #if defined(WITH_CONTIKI) 33 contiki_prng_impl(
unsigned char *buf,
size_t len) {
34 uint16_t v = random_rand();
35 while (len >
sizeof(v)) {
36 memcpy(buf, &v,
sizeof(v));
46 #define prng(Buf,Length) contiki_prng_impl((Buf), (Length)) 47 #define prng_init(Value) random_init((uint16_t)(Value)) 48 #elif defined(WITH_LWIP) && defined(LWIP_RAND) 50 lwip_prng_impl(
unsigned char *buf,
size_t len) {
51 u32_t v = LWIP_RAND();
52 while (len >
sizeof(v)) {
53 memcpy(buf, &v,
sizeof(v));
63 #define prng(Buf,Length) lwip_prng_impl((Buf), (Length)) 64 #define prng_init(Value) 66 #define prng_init(Value) 67 errno_t __cdecl rand_s( _Out_
unsigned int* _RandomValue );
78 if ( rand_s( &r ) != 0 )
80 for ( i = 0; i < len && i < 4; i++ ) {
100 *buf++ = rand() & 0xFF;
112 #define prng(Buf,Length) coap_prng_impl((Buf), (Length)) 122 #define prng_init(Value) srand((unsigned long)(Value)) #define COAP_STATIC_INLINE
COAP_STATIC_INLINE int coap_prng_impl(unsigned char *buf, size_t len)
Fills buf with len random bytes.