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,
444 uint8_t *buf, size_t *npush)
446 size_t np = 0, offset;
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, &np);
577 case CTDB_CONTROL_TAKEOVER_IP:
578 ctdb_public_ip_push(cd->data.pubip, buf, &np);
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, &np);
601 case CTDB_CONTROL_REGISTER_NOTIFY:
602 ctdb_notify_data_push(cd->data.notify, buf, &np);
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, &np);
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, &np);
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);
724 static int ctdb_req_control_data_pull(uint8_t *buf, size_t buflen,
727 struct ctdb_req_control_data *cd,
730 size_t np = 0, offset;
737 case CTDB_CONTROL_PROCESS_EXISTS:
738 ret = ctdb_pid_pull(buf, buflen, &cd->data.pid, &np);
741 case CTDB_CONTROL_GETDBPATH:
742 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
745 case CTDB_CONTROL_SETVNNMAP:
746 ret = ctdb_vnn_map_pull(buf, buflen, mem_ctx,
747 &cd->data.vnnmap, &np);
750 case CTDB_CONTROL_SET_DEBUG:
751 ret = ctdb_uint32_pull(buf, buflen, &cd->data.loglevel, &np);
754 case CTDB_CONTROL_PULL_DB:
755 ret = ctdb_pulldb_pull(buf, buflen, mem_ctx,
756 &cd->data.pulldb, &np);
759 case CTDB_CONTROL_PUSH_DB:
760 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
761 &cd->data.recbuf, &np);
764 case CTDB_CONTROL_SET_RECMODE:
765 ret = ctdb_uint32_pull(buf, buflen, &cd->data.recmode, &np);
768 case CTDB_CONTROL_DB_ATTACH:
769 ret = ctdb_string_pull(buf, buflen, mem_ctx,
770 &cd->data.db_name, &np);
773 case CTDB_CONTROL_SET_CALL:
776 case CTDB_CONTROL_TRAVERSE_START:
777 ret = ctdb_traverse_start_pull(buf, buflen, mem_ctx,
778 &cd->data.traverse_start, &np);
781 case CTDB_CONTROL_TRAVERSE_ALL:
782 ret = ctdb_traverse_all_pull(buf, buflen, mem_ctx,
783 &cd->data.traverse_all, &np);
786 case CTDB_CONTROL_TRAVERSE_DATA:
787 ret = ctdb_rec_data_pull(buf, buflen, mem_ctx,
788 &cd->data.rec_data, &np);
791 case CTDB_CONTROL_GET_DBNAME:
792 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
795 case CTDB_CONTROL_ENABLE_SEQNUM:
796 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
799 case CTDB_CONTROL_UPDATE_SEQNUM:
800 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
803 case CTDB_CONTROL_SET_RECMASTER:
804 ret = ctdb_uint32_pull(buf, buflen, &cd->data.recmaster, &np);
807 case CTDB_CONTROL_TCP_CLIENT:
808 ret = ctdb_connection_pull(buf, buflen, mem_ctx,
809 &cd->data.conn, &np);
812 case CTDB_CONTROL_TCP_ADD:
813 ret = ctdb_connection_pull(buf, buflen, mem_ctx,
814 &cd->data.conn, &np);
817 case CTDB_CONTROL_TCP_REMOVE:
818 ret = ctdb_connection_pull(buf, buflen, mem_ctx,
819 &cd->data.conn, &np);
822 case CTDB_CONTROL_SET_TUNABLE:
823 ret = ctdb_tunable_pull(buf, buflen, mem_ctx,
824 &cd->data.tunable, &np);
827 case CTDB_CONTROL_GET_TUNABLE:
828 ret = ctdb_stringn_pull(buf, buflen, mem_ctx,
829 &cd->data.tun_var, &np);
832 case CTDB_CONTROL_MODIFY_FLAGS:
833 ret = ctdb_node_flag_change_pull(buf, buflen, mem_ctx,
834 &cd->data.flag_change, &np);
837 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
838 ret = ctdb_sock_addr_pull(buf, buflen, mem_ctx,
839 &cd->data.addr, &np);
842 case CTDB_CONTROL_SET_TCP_TICKLE_LIST:
843 ret = ctdb_tickle_list_pull(buf, buflen, mem_ctx,
844 &cd->data.tickles, &np);
847 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
848 ret = ctdb_string_pull(buf, buflen, mem_ctx,
849 &cd->data.db_name, &np);
852 case CTDB_CONTROL_UPDATE_RECORD:
853 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
854 &cd->data.recbuf, &np);
857 case CTDB_CONTROL_SEND_GRATUITOUS_ARP:
858 ret = ctdb_addr_info_pull(buf, buflen, mem_ctx,
859 &cd->data.addr_info, &np);
862 case CTDB_CONTROL_WIPE_DATABASE:
863 ret = ctdb_transdb_pull(buf, buflen, mem_ctx,
864 &cd->data.transdb, &np);
867 case CTDB_CONTROL_TRY_DELETE_RECORDS:
868 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
869 &cd->data.recbuf, &np);
872 case CTDB_CONTROL_ADD_PUBLIC_IP:
873 ret = ctdb_addr_info_pull(buf, buflen, mem_ctx,
874 &cd->data.addr_info, &np);
877 case CTDB_CONTROL_DEL_PUBLIC_IP:
878 ret = ctdb_addr_info_pull(buf, buflen, mem_ctx,
879 &cd->data.addr_info, &np);
882 case CTDB_CONTROL_RELEASE_IP:
883 ret = ctdb_public_ip_pull(buf, buflen, mem_ctx,
884 &cd->data.pubip, &np);
887 case CTDB_CONTROL_TAKEOVER_IP:
888 ret = ctdb_public_ip_pull(buf, buflen, mem_ctx,
889 &cd->data.pubip, &np);
892 case CTDB_CONTROL_TRAVERSE_KILL:
893 ret = ctdb_traverse_start_pull(buf, buflen, mem_ctx,
894 &cd->data.traverse_start, &np);
897 case CTDB_CONTROL_RECD_RECLOCK_LATENCY:
898 ret = ctdb_double_pull(buf, buflen, &cd->data.reclock_latency,
902 case CTDB_CONTROL_SET_LMASTERROLE:
903 ret = ctdb_uint32_pull(buf, buflen, &cd->data.role, &np);
906 case CTDB_CONTROL_SET_RECMASTERROLE:
907 ret = ctdb_uint32_pull(buf, buflen, &cd->data.role, &np);
910 case CTDB_CONTROL_SET_BAN_STATE:
911 ret = ctdb_ban_state_pull(buf, buflen, mem_ctx,
912 &cd->data.ban_state, &np);
915 case CTDB_CONTROL_REGISTER_NOTIFY:
916 ret = ctdb_notify_data_pull(buf, buflen, mem_ctx,
917 &cd->data.notify, &np);
920 case CTDB_CONTROL_DEREGISTER_NOTIFY:
921 ctdb_uint64_pull(buf, buflen, &cd->data.srvid, &np);
924 case CTDB_CONTROL_TRANS3_COMMIT:
925 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
926 &cd->data.recbuf, &np);
929 case CTDB_CONTROL_GET_DB_SEQNUM:
931 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
936 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &u32, &np);
941 case CTDB_CONTROL_DB_SET_HEALTHY:
942 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
945 case CTDB_CONTROL_DB_GET_HEALTH:
946 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
949 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
950 ret = ctdb_sock_addr_pull(buf, buflen, mem_ctx,
951 &cd->data.addr, &np);
954 case CTDB_CONTROL_SET_IFACE_LINK_STATE:
955 ret = ctdb_iface_pull(buf, buflen, mem_ctx,
956 &cd->data.iface, &np);
959 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE:
960 ret = ctdb_connection_pull(buf, buflen, mem_ctx,
961 &cd->data.conn, &np);
964 case CTDB_CONTROL_SCHEDULE_FOR_DELETION:
965 ret = ctdb_key_data_pull(buf, buflen, mem_ctx,
969 case CTDB_CONTROL_SET_DB_READONLY:
970 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
973 case CTDB_CONTROL_CHECK_SRVIDS:
976 case CTDB_CONTROL_TRAVERSE_START_EXT:
977 ret = ctdb_traverse_start_ext_pull(buf, buflen, mem_ctx,
978 &cd->data.traverse_start_ext,
982 case CTDB_CONTROL_GET_DB_STATISTICS:
983 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
986 case CTDB_CONTROL_SET_DB_STICKY:
987 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
990 case CTDB_CONTROL_TRAVERSE_ALL_EXT:
991 ret = ctdb_traverse_all_ext_pull(buf, buflen, mem_ctx,
992 &cd->data.traverse_all_ext,
996 case CTDB_CONTROL_RECEIVE_RECORDS:
997 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
998 &cd->data.recbuf, &np);
1001 case CTDB_CONTROL_DB_DETACH:
1002 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1005 case CTDB_CONTROL_DB_FREEZE:
1006 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1009 case CTDB_CONTROL_DB_THAW:
1010 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1013 case CTDB_CONTROL_DB_TRANSACTION_START:
1014 ret = ctdb_transdb_pull(buf, buflen, mem_ctx,
1015 &cd->data.transdb, &np);
1018 case CTDB_CONTROL_DB_TRANSACTION_COMMIT:
1019 ret = ctdb_transdb_pull(buf, buflen, mem_ctx,
1020 &cd->data.transdb, &np);
1023 case CTDB_CONTROL_DB_TRANSACTION_CANCEL:
1024 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1027 case CTDB_CONTROL_DB_PULL:
1028 ret = ctdb_pulldb_ext_pull(buf, buflen, mem_ctx,
1029 &cd->data.pulldb_ext, &np);
1032 case CTDB_CONTROL_DB_PUSH_START:
1033 ret = ctdb_pulldb_ext_pull(buf, buflen, mem_ctx,
1034 &cd->data.pulldb_ext, &np);
1037 case CTDB_CONTROL_DB_PUSH_CONFIRM:
1038 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1041 case CTDB_CONTROL_DB_OPEN_FLAGS:
1042 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1045 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
1046 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1047 &cd->data.db_name, &np);
1059 static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data *cd)
1067 switch (cd->opcode) {
1068 case CTDB_CONTROL_PROCESS_EXISTS:
1071 case CTDB_CONTROL_STATISTICS:
1072 len = ctdb_statistics_len(cd->data.stats);
1075 case CTDB_CONTROL_PING:
1078 case CTDB_CONTROL_GETDBPATH:
1079 len = ctdb_string_len(&cd->data.db_path);
1082 case CTDB_CONTROL_GETVNNMAP:
1083 len = ctdb_vnn_map_len(cd->data.vnnmap);
1086 case CTDB_CONTROL_SETVNNMAP:
1089 case CTDB_CONTROL_GET_DEBUG:
1090 len = ctdb_uint32_len(&cd->data.loglevel);
1093 case CTDB_CONTROL_SET_DEBUG:
1096 case CTDB_CONTROL_GET_DBMAP:
1097 len = ctdb_dbid_map_len(cd->data.dbmap);
1100 case CTDB_CONTROL_PULL_DB:
1101 len = ctdb_rec_buffer_len(cd->data.recbuf);
1104 case CTDB_CONTROL_PUSH_DB:
1107 case CTDB_CONTROL_GET_RECMODE:
1110 case CTDB_CONTROL_SET_RECMODE:
1113 case CTDB_CONTROL_STATISTICS_RESET:
1116 case CTDB_CONTROL_DB_ATTACH:
1117 len = ctdb_uint32_len(&cd->data.db_id);
1120 case CTDB_CONTROL_SET_CALL:
1123 case CTDB_CONTROL_TRAVERSE_START:
1126 case CTDB_CONTROL_TRAVERSE_ALL:
1129 case CTDB_CONTROL_TRAVERSE_DATA:
1132 case CTDB_CONTROL_REGISTER_SRVID:
1135 case CTDB_CONTROL_DEREGISTER_SRVID:
1138 case CTDB_CONTROL_GET_DBNAME:
1139 len = ctdb_string_len(&cd->data.db_name);
1142 case CTDB_CONTROL_ENABLE_SEQNUM:
1145 case CTDB_CONTROL_UPDATE_SEQNUM:
1148 case CTDB_CONTROL_DUMP_MEMORY:
1149 len = ctdb_string_len(&cd->data.mem_str);
1152 case CTDB_CONTROL_GET_PID:
1155 case CTDB_CONTROL_GET_RECMASTER:
1158 case CTDB_CONTROL_SET_RECMASTER:
1161 case CTDB_CONTROL_FREEZE:
1164 case CTDB_CONTROL_GET_PNN:
1167 case CTDB_CONTROL_SHUTDOWN:
1170 case CTDB_CONTROL_GET_MONMODE:
1173 case CTDB_CONTROL_TCP_CLIENT:
1176 case CTDB_CONTROL_TCP_ADD:
1179 case CTDB_CONTROL_TCP_REMOVE:
1182 case CTDB_CONTROL_STARTUP:
1185 case CTDB_CONTROL_SET_TUNABLE:
1188 case CTDB_CONTROL_GET_TUNABLE:
1189 len = ctdb_uint32_len(&cd->data.tun_value);
1192 case CTDB_CONTROL_LIST_TUNABLES:
1193 len = ctdb_var_list_len(cd->data.tun_var_list);
1196 case CTDB_CONTROL_MODIFY_FLAGS:
1199 case CTDB_CONTROL_GET_ALL_TUNABLES:
1200 len = ctdb_tunable_list_len(cd->data.tun_list);
1203 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
1204 len = ctdb_tickle_list_len(cd->data.tickles);
1207 case CTDB_CONTROL_SET_TCP_TICKLE_LIST:
1210 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
1211 len = ctdb_uint32_len(&cd->data.db_id);
1214 case CTDB_CONTROL_UPDATE_RECORD:
1217 case CTDB_CONTROL_SEND_GRATUITOUS_ARP:
1220 case CTDB_CONTROL_WIPE_DATABASE:
1223 case CTDB_CONTROL_UPTIME:
1224 len = ctdb_uptime_len(cd->data.uptime);
1227 case CTDB_CONTROL_START_RECOVERY:
1230 case CTDB_CONTROL_END_RECOVERY:
1233 case CTDB_CONTROL_RELOAD_NODES_FILE:
1236 case CTDB_CONTROL_TRY_DELETE_RECORDS:
1237 len = ctdb_rec_buffer_len(cd->data.recbuf);
1240 case CTDB_CONTROL_ENABLE_MONITOR:
1243 case CTDB_CONTROL_DISABLE_MONITOR:
1246 case CTDB_CONTROL_ADD_PUBLIC_IP:
1249 case CTDB_CONTROL_DEL_PUBLIC_IP:
1252 case CTDB_CONTROL_GET_CAPABILITIES:
1253 len = ctdb_uint32_len(&cd->data.caps);
1256 case CTDB_CONTROL_RECD_PING:
1259 case CTDB_CONTROL_RELEASE_IP:
1262 case CTDB_CONTROL_TAKEOVER_IP:
1265 case CTDB_CONTROL_GET_PUBLIC_IPS:
1266 len = ctdb_public_ip_list_len(cd->data.pubip_list);
1269 case CTDB_CONTROL_GET_NODEMAP:
1270 len = ctdb_node_map_len(cd->data.nodemap);
1273 case CTDB_CONTROL_TRAVERSE_KILL:
1276 case CTDB_CONTROL_RECD_RECLOCK_LATENCY:
1279 case CTDB_CONTROL_GET_RECLOCK_FILE:
1280 len = ctdb_string_len(&cd->data.reclock_file);
1283 case CTDB_CONTROL_STOP_NODE:
1286 case CTDB_CONTROL_CONTINUE_NODE:
1289 case CTDB_CONTROL_SET_LMASTERROLE:
1292 case CTDB_CONTROL_SET_RECMASTERROLE:
1295 case CTDB_CONTROL_SET_BAN_STATE:
1298 case CTDB_CONTROL_GET_BAN_STATE:
1299 len = ctdb_ban_state_len(cd->data.ban_state);
1302 case CTDB_CONTROL_SET_DB_PRIORITY:
1305 case CTDB_CONTROL_GET_DB_PRIORITY:
1308 case CTDB_CONTROL_REGISTER_NOTIFY:
1311 case CTDB_CONTROL_DEREGISTER_NOTIFY:
1314 case CTDB_CONTROL_TRANS3_COMMIT:
1317 case CTDB_CONTROL_GET_DB_SEQNUM:
1318 len = ctdb_uint64_len(&cd->data.seqnum);
1321 case CTDB_CONTROL_DB_SET_HEALTHY:
1324 case CTDB_CONTROL_DB_GET_HEALTH:
1325 len = ctdb_string_len(&cd->data.reason);
1328 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
1329 len = ctdb_public_ip_info_len(cd->data.ipinfo);
1332 case CTDB_CONTROL_GET_IFACES:
1333 len = ctdb_iface_list_len(cd->data.iface_list);
1336 case CTDB_CONTROL_SET_IFACE_LINK_STATE:
1339 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE:
1342 case CTDB_CONTROL_GET_STAT_HISTORY:
1343 len = ctdb_statistics_list_len(cd->data.stats_list);
1346 case CTDB_CONTROL_SCHEDULE_FOR_DELETION:
1349 case CTDB_CONTROL_SET_DB_READONLY:
1352 case CTDB_CONTROL_CHECK_SRVIDS:
1355 case CTDB_CONTROL_TRAVERSE_START_EXT:
1358 case CTDB_CONTROL_GET_DB_STATISTICS:
1359 len = ctdb_db_statistics_len(cd->data.dbstats);
1362 case CTDB_CONTROL_SET_DB_STICKY:
1365 case CTDB_CONTROL_RELOAD_PUBLIC_IPS:
1368 case CTDB_CONTROL_TRAVERSE_ALL_EXT:
1371 case CTDB_CONTROL_RECEIVE_RECORDS:
1372 len = ctdb_rec_buffer_len(cd->data.recbuf);
1375 case CTDB_CONTROL_IPREALLOCATED:
1378 case CTDB_CONTROL_GET_RUNSTATE:
1379 len = ctdb_uint32_len(&cd->data.runstate);
1382 case CTDB_CONTROL_DB_DETACH:
1385 case CTDB_CONTROL_GET_NODES_FILE:
1386 len = ctdb_node_map_len(cd->data.nodemap);
1389 case CTDB_CONTROL_DB_FREEZE:
1392 case CTDB_CONTROL_DB_THAW:
1395 case CTDB_CONTROL_DB_TRANSACTION_START:
1398 case CTDB_CONTROL_DB_TRANSACTION_COMMIT:
1401 case CTDB_CONTROL_DB_TRANSACTION_CANCEL:
1404 case CTDB_CONTROL_DB_PULL:
1405 len = ctdb_uint32_len(&cd->data.num_records);
1408 case CTDB_CONTROL_DB_PUSH_START:
1411 case CTDB_CONTROL_DB_PUSH_CONFIRM:
1412 len = ctdb_uint32_len(&cd->data.num_records);
1415 case CTDB_CONTROL_DB_OPEN_FLAGS:
1416 len = ctdb_int32_len(&cd->data.tdb_flags);
1419 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
1420 len = ctdb_uint32_len(&cd->data.db_id);
1427 static void ctdb_reply_control_data_push(struct ctdb_reply_control_data *cd,
1428 uint8_t *buf, size_t *npush)
1432 switch (cd->opcode) {
1433 case CTDB_CONTROL_STATISTICS:
1434 ctdb_statistics_push(cd->data.stats, buf, &np);
1437 case CTDB_CONTROL_GETDBPATH:
1438 ctdb_string_push(&cd->data.db_path, buf, &np);
1441 case CTDB_CONTROL_GETVNNMAP:
1442 ctdb_vnn_map_push(cd->data.vnnmap, buf, &np);
1445 case CTDB_CONTROL_GET_DEBUG:
1446 ctdb_uint32_push(&cd->data.loglevel, buf, &np);
1449 case CTDB_CONTROL_GET_DBMAP:
1450 ctdb_dbid_map_push(cd->data.dbmap, buf, &np);
1453 case CTDB_CONTROL_PULL_DB:
1454 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
1457 case CTDB_CONTROL_PUSH_DB:
1460 case CTDB_CONTROL_DB_ATTACH:
1461 ctdb_uint32_push(&cd->data.db_id, buf, &np);
1464 case CTDB_CONTROL_GET_DBNAME:
1465 ctdb_string_push(&cd->data.db_name, buf, &np);
1468 case CTDB_CONTROL_DUMP_MEMORY:
1469 ctdb_string_push(&cd->data.mem_str, buf, &np);
1472 case CTDB_CONTROL_GET_PID:
1475 case CTDB_CONTROL_GET_RECMASTER:
1478 case CTDB_CONTROL_GET_TUNABLE:
1479 ctdb_uint32_push(&cd->data.tun_value, buf, &np);
1482 case CTDB_CONTROL_LIST_TUNABLES:
1483 ctdb_var_list_push(cd->data.tun_var_list, buf, &np);
1486 case CTDB_CONTROL_GET_ALL_TUNABLES:
1487 ctdb_tunable_list_push(cd->data.tun_list, buf, &np);
1490 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
1491 ctdb_tickle_list_push(cd->data.tickles, buf, &np);
1494 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
1495 ctdb_uint32_push(&cd->data.db_id, buf, &np);
1498 case CTDB_CONTROL_UPTIME:
1499 ctdb_uptime_push(cd->data.uptime, buf, &np);
1502 case CTDB_CONTROL_TRY_DELETE_RECORDS:
1503 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
1506 case CTDB_CONTROL_GET_CAPABILITIES:
1507 ctdb_uint32_push(&cd->data.caps, buf, &np);
1510 case CTDB_CONTROL_GET_PUBLIC_IPS:
1511 ctdb_public_ip_list_push(cd->data.pubip_list, buf, &np);
1514 case CTDB_CONTROL_GET_NODEMAP:
1515 ctdb_node_map_push(cd->data.nodemap, buf, &np);
1518 case CTDB_CONTROL_GET_RECLOCK_FILE:
1519 ctdb_string_push(&cd->data.reclock_file, buf, &np);
1522 case CTDB_CONTROL_GET_BAN_STATE:
1523 ctdb_ban_state_push(cd->data.ban_state, buf, &np);
1526 case CTDB_CONTROL_GET_DB_PRIORITY:
1529 case CTDB_CONTROL_GET_DB_SEQNUM:
1530 ctdb_uint64_push(&cd->data.seqnum, buf, &np);
1533 case CTDB_CONTROL_DB_GET_HEALTH:
1534 ctdb_string_push(&cd->data.reason, buf, &np);
1537 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
1538 ctdb_public_ip_info_push(cd->data.ipinfo, buf, &np);
1541 case CTDB_CONTROL_GET_IFACES:
1542 ctdb_iface_list_push(cd->data.iface_list, buf, &np);
1545 case CTDB_CONTROL_GET_STAT_HISTORY:
1546 ctdb_statistics_list_push(cd->data.stats_list, buf, &np);
1549 case CTDB_CONTROL_CHECK_SRVIDS:
1552 case CTDB_CONTROL_GET_DB_STATISTICS:
1553 ctdb_db_statistics_push(cd->data.dbstats, buf, &np);
1556 case CTDB_CONTROL_RECEIVE_RECORDS:
1557 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
1560 case CTDB_CONTROL_GET_RUNSTATE:
1561 ctdb_uint32_push(&cd->data.runstate, buf, &np);
1564 case CTDB_CONTROL_GET_NODES_FILE:
1565 ctdb_node_map_push(cd->data.nodemap, buf, &np);
1568 case CTDB_CONTROL_DB_PULL:
1569 ctdb_uint32_push(&cd->data.num_records, buf, &np);
1572 case CTDB_CONTROL_DB_PUSH_CONFIRM:
1573 ctdb_uint32_push(&cd->data.num_records, buf, &np);
1576 case CTDB_CONTROL_DB_OPEN_FLAGS:
1577 ctdb_int32_push(&cd->data.tdb_flags, buf, &np);
1580 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
1581 ctdb_uint32_push(&cd->data.db_id, buf, &np);
1588 static int ctdb_reply_control_data_pull(uint8_t *buf, size_t buflen,
1589 uint32_t opcode, TALLOC_CTX *mem_ctx,
1590 struct ctdb_reply_control_data *cd,
1596 cd->opcode = opcode;
1599 case CTDB_CONTROL_STATISTICS:
1600 ret = ctdb_statistics_pull(buf, buflen, mem_ctx,
1601 &cd->data.stats, &np);
1604 case CTDB_CONTROL_GETDBPATH:
1605 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1606 &cd->data.db_path, &np);
1609 case CTDB_CONTROL_GETVNNMAP:
1610 ret = ctdb_vnn_map_pull(buf, buflen, mem_ctx,
1611 &cd->data.vnnmap, &np);
1614 case CTDB_CONTROL_GET_DEBUG:
1615 ret = ctdb_uint32_pull(buf, buflen, &cd->data.loglevel, &np);
1618 case CTDB_CONTROL_GET_DBMAP:
1619 ret = ctdb_dbid_map_pull(buf, buflen, mem_ctx,
1620 &cd->data.dbmap, &np);
1623 case CTDB_CONTROL_PULL_DB:
1624 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
1625 &cd->data.recbuf, &np);
1628 case CTDB_CONTROL_PUSH_DB:
1631 case CTDB_CONTROL_DB_ATTACH:
1632 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1635 case CTDB_CONTROL_GET_DBNAME:
1636 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1637 &cd->data.db_name, &np);
1640 case CTDB_CONTROL_DUMP_MEMORY:
1641 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1642 &cd->data.mem_str, &np);
1645 case CTDB_CONTROL_GET_PID:
1648 case CTDB_CONTROL_GET_RECMASTER:
1651 case CTDB_CONTROL_GET_TUNABLE:
1652 ret = ctdb_uint32_pull(buf, buflen, &cd->data.tun_value,
1656 case CTDB_CONTROL_LIST_TUNABLES:
1657 ret = ctdb_var_list_pull(buf, buflen, mem_ctx,
1658 &cd->data.tun_var_list, &np);
1661 case CTDB_CONTROL_GET_ALL_TUNABLES:
1662 ret = ctdb_tunable_list_pull(buf, buflen, mem_ctx,
1663 &cd->data.tun_list, &np);
1666 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
1667 ret = ctdb_tickle_list_pull(buf, buflen, mem_ctx,
1668 &cd->data.tickles, &np);
1671 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
1672 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1675 case CTDB_CONTROL_UPTIME:
1676 ret = ctdb_uptime_pull(buf, buflen, mem_ctx,
1677 &cd->data.uptime, &np);
1680 case CTDB_CONTROL_TRY_DELETE_RECORDS:
1681 ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
1682 &cd->data.recbuf, &np);
1685 case CTDB_CONTROL_GET_CAPABILITIES:
1686 ret = ctdb_uint32_pull(buf, buflen, &cd->data.caps, &np);
1689 case CTDB_CONTROL_GET_PUBLIC_IPS:
1690 ret = ctdb_public_ip_list_pull(buf, buflen, mem_ctx,
1691 &cd->data.pubip_list, &np);
1694 case CTDB_CONTROL_GET_NODEMAP:
1695 ret = ctdb_node_map_pull(buf, buflen, mem_ctx,
1696 &cd->data.nodemap, &np);
1699 case CTDB_CONTROL_GET_RECLOCK_FILE:
1700 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1701 &cd->data.reclock_file, &np);
1704 case CTDB_CONTROL_GET_BAN_STATE:
1705 ret = ctdb_ban_state_pull(buf, buflen, mem_ctx,
1706 &cd->data.ban_state, &np);
1709 case CTDB_CONTROL_GET_DB_PRIORITY:
1712 case CTDB_CONTROL_GET_DB_SEQNUM:
1713 ret = ctdb_uint64_pull(buf, buflen, &cd->data.seqnum, &np);
1716 case CTDB_CONTROL_DB_GET_HEALTH:
1717 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1718 &cd->data.reason, &np);
1721 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
1722 ret = ctdb_public_ip_info_pull(buf, buflen, mem_ctx,
1723 &cd->data.ipinfo, &np);
1726 case CTDB_CONTROL_GET_IFACES:
1727 ret = ctdb_iface_list_pull(buf, buflen, mem_ctx,
1728 &cd->data.iface_list, &np);
1731 case CTDB_CONTROL_GET_STAT_HISTORY:
1732 ret = ctdb_statistics_list_pull(buf, buflen, mem_ctx,
1733 &cd->data.stats_list, &np);
1736 case CTDB_CONTROL_CHECK_SRVIDS:
1739 case CTDB_CONTROL_GET_DB_STATISTICS:
1740 ret = ctdb_db_statistics_pull(buf, buflen, mem_ctx,
1741 &cd->data.dbstats, &np);
1744 case CTDB_CONTROL_RECEIVE_RECORDS:
1745 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
1746 &cd->data.recbuf, &np);
1749 case CTDB_CONTROL_GET_RUNSTATE:
1750 ret = ctdb_uint32_pull(buf, buflen, &cd->data.runstate, &np);
1753 case CTDB_CONTROL_GET_NODES_FILE:
1754 ret = ctdb_node_map_pull(buf, buflen, mem_ctx,
1755 &cd->data.nodemap, &np);
1758 case CTDB_CONTROL_DB_PULL:
1759 ret = ctdb_uint32_pull(buf, buflen, &cd->data.num_records,
1763 case CTDB_CONTROL_DB_PUSH_CONFIRM:
1764 ret = ctdb_uint32_pull(buf, buflen, &cd->data.num_records,
1768 case CTDB_CONTROL_DB_OPEN_FLAGS:
1769 ret = ctdb_int32_pull(buf, buflen, &cd->data.tdb_flags, &np);
1772 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
1773 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1785 size_t ctdb_req_control_len(struct ctdb_req_header *h,
1786 struct ctdb_req_control *c)
1788 return offsetof(struct ctdb_req_control_wire, data) +
1789 ctdb_req_control_data_len(&c->rdata);
1792 int ctdb_req_control_push(struct ctdb_req_header *h,
1793 struct ctdb_req_control *request,
1794 uint8_t *buf, size_t *buflen)
1796 struct ctdb_req_control_wire *wire =
1797 (struct ctdb_req_control_wire *)buf;
1800 length = ctdb_req_control_len(h, request);
1801 if (*buflen < length) {
1806 h->length = *buflen;
1807 ctdb_req_header_push(h, (uint8_t *)&wire->hdr, &np);
1809 wire->opcode = request->opcode;
1810 wire->pad = request->pad;
1811 wire->srvid = request->srvid;
1812 wire->client_id = request->client_id;
1813 wire->flags = request->flags;
1815 wire->datalen = ctdb_req_control_data_len(&request->rdata);
1816 ctdb_req_control_data_push(&request->rdata, wire->data, &np);
1821 int ctdb_req_control_pull(uint8_t *buf, size_t buflen,
1822 struct ctdb_req_header *h,
1823 TALLOC_CTX *mem_ctx,
1824 struct ctdb_req_control *c)
1826 struct ctdb_req_control_wire *wire =
1827 (struct ctdb_req_control_wire *)buf;
1831 length = offsetof(struct ctdb_req_control_wire, data);
1832 if (buflen < length) {
1835 if (wire->datalen > buflen) {
1838 if (length + wire->datalen < length) {
1841 if (buflen < length + wire->datalen) {
1846 ret = ctdb_req_header_pull((uint8_t *)&wire->hdr, buflen, h,
1853 c->opcode = wire->opcode;
1855 c->srvid = wire->srvid;
1856 c->client_id = wire->client_id;
1857 c->flags = wire->flags;
1859 ret = ctdb_req_control_data_pull(wire->data, wire->datalen,
1860 c->opcode, mem_ctx, &c->rdata, &np);
1868 size_t ctdb_reply_control_len(struct ctdb_req_header *h,
1869 struct ctdb_reply_control *c)
1871 return offsetof(struct ctdb_reply_control_wire, data) +
1873 ctdb_reply_control_data_len(&c->rdata) :
1874 ctdb_string_len(&c->errmsg));
1877 int ctdb_reply_control_push(struct ctdb_req_header *h,
1878 struct ctdb_reply_control *reply,
1879 uint8_t *buf, size_t *buflen)
1881 struct ctdb_reply_control_wire *wire =
1882 (struct ctdb_reply_control_wire *)buf;
1885 length = ctdb_reply_control_len(h, reply);
1886 if (*buflen < length) {
1891 h->length = *buflen;
1892 ctdb_req_header_push(h, (uint8_t *)&wire->hdr, &np);
1894 wire->status = reply->status;
1896 if (reply->status == 0) {
1897 wire->datalen = ctdb_reply_control_data_len(&reply->rdata);
1899 ctdb_reply_control_data_push(&reply->rdata, wire->data, &np);
1902 wire->errorlen = ctdb_string_len(&reply->errmsg);
1903 ctdb_string_push(&reply->errmsg, wire->data + wire->datalen,
1910 int ctdb_reply_control_pull(uint8_t *buf, size_t buflen, uint32_t opcode,
1911 struct ctdb_req_header *h,
1912 TALLOC_CTX *mem_ctx,
1913 struct ctdb_reply_control *c)
1915 struct ctdb_reply_control_wire *wire =
1916 (struct ctdb_reply_control_wire *)buf;
1920 length = offsetof(struct ctdb_reply_control_wire, data);
1921 if (buflen < length) {
1924 if (wire->datalen > buflen || wire->errorlen > buflen) {
1927 if (length + wire->datalen < length) {
1930 if (length + wire->datalen + wire->errorlen < length) {
1933 if (buflen < length + wire->datalen + wire->errorlen) {
1938 ret = ctdb_req_header_pull((uint8_t *)&wire->hdr, buflen, h,
1945 c->status = wire->status;
1947 if (c->status != -1) {
1948 ret = ctdb_reply_control_data_pull(wire->data, wire->datalen,
1956 ret = ctdb_string_pull(wire->data + wire->datalen, wire->errorlen,
1957 mem_ctx, &c->errmsg, &np);