summaryrefslogtreecommitdiffstats
path: root/src/havegecmd.h
blob: 0bc74fdebae1f04e12a8373beab103b262cb4869 (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
/**
 ** Provide HAVEGE socket communication API
 **
 ** Copyright 2018 Werner Fink <werner@suse.de>
 **
 ** 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 3 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, see <http://www.gnu.org/licenses/>.
 **
 */

#ifndef HAVEGECMD_H
#define HAVEGECMD_H

#ifdef __cplusplus
extern "C" {
#endif

#include "havege.h"
#include "haveged.h"

#include <sys/types.h>
#include <sys/socket.h>

#define HAVEGED_SOCKET_PATH      "\0/sys/entropy/haveged"
#define MAGIC_CHROOT             'R'

/**
 * Open and listen on a UNIX socket to get command from there
 */
int cmd_listen(struct pparams *);

/**
 * Open and connect on a UNIX socket to send command over this
 */
int cmd_connect(struct pparams *);

/**
 * Handle arguments in command mode
 */
int getcmd(char *);

/**
 * Handle incomming messages from socket
 */
int socket_handler(int, const volatile char *, char *const [], struct pparams *);

/**
 * Receive incomming messages from socket
 */
ssize_t safein(int, void *, size_t);

/**
 * Send outgoing messages to socket
 */
void safeout(int, const void *, size_t);

/**
 * Socket file descriptor used for communication
 */

extern int socket_fd;

#ifdef __cplusplus
}
#endif

#endif