aboutsummaryrefslogtreecommitdiffstats
path: root/rngd.h
blob: e2e3a626bf73b1759441cfdddea0348857487f97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * rngd.h -- rngd globals
 *
 * Copyright (C) 2001 Philipp Rumpf
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef RNGD__H
#define RNGD__H

#define _GNU_SOURCE

#include "rng-tools-config.h"

#include <unistd.h>
#include <stdint.h>
#include <stdio.h>
#include <syslog.h>

#include "fips.h"

/* Command line arguments and processing */
struct arguments {
	char *random_name;

	int random_step;
	int fill_watermark;
	double poll_timeout;

	int daemon;
	int enable_tpm;
};
extern struct arguments *arguments;

/* structures to store rng information */
struct rng {
	char *rng_name;
	int rng_fd;

	int (*xread) (void *buf, size_t size, struct rng *ent_src);
	fips_ctx_t *fipsctx;

	struct rng *next;
};

/* Background/daemon mode */
extern int am_daemon;			/* Nonzero if we went daemon */


/*
 * Routines and macros
 */
#define message(priority,fmt,args...) do { \
	if (am_daemon) { \
		syslog((priority), fmt, ##args); \
	} else { \
		fprintf(stderr, fmt, ##args); \
		fprintf(stderr, "\n"); \
	} \
} while (0)

extern void list_add(struct rng *ent_src);
#endif /* RNGD__H */