iot/zoap: Add helper for generating tokens
Most applications will want to use randomly generated tokens, add a helper for that. Change-Id: If2a6b1d96596024afd2d2ce8e3632900adfe9c0f Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
This commit is contained in:
parent
dc45748d50
commit
ea28e4fccb
|
@ -1275,3 +1275,13 @@ size_t zoap_next_block(struct zoap_block_context *ctx)
|
|||
|
||||
return ctx->current;
|
||||
}
|
||||
|
||||
uint8_t *zoap_next_token(void)
|
||||
{
|
||||
static uint32_t rand[2];
|
||||
|
||||
rand[0] = sys_rand32_get();
|
||||
rand[1] = sys_rand32_get();
|
||||
|
||||
return (uint8_t *) rand;
|
||||
}
|
||||
|
|
|
@ -543,4 +543,10 @@ static inline uint16_t zoap_next_id(void)
|
|||
return ++message_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a randomly generated array of 8 bytes, that can be used as a
|
||||
* message's token.
|
||||
*/
|
||||
uint8_t *zoap_next_token(void);
|
||||
|
||||
#endif /* __ZOAP_H__ */
|
||||
|
|
Loading…
Reference in a new issue