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