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