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