Change the kernel dev_t, representing a pointer to a specinfo structure,
[dragonfly.git] / sys / sys / random.h
CommitLineData
984263bc
MD
1/*
2 * random.h -- A strong random number generator
3 *
4 * $FreeBSD: src/sys/sys/random.h,v 1.19.2.2 2002/09/17 17:11:54 sam Exp $
b13267a5 5 * $DragonFly: src/sys/sys/random.h,v 1.10 2006/09/10 01:26:40 dillon Exp $
984263bc
MD
6 *
7 * Version 0.95, last modified 18-Oct-95
8 *
9 * Copyright Theodore Ts'o, 1994, 1995. All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, and the entire permission notice in its entirety,
16 * including the disclaimer of warranties.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. The name of the author may not be used to endorse or promote
21 * products derived from this software without specific prior
22 * written permission.
23 *
24 * ALTERNATIVELY, this product may be distributed under the terms of
25 * the GNU Public License, in which case the provisions of the GPL are
26 * required INSTEAD OF the above restrictions. (This clause is
27 * necessary due to a potential bad interaction between the GPL and
28 * the restrictions contained in a BSD-style copyright.)
29 *
30 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
31 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
32 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
34 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
36 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
38 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
40 * OF THE POSSIBILITY OF SUCH DAMAGE.
41 *
42 */
43
44/*
45 * Many kernel routines will have a use for good random numbers,
46 * for example, for truely random TCP sequence numbers, which prevent
47 * certain forms of TCP spoofing attacks.
48 *
49 */
50
51#ifndef _SYS_RANDOM_H_
52#define _SYS_RANDOM_H_
53
1bd40720
MD
54#ifndef _SYS_TYPES_H_
55#include <sys/types.h>
56#endif
ef0fdad1
MD
57#ifndef _SYS_INTERRUPT_H_
58#include <sys/interrupt.h>
59#endif
1bd40720 60#ifndef _SYS_IOCCOM_H_
984263bc 61#include <sys/ioccom.h>
1bd40720 62#endif
984263bc
MD
63
64#define MEM_SETIRQ _IOW('r', 1, u_int16_t) /* set interrupt */
65#define MEM_CLEARIRQ _IOW('r', 2, u_int16_t) /* clear interrupt */
5f456c40
MD
66#define MEM_RETURNIRQ _IOR('r', 3, u_int16_t) /* obsolete */
67#define MEM_FINDIRQ _IOWR('r', 4, u_int16_t) /* next interrupt */
984263bc
MD
68
69#ifdef _KERNEL
70
71/* Type of the cookie passed to add_interrupt_randomness. */
72
73struct random_softc {
984263bc 74 int sc_intr;
7e071e7a 75 int sc_enabled;
984263bc
MD
76};
77
78/* Exported functions */
79
80void rand_initialize(void);
81void add_keyboard_randomness(u_char scancode);
7e071e7a 82void add_interrupt_randomness(int intr);
984263bc
MD
83#ifdef notused
84void add_blkdev_randomness(int major);
85#endif
86void add_true_randomness(int);
bcce56a4 87int add_buffer_randomness(const char *, int);
984263bc
MD
88
89#ifdef notused
90void get_random_bytes(void *buf, u_int nbytes);
91#endif
92u_int read_random(void *buf, u_int size);
93u_int read_random_unlimited(void *buf, u_int size);
94#ifdef notused
95u_int write_random(const char *buf, u_int nbytes);
96#endif
41c20dac 97struct thread;
b13267a5 98int random_poll(cdev_t dev, int events);
984263bc
MD
99
100#endif /* _KERNEL */
101
102#endif /* !_SYS_RANDOM_H_ */