2 * Copied from LiMon - BOOTP.
4 * Copyright 1994, 1995, 2000 Neil Russell.
6 * Copyright 2000 Paolo Scaffardi
10 #define __NET_RAND_H__
13 #include <dm/uclass.h>
17 * Return a seed for the PRNG derived from the eth0 MAC address.
19 static inline unsigned int seed_mac(void)
21 unsigned char enetaddr[ARP_HLEN];
25 memcpy(enetaddr, eth_get_ethaddr(), ARP_HLEN);
28 seed ^= enetaddr[4] << 8;
29 seed ^= enetaddr[3] << 16;
30 seed ^= enetaddr[2] << 24;
32 seed ^= enetaddr[0] << 8;
38 * Seed the random number generator using the eth0 MAC address.
40 static inline void srand_mac(void)
46 if (IS_ENABLED(CONFIG_DM_RNG)) {
47 ret = uclass_get_device(UCLASS_RNG, 0, &devp);
49 ret = dm_rng_read(devp, &randv, sizeof(randv));
60 #endif /* __NET_RAND_H__ */