]> the.earth.li Git - onak.git/blob - keydb/keyd.h
1ea601c82777af9de57ecc039578f0e8b4e1b5b3
[onak.git] / keydb / keyd.h
1 /**
2  * @file keyd.h
3  * @brief Public API for keyd.
4  *
5  * Copyright 2004,2011 Jonathan McDowell <noodles@earth.li>
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation; version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program.  If not, see <https://www.gnu.org/licenses/>.
18  */
19
20 #ifndef __KEYD_H__
21 #define __KEYD_H__
22
23 #include <stdint.h>
24
25 /**
26  * @brief The name of the keyd Unix domain socket
27  */
28 #define KEYD_SOCKET "keyd.sock"
29
30 /**
31  * @brief keyd commands
32  */
33 enum keyd_ops {
34         KEYD_CMD_UNKNOWN = 0,
35         KEYD_CMD_VERSION = 1,
36         KEYD_CMD_GET_ID,
37         KEYD_CMD_STORE,
38         KEYD_CMD_DELETE,
39         KEYD_CMD_GET_TEXT,
40         KEYD_CMD_GETFULLKEYID,
41         KEYD_CMD_KEYITER,
42         KEYD_CMD_CLOSE,
43         KEYD_CMD_QUIT,
44         KEYD_CMD_STATS,
45         KEYD_CMD_GET_SKSHASH,
46         KEYD_CMD_GET_FP,
47         KEYD_CMD_UPDATE,
48         KEYD_CMD_LAST                   /* Placeholder */
49 };
50
51 /**
52  * @brief Reply codes for keyd commands
53  */
54 enum keyd_reply {
55         KEYD_REPLY_OK = 0,
56         KEYD_REPLY_UNKNOWN_CMD = 1
57 };
58
59 /**
60  * @brief Version of the keyd protocol currently supported
61  */
62 static const uint32_t keyd_version = 5;
63
64 /**
65  * @brief Response structure for the @a KEYD_CMD_STATS response
66  */
67 struct keyd_stats {
68         /** Unix time of when the keyd daemon was started */
69         time_t started;
70         /** Number of connects we've seen to keyd */
71         uint32_t connects;
72         /** Count of the number of times each command has been used */
73         uint32_t command_stats[KEYD_CMD_LAST];
74 };
75
76 #endif /* __KEYD_H__ */