Sat Dec 17 12:59:22 2011 UTC ()
Add comments for some ioctls and structs; fix a typo in another comment.


(apb)
diff -r1.26 -r1.27 src/sys/sys/rnd.h

cvs diff -r1.26 -r1.27 src/sys/sys/rnd.h (expand / switch to unified diff)

--- src/sys/sys/rnd.h 2011/11/29 03:50:32 1.26
+++ src/sys/sys/rnd.h 2011/12/17 12:59:21 1.27
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rnd.h,v 1.26 2011/11/29 03:50:32 tls Exp $ */ 1/* $NetBSD: rnd.h,v 1.27 2011/12/17 12:59:21 apb Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc. 4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Michael Graff <explorer@flame.org>. This code uses ideas and 8 * by Michael Graff <explorer@flame.org>. This code uses ideas and
9 * algorithms from the Linux driver written by Ted Ts'o. 9 * algorithms from the Linux driver written by Ted Ts'o.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -53,26 +53,27 @@ @@ -53,26 +53,27 @@
53 53
54/* 54/*
55 * Exposed "size" of entropy pool, for convenience in load/save 55 * Exposed "size" of entropy pool, for convenience in load/save
56 * from userspace. Do not assume this is the same as the actual in-kernel 56 * from userspace. Do not assume this is the same as the actual in-kernel
57 * pool size! 57 * pool size!
58 */ 58 */
59#define RND_SAVEWORDS 128 59#define RND_SAVEWORDS 128
60typedef struct { 60typedef struct {
61 uint32_t entropy; 61 uint32_t entropy;
62 uint8_t data[RND_SAVEWORDS * sizeof(uint32_t)]; 62 uint8_t data[RND_SAVEWORDS * sizeof(uint32_t)];
63 uint8_t digest[SHA1_DIGEST_LENGTH]; 63 uint8_t digest[SHA1_DIGEST_LENGTH];
64} rndsave_t; 64} rndsave_t;
65 65
 66/* Statistics exposed by RNDGETPOOLSTAT */
