VERSION: Bump version up to 4.10.12.
[Samba.git] / ctdb / protocol / protocol_client.c
blob9aa32a9bba7c409f421dfc9c39b0bf89cba4954a
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)
404 request->opcode = CTDB_CONTROL_DB_ATTACH;
405 request->pad = 0;
406 request->srvid = 0;
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 /* CTDB_CONTROL_TCP_CLIENT */
725 void ctdb_req_control_tcp_client(struct ctdb_req_control *request,
726 struct ctdb_connection *conn)
728 request->opcode = CTDB_CONTROL_TCP_CLIENT;
729 request->pad = 0;
730 request->srvid = 0;
731 request->client_id = 0;
732 request->flags = 0;
734 request->rdata.opcode = CTDB_CONTROL_TCP_CLIENT;
735 request->rdata.data.conn = conn;
738 int ctdb_reply_control_tcp_client(struct ctdb_reply_control *reply)
740 return ctdb_reply_control_generic(reply, CTDB_CONTROL_TCP_CLIENT);
743 /* CTDB_CONTROL_TCP_ADD */
745 void ctdb_req_control_tcp_add(struct ctdb_req_control *request,
746 struct ctdb_connection *conn)
748 request->opcode = CTDB_CONTROL_TCP_ADD;
749 request->pad = 0;
750 request->srvid = 0;
751 request->client_id = 0;
752 request->flags = 0;
754 request->rdata.opcode = CTDB_CONTROL_TCP_ADD;
755 request->rdata.data.conn = conn;
758 int ctdb_reply_control_tcp_add(struct ctdb_reply_control *reply)
760 return ctdb_reply_control_generic(reply, CTDB_CONTROL_TCP_ADD);
763 /* CTDB_CONTROL_TCP_REMOVE */
765 void ctdb_req_control_tcp_remove(struct ctdb_req_control *request,
766 struct ctdb_connection *conn)
768 request->opcode = CTDB_CONTROL_TCP_REMOVE;
769 request->pad = 0;
770 request->srvid = 0;
771 request->client_id = 0;
772 request->flags = 0;
774 request->rdata.opcode = CTDB_CONTROL_TCP_REMOVE;
775 request->rdata.data.conn = conn;
778 int ctdb_reply_control_tcp_remove(struct ctdb_reply_control *reply)
780 return ctdb_reply_control_generic(reply, CTDB_CONTROL_TCP_REMOVE);
783 /* CTDB_CONTROL_STARTUP */
785 void ctdb_req_control_startup(struct ctdb_req_control *request)
787 request->opcode = CTDB_CONTROL_STARTUP;
788 request->pad = 0;
789 request->srvid = 0;
790 request->client_id = 0;
791 request->flags = 0;
793 request->rdata.opcode = CTDB_CONTROL_STARTUP;
796 int ctdb_reply_control_startup(struct ctdb_reply_control *reply)
798 return ctdb_reply_control_generic(reply, CTDB_CONTROL_STARTUP);
801 /* CTDB_CONTROL_SET_TUNABLE */
803 void ctdb_req_control_set_tunable(struct ctdb_req_control *request,
804 struct ctdb_tunable *tunable)
806 request->opcode = CTDB_CONTROL_SET_TUNABLE;
807 request->pad = 0;
808 request->srvid = 0;
809 request->client_id = 0;
810 request->flags = 0;
812 request->rdata.opcode = CTDB_CONTROL_SET_TUNABLE;
813 request->rdata.data.tunable = tunable;
816 int ctdb_reply_control_set_tunable(struct ctdb_reply_control *reply)
818 return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_TUNABLE);
821 /* CTDB_CONTROL_GET_TUNABLE */
823 void ctdb_req_control_get_tunable(struct ctdb_req_control *request,
824 const char *name)
826 request->opcode = CTDB_CONTROL_GET_TUNABLE;
827 request->pad = 0;
828 request->srvid = 0;
829 request->client_id = 0;
830 request->flags = 0;
832 request->rdata.opcode = CTDB_CONTROL_GET_TUNABLE;
833 request->rdata.data.tun_var = discard_const(name);
836 int ctdb_reply_control_get_tunable(struct ctdb_reply_control *reply,
837 uint32_t *value)
839 if (reply->rdata.opcode != CTDB_CONTROL_GET_TUNABLE) {
840 return EPROTO;
843 if (reply->status == 0) {
844 *value = reply->rdata.data.tun_value;
846 return reply->status;
849 /* CTDB_CONTROL_LIST_TUNABLES */
851 void ctdb_req_control_list_tunables(struct ctdb_req_control *request)
853 request->opcode = CTDB_CONTROL_LIST_TUNABLES;
854 request->pad = 0;
855 request->srvid = 0;
856 request->client_id = 0;
857 request->flags = 0;
859 request->rdata.opcode = CTDB_CONTROL_LIST_TUNABLES;
862 int ctdb_reply_control_list_tunables(struct ctdb_reply_control *reply,
863 TALLOC_CTX *mem_ctx,
864 struct ctdb_var_list **tun_var_list)
866 if (reply->rdata.opcode != CTDB_CONTROL_LIST_TUNABLES) {
867 return EPROTO;
870 if (reply->status == 0) {
871 *tun_var_list = talloc_steal(mem_ctx,
872 reply->rdata.data.tun_var_list);
874 return reply->status;
877 /* CTDB_CONTROL_MODIFY_FLAGS */
879 void ctdb_req_control_modify_flags(struct ctdb_req_control *request,
880 struct ctdb_node_flag_change *flag_change)
882 request->opcode = CTDB_CONTROL_MODIFY_FLAGS;
883 request->pad = 0;
884 request->srvid = 0;
885 request->client_id = 0;
886 request->flags = 0;
888 request->rdata.opcode = CTDB_CONTROL_MODIFY_FLAGS;
889 request->rdata.data.flag_change = flag_change;
892 int ctdb_reply_control_modify_flags(struct ctdb_reply_control *reply)
894 return ctdb_reply_control_generic(reply, CTDB_CONTROL_MODIFY_FLAGS);
897 /* CTDB_CONTROL_GET_ALL_TUNABLES */
899 void ctdb_req_control_get_all_tunables(struct ctdb_req_control *request)
901 request->opcode = CTDB_CONTROL_GET_ALL_TUNABLES;
902 request->pad = 0;
903 request->srvid = 0;
904 request->client_id = 0;
905 request->flags = 0;
907 request->rdata.opcode = CTDB_CONTROL_GET_ALL_TUNABLES;
910 int ctdb_reply_control_get_all_tunables(struct ctdb_reply_control *reply,
911 TALLOC_CTX *mem_ctx,
912 struct ctdb_tunable_list **tun_list)
914 if (reply->rdata.opcode != CTDB_CONTROL_GET_ALL_TUNABLES) {
915 return EPROTO;
918 if (reply->status == 0) {
919 *tun_list = talloc_steal(mem_ctx, reply->rdata.data.tun_list);
921 return reply->status;
924 /* CTDB_CONTROL_GET_TCP_TICKLE_LIST */
926 void ctdb_req_control_get_tcp_tickle_list(struct ctdb_req_control *request,
927 ctdb_sock_addr *addr)
929 request->opcode = CTDB_CONTROL_GET_TCP_TICKLE_LIST;
930 request->pad = 0;
931 request->srvid = 0;
932 request->client_id = 0;
933 request->flags = 0;
935 request->rdata.opcode = CTDB_CONTROL_GET_TCP_TICKLE_LIST;
936 request->rdata.data.addr = addr;
939 int ctdb_reply_control_get_tcp_tickle_list(struct ctdb_reply_control *reply,
940 TALLOC_CTX *mem_ctx,
941 struct ctdb_tickle_list **tickles)
943 if (reply->rdata.opcode != CTDB_CONTROL_GET_TCP_TICKLE_LIST) {
944 return EPROTO;
947 if (reply->status == 0) {
948 *tickles = talloc_steal(mem_ctx, reply->rdata.data.tickles);
950 return reply->status;
953 /* CTDB_CONTROL_SET_TCP_TICKLE_LIST */
955 void ctdb_req_control_set_tcp_tickle_list(struct ctdb_req_control *request,
956 struct ctdb_tickle_list *tickles)
958 request->opcode = CTDB_CONTROL_SET_TCP_TICKLE_LIST;
959 request->pad = 0;
960 request->srvid = 0;
961 request->client_id = 0;
962 request->flags = 0;
964 request->rdata.opcode = CTDB_CONTROL_SET_TCP_TICKLE_LIST;
965 request->rdata.data.tickles = tickles;
968 int ctdb_reply_control_set_tcp_tickle_list(struct ctdb_reply_control *reply)
970 return ctdb_reply_control_generic(reply,
971 CTDB_CONTROL_SET_TCP_TICKLE_LIST);
974 /* CTDB_CONTROL_DB_ATTACH_PERSISTENT */
976 void ctdb_req_control_db_attach_persistent(struct ctdb_req_control *request,
977 const char *db_name)
979 request->opcode = CTDB_CONTROL_DB_ATTACH_PERSISTENT;
980 request->pad = 0;
981 request->srvid = 0;
982 request->client_id = 0;
983 request->flags = 0;
985 request->rdata.opcode = CTDB_CONTROL_DB_ATTACH_PERSISTENT;
986 request->rdata.data.db_name = db_name;
989 int ctdb_reply_control_db_attach_persistent(struct ctdb_reply_control *reply,
990 uint32_t *db_id)
992 if (reply->rdata.opcode != CTDB_CONTROL_DB_ATTACH_PERSISTENT) {
993 return EPROTO;
996 if (reply->status == 0) {
997 *db_id = reply->rdata.data.db_id;
999 return reply->status;
1002 /* CTDB_CONTROL_UPDATE_RECORD */
1004 void ctdb_req_control_update_record(struct ctdb_req_control *request,
1005 struct ctdb_rec_buffer *recbuf)
1007 request->opcode = CTDB_CONTROL_UPDATE_RECORD;
1008 request->pad = 0;
1009 request->srvid = 0;
1010 request->client_id = 0;
1011 request->flags = 0;
1013 request->rdata.opcode = CTDB_CONTROL_UPDATE_RECORD;
1014 request->rdata.data.recbuf = recbuf;
1017 int ctdb_reply_control_update_record(struct ctdb_reply_control *reply)
1019 return ctdb_reply_control_generic(reply, CTDB_CONTROL_UPDATE_RECORD);
1022 /* CTDB_CONTROL_SEND_GRATUITOUS_ARP */
1024 void ctdb_req_control_send_gratuitous_arp(struct ctdb_req_control *request,
1025 struct ctdb_addr_info *addr_info)
1027 request->opcode = CTDB_CONTROL_SEND_GRATUITOUS_ARP;
1028 request->pad = 0;
1029 request->srvid = 0;
1030 request->client_id = 0;
1031 request->flags = 0;
1033 request->rdata.opcode = CTDB_CONTROL_SEND_GRATUITOUS_ARP;
1034 request->rdata.data.addr_info = addr_info;
1037 int ctdb_reply_control_send_gratuitous_arp(struct ctdb_reply_control *reply)
1039 return ctdb_reply_control_generic(reply,
1040 CTDB_CONTROL_SEND_GRATUITOUS_ARP);
1043 /* CTDB_CONTROL_WIPE_DATABASE */
1045 void ctdb_req_control_wipe_database(struct ctdb_req_control *request,
1046 struct ctdb_transdb *transdb)
1048 request->opcode = CTDB_CONTROL_WIPE_DATABASE;
1049 request->pad = 0;
1050 request->srvid = 0;
1051 request->client_id = 0;
1052 request->flags = 0;
1054 request->rdata.opcode = CTDB_CONTROL_WIPE_DATABASE;
1055 request->rdata.data.transdb = transdb;
1058 int ctdb_reply_control_wipe_database(struct ctdb_reply_control *reply)
1060 return ctdb_reply_control_generic(reply, CTDB_CONTROL_WIPE_DATABASE);
1063 /* CTDB_CONTROL_UPTIME */
1065 void ctdb_req_control_uptime(struct ctdb_req_control *request)
1067 request->opcode = CTDB_CONTROL_UPTIME;
1068 request->pad = 0;
1069 request->srvid = 0;
1070 request->client_id = 0;
1071 request->flags = 0;
1073 request->rdata.opcode = CTDB_CONTROL_UPTIME;
1076 int ctdb_reply_control_uptime(struct ctdb_reply_control *reply,
1077 TALLOC_CTX *mem_ctx, struct ctdb_uptime **uptime)
1079 if (reply->rdata.opcode != CTDB_CONTROL_UPTIME) {
1080 return EPROTO;
1083 if (reply->status == 0) {
1084 *uptime = talloc_steal(mem_ctx, reply->rdata.data.uptime);
1086 return reply->status;
1089 /* CTDB_CONTROL_START_RECOVERY */
1091 void ctdb_req_control_start_recovery(struct ctdb_req_control *request)
1093 request->opcode = CTDB_CONTROL_START_RECOVERY;
1094 request->pad = 0;
1095 request->srvid = 0;
1096 request->client_id = 0;
1097 request->flags = 0;
1099 request->rdata.opcode = CTDB_CONTROL_START_RECOVERY;
1102 int ctdb_reply_control_start_recovery(struct ctdb_reply_control *reply)
1104 return ctdb_reply_control_generic(reply, CTDB_CONTROL_START_RECOVERY);
1107 /* CTDB_CONTROL_END_RECOVERY */
1109 void ctdb_req_control_end_recovery(struct ctdb_req_control *request)
1111 request->opcode = CTDB_CONTROL_END_RECOVERY;
1112 request->pad = 0;
1113 request->srvid = 0;
1114 request->client_id = 0;
1115 request->flags = 0;
1117 request->rdata.opcode = CTDB_CONTROL_END_RECOVERY;
1120 int ctdb_reply_control_end_recovery(struct ctdb_reply_control *reply)
1122 return ctdb_reply_control_generic(reply, CTDB_CONTROL_END_RECOVERY);
1125 /* CTDB_CONTROL_RELOAD_NODES_FILE */
1127 void ctdb_req_control_reload_nodes_file(struct ctdb_req_control *request)
1129 request->opcode = CTDB_CONTROL_RELOAD_NODES_FILE;
1130 request->pad = 0;
1131 request->srvid = 0;
1132 request->client_id = 0;
1133 request->flags = 0;
1135 request->rdata.opcode = CTDB_CONTROL_RELOAD_NODES_FILE;
1138 int ctdb_reply_control_reload_nodes_file(struct ctdb_reply_control *reply)
1140 return ctdb_reply_control_generic(reply,
1141 CTDB_CONTROL_RELOAD_NODES_FILE);
1144 /* CTDB_CONTROL_TRY_DELETE_RECORDS */
1146 void ctdb_req_control_try_delete_records(struct ctdb_req_control *request,
1147 struct ctdb_rec_buffer *recbuf)
1149 request->opcode = CTDB_CONTROL_TRY_DELETE_RECORDS;
1150 request->pad = 0;
1151 request->srvid = 0;
1152 request->client_id = 0;
1153 request->flags = 0;
1155 request->rdata.opcode = CTDB_CONTROL_TRY_DELETE_RECORDS;
1156 request->rdata.data.recbuf = recbuf;
1159 int ctdb_reply_control_try_delete_records(struct ctdb_reply_control *reply,
1160 TALLOC_CTX *mem_ctx,
1161 struct ctdb_rec_buffer **recbuf)
1163 if (reply->rdata.opcode != CTDB_CONTROL_TRY_DELETE_RECORDS) {
1164 return EPROTO;
1167 if (reply->status == 0) {
1168 *recbuf = talloc_steal(mem_ctx, reply->rdata.data.recbuf);
1170 return reply->status;
1173 /* CTDB_CONTROL_ENABLE_MONITOR */
1174 /* CTDB_CONTROL_DISABLE_MONITOR */
1176 /* CTDB_CONTROL_ADD_PUBLIC_IP */
1178 void ctdb_req_control_add_public_ip(struct ctdb_req_control *request,
1179 struct ctdb_addr_info *addr_info)
1181 request->opcode = CTDB_CONTROL_ADD_PUBLIC_IP;
1182 request->pad = 0;
1183 request->srvid = 0;
1184 request->client_id = 0;
1185 request->flags = 0;
1187 request->rdata.opcode = CTDB_CONTROL_ADD_PUBLIC_IP;
1188 request->rdata.data.addr_info = addr_info;
1191 int ctdb_reply_control_add_public_ip(struct ctdb_reply_control *reply)
1193 return ctdb_reply_control_generic(reply, CTDB_CONTROL_ADD_PUBLIC_IP);
1196 /* CTDB_CONTROL_DEL_PUBLIC_IP */
1198 void ctdb_req_control_del_public_ip(struct ctdb_req_control *request,
1199 struct ctdb_addr_info *addr_info)
1201 request->opcode = CTDB_CONTROL_DEL_PUBLIC_IP;
1202 request->pad = 0;
1203 request->srvid = 0;
1204 request->client_id = 0;
1205 request->flags = 0;
1207 request->rdata.opcode = CTDB_CONTROL_DEL_PUBLIC_IP;
1208 request->rdata.data.addr_info = addr_info;
1211 int ctdb_reply_control_del_public_ip(struct ctdb_reply_control *reply)
1213 return ctdb_reply_control_generic(reply, CTDB_CONTROL_DEL_PUBLIC_IP);
1216 /* CTDB_CONTROL_GET_CAPABILITIES */
1218 void ctdb_req_control_get_capabilities(struct ctdb_req_control *request)
1220 request->opcode = CTDB_CONTROL_GET_CAPABILITIES;
1221 request->pad = 0;
1222 request->srvid = 0;
1223 request->client_id = 0;
1224 request->flags = 0;
1226 request->rdata.opcode = CTDB_CONTROL_GET_CAPABILITIES;
1229 int ctdb_reply_control_get_capabilities(struct ctdb_reply_control *reply,
1230 uint32_t *caps)
1232 if (reply->rdata.opcode != CTDB_CONTROL_GET_CAPABILITIES) {
1233 return EPROTO;
1236 if (reply->status == 0) {
1237 *caps = reply->rdata.data.caps;
1239 return reply->status;
1242 /* CTDB_CONTROL_RECD_PING */
1244 void ctdb_req_control_recd_ping(struct ctdb_req_control *request)
1246 request->opcode = CTDB_CONTROL_RECD_PING;
1247 request->pad = 0;
1248 request->srvid = 0;
1249 request->client_id = 0;
1250 request->flags = 0;
1252 request->rdata.opcode = CTDB_CONTROL_RECD_PING;
1255 int ctdb_reply_control_recd_ping(struct ctdb_reply_control *reply)
1257 return ctdb_reply_control_generic(reply, CTDB_CONTROL_RECD_PING);
1260 /* CTDB_CONTROL_RELEASE_IP */
1262 void ctdb_req_control_release_ip(struct ctdb_req_control *request,
1263 struct ctdb_public_ip *pubip)
1265 request->opcode = CTDB_CONTROL_RELEASE_IP;
1266 request->pad = 0;
1267 request->srvid = 0;
1268 request->client_id = 0;
1269 request->flags = 0;
1271 request->rdata.opcode = CTDB_CONTROL_RELEASE_IP;
1272 request->rdata.data.pubip = pubip;
1275 int ctdb_reply_control_release_ip(struct ctdb_reply_control *reply)
1277 return ctdb_reply_control_generic(reply, CTDB_CONTROL_RELEASE_IP);
1280 /* CTDB_CONTROL_TAKEOVER_IP */
1282 void ctdb_req_control_takeover_ip(struct ctdb_req_control *request,
1283 struct ctdb_public_ip *pubip)
1285 request->opcode = CTDB_CONTROL_TAKEOVER_IP;
1286 request->pad = 0;
1287 request->srvid = 0;
1288 request->client_id = 0;
1289 request->flags = 0;
1291 request->rdata.opcode = CTDB_CONTROL_TAKEOVER_IP;
1292 request->rdata.data.pubip = pubip;
1295 int ctdb_reply_control_takeover_ip(struct ctdb_reply_control *reply)
1297 return ctdb_reply_control_generic(reply, CTDB_CONTROL_TAKEOVER_IP);
1300 /* CTDB_CONTROL_GET_PUBLIC_IPS */
1302 void ctdb_req_control_get_public_ips(struct ctdb_req_control *request,
1303 bool available_only)
1305 request->opcode = CTDB_CONTROL_GET_PUBLIC_IPS;
1306 request->pad = 0;
1307 request->srvid = 0;
1308 request->client_id = 0;
1309 request->flags = 0;
1311 request->rdata.opcode = CTDB_CONTROL_GET_PUBLIC_IPS;
1312 if (available_only) {
1313 request->flags = CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE;
1317 int ctdb_reply_control_get_public_ips(struct ctdb_reply_control *reply,
1318 TALLOC_CTX *mem_ctx,
1319 struct ctdb_public_ip_list **pubip_list)
1321 if (reply->rdata.opcode != CTDB_CONTROL_GET_PUBLIC_IPS) {
1322 return EPROTO;
1325 if (reply->status == 0) {
1326 *pubip_list = talloc_steal(mem_ctx,
1327 reply->rdata.data.pubip_list);
1329 return reply->status;
1332 /* CTDB_CONTROL_GET_NODEMAP */
1334 void ctdb_req_control_get_nodemap(struct ctdb_req_control *request)
1336 request->opcode = CTDB_CONTROL_GET_NODEMAP;
1337 request->pad = 0;
1338 request->srvid = 0;
1339 request->client_id = 0;
1340 request->flags = 0;
1342 request->rdata.opcode = CTDB_CONTROL_GET_NODEMAP;
1345 int ctdb_reply_control_get_nodemap(struct ctdb_reply_control *reply,
1346 TALLOC_CTX *mem_ctx,
1347 struct ctdb_node_map **nodemap)
1349 if (reply->rdata.opcode != CTDB_CONTROL_GET_NODEMAP) {
1350 return EPROTO;
1353 if (reply->status == 0) {
1354 *nodemap = talloc_steal(mem_ctx, reply->rdata.data.nodemap);
1356 return reply->status;
1359 /* CTDB_CONTROL_TRAVERSE_KILL */
1361 void ctdb_req_control_traverse_kill(struct ctdb_req_control *request,
1362 struct ctdb_traverse_start *traverse)
1364 request->opcode = CTDB_CONTROL_TRAVERSE_KILL;
1365 request->pad = 0;
1366 request->srvid = 0;
1367 request->client_id = 0;
1368 request->flags = 0;
1370 request->rdata.opcode = CTDB_CONTROL_TRAVERSE_KILL;
1371 request->rdata.data.traverse_start = traverse;
1374 int ctdb_reply_control_traverse_kill(struct ctdb_reply_control *reply)
1376 return ctdb_reply_control_generic(reply, CTDB_CONTROL_TRAVERSE_KILL);
1379 /* CTDB_CONTROL_RECD_RECLOCK_LATENCY */
1381 void ctdb_req_control_recd_reclock_latency(struct ctdb_req_control *request,
1382 double reclock_latency)
1384 request->opcode = CTDB_CONTROL_RECD_RECLOCK_LATENCY;
1385 request->pad = 0;
1386 request->srvid = 0;
1387 request->client_id = 0;
1388 request->flags = 0;
1390 request->rdata.opcode = CTDB_CONTROL_RECD_RECLOCK_LATENCY;
1391 request->rdata.data.reclock_latency = reclock_latency;
1394 int ctdb_reply_control_recd_reclock_latency(struct ctdb_reply_control *reply)
1396 return ctdb_reply_control_generic(reply,
1397 CTDB_CONTROL_RECD_RECLOCK_LATENCY);
1400 /* CTDB_CONTROL_GET_RECLOCK_FILE */
1402 void ctdb_req_control_get_reclock_file(struct ctdb_req_control *request)
1404 request->opcode = CTDB_CONTROL_GET_RECLOCK_FILE;
1405 request->pad = 0;
1406 request->srvid = 0;
1407 request->client_id = 0;
1408 request->flags = 0;
1410 request->rdata.opcode = CTDB_CONTROL_GET_RECLOCK_FILE;
1413 int ctdb_reply_control_get_reclock_file(struct ctdb_reply_control *reply,
1414 TALLOC_CTX *mem_ctx,
1415 const char **reclock_file)
1417 if (reply->rdata.opcode != CTDB_CONTROL_GET_RECLOCK_FILE) {
1418 return EPROTO;
1421 if (reply->status == 0) {
1422 *reclock_file = talloc_steal(mem_ctx,
1423 reply->rdata.data.reclock_file);
1425 return reply->status;
1428 /* CTDB_CONTROL_STOP_NODE */
1430 void ctdb_req_control_stop_node(struct ctdb_req_control *request)
1432 request->opcode = CTDB_CONTROL_STOP_NODE;
1433 request->pad = 0;
1434 request->srvid = 0;
1435 request->client_id = 0;
1436 request->flags = 0;
1438 request->rdata.opcode = CTDB_CONTROL_STOP_NODE;
1441 int ctdb_reply_control_stop_node(struct ctdb_reply_control *reply)
1443 return ctdb_reply_control_generic(reply, CTDB_CONTROL_STOP_NODE);
1446 /* CTDB_CONTROL_CONTINUE_NODE */
1448 void ctdb_req_control_continue_node(struct ctdb_req_control *request)
1450 request->opcode = CTDB_CONTROL_CONTINUE_NODE;
1451 request->pad = 0;
1452 request->srvid = 0;
1453 request->client_id = 0;
1454 request->flags = 0;
1456 request->rdata.opcode = CTDB_CONTROL_CONTINUE_NODE;
1459 int ctdb_reply_control_continue_node(struct ctdb_reply_control *reply)
1461 return ctdb_reply_control_generic(reply, CTDB_CONTROL_CONTINUE_NODE);
1464 /* CTDB_CONTROL_SET_LMASTERROLE */
1466 void ctdb_req_control_set_lmasterrole(struct ctdb_req_control *request,
1467 uint32_t lmaster_role)
1469 request->opcode = CTDB_CONTROL_SET_LMASTERROLE;
1470 request->pad = 0;
1471 request->srvid = 0;
1472 request->client_id = 0;
1473 request->flags = 0;
1475 request->rdata.opcode = CTDB_CONTROL_SET_LMASTERROLE;
1476 request->rdata.data.role = lmaster_role;
1479 int ctdb_reply_control_set_lmasterrole(struct ctdb_reply_control *reply)
1481 return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_LMASTERROLE);
1484 /* CTDB_CONTROL_SET_RECMASTERROLE */
1486 void ctdb_req_control_set_recmasterrole(struct ctdb_req_control *request,
1487 uint32_t recmaster_role)
1489 request->opcode = CTDB_CONTROL_SET_RECMASTERROLE;
1490 request->pad = 0;
1491 request->srvid = 0;
1492 request->client_id = 0;
1493 request->flags = 0;
1495 request->rdata.opcode = CTDB_CONTROL_SET_RECMASTERROLE;
1496 request->rdata.data.role = recmaster_role;
1499 int ctdb_reply_control_set_recmasterrole(struct ctdb_reply_control *reply)
1501 return ctdb_reply_control_generic(reply,
1502 CTDB_CONTROL_SET_RECMASTERROLE);
1505 /* CTDB_CONTROL_SET_BAN_STATE */
1507 void ctdb_req_control_set_ban_state(struct ctdb_req_control *request,
1508 struct ctdb_ban_state *ban_state)
1510 request->opcode = CTDB_CONTROL_SET_BAN_STATE;
1511 request->pad = 0;
1512 request->srvid = 0;
1513 request->client_id = 0;
1514 request->flags = 0;
1516 request->rdata.opcode = CTDB_CONTROL_SET_BAN_STATE;
1517 request->rdata.data.ban_state = ban_state;
1520 int ctdb_reply_control_set_ban_state(struct ctdb_reply_control *reply)
1522 return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_BAN_STATE);
1525 /* CTDB_CONTROL_GET_BAN_STATE */
1527 void ctdb_req_control_get_ban_state(struct ctdb_req_control *request)
1529 request->opcode = CTDB_CONTROL_GET_BAN_STATE;
1530 request->pad = 0;
1531 request->srvid = 0;
1532 request->client_id = 0;
1533 request->flags = 0;
1535 request->rdata.opcode = CTDB_CONTROL_GET_BAN_STATE;
1538 int ctdb_reply_control_get_ban_state(struct ctdb_reply_control *reply,
1539 TALLOC_CTX *mem_ctx,
1540 struct ctdb_ban_state **ban_state)
1542 if (reply->rdata.opcode != CTDB_CONTROL_GET_BAN_STATE) {
1543 return EPROTO;
1546 if (reply->status == 0) {
1547 *ban_state = talloc_steal(mem_ctx,
1548 reply->rdata.data.ban_state);
1550 return reply->status;
1553 /* CTDB_CONTROL_REGISTER_NOTIFY */
1555 void ctdb_req_control_register_notify(struct ctdb_req_control *request,
1556 struct ctdb_notify_data *notify)
1558 request->opcode = CTDB_CONTROL_REGISTER_NOTIFY;
1559 request->pad = 0;
1560 request->srvid = 0;
1561 request->client_id = 0;
1562 request->flags = 0;
1564 request->rdata.opcode = CTDB_CONTROL_REGISTER_NOTIFY;
1565 request->rdata.data.notify = notify;
1568 int ctdb_reply_control_register_notify(struct ctdb_reply_control *reply)
1570 return ctdb_reply_control_generic(reply, CTDB_CONTROL_REGISTER_NOTIFY);
1573 /* CTDB_CONTROL_DEREGISTER_NOTIFY */
1575 void ctdb_req_control_deregister_notify(struct ctdb_req_control *request,
1576 uint64_t srvid)
1578 request->opcode = CTDB_CONTROL_DEREGISTER_NOTIFY;
1579 request->pad = 0;
1580 request->srvid = 0;
1581 request->client_id = 0;
1582 request->flags = 0;
1584 request->rdata.opcode = CTDB_CONTROL_DEREGISTER_NOTIFY;
1585 request->rdata.data.srvid = srvid;
1588 int ctdb_reply_control_deregister_notify(struct ctdb_reply_control *reply)
1590 return ctdb_reply_control_generic(reply,
1591 CTDB_CONTROL_DEREGISTER_NOTIFY);
1594 /* CTDB_CONTROL_TRANS3_COMMIT */
1596 void ctdb_req_control_trans3_commit(struct ctdb_req_control *request,
1597 struct ctdb_rec_buffer *recbuf)
1599 request->opcode = CTDB_CONTROL_TRANS3_COMMIT;
1600 request->pad = 0;
1601 request->srvid = 0;
1602 request->client_id = 0;
1603 request->flags = 0;
1605 request->rdata.opcode = CTDB_CONTROL_TRANS3_COMMIT;
1606 request->rdata.data.recbuf = recbuf;
1609 int ctdb_reply_control_trans3_commit(struct ctdb_reply_control *reply)
1611 return ctdb_reply_control_generic(reply, CTDB_CONTROL_TRANS3_COMMIT);
1614 /* CTDB_CONTROL_GET_DB_SEQNUM */
1616 void ctdb_req_control_get_db_seqnum(struct ctdb_req_control *request,
1617 uint32_t db_id)
1619 request->opcode = CTDB_CONTROL_GET_DB_SEQNUM;
1620 request->pad = 0;
1621 request->srvid = 0;
1622 request->client_id = 0;
1623 request->flags = 0;
1625 request->rdata.opcode = CTDB_CONTROL_GET_DB_SEQNUM;
1626 request->rdata.data.db_id = db_id;
1629 int ctdb_reply_control_get_db_seqnum(struct ctdb_reply_control *reply,
1630 uint64_t *seqnum)
1632 if (reply->rdata.opcode != CTDB_CONTROL_GET_DB_SEQNUM) {
1633 return EPROTO;
1636 if (reply->status == 0) {
1637 *seqnum = reply->rdata.data.seqnum;
1639 return reply->status;
1642 /* CTDB_CONTROL_DB_SET_HEALTHY */
1644 void ctdb_req_control_db_set_healthy(struct ctdb_req_control *request,
1645 uint32_t db_id)
1647 request->opcode = CTDB_CONTROL_DB_SET_HEALTHY;
1648 request->pad = 0;
1649 request->srvid = 0;
1650 request->client_id = 0;
1651 request->flags = 0;
1653 request->rdata.opcode = CTDB_CONTROL_DB_SET_HEALTHY;
1654 request->rdata.data.db_id = db_id;
1657 int ctdb_reply_control_db_set_healthy(struct ctdb_reply_control *reply)
1659 return ctdb_reply_control_generic(reply, CTDB_CONTROL_DB_SET_HEALTHY);
1662 /* CTDB_CONTROL_DB_GET_HEALTH */
1664 void ctdb_req_control_db_get_health(struct ctdb_req_control *request,
1665 uint32_t db_id)
1667 request->opcode = CTDB_CONTROL_DB_GET_HEALTH;
1668 request->pad = 0;
1669 request->srvid = 0;
1670 request->client_id = 0;
1671 request->flags = 0;
1673 request->rdata.opcode = CTDB_CONTROL_DB_GET_HEALTH;
1674 request->rdata.data.db_id = db_id;
1677 int ctdb_reply_control_db_get_health(struct ctdb_reply_control *reply,
1678 TALLOC_CTX *mem_ctx, const char **reason)
1680 if (reply->rdata.opcode != CTDB_CONTROL_DB_GET_HEALTH) {
1681 return EPROTO;
1684 if (reply->status == 0) {
1685 *reason = talloc_steal(mem_ctx, reply->rdata.data.reason);
1687 return reply->status;
1690 /* CTDB_CONTROL_GET_PUBLIC_IP_INFO */
1692 void ctdb_req_control_get_public_ip_info(struct ctdb_req_control *request,
1693 ctdb_sock_addr *addr)
1695 request->opcode = CTDB_CONTROL_GET_PUBLIC_IP_INFO;
1696 request->pad = 0;
1697 request->srvid = 0;
1698 request->client_id = 0;
1699 request->flags = 0;
1701 request->rdata.opcode = CTDB_CONTROL_GET_PUBLIC_IP_INFO;
1702 request->rdata.data.addr = addr;
1705 int ctdb_reply_control_get_public_ip_info(struct ctdb_reply_control *reply,
1706 TALLOC_CTX *mem_ctx,
1707 struct ctdb_public_ip_info **ipinfo)
1709 if (reply->rdata.opcode != CTDB_CONTROL_GET_PUBLIC_IP_INFO) {
1710 return EPROTO;
1713 if (reply->status == 0) {
1714 *ipinfo = talloc_steal(mem_ctx, reply->rdata.data.ipinfo);
1716 return reply->status;
1719 /* CTDB_CONTROL_GET_IFACES */
1721 void ctdb_req_control_get_ifaces(struct ctdb_req_control *request)
1723 request->opcode = CTDB_CONTROL_GET_IFACES;
1724 request->pad = 0;
1725 request->srvid = 0;
1726 request->client_id = 0;
1727 request->flags = 0;
1729 request->rdata.opcode = CTDB_CONTROL_GET_IFACES;
1732 int ctdb_reply_control_get_ifaces(struct ctdb_reply_control *reply,
1733 TALLOC_CTX *mem_ctx,
1734 struct ctdb_iface_list **iface_list)
1736 if (reply->rdata.opcode != CTDB_CONTROL_GET_IFACES) {
1737 return EPROTO;
1740 if (reply->status == 0) {
1741 *iface_list = talloc_steal(mem_ctx,
1742 reply->rdata.data.iface_list);
1744 return reply->status;
1747 /* CTDB_CONTROL_SET_IFACE_LINK_STATE */
1749 void ctdb_req_control_set_iface_link_state(struct ctdb_req_control *request,
1750 struct ctdb_iface *iface)
1752 request->opcode = CTDB_CONTROL_SET_IFACE_LINK_STATE;
1753 request->pad = 0;
1754 request->srvid = 0;
1755 request->client_id = 0;
1756 request->flags = 0;
1758 request->rdata.opcode = CTDB_CONTROL_SET_IFACE_LINK_STATE;
1759 request->rdata.data.iface = iface;
1762 int ctdb_reply_control_set_iface_link_state(struct ctdb_reply_control *reply)
1764 return ctdb_reply_control_generic(reply,
1765 CTDB_CONTROL_SET_IFACE_LINK_STATE);
1768 /* CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE */
1770 void ctdb_req_control_tcp_add_delayed_update(struct ctdb_req_control *request,
1771 struct ctdb_connection *conn)
1773 request->opcode = CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE;
1774 request->pad = 0;
1775 request->srvid = 0;
1776 request->client_id = 0;
1777 request->flags = 0;
1779 request->rdata.opcode = CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE;
1780 request->rdata.data.conn = conn;
1783 int ctdb_reply_control_tcp_add_delayed_update(struct ctdb_reply_control *reply)
1785 return ctdb_reply_control_generic(reply,
1786 CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE);
1789 /* CTDB_CONTROL_GET_STAT_HISTORY */
1791 void ctdb_req_control_get_stat_history(struct ctdb_req_control *request)
1793 request->opcode = CTDB_CONTROL_GET_STAT_HISTORY;
1794 request->pad = 0;
1795 request->srvid = 0;
1796 request->client_id = 0;
1797 request->flags = 0;
1799 request->rdata.opcode = CTDB_CONTROL_GET_STAT_HISTORY;
1802 int ctdb_reply_control_get_stat_history(struct ctdb_reply_control *reply,
1803 TALLOC_CTX *mem_ctx,
1804 struct ctdb_statistics_list **stats_list)
1806 if (reply->rdata.opcode != CTDB_CONTROL_GET_STAT_HISTORY) {
1807 return EPROTO;
1810 if (reply->status == 0) {
1811 *stats_list = talloc_steal(mem_ctx,
1812 reply->rdata.data.stats_list);
1814 return reply->status;
1817 /* CTDB_CONTROL_SCHEDULE_FOR_DELETION */
1819 void ctdb_req_control_schedule_for_deletion(struct ctdb_req_control *request,
1820 struct ctdb_key_data *key)
1822 request->opcode = CTDB_CONTROL_SCHEDULE_FOR_DELETION;
1823 request->pad = 0;
1824 request->srvid = 0;
1825 request->client_id = 0;
1826 request->flags = 0;
1828 request->rdata.opcode = CTDB_CONTROL_SCHEDULE_FOR_DELETION;
1829 request->rdata.data.key = key;
1832 int ctdb_reply_control_schedule_for_deletion(struct ctdb_reply_control *reply)
1834 return ctdb_reply_control_generic(reply,
1835 CTDB_CONTROL_SCHEDULE_FOR_DELETION);
1838 /* CTDB_CONTROL_SET_DB_READONLY */
1840 void ctdb_req_control_set_db_readonly(struct ctdb_req_control *request,
1841 uint32_t db_id)
1843 request->opcode = CTDB_CONTROL_SET_DB_READONLY;
1844 request->pad = 0;
1845 request->srvid = 0;
1846 request->client_id = 0;
1847 request->flags = 0;
1849 request->rdata.opcode = CTDB_CONTROL_SET_DB_READONLY;
1850 request->rdata.data.db_id = db_id;
1853 int ctdb_reply_control_set_db_readonly(struct ctdb_reply_control *reply)
1855 return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_DB_READONLY);
1858 /* CTDB_CONTROL_CHECK_SRVIDS */
1860 /* CTDB_CONTROL_TRAVERSE_START_EXT */
1862 void ctdb_req_control_traverse_start_ext(struct ctdb_req_control *request,
1863 struct ctdb_traverse_start_ext *traverse)
1865 request->opcode = CTDB_CONTROL_TRAVERSE_START_EXT;
1866 request->pad = 0;
1867 request->srvid = 0;
1868 request->client_id = 0;
1869 request->flags = 0;
1871 request->rdata.opcode = CTDB_CONTROL_TRAVERSE_START_EXT;
1872 request->rdata.data.traverse_start_ext = traverse;
1875 int ctdb_reply_control_traverse_start_ext(struct ctdb_reply_control *reply)
1877 return ctdb_reply_control_generic(reply,
1878 CTDB_CONTROL_TRAVERSE_START_EXT);
1881 /* CTDB_CONTROL_GET_DB_STATISTICS */
1883 void ctdb_req_control_get_db_statistics(struct ctdb_req_control *request,
1884 uint32_t db_id)
1886 request->opcode = CTDB_CONTROL_GET_DB_STATISTICS;
1887 request->pad = 0;
1888 request->srvid = 0;
1889 request->client_id = 0;
1890 request->flags = 0;
1892 request->rdata.opcode = CTDB_CONTROL_GET_DB_STATISTICS;
1893 request->rdata.data.db_id = db_id;
1896 int ctdb_reply_control_get_db_statistics(struct ctdb_reply_control *reply,
1897 TALLOC_CTX *mem_ctx,
1898 struct ctdb_db_statistics **dbstats)
1900 if (reply->rdata.opcode != CTDB_CONTROL_GET_DB_STATISTICS) {
1901 return EPROTO;
1904 if (reply->status == 0) {
1905 *dbstats = talloc_steal(mem_ctx, reply->rdata.data.dbstats);
1907 return reply->status;
1910 /* CTDB_CONTROL_SET_DB_STICKY */
1912 void ctdb_req_control_set_db_sticky(struct ctdb_req_control *request,
1913 uint32_t db_id)
1915 request->opcode = CTDB_CONTROL_SET_DB_STICKY;
1916 request->pad = 0;
1917 request->srvid = 0;
1918 request->client_id = 0;
1919 request->flags = 0;
1921 request->rdata.opcode = CTDB_CONTROL_SET_DB_STICKY;
1922 request->rdata.data.db_id = db_id;
1925 int ctdb_reply_control_set_db_sticky(struct ctdb_reply_control *reply)
1927 return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_DB_STICKY);
1930 /* CTDB_CONTROL_RELOAD_PUBLIC_IPS */
1932 void ctdb_req_control_reload_public_ips(struct ctdb_req_control *request)
1934 request->opcode = CTDB_CONTROL_RELOAD_PUBLIC_IPS;
1935 request->pad = 0;
1936 request->srvid = 0;
1937 request->client_id = 0;
1938 request->flags = 0;
1940 request->rdata.opcode = CTDB_CONTROL_RELOAD_PUBLIC_IPS;
1943 int ctdb_reply_control_reload_public_ips(struct ctdb_reply_control *reply)
1945 return ctdb_reply_control_generic(reply,
1946 CTDB_CONTROL_RELOAD_PUBLIC_IPS);
1949 /* CTDB_CONTROL_TRAVERSE_ALL_EXT */
1951 /* CTDB_CONTROL_IPREALLOCATED */
1953 void ctdb_req_control_ipreallocated(struct ctdb_req_control *request)
1955 request->opcode = CTDB_CONTROL_IPREALLOCATED;
1956 request->pad = 0;
1957 request->srvid = 0;
1958 request->client_id = 0;
1959 request->flags = 0;
1961 request->rdata.opcode = CTDB_CONTROL_IPREALLOCATED;
1964 int ctdb_reply_control_ipreallocated(struct ctdb_reply_control *reply)
1966 return ctdb_reply_control_generic(reply, CTDB_CONTROL_IPREALLOCATED);
1969 /* CTDB_CONTROL_GET_RUNSTATE */
1971 void ctdb_req_control_get_runstate(struct ctdb_req_control *request)
1973 request->opcode = CTDB_CONTROL_GET_RUNSTATE;
1974 request->pad = 0;
1975 request->srvid = 0;
1976 request->client_id = 0;
1977 request->flags = 0;
1979 request->rdata.opcode = CTDB_CONTROL_GET_RUNSTATE;
1982 int ctdb_reply_control_get_runstate(struct ctdb_reply_control *reply,
1983 enum ctdb_runstate *runstate)
1985 if (reply->rdata.opcode != CTDB_CONTROL_GET_RUNSTATE) {
1986 return EPROTO;
1989 if (reply->status == 0) {
1990 *runstate = reply->rdata.data.runstate;
1992 return reply->status;
1995 /* CTDB_CONTROL_DB_DETACH */
1997 void ctdb_req_control_db_detach(struct ctdb_req_control *request,
1998 uint32_t db_id)
2000 request->opcode = CTDB_CONTROL_DB_DETACH;
2001 request->pad = 0;
2002 request->srvid = 0;
2003 request->client_id = 0;
2004 request->flags = 0;
2006 request->rdata.opcode = CTDB_CONTROL_DB_DETACH;
2007 request->rdata.data.db_id = db_id;
2010 int ctdb_reply_control_db_detach(struct ctdb_reply_control *reply)
2012 return ctdb_reply_control_generic(reply, CTDB_CONTROL_DB_DETACH);
2015 /* CTDB_CONTROL_GET_NODES_FILE */
2017 void ctdb_req_control_get_nodes_file(struct ctdb_req_control *request)
2019 request->opcode = CTDB_CONTROL_GET_NODES_FILE;
2020 request->pad = 0;
2021 request->srvid = 0;
2022 request->client_id = 0;
2023 request->flags = 0;
2025 request->rdata.opcode = CTDB_CONTROL_GET_NODES_FILE;
2028 int ctdb_reply_control_get_nodes_file(struct ctdb_reply_control *reply,
2029 TALLOC_CTX *mem_ctx,
2030 struct ctdb_node_map **nodemap)
2032 if (reply->rdata.opcode != CTDB_CONTROL_GET_NODES_FILE) {
2033 return EPROTO;
2036 if (reply->status == 0) {
2037 *nodemap = talloc_steal(mem_ctx, reply->rdata.data.nodemap);
2039 return reply->status;
2042 /* CTDB_CONTROL_DB_FREEZE */
2044 void ctdb_req_control_db_freeze(struct ctdb_req_control *request,
2045 uint32_t db_id)
2047 request->opcode = CTDB_CONTROL_DB_FREEZE;
2048 request->pad = 0;
2049 request->srvid = 0;
2050 request->client_id = 0;
2051 request->flags = 0;
2053 request->rdata.opcode = CTDB_CONTROL_DB_FREEZE;
2054 request->rdata.data.db_id = db_id;
2057 int ctdb_reply_control_db_freeze(struct ctdb_reply_control *reply)
2059 return ctdb_reply_control_generic(reply, CTDB_CONTROL_DB_FREEZE);
2062 /* CTDB_CONTROL_DB_THAW */
2064 void ctdb_req_control_db_thaw(struct ctdb_req_control *request,
2065 uint32_t db_id)
2067 request->opcode = CTDB_CONTROL_DB_THAW;
2068 request->pad = 0;
2069 request->srvid = 0;
2070 request->client_id = 0;
2071 request->flags = 0;
2073 request->rdata.opcode = CTDB_CONTROL_DB_THAW;
2074 request->rdata.data.db_id = db_id;
2077 int ctdb_reply_control_db_thaw(struct ctdb_reply_control *reply)
2079 return ctdb_reply_control_generic(reply, CTDB_CONTROL_DB_THAW);
2082 /* CTDB_CONTROL_DB_TRANSACTION_START */
2084 void ctdb_req_control_db_transaction_start(struct ctdb_req_control *request,
2085 struct ctdb_transdb *transdb)
2087 request->opcode = CTDB_CONTROL_DB_TRANSACTION_START;
2088 request->pad = 0;
2089 request->srvid = 0;
2090 request->client_id = 0;
2091 request->flags = 0;
2093 request->rdata.opcode = CTDB_CONTROL_DB_TRANSACTION_START;
2094 request->rdata.data.transdb = transdb;
2097 int ctdb_reply_control_db_transaction_start(struct ctdb_reply_control *reply)
2099 return ctdb_reply_control_generic(reply,
2100 CTDB_CONTROL_DB_TRANSACTION_START);
2103 /* CTDB_CONTROL_DB_TRANSACTION_COMMIT */
2105 void ctdb_req_control_db_transaction_commit(struct ctdb_req_control *request,
2106 struct ctdb_transdb *transdb)
2108 request->opcode = CTDB_CONTROL_DB_TRANSACTION_COMMIT;
2109 request->pad = 0;
2110 request->srvid = 0;
2111 request->client_id = 0;
2112 request->flags = 0;
2114 request->rdata.opcode = CTDB_CONTROL_DB_TRANSACTION_COMMIT;
2115 request->rdata.data.transdb = transdb;
2118 int ctdb_reply_control_db_transaction_commit(struct ctdb_reply_control *reply)
2120 return ctdb_reply_control_generic(reply,
2121 CTDB_CONTROL_DB_TRANSACTION_COMMIT);
2124 /* CTDB_CONTROL_DB_TRANSACTION_CANCEL */
2126 void ctdb_req_control_db_transaction_cancel(struct ctdb_req_control *request,
2127 uint32_t db_id)
2129 request->opcode = CTDB_CONTROL_DB_TRANSACTION_CANCEL;
2130 request->pad = 0;
2131 request->srvid = 0;
2132 request->client_id = 0;
2133 request->flags = 0;
2135 request->rdata.opcode = CTDB_CONTROL_DB_TRANSACTION_CANCEL;
2136 request->rdata.data.db_id = db_id;
2139 int ctdb_reply_control_db_transaction_cancel(struct ctdb_reply_control *reply)
2141 return ctdb_reply_control_generic(reply,
2142 CTDB_CONTROL_DB_TRANSACTION_CANCEL);
2145 /* CTDB_CONTROL_DB_PULL */
2147 void ctdb_req_control_db_pull(struct ctdb_req_control *request,
2148 struct ctdb_pulldb_ext *pulldb_ext)
2150 request->opcode = CTDB_CONTROL_DB_PULL;
2151 request->pad = 0;
2152 request->srvid = 0;
2153 request->client_id = 0;
2154 request->flags = 0;
2156 request->rdata.opcode = CTDB_CONTROL_DB_PULL;
2157 request->rdata.data.pulldb_ext = pulldb_ext;
2160 int ctdb_reply_control_db_pull(struct ctdb_reply_control *reply,
2161 uint32_t *num_records)
2163 if (reply->rdata.opcode != CTDB_CONTROL_DB_PULL) {
2164 return EPROTO;
2167 if (reply->status == 0) {
2168 *num_records = reply->rdata.data.num_records;
2170 return reply->status;
2173 /* CTDB_CONTROL_DB_PUSH_START */
2175 void ctdb_req_control_db_push_start(struct ctdb_req_control *request,
2176 struct ctdb_pulldb_ext *pulldb_ext)
2178 request->opcode = CTDB_CONTROL_DB_PUSH_START;
2179 request->pad = 0;
2180 request->srvid = 0;
2181 request->client_id = 0;
2182 request->flags = 0;
2184 request->rdata.opcode = CTDB_CONTROL_DB_PUSH_START;
2185 request->rdata.data.pulldb_ext = pulldb_ext;
2188 int ctdb_reply_control_db_push_start(struct ctdb_reply_control *reply)
2190 return ctdb_reply_control_generic(reply, CTDB_CONTROL_DB_PUSH_START);
2193 /* CTDB_CONTROL_DB_PUSH_CONFIRM */
2195 void ctdb_req_control_db_push_confirm(struct ctdb_req_control *request,
2196 uint32_t db_id)
2198 request->opcode = CTDB_CONTROL_DB_PUSH_CONFIRM;
2199 request->pad = 0;
2200 request->srvid = 0;
2201 request->client_id = 0;
2202 request->flags = 0;
2204 request->rdata.opcode = CTDB_CONTROL_DB_PUSH_CONFIRM;
2205 request->rdata.data.db_id = db_id;
2208 int ctdb_reply_control_db_push_confirm(struct ctdb_reply_control *reply,
2209 uint32_t *num_records)
2211 if (reply->rdata.opcode != CTDB_CONTROL_DB_PUSH_CONFIRM) {
2212 return EPROTO;
2215 if (reply->status == 0) {
2216 *num_records = reply->rdata.data.num_records;
2218 return reply->status;
2221 /* CTDB_CONTROL_DB_OPEN_FLAGS */
2223 void ctdb_req_control_db_open_flags(struct ctdb_req_control *request,
2224 uint32_t db_id)
2226 request->opcode = CTDB_CONTROL_DB_OPEN_FLAGS;
2227 request->pad = 0;
2228 request->srvid = 0;
2229 request->client_id = 0;
2230 request->flags = 0;
2232 request->rdata.opcode = CTDB_CONTROL_DB_OPEN_FLAGS;
2233 request->rdata.data.db_id = db_id;
2236 int ctdb_reply_control_db_open_flags(struct ctdb_reply_control *reply,
2237 int *tdb_flags)
2239 if (reply->rdata.opcode != CTDB_CONTROL_DB_OPEN_FLAGS) {
2240 return EPROTO;
2243 if (reply->status == 0) {
2244 *tdb_flags = reply->rdata.data.tdb_flags;
2246 return reply->status;
2249 /* CTDB_CONTROL_DB_ATTACH_REPLICATED */
2251 void ctdb_req_control_db_attach_replicated(struct ctdb_req_control *request,
2252 const char *db_name)
2254 request->opcode = CTDB_CONTROL_DB_ATTACH_REPLICATED;
2255 request->pad = 0;
2256 request->srvid = 0;
2257 request->client_id = 0;
2258 request->flags = 0;
2260 request->rdata.opcode = CTDB_CONTROL_DB_ATTACH_REPLICATED;
2261 request->rdata.data.db_name = db_name;
2264 int ctdb_reply_control_db_attach_replicated(struct ctdb_reply_control *reply,
2265 uint32_t *db_id)
2267 if (reply->rdata.opcode != CTDB_CONTROL_DB_ATTACH_REPLICATED) {
2268 return EPROTO;
2270 if (reply->status == 0) {
2271 *db_id = reply->rdata.data.db_id;
2273 return reply->status;
2276 /* CTDB_CONTROL_CHECK_PID_SRVID */
2278 void ctdb_req_control_check_pid_srvid(struct ctdb_req_control *request,
2279 struct ctdb_pid_srvid *pid_srvid)
2281 request->opcode = CTDB_CONTROL_CHECK_PID_SRVID;
2282 request->pad = 0;
2283 request->srvid = 0;
2284 request->client_id = 0;
2285 request->flags = 0;
2287 request->rdata.opcode = CTDB_CONTROL_CHECK_PID_SRVID;
2288 request->rdata.data.pid_srvid = pid_srvid;
2291 int ctdb_reply_control_check_pid_srvid(struct ctdb_reply_control *reply,
2292 int *status)
2294 if (reply->rdata.opcode != CTDB_CONTROL_CHECK_PID_SRVID) {
2295 return EPROTO;
2298 *status = reply->status;
2299 reply->status = 0;
2301 return reply->status;
2304 /* CTDB_CONTROL_TUNNEL_REGISTER */
2306 void ctdb_req_control_tunnel_register(struct ctdb_req_control *request,
2307 uint64_t tunnel_id)
2309 request->opcode = CTDB_CONTROL_TUNNEL_REGISTER;
2310 request->pad = 0;
2311 request->srvid = tunnel_id;
2312 request->client_id = 0;
2313 request->flags = 0;
2316 int ctdb_reply_control_tunnel_register(struct ctdb_reply_control *reply)
2318 if (reply->rdata.opcode != CTDB_CONTROL_TUNNEL_REGISTER) {
2319 return EPROTO;
2322 return reply->status;
2325 /* CTDB_CONTROL_TUNNEL_DEREGISTER */
2327 void ctdb_req_control_tunnel_deregister(struct ctdb_req_control *request,
2328 uint64_t tunnel_id)
2330 request->opcode = CTDB_CONTROL_TUNNEL_DEREGISTER;
2331 request->pad = 0;
2332 request->srvid = tunnel_id;
2333 request->client_id = 0;
2334 request->flags = 0;
2337 int ctdb_reply_control_tunnel_deregister(struct ctdb_reply_control *reply)
2339 if (reply->rdata.opcode != CTDB_CONTROL_TUNNEL_DEREGISTER) {
2340 return EPROTO;
2343 return reply->status;