Compare commits
2 Commits
3ff8685fc6
...
219443ba7a
Author | SHA1 | Date | |
---|---|---|---|
|
219443ba7a | ||
|
98e0ca3f6f |
@ -68,8 +68,7 @@ even sees the data. ndhc also only listens to DHCP traffic when it's
|
||||
necessary.
|
||||
|
||||
*Flexible*. ndhc can request particular IPs, send user-specified client
|
||||
IDs, write a file that contains the current lease IP, write PID files,
|
||||
etc.
|
||||
IDs, write a file that contains the current lease IP, etc.
|
||||
|
||||
*Self-contained*. ndhc does not exec other processes, or rely on the shell.
|
||||
Further, ndhc relies on no external libraries aside from the system libc.
|
||||
|
@ -1,11 +1,9 @@
|
||||
// Copyright 2013-2022 Nicholas J. Kain <njkain at gmail dot com>
|
||||
// Copyright 2013-2023 Nicholas J. Kain <njkain at gmail dot com>
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include <stdint.h>
|
||||
#include "nk/hwrng.h"
|
||||
#include "nk/random.h"
|
||||
|
||||
// SFC64 modified to use a Weyl counter.
|
||||
|
||||
void nk_random_init(struct nk_random_state *s)
|
||||
{
|
||||
nk_hwrng_bytes(s->seed, sizeof(uint64_t) * 3);
|
||||
@ -19,8 +17,7 @@ static inline uint64_t rotl64(const uint64_t x, int k) {
|
||||
|
||||
uint64_t nk_random_u64(struct nk_random_state *s)
|
||||
{
|
||||
const uint64_t t = (s->seed[0] + s->seed[1]) ^ s->seed[3];
|
||||
s->seed[3] += 0x6a09e667a7541669ull;
|
||||
const uint64_t t = s->seed[0] + s->seed[1] + s->seed[3]++;
|
||||
s->seed[0] = s->seed[1] ^ (s->seed[1] >> 11);
|
||||
s->seed[1] = s->seed[2] + (s->seed[2] << 3);
|
||||
s->seed[2] = rotl64(s->seed[2], 24) + t;
|
||||
|
Loading…
Reference in New Issue
Block a user