66typedef struct 67typedef struct
67{ 68{
68 uint32_t poolsize; 69 uint32_t poolsize;
69 uint32_t threshold; 70 uint32_t threshold;
70 uint32_t maxentropy; 71 uint32_t maxentropy;
71 72
72 uint32_t added; 73 uint32_t added;
73 uint32_t curentropy; 74 uint32_t curentropy;
74 uint32_t removed; 75 uint32_t removed;
75 uint32_t discarded; 76 uint32_t discarded;
76 uint32_t generated; 77 uint32_t generated;
77} rndpoolstat_t; 78} rndpoolstat_t;
78 79
@@ -108,27 +109,27 @@ typedef struct { @@ -108,27 +109,27 @@ typedef struct {
108#define RND_POOLWORDS 128 109#define RND_POOLWORDS 128
109#endif 110#endif
110#define RND_POOLBITS (RND_POOLWORDS * 32) 111#define RND_POOLBITS (RND_POOLWORDS * 32)
111 112
112typedef struct krndsource { 113typedef struct krndsource {
113 LIST_ENTRY(krndsource) list; /* the linked list */ 114 LIST_ENTRY(krndsource) list; /* the linked list */
114 char name[16]; /* device name */ 115 char name[16]; /* device name */
115 uint32_t last_time; /* last time recorded */ 116 uint32_t last_time; /* last time recorded */
116 uint32_t last_delta; /* last delta value */ 117 uint32_t last_delta; /* last delta value */
117 uint32_t last_delta2; /* last delta2 value */ 118 uint32_t last_delta2; /* last delta2 value */
118 uint32_t total; /* entropy from this source */ 119 uint32_t total; /* entropy from this source */
119 uint32_t type; /* type */ 120 uint32_t type; /* type */
120 uint32_t flags; /* flags */ 121 uint32_t flags; /* flags */
121 void *state; /* state informaiton */ 122 void *state; /* state information */
122 size_t test_cnt; /* how much test data accumulated? */ 123 size_t test_cnt; /* how much test data accumulated? */
123 rngtest_t *test; /* test data for RNG type sources */ 124 rngtest_t *test; /* test data for RNG type sources */
124} krndsource_t; 125} krndsource_t;
125 126
126typedef struct rndsink { 127typedef struct rndsink {
127 TAILQ_ENTRY(rndsink) tailq; /* the queue */ 128 TAILQ_ENTRY(rndsink) tailq; /* the queue */
128 void (*cb)(void *); /* callback function when ready */ 129 void (*cb)(void *); /* callback function when ready */
129 void *arg; /* callback function argument */ 130 void *arg; /* callback function argument */
130 char name[16]; /* sink name */ 131 char name[16]; /* sink name */
131 size_t len; /* how many bytes wanted/supplied */ 132 size_t len; /* how many bytes wanted/supplied */
132 uint8_t data[64]; /* random data returned here */ 133 uint8_t data[64]; /* random data returned here */
133} rndsink_t; 134} rndsink_t;
134 135
@@ -187,27 +188,31 @@ typedef struct { @@ -187,27 +188,31 @@ typedef struct {
187 188
188/* 189/*
189 * set/clear device flags. If type is set to 0xff, the name is used 190 * set/clear device flags. If type is set to 0xff, the name is used
190 * instead. Otherwise, the flags set/cleared apply to all devices of 191 * instead. Otherwise, the flags set/cleared apply to all devices of
191 * the specified type, and the name is ignored. 192 * the specified type, and the name is ignored.
192 */ 193 */
193typedef struct { 194typedef struct {
194 char name[16]; /* the name we are adjusting */ 195 char name[16]; /* the name we are adjusting */
195 uint32_t type; /* the type of device we want */ 196 uint32_t type; /* the type of device we want */
196 uint32_t flags; /* flags to set or clear */ 197 uint32_t flags; /* flags to set or clear */
197 uint32_t mask; /* mask for the flags we are setting */ 198 uint32_t mask; /* mask for the flags we are setting */
198} rndctl_t; 199} rndctl_t;
199 200
 201/*
 202 * Add entropy to the pool. len is the data length, in bytes.
 203 * entropy is the number of bits of estimated entropy in the data.
 204 */
200typedef struct { 205typedef struct {
201 uint32_t len; 206 uint32_t len;
202 uint32_t entropy; 207 uint32_t entropy;
203 u_char data[RND_SAVEWORDS * sizeof(uint32_t)]; 208 u_char data[RND_SAVEWORDS * sizeof(uint32_t)];
204} rnddata_t; 209} rnddata_t;
205 210
206#define RNDGETENTCNT _IOR('R', 101, uint32_t) /* get entropy count */ 211#define RNDGETENTCNT _IOR('R', 101, uint32_t) /* get entropy count */
207#define RNDGETSRCNUM _IOWR('R', 102, rndstat_t) /* get rnd source info */ 212#define RNDGETSRCNUM _IOWR('R', 102, rndstat_t) /* get rnd source info */
208#define RNDGETSRCNAME _IOWR('R', 103, rndstat_name_t) /* get src by name */ 213#define RNDGETSRCNAME _IOWR('R', 103, rndstat_name_t) /* get src by name */
209#define RNDCTL _IOW('R', 104, rndctl_t) /* set/clear source flags */ 214#define RNDCTL _IOW('R', 104, rndctl_t) /* set/clear source flags */
210#define RNDADDDATA _IOW('R', 105, rnddata_t) /* add data to the pool */ 215#define RNDADDDATA _IOW('R', 105, rnddata_t) /* add data to the pool */
211#define RNDGETPOOLSTAT _IOR('R', 106, rndpoolstat_t) 216#define RNDGETPOOLSTAT _IOR('R', 106, rndpoolstat_t) /* get statistics */
212 217
213#endif /* !_SYS_RND_H_ */ 218#endif /* !_SYS_RND_H_ */