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 static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd)
40 case CTDB_CONTROL_PROCESS_EXISTS:
41 len = ctdb_pid_len(&cd->data.pid);
44 case CTDB_CONTROL_STATISTICS:
47 case CTDB_CONTROL_PING:
50 case CTDB_CONTROL_GETDBPATH:
51 len = ctdb_uint32_len(&cd->data.db_id);
54 case CTDB_CONTROL_GETVNNMAP:
57 case CTDB_CONTROL_SETVNNMAP:
58 len = ctdb_vnn_map_len(cd->data.vnnmap);
61 case CTDB_CONTROL_GET_DEBUG:
64 case CTDB_CONTROL_SET_DEBUG:
65 len = ctdb_uint32_len(&cd->data.loglevel);
68 case CTDB_CONTROL_GET_DBMAP:
71 case CTDB_CONTROL_PULL_DB:
72 len = ctdb_pulldb_len(cd->data.pulldb);
75 case CTDB_CONTROL_PUSH_DB:
76 len = ctdb_rec_buffer_len(cd->data.recbuf);
79 case CTDB_CONTROL_GET_RECMODE:
82 case CTDB_CONTROL_SET_RECMODE:
83 len = ctdb_uint32_len(&cd->data.recmode);
86 case CTDB_CONTROL_STATISTICS_RESET:
89 case CTDB_CONTROL_DB_ATTACH:
90 len = ctdb_string_len(&cd->data.db_name);
93 case CTDB_CONTROL_SET_CALL:
96 case CTDB_CONTROL_TRAVERSE_START:
97 len = ctdb_traverse_start_len(cd->data.traverse_start);
100 case CTDB_CONTROL_TRAVERSE_ALL:
101 len = ctdb_traverse_all_len(cd->data.traverse_all);
104 case CTDB_CONTROL_TRAVERSE_DATA:
105 len = ctdb_rec_data_len(cd->data.rec_data);
108 case CTDB_CONTROL_REGISTER_SRVID:
111 case CTDB_CONTROL_DEREGISTER_SRVID:
114 case CTDB_CONTROL_GET_DBNAME:
115 len = ctdb_uint32_len(&cd->data.db_id);
118 case CTDB_CONTROL_ENABLE_SEQNUM:
119 len = ctdb_uint32_len(&cd->data.db_id);
122 case CTDB_CONTROL_UPDATE_SEQNUM:
123 len = ctdb_uint32_len(&cd->data.db_id);
126 case CTDB_CONTROL_DUMP_MEMORY:
129 case CTDB_CONTROL_GET_PID:
132 case CTDB_CONTROL_GET_RECMASTER:
135 case CTDB_CONTROL_SET_RECMASTER:
136 len = ctdb_uint32_len(&cd->data.recmaster);
139 case CTDB_CONTROL_FREEZE:
142 case CTDB_CONTROL_GET_PNN:
145 case CTDB_CONTROL_SHUTDOWN:
148 case CTDB_CONTROL_GET_MONMODE:
151 case CTDB_CONTROL_TCP_CLIENT:
152 len = ctdb_connection_len(cd->data.conn);
155 case CTDB_CONTROL_TCP_ADD:
156 len = ctdb_connection_len(cd->data.conn);
159 case CTDB_CONTROL_TCP_REMOVE:
160 len = ctdb_connection_len(cd->data.conn);
163 case CTDB_CONTROL_STARTUP:
166 case CTDB_CONTROL_SET_TUNABLE:
167 len = ctdb_tunable_len(cd->data.tunable);
170 case CTDB_CONTROL_GET_TUNABLE:
171 len = ctdb_stringn_len(&cd->data.tun_var);
174 case CTDB_CONTROL_LIST_TUNABLES:
177 case CTDB_CONTROL_MODIFY_FLAGS:
178 len = ctdb_node_flag_change_len(cd->data.flag_change);
181 case CTDB_CONTROL_GET_ALL_TUNABLES:
184 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
185 len = ctdb_sock_addr_len(cd->data.addr);
188 case CTDB_CONTROL_SET_TCP_TICKLE_LIST:
189 len = ctdb_tickle_list_len(cd->data.tickles);
192 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
193 len = ctdb_string_len(&cd->data.db_name);
196 case CTDB_CONTROL_UPDATE_RECORD:
197 len = ctdb_rec_buffer_len(cd->data.recbuf);
200 case CTDB_CONTROL_SEND_GRATUITOUS_ARP:
201 len = ctdb_addr_info_len(cd->data.addr_info);
204 case CTDB_CONTROL_WIPE_DATABASE:
205 len = ctdb_transdb_len(cd->data.transdb);
208 case CTDB_CONTROL_UPTIME:
211 case CTDB_CONTROL_START_RECOVERY:
214 case CTDB_CONTROL_END_RECOVERY:
217 case CTDB_CONTROL_RELOAD_NODES_FILE:
220 case CTDB_CONTROL_TRY_DELETE_RECORDS:
221 len = ctdb_rec_buffer_len(cd->data.recbuf);
224 case CTDB_CONTROL_ENABLE_MONITOR:
227 case CTDB_CONTROL_DISABLE_MONITOR:
230 case CTDB_CONTROL_ADD_PUBLIC_IP:
231 len = ctdb_addr_info_len(cd->data.addr_info);
234 case CTDB_CONTROL_DEL_PUBLIC_IP:
235 len = ctdb_addr_info_len(cd->data.addr_info);
238 case CTDB_CONTROL_GET_CAPABILITIES:
241 case CTDB_CONTROL_RECD_PING:
244 case CTDB_CONTROL_RELEASE_IP:
245 len = ctdb_public_ip_len(cd->data.pubip);
248 case CTDB_CONTROL_TAKEOVER_IP:
249 len = ctdb_public_ip_len(cd->data.pubip);
252 case CTDB_CONTROL_GET_PUBLIC_IPS:
255 case CTDB_CONTROL_GET_NODEMAP:
258 case CTDB_CONTROL_TRAVERSE_KILL:
259 len = ctdb_traverse_start_len(cd->data.traverse_start);
262 case CTDB_CONTROL_RECD_RECLOCK_LATENCY:
263 len = ctdb_double_len(&cd->data.reclock_latency);
266 case CTDB_CONTROL_GET_RECLOCK_FILE:
269 case CTDB_CONTROL_STOP_NODE:
272 case CTDB_CONTROL_CONTINUE_NODE:
275 case CTDB_CONTROL_SET_LMASTERROLE:
276 len = ctdb_uint32_len(&cd->data.role);
279 case CTDB_CONTROL_SET_RECMASTERROLE:
280 len = ctdb_uint32_len(&cd->data.role);
283 case CTDB_CONTROL_SET_BAN_STATE:
284 len = ctdb_ban_state_len(cd->data.ban_state);
287 case CTDB_CONTROL_GET_BAN_STATE:
290 case CTDB_CONTROL_REGISTER_NOTIFY:
291 len = ctdb_notify_data_len(cd->data.notify);
294 case CTDB_CONTROL_DEREGISTER_NOTIFY:
295 len = ctdb_uint64_len(&cd->data.srvid);
298 case CTDB_CONTROL_TRANS3_COMMIT:
299 len = ctdb_rec_buffer_len(cd->data.recbuf);
302 case CTDB_CONTROL_GET_DB_SEQNUM:
304 len = ctdb_uint32_len(&cd->data.db_id) + ctdb_uint32_len(&u32);
307 case CTDB_CONTROL_DB_SET_HEALTHY:
308 len = ctdb_uint32_len(&cd->data.db_id);
311 case CTDB_CONTROL_DB_GET_HEALTH:
312 len = ctdb_uint32_len(&cd->data.db_id);
315 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
316 len = ctdb_sock_addr_len(cd->data.addr);
319 case CTDB_CONTROL_GET_IFACES:
322 case CTDB_CONTROL_SET_IFACE_LINK_STATE:
323 len = ctdb_iface_len(cd->data.iface);
326 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE:
327 len = ctdb_connection_len(cd->data.conn);
330 case CTDB_CONTROL_GET_STAT_HISTORY:
333 case CTDB_CONTROL_SCHEDULE_FOR_DELETION:
334 len = ctdb_key_data_len(cd->data.key);
337 case CTDB_CONTROL_SET_DB_READONLY:
338 len = ctdb_uint32_len(&cd->data.db_id);
341 case CTDB_CONTROL_CHECK_SRVIDS:
344 case CTDB_CONTROL_TRAVERSE_START_EXT:
345 len = ctdb_traverse_start_ext_len(cd->data.traverse_start_ext);
348 case CTDB_CONTROL_GET_DB_STATISTICS:
349 len = ctdb_uint32_len(&cd->data.db_id);
352 case CTDB_CONTROL_SET_DB_STICKY:
353 len = ctdb_uint32_len(&cd->data.db_id);
356 case CTDB_CONTROL_RELOAD_PUBLIC_IPS:
359 case CTDB_CONTROL_TRAVERSE_ALL_EXT:
360 len = ctdb_traverse_all_ext_len(cd->data.traverse_all_ext);
363 case CTDB_CONTROL_RECEIVE_RECORDS:
364 len = ctdb_rec_buffer_len(cd->data.recbuf);
367 case CTDB_CONTROL_IPREALLOCATED:
370 case CTDB_CONTROL_GET_RUNSTATE:
373 case CTDB_CONTROL_DB_DETACH:
374 len = ctdb_uint32_len(&cd->data.db_id);
377 case CTDB_CONTROL_GET_NODES_FILE:
380 case CTDB_CONTROL_DB_FREEZE:
381 len = ctdb_uint32_len(&cd->data.db_id);
384 case CTDB_CONTROL_DB_THAW:
385 len = ctdb_uint32_len(&cd->data.db_id);
388 case CTDB_CONTROL_DB_TRANSACTION_START:
389 len = ctdb_transdb_len(cd->data.transdb);
392 case CTDB_CONTROL_DB_TRANSACTION_COMMIT:
393 len = ctdb_transdb_len(cd->data.transdb);
396 case CTDB_CONTROL_DB_TRANSACTION_CANCEL:
397 len = ctdb_uint32_len(&cd->data.db_id);
400 case CTDB_CONTROL_DB_PULL:
401 len = ctdb_pulldb_ext_len(cd->data.pulldb_ext);
404 case CTDB_CONTROL_DB_PUSH_START:
405 len = ctdb_pulldb_ext_len(cd->data.pulldb_ext);
408 case CTDB_CONTROL_DB_PUSH_CONFIRM:
409 len = ctdb_uint32_len(&cd->data.db_id);
412 case CTDB_CONTROL_DB_OPEN_FLAGS:
413 len = ctdb_uint32_len(&cd->data.db_id);
416 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
417 len = ctdb_string_len(&cd->data.db_name);
424 static void ctdb_req_control_data_push(struct ctdb_req_control_data *cd,
425 uint8_t *buf, size_t *npush)
427 size_t np = 0, offset;
430 switch (cd->opcode) {
431 case CTDB_CONTROL_PROCESS_EXISTS:
432 ctdb_pid_push(&cd->data.pid, buf, &np);
435 case CTDB_CONTROL_GETDBPATH:
436 ctdb_uint32_push(&cd->data.db_id, buf, &np);
439 case CTDB_CONTROL_SETVNNMAP:
440 ctdb_vnn_map_push(cd->data.vnnmap, buf, &np);
443 case CTDB_CONTROL_SET_DEBUG:
444 ctdb_uint32_push(&cd->data.loglevel, buf, &np);
447 case CTDB_CONTROL_PULL_DB:
448 ctdb_pulldb_push(cd->data.pulldb, buf, &np);
451 case CTDB_CONTROL_PUSH_DB:
452 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
455 case CTDB_CONTROL_SET_RECMODE:
456 ctdb_uint32_push(&cd->data.recmode, buf, &np);
459 case CTDB_CONTROL_DB_ATTACH:
460 ctdb_string_push(&cd->data.db_name, buf, &np);
463 case CTDB_CONTROL_SET_CALL:
466 case CTDB_CONTROL_TRAVERSE_START:
467 ctdb_traverse_start_push(cd->data.traverse_start, buf, &np);
470 case CTDB_CONTROL_TRAVERSE_ALL:
471 ctdb_traverse_all_push(cd->data.traverse_all, buf, &np);
474 case CTDB_CONTROL_TRAVERSE_DATA:
475 ctdb_rec_data_push(cd->data.rec_data, buf, &np);
478 case CTDB_CONTROL_GET_DBNAME:
479 ctdb_uint32_push(&cd->data.db_id, buf, &np);
482 case CTDB_CONTROL_ENABLE_SEQNUM:
483 ctdb_uint32_push(&cd->data.db_id, buf, &np);
486 case CTDB_CONTROL_UPDATE_SEQNUM:
487 ctdb_uint32_push(&cd->data.db_id, buf, &np);
490 case CTDB_CONTROL_SET_RECMASTER:
491 ctdb_uint32_push(&cd->data.recmaster, buf, &np);
494 case CTDB_CONTROL_TCP_CLIENT:
495 ctdb_connection_push(cd->data.conn, buf, &np);
498 case CTDB_CONTROL_TCP_ADD:
499 ctdb_connection_push(cd->data.conn, buf, &np);
502 case CTDB_CONTROL_TCP_REMOVE:
503 ctdb_connection_push(cd->data.conn, buf, &np);
506 case CTDB_CONTROL_SET_TUNABLE:
507 ctdb_tunable_push(cd->data.tunable, buf, &np);
510 case CTDB_CONTROL_GET_TUNABLE:
511 ctdb_stringn_push(&cd->data.tun_var, buf, &np);
514 case CTDB_CONTROL_MODIFY_FLAGS:
515 ctdb_node_flag_change_push(cd->data.flag_change, buf, &np);
518 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
519 ctdb_sock_addr_push(cd->data.addr, buf, &np);
522 case CTDB_CONTROL_SET_TCP_TICKLE_LIST:
523 ctdb_tickle_list_push(cd->data.tickles, buf, &np);
526 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
527 ctdb_string_push(&cd->data.db_name, buf, &np);
530 case CTDB_CONTROL_UPDATE_RECORD:
531 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
534 case CTDB_CONTROL_SEND_GRATUITOUS_ARP:
535 ctdb_addr_info_push(cd->data.addr_info, buf, &np);
538 case CTDB_CONTROL_WIPE_DATABASE:
539 ctdb_transdb_push(cd->data.transdb, buf, &np);
542 case CTDB_CONTROL_TRY_DELETE_RECORDS:
543 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
546 case CTDB_CONTROL_ADD_PUBLIC_IP:
547 ctdb_addr_info_push(cd->data.addr_info, buf, &np);
550 case CTDB_CONTROL_DEL_PUBLIC_IP:
551 ctdb_addr_info_push(cd->data.addr_info, buf, &np);
554 case CTDB_CONTROL_RELEASE_IP:
555 ctdb_public_ip_push(cd->data.pubip, buf, &np);
558 case CTDB_CONTROL_TAKEOVER_IP:
559 ctdb_public_ip_push(cd->data.pubip, buf, &np);
562 case CTDB_CONTROL_TRAVERSE_KILL:
563 ctdb_traverse_start_push(cd->data.traverse_start, buf, &np);
566 case CTDB_CONTROL_RECD_RECLOCK_LATENCY:
567 ctdb_double_push(&cd->data.reclock_latency, buf, &np);
570 case CTDB_CONTROL_SET_LMASTERROLE:
571 ctdb_uint32_push(&cd->data.role, buf, &np);
574 case CTDB_CONTROL_SET_RECMASTERROLE:
575 ctdb_uint32_push(&cd->data.role, buf, &np);
578 case CTDB_CONTROL_SET_BAN_STATE:
579 ctdb_ban_state_push(cd->data.ban_state, buf, &np);
582 case CTDB_CONTROL_REGISTER_NOTIFY:
583 ctdb_notify_data_push(cd->data.notify, buf, &np);
586 case CTDB_CONTROL_DEREGISTER_NOTIFY:
587 ctdb_uint64_push(&cd->data.srvid, buf, &np);
590 case CTDB_CONTROL_TRANS3_COMMIT:
591 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
594 case CTDB_CONTROL_GET_DB_SEQNUM:
597 ctdb_uint32_push(&cd->data.db_id, buf, &np);
599 ctdb_uint32_push(&u32, buf+offset, &np);
604 case CTDB_CONTROL_DB_SET_HEALTHY:
605 ctdb_uint32_push(&cd->data.db_id, buf, &np);
608 case CTDB_CONTROL_DB_GET_HEALTH:
609 ctdb_uint32_push(&cd->data.db_id, buf, &np);
612 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
613 ctdb_sock_addr_push(cd->data.addr, buf, &np);
616 case CTDB_CONTROL_SET_IFACE_LINK_STATE:
617 ctdb_iface_push(cd->data.iface, buf, &np);
620 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE:
621 ctdb_connection_push(cd->data.conn, buf, &np);
624 case CTDB_CONTROL_SCHEDULE_FOR_DELETION:
625 ctdb_key_data_push(cd->data.key, buf, &np);
628 case CTDB_CONTROL_SET_DB_READONLY:
629 ctdb_uint32_push(&cd->data.db_id, buf, &np);
632 case CTDB_CONTROL_CHECK_SRVIDS:
635 case CTDB_CONTROL_TRAVERSE_START_EXT:
636 ctdb_traverse_start_ext_push(cd->data.traverse_start_ext, buf,
640 case CTDB_CONTROL_GET_DB_STATISTICS:
641 ctdb_uint32_push(&cd->data.db_id, buf, &np);
644 case CTDB_CONTROL_SET_DB_STICKY:
645 ctdb_uint32_push(&cd->data.db_id, buf, &np);
648 case CTDB_CONTROL_TRAVERSE_ALL_EXT:
649 ctdb_traverse_all_ext_push(cd->data.traverse_all_ext, buf,
653 case CTDB_CONTROL_RECEIVE_RECORDS:
654 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
657 case CTDB_CONTROL_DB_DETACH:
658 ctdb_uint32_push(&cd->data.db_id, buf, &np);
661 case CTDB_CONTROL_DB_FREEZE:
662 ctdb_uint32_push(&cd->data.db_id, buf, &np);
665 case CTDB_CONTROL_DB_THAW:
666 ctdb_uint32_push(&cd->data.db_id, buf, &np);
669 case CTDB_CONTROL_DB_TRANSACTION_START:
670 ctdb_transdb_push(cd->data.transdb, buf, &np);
673 case CTDB_CONTROL_DB_TRANSACTION_COMMIT:
674 ctdb_transdb_push(cd->data.transdb, buf, &np);
677 case CTDB_CONTROL_DB_TRANSACTION_CANCEL:
678 ctdb_uint32_push(&cd->data.db_id, buf, &np);
681 case CTDB_CONTROL_DB_PULL:
682 ctdb_pulldb_ext_push(cd->data.pulldb_ext, buf, &np);
685 case CTDB_CONTROL_DB_PUSH_START:
686 ctdb_pulldb_ext_push(cd->data.pulldb_ext, buf, &np);
689 case CTDB_CONTROL_DB_PUSH_CONFIRM:
690 ctdb_uint32_push(&cd->data.db_id, buf, &np);
693 case CTDB_CONTROL_DB_OPEN_FLAGS:
694 ctdb_uint32_push(&cd->data.db_id, buf, &np);
697 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
698 ctdb_string_push(&cd->data.db_name, buf, &np);
705 static int ctdb_req_control_data_pull(uint8_t *buf, size_t buflen,
708 struct ctdb_req_control_data *cd,
711 size_t np = 0, offset;
718 case CTDB_CONTROL_PROCESS_EXISTS:
719 ret = ctdb_pid_pull(buf, buflen, &cd->data.pid, &np);
722 case CTDB_CONTROL_GETDBPATH:
723 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
726 case CTDB_CONTROL_SETVNNMAP:
727 ret = ctdb_vnn_map_pull(buf, buflen, mem_ctx,
728 &cd->data.vnnmap, &np);
731 case CTDB_CONTROL_SET_DEBUG:
732 ret = ctdb_uint32_pull(buf, buflen, &cd->data.loglevel, &np);
735 case CTDB_CONTROL_PULL_DB:
736 ret = ctdb_pulldb_pull(buf, buflen, mem_ctx,
737 &cd->data.pulldb, &np);
740 case CTDB_CONTROL_PUSH_DB:
741 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
742 &cd->data.recbuf, &np);
745 case CTDB_CONTROL_SET_RECMODE:
746 ret = ctdb_uint32_pull(buf, buflen, &cd->data.recmode, &np);
749 case CTDB_CONTROL_DB_ATTACH:
750 ret = ctdb_string_pull(buf, buflen, mem_ctx,
751 &cd->data.db_name, &np);
754 case CTDB_CONTROL_SET_CALL:
757 case CTDB_CONTROL_TRAVERSE_START:
758 ret = ctdb_traverse_start_pull(buf, buflen, mem_ctx,
759 &cd->data.traverse_start, &np);
762 case CTDB_CONTROL_TRAVERSE_ALL:
763 ret = ctdb_traverse_all_pull(buf, buflen, mem_ctx,
764 &cd->data.traverse_all, &np);
767 case CTDB_CONTROL_TRAVERSE_DATA:
768 ret = ctdb_rec_data_pull(buf, buflen, mem_ctx,
769 &cd->data.rec_data, &np);
772 case CTDB_CONTROL_GET_DBNAME:
773 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
776 case CTDB_CONTROL_ENABLE_SEQNUM:
777 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
780 case CTDB_CONTROL_UPDATE_SEQNUM:
781 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
784 case CTDB_CONTROL_SET_RECMASTER:
785 ret = ctdb_uint32_pull(buf, buflen, &cd->data.recmaster, &np);
788 case CTDB_CONTROL_TCP_CLIENT:
789 ret = ctdb_connection_pull(buf, buflen, mem_ctx,
790 &cd->data.conn, &np);
793 case CTDB_CONTROL_TCP_ADD:
794 ret = ctdb_connection_pull(buf, buflen, mem_ctx,
795 &cd->data.conn, &np);
798 case CTDB_CONTROL_TCP_REMOVE:
799 ret = ctdb_connection_pull(buf, buflen, mem_ctx,
800 &cd->data.conn, &np);
803 case CTDB_CONTROL_SET_TUNABLE:
804 ret = ctdb_tunable_pull(buf, buflen, mem_ctx,
805 &cd->data.tunable, &np);
808 case CTDB_CONTROL_GET_TUNABLE:
809 ret = ctdb_stringn_pull(buf, buflen, mem_ctx,
810 &cd->data.tun_var, &np);
813 case CTDB_CONTROL_MODIFY_FLAGS:
814 ret = ctdb_node_flag_change_pull(buf, buflen, mem_ctx,
815 &cd->data.flag_change, &np);
818 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
819 ret = ctdb_sock_addr_pull(buf, buflen, mem_ctx,
820 &cd->data.addr, &np);
823 case CTDB_CONTROL_SET_TCP_TICKLE_LIST:
824 ret = ctdb_tickle_list_pull(buf, buflen, mem_ctx,
825 &cd->data.tickles, &np);
828 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
829 ret = ctdb_string_pull(buf, buflen, mem_ctx,
830 &cd->data.db_name, &np);
833 case CTDB_CONTROL_UPDATE_RECORD:
834 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
835 &cd->data.recbuf, &np);
838 case CTDB_CONTROL_SEND_GRATUITOUS_ARP:
839 ret = ctdb_addr_info_pull(buf, buflen, mem_ctx,
840 &cd->data.addr_info, &np);
843 case CTDB_CONTROL_WIPE_DATABASE:
844 ret = ctdb_transdb_pull(buf, buflen, mem_ctx,
845 &cd->data.transdb, &np);
848 case CTDB_CONTROL_TRY_DELETE_RECORDS:
849 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
850 &cd->data.recbuf, &np);
853 case CTDB_CONTROL_ADD_PUBLIC_IP:
854 ret = ctdb_addr_info_pull(buf, buflen, mem_ctx,
855 &cd->data.addr_info, &np);
858 case CTDB_CONTROL_DEL_PUBLIC_IP:
859 ret = ctdb_addr_info_pull(buf, buflen, mem_ctx,
860 &cd->data.addr_info, &np);
863 case CTDB_CONTROL_RELEASE_IP:
864 ret = ctdb_public_ip_pull(buf, buflen, mem_ctx,
865 &cd->data.pubip, &np);
868 case CTDB_CONTROL_TAKEOVER_IP:
869 ret = ctdb_public_ip_pull(buf, buflen, mem_ctx,
870 &cd->data.pubip, &np);
873 case CTDB_CONTROL_TRAVERSE_KILL:
874 ret = ctdb_traverse_start_pull(buf, buflen, mem_ctx,
875 &cd->data.traverse_start, &np);
878 case CTDB_CONTROL_RECD_RECLOCK_LATENCY:
879 ret = ctdb_double_pull(buf, buflen, &cd->data.reclock_latency,
883 case CTDB_CONTROL_SET_LMASTERROLE:
884 ret = ctdb_uint32_pull(buf, buflen, &cd->data.role, &np);
887 case CTDB_CONTROL_SET_RECMASTERROLE:
888 ret = ctdb_uint32_pull(buf, buflen, &cd->data.role, &np);
891 case CTDB_CONTROL_SET_BAN_STATE:
892 ret = ctdb_ban_state_pull(buf, buflen, mem_ctx,
893 &cd->data.ban_state, &np);
896 case CTDB_CONTROL_REGISTER_NOTIFY:
897 ret = ctdb_notify_data_pull(buf, buflen, mem_ctx,
898 &cd->data.notify, &np);
901 case CTDB_CONTROL_DEREGISTER_NOTIFY:
902 ret = ctdb_uint64_pull(buf, buflen, &cd->data.srvid, &np);
905 case CTDB_CONTROL_TRANS3_COMMIT:
906 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
907 &cd->data.recbuf, &np);
910 case CTDB_CONTROL_GET_DB_SEQNUM:
912 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
917 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &u32, &np);
922 case CTDB_CONTROL_DB_SET_HEALTHY:
923 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
926 case CTDB_CONTROL_DB_GET_HEALTH:
927 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
930 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
931 ret = ctdb_sock_addr_pull(buf, buflen, mem_ctx,
932 &cd->data.addr, &np);
935 case CTDB_CONTROL_SET_IFACE_LINK_STATE:
936 ret = ctdb_iface_pull(buf, buflen, mem_ctx,
937 &cd->data.iface, &np);
940 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE:
941 ret = ctdb_connection_pull(buf, buflen, mem_ctx,
942 &cd->data.conn, &np);
945 case CTDB_CONTROL_SCHEDULE_FOR_DELETION:
946 ret = ctdb_key_data_pull(buf, buflen, mem_ctx,
950 case CTDB_CONTROL_SET_DB_READONLY:
951 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
954 case CTDB_CONTROL_CHECK_SRVIDS:
957 case CTDB_CONTROL_TRAVERSE_START_EXT:
958 ret = ctdb_traverse_start_ext_pull(buf, buflen, mem_ctx,
959 &cd->data.traverse_start_ext,
963 case CTDB_CONTROL_GET_DB_STATISTICS:
964 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
967 case CTDB_CONTROL_SET_DB_STICKY:
968 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
971 case CTDB_CONTROL_TRAVERSE_ALL_EXT:
972 ret = ctdb_traverse_all_ext_pull(buf, buflen, mem_ctx,
973 &cd->data.traverse_all_ext,
977 case CTDB_CONTROL_RECEIVE_RECORDS:
978 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
979 &cd->data.recbuf, &np);
982 case CTDB_CONTROL_DB_DETACH:
983 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
986 case CTDB_CONTROL_DB_FREEZE:
987 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
990 case CTDB_CONTROL_DB_THAW:
991 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
994 case CTDB_CONTROL_DB_TRANSACTION_START:
995 ret = ctdb_transdb_pull(buf, buflen, mem_ctx,
996 &cd->data.transdb, &np);
999 case CTDB_CONTROL_DB_TRANSACTION_COMMIT:
1000 ret = ctdb_transdb_pull(buf, buflen, mem_ctx,
1001 &cd->data.transdb, &np);
1004 case CTDB_CONTROL_DB_TRANSACTION_CANCEL:
1005 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1008 case CTDB_CONTROL_DB_PULL:
1009 ret = ctdb_pulldb_ext_pull(buf, buflen, mem_ctx,
1010 &cd->data.pulldb_ext, &np);
1013 case CTDB_CONTROL_DB_PUSH_START:
1014 ret = ctdb_pulldb_ext_pull(buf, buflen, mem_ctx,
1015 &cd->data.pulldb_ext, &np);
1018 case CTDB_CONTROL_DB_PUSH_CONFIRM:
1019 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1022 case CTDB_CONTROL_DB_OPEN_FLAGS:
1023 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1026 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
1027 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1028 &cd->data.db_name, &np);
1040 static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data *cd)
1048 switch (cd->opcode) {
1049 case CTDB_CONTROL_PROCESS_EXISTS:
1052 case CTDB_CONTROL_STATISTICS:
1053 len = ctdb_statistics_len(cd->data.stats);
1056 case CTDB_CONTROL_PING:
1059 case CTDB_CONTROL_GETDBPATH:
1060 len = ctdb_string_len(&cd->data.db_path);
1063 case CTDB_CONTROL_GETVNNMAP:
1064 len = ctdb_vnn_map_len(cd->data.vnnmap);
1067 case CTDB_CONTROL_SETVNNMAP:
1070 case CTDB_CONTROL_GET_DEBUG:
1071 len = ctdb_uint32_len(&cd->data.loglevel);
1074 case CTDB_CONTROL_SET_DEBUG:
1077 case CTDB_CONTROL_GET_DBMAP:
1078 len = ctdb_dbid_map_len(cd->data.dbmap);
1081 case CTDB_CONTROL_PULL_DB:
1082 len = ctdb_rec_buffer_len(cd->data.recbuf);
1085 case CTDB_CONTROL_PUSH_DB:
1088 case CTDB_CONTROL_GET_RECMODE:
1091 case CTDB_CONTROL_SET_RECMODE:
1094 case CTDB_CONTROL_STATISTICS_RESET:
1097 case CTDB_CONTROL_DB_ATTACH:
1098 len = ctdb_uint32_len(&cd->data.db_id);
1101 case CTDB_CONTROL_SET_CALL:
1104 case CTDB_CONTROL_TRAVERSE_START:
1107 case CTDB_CONTROL_TRAVERSE_ALL:
1110 case CTDB_CONTROL_TRAVERSE_DATA:
1113 case CTDB_CONTROL_REGISTER_SRVID:
1116 case CTDB_CONTROL_DEREGISTER_SRVID:
1119 case CTDB_CONTROL_GET_DBNAME:
1120 len = ctdb_string_len(&cd->data.db_name);
1123 case CTDB_CONTROL_ENABLE_SEQNUM:
1126 case CTDB_CONTROL_UPDATE_SEQNUM:
1129 case CTDB_CONTROL_DUMP_MEMORY:
1130 len = ctdb_string_len(&cd->data.mem_str);
1133 case CTDB_CONTROL_GET_PID:
1136 case CTDB_CONTROL_GET_RECMASTER:
1139 case CTDB_CONTROL_SET_RECMASTER:
1142 case CTDB_CONTROL_FREEZE:
1145 case CTDB_CONTROL_GET_PNN:
1148 case CTDB_CONTROL_SHUTDOWN:
1151 case CTDB_CONTROL_GET_MONMODE:
1154 case CTDB_CONTROL_TCP_CLIENT:
1157 case CTDB_CONTROL_TCP_ADD:
1160 case CTDB_CONTROL_TCP_REMOVE:
1163 case CTDB_CONTROL_STARTUP:
1166 case CTDB_CONTROL_SET_TUNABLE:
1169 case CTDB_CONTROL_GET_TUNABLE:
1170 len = ctdb_uint32_len(&cd->data.tun_value);
1173 case CTDB_CONTROL_LIST_TUNABLES:
1174 len = ctdb_var_list_len(cd->data.tun_var_list);
1177 case CTDB_CONTROL_MODIFY_FLAGS:
1180 case CTDB_CONTROL_GET_ALL_TUNABLES:
1181 len = ctdb_tunable_list_len(cd->data.tun_list);
1184 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
1185 len = ctdb_tickle_list_len(cd->data.tickles);
1188 case CTDB_CONTROL_SET_TCP_TICKLE_LIST:
1191 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
1192 len = ctdb_uint32_len(&cd->data.db_id);
1195 case CTDB_CONTROL_UPDATE_RECORD:
1198 case CTDB_CONTROL_SEND_GRATUITOUS_ARP:
1201 case CTDB_CONTROL_WIPE_DATABASE:
1204 case CTDB_CONTROL_UPTIME:
1205 len = ctdb_uptime_len(cd->data.uptime);
1208 case CTDB_CONTROL_START_RECOVERY:
1211 case CTDB_CONTROL_END_RECOVERY:
1214 case CTDB_CONTROL_RELOAD_NODES_FILE:
1217 case CTDB_CONTROL_TRY_DELETE_RECORDS:
1218 len = ctdb_rec_buffer_len(cd->data.recbuf);
1221 case CTDB_CONTROL_ENABLE_MONITOR:
1224 case CTDB_CONTROL_DISABLE_MONITOR:
1227 case CTDB_CONTROL_ADD_PUBLIC_IP:
1230 case CTDB_CONTROL_DEL_PUBLIC_IP:
1233 case CTDB_CONTROL_GET_CAPABILITIES:
1234 len = ctdb_uint32_len(&cd->data.caps);
1237 case CTDB_CONTROL_RECD_PING:
1240 case CTDB_CONTROL_RELEASE_IP:
1243 case CTDB_CONTROL_TAKEOVER_IP:
1246 case CTDB_CONTROL_GET_PUBLIC_IPS:
1247 len = ctdb_public_ip_list_len(cd->data.pubip_list);
1250 case CTDB_CONTROL_GET_NODEMAP:
1251 len = ctdb_node_map_len(cd->data.nodemap);
1254 case CTDB_CONTROL_TRAVERSE_KILL:
1257 case CTDB_CONTROL_RECD_RECLOCK_LATENCY:
1260 case CTDB_CONTROL_GET_RECLOCK_FILE:
1261 len = ctdb_string_len(&cd->data.reclock_file);
1264 case CTDB_CONTROL_STOP_NODE:
1267 case CTDB_CONTROL_CONTINUE_NODE:
1270 case CTDB_CONTROL_SET_LMASTERROLE:
1273 case CTDB_CONTROL_SET_RECMASTERROLE:
1276 case CTDB_CONTROL_SET_BAN_STATE:
1279 case CTDB_CONTROL_GET_BAN_STATE:
1280 len = ctdb_ban_state_len(cd->data.ban_state);
1283 case CTDB_CONTROL_SET_DB_PRIORITY:
1286 case CTDB_CONTROL_GET_DB_PRIORITY:
1289 case CTDB_CONTROL_REGISTER_NOTIFY:
1292 case CTDB_CONTROL_DEREGISTER_NOTIFY:
1295 case CTDB_CONTROL_TRANS3_COMMIT:
1298 case CTDB_CONTROL_GET_DB_SEQNUM:
1299 len = ctdb_uint64_len(&cd->data.seqnum);
1302 case CTDB_CONTROL_DB_SET_HEALTHY:
1305 case CTDB_CONTROL_DB_GET_HEALTH:
1306 len = ctdb_string_len(&cd->data.reason);
1309 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
1310 len = ctdb_public_ip_info_len(cd->data.ipinfo);
1313 case CTDB_CONTROL_GET_IFACES:
1314 len = ctdb_iface_list_len(cd->data.iface_list);
1317 case CTDB_CONTROL_SET_IFACE_LINK_STATE:
1320 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE:
1323 case CTDB_CONTROL_GET_STAT_HISTORY:
1324 len = ctdb_statistics_list_len(cd->data.stats_list);
1327 case CTDB_CONTROL_SCHEDULE_FOR_DELETION:
1330 case CTDB_CONTROL_SET_DB_READONLY:
1333 case CTDB_CONTROL_CHECK_SRVIDS:
1336 case CTDB_CONTROL_TRAVERSE_START_EXT:
1339 case CTDB_CONTROL_GET_DB_STATISTICS:
1340 len = ctdb_db_statistics_len(cd->data.dbstats);
1343 case CTDB_CONTROL_SET_DB_STICKY:
1346 case CTDB_CONTROL_RELOAD_PUBLIC_IPS:
1349 case CTDB_CONTROL_TRAVERSE_ALL_EXT:
1352 case CTDB_CONTROL_RECEIVE_RECORDS:
1353 len = ctdb_rec_buffer_len(cd->data.recbuf);
1356 case CTDB_CONTROL_IPREALLOCATED:
1359 case CTDB_CONTROL_GET_RUNSTATE:
1360 len = ctdb_uint32_len(&cd->data.runstate);
1363 case CTDB_CONTROL_DB_DETACH:
1366 case CTDB_CONTROL_GET_NODES_FILE:
1367 len = ctdb_node_map_len(cd->data.nodemap);
1370 case CTDB_CONTROL_DB_FREEZE:
1373 case CTDB_CONTROL_DB_THAW:
1376 case CTDB_CONTROL_DB_TRANSACTION_START:
1379 case CTDB_CONTROL_DB_TRANSACTION_COMMIT:
1382 case CTDB_CONTROL_DB_TRANSACTION_CANCEL:
1385 case CTDB_CONTROL_DB_PULL:
1386 len = ctdb_uint32_len(&cd->data.num_records);
1389 case CTDB_CONTROL_DB_PUSH_START:
1392 case CTDB_CONTROL_DB_PUSH_CONFIRM:
1393 len = ctdb_uint32_len(&cd->data.num_records);
1396 case CTDB_CONTROL_DB_OPEN_FLAGS:
1397 len = ctdb_int32_len(&cd->data.tdb_flags);
1400 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
1401 len = ctdb_uint32_len(&cd->data.db_id);
1408 static void ctdb_reply_control_data_push(struct ctdb_reply_control_data *cd,
1409 uint8_t *buf, size_t *npush)
1413 switch (cd->opcode) {
1414 case CTDB_CONTROL_STATISTICS:
1415 ctdb_statistics_push(cd->data.stats, buf, &np);
1418 case CTDB_CONTROL_GETDBPATH:
1419 ctdb_string_push(&cd->data.db_path, buf, &np);
1422 case CTDB_CONTROL_GETVNNMAP:
1423 ctdb_vnn_map_push(cd->data.vnnmap, buf, &np);
1426 case CTDB_CONTROL_GET_DEBUG:
1427 ctdb_uint32_push(&cd->data.loglevel, buf, &np);
1430 case CTDB_CONTROL_GET_DBMAP:
1431 ctdb_dbid_map_push(cd->data.dbmap, buf, &np);
1434 case CTDB_CONTROL_PULL_DB:
1435 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
1438 case CTDB_CONTROL_PUSH_DB:
1441 case CTDB_CONTROL_DB_ATTACH:
1442 ctdb_uint32_push(&cd->data.db_id, buf, &np);
1445 case CTDB_CONTROL_GET_DBNAME:
1446 ctdb_string_push(&cd->data.db_name, buf, &np);
1449 case CTDB_CONTROL_DUMP_MEMORY:
1450 ctdb_string_push(&cd->data.mem_str, buf, &np);
1453 case CTDB_CONTROL_GET_PID:
1456 case CTDB_CONTROL_GET_RECMASTER:
1459 case CTDB_CONTROL_GET_TUNABLE:
1460 ctdb_uint32_push(&cd->data.tun_value, buf, &np);
1463 case CTDB_CONTROL_LIST_TUNABLES:
1464 ctdb_var_list_push(cd->data.tun_var_list, buf, &np);
1467 case CTDB_CONTROL_GET_ALL_TUNABLES:
1468 ctdb_tunable_list_push(cd->data.tun_list, buf, &np);
1471 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
1472 ctdb_tickle_list_push(cd->data.tickles, buf, &np);
1475 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
1476 ctdb_uint32_push(&cd->data.db_id, buf, &np);
1479 case CTDB_CONTROL_UPTIME:
1480 ctdb_uptime_push(cd->data.uptime, buf, &np);
1483 case CTDB_CONTROL_TRY_DELETE_RECORDS:
1484 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
1487 case CTDB_CONTROL_GET_CAPABILITIES:
1488 ctdb_uint32_push(&cd->data.caps, buf, &np);
1491 case CTDB_CONTROL_GET_PUBLIC_IPS:
1492 ctdb_public_ip_list_push(cd->data.pubip_list, buf, &np);
1495 case CTDB_CONTROL_GET_NODEMAP:
1496 ctdb_node_map_push(cd->data.nodemap, buf, &np);
1499 case CTDB_CONTROL_GET_RECLOCK_FILE:
1500 ctdb_string_push(&cd->data.reclock_file, buf, &np);
1503 case CTDB_CONTROL_GET_BAN_STATE:
1504 ctdb_ban_state_push(cd->data.ban_state, buf, &np);
1507 case CTDB_CONTROL_GET_DB_PRIORITY:
1510 case CTDB_CONTROL_GET_DB_SEQNUM:
1511 ctdb_uint64_push(&cd->data.seqnum, buf, &np);
1514 case CTDB_CONTROL_DB_GET_HEALTH:
1515 ctdb_string_push(&cd->data.reason, buf, &np);
1518 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
1519 ctdb_public_ip_info_push(cd->data.ipinfo, buf, &np);
1522 case CTDB_CONTROL_GET_IFACES:
1523 ctdb_iface_list_push(cd->data.iface_list, buf, &np);
1526 case CTDB_CONTROL_GET_STAT_HISTORY:
1527 ctdb_statistics_list_push(cd->data.stats_list, buf, &np);
1530 case CTDB_CONTROL_CHECK_SRVIDS:
1533 case CTDB_CONTROL_GET_DB_STATISTICS:
1534 ctdb_db_statistics_push(cd->data.dbstats, buf, &np);
1537 case CTDB_CONTROL_RECEIVE_RECORDS:
1538 ctdb_rec_buffer_push(cd->data.recbuf, buf, &np);
1541 case CTDB_CONTROL_GET_RUNSTATE:
1542 ctdb_uint32_push(&cd->data.runstate, buf, &np);
1545 case CTDB_CONTROL_GET_NODES_FILE:
1546 ctdb_node_map_push(cd->data.nodemap, buf, &np);
1549 case CTDB_CONTROL_DB_PULL:
1550 ctdb_uint32_push(&cd->data.num_records, buf, &np);
1553 case CTDB_CONTROL_DB_PUSH_CONFIRM:
1554 ctdb_uint32_push(&cd->data.num_records, buf, &np);
1557 case CTDB_CONTROL_DB_OPEN_FLAGS:
1558 ctdb_int32_push(&cd->data.tdb_flags, buf, &np);
1561 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
1562 ctdb_uint32_push(&cd->data.db_id, buf, &np);
1569 static int ctdb_reply_control_data_pull(uint8_t *buf, size_t buflen,
1570 uint32_t opcode, TALLOC_CTX *mem_ctx,
1571 struct ctdb_reply_control_data *cd,
1577 cd->opcode = opcode;
1580 case CTDB_CONTROL_STATISTICS:
1581 ret = ctdb_statistics_pull(buf, buflen, mem_ctx,
1582 &cd->data.stats, &np);
1585 case CTDB_CONTROL_GETDBPATH:
1586 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1587 &cd->data.db_path, &np);
1590 case CTDB_CONTROL_GETVNNMAP:
1591 ret = ctdb_vnn_map_pull(buf, buflen, mem_ctx,
1592 &cd->data.vnnmap, &np);
1595 case CTDB_CONTROL_GET_DEBUG:
1596 ret = ctdb_uint32_pull(buf, buflen, &cd->data.loglevel, &np);
1599 case CTDB_CONTROL_GET_DBMAP:
1600 ret = ctdb_dbid_map_pull(buf, buflen, mem_ctx,
1601 &cd->data.dbmap, &np);
1604 case CTDB_CONTROL_PULL_DB:
1605 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
1606 &cd->data.recbuf, &np);
1609 case CTDB_CONTROL_PUSH_DB:
1612 case CTDB_CONTROL_DB_ATTACH:
1613 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1616 case CTDB_CONTROL_GET_DBNAME:
1617 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1618 &cd->data.db_name, &np);
1621 case CTDB_CONTROL_DUMP_MEMORY:
1622 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1623 &cd->data.mem_str, &np);
1626 case CTDB_CONTROL_GET_PID:
1629 case CTDB_CONTROL_GET_RECMASTER:
1632 case CTDB_CONTROL_GET_TUNABLE:
1633 ret = ctdb_uint32_pull(buf, buflen, &cd->data.tun_value,
1637 case CTDB_CONTROL_LIST_TUNABLES:
1638 ret = ctdb_var_list_pull(buf, buflen, mem_ctx,
1639 &cd->data.tun_var_list, &np);
1642 case CTDB_CONTROL_GET_ALL_TUNABLES:
1643 ret = ctdb_tunable_list_pull(buf, buflen, mem_ctx,
1644 &cd->data.tun_list, &np);
1647 case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
1648 ret = ctdb_tickle_list_pull(buf, buflen, mem_ctx,
1649 &cd->data.tickles, &np);
1652 case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
1653 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1656 case CTDB_CONTROL_UPTIME:
1657 ret = ctdb_uptime_pull(buf, buflen, mem_ctx,
1658 &cd->data.uptime, &np);
1661 case CTDB_CONTROL_TRY_DELETE_RECORDS:
1662 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
1663 &cd->data.recbuf, &np);
1666 case CTDB_CONTROL_GET_CAPABILITIES:
1667 ret = ctdb_uint32_pull(buf, buflen, &cd->data.caps, &np);
1670 case CTDB_CONTROL_GET_PUBLIC_IPS:
1671 ret = ctdb_public_ip_list_pull(buf, buflen, mem_ctx,
1672 &cd->data.pubip_list, &np);
1675 case CTDB_CONTROL_GET_NODEMAP:
1676 ret = ctdb_node_map_pull(buf, buflen, mem_ctx,
1677 &cd->data.nodemap, &np);
1680 case CTDB_CONTROL_GET_RECLOCK_FILE:
1681 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1682 &cd->data.reclock_file, &np);
1685 case CTDB_CONTROL_GET_BAN_STATE:
1686 ret = ctdb_ban_state_pull(buf, buflen, mem_ctx,
1687 &cd->data.ban_state, &np);
1690 case CTDB_CONTROL_GET_DB_PRIORITY:
1693 case CTDB_CONTROL_GET_DB_SEQNUM:
1694 ret = ctdb_uint64_pull(buf, buflen, &cd->data.seqnum, &np);
1697 case CTDB_CONTROL_DB_GET_HEALTH:
1698 ret = ctdb_string_pull(buf, buflen, mem_ctx,
1699 &cd->data.reason, &np);
1702 case CTDB_CONTROL_GET_PUBLIC_IP_INFO:
1703 ret = ctdb_public_ip_info_pull(buf, buflen, mem_ctx,
1704 &cd->data.ipinfo, &np);
1707 case CTDB_CONTROL_GET_IFACES:
1708 ret = ctdb_iface_list_pull(buf, buflen, mem_ctx,
1709 &cd->data.iface_list, &np);
1712 case CTDB_CONTROL_GET_STAT_HISTORY:
1713 ret = ctdb_statistics_list_pull(buf, buflen, mem_ctx,
1714 &cd->data.stats_list, &np);
1717 case CTDB_CONTROL_CHECK_SRVIDS:
1720 case CTDB_CONTROL_GET_DB_STATISTICS:
1721 ret = ctdb_db_statistics_pull(buf, buflen, mem_ctx,
1722 &cd->data.dbstats, &np);
1725 case CTDB_CONTROL_RECEIVE_RECORDS:
1726 ret = ctdb_rec_buffer_pull(buf, buflen, mem_ctx,
1727 &cd->data.recbuf, &np);
1730 case CTDB_CONTROL_GET_RUNSTATE:
1731 ret = ctdb_uint32_pull(buf, buflen, &cd->data.runstate, &np);
1734 case CTDB_CONTROL_GET_NODES_FILE:
1735 ret = ctdb_node_map_pull(buf, buflen, mem_ctx,
1736 &cd->data.nodemap, &np);
1739 case CTDB_CONTROL_DB_PULL:
1740 ret = ctdb_uint32_pull(buf, buflen, &cd->data.num_records,
1744 case CTDB_CONTROL_DB_PUSH_CONFIRM:
1745 ret = ctdb_uint32_pull(buf, buflen, &cd->data.num_records,
1749 case CTDB_CONTROL_DB_OPEN_FLAGS:
1750 ret = ctdb_int32_pull(buf, buflen, &cd->data.tdb_flags, &np);
1753 case CTDB_CONTROL_DB_ATTACH_REPLICATED:
1754 ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
1766 size_t ctdb_req_control_len(struct ctdb_req_header *h,
1767 struct ctdb_req_control *c)
1771 return ctdb_req_header_len(h) +
1772 ctdb_uint32_len(&c->opcode) +
1773 ctdb_uint32_len(&c->pad) +
1774 ctdb_uint64_len(&c->srvid) +
1775 ctdb_uint32_len(&c->client_id) +
1776 ctdb_uint32_len(&c->flags) +
1777 ctdb_uint32_len(&u32) +
1778 ctdb_req_control_data_len(&c->rdata);
1781 int ctdb_req_control_push(struct ctdb_req_header *h,
1782 struct ctdb_req_control *c,
1783 uint8_t *buf, size_t *buflen)
1785 size_t offset = 0, np;
1789 length = ctdb_req_control_len(h, c);
1790 if (*buflen < length) {
1795 h->length = *buflen;
1796 ctdb_req_header_push(h, buf+offset, &np);
1799 ctdb_uint32_push(&c->opcode, buf+offset, &np);
1802 ctdb_uint32_push(&c->pad, buf+offset, &np);
1805 ctdb_uint64_push(&c->srvid, buf+offset, &np);
1808 ctdb_uint32_push(&c->client_id, buf+offset, &np);
1811 ctdb_uint32_push(&c->flags, buf+offset, &np);
1814 u32 = ctdb_req_control_data_len(&c->rdata);
1815 ctdb_uint32_push(&u32, buf+offset, &np);
1818 ctdb_req_control_data_push(&c->rdata, buf+offset, &np);
1821 if (offset > *buflen) {
1828 int ctdb_req_control_pull(uint8_t *buf, size_t buflen,
1829 struct ctdb_req_header *h,
1830 TALLOC_CTX *mem_ctx,
1831 struct ctdb_req_control *c)
1833 struct ctdb_req_header header;
1834 size_t offset = 0, np;
1838 ret = ctdb_req_header_pull(buf+offset, buflen-offset, &header, &np);
1848 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &c->opcode, &np);
1854 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &c->pad, &np);
1860 ret = ctdb_uint64_pull(buf+offset, buflen-offset, &c->srvid, &np);
1866 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &c->client_id, &np);
1872 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &c->flags, &np);
1878 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &u32, &np);
1884 if (u32 > buflen-offset) {
1888 ret = ctdb_req_control_data_pull(buf+offset, u32, c->opcode, mem_ctx,
1895 if (offset > buflen) {
1902 size_t ctdb_reply_control_len(struct ctdb_req_header *h,
1903 struct ctdb_reply_control *c)
1905 uint32_t dsize, esize;
1907 if (c->status == 0) {
1908 dsize = ctdb_reply_control_data_len(&c->rdata);
1912 esize = ctdb_string_len(&c->errmsg);
1915 return ctdb_req_header_len(h) +
1916 ctdb_int32_len(&c->status) +
1917 ctdb_uint32_len(&dsize) +
1918 ctdb_uint32_len(&esize) +
1922 int ctdb_reply_control_push(struct ctdb_req_header *h,
1923 struct ctdb_reply_control *c,
1924 uint8_t *buf, size_t *buflen)
1926 size_t offset = 0, np;
1928 uint32_t dsize, esize;
1930 length = ctdb_reply_control_len(h, c);
1931 if (*buflen < length) {
1936 h->length = *buflen;
1937 ctdb_req_header_push(h, buf+offset, &np);
1940 ctdb_int32_push(&c->status, buf+offset, &np);
1943 if (c->status == 0) {
1944 dsize = ctdb_reply_control_data_len(&c->rdata);
1948 esize = ctdb_string_len(&c->errmsg);
1951 ctdb_uint32_push(&dsize, buf+offset, &np);
1954 ctdb_uint32_push(&esize, buf+offset, &np);
1957 if (c->status == 0) {
1958 ctdb_reply_control_data_push(&c->rdata, buf+offset, &np);
1960 ctdb_string_push(&c->errmsg, buf+offset, &np);
1967 int ctdb_reply_control_pull(uint8_t *buf, size_t buflen, uint32_t opcode,
1968 struct ctdb_req_header *h,
1969 TALLOC_CTX *mem_ctx,
1970 struct ctdb_reply_control *c)
1972 struct ctdb_req_header header;
1973 size_t offset = 0, np;
1974 uint32_t dsize, esize;
1977 ret = ctdb_req_header_pull(buf+offset, buflen-offset, &header, &np);
1987 ret = ctdb_int32_pull(buf+offset, buflen-offset, &c->status, &np);
1993 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &dsize, &np);
1999 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &esize, &np);
2007 if (c->status == 0) {
2008 if (buflen-offset < dsize) {
2012 ret = ctdb_reply_control_data_pull(buf+offset, dsize,
2013 opcode, mem_ctx, &c->rdata,
2021 if (buflen-offset < esize) {
2025 ret = ctdb_string_pull(buf+offset, esize, mem_ctx, &c->errmsg,