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"
30 struct ctdb_req_control_wire
{
31 struct ctdb_req_header hdr
;
41 struct ctdb_reply_control_wire
{
42 struct ctdb_req_header hdr
;
49 static size_t ctdb_req_control_data_len(struct ctdb_req_control_data
*cd
)
58 case CTDB_CONTROL_PROCESS_EXISTS
:
59 len
= ctdb_pid_len(cd
->data
.pid
);
62 case CTDB_CONTROL_STATISTICS
:
65 case CTDB_CONTROL_PING
:
68 case CTDB_CONTROL_GETDBPATH
:
69 len
= ctdb_uint32_len(cd
->data
.db_id
);
72 case CTDB_CONTROL_GETVNNMAP
:
75 case CTDB_CONTROL_SETVNNMAP
:
76 len
= ctdb_vnn_map_len(cd
->data
.vnnmap
);
79 case CTDB_CONTROL_GET_DEBUG
:
82 case CTDB_CONTROL_SET_DEBUG
:
83 len
= ctdb_uint32_len(cd
->data
.loglevel
);
86 case CTDB_CONTROL_GET_DBMAP
:
89 case CTDB_CONTROL_PULL_DB
:
90 len
= ctdb_pulldb_len(cd
->data
.pulldb
);
93 case CTDB_CONTROL_PUSH_DB
:
94 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
97 case CTDB_CONTROL_GET_RECMODE
:
100 case CTDB_CONTROL_SET_RECMODE
:
101 len
= ctdb_uint32_len(cd
->data
.recmode
);
104 case CTDB_CONTROL_STATISTICS_RESET
:
107 case CTDB_CONTROL_DB_ATTACH
:
108 len
= ctdb_string_len(cd
->data
.db_name
);
111 case CTDB_CONTROL_SET_CALL
:
114 case CTDB_CONTROL_TRAVERSE_START
:
115 len
= ctdb_traverse_start_len(cd
->data
.traverse_start
);
118 case CTDB_CONTROL_TRAVERSE_ALL
:
119 len
= ctdb_traverse_all_len(cd
->data
.traverse_all
);
122 case CTDB_CONTROL_TRAVERSE_DATA
:
123 len
= ctdb_rec_data_len(cd
->data
.rec_data
);
126 case CTDB_CONTROL_REGISTER_SRVID
:
129 case CTDB_CONTROL_DEREGISTER_SRVID
:
132 case CTDB_CONTROL_GET_DBNAME
:
133 len
= ctdb_uint32_len(cd
->data
.db_id
);
136 case CTDB_CONTROL_ENABLE_SEQNUM
:
137 len
= ctdb_uint32_len(cd
->data
.db_id
);
140 case CTDB_CONTROL_UPDATE_SEQNUM
:
141 len
= ctdb_uint32_len(cd
->data
.db_id
);
144 case CTDB_CONTROL_DUMP_MEMORY
:
147 case CTDB_CONTROL_GET_PID
:
150 case CTDB_CONTROL_GET_RECMASTER
:
153 case CTDB_CONTROL_SET_RECMASTER
:
154 len
= ctdb_uint32_len(cd
->data
.recmaster
);
157 case CTDB_CONTROL_FREEZE
:
160 case CTDB_CONTROL_GET_PNN
:
163 case CTDB_CONTROL_SHUTDOWN
:
166 case CTDB_CONTROL_GET_MONMODE
:
169 case CTDB_CONTROL_TCP_CLIENT
:
170 len
= ctdb_connection_len(cd
->data
.conn
);
173 case CTDB_CONTROL_TCP_ADD
:
174 len
= ctdb_connection_len(cd
->data
.conn
);
177 case CTDB_CONTROL_TCP_REMOVE
:
178 len
= ctdb_connection_len(cd
->data
.conn
);
181 case CTDB_CONTROL_STARTUP
:
184 case CTDB_CONTROL_SET_TUNABLE
:
185 len
= ctdb_tunable_len(cd
->data
.tunable
);
188 case CTDB_CONTROL_GET_TUNABLE
:
189 len
= ctdb_stringn_len(cd
->data
.tun_var
);
192 case CTDB_CONTROL_LIST_TUNABLES
:
195 case CTDB_CONTROL_MODIFY_FLAGS
:
196 len
= ctdb_node_flag_change_len(cd
->data
.flag_change
);
199 case CTDB_CONTROL_GET_ALL_TUNABLES
:
202 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
203 len
= ctdb_sock_addr_len(cd
->data
.addr
);
206 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
207 len
= ctdb_tickle_list_len(cd
->data
.tickles
);
210 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
211 len
= ctdb_string_len(cd
->data
.db_name
);
214 case CTDB_CONTROL_UPDATE_RECORD
:
215 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
218 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
219 len
= ctdb_addr_info_len(cd
->data
.addr_info
);
222 case CTDB_CONTROL_WIPE_DATABASE
:
223 len
= ctdb_transdb_len(cd
->data
.transdb
);
226 case CTDB_CONTROL_UPTIME
:
229 case CTDB_CONTROL_START_RECOVERY
:
232 case CTDB_CONTROL_END_RECOVERY
:
235 case CTDB_CONTROL_RELOAD_NODES_FILE
:
238 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
239 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
242 case CTDB_CONTROL_ENABLE_MONITOR
:
245 case CTDB_CONTROL_DISABLE_MONITOR
:
248 case CTDB_CONTROL_ADD_PUBLIC_IP
:
249 len
= ctdb_addr_info_len(cd
->data
.addr_info
);
252 case CTDB_CONTROL_DEL_PUBLIC_IP
:
253 len
= ctdb_addr_info_len(cd
->data
.addr_info
);
256 case CTDB_CONTROL_GET_CAPABILITIES
:
259 case CTDB_CONTROL_RECD_PING
:
262 case CTDB_CONTROL_RELEASE_IP
:
263 len
= ctdb_public_ip_len(cd
->data
.pubip
);
266 case CTDB_CONTROL_TAKEOVER_IP
:
267 len
= ctdb_public_ip_len(cd
->data
.pubip
);
270 case CTDB_CONTROL_GET_PUBLIC_IPS
:
273 case CTDB_CONTROL_GET_NODEMAP
:
276 case CTDB_CONTROL_TRAVERSE_KILL
:
277 len
= ctdb_traverse_start_len(cd
->data
.traverse_start
);
280 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
281 len
= ctdb_double_len(cd
->data
.reclock_latency
);
284 case CTDB_CONTROL_GET_RECLOCK_FILE
:
287 case CTDB_CONTROL_STOP_NODE
:
290 case CTDB_CONTROL_CONTINUE_NODE
:
293 case CTDB_CONTROL_SET_LMASTERROLE
:
294 len
= ctdb_uint32_len(cd
->data
.role
);
297 case CTDB_CONTROL_SET_RECMASTERROLE
:
298 len
= ctdb_uint32_len(cd
->data
.role
);
301 case CTDB_CONTROL_SET_BAN_STATE
:
302 len
= ctdb_ban_state_len(cd
->data
.ban_state
);
305 case CTDB_CONTROL_GET_BAN_STATE
:
308 case CTDB_CONTROL_REGISTER_NOTIFY
:
309 len
= ctdb_notify_data_len(cd
->data
.notify
);
312 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
313 len
= ctdb_uint64_len(cd
->data
.srvid
);
316 case CTDB_CONTROL_TRANS3_COMMIT
:
317 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
320 case CTDB_CONTROL_GET_DB_SEQNUM
:
321 len
= ctdb_uint64_len((uint64_t)cd
->data
.db_id
);
324 case CTDB_CONTROL_DB_SET_HEALTHY
:
325 len
= ctdb_uint32_len(cd
->data
.db_id
);
328 case CTDB_CONTROL_DB_GET_HEALTH
:
329 len
= ctdb_uint32_len(cd
->data
.db_id
);
332 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
333 len
= ctdb_sock_addr_len(cd
->data
.addr
);
336 case CTDB_CONTROL_GET_IFACES
:
339 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
340 len
= ctdb_iface_len(cd
->data
.iface
);
343 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
344 len
= ctdb_connection_len(cd
->data
.conn
);
347 case CTDB_CONTROL_GET_STAT_HISTORY
:
350 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
351 len
= ctdb_key_data_len(cd
->data
.key
);
354 case CTDB_CONTROL_SET_DB_READONLY
:
355 len
= ctdb_uint32_len(cd
->data
.db_id
);
358 case CTDB_CONTROL_CHECK_SRVIDS
:
359 len
= ctdb_uint64_array_len(cd
->data
.u64_array
);
362 case CTDB_CONTROL_TRAVERSE_START_EXT
:
363 len
= ctdb_traverse_start_ext_len(cd
->data
.traverse_start_ext
);
366 case CTDB_CONTROL_GET_DB_STATISTICS
:
367 len
= ctdb_uint32_len(cd
->data
.db_id
);
370 case CTDB_CONTROL_SET_DB_STICKY
:
371 len
= ctdb_uint32_len(cd
->data
.db_id
);
374 case CTDB_CONTROL_RELOAD_PUBLIC_IPS
:
377 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
378 len
= ctdb_traverse_all_ext_len(cd
->data
.traverse_all_ext
);
381 case CTDB_CONTROL_RECEIVE_RECORDS
:
382 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
385 case CTDB_CONTROL_IPREALLOCATED
:
388 case CTDB_CONTROL_GET_RUNSTATE
:
391 case CTDB_CONTROL_DB_DETACH
:
392 len
= ctdb_uint32_len(cd
->data
.db_id
);
395 case CTDB_CONTROL_GET_NODES_FILE
:
398 case CTDB_CONTROL_DB_FREEZE
:
399 len
= ctdb_uint32_len(cd
->data
.db_id
);
402 case CTDB_CONTROL_DB_THAW
:
403 len
= ctdb_uint32_len(cd
->data
.db_id
);
406 case CTDB_CONTROL_DB_TRANSACTION_START
:
407 len
= ctdb_transdb_len(cd
->data
.transdb
);
410 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
411 len
= ctdb_transdb_len(cd
->data
.transdb
);
414 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
415 len
= ctdb_uint32_len(cd
->data
.db_id
);
418 case CTDB_CONTROL_DB_PULL
:
419 len
= ctdb_pulldb_ext_len(cd
->data
.pulldb_ext
);
422 case CTDB_CONTROL_DB_PUSH_START
:
423 len
= ctdb_pulldb_ext_len(cd
->data
.pulldb_ext
);
426 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
427 len
= ctdb_uint32_len(cd
->data
.db_id
);
430 case CTDB_CONTROL_DB_OPEN_FLAGS
:
431 len
= ctdb_uint32_len(cd
->data
.db_id
);
434 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
435 len
= ctdb_string_len(cd
->data
.db_name
);
442 static void ctdb_req_control_data_push(struct ctdb_req_control_data
*cd
,
445 switch (cd
->opcode
) {
446 case CTDB_CONTROL_PROCESS_EXISTS
:
447 ctdb_pid_push(cd
->data
.pid
, buf
);
450 case CTDB_CONTROL_GETDBPATH
:
451 ctdb_uint32_push(cd
->data
.db_id
, buf
);
454 case CTDB_CONTROL_SETVNNMAP
:
455 ctdb_vnn_map_push(cd
->data
.vnnmap
, buf
);
458 case CTDB_CONTROL_SET_DEBUG
:
459 ctdb_uint32_push(cd
->data
.loglevel
, buf
);
462 case CTDB_CONTROL_PULL_DB
:
463 ctdb_pulldb_push(cd
->data
.pulldb
, buf
);
466 case CTDB_CONTROL_PUSH_DB
:
467 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
);
470 case CTDB_CONTROL_SET_RECMODE
:
471 ctdb_uint32_push(cd
->data
.recmode
, buf
);
474 case CTDB_CONTROL_DB_ATTACH
:
475 ctdb_string_push(cd
->data
.db_name
, buf
);
478 case CTDB_CONTROL_SET_CALL
:
481 case CTDB_CONTROL_TRAVERSE_START
:
482 ctdb_traverse_start_push(cd
->data
.traverse_start
, buf
);
485 case CTDB_CONTROL_TRAVERSE_ALL
:
486 ctdb_traverse_all_push(cd
->data
.traverse_all
, buf
);
489 case CTDB_CONTROL_TRAVERSE_DATA
:
490 ctdb_rec_data_push(cd
->data
.rec_data
, buf
);
493 case CTDB_CONTROL_GET_DBNAME
:
494 ctdb_uint32_push(cd
->data
.db_id
, buf
);
497 case CTDB_CONTROL_ENABLE_SEQNUM
:
498 ctdb_uint32_push(cd
->data
.db_id
, buf
);
501 case CTDB_CONTROL_UPDATE_SEQNUM
:
502 ctdb_uint32_push(cd
->data
.db_id
, buf
);
505 case CTDB_CONTROL_SET_RECMASTER
:
506 ctdb_uint32_push(cd
->data
.recmaster
, buf
);
509 case CTDB_CONTROL_TCP_CLIENT
:
510 ctdb_connection_push(cd
->data
.conn
, buf
);
513 case CTDB_CONTROL_TCP_ADD
:
514 ctdb_connection_push(cd
->data
.conn
, buf
);
517 case CTDB_CONTROL_TCP_REMOVE
:
518 ctdb_connection_push(cd
->data
.conn
, buf
);
521 case CTDB_CONTROL_SET_TUNABLE
:
522 ctdb_tunable_push(cd
->data
.tunable
, buf
);
525 case CTDB_CONTROL_GET_TUNABLE
:
526 ctdb_stringn_push(cd
->data
.tun_var
, buf
);
529 case CTDB_CONTROL_MODIFY_FLAGS
:
530 ctdb_node_flag_change_push(cd
->data
.flag_change
, buf
);
533 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
534 ctdb_sock_addr_push(cd
->data
.addr
, buf
);
537 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
538 ctdb_tickle_list_push(cd
->data
.tickles
, buf
);
541 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
542 ctdb_string_push(cd
->data
.db_name
, buf
);
545 case CTDB_CONTROL_UPDATE_RECORD
:
546 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
);
549 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
550 ctdb_addr_info_push(cd
->data
.addr_info
, buf
);
553 case CTDB_CONTROL_WIPE_DATABASE
:
554 ctdb_transdb_push(cd
->data
.transdb
, buf
);
557 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
558 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
);
561 case CTDB_CONTROL_ADD_PUBLIC_IP
:
562 ctdb_addr_info_push(cd
->data
.addr_info
, buf
);
565 case CTDB_CONTROL_DEL_PUBLIC_IP
:
566 ctdb_addr_info_push(cd
->data
.addr_info
, buf
);
569 case CTDB_CONTROL_RELEASE_IP
:
570 ctdb_public_ip_push(cd
->data
.pubip
, buf
);
573 case CTDB_CONTROL_TAKEOVER_IP
:
574 ctdb_public_ip_push(cd
->data
.pubip
, buf
);
577 case CTDB_CONTROL_TRAVERSE_KILL
:
578 ctdb_traverse_start_push(cd
->data
.traverse_start
, buf
);
581 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
582 ctdb_double_push(cd
->data
.reclock_latency
, buf
);
585 case CTDB_CONTROL_SET_LMASTERROLE
:
586 ctdb_uint32_push(cd
->data
.role
, buf
);
589 case CTDB_CONTROL_SET_RECMASTERROLE
:
590 ctdb_uint32_push(cd
->data
.role
, buf
);
593 case CTDB_CONTROL_SET_BAN_STATE
:
594 ctdb_ban_state_push(cd
->data
.ban_state
, buf
);
597 case CTDB_CONTROL_REGISTER_NOTIFY
:
598 ctdb_notify_data_push(cd
->data
.notify
, buf
);
601 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
602 ctdb_uint64_push(cd
->data
.srvid
, buf
);
605 case CTDB_CONTROL_TRANS3_COMMIT
:
606 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
);
609 case CTDB_CONTROL_GET_DB_SEQNUM
:
610 ctdb_uint32_push(cd
->data
.db_id
, buf
);
613 case CTDB_CONTROL_DB_SET_HEALTHY
:
614 ctdb_uint32_push(cd
->data
.db_id
, buf
);
617 case CTDB_CONTROL_DB_GET_HEALTH
:
618 ctdb_uint32_push(cd
->data
.db_id
, buf
);
621 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
622 ctdb_sock_addr_push(cd
->data
.addr
, buf
);
625 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
626 ctdb_iface_push(cd
->data
.iface
, buf
);
629 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
630 ctdb_connection_push(cd
->data
.conn
, buf
);
633 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
634 ctdb_key_data_push(cd
->data
.key
, buf
);
637 case CTDB_CONTROL_SET_DB_READONLY
:
638 ctdb_uint32_push(cd
->data
.db_id
, buf
);
641 case CTDB_CONTROL_CHECK_SRVIDS
:
642 ctdb_uint64_array_push(cd
->data
.u64_array
, buf
);
645 case CTDB_CONTROL_TRAVERSE_START_EXT
:
646 ctdb_traverse_start_ext_push(cd
->data
.traverse_start_ext
, buf
);
649 case CTDB_CONTROL_GET_DB_STATISTICS
:
650 ctdb_uint32_push(cd
->data
.db_id
, buf
);
653 case CTDB_CONTROL_SET_DB_STICKY
:
654 ctdb_uint32_push(cd
->data
.db_id
, buf
);
657 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
658 ctdb_traverse_all_ext_push(cd
->data
.traverse_all_ext
, buf
);
661 case CTDB_CONTROL_RECEIVE_RECORDS
:
662 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
);
665 case CTDB_CONTROL_DB_DETACH
:
666 ctdb_uint32_push(cd
->data
.db_id
, buf
);
669 case CTDB_CONTROL_DB_FREEZE
:
670 ctdb_uint32_push(cd
->data
.db_id
, buf
);
673 case CTDB_CONTROL_DB_THAW
:
674 ctdb_uint32_push(cd
->data
.db_id
, buf
);
677 case CTDB_CONTROL_DB_TRANSACTION_START
:
678 ctdb_transdb_push(cd
->data
.transdb
, buf
);
681 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
682 ctdb_transdb_push(cd
->data
.transdb
, buf
);
685 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
686 ctdb_uint32_push(cd
->data
.db_id
, buf
);
689 case CTDB_CONTROL_DB_PULL
:
690 ctdb_pulldb_ext_push(cd
->data
.pulldb_ext
, buf
);
693 case CTDB_CONTROL_DB_PUSH_START
:
694 ctdb_pulldb_ext_push(cd
->data
.pulldb_ext
, buf
);
697 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
698 ctdb_uint32_push(cd
->data
.db_id
, buf
);
701 case CTDB_CONTROL_DB_OPEN_FLAGS
:
702 ctdb_uint32_push(cd
->data
.db_id
, buf
);
705 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
706 ctdb_string_push(cd
->data
.db_name
, buf
);
711 static int ctdb_req_control_data_pull(uint8_t *buf
, size_t buflen
,
714 struct ctdb_req_control_data
*cd
)
721 case CTDB_CONTROL_PROCESS_EXISTS
:
722 ret
= ctdb_pid_pull(buf
, buflen
, mem_ctx
,
726 case CTDB_CONTROL_GETDBPATH
:
727 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
731 case CTDB_CONTROL_SETVNNMAP
:
732 ret
= ctdb_vnn_map_pull(buf
, buflen
, mem_ctx
,
736 case CTDB_CONTROL_SET_DEBUG
:
737 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
741 case CTDB_CONTROL_PULL_DB
:
742 ret
= ctdb_pulldb_pull(buf
, buflen
, mem_ctx
,
746 case CTDB_CONTROL_PUSH_DB
:
747 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
751 case CTDB_CONTROL_SET_RECMODE
:
752 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
756 case CTDB_CONTROL_DB_ATTACH
:
757 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
761 case CTDB_CONTROL_SET_CALL
:
764 case CTDB_CONTROL_TRAVERSE_START
:
765 ret
= ctdb_traverse_start_pull(buf
, buflen
, mem_ctx
,
766 &cd
->data
.traverse_start
);
769 case CTDB_CONTROL_TRAVERSE_ALL
:
770 ret
= ctdb_traverse_all_pull(buf
, buflen
, mem_ctx
,
771 &cd
->data
.traverse_all
);
774 case CTDB_CONTROL_TRAVERSE_DATA
:
775 ret
= ctdb_rec_data_pull(buf
, buflen
, mem_ctx
,
779 case CTDB_CONTROL_GET_DBNAME
:
780 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
784 case CTDB_CONTROL_ENABLE_SEQNUM
:
785 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
789 case CTDB_CONTROL_UPDATE_SEQNUM
:
790 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
794 case CTDB_CONTROL_SET_RECMASTER
:
795 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
796 &cd
->data
.recmaster
);
799 case CTDB_CONTROL_TCP_CLIENT
:
800 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
804 case CTDB_CONTROL_TCP_ADD
:
805 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
809 case CTDB_CONTROL_TCP_REMOVE
:
810 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
814 case CTDB_CONTROL_SET_TUNABLE
:
815 ret
= ctdb_tunable_pull(buf
, buflen
, mem_ctx
,
819 case CTDB_CONTROL_GET_TUNABLE
:
820 ret
= ctdb_stringn_pull(buf
, buflen
, mem_ctx
,
824 case CTDB_CONTROL_MODIFY_FLAGS
:
825 ret
= ctdb_node_flag_change_pull(buf
, buflen
, mem_ctx
,
826 &cd
->data
.flag_change
);
829 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
830 ret
= ctdb_sock_addr_pull(buf
, buflen
, mem_ctx
,
834 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
835 ret
= ctdb_tickle_list_pull(buf
, buflen
, mem_ctx
,
839 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
840 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
844 case CTDB_CONTROL_UPDATE_RECORD
:
845 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
849 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
850 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
851 &cd
->data
.addr_info
);
854 case CTDB_CONTROL_WIPE_DATABASE
:
855 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
859 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
860 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
864 case CTDB_CONTROL_ADD_PUBLIC_IP
:
865 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
866 &cd
->data
.addr_info
);
869 case CTDB_CONTROL_DEL_PUBLIC_IP
:
870 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
871 &cd
->data
.addr_info
);
874 case CTDB_CONTROL_RELEASE_IP
:
875 ret
= ctdb_public_ip_pull(buf
, buflen
, mem_ctx
,
879 case CTDB_CONTROL_TAKEOVER_IP
:
880 ret
= ctdb_public_ip_pull(buf
, buflen
, mem_ctx
,
884 case CTDB_CONTROL_TRAVERSE_KILL
:
885 ret
= ctdb_traverse_start_pull(buf
, buflen
, mem_ctx
,
886 &cd
->data
.traverse_start
);
889 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
890 ret
= ctdb_double_pull(buf
, buflen
, mem_ctx
,
891 &cd
->data
.reclock_latency
);
894 case CTDB_CONTROL_SET_LMASTERROLE
:
895 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
899 case CTDB_CONTROL_SET_RECMASTERROLE
:
900 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
904 case CTDB_CONTROL_SET_BAN_STATE
:
905 ret
= ctdb_ban_state_pull(buf
, buflen
, mem_ctx
,
906 &cd
->data
.ban_state
);
909 case CTDB_CONTROL_REGISTER_NOTIFY
:
910 ret
= ctdb_notify_data_pull(buf
, buflen
, mem_ctx
,
914 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
915 ctdb_uint64_pull(buf
, buflen
, mem_ctx
,
919 case CTDB_CONTROL_TRANS3_COMMIT
:
920 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
924 case CTDB_CONTROL_GET_DB_SEQNUM
:
925 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
929 case CTDB_CONTROL_DB_SET_HEALTHY
:
930 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
934 case CTDB_CONTROL_DB_GET_HEALTH
:
935 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
939 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
940 ret
= ctdb_sock_addr_pull(buf
, buflen
, mem_ctx
,
944 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
945 ret
= ctdb_iface_pull(buf
, buflen
, mem_ctx
,
949 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
950 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
954 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
955 ret
= ctdb_key_data_pull(buf
, buflen
, mem_ctx
,
959 case CTDB_CONTROL_SET_DB_READONLY
:
960 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
964 case CTDB_CONTROL_CHECK_SRVIDS
:
965 ret
= ctdb_uint64_array_pull(buf
, buflen
, mem_ctx
,
966 &cd
->data
.u64_array
);
969 case CTDB_CONTROL_TRAVERSE_START_EXT
:
970 ret
= ctdb_traverse_start_ext_pull(buf
, buflen
, mem_ctx
,
971 &cd
->data
.traverse_start_ext
);
974 case CTDB_CONTROL_GET_DB_STATISTICS
:
975 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
979 case CTDB_CONTROL_SET_DB_STICKY
:
980 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
984 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
985 ret
= ctdb_traverse_all_ext_pull(buf
, buflen
, mem_ctx
,
986 &cd
->data
.traverse_all_ext
);
989 case CTDB_CONTROL_RECEIVE_RECORDS
:
990 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
994 case CTDB_CONTROL_DB_DETACH
:
995 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
999 case CTDB_CONTROL_DB_FREEZE
:
1000 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
1004 case CTDB_CONTROL_DB_THAW
:
1005 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
1009 case CTDB_CONTROL_DB_TRANSACTION_START
:
1010 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
1014 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
1015 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
1019 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
1020 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
1024 case CTDB_CONTROL_DB_PULL
:
1025 ret
= ctdb_pulldb_ext_pull(buf
, buflen
, mem_ctx
,
1026 &cd
->data
.pulldb_ext
);
1029 case CTDB_CONTROL_DB_PUSH_START
:
1030 ret
= ctdb_pulldb_ext_pull(buf
, buflen
, mem_ctx
,
1031 &cd
->data
.pulldb_ext
);
1034 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1035 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
1039 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1040 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
1044 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1045 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1053 static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data
*cd
)
1061 switch (cd
->opcode
) {
1062 case CTDB_CONTROL_PROCESS_EXISTS
:
1065 case CTDB_CONTROL_STATISTICS
:
1066 len
= ctdb_statistics_len(cd
->data
.stats
);
1069 case CTDB_CONTROL_PING
:
1072 case CTDB_CONTROL_GETDBPATH
:
1073 len
= ctdb_string_len(cd
->data
.db_path
);
1076 case CTDB_CONTROL_GETVNNMAP
:
1077 len
= ctdb_vnn_map_len(cd
->data
.vnnmap
);
1080 case CTDB_CONTROL_SETVNNMAP
:
1083 case CTDB_CONTROL_GET_DEBUG
:
1084 len
= ctdb_uint32_len(cd
->data
.loglevel
);
1087 case CTDB_CONTROL_SET_DEBUG
:
1090 case CTDB_CONTROL_GET_DBMAP
:
1091 len
= ctdb_dbid_map_len(cd
->data
.dbmap
);
1094 case CTDB_CONTROL_PULL_DB
:
1095 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
1098 case CTDB_CONTROL_PUSH_DB
:
1101 case CTDB_CONTROL_GET_RECMODE
:
1104 case CTDB_CONTROL_SET_RECMODE
:
1107 case CTDB_CONTROL_STATISTICS_RESET
:
1110 case CTDB_CONTROL_DB_ATTACH
:
1111 len
= ctdb_uint32_len(cd
->data
.db_id
);
1114 case CTDB_CONTROL_SET_CALL
:
1117 case CTDB_CONTROL_TRAVERSE_START
:
1120 case CTDB_CONTROL_TRAVERSE_ALL
:
1123 case CTDB_CONTROL_TRAVERSE_DATA
:
1126 case CTDB_CONTROL_REGISTER_SRVID
:
1129 case CTDB_CONTROL_DEREGISTER_SRVID
:
1132 case CTDB_CONTROL_GET_DBNAME
:
1133 len
= ctdb_string_len(cd
->data
.db_name
);
1136 case CTDB_CONTROL_ENABLE_SEQNUM
:
1139 case CTDB_CONTROL_UPDATE_SEQNUM
:
1142 case CTDB_CONTROL_DUMP_MEMORY
:
1143 len
= ctdb_string_len(cd
->data
.mem_str
);
1146 case CTDB_CONTROL_GET_PID
:
1149 case CTDB_CONTROL_GET_RECMASTER
:
1152 case CTDB_CONTROL_SET_RECMASTER
:
1155 case CTDB_CONTROL_FREEZE
:
1158 case CTDB_CONTROL_GET_PNN
:
1161 case CTDB_CONTROL_SHUTDOWN
:
1164 case CTDB_CONTROL_GET_MONMODE
:
1167 case CTDB_CONTROL_TCP_CLIENT
:
1170 case CTDB_CONTROL_TCP_ADD
:
1173 case CTDB_CONTROL_TCP_REMOVE
:
1176 case CTDB_CONTROL_STARTUP
:
1179 case CTDB_CONTROL_SET_TUNABLE
:
1182 case CTDB_CONTROL_GET_TUNABLE
:
1183 len
= ctdb_uint32_len(cd
->data
.tun_value
);
1186 case CTDB_CONTROL_LIST_TUNABLES
:
1187 len
= ctdb_var_list_len(cd
->data
.tun_var_list
);
1190 case CTDB_CONTROL_MODIFY_FLAGS
:
1193 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1194 len
= ctdb_tunable_list_len(cd
->data
.tun_list
);
1197 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1198 len
= ctdb_tickle_list_len(cd
->data
.tickles
);
1201 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
1204 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1205 len
= ctdb_uint32_len(cd
->data
.db_id
);
1208 case CTDB_CONTROL_UPDATE_RECORD
:
1211 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
1214 case CTDB_CONTROL_WIPE_DATABASE
:
1217 case CTDB_CONTROL_UPTIME
:
1218 len
= ctdb_uptime_len(cd
->data
.uptime
);
1221 case CTDB_CONTROL_START_RECOVERY
:
1224 case CTDB_CONTROL_END_RECOVERY
:
1227 case CTDB_CONTROL_RELOAD_NODES_FILE
:
1230 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1231 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
1234 case CTDB_CONTROL_ENABLE_MONITOR
:
1237 case CTDB_CONTROL_DISABLE_MONITOR
:
1240 case CTDB_CONTROL_ADD_PUBLIC_IP
:
1243 case CTDB_CONTROL_DEL_PUBLIC_IP
:
1246 case CTDB_CONTROL_GET_CAPABILITIES
:
1247 len
= ctdb_uint32_len(cd
->data
.caps
);
1250 case CTDB_CONTROL_RECD_PING
:
1253 case CTDB_CONTROL_RELEASE_IP
:
1256 case CTDB_CONTROL_TAKEOVER_IP
:
1259 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1260 len
= ctdb_public_ip_list_len(cd
->data
.pubip_list
);
1263 case CTDB_CONTROL_GET_NODEMAP
:
1264 len
= ctdb_node_map_len(cd
->data
.nodemap
);
1267 case CTDB_CONTROL_TRAVERSE_KILL
:
1270 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
1273 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1274 len
= ctdb_string_len(cd
->data
.reclock_file
);
1277 case CTDB_CONTROL_STOP_NODE
:
1280 case CTDB_CONTROL_CONTINUE_NODE
:
1283 case CTDB_CONTROL_SET_LMASTERROLE
:
1286 case CTDB_CONTROL_SET_RECMASTERROLE
:
1289 case CTDB_CONTROL_SET_BAN_STATE
:
1292 case CTDB_CONTROL_GET_BAN_STATE
:
1293 len
= ctdb_ban_state_len(cd
->data
.ban_state
);
1296 case CTDB_CONTROL_SET_DB_PRIORITY
:
1299 case CTDB_CONTROL_GET_DB_PRIORITY
:
1302 case CTDB_CONTROL_REGISTER_NOTIFY
:
1305 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
1308 case CTDB_CONTROL_TRANS3_COMMIT
:
1311 case CTDB_CONTROL_GET_DB_SEQNUM
:
1312 len
= ctdb_uint64_len(cd
->data
.seqnum
);
1315 case CTDB_CONTROL_DB_SET_HEALTHY
:
1318 case CTDB_CONTROL_DB_GET_HEALTH
:
1319 len
= ctdb_string_len(cd
->data
.reason
);
1322 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1323 len
= ctdb_public_ip_info_len(cd
->data
.ipinfo
);
1326 case CTDB_CONTROL_GET_IFACES
:
1327 len
= ctdb_iface_list_len(cd
->data
.iface_list
);
1330 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
1333 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
1336 case CTDB_CONTROL_GET_STAT_HISTORY
:
1337 len
= ctdb_statistics_list_len(cd
->data
.stats_list
);
1340 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
1343 case CTDB_CONTROL_SET_DB_READONLY
:
1346 case CTDB_CONTROL_CHECK_SRVIDS
:
1347 len
= ctdb_uint8_array_len(cd
->data
.u8_array
);
1350 case CTDB_CONTROL_TRAVERSE_START_EXT
:
1353 case CTDB_CONTROL_GET_DB_STATISTICS
:
1354 len
= ctdb_db_statistics_len(cd
->data
.dbstats
);
1357 case CTDB_CONTROL_SET_DB_STICKY
:
1360 case CTDB_CONTROL_RELOAD_PUBLIC_IPS
:
1363 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
1366 case CTDB_CONTROL_RECEIVE_RECORDS
:
1367 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
1370 case CTDB_CONTROL_IPREALLOCATED
:
1373 case CTDB_CONTROL_GET_RUNSTATE
:
1374 len
= ctdb_uint32_len(cd
->data
.runstate
);
1377 case CTDB_CONTROL_DB_DETACH
:
1380 case CTDB_CONTROL_GET_NODES_FILE
:
1381 len
= ctdb_node_map_len(cd
->data
.nodemap
);
1384 case CTDB_CONTROL_DB_FREEZE
:
1387 case CTDB_CONTROL_DB_THAW
:
1390 case CTDB_CONTROL_DB_TRANSACTION_START
:
1393 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
1396 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
1399 case CTDB_CONTROL_DB_PULL
:
1400 len
= ctdb_uint32_len(cd
->data
.num_records
);
1403 case CTDB_CONTROL_DB_PUSH_START
:
1406 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1407 len
= ctdb_uint32_len(cd
->data
.num_records
);
1410 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1411 len
= ctdb_int32_len(cd
->data
.tdb_flags
);
1414 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1415 len
= ctdb_uint32_len(cd
->data
.db_id
);
1422 static void ctdb_reply_control_data_push(struct ctdb_reply_control_data
*cd
,
1425 switch (cd
->opcode
) {
1426 case CTDB_CONTROL_STATISTICS
:
1427 ctdb_statistics_push(cd
->data
.stats
, buf
);
1430 case CTDB_CONTROL_GETDBPATH
:
1431 ctdb_string_push(cd
->data
.db_path
, buf
);
1434 case CTDB_CONTROL_GETVNNMAP
:
1435 ctdb_vnn_map_push(cd
->data
.vnnmap
, buf
);
1438 case CTDB_CONTROL_GET_DEBUG
:
1439 ctdb_uint32_push(cd
->data
.loglevel
, buf
);
1442 case CTDB_CONTROL_GET_DBMAP
:
1443 ctdb_dbid_map_push(cd
->data
.dbmap
, buf
);
1446 case CTDB_CONTROL_PULL_DB
:
1447 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
);
1450 case CTDB_CONTROL_PUSH_DB
:
1453 case CTDB_CONTROL_DB_ATTACH
:
1454 ctdb_uint32_push(cd
->data
.db_id
, buf
);
1457 case CTDB_CONTROL_GET_DBNAME
:
1458 ctdb_string_push(cd
->data
.db_name
, buf
);
1461 case CTDB_CONTROL_DUMP_MEMORY
:
1462 ctdb_string_push(cd
->data
.mem_str
, buf
);
1465 case CTDB_CONTROL_GET_PID
:
1468 case CTDB_CONTROL_GET_RECMASTER
:
1471 case CTDB_CONTROL_GET_TUNABLE
:
1472 ctdb_uint32_push(cd
->data
.tun_value
, buf
);
1475 case CTDB_CONTROL_LIST_TUNABLES
:
1476 ctdb_var_list_push(cd
->data
.tun_var_list
, buf
);
1479 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1480 ctdb_tunable_list_push(cd
->data
.tun_list
, buf
);
1483 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1484 ctdb_tickle_list_push(cd
->data
.tickles
, buf
);
1487 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1488 ctdb_uint32_push(cd
->data
.db_id
, buf
);
1491 case CTDB_CONTROL_UPTIME
:
1492 ctdb_uptime_push(cd
->data
.uptime
, buf
);
1495 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1496 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
);
1499 case CTDB_CONTROL_GET_CAPABILITIES
:
1500 ctdb_uint32_push(cd
->data
.caps
, buf
);
1503 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1504 ctdb_public_ip_list_push(cd
->data
.pubip_list
, buf
);
1507 case CTDB_CONTROL_GET_NODEMAP
:
1508 ctdb_node_map_push(cd
->data
.nodemap
, buf
);
1511 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1512 ctdb_string_push(cd
->data
.reclock_file
, buf
);
1515 case CTDB_CONTROL_GET_BAN_STATE
:
1516 ctdb_ban_state_push(cd
->data
.ban_state
, buf
);
1519 case CTDB_CONTROL_GET_DB_PRIORITY
:
1522 case CTDB_CONTROL_GET_DB_SEQNUM
:
1523 ctdb_uint64_push(cd
->data
.seqnum
, buf
);
1526 case CTDB_CONTROL_DB_GET_HEALTH
:
1527 ctdb_string_push(cd
->data
.reason
, buf
);
1530 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1531 ctdb_public_ip_info_push(cd
->data
.ipinfo
, buf
);
1534 case CTDB_CONTROL_GET_IFACES
:
1535 ctdb_iface_list_push(cd
->data
.iface_list
, buf
);
1538 case CTDB_CONTROL_GET_STAT_HISTORY
:
1539 ctdb_statistics_list_push(cd
->data
.stats_list
, buf
);
1542 case CTDB_CONTROL_CHECK_SRVIDS
:
1543 ctdb_uint8_array_push(cd
->data
.u8_array
, buf
);
1546 case CTDB_CONTROL_GET_DB_STATISTICS
:
1547 ctdb_db_statistics_push(cd
->data
.dbstats
, buf
);
1550 case CTDB_CONTROL_RECEIVE_RECORDS
:
1551 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
);
1554 case CTDB_CONTROL_GET_RUNSTATE
:
1555 ctdb_uint32_push(cd
->data
.runstate
, buf
);
1558 case CTDB_CONTROL_GET_NODES_FILE
:
1559 ctdb_node_map_push(cd
->data
.nodemap
, buf
);
1562 case CTDB_CONTROL_DB_PULL
:
1563 ctdb_uint32_push(cd
->data
.num_records
, buf
);
1566 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1567 ctdb_uint32_push(cd
->data
.num_records
, buf
);
1570 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1571 ctdb_int32_push(cd
->data
.tdb_flags
, buf
);
1574 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1575 ctdb_uint32_push(cd
->data
.db_id
, buf
);
1580 static int ctdb_reply_control_data_pull(uint8_t *buf
, size_t buflen
,
1581 uint32_t opcode
, TALLOC_CTX
*mem_ctx
,
1582 struct ctdb_reply_control_data
*cd
)
1585 cd
->opcode
= opcode
;
1588 case CTDB_CONTROL_STATISTICS
:
1589 ret
= ctdb_statistics_pull(buf
, buflen
, mem_ctx
,
1593 case CTDB_CONTROL_GETDBPATH
:
1594 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1598 case CTDB_CONTROL_GETVNNMAP
:
1599 ret
= ctdb_vnn_map_pull(buf
, buflen
, mem_ctx
,
1603 case CTDB_CONTROL_GET_DEBUG
:
1604 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
1605 &cd
->data
.loglevel
);
1608 case CTDB_CONTROL_GET_DBMAP
:
1609 ret
= ctdb_dbid_map_pull(buf
, buflen
, mem_ctx
,
1613 case CTDB_CONTROL_PULL_DB
:
1614 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1618 case CTDB_CONTROL_PUSH_DB
:
1621 case CTDB_CONTROL_DB_ATTACH
:
1622 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
1626 case CTDB_CONTROL_GET_DBNAME
:
1627 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1631 case CTDB_CONTROL_DUMP_MEMORY
:
1632 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1636 case CTDB_CONTROL_GET_PID
:
1639 case CTDB_CONTROL_GET_RECMASTER
:
1642 case CTDB_CONTROL_GET_TUNABLE
:
1643 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
1644 &cd
->data
.tun_value
);
1647 case CTDB_CONTROL_LIST_TUNABLES
:
1648 ret
= ctdb_var_list_pull(buf
, buflen
, mem_ctx
,
1649 &cd
->data
.tun_var_list
);
1652 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1653 ret
= ctdb_tunable_list_pull(buf
, buflen
, mem_ctx
,
1654 &cd
->data
.tun_list
);
1657 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1658 ret
= ctdb_tickle_list_pull(buf
, buflen
, mem_ctx
,
1662 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1663 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
1667 case CTDB_CONTROL_UPTIME
:
1668 ret
= ctdb_uptime_pull(buf
, buflen
, mem_ctx
,
1672 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1673 ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1677 case CTDB_CONTROL_GET_CAPABILITIES
:
1678 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
1682 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1683 ret
= ctdb_public_ip_list_pull(buf
, buflen
, mem_ctx
,
1684 &cd
->data
.pubip_list
);
1687 case CTDB_CONTROL_GET_NODEMAP
:
1688 ret
= ctdb_node_map_pull(buf
, buflen
, mem_ctx
,
1692 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1693 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1694 &cd
->data
.reclock_file
);
1697 case CTDB_CONTROL_GET_BAN_STATE
:
1698 ret
= ctdb_ban_state_pull(buf
, buflen
, mem_ctx
,
1699 &cd
->data
.ban_state
);
1702 case CTDB_CONTROL_GET_DB_PRIORITY
:
1705 case CTDB_CONTROL_GET_DB_SEQNUM
:
1706 ret
= ctdb_uint64_pull(buf
, buflen
, mem_ctx
,
1710 case CTDB_CONTROL_DB_GET_HEALTH
:
1711 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1715 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1716 ret
= ctdb_public_ip_info_pull(buf
, buflen
, mem_ctx
,
1720 case CTDB_CONTROL_GET_IFACES
:
1721 ret
= ctdb_iface_list_pull(buf
, buflen
, mem_ctx
,
1722 &cd
->data
.iface_list
);
1725 case CTDB_CONTROL_GET_STAT_HISTORY
:
1726 ret
= ctdb_statistics_list_pull(buf
, buflen
, mem_ctx
,
1727 &cd
->data
.stats_list
);
1730 case CTDB_CONTROL_CHECK_SRVIDS
:
1731 ret
= ctdb_uint8_array_pull(buf
, buflen
, mem_ctx
,
1732 &cd
->data
.u8_array
);
1735 case CTDB_CONTROL_GET_DB_STATISTICS
:
1736 ret
= ctdb_db_statistics_pull(buf
, buflen
, mem_ctx
,
1740 case CTDB_CONTROL_RECEIVE_RECORDS
:
1741 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1745 case CTDB_CONTROL_GET_RUNSTATE
:
1746 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
1747 &cd
->data
.runstate
);
1750 case CTDB_CONTROL_GET_NODES_FILE
:
1751 ret
= ctdb_node_map_pull(buf
, buflen
, mem_ctx
,
1755 case CTDB_CONTROL_DB_PULL
:
1756 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
1757 &cd
->data
.num_records
);
1760 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1761 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
1762 &cd
->data
.num_records
);
1765 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1766 ret
= ctdb_int32_pull(buf
, buflen
, mem_ctx
,
1767 &cd
->data
.tdb_flags
);
1770 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1771 ret
= ctdb_uint32_pull(buf
, buflen
, mem_ctx
,
1779 size_t ctdb_req_control_len(struct ctdb_req_header
*h
,
1780 struct ctdb_req_control
*c
)
1782 return offsetof(struct ctdb_req_control_wire
, data
) +
1783 ctdb_req_control_data_len(&c
->rdata
);
1786 int ctdb_req_control_push(struct ctdb_req_header
*h
,
1787 struct ctdb_req_control
*request
,
1788 uint8_t *buf
, size_t *buflen
)
1790 struct ctdb_req_control_wire
*wire
=
1791 (struct ctdb_req_control_wire
*)buf
;
1794 length
= ctdb_req_control_len(h
, request
);
1795 if (*buflen
< length
) {
1800 h
->length
= *buflen
;
1801 ctdb_req_header_push(h
, (uint8_t *)&wire
->hdr
);
1803 wire
->opcode
= request
->opcode
;
1804 wire
->pad
= request
->pad
;
1805 wire
->srvid
= request
->srvid
;
1806 wire
->client_id
= request
->client_id
;
1807 wire
->flags
= request
->flags
;
1809 wire
->datalen
= ctdb_req_control_data_len(&request
->rdata
);
1810 ctdb_req_control_data_push(&request
->rdata
, wire
->data
);
1815 int ctdb_req_control_pull(uint8_t *buf
, size_t buflen
,
1816 struct ctdb_req_header
*h
,
1817 TALLOC_CTX
*mem_ctx
,
1818 struct ctdb_req_control
*c
)
1820 struct ctdb_req_control_wire
*wire
=
1821 (struct ctdb_req_control_wire
*)buf
;
1825 length
= offsetof(struct ctdb_req_control_wire
, data
);
1826 if (buflen
< length
) {
1829 if (wire
->datalen
> buflen
) {
1832 if (length
+ wire
->datalen
< length
) {
1835 if (buflen
< length
+ wire
->datalen
) {
1840 ret
= ctdb_req_header_pull((uint8_t *)&wire
->hdr
, buflen
, h
);
1846 c
->opcode
= wire
->opcode
;
1848 c
->srvid
= wire
->srvid
;
1849 c
->client_id
= wire
->client_id
;
1850 c
->flags
= wire
->flags
;
1852 ret
= ctdb_req_control_data_pull(wire
->data
, wire
->datalen
,
1853 c
->opcode
, mem_ctx
, &c
->rdata
);
1861 size_t ctdb_reply_control_len(struct ctdb_req_header
*h
,
1862 struct ctdb_reply_control
*c
)
1864 return offsetof(struct ctdb_reply_control_wire
, data
) +
1866 ctdb_reply_control_data_len(&c
->rdata
) :
1867 ctdb_string_len(c
->errmsg
));
1870 int ctdb_reply_control_push(struct ctdb_req_header
*h
,
1871 struct ctdb_reply_control
*reply
,
1872 uint8_t *buf
, size_t *buflen
)
1874 struct ctdb_reply_control_wire
*wire
=
1875 (struct ctdb_reply_control_wire
*)buf
;
1878 length
= ctdb_reply_control_len(h
, reply
);
1879 if (*buflen
< length
) {
1884 h
->length
= *buflen
;
1885 ctdb_req_header_push(h
, (uint8_t *)&wire
->hdr
);
1887 wire
->status
= reply
->status
;
1889 if (reply
->status
== 0) {
1890 wire
->datalen
= ctdb_reply_control_data_len(&reply
->rdata
);
1892 ctdb_reply_control_data_push(&reply
->rdata
, wire
->data
);
1895 wire
->errorlen
= ctdb_string_len(reply
->errmsg
);
1896 ctdb_string_push(reply
->errmsg
, wire
->data
+ wire
->datalen
);
1902 int ctdb_reply_control_pull(uint8_t *buf
, size_t buflen
, uint32_t opcode
,
1903 struct ctdb_req_header
*h
,
1904 TALLOC_CTX
*mem_ctx
,
1905 struct ctdb_reply_control
*c
)
1907 struct ctdb_reply_control_wire
*wire
=
1908 (struct ctdb_reply_control_wire
*)buf
;
1912 length
= offsetof(struct ctdb_reply_control_wire
, data
);
1913 if (buflen
< length
) {
1916 if (wire
->datalen
> buflen
|| wire
->errorlen
> buflen
) {
1919 if (length
+ wire
->datalen
< length
) {
1922 if (length
+ wire
->datalen
+ wire
->errorlen
< length
) {
1925 if (buflen
< length
+ wire
->datalen
+ wire
->errorlen
) {
1930 ret
= ctdb_req_header_pull((uint8_t *)&wire
->hdr
, buflen
, h
);
1936 c
->status
= wire
->status
;
1938 if (c
->status
!= -1) {
1939 ret
= ctdb_reply_control_data_pull(wire
->data
, wire
->datalen
,
1947 ret
= ctdb_string_pull(wire
->data
+ wire
->datalen
, wire
->errorlen
,
1948 mem_ctx
, &c
->errmsg
);