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/>.
21 #include "system/network.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;
39 c->calldata = tdb_null;
43 static int ctdb_reply_control_generic(struct ctdb_reply_control
*reply
,
46 if (reply
->rdata
.opcode
!= opcode
) {
53 /* CTDB_CONTROL_PROCESS_EXISTS */
55 void ctdb_req_control_process_exists(struct ctdb_req_control
*request
,
58 request
->opcode
= CTDB_CONTROL_PROCESS_EXISTS
;
61 request
->client_id
= 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
,
72 if (reply
->rdata
.opcode
!= CTDB_CONTROL_PROCESS_EXISTS
) {
76 *status
= reply
->status
;
82 /* CTDB_CONTROL_STATISTICS */
84 void ctdb_req_control_statistics(struct ctdb_req_control
*request
)
86 request
->opcode
= CTDB_CONTROL_STATISTICS
;
89 request
->client_id
= 0;
92 request
->rdata
.opcode
= CTDB_CONTROL_STATISTICS
;
95 int ctdb_reply_control_statistics(struct ctdb_reply_control
*reply
,
97 struct ctdb_statistics
**stats
)
99 if (reply
->rdata
.opcode
!= CTDB_CONTROL_STATISTICS
) {
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
;
116 request
->client_id
= 0;
119 request
->rdata
.opcode
= CTDB_CONTROL_PING
;
122 int ctdb_reply_control_ping(struct ctdb_reply_control
*reply
,
125 if (reply
->rdata
.opcode
!= CTDB_CONTROL_PING
) {
129 if (reply
->status
>= 0) {
130 *num_clients
= reply
->status
;
133 return reply
->status
;
136 /* CTDB_CONTROL_GETDBPATH */
138 void ctdb_req_control_getdbpath(struct ctdb_req_control
*request
,
141 request
->opcode
= CTDB_CONTROL_GETDBPATH
;
144 request
->client_id
= 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
) {
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
;
171 request
->client_id
= 0;
174 request
->rdata
.opcode
= CTDB_CONTROL_GETVNNMAP
;
177 int ctdb_reply_control_getvnnmap(struct ctdb_reply_control
*reply
,
179 struct ctdb_vnn_map
**vnnmap
)
181 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GETVNNMAP
) {
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
;
199 request
->client_id
= 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
;
218 request
->client_id
= 0;
221 request
->rdata
.opcode
= CTDB_CONTROL_GET_DEBUG
;
224 int ctdb_reply_control_get_debug(struct ctdb_reply_control
*reply
,
227 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_DEBUG
) {
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
,
242 request
->opcode
= CTDB_CONTROL_SET_DEBUG
;
245 request
->client_id
= 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
;
264 request
->client_id
= 0;
267 request
->rdata
.opcode
= CTDB_CONTROL_GET_DBMAP
;
270 int ctdb_reply_control_get_dbmap(struct ctdb_reply_control
*reply
,
272 struct ctdb_dbid_map
**dbmap
)
274 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_DBMAP
) {
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
;
292 request
->client_id
= 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
,
301 struct ctdb_rec_buffer
**recbuf
)
303 if (reply
->rdata
.opcode
!= CTDB_CONTROL_PULL_DB
) {
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
;
321 request
->client_id
= 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
;
340 request
->client_id
= 0;
343 request
->rdata
.opcode
= CTDB_CONTROL_GET_RECMODE
;
346 int ctdb_reply_control_get_recmode(struct ctdb_reply_control
*reply
,
349 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_RECMODE
) {
353 if (reply
->status
>= 0) {
354 *recmode
= reply
->status
;
357 return reply
->status
;
360 /* CTDB_CONTROL_SET_RECMODE */
362 void ctdb_req_control_set_recmode(struct ctdb_req_control
*request
,
365 request
->opcode
= CTDB_CONTROL_SET_RECMODE
;
368 request
->client_id
= 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
;
387 request
->client_id
= 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
;
406 request
->srvid
= tdb_flags
;
407 request
->client_id
= 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
,
417 if (reply
->rdata
.opcode
!= CTDB_CONTROL_DB_ATTACH
) {
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
;
437 request
->client_id
= 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
,
457 request
->opcode
= CTDB_CONTROL_REGISTER_SRVID
;
459 request
->srvid
= srvid
;
460 request
->client_id
= 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
,
476 request
->opcode
= CTDB_CONTROL_DEREGISTER_SRVID
;
478 request
->srvid
= srvid
;
479 request
->client_id
= 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
,
496 request
->opcode
= CTDB_CONTROL_GET_DBNAME
;
499 request
->client_id
= 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
) {
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
,
524 request
->opcode
= CTDB_CONTROL_ENABLE_SEQNUM
;
527 request
->client_id
= 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
,
544 request
->opcode
= CTDB_CONTROL_UPDATE_SEQNUM
;
547 request
->client_id
= 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
;
566 request
->client_id
= 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
) {
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
;
592 request
->client_id
= 0;
595 request
->rdata
.opcode
= CTDB_CONTROL_GET_PID
;
598 int ctdb_reply_control_get_pid(struct ctdb_reply_control
*reply
,
601 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_PID
) {
605 *pid
= reply
->status
;
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
;
618 request
->client_id
= 0;
621 request
->rdata
.opcode
= CTDB_CONTROL_GET_RECMASTER
;
624 int ctdb_reply_control_get_recmaster(struct ctdb_reply_control
*reply
,
627 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_RECMASTER
) {
631 *recmaster
= reply
->status
;
634 return reply
->status
;
637 /* CTDB_CONTROL_SET_RECMASTER */
639 void ctdb_req_control_set_recmaster(struct ctdb_req_control
*request
,
642 request
->opcode
= CTDB_CONTROL_SET_RECMASTER
;
645 request
->client_id
= 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
,
662 request
->opcode
= CTDB_CONTROL_FREEZE
;
664 request
->srvid
= priority
;
665 request
->client_id
= 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
;
683 request
->client_id
= 0;
686 request
->rdata
.opcode
= CTDB_CONTROL_GET_PNN
;
689 int ctdb_reply_control_get_pnn(struct ctdb_reply_control
*reply
,
692 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_PNN
) {
696 if (reply
->status
>= 0) {
697 *pnn
= reply
->status
;
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
;
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
;
728 request
->client_id
= 0;
731 request
->rdata
.opcode
= CTDB_CONTROL_GET_MONMODE
;
734 int ctdb_reply_control_get_monmode(struct ctdb_reply_control
*reply
,
737 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_MONMODE
) {
741 if (reply
->status
>= 0) {
742 *mon_mode
= reply
->status
;
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
;
756 request
->client_id
= 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
;
776 request
->client_id
= 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
;
796 request
->client_id
= 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
;
815 request
->client_id
= 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
;
834 request
->client_id
= 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
,
851 request
->opcode
= CTDB_CONTROL_GET_TUNABLE
;
854 request
->client_id
= 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
,
864 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_TUNABLE
) {
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
;
881 request
->client_id
= 0;
884 request
->rdata
.opcode
= CTDB_CONTROL_LIST_TUNABLES
;
887 int ctdb_reply_control_list_tunables(struct ctdb_reply_control
*reply
,
889 struct ctdb_var_list
**tun_var_list
)
891 if (reply
->rdata
.opcode
!= CTDB_CONTROL_LIST_TUNABLES
) {
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
;
910 request
->client_id
= 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
;
929 request
->client_id
= 0;
932 request
->rdata
.opcode
= CTDB_CONTROL_GET_ALL_TUNABLES
;
935 int ctdb_reply_control_get_all_tunables(struct ctdb_reply_control
*reply
,
937 struct ctdb_tunable_list
**tun_list
)
939 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_ALL_TUNABLES
) {
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
;
957 request
->client_id
= 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
,
966 struct ctdb_tickle_list
**tickles
)
968 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_TCP_TICKLE_LIST
) {
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
;
986 request
->client_id
= 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
,
1005 request
->opcode
= CTDB_CONTROL_DB_ATTACH_PERSISTENT
;
1007 request
->srvid
= tdb_flags
;
1008 request
->client_id
= 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
,
1018 if (reply
->rdata
.opcode
!= CTDB_CONTROL_DB_ATTACH_PERSISTENT
) {
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
;
1036 request
->client_id
= 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
;
1056 request
->client_id
= 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
;
1077 request
->client_id
= 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
;
1096 request
->client_id
= 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
) {
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
;
1122 request
->client_id
= 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
;
1140 request
->client_id
= 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
;
1158 request
->client_id
= 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
;
1178 request
->client_id
= 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
) {
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
;
1206 request
->client_id
= 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
;
1224 request
->client_id
= 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
;
1243 request
->client_id
= 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
;
1263 request
->client_id
= 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_GET_CAPABILITIES */
1277 void ctdb_req_control_get_capabilities(struct ctdb_req_control
*request
)
1279 request
->opcode
= CTDB_CONTROL_GET_CAPABILITIES
;
1282 request
->client_id
= 0;
1285 request
->rdata
.opcode
= CTDB_CONTROL_GET_CAPABILITIES
;
1288 int ctdb_reply_control_get_capabilities(struct ctdb_reply_control
*reply
,
1291 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_CAPABILITIES
) {
1295 if (reply
->status
== 0) {
1296 *caps
= reply
->rdata
.data
.caps
;
1298 return reply
->status
;
1301 /* CTDB_CONTROL_RECD_PING */
1303 void ctdb_req_control_recd_ping(struct ctdb_req_control
*request
)
1305 request
->opcode
= CTDB_CONTROL_RECD_PING
;
1308 request
->client_id
= 0;
1311 request
->rdata
.opcode
= CTDB_CONTROL_RECD_PING
;
1314 int ctdb_reply_control_recd_ping(struct ctdb_reply_control
*reply
)
1316 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_RECD_PING
);
1319 /* CTDB_CONTROL_RELEASE_IP */
1321 void ctdb_req_control_release_ip(struct ctdb_req_control
*request
,
1322 struct ctdb_public_ip
*pubip
)
1324 request
->opcode
= CTDB_CONTROL_RELEASE_IP
;
1327 request
->client_id
= 0;
1330 request
->rdata
.opcode
= CTDB_CONTROL_RELEASE_IP
;
1331 request
->rdata
.data
.pubip
= pubip
;
1334 int ctdb_reply_control_release_ip(struct ctdb_reply_control
*reply
)
1336 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_RELEASE_IP
);
1339 /* CTDB_CONTROL_TAKEOVER_IP */
1341 void ctdb_req_control_takeover_ip(struct ctdb_req_control
*request
,
1342 struct ctdb_public_ip
*pubip
)
1344 request
->opcode
= CTDB_CONTROL_TAKEOVER_IP
;
1347 request
->client_id
= 0;
1350 request
->rdata
.opcode
= CTDB_CONTROL_TAKEOVER_IP
;
1351 request
->rdata
.data
.pubip
= pubip
;
1354 int ctdb_reply_control_takeover_ip(struct ctdb_reply_control
*reply
)
1356 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_TAKEOVER_IP
);
1359 /* CTDB_CONTROL_GET_PUBLIC_IPS */
1361 void ctdb_req_control_get_public_ips(struct ctdb_req_control
*request
,
1362 bool available_only
)
1364 request
->opcode
= CTDB_CONTROL_GET_PUBLIC_IPS
;
1367 request
->client_id
= 0;
1370 request
->rdata
.opcode
= CTDB_CONTROL_GET_PUBLIC_IPS
;
1371 if (available_only
) {
1372 request
->flags
= CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE
;
1376 int ctdb_reply_control_get_public_ips(struct ctdb_reply_control
*reply
,
1377 TALLOC_CTX
*mem_ctx
,
1378 struct ctdb_public_ip_list
**pubip_list
)
1380 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_PUBLIC_IPS
) {
1384 if (reply
->status
== 0) {
1385 *pubip_list
= talloc_steal(mem_ctx
,
1386 reply
->rdata
.data
.pubip_list
);
1388 return reply
->status
;
1391 /* CTDB_CONTROL_GET_NODEMAP */
1393 void ctdb_req_control_get_nodemap(struct ctdb_req_control
*request
)
1395 request
->opcode
= CTDB_CONTROL_GET_NODEMAP
;
1398 request
->client_id
= 0;
1401 request
->rdata
.opcode
= CTDB_CONTROL_GET_NODEMAP
;
1404 int ctdb_reply_control_get_nodemap(struct ctdb_reply_control
*reply
,
1405 TALLOC_CTX
*mem_ctx
,
1406 struct ctdb_node_map
**nodemap
)
1408 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_NODEMAP
) {
1412 if (reply
->status
== 0) {
1413 *nodemap
= talloc_steal(mem_ctx
, reply
->rdata
.data
.nodemap
);
1415 return reply
->status
;
1418 /* CTDB_CONTROL_TRAVERSE_KILL */
1420 void ctdb_req_control_traverse_kill(struct ctdb_req_control
*request
,
1421 struct ctdb_traverse_start
*traverse
)
1423 request
->opcode
= CTDB_CONTROL_TRAVERSE_KILL
;
1426 request
->client_id
= 0;
1429 request
->rdata
.opcode
= CTDB_CONTROL_TRAVERSE_KILL
;
1430 request
->rdata
.data
.traverse_start
= traverse
;
1433 int ctdb_reply_control_traverse_kill(struct ctdb_reply_control
*reply
)
1435 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_TRAVERSE_KILL
);
1438 /* CTDB_CONTROL_RECD_RECLOCK_LATENCY */
1440 void ctdb_req_control_recd_reclock_latency(struct ctdb_req_control
*request
,
1441 double reclock_latency
)
1443 request
->opcode
= CTDB_CONTROL_RECD_RECLOCK_LATENCY
;
1446 request
->client_id
= 0;
1449 request
->rdata
.opcode
= CTDB_CONTROL_RECD_RECLOCK_LATENCY
;
1450 request
->rdata
.data
.reclock_latency
= reclock_latency
;
1453 int ctdb_reply_control_recd_reclock_latency(struct ctdb_reply_control
*reply
)
1455 return ctdb_reply_control_generic(reply
,
1456 CTDB_CONTROL_RECD_RECLOCK_LATENCY
);
1459 /* CTDB_CONTROL_GET_RECLOCK_FILE */
1461 void ctdb_req_control_get_reclock_file(struct ctdb_req_control
*request
)
1463 request
->opcode
= CTDB_CONTROL_GET_RECLOCK_FILE
;
1466 request
->client_id
= 0;
1469 request
->rdata
.opcode
= CTDB_CONTROL_GET_RECLOCK_FILE
;
1472 int ctdb_reply_control_get_reclock_file(struct ctdb_reply_control
*reply
,
1473 TALLOC_CTX
*mem_ctx
,
1474 const char **reclock_file
)
1476 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_RECLOCK_FILE
) {
1480 if (reply
->status
== 0) {
1481 *reclock_file
= talloc_steal(mem_ctx
,
1482 reply
->rdata
.data
.reclock_file
);
1484 return reply
->status
;
1487 /* CTDB_CONTROL_STOP_NODE */
1489 void ctdb_req_control_stop_node(struct ctdb_req_control
*request
)
1491 request
->opcode
= CTDB_CONTROL_STOP_NODE
;
1494 request
->client_id
= 0;
1497 request
->rdata
.opcode
= CTDB_CONTROL_STOP_NODE
;
1500 int ctdb_reply_control_stop_node(struct ctdb_reply_control
*reply
)
1502 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_STOP_NODE
);
1505 /* CTDB_CONTROL_CONTINUE_NODE */
1507 void ctdb_req_control_continue_node(struct ctdb_req_control
*request
)
1509 request
->opcode
= CTDB_CONTROL_CONTINUE_NODE
;
1512 request
->client_id
= 0;
1515 request
->rdata
.opcode
= CTDB_CONTROL_CONTINUE_NODE
;
1518 int ctdb_reply_control_continue_node(struct ctdb_reply_control
*reply
)
1520 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_CONTINUE_NODE
);
1523 /* CTDB_CONTROL_SET_LMASTERROLE */
1525 void ctdb_req_control_set_lmasterrole(struct ctdb_req_control
*request
,
1526 uint32_t lmaster_role
)
1528 request
->opcode
= CTDB_CONTROL_SET_LMASTERROLE
;
1531 request
->client_id
= 0;
1534 request
->rdata
.opcode
= CTDB_CONTROL_SET_LMASTERROLE
;
1535 request
->rdata
.data
.role
= lmaster_role
;
1538 int ctdb_reply_control_set_lmasterrole(struct ctdb_reply_control
*reply
)
1540 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_SET_LMASTERROLE
);
1543 /* CTDB_CONTROL_SET_RECMASTERROLE */
1545 void ctdb_req_control_set_recmasterrole(struct ctdb_req_control
*request
,
1546 uint32_t recmaster_role
)
1548 request
->opcode
= CTDB_CONTROL_SET_RECMASTERROLE
;
1551 request
->client_id
= 0;
1554 request
->rdata
.opcode
= CTDB_CONTROL_SET_RECMASTERROLE
;
1555 request
->rdata
.data
.role
= recmaster_role
;
1558 int ctdb_reply_control_set_recmasterrole(struct ctdb_reply_control
*reply
)
1560 return ctdb_reply_control_generic(reply
,
1561 CTDB_CONTROL_SET_RECMASTERROLE
);
1564 /* CTDB_CONTROL_SET_BAN_STATE */
1566 void ctdb_req_control_set_ban_state(struct ctdb_req_control
*request
,
1567 struct ctdb_ban_state
*ban_state
)
1569 request
->opcode
= CTDB_CONTROL_SET_BAN_STATE
;
1572 request
->client_id
= 0;
1575 request
->rdata
.opcode
= CTDB_CONTROL_SET_BAN_STATE
;
1576 request
->rdata
.data
.ban_state
= ban_state
;
1579 int ctdb_reply_control_set_ban_state(struct ctdb_reply_control
*reply
)
1581 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_SET_BAN_STATE
);
1584 /* CTDB_CONTROL_GET_BAN_STATE */
1586 void ctdb_req_control_get_ban_state(struct ctdb_req_control
*request
)
1588 request
->opcode
= CTDB_CONTROL_GET_BAN_STATE
;
1591 request
->client_id
= 0;
1594 request
->rdata
.opcode
= CTDB_CONTROL_GET_BAN_STATE
;
1597 int ctdb_reply_control_get_ban_state(struct ctdb_reply_control
*reply
,
1598 TALLOC_CTX
*mem_ctx
,
1599 struct ctdb_ban_state
**ban_state
)
1601 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_BAN_STATE
) {
1605 if (reply
->status
== 0) {
1606 *ban_state
= talloc_steal(mem_ctx
,
1607 reply
->rdata
.data
.ban_state
);
1609 return reply
->status
;
1612 /* CTDB_CONTROL_REGISTER_NOTIFY */
1614 void ctdb_req_control_register_notify(struct ctdb_req_control
*request
,
1615 struct ctdb_notify_data
*notify
)
1617 request
->opcode
= CTDB_CONTROL_REGISTER_NOTIFY
;
1620 request
->client_id
= 0;
1623 request
->rdata
.opcode
= CTDB_CONTROL_REGISTER_NOTIFY
;
1624 request
->rdata
.data
.notify
= notify
;
1627 int ctdb_reply_control_register_notify(struct ctdb_reply_control
*reply
)
1629 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_REGISTER_NOTIFY
);
1632 /* CTDB_CONTROL_DEREGISTER_NOTIFY */
1634 void ctdb_req_control_deregister_notify(struct ctdb_req_control
*request
,
1637 request
->opcode
= CTDB_CONTROL_DEREGISTER_NOTIFY
;
1640 request
->client_id
= 0;
1643 request
->rdata
.opcode
= CTDB_CONTROL_DEREGISTER_NOTIFY
;
1644 request
->rdata
.data
.srvid
= srvid
;
1647 int ctdb_reply_control_deregister_notify(struct ctdb_reply_control
*reply
)
1649 return ctdb_reply_control_generic(reply
,
1650 CTDB_CONTROL_DEREGISTER_NOTIFY
);
1653 /* CTDB_CONTROL_TRANS3_COMMIT */
1655 void ctdb_req_control_trans3_commit(struct ctdb_req_control
*request
,
1656 struct ctdb_rec_buffer
*recbuf
)
1658 request
->opcode
= CTDB_CONTROL_TRANS3_COMMIT
;
1661 request
->client_id
= 0;
1664 request
->rdata
.opcode
= CTDB_CONTROL_TRANS3_COMMIT
;
1665 request
->rdata
.data
.recbuf
= recbuf
;
1668 int ctdb_reply_control_trans3_commit(struct ctdb_reply_control
*reply
)
1670 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_TRANS3_COMMIT
);
1673 /* CTDB_CONTROL_GET_DB_SEQNUM */
1675 void ctdb_req_control_get_db_seqnum(struct ctdb_req_control
*request
,
1678 request
->opcode
= CTDB_CONTROL_GET_DB_SEQNUM
;
1681 request
->client_id
= 0;
1684 request
->rdata
.opcode
= CTDB_CONTROL_GET_DB_SEQNUM
;
1685 request
->rdata
.data
.db_id
= db_id
;
1688 int ctdb_reply_control_get_db_seqnum(struct ctdb_reply_control
*reply
,
1691 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_DB_SEQNUM
) {
1695 if (reply
->status
== 0) {
1696 *seqnum
= reply
->rdata
.data
.seqnum
;
1698 return reply
->status
;
1701 /* CTDB_CONTROL_DB_SET_HEALTHY */
1703 void ctdb_req_control_db_set_healthy(struct ctdb_req_control
*request
,
1706 request
->opcode
= CTDB_CONTROL_DB_SET_HEALTHY
;
1709 request
->client_id
= 0;
1712 request
->rdata
.opcode
= CTDB_CONTROL_DB_SET_HEALTHY
;
1713 request
->rdata
.data
.db_id
= db_id
;
1716 int ctdb_reply_control_db_set_healthy(struct ctdb_reply_control
*reply
)
1718 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_DB_SET_HEALTHY
);
1721 /* CTDB_CONTROL_DB_GET_HEALTH */
1723 void ctdb_req_control_db_get_health(struct ctdb_req_control
*request
,
1726 request
->opcode
= CTDB_CONTROL_DB_GET_HEALTH
;
1729 request
->client_id
= 0;
1732 request
->rdata
.opcode
= CTDB_CONTROL_DB_GET_HEALTH
;
1733 request
->rdata
.data
.db_id
= db_id
;
1736 int ctdb_reply_control_db_get_health(struct ctdb_reply_control
*reply
,
1737 TALLOC_CTX
*mem_ctx
, const char **reason
)
1739 if (reply
->rdata
.opcode
!= CTDB_CONTROL_DB_GET_HEALTH
) {
1743 if (reply
->status
== 0) {
1744 *reason
= talloc_steal(mem_ctx
, reply
->rdata
.data
.reason
);
1746 return reply
->status
;
1749 /* CTDB_CONTROL_GET_PUBLIC_IP_INFO */
1751 void ctdb_req_control_get_public_ip_info(struct ctdb_req_control
*request
,
1752 ctdb_sock_addr
*addr
)
1754 request
->opcode
= CTDB_CONTROL_GET_PUBLIC_IP_INFO
;
1757 request
->client_id
= 0;
1760 request
->rdata
.opcode
= CTDB_CONTROL_GET_PUBLIC_IP_INFO
;
1761 request
->rdata
.data
.addr
= addr
;
1764 int ctdb_reply_control_get_public_ip_info(struct ctdb_reply_control
*reply
,
1765 TALLOC_CTX
*mem_ctx
,
1766 struct ctdb_public_ip_info
**ipinfo
)
1768 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_PUBLIC_IP_INFO
) {
1772 if (reply
->status
== 0) {
1773 *ipinfo
= talloc_steal(mem_ctx
, reply
->rdata
.data
.ipinfo
);
1775 return reply
->status
;
1778 /* CTDB_CONTROL_GET_IFACES */
1780 void ctdb_req_control_get_ifaces(struct ctdb_req_control
*request
)
1782 request
->opcode
= CTDB_CONTROL_GET_IFACES
;
1785 request
->client_id
= 0;
1788 request
->rdata
.opcode
= CTDB_CONTROL_GET_IFACES
;
1791 int ctdb_reply_control_get_ifaces(struct ctdb_reply_control
*reply
,
1792 TALLOC_CTX
*mem_ctx
,
1793 struct ctdb_iface_list
**iface_list
)
1795 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_IFACES
) {
1799 if (reply
->status
== 0) {
1800 *iface_list
= talloc_steal(mem_ctx
,
1801 reply
->rdata
.data
.iface_list
);
1803 return reply
->status
;
1806 /* CTDB_CONTROL_SET_IFACE_LINK_STATE */
1808 void ctdb_req_control_set_iface_link_state(struct ctdb_req_control
*request
,
1809 struct ctdb_iface
*iface
)
1811 request
->opcode
= CTDB_CONTROL_SET_IFACE_LINK_STATE
;
1814 request
->client_id
= 0;
1817 request
->rdata
.opcode
= CTDB_CONTROL_SET_IFACE_LINK_STATE
;
1818 request
->rdata
.data
.iface
= iface
;
1821 int ctdb_reply_control_set_iface_link_state(struct ctdb_reply_control
*reply
)
1823 return ctdb_reply_control_generic(reply
,
1824 CTDB_CONTROL_SET_IFACE_LINK_STATE
);
1827 /* CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE */
1829 void ctdb_req_control_tcp_add_delayed_update(struct ctdb_req_control
*request
,
1830 struct ctdb_connection
*conn
)
1832 request
->opcode
= CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
;
1835 request
->client_id
= 0;
1838 request
->rdata
.opcode
= CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
;
1839 request
->rdata
.data
.conn
= conn
;
1842 int ctdb_reply_control_tcp_add_delayed_update(struct ctdb_reply_control
*reply
)
1844 return ctdb_reply_control_generic(reply
,
1845 CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
);
1848 /* CTDB_CONTROL_GET_STAT_HISTORY */
1850 void ctdb_req_control_get_stat_history(struct ctdb_req_control
*request
)
1852 request
->opcode
= CTDB_CONTROL_GET_STAT_HISTORY
;
1855 request
->client_id
= 0;
1858 request
->rdata
.opcode
= CTDB_CONTROL_GET_STAT_HISTORY
;
1861 int ctdb_reply_control_get_stat_history(struct ctdb_reply_control
*reply
,
1862 TALLOC_CTX
*mem_ctx
,
1863 struct ctdb_statistics_list
**stats_list
)
1865 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_STAT_HISTORY
) {
1869 if (reply
->status
== 0) {
1870 *stats_list
= talloc_steal(mem_ctx
,
1871 reply
->rdata
.data
.stats_list
);
1873 return reply
->status
;
1876 /* CTDB_CONTROL_SCHEDULE_FOR_DELETION */
1878 void ctdb_req_control_schedule_for_deletion(struct ctdb_req_control
*request
,
1879 struct ctdb_key_data
*key
)
1881 request
->opcode
= CTDB_CONTROL_SCHEDULE_FOR_DELETION
;
1884 request
->client_id
= 0;
1887 request
->rdata
.opcode
= CTDB_CONTROL_SCHEDULE_FOR_DELETION
;
1888 request
->rdata
.data
.key
= key
;
1891 int ctdb_reply_control_schedule_for_deletion(struct ctdb_reply_control
*reply
)
1893 return ctdb_reply_control_generic(reply
,
1894 CTDB_CONTROL_SCHEDULE_FOR_DELETION
);
1897 /* CTDB_CONTROL_SET_DB_READONLY */
1899 void ctdb_req_control_set_db_readonly(struct ctdb_req_control
*request
,
1902 request
->opcode
= CTDB_CONTROL_SET_DB_READONLY
;
1905 request
->client_id
= 0;
1908 request
->rdata
.opcode
= CTDB_CONTROL_SET_DB_READONLY
;
1909 request
->rdata
.data
.db_id
= db_id
;
1912 int ctdb_reply_control_set_db_readonly(struct ctdb_reply_control
*reply
)
1914 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_SET_DB_READONLY
);
1917 /* CTDB_CONTROL_CHECK_SRVIDS */
1919 void ctdb_req_control_check_srvids(struct ctdb_req_control
*request
,
1920 struct ctdb_uint64_array
*u64_array
)
1922 request
->opcode
= CTDB_CONTROL_CHECK_SRVIDS
;
1925 request
->client_id
= 0;
1928 request
->rdata
.opcode
= CTDB_CONTROL_CHECK_SRVIDS
;
1929 request
->rdata
.data
.u64_array
= u64_array
;
1932 int ctdb_reply_control_check_srvids(struct ctdb_reply_control
*reply
,
1933 TALLOC_CTX
*mem_ctx
,
1934 struct ctdb_uint8_array
**u8_array
)
1936 if (reply
->rdata
.opcode
!= CTDB_CONTROL_CHECK_SRVIDS
) {
1940 if (reply
->status
== 0) {
1941 *u8_array
= talloc_steal(mem_ctx
, reply
->rdata
.data
.u8_array
);
1943 return reply
->status
;
1946 /* CTDB_CONTROL_TRAVERSE_START_EXT */
1948 void ctdb_req_control_traverse_start_ext(struct ctdb_req_control
*request
,
1949 struct ctdb_traverse_start_ext
*traverse
)
1951 request
->opcode
= CTDB_CONTROL_TRAVERSE_START_EXT
;
1954 request
->client_id
= 0;
1957 request
->rdata
.opcode
= CTDB_CONTROL_TRAVERSE_START_EXT
;
1958 request
->rdata
.data
.traverse_start_ext
= traverse
;
1961 int ctdb_reply_control_traverse_start_ext(struct ctdb_reply_control
*reply
)
1963 return ctdb_reply_control_generic(reply
,
1964 CTDB_CONTROL_TRAVERSE_START_EXT
);
1967 /* CTDB_CONTROL_GET_DB_STATISTICS */
1969 void ctdb_req_control_get_db_statistics(struct ctdb_req_control
*request
,
1972 request
->opcode
= CTDB_CONTROL_GET_DB_STATISTICS
;
1975 request
->client_id
= 0;
1978 request
->rdata
.opcode
= CTDB_CONTROL_GET_DB_STATISTICS
;
1979 request
->rdata
.data
.db_id
= db_id
;
1982 int ctdb_reply_control_get_db_statistics(struct ctdb_reply_control
*reply
,
1983 TALLOC_CTX
*mem_ctx
,
1984 struct ctdb_db_statistics
**dbstats
)
1986 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_DB_STATISTICS
) {
1990 if (reply
->status
== 0) {
1991 *dbstats
= talloc_steal(mem_ctx
, reply
->rdata
.data
.dbstats
);
1993 return reply
->status
;
1996 /* CTDB_CONTROL_SET_DB_STICKY */
1998 void ctdb_req_control_set_db_sticky(struct ctdb_req_control
*request
,
2001 request
->opcode
= CTDB_CONTROL_SET_DB_STICKY
;
2004 request
->client_id
= 0;
2007 request
->rdata
.opcode
= CTDB_CONTROL_SET_DB_STICKY
;
2008 request
->rdata
.data
.db_id
= db_id
;
2011 int ctdb_reply_control_set_db_sticky(struct ctdb_reply_control
*reply
)
2013 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_SET_DB_STICKY
);
2016 /* CTDB_CONTROL_RELOAD_PUBLIC_IPS */
2018 void ctdb_req_control_reload_public_ips(struct ctdb_req_control
*request
)
2020 request
->opcode
= CTDB_CONTROL_RELOAD_PUBLIC_IPS
;
2023 request
->client_id
= 0;
2026 request
->rdata
.opcode
= CTDB_CONTROL_RELOAD_PUBLIC_IPS
;
2029 int ctdb_reply_control_reload_public_ips(struct ctdb_reply_control
*reply
)
2031 return ctdb_reply_control_generic(reply
,
2032 CTDB_CONTROL_RELOAD_PUBLIC_IPS
);
2035 /* CTDB_CONTROL_TRAVERSE_ALL_EXT */
2037 /* CTDB_CONTROL_RECEIVE_RECORDS */
2039 void ctdb_req_control_receive_records(struct ctdb_req_control
*request
,
2040 struct ctdb_rec_buffer
*recbuf
)
2042 request
->opcode
= CTDB_CONTROL_RECEIVE_RECORDS
;
2045 request
->client_id
= 0;
2048 request
->rdata
.opcode
= CTDB_CONTROL_RECEIVE_RECORDS
;
2049 request
->rdata
.data
.recbuf
= recbuf
;
2052 int ctdb_reply_control_receive_records(struct ctdb_reply_control
*reply
,
2053 TALLOC_CTX
*mem_ctx
,
2054 struct ctdb_rec_buffer
**recbuf
)
2056 if (reply
->rdata
.opcode
!= CTDB_CONTROL_RECEIVE_RECORDS
) {
2060 if (reply
->status
== 0) {
2061 *recbuf
= talloc_steal(mem_ctx
, reply
->rdata
.data
.recbuf
);
2063 return reply
->status
;
2066 /* CTDB_CONTROL_IPREALLOCATED */
2068 void ctdb_req_control_ipreallocated(struct ctdb_req_control
*request
)
2070 request
->opcode
= CTDB_CONTROL_IPREALLOCATED
;
2073 request
->client_id
= 0;
2076 request
->rdata
.opcode
= CTDB_CONTROL_IPREALLOCATED
;
2079 int ctdb_reply_control_ipreallocated(struct ctdb_reply_control
*reply
)
2081 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_IPREALLOCATED
);
2084 /* CTDB_CONTROL_GET_RUNSTATE */
2086 void ctdb_req_control_get_runstate(struct ctdb_req_control
*request
)
2088 request
->opcode
= CTDB_CONTROL_GET_RUNSTATE
;
2091 request
->client_id
= 0;
2094 request
->rdata
.opcode
= CTDB_CONTROL_GET_RUNSTATE
;
2097 int ctdb_reply_control_get_runstate(struct ctdb_reply_control
*reply
,
2098 enum ctdb_runstate
*runstate
)
2100 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_RUNSTATE
) {
2104 if (reply
->status
== 0) {
2105 *runstate
= reply
->rdata
.data
.runstate
;
2107 return reply
->status
;
2110 /* CTDB_CONTROL_DB_DETACH */
2112 void ctdb_req_control_db_detach(struct ctdb_req_control
*request
,
2115 request
->opcode
= CTDB_CONTROL_DB_DETACH
;
2118 request
->client_id
= 0;
2121 request
->rdata
.opcode
= CTDB_CONTROL_DB_DETACH
;
2122 request
->rdata
.data
.db_id
= db_id
;
2125 int ctdb_reply_control_db_detach(struct ctdb_reply_control
*reply
)
2127 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_DB_DETACH
);
2130 /* CTDB_CONTROL_GET_NODES_FILE */
2132 void ctdb_req_control_get_nodes_file(struct ctdb_req_control
*request
)
2134 request
->opcode
= CTDB_CONTROL_GET_NODES_FILE
;
2137 request
->client_id
= 0;
2140 request
->rdata
.opcode
= CTDB_CONTROL_GET_NODES_FILE
;
2143 int ctdb_reply_control_get_nodes_file(struct ctdb_reply_control
*reply
,
2144 TALLOC_CTX
*mem_ctx
,
2145 struct ctdb_node_map
**nodemap
)
2147 if (reply
->rdata
.opcode
!= CTDB_CONTROL_GET_NODES_FILE
) {
2151 if (reply
->status
== 0) {
2152 *nodemap
= talloc_steal(mem_ctx
, reply
->rdata
.data
.nodemap
);
2154 return reply
->status
;
2157 /* CTDB_CONTROL_DB_FREEZE */
2159 void ctdb_req_control_db_freeze(struct ctdb_req_control
*request
,
2162 request
->opcode
= CTDB_CONTROL_DB_FREEZE
;
2165 request
->client_id
= 0;
2168 request
->rdata
.opcode
= CTDB_CONTROL_DB_FREEZE
;
2169 request
->rdata
.data
.db_id
= db_id
;
2172 int ctdb_reply_control_db_freeze(struct ctdb_reply_control
*reply
)
2174 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_DB_FREEZE
);
2177 /* CTDB_CONTROL_DB_THAW */
2179 void ctdb_req_control_db_thaw(struct ctdb_req_control
*request
,
2182 request
->opcode
= CTDB_CONTROL_DB_THAW
;
2185 request
->client_id
= 0;
2188 request
->rdata
.opcode
= CTDB_CONTROL_DB_THAW
;
2189 request
->rdata
.data
.db_id
= db_id
;
2192 int ctdb_reply_control_db_thaw(struct ctdb_reply_control
*reply
)
2194 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_DB_THAW
);
2197 /* CTDB_CONTROL_DB_TRANSACTION_START */
2199 void ctdb_req_control_db_transaction_start(struct ctdb_req_control
*request
,
2200 struct ctdb_transdb
*transdb
)
2202 request
->opcode
= CTDB_CONTROL_DB_TRANSACTION_START
;
2205 request
->client_id
= 0;
2208 request
->rdata
.opcode
= CTDB_CONTROL_DB_TRANSACTION_START
;
2209 request
->rdata
.data
.transdb
= transdb
;
2212 int ctdb_reply_control_db_transaction_start(struct ctdb_reply_control
*reply
)
2214 return ctdb_reply_control_generic(reply
,
2215 CTDB_CONTROL_DB_TRANSACTION_START
);
2218 /* CTDB_CONTROL_DB_TRANSACTION_COMMIT */
2220 void ctdb_req_control_db_transaction_commit(struct ctdb_req_control
*request
,
2221 struct ctdb_transdb
*transdb
)
2223 request
->opcode
= CTDB_CONTROL_DB_TRANSACTION_COMMIT
;
2226 request
->client_id
= 0;
2229 request
->rdata
.opcode
= CTDB_CONTROL_DB_TRANSACTION_COMMIT
;
2230 request
->rdata
.data
.transdb
= transdb
;
2233 int ctdb_reply_control_db_transaction_commit(struct ctdb_reply_control
*reply
)
2235 return ctdb_reply_control_generic(reply
,
2236 CTDB_CONTROL_DB_TRANSACTION_COMMIT
);
2239 /* CTDB_CONTROL_DB_TRANSACTION_CANCEL */
2241 void ctdb_req_control_db_transaction_cancel(struct ctdb_req_control
*request
,
2244 request
->opcode
= CTDB_CONTROL_DB_TRANSACTION_CANCEL
;
2247 request
->client_id
= 0;
2250 request
->rdata
.opcode
= CTDB_CONTROL_DB_TRANSACTION_CANCEL
;
2251 request
->rdata
.data
.db_id
= db_id
;
2254 int ctdb_reply_control_db_transaction_cancel(struct ctdb_reply_control
*reply
)
2256 return ctdb_reply_control_generic(reply
,
2257 CTDB_CONTROL_DB_TRANSACTION_CANCEL
);
2260 /* CTDB_CONTROL_DB_PULL */
2262 void ctdb_req_control_db_pull(struct ctdb_req_control
*request
,
2263 struct ctdb_pulldb_ext
*pulldb_ext
)
2265 request
->opcode
= CTDB_CONTROL_DB_PULL
;
2268 request
->client_id
= 0;
2271 request
->rdata
.opcode
= CTDB_CONTROL_DB_PULL
;
2272 request
->rdata
.data
.pulldb_ext
= pulldb_ext
;
2275 int ctdb_reply_control_db_pull(struct ctdb_reply_control
*reply
,
2276 uint32_t *num_records
)
2278 if (reply
->rdata
.opcode
!= CTDB_CONTROL_DB_PULL
) {
2282 if (reply
->status
== 0) {
2283 *num_records
= reply
->rdata
.data
.num_records
;
2285 return reply
->status
;
2288 /* CTDB_CONTROL_DB_PUSH_START */
2290 void ctdb_req_control_db_push_start(struct ctdb_req_control
*request
,
2291 struct ctdb_pulldb_ext
*pulldb_ext
)
2293 request
->opcode
= CTDB_CONTROL_DB_PUSH_START
;
2296 request
->client_id
= 0;
2299 request
->rdata
.opcode
= CTDB_CONTROL_DB_PUSH_START
;
2300 request
->rdata
.data
.pulldb_ext
= pulldb_ext
;
2303 int ctdb_reply_control_db_push_start(struct ctdb_reply_control
*reply
)
2305 return ctdb_reply_control_generic(reply
, CTDB_CONTROL_DB_PUSH_START
);
2308 /* CTDB_CONTROL_DB_PUSH_CONFIRM */
2310 void ctdb_req_control_db_push_confirm(struct ctdb_req_control
*request
,
2313 request
->opcode
= CTDB_CONTROL_DB_PUSH_CONFIRM
;
2316 request
->client_id
= 0;
2319 request
->rdata
.opcode
= CTDB_CONTROL_DB_PUSH_CONFIRM
;
2320 request
->rdata
.data
.db_id
= db_id
;
2323 int ctdb_reply_control_db_push_confirm(struct ctdb_reply_control
*reply
,
2324 uint32_t *num_records
)
2326 if (reply
->rdata
.opcode
!= CTDB_CONTROL_DB_PUSH_CONFIRM
) {
2330 if (reply
->status
== 0) {
2331 *num_records
= reply
->rdata
.data
.num_records
;
2333 return reply
->status
;