ctdb-daemon: Add ctdb_vfork_exec()
[Samba.git] / ctdb / protocol / protocol_client.c
blob6eb6ede42cf343696ba2711905f169f4d2f76504
1 /*
2 CTDB protocol marshalling
4 Copyright (C) Amitay Isaacs 2015
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.
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.
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/>.
20 #include "replace.h"
21 #include "system/network.h"
23 #include <talloc.h>
24 #include <tdb.h>
26 #include "protocol.h"
27 #include "protocol_api.h"
28 #include "protocol_private.h"
31 void ctdb_req_call_fill(struct ctdb_req_call *c,
32 uint32_t db_id, uint32_t flags,
33 uint32_t call_id, TDB_DATA key)
35 request->flags = flags;
36 c->db_id = db_id;
37 c->call_id = call_id;
38 c->key = key;
39 c->calldata = tdb_null;
43 static int ctdb_reply_control_generic(struct ctdb_reply_control *reply,
44 uint32_t opcode)
46 if (reply->rdata.opcode != opcode) {
47 return EPROTO;
50 return reply->status;
53 /* CTDB_CONTROL_PROCESS_EXISTS */
55 void ctdb_req_control_process_exists(struct ctdb_req_control *request,
56 pid_t pid)
58 request->opcode = CTDB_CONTROL_PROCESS_EXISTS;
59 request->pad = 0;
60 request->srvid = 0;
61 request->client_id = 0;
62 request->flags = 0;
64 request->rdata.opcode = CTDB_CONTROL_PROCESS_EXISTS;
65 request->rdata.data.pid = pid;
69 int ctdb_reply_control_process_exists(struct ctdb_reply_control *reply,
70 int *status)
72 if (reply->rdata.opcode != CTDB_CONTROL_PROCESS_EXISTS) {
73 return EPROTO;
76 *status = reply->status;
77 reply->status = 0;
79 return reply->status;
82 /* CTDB_CONTROL_STATISTICS */
84 void ctdb_req_control_statistics(struct ctdb_req_control *request)
86 request->opcode = CTDB_CONTROL_STATISTICS;
87 request->pad = 0;
88 request->srvid = 0;
89 request->client_id = 0;
90 request->flags = 0;
92 request->rdata.opcode = CTDB_CONTROL_STATISTICS;
95 int ctdb_reply_control_statistics(struct ctdb_reply_control *reply,
96 TALLOC_CTX *mem_ctx,
97 struct ctdb_statistics **stats)
99 if (reply->rdata.opcode != CTDB_CONTROL_STATISTICS) {
100 return EPROTO;
103 if (reply->status == 0) {
104 *stats = talloc_steal(mem_ctx, reply->rdata.data.stats);
106 return reply->status;
109 /* CTDB_CONTROL_PING */
111 void ctdb_req_control_ping(struct ctdb_req_control *request)
113 request->opcode = CTDB_CONTROL_PING;
114 request->pad = 0;
115 request->srvid = 0;
116 request->client_id = 0;
117 request->flags = 0;
119 request->rdata.opcode = CTDB_CONTROL_PING;
122 int ctdb_reply_control_ping(struct ctdb_reply_control *reply,
123 int *num_clients)
125 if (reply->rdata.opcode != CTDB_CONTROL_PING) {
126 return EPROTO;
129 if (reply->status >= 0) {
130 *num_clients = reply->status;
131 reply->status = 0;
133 return reply->status;
136 /* CTDB_CONTROL_GETDBPATH */
138 void ctdb_req_control_getdbpath(struct ctdb_req_control *request,
139 uint32_t db_id)
141 request->opcode = CTDB_CONTROL_GETDBPATH;
142 request->pad = 0;
143 request->srvid = 0;
144 request->client_id = 0;
145 request->flags = 0;
147 request->rdata.opcode = CTDB_CONTROL_GETDBPATH;
148 request->rdata.data.db_id = db_id;
151 int ctdb_reply_control_getdbpath(struct ctdb_reply_control *reply,
152 TALLOC_CTX *mem_ctx, const char **db_path)
154 if (reply->rdata.opcode != CTDB_CONTROL_GETDBPATH) {
155 return EPROTO;
158 if (reply->status == 0) {
159 *db_path = talloc_steal(mem_ctx, reply->rdata.data.db_path);
161 return reply->status;
164 /* CTDB_CONTROL_GETVNNMAP */
166 void ctdb_req_control_getvnnmap(struct ctdb_req_control *request)
168 request->opcode = CTDB_CONTROL_GETVNNMAP;
169 request->pad = 0;
170 request->srvid = 0;
171 request->client_id = 0;
172 request->flags = 0;
174 request->rdata.opcode = CTDB_CONTROL_GETVNNMAP;
177 int ctdb_reply_control_getvnnmap(struct ctdb_reply_control *reply,
178 TALLOC_CTX *mem_ctx,
179 struct ctdb_vnn_map **vnnmap)
181 if (reply->rdata.opcode != CTDB_CONTROL_GETVNNMAP) {
182 return EPROTO;
185 if (reply->status == 0) {
186 *vnnmap = talloc_steal(mem_ctx, reply->rdata.data.vnnmap);
188 return reply->status;
191 /* CTDB_CONTROL_SETVNNMAP */
193 void ctdb_req_control_setvnnmap(struct ctdb_req_control *request,
194 struct ctdb_vnn_map *vnnmap)
196 request->opcode = CTDB_CONTROL_SETVNNMAP;
197 request->pad = 0;
198 request->srvid = 0;
199 request->client_id = 0;
200 request->flags = 0;
202 request->rdata.opcode = CTDB_CONTROL_SETVNNMAP;
203 request->rdata.data.vnnmap = vnnmap;
206 int ctdb_reply_control_setvnnmap(struct ctdb_reply_control *reply)
208 return ctdb_reply_control_generic(reply, CTDB_CONTROL_SETVNNMAP);
211 /* CTDB_CONTROL_GET_DEBUG */
213 void ctdb_req_control_get_debug(struct ctdb_req_control *request)
215 request->opcode = CTDB_CONTROL_GET_DEBUG;
216 request->pad = 0;
217 request->srvid = 0;
218 request->client_id = 0;
219 request->flags = 0;
221 request->rdata.opcode = CTDB_CONTROL_GET_DEBUG;
224 int ctdb_reply_control_get_debug(struct ctdb_reply_control *reply,
225 int *loglevel)
227 if (reply->rdata.opcode != CTDB_CONTROL_GET_DEBUG) {
228 return EPROTO;
231 if (reply->status == 0) {
232 *loglevel = (int)reply->rdata.data.loglevel;
234 return reply->status;
237 /* CTDB_CONTROL_SET_DEBUG */
239 void ctdb_req_control_set_debug(struct ctdb_req_control *request,
240 int loglevel)
242 request->opcode = CTDB_CONTROL_SET_DEBUG;
243 request->pad = 0;
244 request->srvid = 0;
245 request->client_id = 0;
246 request->flags = 0;
248 request->rdata.opcode = CTDB_CONTROL_SET_DEBUG;
249 request->rdata.data.loglevel = (uint32_t)loglevel;
252 int ctdb_reply_control_set_debug(struct ctdb_reply_control *reply)
254 return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_DEBUG);
257 /* CTDB_CONTROL_GET_DBMAP */
259 void ctdb_req_control_get_dbmap(struct ctdb_req_control *request)
261 request->opcode = CTDB_CONTROL_GET_DBMAP;
262 request->pad = 0;
263 request->srvid = 0;
264 request->client_id = 0;
265 request->flags = 0;
267 request->rdata.opcode = CTDB_CONTROL_GET_DBMAP;
270 int ctdb_reply_control_get_dbmap(struct ctdb_reply_control *reply,
271 TALLOC_CTX *mem_ctx,
272 struct ctdb_dbid_map **dbmap)
274 if (reply->rdata.opcode != CTDB_CONTROL_GET_DBMAP) {
275 return EPROTO;
278 if (reply->status == 0) {
279 *dbmap = talloc_steal(mem_ctx, reply->rdata.data.dbmap);
281 return reply->status;
284 /* CTDB_CONTROL_PULL_DB */
286 void ctdb_req_control_pull_db(struct ctdb_req_control *request,
287 struct ctdb_pulldb *pulldb)
289 request->opcode = CTDB_CONTROL_PULL_DB;
290 request->pad = 0;
291 request->srvid = 0;
292 request->client_id = 0;
293 request->flags = 0;
295 request->rdata.opcode = CTDB_CONTROL_PULL_DB;
296 request->rdata.data.pulldb = pulldb;
299 int ctdb_reply_control_pull_db(struct ctdb_reply_control *reply,
300 TALLOC_CTX *mem_ctx,
301 struct ctdb_rec_buffer **recbuf)
303 if (reply->rdata.opcode != CTDB_CONTROL_PULL_DB) {
304 return EPROTO;
307 if (reply->status == 0) {
308 *recbuf = talloc_steal(mem_ctx, reply->rdata.data.recbuf);
310 return reply->status;
313 /* CTDB_CONTROL_PUSH_DB */
315 void ctdb_req_control_push_db(struct ctdb_req_control *request,
316 struct ctdb_rec_buffer *recbuf)
318 request->opcode = CTDB_CONTROL_PUSH_DB;
319 request->pad = 0;
320 request->srvid = 0;
321 request->client_id = 0;
322 request->flags = 0;
324 request->rdata.opcode = CTDB_CONTROL_PUSH_DB;
325 request->rdata.data.recbuf = recbuf;
328 int ctdb_reply_control_push_db(struct ctdb_reply_control *reply)
330 return ctdb_reply_control_generic(reply, CTDB_CONTROL_PUSH_DB);
333 /* CTDB_CONTROL_GET_RECMODE */
335 void ctdb_req_control_get_recmode(struct ctdb_req_control *request)
337 request->opcode = CTDB_CONTROL_GET_RECMODE;
338 request->pad = 0;
339 request->srvid = 0;
340 request->client_id = 0;
341 request->flags = 0;
343 request->rdata.opcode = CTDB_CONTROL_GET_RECMODE;
346 int ctdb_reply_control_get_recmode(struct ctdb_reply_control *reply,
347 int *recmode)
349 if (reply->rdata.opcode != CTDB_CONTROL_GET_RECMODE) {
350 return EPROTO;
353 if (reply->status >= 0) {
354 *recmode = reply->status;
355 reply->status = 0;
357 return reply->status;
360 /* CTDB_CONTROL_SET_RECMODE */
362 void ctdb_req_control_set_recmode(struct ctdb_req_control *request,
363 int recmode)
365 request->opcode = CTDB_CONTROL_SET_RECMODE;
366 request->pad = 0;
367 request->srvid = 0;
368 request->client_id = 0;
369 request->flags = 0;
371 request->rdata.opcode = CTDB_CONTROL_SET_RECMODE;
372 request->rdata.data.recmode = recmode;
375 int ctdb_reply_control_set_recmode(struct ctdb_reply_control *reply)
377 return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_RECMODE);
380 /* CTDB_CONTROL_STATISTICS_RESET */
382 void ctdb_req_control_statistics_reset(struct ctdb_req_control *request)
384 request->opcode = CTDB_CONTROL_STATISTICS_RESET;
385 request->pad = 0;
386 request->srvid = 0;
387 request->client_id = 0;
388 request->flags = 0;
390 request->rdata.opcode = CTDB_CONTROL_STATISTICS_RESET;
393 int ctdb_reply_control_statistics_reset(struct ctdb_reply_control *reply)
395 return ctdb_reply_control_generic(reply,
396 CTDB_CONTROL_STATISTICS_RESET);
399 /* CTDB_CONTROL_DB_ATTACH */
401 void ctdb_req_control_db_attach(struct ctdb_req_control *request,
402 const char *db_name, uint32_t tdb_flags)
404 request->opcode = CTDB_CONTROL_DB_ATTACH;
405 request->pad = 0;
406 request->srvid = tdb_flags;
407 request->client_id = 0;
408 request->flags = 0;
410 request->rdata.opcode = CTDB_CONTROL_DB_ATTACH;
411 request->rdata.data.db_name = db_name;
414 int ctdb_reply_control_db_attach(struct ctdb_reply_control *reply,
415 uint32_t *db_id)
417 if (reply->rdata.opcode != CTDB_CONTROL_DB_ATTACH) {
418 return EPROTO;
421 if (reply->status == 0) {
422 *db_id = reply->rdata.data.db_id;
424 return reply->status;
427 /* CTDB_CONTROL_SET_CALL */
429 /* CTDB_CONTROL_TRAVERSE_START */
431 void ctdb_req_control_traverse_start(struct ctdb_req_control *request,
432 struct ctdb_traverse_start *traverse)
434 request->opcode = CTDB_CONTROL_TRAVERSE_START;
435 request->pad = 0;
436 request->srvid = 0;
437 request->client_id = 0;
438 request->flags = 0;
440 request->rdata.opcode = CTDB_CONTROL_TRAVERSE_START;
441 request->rdata.data.traverse_start = traverse;
444 int ctdb_reply_control_traverse_start(struct ctdb_reply_control *reply)
446 return ctdb_reply_control_generic(reply, CTDB_CONTROL_TRAVERSE_START);
449 /* CTDB_CONTROL_TRAVERSE_ALL */
450 /* CTDB_CONTROL_TRAVERSE_DATA */
452 /* CTDB_CONTROL_REGISTER_SRVID */
454 void ctdb_req_control_register_srvid(struct ctdb_req_control *request,
455 uint64_t srvid)
457 request->opcode = CTDB_CONTROL_REGISTER_SRVID;
458 request->pad = 0;
459 request->srvid = srvid;
460 request->client_id = 0;
461 request->flags = 0;
463 request->rdata.opcode = CTDB_CONTROL_REGISTER_SRVID;
466 int ctdb_reply_control_register_srvid(struct ctdb_reply_control *reply)
468 return ctdb_reply_control_generic(reply, CTDB_CONTROL_REGISTER_SRVID);
471 /* CTDB_CONTROL_DEREGISTER_SRVID */
473 void ctdb_req_control_deregister_srvid(struct ctdb_req_control *request,
474 uint64_t srvid)
476 request->opcode = CTDB_CONTROL_DEREGISTER_SRVID;
477 request->pad = 0;
478 request->srvid = srvid;
479 request->client_id = 0;
480 request->flags = 0;
482 request->rdata.opcode = CTDB_CONTROL_DEREGISTER_SRVID;
485 int ctdb_reply_control_deregister_srvid(struct ctdb_reply_control *reply)
487 return ctdb_reply_control_generic(reply,
488 CTDB_CONTROL_DEREGISTER_SRVID);
491 /* CTDB_CONTROL_GET_DBNAME */
493 void ctdb_req_control_get_dbname(struct ctdb_req_control *request,
494 uint32_t db_id)
496 request->opcode = CTDB_CONTROL_GET_DBNAME;
497 request->pad = 0;
498 request->srvid = 0;
499 request->client_id = 0;
500 request->flags = 0;
502 request->rdata.opcode = CTDB_CONTROL_GET_DBNAME;
503 request->rdata.data.db_id = db_id;
506 int ctdb_reply_control_get_dbname(struct ctdb_reply_control *reply,
507 TALLOC_CTX *mem_ctx, const char **db_name)
509 if (reply->rdata.opcode != CTDB_CONTROL_GET_DBNAME) {
510 return EPROTO;
513 if (reply->status == 0) {
514 *db_name = talloc_steal(mem_ctx, reply->rdata.data.db_name);
516 return reply->status;
519 /* CTDB_CONTROL_ENABLE_SEQNUM */
521 void ctdb_req_control_enable_seqnum(struct ctdb_req_control *request,
522 uint32_t db_id)
524 request->opcode = CTDB_CONTROL_ENABLE_SEQNUM;
525 request->pad = 0;
526 request->srvid = 0;
527 request->client_id = 0;
528 request->flags = 0;
530 request->rdata.opcode = CTDB_CONTROL_ENABLE_SEQNUM;
531 request->rdata.data.db_id = db_id;
534 int ctdb_reply_control_enable_seqnum(struct ctdb_reply_control *reply)
536 return ctdb_reply_control_generic(reply, CTDB_CONTROL_ENABLE_SEQNUM);
539 /* CTDB_CONTROL_UPDATE_SEQNUM */
541 void ctdb_req_control_update_seqnum(struct ctdb_req_control *request,
542 uint32_t db_id)
544 request->opcode = CTDB_CONTROL_UPDATE_SEQNUM;
545 request->pad = 0;
546 request->srvid = 0;
547 request->client_id = 0;
548 request->flags = 0;
550 request->rdata.opcode = CTDB_CONTROL_UPDATE_SEQNUM;
551 request->rdata.data.db_id = db_id;
554 int ctdb_reply_control_update_seqnum(struct ctdb_reply_control *reply)
556 return ctdb_reply_control_generic(reply, CTDB_CONTROL_UPDATE_SEQNUM);
559 /* CTDB_CONTROL_DUMP_MEMORY */
561 void ctdb_req_control_dump_memory(struct ctdb_req_control *request)
563 request->opcode = CTDB_CONTROL_DUMP_MEMORY;
564 request->pad = 0;
565 request->srvid = 0;
566 request->client_id = 0;
567 request->flags = 0;
569 request->rdata.opcode = CTDB_CONTROL_DUMP_MEMORY;
572 int ctdb_reply_control_dump_memory(struct ctdb_reply_control *reply,
573 TALLOC_CTX *mem_ctx, const char **mem_str)
575 if (reply->rdata.opcode != CTDB_CONTROL_DUMP_MEMORY) {
576 return EPROTO;
579 if (reply->status == 0) {
580 *mem_str = talloc_steal(mem_ctx, reply->rdata.data.mem_str);
582 return reply->status;
585 /* CTDB_CONTROL_GET_PID */
587 void ctdb_req_control_get_pid(struct ctdb_req_control *request)
589 request->opcode = CTDB_CONTROL_GET_PID;
590 request->pad = 0;
591 request->srvid = 0;
592 request->client_id = 0;
593 request->flags = 0;
595 request->rdata.opcode = CTDB_CONTROL_GET_PID;
598 int ctdb_reply_control_get_pid(struct ctdb_reply_control *reply,
599 pid_t *pid)
601 if (reply->rdata.opcode != CTDB_CONTROL_GET_PID) {
602 return EPROTO;
605 *pid = reply->status;
606 reply->status = 0;
608 return reply->status;
611 /* CTDB_CONTROL_GET_RECMASTER */
613 void ctdb_req_control_get_recmaster(struct ctdb_req_control *request)
615 request->opcode = CTDB_CONTROL_GET_RECMASTER;
616 request->pad = 0;
617 request->srvid = 0;
618 request->client_id = 0;
619 request->flags = 0;
621 request->rdata.opcode = CTDB_CONTROL_GET_RECMASTER;
624 int ctdb_reply_control_get_recmaster(struct ctdb_reply_control *reply,
625 uint32_t *recmaster)
627 if (reply->rdata.opcode != CTDB_CONTROL_GET_RECMASTER) {
628 return EPROTO;
631 *recmaster = reply->status;
632 reply->status = 0;
634 return reply->status;
637 /* CTDB_CONTROL_SET_RECMASTER */
639 void ctdb_req_control_set_recmaster(struct ctdb_req_control *request,
640 int recmaster)
642 request->opcode = CTDB_CONTROL_SET_RECMASTER;
643 request->pad = 0;
644 request->srvid = 0;
645 request->client_id = 0;
646 request->flags = 0;
648 request->rdata.opcode = CTDB_CONTROL_SET_RECMASTER;
649 request->rdata.data.recmaster = recmaster;
652 int ctdb_reply_control_set_recmaster(struct ctdb_reply_control *reply)
654 return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_RECMASTER);
657 /* CTDB_CONTROL_FREEZE */
659 void ctdb_req_control_freeze(struct ctdb_req_control *request,
660 uint32_t priority)
662 request->opcode = CTDB_CONTROL_FREEZE;
663 request->pad = 0;
664 request->srvid = priority;
665 request->client_id = 0;
666 request->flags = 0;
668 request->rdata.opcode = CTDB_CONTROL_FREEZE;
671 int ctdb_reply_control_freeze(struct ctdb_reply_control *reply)
673 return ctdb_reply_control_generic(reply, CTDB_CONTROL_FREEZE);
676 /* CTDB_CONTROL_GET_PNN */
678 void ctdb_req_control_get_pnn(struct ctdb_req_control *request)
680 request->opcode = CTDB_CONTROL_GET_PNN;
681 request->pad = 0;
682 request->srvid = 0;
683 request->client_id = 0;
684 request->flags = 0;
686 request->rdata.opcode = CTDB_CONTROL_GET_PNN;
689 int ctdb_reply_control_get_pnn(struct ctdb_reply_control *reply,
690 uint32_t *pnn)
692 if (reply->rdata.opcode != CTDB_CONTROL_GET_PNN) {
693 return EPROTO;
696 if (reply->status >= 0) {
697 *pnn = reply->status;
698 reply->status = 0;
700 return reply->status;
703 /* CTDB_CONTROL_SHUTDOWN */
705 void ctdb_req_control_shutdown(struct ctdb_req_control *request)
707 request->opcode = CTDB_CONTROL_SHUTDOWN;
708 request->pad = 0;
709 request->srvid = 0;
710 request->client_id = 0;
711 request->flags = CTDB_CTRL_FLAG_NOREPLY;
713 request->rdata.opcode = CTDB_CONTROL_SHUTDOWN;
716 int ctdb_reply_control_shutdown(struct ctdb_reply_control *reply)
718 return ctdb_reply_control_generic(reply, CTDB_CONTROL_SHUTDOWN);
721 /* CTDB_CONTROL_GET_MONMODE */
723 void ctdb_req_control_get_monmode(struct ctdb_req_control *request)
725 request->opcode = CTDB_CONTROL_GET_MONMODE;
726 request->pad = 0;
727 request->srvid = 0;
728 request->client_id = 0;
729 request->flags = 0;
731 request->rdata.opcode = CTDB_CONTROL_GET_MONMODE;
734 int ctdb_reply_control_get_monmode(struct ctdb_reply_control *reply,
735 int *mon_mode)
737 if (reply->rdata.opcode != CTDB_CONTROL_GET_MONMODE) {
738 return EPROTO;
741 if (reply->status >= 0) {
742 *mon_mode = reply->status;
743 reply->status = 0;
745 return reply->status;
748 /* CTDB_CONTROL_TCP_CLIENT */
750 void ctdb_req_control_tcp_client(struct ctdb_req_control *request,
751 struct ctdb_connection *conn)
753 request->opcode = CTDB_CONTROL_TCP_CLIENT;
754 request->pad = 0;
755 request->srvid = 0;
756 request->client_id = 0;
757 request->flags = 0;
759 request->rdata.opcode = CTDB_CONTROL_TCP_CLIENT;
760 request->rdata.data.conn = conn;
763 int ctdb_reply_control_tcp_client(struct ctdb_reply_control *reply)
765 return ctdb_reply_control_generic(reply, CTDB_CONTROL_TCP_CLIENT);
768 /* CTDB_CONTROL_TCP_ADD */
770 void ctdb_req_control_tcp_add(struct ctdb_req_control *request,
771 struct ctdb_connection *conn)
773 request->opcode = CTDB_CONTROL_TCP_ADD;
774 request->pad = 0;
775 request->srvid = 0;
776 request->client_id = 0;
777 request->flags = 0;
779 request->rdata.opcode = CTDB_CONTROL_TCP_ADD;
780 request->rdata.data.conn = conn;
783 int ctdb_reply_control_tcp_add(struct ctdb_reply_control *reply)
785 return ctdb_reply_control_generic(reply, CTDB_CONTROL_TCP_ADD);
788 /* CTDB_CONTROL_TCP_REMOVE */
790 void ctdb_req_control_tcp_remove(struct ctdb_req_control *request,
791 struct ctdb_connection *conn)
793 request->opcode = CTDB_CONTROL_TCP_REMOVE;
794 request->pad = 0;
795 request->srvid = 0;
796 request->client_id = 0;
797 request->flags = 0;
799 request->rdata.opcode = CTDB_CONTROL_TCP_REMOVE;
800 request->rdata.data.conn = conn;
803 int ctdb_reply_control_tcp_remove(struct ctdb_reply_control *reply)
805 return ctdb_reply_control_generic(reply, CTDB_CONTROL_TCP_REMOVE);
808 /* CTDB_CONTROL_STARTUP */
810 void ctdb_req_control_startup(struct ctdb_req_control *request)
812 request->opcode = CTDB_CONTROL_STARTUP;
813 request->pad = 0;
814 request->srvid = 0;
815 request->client_id = 0;
816 request->flags = 0;
818 request->rdata.opcode = CTDB_CONTROL_STARTUP;
821 int ctdb_reply_control_startup(struct ctdb_reply_control *reply)
823 return ctdb_reply_control_generic(reply, CTDB_CONTROL_STARTUP);
826 /* CTDB_CONTROL_SET_TUNABLE */
828 void ctdb_req_control_set_tunable(struct ctdb_req_control *request,
829 struct ctdb_tunable *tunable)
831 request->opcode = CTDB_CONTROL_SET_TUNABLE;
832 request->pad = 0;
833 request->srvid = 0;
834 request->client_id = 0;
835 request->flags = 0;
837 request->rdata.opcode = CTDB_CONTROL_SET_TUNABLE;
838 request->rdata.data.tunable = tunable;
841 int ctdb_reply_control_set_tunable(struct ctdb_reply_control *reply)
843 return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_TUNABLE);
846 /* CTDB_CONTROL_GET_TUNABLE */
848 void ctdb_req_control_get_tunable(struct ctdb_req_control *request,
849 const char *name)
851 request->opcode = CTDB_CONTROL_GET_TUNABLE;
852 request->pad = 0;
853 request->srvid = 0;
854 request->client_id = 0;
855 request->flags = 0;
857 request->rdata.opcode = CTDB_CONTROL_GET_TUNABLE;
858 request->rdata.data.tun_var = discard_const(name);
861 int ctdb_reply_control_get_tunable(struct ctdb_reply_control *reply,
862 uint32_t *value)
864 if (reply->rdata.opcode != CTDB_CONTROL_GET_TUNABLE) {
865 return EPROTO;
868 if (reply->status == 0) {
869 *value = reply->rdata.data.tun_value;
871 return reply->status;
874 /* CTDB_CONTROL_LIST_TUNABLES */
876 void ctdb_req_control_list_tunables(struct ctdb_req_control *request)
878 request->opcode = CTDB_CONTROL_LIST_TUNABLES;
879 request->pad = 0;
880 request->srvid = 0;
881 request->client_id = 0;
882 request->flags = 0;
884 request->rdata.opcode = CTDB_CONTROL_LIST_TUNABLES;
887 int ctdb_reply_control_list_tunables(struct ctdb_reply_control *reply,
888 TALLOC_CTX *mem_ctx,
889 struct ctdb_var_list **tun_var_list)
891 if (reply->rdata.opcode != CTDB_CONTROL_LIST_TUNABLES) {
892 return EPROTO;
895 if (reply->status == 0) {
896 *tun_var_list = talloc_steal(mem_ctx,
897 reply->rdata.data.tun_var_list);
899 return reply->status;
902 /* CTDB_CONTROL_MODIFY_FLAGS */
904 void ctdb_req_control_modify_flags(struct ctdb_req_control *request,
905 struct ctdb_node_flag_change *flag_change)
907 request->opcode = CTDB_CONTROL_MODIFY_FLAGS;
908 request->pad = 0;
909 request->srvid = 0;
910 request->client_id = 0;
911 request->flags = 0;
913 request->rdata.opcode = CTDB_CONTROL_MODIFY_FLAGS;
914 request->rdata.data.flag_change = flag_change;
917 int ctdb_reply_control_modify_flags(struct ctdb_reply_control *reply)
919 return ctdb_reply_control_generic(reply, CTDB_CONTROL_MODIFY_FLAGS);
922 /* CTDB_CONTROL_GET_ALL_TUNABLES */
924 void ctdb_req_control_get_all_tunables(struct ctdb_req_control *request)
926 request->opcode = CTDB_CONTROL_GET_ALL_TUNABLES;
927 request->pad = 0;
928 request->srvid = 0;
929 request->client_id = 0;
930 request->flags = 0;
932 request->rdata.opcode = CTDB_CONTROL_GET_ALL_TUNABLES;
935 int ctdb_reply_control_get_all_tunables(struct ctdb_reply_control *reply,
936 TALLOC_CTX *mem_ctx,
937 struct ctdb_tunable_list **tun_list)
939 if (reply->rdata.opcode != CTDB_CONTROL_GET_ALL_TUNABLES) {
940 return EPROTO;
943 if (reply->status == 0) {
944 *tun_list = talloc_steal(mem_ctx, reply->rdata.data.tun_list);
946 return reply->status;
949 /* CTDB_CONTROL_GET_TCP_TICKLE_LIST */
951 void ctdb_req_control_get_tcp_tickle_list(struct ctdb_req_control *request,
952 ctdb_sock_addr *addr)
954 request->opcode = CTDB_CONTROL_GET_TCP_TICKLE_LIST;
955 request->pad = 0;
956 request->srvid = 0;
957 request->client_id = 0;
958 request->flags = 0;
960 request->rdata.opcode = CTDB_CONTROL_GET_TCP_TICKLE_LIST;
961 request->rdata.data.addr = addr;
964 int ctdb_reply_control_get_tcp_tickle_list(struct ctdb_reply_control *reply,
965 TALLOC_CTX *mem_ctx,
966 struct ctdb_tickle_list **tickles)
968 if (reply->rdata.opcode != CTDB_CONTROL_GET_TCP_TICKLE_LIST) {
969 return EPROTO;
972 if (reply->status == 0) {
973 *tickles = talloc_steal(mem_ctx, reply->rdata.data.tickles);
975 return reply->status;
978 /* CTDB_CONTROL_SET_TCP_TICKLE_LIST */
980 void ctdb_req_control_set_tcp_tickle_list(struct ctdb_req_control *request,
981 struct ctdb_tickle_list *tickles)
983 request->opcode = CTDB_CONTROL_SET_TCP_TICKLE_LIST;
984 request->pad = 0;
985 request->srvid = 0;
986 request->client_id = 0;
987 request->flags = 0;
989 request->rdata.opcode = CTDB_CONTROL_SET_TCP_TICKLE_LIST;
990 request->rdata.data.tickles = tickles;
993 int ctdb_reply_control_set_tcp_tickle_list(struct ctdb_reply_control *reply)
995 return ctdb_reply_control_generic(reply,
996 CTDB_CONTROL_SET_TCP_TICKLE_LIST);
999 /* CTDB_CONTROL_DB_ATTACH_PERSISTENT */
1001 void ctdb_req_control_db_attach_persistent(struct ctdb_req_control *request,
1002 const char *db_name,
1003 uint32_t tdb_flags)
1005 request->opcode = CTDB_CONTROL_DB_ATTACH_PERSISTENT;
1006 request->pad = 0;
1007 request->srvid = tdb_flags;
1008 request->client_id = 0;
1009 request->flags = 0;
1011 request->rdata.opcode = CTDB_CONTROL_DB_ATTACH_PERSISTENT;
1012 request->rdata.data.db_name = db_name;
1015 int ctdb_reply_control_db_attach_persistent(struct ctdb_reply_control *reply,
1016 uint32_t *db_id)
1018 if (reply->rdata.opcode != CTDB_CONTROL_DB_ATTACH_PERSISTENT) {
1019 return EPROTO;
1022 if (reply->status == 0) {
1023 *db_id = reply->rdata.data.db_id;
1025 return reply->status;
1028 /* CTDB_CONTROL_UPDATE_RECORD */
1030 void ctdb_req_control_update_record(struct ctdb_req_control *request,
1031 struct ctdb_rec_buffer *recbuf)
1033 request->opcode = CTDB_CONTROL_UPDATE_RECORD;
1034 request->pad = 0;
1035 request->srvid = 0;
1036 request->client_id = 0;
1037 request->flags = 0;
1039 request->rdata.opcode = CTDB_CONTROL_UPDATE_RECORD;
1040 request->rdata.data.recbuf = recbuf;
1043 int ctdb_reply_control_update_record(struct ctdb_reply_control *reply)
1045 return ctdb_reply_control_generic(reply, CTDB_CONTROL_UPDATE_RECORD);
1048 /* CTDB_CONTROL_SEND_GRATUITOUS_ARP */
1050 void ctdb_req_control_send_gratuitous_arp(struct ctdb_req_control *request,
1051 struct ctdb_addr_info *addr_info)
1053 request->opcode = CTDB_CONTROL_SEND_GRATUITOUS_ARP;
1054 request->pad = 0;
1055 request->srvid = 0;
1056 request->client_id = 0;
1057 request->flags = 0;
1059 request->rdata.opcode = CTDB_CONTROL_SEND_GRATUITOUS_ARP;
1060 request->rdata.data.addr_info = addr_info;
1063 int ctdb_reply_control_send_gratuitous_arp(struct ctdb_reply_control *reply)
1065 return ctdb_reply_control_generic(reply,
1066 CTDB_CONTROL_SEND_GRATUITOUS_ARP);
1069 /* CTDB_CONTROL_WIPE_DATABASE */
1071 void ctdb_req_control_wipe_database(struct ctdb_req_control *request,
1072 struct ctdb_transdb *transdb)
1074 request->opcode = CTDB_CONTROL_WIPE_DATABASE;
1075 request->pad = 0;
1076 request->srvid = 0;
1077 request->client_id = 0;
1078 request->flags = 0;
1080 request->rdata.opcode = CTDB_CONTROL_WIPE_DATABASE;
1081 request->rdata.data.transdb = transdb;
1084 int ctdb_reply_control_wipe_database(struct ctdb_reply_control *reply)
1086 return ctdb_reply_control_generic(reply, CTDB_CONTROL_WIPE_DATABASE);
1089 /* CTDB_CONTROL_UPTIME */
1091 void ctdb_req_control_uptime(struct ctdb_req_control *request)
1093 request->opcode = CTDB_CONTROL_UPTIME;
1094 request->pad = 0;
1095 request->srvid = 0;
1096 request->client_id = 0;
1097 request->flags = 0;
1099 request->rdata.opcode = CTDB_CONTROL_UPTIME;
1102 int ctdb_reply_control_uptime(struct ctdb_reply_control *reply,
1103 TALLOC_CTX *mem_ctx, struct ctdb_uptime **uptime)
1105 if (reply->rdata.opcode != CTDB_CONTROL_UPTIME) {
1106 return EPROTO;
1109 if (reply->status == 0) {
1110 *uptime = talloc_steal(mem_ctx, reply->rdata.data.uptime);
1112 return reply->status;
1115 /* CTDB_CONTROL_START_RECOVERY */
1117 void ctdb_req_control_start_recovery(struct ctdb_req_control *request)
1119 request->opcode = CTDB_CONTROL_START_RECOVERY;
1120 request->pad = 0;
1121 request->srvid = 0;
1122 request->client_id = 0;
1123 request->flags = 0;
1125 request->rdata.opcode = CTDB_CONTROL_START_RECOVERY;
1128 int ctdb_reply_control_start_recovery(struct ctdb_reply_control *reply)
1130 return ctdb_reply_control_generic(reply, CTDB_CONTROL_START_RECOVERY);
1133 /* CTDB_CONTROL_END_RECOVERY */
1135 void ctdb_req_control_end_recovery(struct ctdb_req_control *request)
1137 request->opcode = CTDB_CONTROL_END_RECOVERY;
1138 request->pad = 0;
1139 request->srvid = 0;
1140 request->client_id = 0;
1141 request->flags = 0;
1143 request->rdata.opcode = CTDB_CONTROL_END_RECOVERY;
1146 int ctdb_reply_control_end_recovery(struct ctdb_reply_control *reply)
1148 return ctdb_reply_control_generic(reply, CTDB_CONTROL_END_RECOVERY);
1151 /* CTDB_CONTROL_RELOAD_NODES_FILE */
1153 void ctdb_req_control_reload_nodes_file(struct ctdb_req_control *request)
1155 request->opcode = CTDB_CONTROL_RELOAD_NODES_FILE;
1156 request->pad = 0;
1157 request->srvid = 0;
1158 request->client_id = 0;
1159 request->flags = 0;
1161 request->rdata.opcode = CTDB_CONTROL_RELOAD_NODES_FILE;
1164 int ctdb_reply_control_reload_nodes_file(struct ctdb_reply_control *reply)
1166 return ctdb_reply_control_generic(reply,
1167 CTDB_CONTROL_RELOAD_NODES_FILE);
1170 /* CTDB_CONTROL_TRY_DELETE_RECORDS */
1172 void ctdb_req_control_try_delete_records(struct ctdb_req_control *request,
1173 struct ctdb_rec_buffer *recbuf)
1175 request->opcode = CTDB_CONTROL_TRY_DELETE_RECORDS;
1176 request->pad = 0;
1177 request->srvid = 0;
1178 request->client_id = 0;
1179 request->flags = 0;
1181 request->rdata.opcode = CTDB_CONTROL_TRY_DELETE_RECORDS;
1182 request->rdata.data.recbuf = recbuf;
1185 int ctdb_reply_control_try_delete_records(struct ctdb_reply_control *reply,
1186 TALLOC_CTX *mem_ctx,
1187 struct ctdb_rec_buffer **recbuf)
1189 if (reply->rdata.opcode != CTDB_CONTROL_TRY_DELETE_RECORDS) {
1190 return EPROTO;
1193 if (reply->status == 0) {
1194 *recbuf = talloc_steal(mem_ctx, reply->rdata.data.recbuf);
1196 return reply->status;
1199 /* CTDB_CONTROL_ENABLE_MONITOR */
1201 void ctdb_req_control_enable_monitor(struct ctdb_req_control *request)
1203 request->opcode = CTDB_CONTROL_ENABLE_MONITOR;
1204 request->pad = 0;
1205 request->srvid = 0;
1206 request->client_id = 0;
1207 request->flags = 0;
1209 request->rdata.opcode = CTDB_CONTROL_ENABLE_MONITOR;
1212 int ctdb_reply_control_enable_monitor(struct ctdb_reply_control *reply)
1214 return ctdb_reply_control_generic(reply, CTDB_CONTROL_ENABLE_MONITOR);
1217 /* CTDB_CONTROL_DISABLE_MONITOR */
1219 void ctdb_req_control_disable_monitor(struct ctdb_req_control *request)
1221 request->opcode = CTDB_CONTROL_DISABLE_MONITOR;
1222 request->pad = 0;
1223 request->srvid = 0;
1224 request->client_id = 0;
1225 request->flags = 0;
1227 request->rdata.opcode = CTDB_CONTROL_DISABLE_MONITOR;
1230 int ctdb_reply_control_disable_monitor(struct ctdb_reply_control *reply)
1232 return ctdb_reply_control_generic(reply, CTDB_CONTROL_DISABLE_MONITOR);
1235 /* CTDB_CONTROL_ADD_PUBLIC_IP */
1237 void ctdb_req_control_add_public_ip(struct ctdb_req_control *request,
1238 struct ctdb_addr_info *addr_info)
1240 request->opcode = CTDB_CONTROL_ADD_PUBLIC_IP;
1241 request->pad = 0;
1242 request->srvid = 0;
1243 request->client_id = 0;
1244 request->flags = 0;
1246 request->rdata.opcode = CTDB_CONTROL_ADD_PUBLIC_IP;
1247 request->rdata.data.addr_info = addr_info;
1250 int ctdb_reply_control_add_public_ip(struct ctdb_reply_control *reply)
1252 return ctdb_reply_control_generic(reply, CTDB_CONTROL_ADD_PUBLIC_IP);
1255 /* CTDB_CONTROL_DEL_PUBLIC_IP */
1257 void ctdb_req_control_del_public_ip(struct ctdb_req_control *request,
1258 struct ctdb_addr_info *addr_info)
1260 request->opcode = CTDB_CONTROL_DEL_PUBLIC_IP;
1261 request->pad = 0;
1262 request->srvid = 0;
1263 request->client_id = 0;
1264 request->flags = 0;
1266 request->rdata.opcode = CTDB_CONTROL_DEL_PUBLIC_IP;
1267 request->rdata.data.addr_info = addr_info;
1270 int ctdb_reply_control_del_public_ip(struct ctdb_reply_control *reply)
1272 return ctdb_reply_control_generic(reply, CTDB_CONTROL_DEL_PUBLIC_IP);
1275 /* CTDB_CONTROL_RUN_EVENTSCRIPTS */
1277 void ctdb_req_control_run_eventscripts(struct ctdb_req_control *request,
1278 const char *event_str)
1280 request->opcode = CTDB_CONTROL_RUN_EVENTSCRIPTS;
1281 request->pad = 0;
1282 request->srvid = 0;
1283 request->client_id = 0;
1284 request->flags = 0;
1286 request->rdata.opcode = CTDB_CONTROL_RUN_EVENTSCRIPTS;
1287 request->rdata.data.event_str = event_str;
1290 int ctdb_reply_control_run_eventscripts(struct ctdb_reply_control *reply)
1292 return ctdb_reply_control_generic(reply,
1293 CTDB_CONTROL_RUN_EVENTSCRIPTS);
1296 /* CTDB_CONTROL_GET_CAPABILITIES */
1298 void ctdb_req_control_get_capabilities(struct ctdb_req_control *request)
1300 request->opcode = CTDB_CONTROL_GET_CAPABILITIES;
1301 request->pad = 0;
1302 request->srvid = 0;
1303 request->client_id = 0;
1304 request->flags = 0;
1306 request->rdata.opcode = CTDB_CONTROL_GET_CAPABILITIES;
1309 int ctdb_reply_control_get_capabilities(struct ctdb_reply_control *reply,
1310 uint32_t *caps)
1312 if (reply->rdata.opcode != CTDB_CONTROL_GET_CAPABILITIES) {
1313 return EPROTO;
1316 if (reply->status == 0) {
1317 *caps = reply->rdata.data.caps;
1319 return reply->status;
1322 /* CTDB_CONTROL_RECD_PING */
1324 void ctdb_req_control_recd_ping(struct ctdb_req_control *request)
1326 request->opcode = CTDB_CONTROL_RECD_PING;
1327 request->pad = 0;
1328 request->srvid = 0;
1329 request->client_id = 0;
1330 request->flags = 0;
1332 request->rdata.opcode = CTDB_CONTROL_RECD_PING;
1335 int ctdb_reply_control_recd_ping(struct ctdb_reply_control *reply)
1337 return ctdb_reply_control_generic(reply, CTDB_CONTROL_RECD_PING);
1340 /* CTDB_CONTROL_RELEASE_IP */
1342 void ctdb_req_control_release_ip(struct ctdb_req_control *request,
1343 struct ctdb_public_ip *pubip)
1345 request->opcode = CTDB_CONTROL_RELEASE_IP;
1346 request->pad = 0;
1347 request->srvid = 0;
1348 request->client_id = 0;
1349 request->flags = 0;
1351 request->rdata.opcode = CTDB_CONTROL_RELEASE_IP;
1352 request->rdata.data.pubip = pubip;
1355 int ctdb_reply_control_release_ip(struct ctdb_reply_control *reply)
1357 return ctdb_reply_control_generic(reply, CTDB_CONTROL_RELEASE_IP);
1360 /* CTDB_CONTROL_TAKEOVER_IP */
1362 void ctdb_req_control_takeover_ip(struct ctdb_req_control *request,
1363 struct ctdb_public_ip *pubip)
1365 request->opcode = CTDB_CONTROL_TAKEOVER_IP;
1366 request->pad = 0;
1367 request->srvid = 0;
1368 request->client_id = 0;
1369 request->flags = 0;
1371 request->rdata.opcode = CTDB_CONTROL_TAKEOVER_IP;
1372 request->rdata.data.pubip = pubip;
1375 int ctdb_reply_control_takeover_ip(struct ctdb_reply_control *reply)
1377 return ctdb_reply_control_generic(reply, CTDB_CONTROL_TAKEOVER_IP);
1380 /* CTDB_CONTROL_GET_PUBLIC_IPS */
1382 void ctdb_req_control_get_public_ips(struct ctdb_req_control *request)
1384 request->opcode = CTDB_CONTROL_GET_PUBLIC_IPS;
1385 request->pad = 0;
1386 request->srvid = 0;
1387 request->client_id = 0;
1388 request->flags = 0;
1390 request->rdata.opcode = CTDB_CONTROL_GET_PUBLIC_IPS;
1393 int ctdb_reply_control_get_public_ips(struct ctdb_reply_control *reply,
1394 TALLOC_CTX *mem_ctx,
1395 struct ctdb_public_ip_list **pubip_list)
1397 if (reply->rdata.opcode != CTDB_CONTROL_GET_PUBLIC_IPS) {
1398 return EPROTO;
1401 if (reply->status == 0) {
1402 *pubip_list = talloc_steal(mem_ctx,
1403 reply->rdata.data.pubip_list);
1405 return reply->status;
1408 /* CTDB_CONTROL_GET_NODEMAP */
1410 void ctdb_req_control_get_nodemap(struct ctdb_req_control *request)
1412 request->opcode = CTDB_CONTROL_GET_NODEMAP;
1413 request->pad = 0;
1414 request->srvid = 0;
1415 request->client_id = 0;
1416 request->flags = 0;
1418 request->rdata.opcode = CTDB_CONTROL_GET_NODEMAP;
1421 int ctdb_reply_control_get_nodemap(struct ctdb_reply_control *reply,
1422 TALLOC_CTX *mem_ctx,
1423 struct ctdb_node_map **nodemap)
1425 if (reply->rdata.opcode != CTDB_CONTROL_GET_NODEMAP) {
1426 return EPROTO;
1429 if (reply->status == 0) {
1430 *nodemap = talloc_steal(mem_ctx, reply->rdata.data.nodemap);
1432 return reply->status;
1435 /* CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS */
1437 void ctdb_req_control_get_event_script_status(struct ctdb_req_control *request,
1438 uint32_t event)
1440 request->opcode = CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS;
1441 request->pad = 0;
1442 request->srvid = 0;
1443 request->client_id = 0;
1444 request->flags = 0;
1446 request->rdata.opcode = CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS;
1447 request->rdata.data.event = event;
1450 int ctdb_reply_control_get_event_script_status(struct ctdb_reply_control *reply,
1451 TALLOC_CTX *mem_ctx,
1452 struct ctdb_script_list **slist)
1454 if (reply->rdata.opcode != CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS) {
1455 return EPROTO;
1458 if (reply->status == 0) {
1459 *slist = talloc_steal(mem_ctx, reply->rdata.data.script_list);
1461 return reply->status;
1464 /* CTDB_CONTROL_TRAVERSE_KILL */
1466 void ctdb_req_control_traverse_kill(struct ctdb_req_control *request,
1467 struct ctdb_traverse_start *traverse)
1469 request->opcode = CTDB_CONTROL_TRAVERSE_KILL;
1470 request->pad = 0;
1471 request->srvid = 0;
1472 request->client_id = 0;
1473 request->flags = 0;
1475 request->rdata.opcode = CTDB_CONTROL_TRAVERSE_KILL;
1476 request->rdata.data.traverse_start = traverse;
1479 int ctdb_reply_control_traverse_kill(struct ctdb_reply_control *reply)
1481 return ctdb_reply_control_generic(reply, CTDB_CONTROL_TRAVERSE_KILL);
1484 /* CTDB_CONTROL_RECD_RECLOCK_LATENCY */
1486 void ctdb_req_control_recd_reclock_latency(struct ctdb_req_control *request,
1487 double reclock_latency)
1489 request->opcode = CTDB_CONTROL_RECD_RECLOCK_LATENCY;
1490 request->pad = 0;
1491 request->srvid = 0;
1492 request->client_id = 0;
1493 request->flags = 0;
1495 request->rdata.opcode = CTDB_CONTROL_RECD_RECLOCK_LATENCY;
1496 request->rdata.data.reclock_latency = reclock_latency;
1499 int ctdb_reply_control_recd_reclock_latency(struct ctdb_reply_control *reply)
1501 return ctdb_reply_control_generic(reply,
1502 CTDB_CONTROL_RECD_RECLOCK_LATENCY);
1505 /* CTDB_CONTROL_GET_RECLOCK_FILE */
1507 void ctdb_req_control_get_reclock_file(struct ctdb_req_control *request)
1509 request->opcode = CTDB_CONTROL_GET_RECLOCK_FILE;
1510 request->pad = 0;
1511 request->srvid = 0;
1512 request->client_id = 0;
1513 request->flags = 0;
1515 request->rdata.opcode = CTDB_CONTROL_GET_RECLOCK_FILE;
1518 int ctdb_reply_control_get_reclock_file(struct ctdb_reply_control *reply,
1519 TALLOC_CTX *mem_ctx,
1520 const char **reclock_file)
1522 if (reply->rdata.opcode != CTDB_CONTROL_GET_RECLOCK_FILE) {
1523 return EPROTO;
1526 if (reply->status == 0) {
1527 *reclock_file = talloc_steal(mem_ctx,
1528 reply->rdata.data.reclock_file);
1530 return reply->status;
1533 /* CTDB_CONTROL_STOP_NODE */
1535 void ctdb_req_control_stop_node(struct ctdb_req_control *request)
1537 request->opcode = CTDB_CONTROL_STOP_NODE;
1538 request->pad = 0;
1539 request->srvid = 0;
1540 request->client_id = 0;
1541 request->flags = 0;
1543 request->rdata.opcode = CTDB_CONTROL_STOP_NODE;
1546 int ctdb_reply_control_stop_node(struct ctdb_reply_control *reply)
1548 return ctdb_reply_control_generic(reply, CTDB_CONTROL_STOP_NODE);
1551 /* CTDB_CONTROL_CONTINUE_NODE */
1553 void ctdb_req_control_continue_node(struct ctdb_req_control *request)
1555 request->opcode = CTDB_CONTROL_CONTINUE_NODE;
1556 request->pad = 0;
1557 request->srvid = 0;
1558 request->client_id = 0;
1559 request->flags = 0;
1561 request->rdata.opcode = CTDB_CONTROL_CONTINUE_NODE;
1564 int ctdb_reply_control_continue_node(struct ctdb_reply_control *reply)
1566 return ctdb_reply_control_generic(reply, CTDB_CONTROL_CONTINUE_NODE);
1569 /* CTDB_CONTROL_SET_LMASTERROLE */
1571 void ctdb_req_control_set_lmasterrole(struct ctdb_req_control *request,
1572 uint32_t lmaster_role)
1574 request->opcode = CTDB_CONTROL_SET_LMASTERROLE;
1575 request->pad = 0;
1576 request->srvid = 0;
1577 request->client_id = 0;
1578 request->flags = 0;
1580 request->rdata.opcode = CTDB_CONTROL_SET_LMASTERROLE;
1581 request->rdata.data.role = lmaster_role;
1584 int ctdb_reply_control_set_lmasterrole(struct ctdb_reply_control *reply)
1586 return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_LMASTERROLE);
1589 /* CTDB_CONTROL_SET_RECMASTERROLE */
1591 void ctdb_req_control_set_recmasterrole(struct ctdb_req_control *request,
1592 uint32_t recmaster_role)
1594 request->opcode = CTDB_CONTROL_SET_RECMASTERROLE;
1595 request->pad = 0;
1596 request->srvid = 0;
1597 request->client_id = 0;
1598 request->flags = 0;
1600 request->rdata.opcode = CTDB_CONTROL_SET_RECMASTERROLE;
1601 request->rdata.data.role = recmaster_role;
1604 int ctdb_reply_control_set_recmasterrole(struct ctdb_reply_control *reply)
1606 return ctdb_reply_control_generic(reply,
1607 CTDB_CONTROL_SET_RECMASTERROLE);
1610 /* CTDB_CONTROL_ENABLE_SCRIPT */
1612 void ctdb_req_control_enable_script(struct ctdb_req_control *request,
1613 const char *script)
1615 request->opcode = CTDB_CONTROL_ENABLE_SCRIPT;
1616 request->pad = 0;
1617 request->srvid = 0;
1618 request->client_id = 0;
1619 request->flags = 0;
1621 request->rdata.opcode = CTDB_CONTROL_ENABLE_SCRIPT;
1622 request->rdata.data.script = script;
1625 int ctdb_reply_control_enable_script(struct ctdb_reply_control *reply)
1627 return ctdb_reply_control_generic(reply, CTDB_CONTROL_ENABLE_SCRIPT);
1630 /* CTDB_CONTROL_DISABLE_SCRIPT */
1632 void ctdb_req_control_disable_script(struct ctdb_req_control *request,
1633 const char *script)
1635 request->opcode = CTDB_CONTROL_DISABLE_SCRIPT;
1636 request->pad = 0;
1637 request->srvid = 0;
1638 request->client_id = 0;
1639 request->flags = 0;
1641 request->rdata.opcode = CTDB_CONTROL_DISABLE_SCRIPT;
1642 request->rdata.data.script = script;
1645 int ctdb_reply_control_disable_script(struct ctdb_reply_control *reply)
1647 return ctdb_reply_control_generic(reply, CTDB_CONTROL_DISABLE_SCRIPT);
1650 /* CTDB_CONTROL_SET_BAN_STATE */
1652 void ctdb_req_control_set_ban_state(struct ctdb_req_control *request,
1653 struct ctdb_ban_state *ban_state)
1655 request->opcode = CTDB_CONTROL_SET_BAN_STATE;
1656 request->pad = 0;
1657 request->srvid = 0;
1658 request->client_id = 0;
1659 request->flags = 0;
1661 request->rdata.opcode = CTDB_CONTROL_SET_BAN_STATE;
1662 request->rdata.data.ban_state = ban_state;
1665 int ctdb_reply_control_set_ban_state(struct ctdb_reply_control *reply)
1667 return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_BAN_STATE);
1670 /* CTDB_CONTROL_GET_BAN_STATE */
1672 void ctdb_req_control_get_ban_state(struct ctdb_req_control *request)
1674 request->opcode = CTDB_CONTROL_GET_BAN_STATE;
1675 request->pad = 0;
1676 request->srvid = 0;
1677 request->client_id = 0;
1678 request->flags = 0;
1680 request->rdata.opcode = CTDB_CONTROL_GET_BAN_STATE;
1683 int ctdb_reply_control_get_ban_state(struct ctdb_reply_control *reply,
1684 TALLOC_CTX *mem_ctx,
1685 struct ctdb_ban_state **ban_state)
1687 if (reply->rdata.opcode != CTDB_CONTROL_GET_BAN_STATE) {
1688 return EPROTO;
1691 if (reply->status == 0) {
1692 *ban_state = talloc_steal(mem_ctx,
1693 reply->rdata.data.ban_state);
1695 return reply->status;
1698 /* CTDB_CONTROL_REGISTER_NOTIFY */
1700 void ctdb_req_control_register_notify(struct ctdb_req_control *request,
1701 struct ctdb_notify_data *notify)
1703 request->opcode = CTDB_CONTROL_REGISTER_NOTIFY;
1704 request->pad = 0;
1705 request->srvid = 0;
1706 request->client_id = 0;
1707 request->flags = 0;
1709 request->rdata.opcode = CTDB_CONTROL_REGISTER_NOTIFY;
1710 request->rdata.data.notify = notify;
1713 int ctdb_reply_control_register_notify(struct ctdb_reply_control *reply)
1715 return ctdb_reply_control_generic(reply, CTDB_CONTROL_REGISTER_NOTIFY);
1718 /* CTDB_CONTROL_DEREGISTER_NOTIFY */
1720 void ctdb_req_control_deregister_notify(struct ctdb_req_control *request,
1721 uint64_t srvid)
1723 request->opcode = CTDB_CONTROL_DEREGISTER_NOTIFY;
1724 request->pad = 0;
1725 request->srvid = 0;
1726 request->client_id = 0;
1727 request->flags = 0;
1729 request->rdata.opcode = CTDB_CONTROL_DEREGISTER_NOTIFY;
1730 request->rdata.data.srvid = srvid;
1733 int ctdb_reply_control_deregister_notify(struct ctdb_reply_control *reply)
1735 return ctdb_reply_control_generic(reply,
1736 CTDB_CONTROL_DEREGISTER_NOTIFY);
1739 /* CTDB_CONTROL_TRANS3_COMMIT */
1741 void ctdb_req_control_trans3_commit(struct ctdb_req_control *request,
1742 struct ctdb_rec_buffer *recbuf)
1744 request->opcode = CTDB_CONTROL_TRANS3_COMMIT;
1745 request->pad = 0;
1746 request->srvid = 0;
1747 request->client_id = 0;
1748 request->flags = 0;
1750 request->rdata.opcode = CTDB_CONTROL_TRANS3_COMMIT;
1751 request->rdata.data.recbuf = recbuf;
1754 int ctdb_reply_control_trans3_commit(struct ctdb_reply_control *reply)
1756 return ctdb_reply_control_generic(reply, CTDB_CONTROL_TRANS3_COMMIT);
1759 /* CTDB_CONTROL_GET_DB_SEQNUM */
1761 void ctdb_req_control_get_db_seqnum(struct ctdb_req_control *request,
1762 uint32_t db_id)
1764 request->opcode = CTDB_CONTROL_GET_DB_SEQNUM;
1765 request->pad = 0;
1766 request->srvid = 0;
1767 request->client_id = 0;
1768 request->flags = 0;
1770 request->rdata.opcode = CTDB_CONTROL_GET_DB_SEQNUM;
1771 request->rdata.data.db_id = db_id;
1774 int ctdb_reply_control_get_db_seqnum(struct ctdb_reply_control *reply,
1775 uint64_t *seqnum)
1777 if (reply->rdata.opcode != CTDB_CONTROL_GET_DB_SEQNUM) {
1778 return EPROTO;
1781 if (reply->status == 0) {
1782 *seqnum = reply->rdata.data.seqnum;
1784 return reply->status;
1787 /* CTDB_CONTROL_DB_SET_HEALTHY */
1789 void ctdb_req_control_db_set_healthy(struct ctdb_req_control *request,
1790 uint32_t db_id)
1792 request->opcode = CTDB_CONTROL_DB_SET_HEALTHY;
1793 request->pad = 0;
1794 request->srvid = 0;
1795 request->client_id = 0;
1796 request->flags = 0;
1798 request->rdata.opcode = CTDB_CONTROL_DB_SET_HEALTHY;
1799 request->rdata.data.db_id = db_id;
1802 int ctdb_reply_control_db_set_healthy(struct ctdb_reply_control *reply)
1804 return ctdb_reply_control_generic(reply, CTDB_CONTROL_DB_SET_HEALTHY);
1807 /* CTDB_CONTROL_DB_GET_HEALTH */
1809 void ctdb_req_control_db_get_health(struct ctdb_req_control *request,
1810 uint32_t db_id)
1812 request->opcode = CTDB_CONTROL_DB_GET_HEALTH;
1813 request->pad = 0;
1814 request->srvid = 0;
1815 request->client_id = 0;
1816 request->flags = 0;
1818 request->rdata.opcode = CTDB_CONTROL_DB_GET_HEALTH;
1819 request->rdata.data.db_id = db_id;
1822 int ctdb_reply_control_db_get_health(struct ctdb_reply_control *reply,
1823 TALLOC_CTX *mem_ctx, const char **reason)
1825 if (reply->rdata.opcode != CTDB_CONTROL_DB_GET_HEALTH) {
1826 return EPROTO;
1829 if (reply->status == 0) {
1830 *reason = talloc_steal(mem_ctx, reply->rdata.data.reason);
1832 return reply->status;
1835 /* CTDB_CONTROL_GET_PUBLIC_IP_INFO */
1837 void ctdb_req_control_get_public_ip_info(struct ctdb_req_control *request,
1838 ctdb_sock_addr *addr)
1840 request->opcode = CTDB_CONTROL_GET_PUBLIC_IP_INFO;
1841 request->pad = 0;
1842 request->srvid = 0;
1843 request->client_id = 0;
1844 request->flags = 0;
1846 request->rdata.opcode = CTDB_CONTROL_GET_PUBLIC_IP_INFO;
1847 request->rdata.data.addr = addr;
1850 int ctdb_reply_control_get_public_ip_info(struct ctdb_reply_control *reply,
1851 TALLOC_CTX *mem_ctx,
1852 struct ctdb_public_ip_info **ipinfo)
1854 if (reply->rdata.opcode != CTDB_CONTROL_GET_PUBLIC_IP_INFO) {
1855 return EPROTO;
1858 if (reply->status == 0) {
1859 *ipinfo = talloc_steal(mem_ctx, reply->rdata.data.ipinfo);
1861 return reply->status;
1864 /* CTDB_CONTROL_GET_IFACES */
1866 void ctdb_req_control_get_ifaces(struct ctdb_req_control *request)
1868 request->opcode = CTDB_CONTROL_GET_IFACES;
1869 request->pad = 0;
1870 request->srvid = 0;
1871 request->client_id = 0;
1872 request->flags = 0;
1874 request->rdata.opcode = CTDB_CONTROL_GET_IFACES;
1877 int ctdb_reply_control_get_ifaces(struct ctdb_reply_control *reply,
1878 TALLOC_CTX *mem_ctx,
1879 struct ctdb_iface_list **iface_list)
1881 if (reply->rdata.opcode != CTDB_CONTROL_GET_IFACES) {
1882 return EPROTO;
1885 if (reply->status == 0) {
1886 *iface_list = talloc_steal(mem_ctx,
1887 reply->rdata.data.iface_list);
1889 return reply->status;
1892 /* CTDB_CONTROL_SET_IFACE_LINK_STATE */
1894 void ctdb_req_control_set_iface_link_state(struct ctdb_req_control *request,
1895 struct ctdb_iface *iface)
1897 request->opcode = CTDB_CONTROL_SET_IFACE_LINK_STATE;
1898 request->pad = 0;
1899 request->srvid = 0;
1900 request->client_id = 0;
1901 request->flags = 0;
1903 request->rdata.opcode = CTDB_CONTROL_SET_IFACE_LINK_STATE;
1904 request->rdata.data.iface = iface;
1907 int ctdb_reply_control_set_iface_link_state(struct ctdb_reply_control *reply)
1909 return ctdb_reply_control_generic(reply,
1910 CTDB_CONTROL_SET_IFACE_LINK_STATE);
1913 /* CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE */
1915 void ctdb_req_control_tcp_add_delayed_update(struct ctdb_req_control *request,
1916 struct ctdb_connection *conn)
1918 request->opcode = CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE;
1919 request->pad = 0;
1920 request->srvid = 0;
1921 request->client_id = 0;
1922 request->flags = 0;
1924 request->rdata.opcode = CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE;
1925 request->rdata.data.conn = conn;
1928 int ctdb_reply_control_tcp_add_delayed_update(struct ctdb_reply_control *reply)
1930 return ctdb_reply_control_generic(reply,
1931 CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE);
1934 /* CTDB_CONTROL_GET_STAT_HISTORY */
1936 void ctdb_req_control_get_stat_history(struct ctdb_req_control *request)
1938 request->opcode = CTDB_CONTROL_GET_STAT_HISTORY;
1939 request->pad = 0;
1940 request->srvid = 0;
1941 request->client_id = 0;
1942 request->flags = 0;
1944 request->rdata.opcode = CTDB_CONTROL_GET_STAT_HISTORY;
1947 int ctdb_reply_control_get_stat_history(struct ctdb_reply_control *reply,
1948 TALLOC_CTX *mem_ctx,
1949 struct ctdb_statistics_list **stats_list)
1951 if (reply->rdata.opcode != CTDB_CONTROL_GET_STAT_HISTORY) {
1952 return EPROTO;
1955 if (reply->status == 0) {
1956 *stats_list = talloc_steal(mem_ctx,
1957 reply->rdata.data.stats_list);
1959 return reply->status;
1962 /* CTDB_CONTROL_SCHEDULE_FOR_DELETION */
1964 void ctdb_req_control_schedule_for_deletion(struct ctdb_req_control *request,
1965 struct ctdb_key_data *key)
1967 request->opcode = CTDB_CONTROL_SCHEDULE_FOR_DELETION;
1968 request->pad = 0;
1969 request->srvid = 0;
1970 request->client_id = 0;
1971 request->flags = 0;
1973 request->rdata.opcode = CTDB_CONTROL_SCHEDULE_FOR_DELETION;
1974 request->rdata.data.key = key;
1977 int ctdb_reply_control_schedule_for_deletion(struct ctdb_reply_control *reply)
1979 return ctdb_reply_control_generic(reply,
1980 CTDB_CONTROL_SCHEDULE_FOR_DELETION);
1983 /* CTDB_CONTROL_SET_DB_READONLY */
1985 void ctdb_req_control_set_db_readonly(struct ctdb_req_control *request,
1986 uint32_t db_id)
1988 request->opcode = CTDB_CONTROL_SET_DB_READONLY;
1989 request->pad = 0;
1990 request->srvid = 0;
1991 request->client_id = 0;
1992 request->flags = 0;
1994 request->rdata.opcode = CTDB_CONTROL_SET_DB_READONLY;
1995 request->rdata.data.db_id = db_id;
1998 int ctdb_reply_control_set_db_readonly(struct ctdb_reply_control *reply)
2000 return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_DB_READONLY);
2003 /* CTDB_CONTROL_CHECK_SRVIDS */
2005 void ctdb_req_control_check_srvids(struct ctdb_req_control *request,
2006 struct ctdb_uint64_array *u64_array)
2008 request->opcode = CTDB_CONTROL_CHECK_SRVIDS;
2009 request->pad = 0;
2010 request->srvid = 0;
2011 request->client_id = 0;
2012 request->flags = 0;
2014 request->rdata.opcode = CTDB_CONTROL_CHECK_SRVIDS;
2015 request->rdata.data.u64_array = u64_array;
2018 int ctdb_reply_control_check_srvids(struct ctdb_reply_control *reply,
2019 TALLOC_CTX *mem_ctx,
2020 struct ctdb_uint8_array **u8_array)
2022 if (reply->rdata.opcode != CTDB_CONTROL_CHECK_SRVIDS) {
2023 return EPROTO;
2026 if (reply->status == 0) {
2027 *u8_array = talloc_steal(mem_ctx, reply->rdata.data.u8_array);
2029 return reply->status;
2032 /* CTDB_CONTROL_TRAVERSE_START_EXT */
2034 void ctdb_req_control_traverse_start_ext(struct ctdb_req_control *request,
2035 struct ctdb_traverse_start_ext *traverse)
2037 request->opcode = CTDB_CONTROL_TRAVERSE_START_EXT;
2038 request->pad = 0;
2039 request->srvid = 0;
2040 request->client_id = 0;
2041 request->flags = 0;
2043 request->rdata.opcode = CTDB_CONTROL_TRAVERSE_START_EXT;
2044 request->rdata.data.traverse_start_ext = traverse;
2047 int ctdb_reply_control_traverse_start_ext(struct ctdb_reply_control *reply)
2049 return ctdb_reply_control_generic(reply,
2050 CTDB_CONTROL_TRAVERSE_START_EXT);
2053 /* CTDB_CONTROL_GET_DB_STATISTICS */
2055 void ctdb_req_control_get_db_statistics(struct ctdb_req_control *request,
2056 uint32_t db_id)
2058 request->opcode = CTDB_CONTROL_GET_DB_STATISTICS;
2059 request->pad = 0;
2060 request->srvid = 0;
2061 request->client_id = 0;
2062 request->flags = 0;
2064 request->rdata.opcode = CTDB_CONTROL_GET_DB_STATISTICS;
2065 request->rdata.data.db_id = db_id;
2068 int ctdb_reply_control_get_db_statistics(struct ctdb_reply_control *reply,
2069 TALLOC_CTX *mem_ctx,
2070 struct ctdb_db_statistics **dbstats)
2072 if (reply->rdata.opcode != CTDB_CONTROL_GET_DB_STATISTICS) {
2073 return EPROTO;
2076 if (reply->status == 0) {
2077 *dbstats = talloc_steal(mem_ctx, reply->rdata.data.dbstats);
2079 return reply->status;
2082 /* CTDB_CONTROL_SET_DB_STICKY */
2084 void ctdb_req_control_set_db_sticky(struct ctdb_req_control *request,
2085 uint32_t db_id)
2087 request->opcode = CTDB_CONTROL_SET_DB_STICKY;
2088 request->pad = 0;
2089 request->srvid = 0;
2090 request->client_id = 0;
2091 request->flags = 0;
2093 request->rdata.opcode = CTDB_CONTROL_SET_DB_STICKY;
2094 request->rdata.data.db_id = db_id;
2097 int ctdb_reply_control_set_db_sticky(struct ctdb_reply_control *reply)
2099 return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_DB_STICKY);
2102 /* CTDB_CONTROL_RELOAD_PUBLIC_IPS */
2104 void ctdb_req_control_reload_public_ips(struct ctdb_req_control *request)
2106 request->opcode = CTDB_CONTROL_RELOAD_PUBLIC_IPS;
2107 request->pad = 0;
2108 request->srvid = 0;
2109 request->client_id = 0;
2110 request->flags = 0;
2112 request->rdata.opcode = CTDB_CONTROL_RELOAD_PUBLIC_IPS;
2115 int ctdb_reply_control_reload_public_ips(struct ctdb_reply_control *reply)
2117 return ctdb_reply_control_generic(reply,
2118 CTDB_CONTROL_RELOAD_PUBLIC_IPS);
2121 /* CTDB_CONTROL_TRAVERSE_ALL_EXT */
2123 /* CTDB_CONTROL_RECEIVE_RECORDS */
2125 void ctdb_req_control_receive_records(struct ctdb_req_control *request,
2126 struct ctdb_rec_buffer *recbuf)
2128 request->opcode = CTDB_CONTROL_RECEIVE_RECORDS;
2129 request->pad = 0;
2130 request->srvid = 0;
2131 request->client_id = 0;
2132 request->flags = 0;
2134 request->rdata.opcode = CTDB_CONTROL_RECEIVE_RECORDS;
2135 request->rdata.data.recbuf = recbuf;
2138 int ctdb_reply_control_receive_records(struct ctdb_reply_control *reply,
2139 TALLOC_CTX *mem_ctx,
2140 struct ctdb_rec_buffer **recbuf)
2142 if (reply->rdata.opcode != CTDB_CONTROL_RECEIVE_RECORDS) {
2143 return EPROTO;
2146 if (reply->status == 0) {
2147 *recbuf = talloc_steal(mem_ctx, reply->rdata.data.recbuf);
2149 return reply->status;
2152 /* CTDB_CONTROL_IPREALLOCATED */
2154 void ctdb_req_control_ipreallocated(struct ctdb_req_control *request)
2156 request->opcode = CTDB_CONTROL_IPREALLOCATED;
2157 request->pad = 0;
2158 request->srvid = 0;
2159 request->client_id = 0;
2160 request->flags = 0;
2162 request->rdata.opcode = CTDB_CONTROL_IPREALLOCATED;
2165 int ctdb_reply_control_ipreallocated(struct ctdb_reply_control *reply)
2167 return ctdb_reply_control_generic(reply, CTDB_CONTROL_IPREALLOCATED);
2170 /* CTDB_CONTROL_GET_RUNSTATE */
2172 void ctdb_req_control_get_runstate(struct ctdb_req_control *request)
2174 request->opcode = CTDB_CONTROL_GET_RUNSTATE;
2175 request->pad = 0;
2176 request->srvid = 0;
2177 request->client_id = 0;
2178 request->flags = 0;
2180 request->rdata.opcode = CTDB_CONTROL_GET_RUNSTATE;
2183 int ctdb_reply_control_get_runstate(struct ctdb_reply_control *reply,
2184 enum ctdb_runstate *runstate)
2186 if (reply->rdata.opcode != CTDB_CONTROL_GET_RUNSTATE) {
2187 return EPROTO;
2190 if (reply->status == 0) {
2191 *runstate = reply->rdata.data.runstate;
2193 return reply->status;
2196 /* CTDB_CONTROL_DB_DETACH */
2198 void ctdb_req_control_db_detach(struct ctdb_req_control *request,
2199 uint32_t db_id)
2201 request->opcode = CTDB_CONTROL_DB_DETACH;
2202 request->pad = 0;
2203 request->srvid = 0;
2204 request->client_id = 0;
2205 request->flags = 0;
2207 request->rdata.opcode = CTDB_CONTROL_DB_DETACH;
2208 request->rdata.data.db_id = db_id;
2211 int ctdb_reply_control_db_detach(struct ctdb_reply_control *reply)
2213 return ctdb_reply_control_generic(reply, CTDB_CONTROL_DB_DETACH);
2216 /* CTDB_CONTROL_GET_NODES_FILE */
2218 void ctdb_req_control_get_nodes_file(struct ctdb_req_control *request)
2220 request->opcode = CTDB_CONTROL_GET_NODES_FILE;
2221 request->pad = 0;
2222 request->srvid = 0;
2223 request->client_id = 0;
2224 request->flags = 0;
2226 request->rdata.opcode = CTDB_CONTROL_GET_NODES_FILE;
2229 int ctdb_reply_control_get_nodes_file(struct ctdb_reply_control *reply,
2230 TALLOC_CTX *mem_ctx,
2231 struct ctdb_node_map **nodemap)
2233 if (reply->rdata.opcode != CTDB_CONTROL_GET_NODES_FILE) {
2234 return EPROTO;
2237 if (reply->status == 0) {
2238 *nodemap = talloc_steal(mem_ctx, reply->rdata.data.nodemap);
2240 return reply->status;
2243 /* CTDB_CONTROL_DB_FREEZE */
2245 void ctdb_req_control_db_freeze(struct ctdb_req_control *request,
2246 uint32_t db_id)
2248 request->opcode = CTDB_CONTROL_DB_FREEZE;
2249 request->pad = 0;
2250 request->srvid = 0;
2251 request->client_id = 0;
2252 request->flags = 0;
2254 request->rdata.opcode = CTDB_CONTROL_DB_FREEZE;
2255 request->rdata.data.db_id = db_id;
2258 int ctdb_reply_control_db_freeze(struct ctdb_reply_control *reply)
2260 return ctdb_reply_control_generic(reply, CTDB_CONTROL_DB_FREEZE);
2263 /* CTDB_CONTROL_DB_THAW */
2265 void ctdb_req_control_db_thaw(struct ctdb_req_control *request,
2266 uint32_t db_id)
2268 request->opcode = CTDB_CONTROL_DB_THAW;
2269 request->pad = 0;
2270 request->srvid = 0;
2271 request->client_id = 0;
2272 request->flags = 0;
2274 request->rdata.opcode = CTDB_CONTROL_DB_THAW;
2275 request->rdata.data.db_id = db_id;
2278 int ctdb_reply_control_db_thaw(struct ctdb_reply_control *reply)
2280 return ctdb_reply_control_generic(reply, CTDB_CONTROL_DB_THAW);
2283 /* CTDB_CONTROL_DB_TRANSACTION_START */
2285 void ctdb_req_control_db_transaction_start(struct ctdb_req_control *request,
2286 struct ctdb_transdb *transdb)
2288 request->opcode = CTDB_CONTROL_DB_TRANSACTION_START;
2289 request->pad = 0;
2290 request->srvid = 0;
2291 request->client_id = 0;
2292 request->flags = 0;
2294 request->rdata.opcode = CTDB_CONTROL_DB_TRANSACTION_START;
2295 request->rdata.data.transdb = transdb;
2298 int ctdb_reply_control_db_transaction_start(struct ctdb_reply_control *reply)
2300 return ctdb_reply_control_generic(reply,
2301 CTDB_CONTROL_DB_TRANSACTION_START);
2304 /* CTDB_CONTROL_DB_TRANSACTION_COMMIT */
2306 void ctdb_req_control_db_transaction_commit(struct ctdb_req_control *request,
2307 struct ctdb_transdb *transdb)
2309 request->opcode = CTDB_CONTROL_DB_TRANSACTION_COMMIT;
2310 request->pad = 0;
2311 request->srvid = 0;
2312 request->client_id = 0;
2313 request->flags = 0;
2315 request->rdata.opcode = CTDB_CONTROL_DB_TRANSACTION_COMMIT;
2316 request->rdata.data.transdb = transdb;
2319 int ctdb_reply_control_db_transaction_commit(struct ctdb_reply_control *reply)
2321 return ctdb_reply_control_generic(reply,
2322 CTDB_CONTROL_DB_TRANSACTION_COMMIT);
2325 /* CTDB_CONTROL_DB_TRANSACTION_CANCEL */
2327 void ctdb_req_control_db_transaction_cancel(struct ctdb_req_control *request,
2328 uint32_t db_id)
2330 request->opcode = CTDB_CONTROL_DB_TRANSACTION_CANCEL;
2331 request->pad = 0;
2332 request->srvid = 0;
2333 request->client_id = 0;
2334 request->flags = 0;
2336 request->rdata.opcode = CTDB_CONTROL_DB_TRANSACTION_CANCEL;
2337 request->rdata.data.db_id = db_id;
2340 int ctdb_reply_control_db_transaction_cancel(struct ctdb_reply_control *reply)
2342 return ctdb_reply_control_generic(reply,
2343 CTDB_CONTROL_DB_TRANSACTION_CANCEL);
2346 /* CTDB_CONTROL_DB_PULL */
2348 void ctdb_req_control_db_pull(struct ctdb_req_control *request,
2349 struct ctdb_pulldb_ext *pulldb_ext)
2351 request->opcode = CTDB_CONTROL_DB_PULL;
2352 request->pad = 0;
2353 request->srvid = 0;
2354 request->client_id = 0;
2355 request->flags = 0;
2357 request->rdata.opcode = CTDB_CONTROL_DB_PULL;
2358 request->rdata.data.pulldb_ext = pulldb_ext;
2361 int ctdb_reply_control_db_pull(struct ctdb_reply_control *reply,
2362 uint32_t *num_records)
2364 if (reply->rdata.opcode != CTDB_CONTROL_DB_PULL) {
2365 return EPROTO;
2368 if (reply->status == 0) {
2369 *num_records = reply->rdata.data.num_records;
2371 return reply->status;
2374 /* CTDB_CONTROL_DB_PUSH_START */
2376 void ctdb_req_control_db_push_start(struct ctdb_req_control *request,
2377 struct ctdb_pulldb_ext *pulldb_ext)
2379 request->opcode = CTDB_CONTROL_DB_PUSH_START;
2380 request->pad = 0;
2381 request->srvid = 0;
2382 request->client_id = 0;
2383 request->flags = 0;
2385 request->rdata.opcode = CTDB_CONTROL_DB_PUSH_START;
2386 request->rdata.data.pulldb_ext = pulldb_ext;
2389 int ctdb_reply_control_db_push_start(struct ctdb_reply_control *reply)
2391 return ctdb_reply_control_generic(reply, CTDB_CONTROL_DB_PUSH_START);
2394 /* CTDB_CONTROL_DB_PUSH_CONFIRM */
2396 void ctdb_req_control_db_push_confirm(struct ctdb_req_control *request,
2397 uint32_t db_id)
2399 request->opcode = CTDB_CONTROL_DB_PUSH_CONFIRM;
2400 request->pad = 0;
2401 request->srvid = 0;
2402 request->client_id = 0;
2403 request->flags = 0;
2405 request->rdata.opcode = CTDB_CONTROL_DB_PUSH_CONFIRM;
2406 request->rdata.data.db_id = db_id;
2409 int ctdb_reply_control_db_push_confirm(struct ctdb_reply_control *reply,
2410 uint32_t *num_records)
2412 if (reply->rdata.opcode != CTDB_CONTROL_DB_PUSH_CONFIRM) {
2413 return EPROTO;
2416 if (reply->status == 0) {
2417 *num_records = reply->rdata.data.num_records;
2419 return reply->status;