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