PERFORCE change 47054 for review
Sam Leffler
sam at FreeBSD.org
Mon Feb 16 14:36:14 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=47054
Change 47054 by sam at sam_ebb on 2004/02/16 14:35:16
add get_random_bytes to ease portability
Affected files ...
.. //depot/projects/netperf+sockets/sys/net80211/ieee80211_freebsd.c#3 edit
Differences ...
==== //depot/projects/netperf+sockets/sys/net80211/ieee80211_freebsd.c#3 (text+ko) ====
@@ -60,6 +60,28 @@
return m;
}
+void
+get_random_bytes(void *data, u_int len)
+{
+ int i = len / sizeof(u_int32_t);
+
+ KASSERT((len % sizeof(u_int32_t)) == 0,
+ ("len %u not a multiple of word size", len));
+ if (!ALIGNED_POINTER(data, u_int32_t)) {
+ u_int8_t *bp;
+
+ for (bp = data; --i >= 0; bp += sizeof(u_int32_t)) {
+ u_int32_t v = arc4random();
+ memcpy(bp, &v, sizeof(v));
+ }
+ } else {
+ u_int32_t *dp = data;
+
+ while (--i >= 0)
+ *dp++ = arc4random();
+ }
+}
+
/*
* Module glue.
*
More information about the p4-projects
mailing list