zephyr/subsys/net/lib/openthread/platform/random.c
Martin Turon 6410a16adb openthread: Update openthread version to latest upstream/master.
Update zephyr integration of openthread to latest api as of 2018-12-17:

2a75d30684

Both echo_server and echo_client compile and are operational.

Signed-off-by: Martin Turon <mturon@google.com>
2018-12-20 12:24:51 +01:00

38 lines
657 B
C

/*
* Copyright (c) 2018 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <kernel.h>
#include <string.h>
#include <openthread/platform/random.h>
#include "platform-zephyr.h"
uint32_t otPlatRandomGet(void)
{
return sys_rand32_get();
}
otError otPlatRandomGetTrue(u8_t *aOutput, u16_t aOutputLength)
{
int i;
u32_t random;
if (!aOutput) {
return OT_ERROR_INVALID_ARGS;
}
for (i = 0; i < (aOutputLength & 0xFFFC); i += 4) {
random = sys_rand32_get();
memcpy(&aOutput[i], &random, sizeof(random));
}
random = sys_rand32_get();
memcpy(&aOutput[i], &random, aOutputLength & 0x0003);
return OT_ERROR_NONE;
}