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