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)
59 case CTDB_CONTROL_PROCESS_EXISTS:
60 len = ctdb_pid_len(&cd->data.pid);
63 case CTDB_CONTROL_STATISTICS:
66 case CTDB_CONTROL_PING:
69 case CTDB_CONTROL_GETDBPATH:
70 len = ctdb_uint32_len(&cd->data.db_id);
73 case CTDB_CONTROL_GETVNNMAP:
76 case CTDB_CONTROL_SETVNNMAP:
77 len = ctdb_vnn_map_len(cd->data.vnnmap);
80 case CTDB_CONTROL_GET_DEBUG:
83 case CTDB_CONTROL_SET_DEBUG:
84 len = ctdb_uint32_len(&cd->data.loglevel);
87 case CTDB_CONTROL_GET_DBMAP:
90 case CTDB_CONTROL_PULL_DB:
91 len = ctdb_pulldb_len(cd->data.pulldb);
94 case CTDB_CONTROL_PUSH_DB:
95 len = ctdb_rec_buffer_len(cd->data.recbuf);
98 case CTDB_CONTROL_GET_RECMODE:
101 case CTDB_CONTROL_SET_RECMODE:
102 len = ctdb_uint32_len(&cd->data.recmode);
105 case CTDB_CONTROL_STATISTICS_RESET:
108 case CTDB_CONTROL_DB_ATTACH:
109 len = ctdb_string_len(&cd->data.db_name);
112 case CTDB_CONTROL_SET_CALL:
115 case CTDB_CONTROL_TRAVERSE_START:
116 len = ctdb_traverse_start_len(cd->data.traverse_start);
119 case CTDB_CONTROL_TRAVERSE_ALL:
120 len = ctdb_traverse_all_len(cd->data.traverse_all);
123 case CTDB_CONTROL_TRAVERSE_DATA:
124 len = ctdb_rec_data_len(cd->data.rec_data);
127 case CTDB_CONTROL_REGISTER_SRVID:
130 case CTDB_CONTROL_DEREGISTER_SRVID:
133 case CTDB_CONTROL_GET_DBNAME:
134 len = ctdb_uint32_len(&cd->data.db_id);
137 case CTDB_CONTROL_ENABLE_SEQNUM:
138 len = ctdb_uint32_len(&cd->data.db_id);
141 case CTDB_CONTROL_UPDATE_SEQNUM:
142 len = ctdb_uint32_len(&cd->data.db_id);
145 case CTDB_CONTROL_DUMP_MEMORY:
148 case CTDB_CONTROL_GET_PID:
151 case CTDB_CONTROL_GET_RECMASTER:
154 case CTDB_CONTROL_SET_RECMASTER:
155 len = ctdb_uint32_len(&cd->data.recmaster);
158 case CTDB_CONTROL_FREEZE:
161 case CTDB_CONTROL_GET_PNN:
164 case CTDB_CONTROL_SHUTDOWN:
167 case CTDB_CONTROL_GET_MONMODE:
170 case CTDB_CONTROL_TCP_CLIENT:
171 len = ctdb_connection_len(cd->data.conn);
174 case CTDB_CONTROL_TCP_ADD:
175 len = ctdb_connection_len(cd->data.conn);
178 case CTDB_CONTROL_TCP_REMOVE:
179 len = ctdb_connection_len(cd->data.conn);
182 case CTDB_CONTROL_STARTUP:
185 case CTDB_CONTROL_SET_TUNABLE:
186 len = ctdb_tunable_len(cd->data.tunable);
189 case CTDB_CONTROL_GET_TUNABLE:
190 len = ctdb_stringn_len(&cd->data.tun_var);
193 case CTDB_CONTROL_LIST_TUNABLES:
196 case CTDB_CONTROL_MODIFY_FLAGS:
197 len = ctdb_node_flag_change_len(cd->data.flag_change);
200 case CTDB_CONTROL_GET_ALL_TUNABLES:
203 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
204 len = ctdb_sock_addr_len(cd->data.addr);
207 case CTDB_CONTROL_SET_TCP_TICKLE_LIST:
208 len = ctdb_tickle_list_len(cd->data.tickles);
211 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
212 len = ctdb_string_len(&cd->data.db_name);
215 case CTDB_CONTROL_UPDATE_RECORD:
216 len = ctdb_rec_buffer_len(cd->data.recbuf);
219 case CTDB_CONTROL_SEND_GRATUITOUS_ARP:
220 len = ctdb_addr_info_len(cd->data.addr_info);
223 case CTDB_CONTROL_WIPE_DATABASE:
224 len = ctdb_transdb_len(cd->data.transdb);
227 case CTDB_CONTROL_UPTIME:
230 case CTDB_CONTROL_START_RECOVERY:
233 case CTDB_CONTROL_END_RECOVERY:
236 case CTDB_CONTROL_RELOAD_NODES_FILE:
239 case CTDB_CONTROL_TRY_DELETE_RECORDS:
240 len = ctdb_rec_buffer_len(cd->data.recbuf);
243 case CTDB_CONTROL_ENABLE_MONITOR:
246 case CTDB_CONTROL_DISABLE_MONITOR:
249 case CTDB_CONTROL_ADD_PUBLIC_IP:
250 len = ctdb_addr_info_len(cd->data.addr_info);
253 case CTDB_CONTROL_DEL_PUBLIC_IP:
254 len = ctdb_addr_info_len(cd->data.addr_info);
257 case CTDB_CONTROL_GET_CAPABILITIES:
260 case CTDB_CONTROL_RECD_PING:
263 case CTDB_CONTROL_RELEASE_IP:
264 len = ctdb_public_ip_len(cd->data.pubip);
267 case CTDB_CONTROL_TAKEOVER_IP:
268 len = ctdb_public_ip_len(cd->data.pubip);
271 case CTDB_CONTROL_GET_PUBLIC_IPS:
274 case CTDB_CONTROL_GET_NODEMAP:
277 case CTDB_CONTROL_TRAVERSE_KILL:
278 len = ctdb_traverse_start_len(cd->data.traverse_start);
281 case CTDB_CONTROL_RECD_RECLOCK_LATENCY:
282 len = ctdb_double_len(&cd->data.reclock_latency);
285 case CTDB_CONTROL_GET_RECLOCK_FILE:
288 case CTDB_CONTROL_STOP_NODE:
291 case CTDB_CONTROL_CONTINUE_NODE:
294 case CTDB_CONTROL_SET_LMASTERROLE:
295 len = ctdb_uint32_len(&cd->data.role);
298 case CTDB_CONTROL_SET_RECMASTERROLE:
299 len = ctdb_uint32_len(&cd->data.role);
302 case CTDB_CONTROL_SET_BAN_STATE:
303 len = ctdb_ban_state_len(cd->data.ban_state);
306 case CTDB_CONTROL_GET_BAN_STATE:
309 case CTDB_CONTROL_REGISTER_NOTIFY:
310 len = ctdb_notify_data_len(cd->data.notify);
313 case CTDB_CONTROL_DEREGISTER_NOTIFY:
314 len = ctdb_uint64_len(&cd->data.srvid);
317 case CTDB_CONTROL_TRANS3_COMMIT:
318 len = ctdb_rec_buffer_len(cd->data.recbuf);
321 case CTDB_CONTROL_GET_DB_SEQNUM:
323 len = ctdb_uint32_len(&cd->data.db_id) + ctdb_uint32_len(&u32);
326 case CTDB_CONTROL_DB_SET_HEALTHY:
327 len = ctdb_uint32_len(&cd->data.db_id);
330 case CTDB_CONTROL_DB_GET_HEALTH:
331 len = ctdb_uint32_len(&cd->data.db_id);
334 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
335 len = ctdb_sock_addr_len(cd->data.addr);
338 case CTDB_CONTROL_GET_IFACES:
341 case CTDB_CONTROL_SET_IFACE_LINK_STATE:
342 len = ctdb_iface_len(cd->data.iface);
345 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE:
346 len = ctdb_connection_len(cd->data.conn);
349 case CTDB_CONTROL_GET_STAT_HISTORY:
352 case CTDB_CONTROL_SCHEDULE_FOR_DELETION:
353 len = ctdb_key_data_len(cd->data.key);
356 case CTDB_CONTROL_SET_DB_READONLY:
357 len = ctdb_uint32_len(&cd->data.db_id);
360 case CTDB_CONTROL_CHECK_SRVIDS:
363 case CTDB_CONTROL_TRAVERSE_START_EXT:
364 len = ctdb_traverse_start_ext_len(cd->data.traverse_start_ext);
367 case CTDB_CONTROL_GET_DB_STATISTICS:
368 len = ctdb_uint32_len(&cd->data.db_id);
371 case CTDB_CONTROL_SET_DB_STICKY:
372 len = ctdb_uint32_len(&cd->data.db_id);
375 case CTDB_CONTROL_RELOAD_PUBLIC_IPS:
378 case CTDB_CONTROL_TRAVERSE_ALL_EXT:
379 len = ctdb_traverse_all_ext_len(cd->data.traverse_all_ext);
382 case CTDB_CONTROL_RECEIVE_RECORDS:
383 len = ctdb_rec_buffer_len(cd->data.recbuf);
386 case CTDB_CONTROL_IPREALLOCATED:
389 case CTDB_CONTROL_GET_RUNSTATE:
392 case CTDB_CONTROL_DB_DETACH:
393 len = ctdb_uint32_len(&cd->data.db_id);
396 case CTDB_CONTROL_GET_NODES_FILE:
399 case CTDB_CONTROL_DB_FREEZE:
400 len = ctdb_uint32_len(&cd->data.db_id);
403 case CTDB_CONTROL_DB_THAW:
404 len = ctdb_uint32_len(&cd->data.db_id);
407 case CTDB_CONTROL_DB_TRANSACTION_START:
408 len = ctdb_transdb_len(cd->data.transdb);
411 case CTDB_CONTROL_DB_TRANSACTION_COMMIT:
412 len = ctdb_transdb_len(cd->data.transdb);
415 case CTDB_CONTROL_DB_TRANSACTION_CANCEL:
416 len = ctdb_uint32_len(&cd->data.db_id);
419 case CTDB_CONTROL_DB_PULL:
420 len = ctdb_pulldb_ext_len(cd->data.pulldb_ext);
423 case CTDB_CONTROL_DB_PUSH_START:
424 len = ctdb_pulldb_ext_len(cd->data.pulldb_ext);
427 case CTDB_CONTROL_DB_PUSH_CONFIRM:
428 len = ctdb_uint32_len(&cd->data.db_id);
431 case CTDB_CONTROL_DB_OPEN_FLAGS:
432 len = ctdb_uint32_len(&cd->data.db_id);
435 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
436 len = ctdb_string_len(&cd->data.db_name);
443 static void ctdb_req_control_data_push(struct ctdb_req_control_data *cd,
449 switch (cd->opcode) {
450 case CTDB_CONTROL_PROCESS_EXISTS:
451 ctdb_pid_push(&cd->data.pid, buf, &np);
454 case CTDB_CONTROL_GETDBPATH:
455 ctdb_uint32_push(&cd->data.db_id, buf, &np);
458 case CTDB_CONTROL_SETVNNMAP:
459 ctdb_vnn_map_push(cd->data.vnnmap, buf, &np);
462 case CTDB_CONTROL_SET_DEBUG:
463 ctdb_uint32_push(&cd->data.loglevel, buf, &np);
466 case CTDB_CONTROL_PULL_DB:
467 ctdb_pulldb_push(cd->data.pulldb, buf, &np);
470 case CTDB_CONTROL_PUSH_DB:
471 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
474 case CTDB_CONTROL_SET_RECMODE:
475 ctdb_uint32_push(&cd->data.recmode, buf, &np);
478 case CTDB_CONTROL_DB_ATTACH:
479 ctdb_string_push(&cd->data.db_name, buf, &np);
482 case CTDB_CONTROL_SET_CALL:
485 case CTDB_CONTROL_TRAVERSE_START:
486 ctdb_traverse_start_push(cd->data.traverse_start, buf, &np);
489 case CTDB_CONTROL_TRAVERSE_ALL:
490 ctdb_traverse_all_push(cd->data.traverse_all, buf, &np);
493 case CTDB_CONTROL_TRAVERSE_DATA:
494 ctdb_rec_data_push(cd->data.rec_data, buf, &np);
497 case CTDB_CONTROL_GET_DBNAME:
498 ctdb_uint32_push(&cd->data.db_id, buf, &np);
501 case CTDB_CONTROL_ENABLE_SEQNUM:
502 ctdb_uint32_push(&cd->data.db_id, buf, &np);
505 case CTDB_CONTROL_UPDATE_SEQNUM:
506 ctdb_uint32_push(&cd->data.db_id, buf, &np);
509 case CTDB_CONTROL_SET_RECMASTER:
510 ctdb_uint32_push(&cd->data.recmaster, buf, &np);
513 case CTDB_CONTROL_TCP_CLIENT:
514 ctdb_connection_push(cd->data.conn, buf, &np);
517 case CTDB_CONTROL_TCP_ADD:
518 ctdb_connection_push(cd->data.conn, buf, &np);
521 case CTDB_CONTROL_TCP_REMOVE:
522 ctdb_connection_push(cd->data.conn, buf, &np);
525 case CTDB_CONTROL_SET_TUNABLE:
526 ctdb_tunable_push(cd->data.tunable, buf, &np);
529 case CTDB_CONTROL_GET_TUNABLE:
530 ctdb_stringn_push(&cd->data.tun_var, buf, &np);
533 case CTDB_CONTROL_MODIFY_FLAGS:
534 ctdb_node_flag_change_push(cd->data.flag_change, buf, &np);
537 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
538 ctdb_sock_addr_push(cd->data.addr, buf, &np);
541 case CTDB_CONTROL_SET_TCP_TICKLE_LIST:
542 ctdb_tickle_list_push(cd->data.tickles, buf, &np);
545 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
546 ctdb_string_push(&cd->data.db_name, buf, &np);
549 case CTDB_CONTROL_UPDATE_RECORD:
550 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
553 case CTDB_CONTROL_SEND_GRATUITOUS_ARP:
554 ctdb_addr_info_push(cd->data.addr_info, buf, &np);
557 case CTDB_CONTROL_WIPE_DATABASE:
558 ctdb_transdb_push(cd->data.transdb, buf, &np);
561 case CTDB_CONTROL_TRY_DELETE_RECORDS:
562 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
565 case CTDB_CONTROL_ADD_PUBLIC_IP:
566 ctdb_addr_info_push(cd->data.addr_info, buf, &np);
569 case CTDB_CONTROL_DEL_PUBLIC_IP:
570 ctdb_addr_info_push(cd->data.addr_info, buf, &np);
573 case CTDB_CONTROL_RELEASE_IP:
574 ctdb_public_ip_push(cd->data.pubip, buf);
577 case CTDB_CONTROL_TAKEOVER_IP:
578 ctdb_public_ip_push(cd->data.pubip, buf);
581 case CTDB_CONTROL_TRAVERSE_KILL:
582 ctdb_traverse_start_push(cd->data.traverse_start, buf, &np);
585 case CTDB_CONTROL_RECD_RECLOCK_LATENCY:
586 ctdb_double_push(&cd->data.reclock_latency, buf, &np);
589 case CTDB_CONTROL_SET_LMASTERROLE:
590 ctdb_uint32_push(&cd->data.role, buf, &np);
593 case CTDB_CONTROL_SET_RECMASTERROLE:
594 ctdb_uint32_push(&cd->data.role, buf, &np);
597 case CTDB_CONTROL_SET_BAN_STATE:
598 ctdb_ban_state_push(cd->data.ban_state, buf);
601 case CTDB_CONTROL_REGISTER_NOTIFY:
602 ctdb_notify_data_push(cd->data.notify, buf);
605 case CTDB_CONTROL_DEREGISTER_NOTIFY:
606 ctdb_uint64_push(&cd->data.srvid, buf, &np);
609 case CTDB_CONTROL_TRANS3_COMMIT:
610 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
613 case CTDB_CONTROL_GET_DB_SEQNUM:
616 ctdb_uint32_push(&cd->data.db_id, buf, &np);
618 ctdb_uint32_push(&u32, buf+offset, &np);
623 case CTDB_CONTROL_DB_SET_HEALTHY:
624 ctdb_uint32_push(&cd->data.db_id, buf, &np);
627 case CTDB_CONTROL_DB_GET_HEALTH:
628 ctdb_uint32_push(&cd->data.db_id, buf, &np);
631 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
632 ctdb_sock_addr_push(cd->data.addr, buf, &np);
635 case CTDB_CONTROL_SET_IFACE_LINK_STATE:
636 ctdb_iface_push(cd->data.iface, buf);
639 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE:
640 ctdb_connection_push(cd->data.conn, buf, &np);
643 case CTDB_CONTROL_SCHEDULE_FOR_DELETION:
644 ctdb_key_data_push(cd->data.key, buf);
647 case CTDB_CONTROL_SET_DB_READONLY:
648 ctdb_uint32_push(&cd->data.db_id, buf, &np);
651 case CTDB_CONTROL_CHECK_SRVIDS:
654 case CTDB_CONTROL_TRAVERSE_START_EXT:
655 ctdb_traverse_start_ext_push(cd->data.traverse_start_ext, buf,
659 case CTDB_CONTROL_GET_DB_STATISTICS:
660 ctdb_uint32_push(&cd->data.db_id, buf, &np);
663 case CTDB_CONTROL_SET_DB_STICKY:
664 ctdb_uint32_push(&cd->data.db_id, buf, &np);
667 case CTDB_CONTROL_TRAVERSE_ALL_EXT:
668 ctdb_traverse_all_ext_push(cd->data.traverse_all_ext, buf,
672 case CTDB_CONTROL_RECEIVE_RECORDS:
673 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
676 case CTDB_CONTROL_DB_DETACH:
677 ctdb_uint32_push(&cd->data.db_id, buf, &np);
680 case CTDB_CONTROL_DB_FREEZE:
681 ctdb_uint32_push(&cd->data.db_id, buf, &np);
684 case CTDB_CONTROL_DB_THAW:
685 ctdb_uint32_push(&cd->data.db_id, buf, &np);
688 case CTDB_CONTROL_DB_TRANSACTION_START:
689 ctdb_transdb_push(cd->data.transdb, buf, &np);
692 case CTDB_CONTROL_DB_TRANSACTION_COMMIT:
693 ctdb_transdb_push(cd->data.transdb, buf, &np);
696 case CTDB_CONTROL_DB_TRANSACTION_CANCEL:
697 ctdb_uint32_push(&cd->data.db_id, buf, &np);
700 case CTDB_CONTROL_DB_PULL:
701 ctdb_pulldb_ext_push(cd->data.pulldb_ext, buf, &np);
704 case CTDB_CONTROL_DB_PUSH_START:
705 ctdb_pulldb_ext_push(cd->data.pulldb_ext, buf, &np);
708 case CTDB_CONTROL_DB_PUSH_CONFIRM:
709 ctdb_uint32_push(&cd->data.db_id, buf, &np);
712 case CTDB_CONTROL_DB_OPEN_FLAGS:
713 ctdb_uint32_push(&cd->data.db_id, buf, &np);
716 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
717 ctdb_string_push(&cd->data.db_name, buf, &np);
722 static int ctdb_req_control_data_pull(uint8_t *buf, size_t buflen,
725 struct ctdb_req_control_data *cd)
734 case CTDB_CONTROL_PROCESS_EXISTS:
735 ret = ctdb_pid_pull(buf, buflen, &cd->data.pid, &np);
738 case CTDB_CONTROL_GETDBPATH:
739 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
742 case CTDB_CONTROL_SETVNNMAP:
743 ret = ctdb_vnn_map_pull(buf, buflen, mem_ctx,
744 &cd->data.vnnmap, &np);
747 case CTDB_CONTROL_SET_DEBUG:
748 ret = ctdb_uint32_pull(buf, buflen, &cd->data.loglevel, &np);
751 case CTDB_CONTROL_PULL_DB:
752 ret = ctdb_pulldb_pull(buf, buflen, mem_ctx,
753 &cd->data.pulldb, &np);
756 case CTDB_CONTROL_PUSH_DB:
757 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
758 &cd->data.recbuf, &np);
761 case CTDB_CONTROL_SET_RECMODE:
762 ret = ctdb_uint32_pull(buf, buflen, &cd->data.recmode, &np);
765 case CTDB_CONTROL_DB_ATTACH:
766 ret = ctdb_string_pull(buf, buflen, mem_ctx,
767 &cd->data.db_name, &np);
770 case CTDB_CONTROL_SET_CALL:
773 case CTDB_CONTROL_TRAVERSE_START:
774 ret = ctdb_traverse_start_pull(buf, buflen, mem_ctx,
775 &cd->data.traverse_start, &np);
778 case CTDB_CONTROL_TRAVERSE_ALL:
779 ret = ctdb_traverse_all_pull(buf, buflen, mem_ctx,
780 &cd->data.traverse_all, &np);
783 case CTDB_CONTROL_TRAVERSE_DATA:
784 ret = ctdb_rec_data_pull(buf, buflen, mem_ctx,
785 &cd->data.rec_data, &np);
788 case CTDB_CONTROL_GET_DBNAME:
789 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
792 case CTDB_CONTROL_ENABLE_SEQNUM:
793 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
796 case CTDB_CONTROL_UPDATE_SEQNUM:
797 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
800 case CTDB_CONTROL_SET_RECMASTER:
801 ret = ctdb_uint32_pull(buf, buflen, &cd->data.recmaster, &np);
804 case CTDB_CONTROL_TCP_CLIENT:
805 ret = ctdb_connection_pull(buf, buflen, mem_ctx,
806 &cd->data.conn, &np);
809 case CTDB_CONTROL_TCP_ADD:
810 ret = ctdb_connection_pull(buf, buflen, mem_ctx,
811 &cd->data.conn, &np);
814 case CTDB_CONTROL_TCP_REMOVE:
815 ret = ctdb_connection_pull(buf, buflen, mem_ctx,
816 &cd->data.conn, &np);
819 case CTDB_CONTROL_SET_TUNABLE:
820 ret = ctdb_tunable_pull(buf, buflen, mem_ctx,
821 &cd->data.tunable, &np);
824 case CTDB_CONTROL_GET_TUNABLE:
825 ret = ctdb_stringn_pull(buf, buflen, mem_ctx,
826 &cd->data.tun_var, &np);
829 case CTDB_CONTROL_MODIFY_FLAGS:
830 ret = ctdb_node_flag_change_pull(buf, buflen, mem_ctx,
831 &cd->data.flag_change, &np);
834 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
835 ret = ctdb_sock_addr_pull(buf, buflen, mem_ctx,
836 &cd->data.addr, &np);
839 case CTDB_CONTROL_SET_TCP_TICKLE_LIST:
840 ret = ctdb_tickle_list_pull(buf, buflen, mem_ctx,
841 &cd->data.tickles, &np);
844 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
845 ret = ctdb_string_pull(buf, buflen, mem_ctx,
846 &cd->data.db_name, &np);
849 case CTDB_CONTROL_UPDATE_RECORD:
850 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
851 &cd->data.recbuf, &np);
854 case CTDB_CONTROL_SEND_GRATUITOUS_ARP:
855 ret = ctdb_addr_info_pull(buf, buflen, mem_ctx,
856 &cd->data.addr_info, &np);
859 case CTDB_CONTROL_WIPE_DATABASE:
860 ret = ctdb_transdb_pull(buf, buflen, mem_ctx,
861 &cd->data.transdb, &np);
864 case CTDB_CONTROL_TRY_DELETE_RECORDS:
865 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
866 &cd->data.recbuf, &np);
869 case CTDB_CONTROL_ADD_PUBLIC_IP:
870 ret = ctdb_addr_info_pull(buf, buflen, mem_ctx,
871 &cd->data.addr_info, &np);
874 case CTDB_CONTROL_DEL_PUBLIC_IP:
875 ret = ctdb_addr_info_pull(buf, buflen, mem_ctx,
876 &cd->data.addr_info, &np);
879 case CTDB_CONTROL_RELEASE_IP:
880 ret = ctdb_public_ip_pull(buf, buflen, mem_ctx,
884 case CTDB_CONTROL_TAKEOVER_IP:
885 ret = ctdb_public_ip_pull(buf, buflen, mem_ctx,
889 case CTDB_CONTROL_TRAVERSE_KILL:
890 ret = ctdb_traverse_start_pull(buf, buflen, mem_ctx,
891 &cd->data.traverse_start, &np);
894 case CTDB_CONTROL_RECD_RECLOCK_LATENCY:
895 ret = ctdb_double_pull(buf, buflen, &cd->data.reclock_latency,
899 case CTDB_CONTROL_SET_LMASTERROLE:
900 ret = ctdb_uint32_pull(buf, buflen, &cd->data.role, &np);
903 case CTDB_CONTROL_SET_RECMASTERROLE:
904 ret = ctdb_uint32_pull(buf, buflen, &cd->data.role, &np);
907 case CTDB_CONTROL_SET_BAN_STATE:
908 ret = ctdb_ban_state_pull(buf, buflen, mem_ctx,
909 &cd->data.ban_state);
912 case CTDB_CONTROL_REGISTER_NOTIFY:
913 ret = ctdb_notify_data_pull(buf, buflen, mem_ctx,
917 case CTDB_CONTROL_DEREGISTER_NOTIFY:
918 ctdb_uint64_pull(buf, buflen, &cd->data.srvid, &np);
921 case CTDB_CONTROL_TRANS3_COMMIT:
922 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
923 &cd->data.recbuf, &np);
926 case CTDB_CONTROL_GET_DB_SEQNUM:
928 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
933 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &u32, &np);
938 case CTDB_CONTROL_DB_SET_HEALTHY:
939 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
942 case CTDB_CONTROL_DB_GET_HEALTH:
943 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
946 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
947 ret = ctdb_sock_addr_pull(buf, buflen, mem_ctx,
948 &cd->data.addr, &np);
951 case CTDB_CONTROL_SET_IFACE_LINK_STATE:
952 ret = ctdb_iface_pull(buf, buflen, mem_ctx,
956 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE:
957 ret = ctdb_connection_pull(buf, buflen, mem_ctx,
958 &cd->data.conn, &np);
961 case CTDB_CONTROL_SCHEDULE_FOR_DELETION:
962 ret = ctdb_key_data_pull(buf, buflen, mem_ctx,
966 case CTDB_CONTROL_SET_DB_READONLY:
967 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
970 case CTDB_CONTROL_CHECK_SRVIDS:
973 case CTDB_CONTROL_TRAVERSE_START_EXT:
974 ret = ctdb_traverse_start_ext_pull(buf, buflen, mem_ctx,
975 &cd->data.traverse_start_ext,
979 case CTDB_CONTROL_GET_DB_STATISTICS:
980 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
983 case CTDB_CONTROL_SET_DB_STICKY:
984 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
987 case CTDB_CONTROL_TRAVERSE_ALL_EXT:
988 ret = ctdb_traverse_all_ext_pull(buf, buflen, mem_ctx,
989 &cd->data.traverse_all_ext,
993 case CTDB_CONTROL_RECEIVE_RECORDS:
994 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
995 &cd->data.recbuf, &np);
998 case CTDB_CONTROL_DB_DETACH:
999 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1002 case CTDB_CONTROL_DB_FREEZE:
1003 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1006 case CTDB_CONTROL_DB_THAW:
1007 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1010 case CTDB_CONTROL_DB_TRANSACTION_START:
1011 ret = ctdb_transdb_pull(buf, buflen, mem_ctx,
1012 &cd->data.transdb, &np);
1015 case CTDB_CONTROL_DB_TRANSACTION_COMMIT:
1016 ret = ctdb_transdb_pull(buf, buflen, mem_ctx,
1017 &cd->data.transdb, &np);
1020 case CTDB_CONTROL_DB_TRANSACTION_CANCEL:
1021 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1024 case CTDB_CONTROL_DB_PULL:
1025 ret = ctdb_pulldb_ext_pull(buf, buflen, mem_ctx,
1026 &cd->data.pulldb_ext, &np);
1029 case CTDB_CONTROL_DB_PUSH_START:
1030 ret = ctdb_pulldb_ext_pull(buf, buflen, mem_ctx,
1031 &cd->data.pulldb_ext, &np);
1034 case CTDB_CONTROL_DB_PUSH_CONFIRM:
1035 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1038 case CTDB_CONTROL_DB_OPEN_FLAGS:
1039 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1042 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
1043 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1044 &cd->data.db_name, &np);
1051 static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data *cd)
1059 switch (cd->opcode) {
1060 case CTDB_CONTROL_PROCESS_EXISTS:
1063 case CTDB_CONTROL_STATISTICS:
1064 len = ctdb_statistics_len(cd->data.stats);
1067 case CTDB_CONTROL_PING:
1070 case CTDB_CONTROL_GETDBPATH:
1071 len = ctdb_string_len(&cd->data.db_path);
1074 case CTDB_CONTROL_GETVNNMAP:
1075 len = ctdb_vnn_map_len(cd->data.vnnmap);
1078 case CTDB_CONTROL_SETVNNMAP:
1081 case CTDB_CONTROL_GET_DEBUG:
1082 len = ctdb_uint32_len(&cd->data.loglevel);
1085 case CTDB_CONTROL_SET_DEBUG:
1088 case CTDB_CONTROL_GET_DBMAP:
1089 len = ctdb_dbid_map_len(cd->data.dbmap);
1092 case CTDB_CONTROL_PULL_DB:
1093 len = ctdb_rec_buffer_len(cd->data.recbuf);
1096 case CTDB_CONTROL_PUSH_DB:
1099 case CTDB_CONTROL_GET_RECMODE:
1102 case CTDB_CONTROL_SET_RECMODE:
1105 case CTDB_CONTROL_STATISTICS_RESET:
1108 case CTDB_CONTROL_DB_ATTACH:
1109 len = ctdb_uint32_len(&cd->data.db_id);
1112 case CTDB_CONTROL_SET_CALL:
1115 case CTDB_CONTROL_TRAVERSE_START:
1118 case CTDB_CONTROL_TRAVERSE_ALL:
1121 case CTDB_CONTROL_TRAVERSE_DATA:
1124 case CTDB_CONTROL_REGISTER_SRVID:
1127 case CTDB_CONTROL_DEREGISTER_SRVID:
1130 case CTDB_CONTROL_GET_DBNAME:
1131 len = ctdb_string_len(&cd->data.db_name);
1134 case CTDB_CONTROL_ENABLE_SEQNUM:
1137 case CTDB_CONTROL_UPDATE_SEQNUM:
1140 case CTDB_CONTROL_DUMP_MEMORY:
1141 len = ctdb_string_len(&cd->data.mem_str);
1144 case CTDB_CONTROL_GET_PID:
1147 case CTDB_CONTROL_GET_RECMASTER:
1150 case CTDB_CONTROL_SET_RECMASTER:
1153 case CTDB_CONTROL_FREEZE:
1156 case CTDB_CONTROL_GET_PNN:
1159 case CTDB_CONTROL_SHUTDOWN:
1162 case CTDB_CONTROL_GET_MONMODE:
1165 case CTDB_CONTROL_TCP_CLIENT:
1168 case CTDB_CONTROL_TCP_ADD:
1171 case CTDB_CONTROL_TCP_REMOVE:
1174 case CTDB_CONTROL_STARTUP:
1177 case CTDB_CONTROL_SET_TUNABLE:
1180 case CTDB_CONTROL_GET_TUNABLE:
1181 len = ctdb_uint32_len(&cd->data.tun_value);
1184 case CTDB_CONTROL_LIST_TUNABLES:
1185 len = ctdb_var_list_len(cd->data.tun_var_list);
1188 case CTDB_CONTROL_MODIFY_FLAGS:
1191 case CTDB_CONTROL_GET_ALL_TUNABLES:
1192 len = ctdb_tunable_list_len(cd->data.tun_list);
1195 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
1196 len = ctdb_tickle_list_len(cd->data.tickles);
1199 case CTDB_CONTROL_SET_TCP_TICKLE_LIST:
1202 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
1203 len = ctdb_uint32_len(&cd->data.db_id);
1206 case CTDB_CONTROL_UPDATE_RECORD:
1209 case CTDB_CONTROL_SEND_GRATUITOUS_ARP:
1212 case CTDB_CONTROL_WIPE_DATABASE:
1215 case CTDB_CONTROL_UPTIME:
1216 len = ctdb_uptime_len(cd->data.uptime);
1219 case CTDB_CONTROL_START_RECOVERY:
1222 case CTDB_CONTROL_END_RECOVERY:
1225 case CTDB_CONTROL_RELOAD_NODES_FILE:
1228 case CTDB_CONTROL_TRY_DELETE_RECORDS:
1229 len = ctdb_rec_buffer_len(cd->data.recbuf);
1232 case CTDB_CONTROL_ENABLE_MONITOR:
1235 case CTDB_CONTROL_DISABLE_MONITOR:
1238 case CTDB_CONTROL_ADD_PUBLIC_IP:
1241 case CTDB_CONTROL_DEL_PUBLIC_IP:
1244 case CTDB_CONTROL_GET_CAPABILITIES:
1245 len = ctdb_uint32_len(&cd->data.caps);
1248 case CTDB_CONTROL_RECD_PING:
1251 case CTDB_CONTROL_RELEASE_IP:
1254 case CTDB_CONTROL_TAKEOVER_IP:
1257 case CTDB_CONTROL_GET_PUBLIC_IPS:
1258 len = ctdb_public_ip_list_len(cd->data.pubip_list);
1261 case CTDB_CONTROL_GET_NODEMAP:
1262 len = ctdb_node_map_len(cd->data.nodemap);
1265 case CTDB_CONTROL_TRAVERSE_KILL:
1268 case CTDB_CONTROL_RECD_RECLOCK_LATENCY:
1271 case CTDB_CONTROL_GET_RECLOCK_FILE:
1272 len = ctdb_string_len(&cd->data.reclock_file);
1275 case CTDB_CONTROL_STOP_NODE:
1278 case CTDB_CONTROL_CONTINUE_NODE:
1281 case CTDB_CONTROL_SET_LMASTERROLE:
1284 case CTDB_CONTROL_SET_RECMASTERROLE:
1287 case CTDB_CONTROL_SET_BAN_STATE:
1290 case CTDB_CONTROL_GET_BAN_STATE:
1291 len = ctdb_ban_state_len(cd->data.ban_state);
1294 case CTDB_CONTROL_SET_DB_PRIORITY:
1297 case CTDB_CONTROL_GET_DB_PRIORITY:
1300 case CTDB_CONTROL_REGISTER_NOTIFY:
1303 case CTDB_CONTROL_DEREGISTER_NOTIFY:
1306 case CTDB_CONTROL_TRANS3_COMMIT:
1309 case CTDB_CONTROL_GET_DB_SEQNUM:
1310 len = ctdb_uint64_len(&cd->data.seqnum);
1313 case CTDB_CONTROL_DB_SET_HEALTHY:
1316 case CTDB_CONTROL_DB_GET_HEALTH:
1317 len = ctdb_string_len(&cd->data.reason);
1320 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
1321 len = ctdb_public_ip_info_len(cd->data.ipinfo);
1324 case CTDB_CONTROL_GET_IFACES:
1325 len = ctdb_iface_list_len(cd->data.iface_list);
1328 case CTDB_CONTROL_SET_IFACE_LINK_STATE:
1331 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE:
1334 case CTDB_CONTROL_GET_STAT_HISTORY:
1335 len = ctdb_statistics_list_len(cd->data.stats_list);
1338 case CTDB_CONTROL_SCHEDULE_FOR_DELETION:
1341 case CTDB_CONTROL_SET_DB_READONLY:
1344 case CTDB_CONTROL_CHECK_SRVIDS:
1347 case CTDB_CONTROL_TRAVERSE_START_EXT:
1350 case CTDB_CONTROL_GET_DB_STATISTICS:
1351 len = ctdb_db_statistics_len(cd->data.dbstats);
1354 case CTDB_CONTROL_SET_DB_STICKY:
1357 case CTDB_CONTROL_RELOAD_PUBLIC_IPS:
1360 case CTDB_CONTROL_TRAVERSE_ALL_EXT:
1363 case CTDB_CONTROL_RECEIVE_RECORDS:
1364 len = ctdb_rec_buffer_len(cd->data.recbuf);
1367 case CTDB_CONTROL_IPREALLOCATED:
1370 case CTDB_CONTROL_GET_RUNSTATE:
1371 len = ctdb_uint32_len(&cd->data.runstate);
1374 case CTDB_CONTROL_DB_DETACH:
1377 case CTDB_CONTROL_GET_NODES_FILE:
1378 len = ctdb_node_map_len(cd->data.nodemap);
1381 case CTDB_CONTROL_DB_FREEZE:
1384 case CTDB_CONTROL_DB_THAW:
1387 case CTDB_CONTROL_DB_TRANSACTION_START:
1390 case CTDB_CONTROL_DB_TRANSACTION_COMMIT:
1393 case CTDB_CONTROL_DB_TRANSACTION_CANCEL:
1396 case CTDB_CONTROL_DB_PULL:
1397 len = ctdb_uint32_len(&cd->data.num_records);
1400 case CTDB_CONTROL_DB_PUSH_START:
1403 case CTDB_CONTROL_DB_PUSH_CONFIRM:
1404 len = ctdb_uint32_len(&cd->data.num_records);
1407 case CTDB_CONTROL_DB_OPEN_FLAGS:
1408 len = ctdb_int32_len(&cd->data.tdb_flags);
1411 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
1412 len = ctdb_uint32_len(&cd->data.db_id);
1419 static void ctdb_reply_control_data_push(struct ctdb_reply_control_data *cd,
1424 switch (cd->opcode) {
1425 case CTDB_CONTROL_STATISTICS:
1426 ctdb_statistics_push(cd->data.stats, buf, &np);
1429 case CTDB_CONTROL_GETDBPATH:
1430 ctdb_string_push(&cd->data.db_path, buf, &np);
1433 case CTDB_CONTROL_GETVNNMAP:
1434 ctdb_vnn_map_push(cd->data.vnnmap, buf, &np);
1437 case CTDB_CONTROL_GET_DEBUG:
1438 ctdb_uint32_push(&cd->data.loglevel, buf, &np);
1441 case CTDB_CONTROL_GET_DBMAP:
1442 ctdb_dbid_map_push(cd->data.dbmap, buf, &np);
1445 case CTDB_CONTROL_PULL_DB:
1446 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
1449 case CTDB_CONTROL_PUSH_DB:
1452 case CTDB_CONTROL_DB_ATTACH:
1453 ctdb_uint32_push(&cd->data.db_id, buf, &np);
1456 case CTDB_CONTROL_GET_DBNAME:
1457 ctdb_string_push(&cd->data.db_name, buf, &np);
1460 case CTDB_CONTROL_DUMP_MEMORY:
1461 ctdb_string_push(&cd->data.mem_str, buf, &np);
1464 case CTDB_CONTROL_GET_PID:
1467 case CTDB_CONTROL_GET_RECMASTER:
1470 case CTDB_CONTROL_GET_TUNABLE:
1471 ctdb_uint32_push(&cd->data.tun_value, buf, &np);
1474 case CTDB_CONTROL_LIST_TUNABLES:
1475 ctdb_var_list_push(cd->data.tun_var_list, buf, &np);
1478 case CTDB_CONTROL_GET_ALL_TUNABLES:
1479 ctdb_tunable_list_push(cd->data.tun_list, buf, &np);
1482 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
1483 ctdb_tickle_list_push(cd->data.tickles, buf, &np);
1486 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
1487 ctdb_uint32_push(&cd->data.db_id, buf, &np);
1490 case CTDB_CONTROL_UPTIME:
1491 ctdb_uptime_push(cd->data.uptime, buf, &np);
1494 case CTDB_CONTROL_TRY_DELETE_RECORDS:
1495 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
1498 case CTDB_CONTROL_GET_CAPABILITIES:
1499 ctdb_uint32_push(&cd->data.caps, buf, &np);
1502 case CTDB_CONTROL_GET_PUBLIC_IPS:
1503 ctdb_public_ip_list_push(cd->data.pubip_list, buf);
1506 case CTDB_CONTROL_GET_NODEMAP:
1507 ctdb_node_map_push(cd->data.nodemap, buf);
1510 case CTDB_CONTROL_GET_RECLOCK_FILE:
1511 ctdb_string_push(&cd->data.reclock_file, buf, &np);
1514 case CTDB_CONTROL_GET_BAN_STATE:
1515 ctdb_ban_state_push(cd->data.ban_state, buf);
1518 case CTDB_CONTROL_GET_DB_PRIORITY:
1521 case CTDB_CONTROL_GET_DB_SEQNUM:
1522 ctdb_uint64_push(&cd->data.seqnum, buf, &np);
1525 case CTDB_CONTROL_DB_GET_HEALTH:
1526 ctdb_string_push(&cd->data.reason, buf, &np);
1529 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
1530 ctdb_public_ip_info_push(cd->data.ipinfo, buf);
1533 case CTDB_CONTROL_GET_IFACES:
1534 ctdb_iface_list_push(cd->data.iface_list, buf);
1537 case CTDB_CONTROL_GET_STAT_HISTORY:
1538 ctdb_statistics_list_push(cd->data.stats_list, buf);
1541 case CTDB_CONTROL_CHECK_SRVIDS:
1544 case CTDB_CONTROL_GET_DB_STATISTICS:
1545 ctdb_db_statistics_push(cd->data.dbstats, buf);
1548 case CTDB_CONTROL_RECEIVE_RECORDS:
1549 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
1552 case CTDB_CONTROL_GET_RUNSTATE:
1553 ctdb_uint32_push(&cd->data.runstate, buf, &np);
1556 case CTDB_CONTROL_GET_NODES_FILE:
1557 ctdb_node_map_push(cd->data.nodemap, buf);
1560 case CTDB_CONTROL_DB_PULL:
1561 ctdb_uint32_push(&cd->data.num_records, buf, &np);
1564 case CTDB_CONTROL_DB_PUSH_CONFIRM:
1565 ctdb_uint32_push(&cd->data.num_records, buf, &np);
1568 case CTDB_CONTROL_DB_OPEN_FLAGS:
1569 ctdb_int32_push(&cd->data.tdb_flags, buf, &np);
1572 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
1573 ctdb_uint32_push(&cd->data.db_id, buf, &np);
1578 static int ctdb_reply_control_data_pull(uint8_t *buf, size_t buflen,
1579 uint32_t opcode, TALLOC_CTX *mem_ctx,
1580 struct ctdb_reply_control_data *cd)
1585 cd->opcode = opcode;
1588 case CTDB_CONTROL_STATISTICS:
1589 ret = ctdb_statistics_pull(buf, buflen, mem_ctx,
1590 &cd->data.stats, &np);
1593 case CTDB_CONTROL_GETDBPATH:
1594 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1595 &cd->data.db_path, &np);
1598 case CTDB_CONTROL_GETVNNMAP:
1599 ret = ctdb_vnn_map_pull(buf, buflen, mem_ctx,
1600 &cd->data.vnnmap, &np);
1603 case CTDB_CONTROL_GET_DEBUG:
1604 ret = ctdb_uint32_pull(buf, buflen, &cd->data.loglevel, &np);
1607 case CTDB_CONTROL_GET_DBMAP:
1608 ret = ctdb_dbid_map_pull(buf, buflen, mem_ctx,
1609 &cd->data.dbmap, &np);
1612 case CTDB_CONTROL_PULL_DB:
1613 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
1614 &cd->data.recbuf, &np);
1617 case CTDB_CONTROL_PUSH_DB:
1620 case CTDB_CONTROL_DB_ATTACH:
1621 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1624 case CTDB_CONTROL_GET_DBNAME:
1625 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1626 &cd->data.db_name, &np);
1629 case CTDB_CONTROL_DUMP_MEMORY:
1630 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1631 &cd->data.mem_str, &np);
1634 case CTDB_CONTROL_GET_PID:
1637 case CTDB_CONTROL_GET_RECMASTER:
1640 case CTDB_CONTROL_GET_TUNABLE:
1641 ret = ctdb_uint32_pull(buf, buflen, &cd->data.tun_value,
1645 case CTDB_CONTROL_LIST_TUNABLES:
1646 ret = ctdb_var_list_pull(buf, buflen, mem_ctx,
1647 &cd->data.tun_var_list, &np);
1650 case CTDB_CONTROL_GET_ALL_TUNABLES:
1651 ret = ctdb_tunable_list_pull(buf, buflen, mem_ctx,
1652 &cd->data.tun_list, &np);
1655 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
1656 ret = ctdb_tickle_list_pull(buf, buflen, mem_ctx,
1657 &cd->data.tickles, &np);
1660 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
1661 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1664 case CTDB_CONTROL_UPTIME:
1665 ret = ctdb_uptime_pull(buf, buflen, mem_ctx,
1666 &cd->data.uptime, &np);
1669 case CTDB_CONTROL_TRY_DELETE_RECORDS:
1670 ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
1671 &cd->data.recbuf, &np);
1674 case CTDB_CONTROL_GET_CAPABILITIES:
1675 ret = ctdb_uint32_pull(buf, buflen, &cd->data.caps, &np);
1678 case CTDB_CONTROL_GET_PUBLIC_IPS:
1679 ret = ctdb_public_ip_list_pull(buf, buflen, mem_ctx,
1680 &cd->data.pubip_list);
1683 case CTDB_CONTROL_GET_NODEMAP:
1684 ret = ctdb_node_map_pull(buf, buflen, mem_ctx,
1688 case CTDB_CONTROL_GET_RECLOCK_FILE:
1689 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1690 &cd->data.reclock_file, &np);
1693 case CTDB_CONTROL_GET_BAN_STATE:
1694 ret = ctdb_ban_state_pull(buf, buflen, mem_ctx,
1695 &cd->data.ban_state);
1698 case CTDB_CONTROL_GET_DB_PRIORITY:
1701 case CTDB_CONTROL_GET_DB_SEQNUM:
1702 ret = ctdb_uint64_pull(buf, buflen, &cd->data.seqnum, &np);
1705 case CTDB_CONTROL_DB_GET_HEALTH:
1706 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1707 &cd->data.reason, &np);
1710 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
1711 ret = ctdb_public_ip_info_pull(buf, buflen, mem_ctx,
1715 case CTDB_CONTROL_GET_IFACES:
1716 ret = ctdb_iface_list_pull(buf, buflen, mem_ctx,
1717 &cd->data.iface_list);
1720 case CTDB_CONTROL_GET_STAT_HISTORY:
1721 ret = ctdb_statistics_list_pull(buf, buflen, mem_ctx,
1722 &cd->data.stats_list);
1725 case CTDB_CONTROL_CHECK_SRVIDS:
1728 case CTDB_CONTROL_GET_DB_STATISTICS:
1729 ret = ctdb_db_statistics_pull(buf, buflen, mem_ctx,
1733 case CTDB_CONTROL_RECEIVE_RECORDS:
1734 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
1735 &cd->data.recbuf, &np);
1738 case CTDB_CONTROL_GET_RUNSTATE:
1739 ret = ctdb_uint32_pull(buf, buflen, &cd->data.runstate, &np);
1742 case CTDB_CONTROL_GET_NODES_FILE:
1743 ret = ctdb_node_map_pull(buf, buflen, mem_ctx,
1747 case CTDB_CONTROL_DB_PULL:
1748 ret = ctdb_uint32_pull(buf, buflen, &cd->data.num_records,
1752 case CTDB_CONTROL_DB_PUSH_CONFIRM:
1753 ret = ctdb_uint32_pull(buf, buflen, &cd->data.num_records,
1757 case CTDB_CONTROL_DB_OPEN_FLAGS:
1758 ret = ctdb_int32_pull(buf, buflen, &cd->data.tdb_flags, &np);
1761 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
1762 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1769 size_t ctdb_req_control_len(struct ctdb_req_header *h,
1770 struct ctdb_req_control *c)
1772 return offsetof(struct ctdb_req_control_wire, data) +
1773 ctdb_req_control_data_len(&c->rdata);
1776 int ctdb_req_control_push(struct ctdb_req_header *h,
1777 struct ctdb_req_control *request,
1778 uint8_t *buf, size_t *buflen)
1780 struct ctdb_req_control_wire *wire =
1781 (struct ctdb_req_control_wire *)buf;
1784 length = ctdb_req_control_len(h, request);
1785 if (*buflen < length) {
1790 h->length = *buflen;
1791 ctdb_req_header_push(h, (uint8_t *)&wire->hdr);
1793 wire->opcode = request->opcode;
1794 wire->pad = request->pad;
1795 wire->srvid = request->srvid;
1796 wire->client_id = request->client_id;
1797 wire->flags = request->flags;
1799 wire->datalen = ctdb_req_control_data_len(&request->rdata);
1800 ctdb_req_control_data_push(&request->rdata, wire->data);
1805 int ctdb_req_control_pull(uint8_t *buf, size_t buflen,
1806 struct ctdb_req_header *h,
1807 TALLOC_CTX *mem_ctx,
1808 struct ctdb_req_control *c)
1810 struct ctdb_req_control_wire *wire =
1811 (struct ctdb_req_control_wire *)buf;
1815 length = offsetof(struct ctdb_req_control_wire, data);
1816 if (buflen < length) {
1819 if (wire->datalen > buflen) {
1822 if (length + wire->datalen < length) {
1825 if (buflen < length + wire->datalen) {
1830 ret = ctdb_req_header_pull((uint8_t *)&wire->hdr, buflen, h);
1836 c->opcode = wire->opcode;
1838 c->srvid = wire->srvid;
1839 c->client_id = wire->client_id;
1840 c->flags = wire->flags;
1842 ret = ctdb_req_control_data_pull(wire->data, wire->datalen,
1843 c->opcode, mem_ctx, &c->rdata);
1851 size_t ctdb_reply_control_len(struct ctdb_req_header *h,
1852 struct ctdb_reply_control *c)
1854 return offsetof(struct ctdb_reply_control_wire, data) +
1856 ctdb_reply_control_data_len(&c->rdata) :
1857 ctdb_string_len(&c->errmsg));
1860 int ctdb_reply_control_push(struct ctdb_req_header *h,
1861 struct ctdb_reply_control *reply,
1862 uint8_t *buf, size_t *buflen)
1864 struct ctdb_reply_control_wire *wire =
1865 (struct ctdb_reply_control_wire *)buf;
1868 length = ctdb_reply_control_len(h, reply);
1869 if (*buflen < length) {
1874 h->length = *buflen;
1875 ctdb_req_header_push(h, (uint8_t *)&wire->hdr);
1877 wire->status = reply->status;
1879 if (reply->status == 0) {
1880 wire->datalen = ctdb_reply_control_data_len(&reply->rdata);
1882 ctdb_reply_control_data_push(&reply->rdata, wire->data);
1885 wire->errorlen = ctdb_string_len(&reply->errmsg);
1886 ctdb_string_push(&reply->errmsg, wire->data + wire->datalen,
1893 int ctdb_reply_control_pull(uint8_t *buf, size_t buflen, uint32_t opcode,
1894 struct ctdb_req_header *h,
1895 TALLOC_CTX *mem_ctx,
1896 struct ctdb_reply_control *c)
1898 struct ctdb_reply_control_wire *wire =
1899 (struct ctdb_reply_control_wire *)buf;
1903 length = offsetof(struct ctdb_reply_control_wire, data);
1904 if (buflen < length) {
1907 if (wire->datalen > buflen || wire->errorlen > buflen) {
1910 if (length + wire->datalen < length) {
1913 if (length + wire->datalen + wire->errorlen < length) {
1916 if (buflen < length + wire->datalen + wire->errorlen) {
1921 ret = ctdb_req_header_pull((uint8_t *)&wire->hdr, buflen, h);
1927 c->status = wire->status;
1929 if (c->status != -1) {
1930 ret = ctdb_reply_control_data_pull(wire->data, wire->datalen,
1938 ret = ctdb_string_pull(wire->data + wire->datalen, wire->errorlen,
1939 mem_ctx, &c->errmsg, &np);