9e47f2691d90bb57b384539a88c2ab0e3bc8be98
[sfrench/samba-autobuild/.git] / ctdb / protocol / protocol_api.h
1 /*
2    CTDB protocol marshalling
3
4    Copyright (C) Amitay Isaacs  2015
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_PROTOCOL_API_H__
21 #define __CTDB_PROTOCOL_API_H__
22
23 #include <talloc.h>
24
25 #include "protocol/protocol.h"
26
27 /* From protocol/protocol_types.c */
28
29 size_t ctdb_ltdb_header_len(struct ctdb_ltdb_header *in);
30 void ctdb_ltdb_header_push(struct ctdb_ltdb_header *in, uint8_t *buf,
31                            size_t *npush);
32 int ctdb_ltdb_header_pull(uint8_t *buf, size_t buflen,
33                           struct ctdb_ltdb_header *out, size_t *npull);
34
35 int ctdb_ltdb_header_extract(TDB_DATA *data, struct ctdb_ltdb_header *header);
36
37 size_t ctdb_rec_data_len(struct ctdb_rec_data *in);
38 void ctdb_rec_data_push(struct ctdb_rec_data *in, uint8_t *buf, size_t *npush);
39 int ctdb_rec_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
40                        struct ctdb_rec_data **out, size_t *npull);
41
42 size_t ctdb_rec_buffer_len(struct ctdb_rec_buffer *in);
43 void ctdb_rec_buffer_push(struct ctdb_rec_buffer *in, uint8_t *buf,
44                           size_t *npush);
45 int ctdb_rec_buffer_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
46                          struct ctdb_rec_buffer **out, size_t *npull);
47
48 struct ctdb_rec_buffer *ctdb_rec_buffer_init(TALLOC_CTX *mem_ctx,
49                                              uint32_t db_id);
50 int ctdb_rec_buffer_add(TALLOC_CTX *mem_ctx, struct ctdb_rec_buffer *recbuf,
51                         uint32_t reqid, struct ctdb_ltdb_header *header,
52                         TDB_DATA key, TDB_DATA data);
53 int ctdb_rec_buffer_traverse(struct ctdb_rec_buffer *recbuf,
54                              ctdb_rec_parser_func_t func,
55                              void *private_data);
56
57 int ctdb_rec_buffer_write(struct ctdb_rec_buffer *recbuf, int fd);
58 int ctdb_rec_buffer_read(int fd, TALLOC_CTX *mem_ctx,
59                          struct ctdb_rec_buffer **out);
60
61 size_t ctdb_server_id_len(struct ctdb_server_id *in);
62 void ctdb_server_id_push(struct ctdb_server_id *in, uint8_t *buf,
63                          size_t *npush);
64 int ctdb_server_id_pull(uint8_t *buf, size_t buflen,
65                         struct ctdb_server_id *out, size_t *npull);
66
67 size_t ctdb_g_lock_len(struct ctdb_g_lock *in);
68 void ctdb_g_lock_push(struct ctdb_g_lock *in, uint8_t *buf, size_t *npush);
69 int ctdb_g_lock_pull(uint8_t *buf, size_t buflen, struct ctdb_g_lock *out,
70                      size_t *npull);
71
72 size_t ctdb_g_lock_list_len(struct ctdb_g_lock_list *in);
73 void ctdb_g_lock_list_push(struct ctdb_g_lock_list *in, uint8_t *buf,
74                            size_t *npush);
75 int ctdb_g_lock_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
76                           struct ctdb_g_lock_list **out, size_t *npull);
77
78 /* From protocol/protocol_header.c */
79
80 void ctdb_req_header_fill(struct ctdb_req_header *h, uint32_t generation,
81                           uint32_t operation, uint32_t destnode,
82                           uint32_t srcnode, uint32_t reqid);
83
84 size_t ctdb_req_header_len(struct ctdb_req_header *h);
85 void ctdb_req_header_push(struct ctdb_req_header *h, uint8_t *buf);
86 int ctdb_req_header_pull(uint8_t *buf, size_t buflen,
87                          struct ctdb_req_header *h);
88
89 int ctdb_req_header_verify(struct ctdb_req_header *h, uint32_t operation);
90
91 /* From protocol/protocol_call.c */
92
93 size_t ctdb_req_call_len(struct ctdb_req_header *h,
94                          struct ctdb_req_call *c);
95
96 int ctdb_req_call_push(struct ctdb_req_header *h,
97                        struct ctdb_req_call *c,
98                        uint8_t *buf, size_t *buflen);
99
100 int ctdb_req_call_pull(uint8_t *buf, size_t buflen,
101                        struct ctdb_req_header *h,
102                        TALLOC_CTX *mem_ctx,
103                        struct ctdb_req_call *c);
104
105 size_t ctdb_reply_call_len(struct ctdb_req_header *h,
106                            struct ctdb_reply_call *c);
107
108 int ctdb_reply_call_push(struct ctdb_req_header *h,
109                          struct ctdb_reply_call *c,
110                          uint8_t *buf, size_t *buflen);
111
112 int ctdb_reply_call_pull(uint8_t *buf, size_t buflen,
113                          struct ctdb_req_header *h,
114                          TALLOC_CTX *mem_ctx,
115                          struct ctdb_reply_call *c);
116
117 size_t ctdb_reply_error_len(struct ctdb_req_header *h,
118                             struct ctdb_reply_error *c);
119
120 int ctdb_reply_error_push(struct ctdb_req_header *h,
121                           struct ctdb_reply_error *c,
122                           uint8_t *buf, size_t *buflen);
123
124 int ctdb_reply_error_pull(uint8_t *buf, size_t buflen,
125                           struct ctdb_req_header *h,
126                           TALLOC_CTX *mem_ctx,
127                           struct ctdb_reply_error *c);
128
129 size_t ctdb_req_dmaster_len(struct ctdb_req_header *h,
130                             struct ctdb_req_dmaster *c);
131
132 int ctdb_req_dmaster_push(struct ctdb_req_header *h,
133                           struct ctdb_req_dmaster *c,
134                           uint8_t *buf, size_t *buflen);
135
136 int ctdb_req_dmaster_pull(uint8_t *buf, size_t buflen,
137                           struct ctdb_req_header *h,
138                           TALLOC_CTX *mem_ctx,
139                           struct ctdb_req_dmaster *c);
140
141 size_t ctdb_reply_dmaster_len(struct ctdb_req_header *h,
142                               struct ctdb_reply_dmaster *c);
143
144 int ctdb_reply_dmaster_push(struct ctdb_req_header *h,
145                             struct ctdb_reply_dmaster *c,
146                             uint8_t *buf, size_t *buflen);
147
148 int ctdb_reply_dmaster_pull(uint8_t *buf, size_t buflen,
149                             struct ctdb_req_header *h,
150                             TALLOC_CTX *mem_ctx,
151                             struct ctdb_reply_dmaster *c);
152
153 /* From protocol/protocol_control.c */
154
155 size_t ctdb_req_control_len(struct ctdb_req_header *h,
156                             struct ctdb_req_control *c);
157
158 int ctdb_req_control_push(struct ctdb_req_header *h,
159                           struct ctdb_req_control *c,
160                           uint8_t *buf, size_t *buflen);
161
162 int ctdb_req_control_pull(uint8_t *buf, size_t buflen,
163                           struct ctdb_req_header *h,
164                           TALLOC_CTX *mem_ctx,
165                           struct ctdb_req_control *c);
166
167 size_t ctdb_reply_control_len(struct ctdb_req_header *h,
168                               struct ctdb_reply_control *c);
169
170 int ctdb_reply_control_push(struct ctdb_req_header *h,
171                             struct ctdb_reply_control *c,
172                             uint8_t *buf, size_t *buflen);
173
174 int ctdb_reply_control_pull(uint8_t *buf, size_t buflen, uint32_t opcode,
175                             struct ctdb_req_header *h,
176                             TALLOC_CTX *mem_ctx,
177                             struct ctdb_reply_control *c);
178
179 /* From protocol/protocol_client.c */
180
181 void ctdb_req_control_process_exists(struct ctdb_req_control *request,
182                                      pid_t pid);
183 int ctdb_reply_control_process_exists(struct ctdb_reply_control *reply,
184                                       int *status);
185
186 void ctdb_req_control_statistics(struct ctdb_req_control *request);
187
188 int ctdb_reply_control_statistics(struct ctdb_reply_control *reply,
189                                   TALLOC_CTX *mem_ctx,
190                                   struct ctdb_statistics **stats);
191
192 void ctdb_req_control_ping(struct ctdb_req_control *request);
193 int ctdb_reply_control_ping(struct ctdb_reply_control *reply,
194                             int *num_clients);
195
196 void ctdb_req_control_getdbpath(struct ctdb_req_control *request,
197                                 uint32_t db_id);
198 int ctdb_reply_control_getdbpath(struct ctdb_reply_control *reply,
199                                  TALLOC_CTX *mem_ctx, const char **db_path);
200
201 void ctdb_req_control_getvnnmap(struct ctdb_req_control *request);
202 int ctdb_reply_control_getvnnmap(struct ctdb_reply_control *reply,
203                                  TALLOC_CTX *mem_ctx,
204                                  struct ctdb_vnn_map **vnnmap);
205
206 void ctdb_req_control_setvnnmap(struct ctdb_req_control *request,
207                                 struct ctdb_vnn_map *vnnmap);
208 int ctdb_reply_control_setvnnmap(struct ctdb_reply_control *reply);
209
210 void ctdb_req_control_get_debug(struct ctdb_req_control *request);
211 int ctdb_reply_control_get_debug(struct ctdb_reply_control *reply,
212                                  int *debug_level);
213
214 void ctdb_req_control_set_debug(struct ctdb_req_control *request,
215                                 int debug_level);
216 int ctdb_reply_control_set_debug(struct ctdb_reply_control *reply);
217
218 void ctdb_req_control_get_dbmap(struct ctdb_req_control *request);
219 int ctdb_reply_control_get_dbmap(struct ctdb_reply_control *reply,
220                                  TALLOC_CTX *mem_ctx,
221                                  struct ctdb_dbid_map **dbmap);
222
223 void ctdb_req_control_pull_db(struct ctdb_req_control *request,
224                               struct ctdb_pulldb *pulldb);
225 int ctdb_reply_control_pull_db(struct ctdb_reply_control *reply,
226                                TALLOC_CTX *mem_ctx,
227                                struct ctdb_rec_buffer **recbuf);
228
229 void ctdb_req_control_push_db(struct ctdb_req_control *request,
230                               struct ctdb_rec_buffer *recbuf);
231 int ctdb_reply_control_push_db(struct ctdb_reply_control *reply);
232
233 void ctdb_req_control_get_recmode(struct ctdb_req_control *request);
234 int ctdb_reply_control_get_recmode(struct ctdb_reply_control *reply,
235                                    int *recmode);
236
237 void ctdb_req_control_set_recmode(struct ctdb_req_control *request,
238                                   int recmode);
239 int ctdb_reply_control_set_recmode(struct ctdb_reply_control *reply);
240
241 void ctdb_req_control_statistics_reset(struct ctdb_req_control *request);
242 int ctdb_reply_control_statistics_reset(struct ctdb_reply_control *reply);
243
244 void ctdb_req_control_db_attach(struct ctdb_req_control *request,
245                                 const char *db_name);
246 int ctdb_reply_control_db_attach(struct ctdb_reply_control *reply,
247                                  uint32_t *db_id);
248
249 void ctdb_req_control_traverse_start(struct ctdb_req_control *request,
250                                      struct ctdb_traverse_start *traverse);
251 int ctdb_reply_control_traverse_start(struct ctdb_reply_control *reply);
252
253 void ctdb_req_control_register_srvid(struct ctdb_req_control *request,
254                                      uint64_t srvid);
255 int ctdb_reply_control_register_srvid(struct ctdb_reply_control *reply);
256
257 void ctdb_req_control_deregister_srvid(struct ctdb_req_control *request,
258                                        uint64_t srvid);
259 int ctdb_reply_control_deregister_srvid(struct ctdb_reply_control *reply);
260
261 void ctdb_req_control_get_dbname(struct ctdb_req_control *request,
262                                  uint32_t db_id);
263 int ctdb_reply_control_get_dbname(struct ctdb_reply_control *reply,
264                                   TALLOC_CTX *mem_ctx, const char **db_name);
265
266 void ctdb_req_control_enable_seqnum(struct ctdb_req_control *request,
267                                     uint32_t db_id);
268 int ctdb_reply_control_enable_seqnum(struct ctdb_reply_control *reply);
269
270 void ctdb_req_control_update_seqnum(struct ctdb_req_control *request,
271                                     uint32_t db_id);
272 int ctdb_reply_control_update_seqnum(struct ctdb_reply_control *reply);
273
274 void ctdb_req_control_dump_memory(struct ctdb_req_control *request);
275 int ctdb_reply_control_dump_memory(struct ctdb_reply_control *reply,
276                                    TALLOC_CTX *mem_ctx, const char **mem_str);
277
278 void ctdb_req_control_get_pid(struct ctdb_req_control *request);
279 int ctdb_reply_control_get_pid(struct ctdb_reply_control *reply,
280                                pid_t *pid);
281
282 void ctdb_req_control_get_recmaster(struct ctdb_req_control *request);
283 int ctdb_reply_control_get_recmaster(struct ctdb_reply_control *reply,
284                                      uint32_t *recmaster);
285
286 void ctdb_req_control_set_recmaster(struct ctdb_req_control *request,
287                                     int recmaster);
288 int ctdb_reply_control_set_recmaster(struct ctdb_reply_control *reply);
289
290 void ctdb_req_control_freeze(struct ctdb_req_control *request,
291                              uint32_t priority);
292 int ctdb_reply_control_freeze(struct ctdb_reply_control *reply);
293
294 void ctdb_req_control_get_pnn(struct ctdb_req_control *request);
295 int ctdb_reply_control_get_pnn(struct ctdb_reply_control *reply,
296                                uint32_t *pnn);
297
298 void ctdb_req_control_shutdown(struct ctdb_req_control *request);
299 int ctdb_reply_control_shutdown(struct ctdb_reply_control *reply);
300
301 void ctdb_req_control_get_monmode(struct ctdb_req_control *request);
302 int ctdb_reply_control_get_monmode(struct ctdb_reply_control *reply,
303                                    int *mon_mode);
304
305 void ctdb_req_control_tcp_client(struct ctdb_req_control *request,
306                                  struct ctdb_connection *conn);
307 int ctdb_reply_control_tcp_client(struct ctdb_reply_control *reply);
308
309 void ctdb_req_control_tcp_add(struct ctdb_req_control *request,
310                               struct ctdb_connection *conn);
311 int ctdb_reply_control_tcp_add(struct ctdb_reply_control *reply);
312
313 void ctdb_req_control_tcp_remove(struct ctdb_req_control *request,
314                                  struct ctdb_connection *conn);
315 int ctdb_reply_control_tcp_remove(struct ctdb_reply_control *reply);
316
317 void ctdb_req_control_startup(struct ctdb_req_control *request);
318 int ctdb_reply_control_startup(struct ctdb_reply_control *reply);
319
320 void ctdb_req_control_set_tunable(struct ctdb_req_control *request,
321                                   struct ctdb_tunable *tunable);
322 int ctdb_reply_control_set_tunable(struct ctdb_reply_control *reply);
323
324 void ctdb_req_control_get_tunable(struct ctdb_req_control *request,
325                                   const char *name);
326 int ctdb_reply_control_get_tunable(struct ctdb_reply_control *reply,
327                                    uint32_t *value);
328
329 void ctdb_req_control_list_tunables(struct ctdb_req_control *request);
330 int ctdb_reply_control_list_tunables(struct ctdb_reply_control *reply,
331                                      TALLOC_CTX *mem_ctx,
332                                      struct ctdb_var_list **tun_var_list);
333
334 void ctdb_req_control_modify_flags(struct ctdb_req_control *request,
335                                    struct ctdb_node_flag_change *flag_change);
336 int ctdb_reply_control_modify_flags(struct ctdb_reply_control *reply);
337
338 void ctdb_req_control_get_all_tunables(struct ctdb_req_control *request);
339 int ctdb_reply_control_get_all_tunables(struct ctdb_reply_control *reply,
340                                         TALLOC_CTX *mem_ctx,
341                                         struct ctdb_tunable_list **tun_list);
342
343 void ctdb_req_control_get_tcp_tickle_list(struct ctdb_req_control *request,
344                                           ctdb_sock_addr *addr);
345 int ctdb_reply_control_get_tcp_tickle_list(struct ctdb_reply_control *reply,
346                                            TALLOC_CTX *mem_ctx,
347                                            struct ctdb_tickle_list **tickles);
348
349 void ctdb_req_control_set_tcp_tickle_list(struct ctdb_req_control *request,
350                                           struct ctdb_tickle_list *tickles);
351 int ctdb_reply_control_set_tcp_tickle_list(struct ctdb_reply_control *reply);
352
353 void ctdb_req_control_db_attach_persistent(struct ctdb_req_control *request,
354                                            const char *name);
355 int ctdb_reply_control_db_attach_persistent(struct ctdb_reply_control *reply,
356                                             uint32_t *db_id);
357
358 void ctdb_req_control_update_record(struct ctdb_req_control *request,
359                                     struct ctdb_rec_buffer *recbuf);
360 int ctdb_reply_control_update_record(struct ctdb_reply_control *reply);
361
362 void ctdb_req_control_send_gratuitous_arp(struct ctdb_req_control *request,
363                                           struct ctdb_addr_info *addr_info);
364 int ctdb_reply_control_send_gratuitous_arp(struct ctdb_reply_control *reply);
365
366 void ctdb_req_control_wipe_database(struct ctdb_req_control *request,
367                                     struct ctdb_transdb *transdb);
368 int ctdb_reply_control_wipe_database(struct ctdb_reply_control *reply);
369
370 void ctdb_req_control_uptime(struct ctdb_req_control *request);
371 int ctdb_reply_control_uptime(struct ctdb_reply_control *reply,
372                               TALLOC_CTX *mem_ctx,
373                               struct ctdb_uptime **uptime);
374
375 void ctdb_req_control_start_recovery(struct ctdb_req_control *request);
376 int ctdb_reply_control_start_recovery(struct ctdb_reply_control *reply);
377
378 void ctdb_req_control_end_recovery(struct ctdb_req_control *request);
379 int ctdb_reply_control_end_recovery(struct ctdb_reply_control *reply);
380
381 void ctdb_req_control_reload_nodes_file(struct ctdb_req_control *request);
382 int ctdb_reply_control_reload_nodes_file(struct ctdb_reply_control *reply);
383
384 void ctdb_req_control_try_delete_records(struct ctdb_req_control *request,
385                                          struct ctdb_rec_buffer *recbuf);
386 int ctdb_reply_control_try_delete_records(struct ctdb_reply_control *reply,
387                                           TALLOC_CTX *mem_ctx,
388                                           struct ctdb_rec_buffer **recbuf);
389
390 void ctdb_req_control_enable_monitor(struct ctdb_req_control *request);
391 int ctdb_reply_control_enable_monitor(struct ctdb_reply_control *reply);
392
393 void ctdb_req_control_disable_monitor(struct ctdb_req_control *request);
394 int ctdb_reply_control_disable_monitor(struct ctdb_reply_control *reply);
395
396 void ctdb_req_control_add_public_ip(struct ctdb_req_control *request,
397                                     struct ctdb_addr_info *addr_info);
398 int ctdb_reply_control_add_public_ip(struct ctdb_reply_control *reply);
399
400 void ctdb_req_control_del_public_ip(struct ctdb_req_control *request,
401                                     struct ctdb_addr_info *addr_info);
402 int ctdb_reply_control_del_public_ip(struct ctdb_reply_control *reply);
403
404 void ctdb_req_control_get_capabilities(struct ctdb_req_control *request);
405 int ctdb_reply_control_get_capabilities(struct ctdb_reply_control *reply,
406                                         uint32_t *caps);
407
408 void ctdb_req_control_recd_ping(struct ctdb_req_control *request);
409 int ctdb_reply_control_recd_ping(struct ctdb_reply_control *reply);
410
411 void ctdb_req_control_release_ip(struct ctdb_req_control *request,
412                                  struct ctdb_public_ip *pubip);
413 int ctdb_reply_control_release_ip(struct ctdb_reply_control *reply);
414
415 void ctdb_req_control_takeover_ip(struct ctdb_req_control *request,
416                                   struct ctdb_public_ip *pubip);
417 int ctdb_reply_control_takeover_ip(struct ctdb_reply_control *reply);
418
419 void ctdb_req_control_get_public_ips(struct ctdb_req_control *request,
420                                      bool available_only);
421 int ctdb_reply_control_get_public_ips(struct ctdb_reply_control *reply,
422                                       TALLOC_CTX *mem_ctx,
423                                       struct ctdb_public_ip_list **pubip_list);
424
425 void ctdb_req_control_get_nodemap(struct ctdb_req_control *request);
426 int ctdb_reply_control_get_nodemap(struct ctdb_reply_control *reply,
427                                    TALLOC_CTX *mem_ctx,
428                                    struct ctdb_node_map **nodemap);
429
430 void ctdb_req_control_traverse_kill(struct ctdb_req_control *request,
431                                     struct ctdb_traverse_start *traverse);
432 int ctdb_reply_control_traverse_kill(struct ctdb_reply_control *reply);
433
434 void ctdb_req_control_recd_reclock_latency(struct ctdb_req_control *request,
435                                            double reclock_latency);
436 int ctdb_reply_control_recd_reclock_latency(struct ctdb_reply_control *reply);
437
438 void ctdb_req_control_get_reclock_file(struct ctdb_req_control *request);
439 int ctdb_reply_control_get_reclock_file(struct ctdb_reply_control *reply,
440                                         TALLOC_CTX *mem_ctx,
441                                         const char **reclock_file);
442
443 void ctdb_req_control_stop_node(struct ctdb_req_control *request);
444 int ctdb_reply_control_stop_node(struct ctdb_reply_control *reply);
445
446 void ctdb_req_control_continue_node(struct ctdb_req_control *request);
447 int ctdb_reply_control_continue_node(struct ctdb_reply_control *reply);
448
449 void ctdb_req_control_set_lmasterrole(struct ctdb_req_control *request,
450                                       uint32_t lmaster_role);
451 int ctdb_reply_control_set_lmasterrole(struct ctdb_reply_control *reply);
452
453 void ctdb_req_control_set_recmasterrole(struct ctdb_req_control *request,
454                                         uint32_t recmaster_role);
455 int ctdb_reply_control_set_recmasterrole(struct ctdb_reply_control *reply);
456
457 void ctdb_req_control_set_ban_state(struct ctdb_req_control *request,
458                                     struct ctdb_ban_state *ban_state);
459 int ctdb_reply_control_set_ban_state(struct ctdb_reply_control *reply);
460
461 void ctdb_req_control_get_ban_state(struct ctdb_req_control *request);
462 int ctdb_reply_control_get_ban_state(struct ctdb_reply_control *reply,
463                                      TALLOC_CTX *mem_ctx,
464                                      struct ctdb_ban_state **ban_state);
465
466 void ctdb_req_control_register_notify(struct ctdb_req_control *request,
467                                       struct ctdb_notify_data *notify);
468 int ctdb_reply_control_register_notify(struct ctdb_reply_control *reply);
469
470 void ctdb_req_control_deregister_notify(struct ctdb_req_control *request,
471                                         uint64_t srvid);
472 int ctdb_reply_control_deregister_notify(struct ctdb_reply_control *reply);
473
474 void ctdb_req_control_trans3_commit(struct ctdb_req_control *request,
475                                     struct ctdb_rec_buffer *recbuf);
476 int ctdb_reply_control_trans3_commit(struct ctdb_reply_control *reply);
477
478 void ctdb_req_control_get_db_seqnum(struct ctdb_req_control *request,
479                                     uint32_t db_id);
480 int ctdb_reply_control_get_db_seqnum(struct ctdb_reply_control *reply,
481                                      uint64_t *seqnum);
482
483 void ctdb_req_control_db_set_healthy(struct ctdb_req_control *request,
484                                      uint32_t db_id);
485 int ctdb_reply_control_db_set_healthy(struct ctdb_reply_control *reply);
486
487 void ctdb_req_control_db_get_health(struct ctdb_req_control *request,
488                                     uint32_t db_id);
489 int ctdb_reply_control_db_get_health(struct ctdb_reply_control *reply,
490                                      TALLOC_CTX *mem_ctx,
491                                      const char **reason);
492
493 void ctdb_req_control_get_public_ip_info(struct ctdb_req_control *request,
494                                          ctdb_sock_addr *addr);
495 int ctdb_reply_control_get_public_ip_info(struct ctdb_reply_control *reply,
496                                           TALLOC_CTX *mem_ctx,
497                                           struct ctdb_public_ip_info **ipinfo);
498
499 void ctdb_req_control_get_ifaces(struct ctdb_req_control *request);
500 int ctdb_reply_control_get_ifaces(struct ctdb_reply_control *reply,
501                                   TALLOC_CTX *mem_ctx,
502                                   struct ctdb_iface_list **iface_list);
503
504 void ctdb_req_control_set_iface_link_state(struct ctdb_req_control *request,
505                                            struct ctdb_iface *iface);
506 int ctdb_reply_control_set_iface_link_state(struct ctdb_reply_control *reply);
507
508 void ctdb_req_control_tcp_add_delayed_update(struct ctdb_req_control *request,
509                                              struct ctdb_connection *conn);
510 int ctdb_reply_control_tcp_add_delayed_update(struct ctdb_reply_control *reply);
511
512 void ctdb_req_control_get_stat_history(struct ctdb_req_control *request);
513 int ctdb_reply_control_get_stat_history(struct ctdb_reply_control *reply,
514                                         TALLOC_CTX *mem_ctx,
515                                         struct ctdb_statistics_list **stats_list);
516
517 void ctdb_req_control_schedule_for_deletion(struct ctdb_req_control *request,
518                                             struct ctdb_key_data *key);
519 int ctdb_reply_control_schedule_for_deletion(struct ctdb_reply_control *reply);
520
521 void ctdb_req_control_set_db_readonly(struct ctdb_req_control *request,
522                                       uint32_t db_id);
523 int ctdb_reply_control_set_db_readonly(struct ctdb_reply_control *reply);
524
525 void ctdb_req_control_traverse_start_ext(struct ctdb_req_control *request,
526                                          struct ctdb_traverse_start_ext *traverse);
527 int ctdb_reply_control_traverse_start_ext(struct ctdb_reply_control *reply);
528
529 void ctdb_req_control_get_db_statistics(struct ctdb_req_control *request,
530                                         uint32_t db_id);
531 int ctdb_reply_control_get_db_statistics(struct ctdb_reply_control *reply,
532                                          TALLOC_CTX *mem_ctx,
533                                          struct ctdb_db_statistics **dbstats);
534
535 void ctdb_req_control_set_db_sticky(struct ctdb_req_control *request,
536                                     uint32_t db_id);
537 int ctdb_reply_control_set_db_sticky(struct ctdb_reply_control *reply);
538
539 void ctdb_req_control_reload_public_ips(struct ctdb_req_control *request);
540 int ctdb_reply_control_reload_public_ips(struct ctdb_reply_control *reply);
541
542 void ctdb_req_control_receive_records(struct ctdb_req_control *request,
543                                       struct ctdb_rec_buffer *recbuf);
544 int ctdb_reply_control_receive_records(struct ctdb_reply_control *reply,
545                                        TALLOC_CTX *mem_ctx,
546                                        struct ctdb_rec_buffer **recbuf);
547
548 void ctdb_req_control_ipreallocated(struct ctdb_req_control *request);
549 int ctdb_reply_control_ipreallocated(struct ctdb_reply_control *reply);
550
551 void ctdb_req_control_get_runstate(struct ctdb_req_control *request);
552 int ctdb_reply_control_get_runstate(struct ctdb_reply_control *reply,
553                                     enum ctdb_runstate *runstate);
554
555 void ctdb_req_control_db_detach(struct ctdb_req_control *request,
556                                 uint32_t db_id);
557 int ctdb_reply_control_db_detach(struct ctdb_reply_control *reply);
558
559 void ctdb_req_control_get_nodes_file(struct ctdb_req_control *request);
560 int ctdb_reply_control_get_nodes_file(struct ctdb_reply_control *reply,
561                                       TALLOC_CTX *mem_ctx,
562                                       struct ctdb_node_map **nodemap);
563
564 void ctdb_req_control_db_freeze(struct ctdb_req_control *request,
565                                 uint32_t db_id);
566 int ctdb_reply_control_db_freeze(struct ctdb_reply_control *reply);
567
568 void ctdb_req_control_db_thaw(struct ctdb_req_control *request,
569                               uint32_t db_id);
570 int ctdb_reply_control_db_thaw(struct ctdb_reply_control *reply);
571
572 void ctdb_req_control_db_transaction_start(struct ctdb_req_control *request,
573                                            struct ctdb_transdb *transdb);
574 int ctdb_reply_control_db_transaction_start(struct ctdb_reply_control *reply);
575
576 void ctdb_req_control_db_transaction_commit(struct ctdb_req_control *request,
577                                             struct ctdb_transdb *transdb);
578 int ctdb_reply_control_db_transaction_commit(struct ctdb_reply_control *reply);
579
580 void ctdb_req_control_db_transaction_cancel(struct ctdb_req_control *request,
581                                             uint32_t db_id);
582 int ctdb_reply_control_db_transaction_cancel(struct ctdb_reply_control *reply);
583
584 void ctdb_req_control_db_pull(struct ctdb_req_control *request,
585                               struct ctdb_pulldb_ext *pulldb_ext);
586 int ctdb_reply_control_db_pull(struct ctdb_reply_control *reply,
587                                uint32_t *num_records);
588
589 void ctdb_req_control_db_push_start(struct ctdb_req_control *request,
590                                     struct ctdb_pulldb_ext *pulldb_ext);
591 int ctdb_reply_control_db_push_start(struct ctdb_reply_control *reply);
592
593 void ctdb_req_control_db_push_confirm(struct ctdb_req_control *request,
594                                       uint32_t db_id);
595 int ctdb_reply_control_db_push_confirm(struct ctdb_reply_control *reply,
596                                        uint32_t *num_records);
597
598 void ctdb_req_control_db_open_flags(struct ctdb_req_control *request,
599                                     uint32_t db_id);
600 int ctdb_reply_control_db_open_flags(struct ctdb_reply_control *reply,
601                                      int *tdb_flags);
602
603 void ctdb_req_control_db_attach_replicated(struct ctdb_req_control *request,
604                                            const char *db_name);
605 int ctdb_reply_control_db_attach_replicated(struct ctdb_reply_control *reply,
606                                             uint32_t *db_id);
607
608 /* From protocol/protocol_debug.c */
609
610 void ctdb_packet_print(uint8_t *buf, size_t buflen, FILE *fp);
611
612 /* From protocol/protocol_message.c */
613
614 size_t ctdb_req_message_len(struct ctdb_req_header *h,
615                             struct ctdb_req_message *c);
616
617 int ctdb_req_message_push(struct ctdb_req_header *h,
618                           struct ctdb_req_message *c,
619                           uint8_t *buf, size_t *buflen);
620
621 int ctdb_req_message_pull(uint8_t *buf, size_t buflen,
622                           struct ctdb_req_header *h,
623                           TALLOC_CTX *mem_ctx,
624                           struct ctdb_req_message *c);
625
626 size_t ctdb_req_message_data_len(struct ctdb_req_header *h,
627                                  struct ctdb_req_message_data *c);
628
629 int ctdb_req_message_data_push(struct ctdb_req_header *h,
630                                struct ctdb_req_message_data *c,
631                                uint8_t *buf, size_t *buflen);
632
633 int ctdb_req_message_data_pull(uint8_t *buf, size_t buflen,
634                                struct ctdb_req_header *h,
635                                TALLOC_CTX *mem_ctx,
636                                struct ctdb_req_message_data *c);
637
638 /* From protocol/protocol_event.c */
639
640 void ctdb_event_header_fill(struct ctdb_event_header *h, uint32_t reqid);
641
642 size_t ctdb_event_request_len(struct ctdb_event_request *in);
643
644 int ctdb_event_request_push(struct ctdb_event_request *in,
645                             uint8_t *buf, size_t *buflen);
646
647 int ctdb_event_request_pull(uint8_t *buf, size_t buflen,
648                             TALLOC_CTX *mem_ctx,
649                             struct ctdb_event_request *out);
650
651 size_t ctdb_event_reply_len(struct ctdb_event_reply *in);
652
653 int ctdb_event_reply_push(struct ctdb_event_reply *in,
654                           uint8_t *buf, size_t *buflen);
655
656 int ctdb_event_reply_pull(uint8_t *buf, size_t buflen,
657                           TALLOC_CTX *mem_ctx,
658                           struct ctdb_event_reply *out);
659
660 /* From protocol/protocol_packet.c */
661
662 int ctdb_allocate_pkt(TALLOC_CTX *mem_ctx, size_t datalen,
663                       uint8_t **buf, size_t *buflen);
664
665 /* From protocol/protocol_util.c */
666
667 const char *ctdb_runstate_to_string(enum ctdb_runstate runstate);
668 enum ctdb_runstate ctdb_runstate_from_string(const char *runstate_str);
669
670 const char *ctdb_event_to_string(enum ctdb_event event);
671 enum ctdb_event ctdb_event_from_string(const char *event_str);
672
673 const char *ctdb_sock_addr_to_string(TALLOC_CTX *mem_ctx, ctdb_sock_addr *addr);
674 int ctdb_sock_addr_cmp_ip(const ctdb_sock_addr *addr1,
675                           const ctdb_sock_addr *addr2);
676 int ctdb_sock_addr_cmp(const ctdb_sock_addr *addr1,
677                        const ctdb_sock_addr *addr2);
678 bool ctdb_sock_addr_same_ip(const ctdb_sock_addr *addr1,
679                             const ctdb_sock_addr *addr2);
680 bool ctdb_sock_addr_same(const ctdb_sock_addr *addr1,
681                          const ctdb_sock_addr *addr2);
682
683 #endif /* __CTDB_PROTOCOL_API_H__ */