1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef QEMU_RNG_H
14#define QEMU_RNG_H
15
16#include "qom/object.h"
17#include "qemu-common.h"
18#include "qapi/error.h"
19
20#define TYPE_RNG_BACKEND "rng-backend"
21#define RNG_BACKEND(obj) \
22 OBJECT_CHECK(RngBackend, (obj), TYPE_RNG_BACKEND)
23#define RNG_BACKEND_GET_CLASS(obj) \
24 OBJECT_GET_CLASS(RngBackendClass, (obj), TYPE_RNG_BACKEND)
25#define RNG_BACKEND_CLASS(klass) \
26 OBJECT_CLASS_CHECK(RngBackendClass, (klass), TYPE_RNG_BACKEND)
27
28typedef struct RngBackendClass RngBackendClass;
29typedef struct RngBackend RngBackend;
30
31typedef void (EntropyReceiveFunc)(void *opaque,
32 const void *data,
33 size_t size);
34
35struct RngBackendClass
36{
37 ObjectClass parent_class;
38
39 void (*request_entropy)(RngBackend *s, size_t size,
40 EntropyReceiveFunc *receive_entropy, void *opaque);
41 void (*cancel_requests)(RngBackend *s);
42
43 void (*opened)(RngBackend *s, Error **errp);
44};
45
46struct RngBackend
47{
48 Object parent;
49
50
51 bool opened;
52};
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69void rng_backend_request_entropy(RngBackend *s, size_t size,
70 EntropyReceiveFunc *receive_entropy,
71 void *opaque);
72
73
74
75
76
77
78
79
80
81void rng_backend_cancel_requests(RngBackend *s);
82#endif
83