ctdb-event: Add event daemon protocol
[metze/samba/wip.git] / ctdb / event / event_protocol_api.h
1 /*
2    CTDB event daemon protocol
3
4    Copyright (C) Amitay Isaacs  2018
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef __CTDB_EVENT_PROTOCOL_API_H__
21 #define __CTDB_EVENT_PROTOCOL_API_H__
22
23 #include <talloc.h>
24
25 #include "event/event_protocol.h"
26
27 /* From event/event_protocol.c */
28
29 int ctdb_event_header_extract(uint8_t *buf,
30                               size_t buflen,
31                               struct ctdb_event_header *h);
32
33 size_t ctdb_event_request_len(struct ctdb_event_header *h,
34                               struct ctdb_event_request *in);
35 int ctdb_event_request_push(struct ctdb_event_header *h,
36                             struct ctdb_event_request *in,
37                             uint8_t *buf,
38                             size_t *buflen);
39 int ctdb_event_request_pull(uint8_t *buf,
40                             size_t buflen,
41                             struct ctdb_event_header *h,
42                             TALLOC_CTX *mem_ctx,
43                             struct ctdb_event_request **out);
44
45 size_t ctdb_event_reply_len(struct ctdb_event_header *h,
46                             struct ctdb_event_reply *in);
47 int ctdb_event_reply_push(struct ctdb_event_header *h,
48                           struct ctdb_event_reply *in,
49                           uint8_t *buf,
50                           size_t *buflen);
51 int ctdb_event_reply_pull(uint8_t *buf,
52                           size_t buflen,
53                           struct ctdb_event_header *h,
54                           TALLOC_CTX *mem_ctx,
55                           struct ctdb_event_reply **out);
56
57 /* From event/event_protocol_util.c */
58
59 const char *ctdb_event_command_to_string(enum ctdb_event_command cmd);
60
61 #endif /* __CTDB_EVENT_PROTOCOL_API_H__ */