2015-04-14 10:20:05 +03:00
/*
CTDB protocol marshalling
Copyright ( C ) Amitay Isaacs 2015
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 3 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , see < http : //www.gnu.org/licenses/>.
*/
# include "replace.h"
# include "system/network.h"
# include <talloc.h>
# include <tdb.h>
# include "protocol.h"
# include "protocol_api.h"
# include "protocol_private.h"
struct ctdb_req_control_wire {
struct ctdb_req_header hdr ;
uint32_t opcode ;
uint32_t pad ;
uint64_t srvid ;
uint32_t client_id ;
uint32_t flags ;
uint32_t datalen ;
uint8_t data [ 1 ] ;
} ;
struct ctdb_reply_control_wire {
struct ctdb_req_header hdr ;
int32_t status ;
uint32_t datalen ;
uint32_t errorlen ;
uint8_t data [ 1 ] ;
} ;
static size_t ctdb_req_control_data_len ( struct ctdb_req_control_data * cd )
{
size_t len = 0 ;
2017-06-29 15:14:23 +03:00
uint32_t u32 ;
2015-04-14 10:20:05 +03:00
if ( cd = = NULL ) {
return 0 ;
}
switch ( cd - > opcode ) {
case CTDB_CONTROL_PROCESS_EXISTS :
2017-06-29 15:18:27 +03:00
len = ctdb_pid_len ( & cd - > data . pid ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_STATISTICS :
break ;
case CTDB_CONTROL_PING :
break ;
case CTDB_CONTROL_GETDBPATH :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETVNNMAP :
break ;
case CTDB_CONTROL_SETVNNMAP :
len = ctdb_vnn_map_len ( cd - > data . vnnmap ) ;
break ;
case CTDB_CONTROL_GET_DEBUG :
break ;
case CTDB_CONTROL_SET_DEBUG :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . loglevel ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DBMAP :
break ;
case CTDB_CONTROL_PULL_DB :
len = ctdb_pulldb_len ( cd - > data . pulldb ) ;
break ;
case CTDB_CONTROL_PUSH_DB :
len = ctdb_rec_buffer_len ( cd - > data . recbuf ) ;
break ;
case CTDB_CONTROL_GET_RECMODE :
break ;
case CTDB_CONTROL_SET_RECMODE :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . recmode ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_STATISTICS_RESET :
break ;
case CTDB_CONTROL_DB_ATTACH :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . db_name ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_CALL :
break ;
case CTDB_CONTROL_TRAVERSE_START :
len = ctdb_traverse_start_len ( cd - > data . traverse_start ) ;
break ;
case CTDB_CONTROL_TRAVERSE_ALL :
len = ctdb_traverse_all_len ( cd - > data . traverse_all ) ;
break ;
case CTDB_CONTROL_TRAVERSE_DATA :
len = ctdb_rec_data_len ( cd - > data . rec_data ) ;
break ;
case CTDB_CONTROL_REGISTER_SRVID :
break ;
case CTDB_CONTROL_DEREGISTER_SRVID :
break ;
case CTDB_CONTROL_GET_DBNAME :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_ENABLE_SEQNUM :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPDATE_SEQNUM :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DUMP_MEMORY :
break ;
case CTDB_CONTROL_GET_PID :
break ;
case CTDB_CONTROL_GET_RECMASTER :
break ;
case CTDB_CONTROL_SET_RECMASTER :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . recmaster ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_FREEZE :
break ;
case CTDB_CONTROL_GET_PNN :
break ;
case CTDB_CONTROL_SHUTDOWN :
break ;
case CTDB_CONTROL_GET_MONMODE :
break ;
case CTDB_CONTROL_TCP_CLIENT :
len = ctdb_connection_len ( cd - > data . conn ) ;
break ;
case CTDB_CONTROL_TCP_ADD :
len = ctdb_connection_len ( cd - > data . conn ) ;
break ;
case CTDB_CONTROL_TCP_REMOVE :
len = ctdb_connection_len ( cd - > data . conn ) ;
break ;
case CTDB_CONTROL_STARTUP :
break ;
case CTDB_CONTROL_SET_TUNABLE :
len = ctdb_tunable_len ( cd - > data . tunable ) ;
break ;
case CTDB_CONTROL_GET_TUNABLE :
2017-04-20 05:45:24 +03:00
len = ctdb_stringn_len ( & cd - > data . tun_var ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_LIST_TUNABLES :
break ;
case CTDB_CONTROL_MODIFY_FLAGS :
len = ctdb_node_flag_change_len ( cd - > data . flag_change ) ;
break ;
case CTDB_CONTROL_GET_ALL_TUNABLES :
break ;
case CTDB_CONTROL_GET_TCP_TICKLE_LIST :
len = ctdb_sock_addr_len ( cd - > data . addr ) ;
break ;
case CTDB_CONTROL_SET_TCP_TICKLE_LIST :
len = ctdb_tickle_list_len ( cd - > data . tickles ) ;
break ;
case CTDB_CONTROL_DB_ATTACH_PERSISTENT :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . db_name ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPDATE_RECORD :
len = ctdb_rec_buffer_len ( cd - > data . recbuf ) ;
break ;
case CTDB_CONTROL_SEND_GRATUITOUS_ARP :
len = ctdb_addr_info_len ( cd - > data . addr_info ) ;
break ;
case CTDB_CONTROL_WIPE_DATABASE :
len = ctdb_transdb_len ( cd - > data . transdb ) ;
break ;
case CTDB_CONTROL_UPTIME :
break ;
case CTDB_CONTROL_START_RECOVERY :
break ;
case CTDB_CONTROL_END_RECOVERY :
break ;
case CTDB_CONTROL_RELOAD_NODES_FILE :
break ;
case CTDB_CONTROL_TRY_DELETE_RECORDS :
len = ctdb_rec_buffer_len ( cd - > data . recbuf ) ;
break ;
case CTDB_CONTROL_ENABLE_MONITOR :
break ;
case CTDB_CONTROL_DISABLE_MONITOR :
break ;
case CTDB_CONTROL_ADD_PUBLIC_IP :
len = ctdb_addr_info_len ( cd - > data . addr_info ) ;
break ;
case CTDB_CONTROL_DEL_PUBLIC_IP :
len = ctdb_addr_info_len ( cd - > data . addr_info ) ;
break ;
case CTDB_CONTROL_GET_CAPABILITIES :
break ;
case CTDB_CONTROL_RECD_PING :
break ;
case CTDB_CONTROL_RELEASE_IP :
len = ctdb_public_ip_len ( cd - > data . pubip ) ;
break ;
case CTDB_CONTROL_TAKEOVER_IP :
len = ctdb_public_ip_len ( cd - > data . pubip ) ;
break ;
case CTDB_CONTROL_GET_PUBLIC_IPS :
break ;
case CTDB_CONTROL_GET_NODEMAP :
break ;
case CTDB_CONTROL_TRAVERSE_KILL :
len = ctdb_traverse_start_len ( cd - > data . traverse_start ) ;
break ;
case CTDB_CONTROL_RECD_RECLOCK_LATENCY :
2017-06-29 15:16:56 +03:00
len = ctdb_double_len ( & cd - > data . reclock_latency ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_RECLOCK_FILE :
break ;
case CTDB_CONTROL_STOP_NODE :
break ;
case CTDB_CONTROL_CONTINUE_NODE :
break ;
case CTDB_CONTROL_SET_LMASTERROLE :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . role ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_RECMASTERROLE :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . role ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_BAN_STATE :
len = ctdb_ban_state_len ( cd - > data . ban_state ) ;
break ;
case CTDB_CONTROL_GET_BAN_STATE :
break ;
case CTDB_CONTROL_REGISTER_NOTIFY :
len = ctdb_notify_data_len ( cd - > data . notify ) ;
break ;
case CTDB_CONTROL_DEREGISTER_NOTIFY :
2017-06-29 15:15:43 +03:00
len = ctdb_uint64_len ( & cd - > data . srvid ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRANS3_COMMIT :
len = ctdb_rec_buffer_len ( cd - > data . recbuf ) ;
break ;
case CTDB_CONTROL_GET_DB_SEQNUM :
2017-06-29 15:14:23 +03:00
u32 = 0 ;
len = ctdb_uint32_len ( & cd - > data . db_id ) + ctdb_uint32_len ( & u32 ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_SET_HEALTHY :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_GET_HEALTH :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IP_INFO :
len = ctdb_sock_addr_len ( cd - > data . addr ) ;
break ;
case CTDB_CONTROL_GET_IFACES :
break ;
case CTDB_CONTROL_SET_IFACE_LINK_STATE :
len = ctdb_iface_len ( cd - > data . iface ) ;
break ;
case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE :
len = ctdb_connection_len ( cd - > data . conn ) ;
break ;
case CTDB_CONTROL_GET_STAT_HISTORY :
break ;
case CTDB_CONTROL_SCHEDULE_FOR_DELETION :
len = ctdb_key_data_len ( cd - > data . key ) ;
break ;
case CTDB_CONTROL_SET_DB_READONLY :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_CHECK_SRVIDS :
break ;
case CTDB_CONTROL_TRAVERSE_START_EXT :
len = ctdb_traverse_start_ext_len ( cd - > data . traverse_start_ext ) ;
break ;
case CTDB_CONTROL_GET_DB_STATISTICS :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_DB_STICKY :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_RELOAD_PUBLIC_IPS :
break ;
case CTDB_CONTROL_TRAVERSE_ALL_EXT :
len = ctdb_traverse_all_ext_len ( cd - > data . traverse_all_ext ) ;
break ;
case CTDB_CONTROL_RECEIVE_RECORDS :
len = ctdb_rec_buffer_len ( cd - > data . recbuf ) ;
break ;
case CTDB_CONTROL_IPREALLOCATED :
break ;
case CTDB_CONTROL_GET_RUNSTATE :
break ;
case CTDB_CONTROL_DB_DETACH :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_NODES_FILE :
break ;
2015-07-31 18:47:22 +03:00
case CTDB_CONTROL_DB_FREEZE :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_THAW :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_TRANSACTION_START :
len = ctdb_transdb_len ( cd - > data . transdb ) ;
break ;
case CTDB_CONTROL_DB_TRANSACTION_COMMIT :
len = ctdb_transdb_len ( cd - > data . transdb ) ;
break ;
case CTDB_CONTROL_DB_TRANSACTION_CANCEL :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-07-31 18:47:22 +03:00
break ;
2016-02-19 02:54:15 +03:00
case CTDB_CONTROL_DB_PULL :
len = ctdb_pulldb_ext_len ( cd - > data . pulldb_ext ) ;
break ;
case CTDB_CONTROL_DB_PUSH_START :
len = ctdb_pulldb_ext_len ( cd - > data . pulldb_ext ) ;
break ;
case CTDB_CONTROL_DB_PUSH_CONFIRM :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2016-02-19 02:54:15 +03:00
break ;
2017-06-14 09:24:02 +03:00
case CTDB_CONTROL_DB_OPEN_FLAGS :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2017-06-14 09:24:02 +03:00
break ;
2017-03-02 09:07:13 +03:00
case CTDB_CONTROL_DB_ATTACH_REPLICATED :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . db_name ) ;
2017-03-02 09:07:13 +03:00
break ;
2015-04-14 10:20:05 +03:00
}
return len ;
}
static void ctdb_req_control_data_push ( struct ctdb_req_control_data * cd ,
uint8_t * buf )
{
2017-06-29 15:14:23 +03:00
size_t np , offset ;
uint32_t u32 ;
2015-04-14 10:20:05 +03:00
switch ( cd - > opcode ) {
case CTDB_CONTROL_PROCESS_EXISTS :
2017-06-29 15:18:27 +03:00
ctdb_pid_push ( & cd - > data . pid , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETDBPATH :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SETVNNMAP :
2017-06-29 12:04:56 +03:00
ctdb_vnn_map_push ( cd - > data . vnnmap , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_DEBUG :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . loglevel , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_PULL_DB :
2017-06-29 12:50:21 +03:00
ctdb_pulldb_push ( cd - > data . pulldb , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_PUSH_DB :
2017-06-29 16:41:08 +03:00
ctdb_rec_buffer_push ( cd - > data . recbuf , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_RECMODE :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . recmode , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_ATTACH :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . db_name , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_CALL :
break ;
case CTDB_CONTROL_TRAVERSE_START :
2017-06-29 16:48:01 +03:00
ctdb_traverse_start_push ( cd - > data . traverse_start , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_ALL :
2017-06-29 16:56:02 +03:00
ctdb_traverse_all_push ( cd - > data . traverse_all , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_DATA :
2017-06-29 16:27:33 +03:00
ctdb_rec_data_push ( cd - > data . rec_data , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DBNAME :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_ENABLE_SEQNUM :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPDATE_SEQNUM :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_RECMASTER :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . recmaster , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TCP_CLIENT :
2017-06-29 17:31:21 +03:00
ctdb_connection_push ( cd - > data . conn , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TCP_ADD :
2017-06-29 17:31:21 +03:00
ctdb_connection_push ( cd - > data . conn , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TCP_REMOVE :
2017-06-29 17:31:21 +03:00
ctdb_connection_push ( cd - > data . conn , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_TUNABLE :
2017-06-29 17:36:18 +03:00
ctdb_tunable_push ( cd - > data . tunable , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_TUNABLE :
2017-04-20 05:45:24 +03:00
ctdb_stringn_push ( & cd - > data . tun_var , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_MODIFY_FLAGS :
2017-06-29 17:42:53 +03:00
ctdb_node_flag_change_push ( cd - > data . flag_change , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_TCP_TICKLE_LIST :
2017-07-18 10:12:37 +03:00
ctdb_sock_addr_push ( cd - > data . addr , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_TCP_TICKLE_LIST :
2017-07-04 10:56:12 +03:00
ctdb_tickle_list_push ( cd - > data . tickles , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_ATTACH_PERSISTENT :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . db_name , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPDATE_RECORD :
2017-06-29 16:41:08 +03:00
ctdb_rec_buffer_push ( cd - > data . recbuf , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SEND_GRATUITOUS_ARP :
2017-07-04 11:12:04 +03:00
ctdb_addr_info_push ( cd - > data . addr_info , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_WIPE_DATABASE :
2017-07-05 10:51:03 +03:00
ctdb_transdb_push ( cd - > data . transdb , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRY_DELETE_RECORDS :
2017-06-29 16:41:08 +03:00
ctdb_rec_buffer_push ( cd - > data . recbuf , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_ADD_PUBLIC_IP :
2017-07-04 11:12:04 +03:00
ctdb_addr_info_push ( cd - > data . addr_info , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DEL_PUBLIC_IP :
2017-07-04 11:12:04 +03:00
ctdb_addr_info_push ( cd - > data . addr_info , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_RELEASE_IP :
ctdb_public_ip_push ( cd - > data . pubip , buf ) ;
break ;
case CTDB_CONTROL_TAKEOVER_IP :
ctdb_public_ip_push ( cd - > data . pubip , buf ) ;
break ;
case CTDB_CONTROL_TRAVERSE_KILL :
2017-06-29 16:48:01 +03:00
ctdb_traverse_start_push ( cd - > data . traverse_start , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_RECD_RECLOCK_LATENCY :
2017-06-29 15:16:56 +03:00
ctdb_double_push ( & cd - > data . reclock_latency , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_LMASTERROLE :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . role , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_RECMASTERROLE :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . role , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_BAN_STATE :
ctdb_ban_state_push ( cd - > data . ban_state , buf ) ;
break ;
case CTDB_CONTROL_REGISTER_NOTIFY :
ctdb_notify_data_push ( cd - > data . notify , buf ) ;
break ;
case CTDB_CONTROL_DEREGISTER_NOTIFY :
2017-06-29 15:15:43 +03:00
ctdb_uint64_push ( & cd - > data . srvid , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRANS3_COMMIT :
2017-06-29 16:41:08 +03:00
ctdb_rec_buffer_push ( cd - > data . recbuf , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DB_SEQNUM :
2017-06-29 15:14:23 +03:00
u32 = 0 ;
offset = 0 ;
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
offset + = np ;
ctdb_uint32_push ( & u32 , buf + offset , & np ) ;
offset + = np ;
np = offset ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_SET_HEALTHY :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_GET_HEALTH :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IP_INFO :
2017-07-18 10:12:37 +03:00
ctdb_sock_addr_push ( cd - > data . addr , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_IFACE_LINK_STATE :
ctdb_iface_push ( cd - > data . iface , buf ) ;
break ;
case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE :
2017-06-29 17:31:21 +03:00
ctdb_connection_push ( cd - > data . conn , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SCHEDULE_FOR_DELETION :
ctdb_key_data_push ( cd - > data . key , buf ) ;
break ;
case CTDB_CONTROL_SET_DB_READONLY :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_CHECK_SRVIDS :
break ;
case CTDB_CONTROL_TRAVERSE_START_EXT :
2017-06-29 17:16:58 +03:00
ctdb_traverse_start_ext_push ( cd - > data . traverse_start_ext , buf ,
& np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DB_STATISTICS :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_DB_STICKY :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_ALL_EXT :
2017-06-29 17:24:40 +03:00
ctdb_traverse_all_ext_push ( cd - > data . traverse_all_ext , buf ,
& np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_RECEIVE_RECORDS :
2017-06-29 16:41:08 +03:00
ctdb_rec_buffer_push ( cd - > data . recbuf , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_DETACH :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
2015-07-31 18:47:22 +03:00
case CTDB_CONTROL_DB_FREEZE :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_THAW :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_TRANSACTION_START :
2017-07-05 10:51:03 +03:00
ctdb_transdb_push ( cd - > data . transdb , buf , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_TRANSACTION_COMMIT :
2017-07-05 10:51:03 +03:00
ctdb_transdb_push ( cd - > data . transdb , buf , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_TRANSACTION_CANCEL :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
2016-02-19 02:54:15 +03:00
case CTDB_CONTROL_DB_PULL :
2017-06-29 12:55:15 +03:00
ctdb_pulldb_ext_push ( cd - > data . pulldb_ext , buf , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
case CTDB_CONTROL_DB_PUSH_START :
2017-06-29 12:55:15 +03:00
ctdb_pulldb_ext_push ( cd - > data . pulldb_ext , buf , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
case CTDB_CONTROL_DB_PUSH_CONFIRM :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
2017-06-14 09:24:02 +03:00
case CTDB_CONTROL_DB_OPEN_FLAGS :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2017-06-14 09:24:02 +03:00
break ;
2017-03-02 09:07:13 +03:00
case CTDB_CONTROL_DB_ATTACH_REPLICATED :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . db_name , buf , & np ) ;
2017-03-02 09:07:13 +03:00
break ;
2015-04-14 10:20:05 +03:00
}
}
static int ctdb_req_control_data_pull ( uint8_t * buf , size_t buflen ,
uint32_t opcode ,
TALLOC_CTX * mem_ctx ,
struct ctdb_req_control_data * cd )
{
2017-06-29 15:14:23 +03:00
size_t np , offset ;
2017-07-26 18:15:34 +03:00
uint32_t u32 ;
2015-04-14 10:20:05 +03:00
int ret = 0 ;
cd - > opcode = opcode ;
switch ( opcode ) {
case CTDB_CONTROL_PROCESS_EXISTS :
2017-06-29 15:18:27 +03:00
ret = ctdb_pid_pull ( buf , buflen , & cd - > data . pid , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETDBPATH :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SETVNNMAP :
ret = ctdb_vnn_map_pull ( buf , buflen , mem_ctx ,
2017-06-29 12:04:56 +03:00
& cd - > data . vnnmap , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_DEBUG :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . loglevel , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_PULL_DB :
ret = ctdb_pulldb_pull ( buf , buflen , mem_ctx ,
2017-06-29 12:50:21 +03:00
& cd - > data . pulldb , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_PUSH_DB :
ret = ctdb_rec_buffer_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:41:08 +03:00
& cd - > data . recbuf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_RECMODE :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . recmode , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_ATTACH :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . db_name , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_CALL :
break ;
case CTDB_CONTROL_TRAVERSE_START :
ret = ctdb_traverse_start_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:48:01 +03:00
& cd - > data . traverse_start , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_ALL :
ret = ctdb_traverse_all_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:56:02 +03:00
& cd - > data . traverse_all , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_DATA :
ret = ctdb_rec_data_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:27:33 +03:00
& cd - > data . rec_data , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DBNAME :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_ENABLE_SEQNUM :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPDATE_SEQNUM :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_RECMASTER :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . recmaster , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TCP_CLIENT :
ret = ctdb_connection_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:31:21 +03:00
& cd - > data . conn , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TCP_ADD :
ret = ctdb_connection_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:31:21 +03:00
& cd - > data . conn , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TCP_REMOVE :
ret = ctdb_connection_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:31:21 +03:00
& cd - > data . conn , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_TUNABLE :
ret = ctdb_tunable_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:36:18 +03:00
& cd - > data . tunable , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_TUNABLE :
ret = ctdb_stringn_pull ( buf , buflen , mem_ctx ,
2017-04-20 05:45:24 +03:00
& cd - > data . tun_var , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_MODIFY_FLAGS :
ret = ctdb_node_flag_change_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:42:53 +03:00
& cd - > data . flag_change , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_TCP_TICKLE_LIST :
ret = ctdb_sock_addr_pull ( buf , buflen , mem_ctx ,
2017-07-18 10:12:37 +03:00
& cd - > data . addr , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_TCP_TICKLE_LIST :
ret = ctdb_tickle_list_pull ( buf , buflen , mem_ctx ,
2017-07-04 10:56:12 +03:00
& cd - > data . tickles , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_ATTACH_PERSISTENT :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . db_name , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPDATE_RECORD :
ret = ctdb_rec_buffer_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:41:08 +03:00
& cd - > data . recbuf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SEND_GRATUITOUS_ARP :
ret = ctdb_addr_info_pull ( buf , buflen , mem_ctx ,
2017-07-04 11:12:04 +03:00
& cd - > data . addr_info , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_WIPE_DATABASE :
ret = ctdb_transdb_pull ( buf , buflen , mem_ctx ,
2017-07-05 10:51:03 +03:00
& cd - > data . transdb , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRY_DELETE_RECORDS :
ret = ctdb_rec_buffer_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:41:08 +03:00
& cd - > data . recbuf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_ADD_PUBLIC_IP :
ret = ctdb_addr_info_pull ( buf , buflen , mem_ctx ,
2017-07-04 11:12:04 +03:00
& cd - > data . addr_info , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DEL_PUBLIC_IP :
ret = ctdb_addr_info_pull ( buf , buflen , mem_ctx ,
2017-07-04 11:12:04 +03:00
& cd - > data . addr_info , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_RELEASE_IP :
ret = ctdb_public_ip_pull ( buf , buflen , mem_ctx ,
& cd - > data . pubip ) ;
break ;
case CTDB_CONTROL_TAKEOVER_IP :
ret = ctdb_public_ip_pull ( buf , buflen , mem_ctx ,
& cd - > data . pubip ) ;
break ;
case CTDB_CONTROL_TRAVERSE_KILL :
ret = ctdb_traverse_start_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:48:01 +03:00
& cd - > data . traverse_start , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_RECD_RECLOCK_LATENCY :
2017-06-29 15:16:56 +03:00
ret = ctdb_double_pull ( buf , buflen , & cd - > data . reclock_latency ,
& np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_LMASTERROLE :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . role , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_RECMASTERROLE :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . role , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_BAN_STATE :
ret = ctdb_ban_state_pull ( buf , buflen , mem_ctx ,
& cd - > data . ban_state ) ;
break ;
case CTDB_CONTROL_REGISTER_NOTIFY :
ret = ctdb_notify_data_pull ( buf , buflen , mem_ctx ,
& cd - > data . notify ) ;
break ;
case CTDB_CONTROL_DEREGISTER_NOTIFY :
2017-06-29 15:15:43 +03:00
ctdb_uint64_pull ( buf , buflen , & cd - > data . srvid , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRANS3_COMMIT :
ret = ctdb_rec_buffer_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:41:08 +03:00
& cd - > data . recbuf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DB_SEQNUM :
2017-06-29 15:14:23 +03:00
offset = 0 ;
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2017-07-26 18:15:34 +03:00
if ( ret ! = 0 ) {
break ;
}
2017-06-29 15:14:23 +03:00
offset + = np ;
ret = ctdb_uint32_pull ( buf + offset , buflen - offset , & u32 , & np ) ;
offset + = np ;
np = offset ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_SET_HEALTHY :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_GET_HEALTH :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IP_INFO :
ret = ctdb_sock_addr_pull ( buf , buflen , mem_ctx ,
2017-07-18 10:12:37 +03:00
& cd - > data . addr , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_IFACE_LINK_STATE :
ret = ctdb_iface_pull ( buf , buflen , mem_ctx ,
& cd - > data . iface ) ;
break ;
case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE :
ret = ctdb_connection_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:31:21 +03:00
& cd - > data . conn , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SCHEDULE_FOR_DELETION :
ret = ctdb_key_data_pull ( buf , buflen , mem_ctx ,
& cd - > data . key ) ;
break ;
case CTDB_CONTROL_SET_DB_READONLY :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_CHECK_SRVIDS :
break ;
case CTDB_CONTROL_TRAVERSE_START_EXT :
ret = ctdb_traverse_start_ext_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:16:58 +03:00
& cd - > data . traverse_start_ext ,
& np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DB_STATISTICS :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_DB_STICKY :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_ALL_EXT :
ret = ctdb_traverse_all_ext_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:24:40 +03:00
& cd - > data . traverse_all_ext ,
& np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_RECEIVE_RECORDS :
ret = ctdb_rec_buffer_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:41:08 +03:00
& cd - > data . recbuf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_DETACH :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
2015-07-31 18:47:22 +03:00
case CTDB_CONTROL_DB_FREEZE :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_THAW :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_TRANSACTION_START :
ret = ctdb_transdb_pull ( buf , buflen , mem_ctx ,
2017-07-05 10:51:03 +03:00
& cd - > data . transdb , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_TRANSACTION_COMMIT :
ret = ctdb_transdb_pull ( buf , buflen , mem_ctx ,
2017-07-05 10:51:03 +03:00
& cd - > data . transdb , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_TRANSACTION_CANCEL :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
2016-02-19 02:54:15 +03:00
case CTDB_CONTROL_DB_PULL :
ret = ctdb_pulldb_ext_pull ( buf , buflen , mem_ctx ,
2017-06-29 12:55:15 +03:00
& cd - > data . pulldb_ext , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
case CTDB_CONTROL_DB_PUSH_START :
ret = ctdb_pulldb_ext_pull ( buf , buflen , mem_ctx ,
2017-06-29 12:55:15 +03:00
& cd - > data . pulldb_ext , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
case CTDB_CONTROL_DB_PUSH_CONFIRM :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
2017-06-14 09:24:02 +03:00
case CTDB_CONTROL_DB_OPEN_FLAGS :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2017-06-14 09:24:02 +03:00
break ;
2017-03-02 09:07:13 +03:00
case CTDB_CONTROL_DB_ATTACH_REPLICATED :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . db_name , & np ) ;
2017-03-02 09:07:13 +03:00
break ;
2015-04-14 10:20:05 +03:00
}
return ret ;
}
static size_t ctdb_reply_control_data_len ( struct ctdb_reply_control_data * cd )
{
size_t len = 0 ;
if ( cd = = NULL ) {
return 0 ;
}
switch ( cd - > opcode ) {
case CTDB_CONTROL_PROCESS_EXISTS :
break ;
case CTDB_CONTROL_STATISTICS :
len = ctdb_statistics_len ( cd - > data . stats ) ;
break ;
case CTDB_CONTROL_PING :
break ;
case CTDB_CONTROL_GETDBPATH :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . db_path ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETVNNMAP :
len = ctdb_vnn_map_len ( cd - > data . vnnmap ) ;
break ;
case CTDB_CONTROL_SETVNNMAP :
break ;
case CTDB_CONTROL_GET_DEBUG :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . loglevel ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_DEBUG :
break ;
case CTDB_CONTROL_GET_DBMAP :
len = ctdb_dbid_map_len ( cd - > data . dbmap ) ;
break ;
case CTDB_CONTROL_PULL_DB :
len = ctdb_rec_buffer_len ( cd - > data . recbuf ) ;
break ;
case CTDB_CONTROL_PUSH_DB :
break ;
case CTDB_CONTROL_GET_RECMODE :
break ;
case CTDB_CONTROL_SET_RECMODE :
break ;
case CTDB_CONTROL_STATISTICS_RESET :
break ;
case CTDB_CONTROL_DB_ATTACH :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_CALL :
break ;
case CTDB_CONTROL_TRAVERSE_START :
break ;
case CTDB_CONTROL_TRAVERSE_ALL :
break ;
case CTDB_CONTROL_TRAVERSE_DATA :
break ;
case CTDB_CONTROL_REGISTER_SRVID :
break ;
case CTDB_CONTROL_DEREGISTER_SRVID :
break ;
case CTDB_CONTROL_GET_DBNAME :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . db_name ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_ENABLE_SEQNUM :
break ;
case CTDB_CONTROL_UPDATE_SEQNUM :
break ;
case CTDB_CONTROL_DUMP_MEMORY :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . mem_str ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PID :
break ;
case CTDB_CONTROL_GET_RECMASTER :
break ;
case CTDB_CONTROL_SET_RECMASTER :
break ;
case CTDB_CONTROL_FREEZE :
break ;
case CTDB_CONTROL_GET_PNN :
break ;
case CTDB_CONTROL_SHUTDOWN :
break ;
case CTDB_CONTROL_GET_MONMODE :
break ;
case CTDB_CONTROL_TCP_CLIENT :
break ;
case CTDB_CONTROL_TCP_ADD :
break ;
case CTDB_CONTROL_TCP_REMOVE :
break ;
case CTDB_CONTROL_STARTUP :
break ;
case CTDB_CONTROL_SET_TUNABLE :
break ;
case CTDB_CONTROL_GET_TUNABLE :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . tun_value ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_LIST_TUNABLES :
len = ctdb_var_list_len ( cd - > data . tun_var_list ) ;
break ;
case CTDB_CONTROL_MODIFY_FLAGS :
break ;
case CTDB_CONTROL_GET_ALL_TUNABLES :
len = ctdb_tunable_list_len ( cd - > data . tun_list ) ;
break ;
case CTDB_CONTROL_GET_TCP_TICKLE_LIST :
len = ctdb_tickle_list_len ( cd - > data . tickles ) ;
break ;
case CTDB_CONTROL_SET_TCP_TICKLE_LIST :
break ;
case CTDB_CONTROL_DB_ATTACH_PERSISTENT :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPDATE_RECORD :
break ;
case CTDB_CONTROL_SEND_GRATUITOUS_ARP :
break ;
case CTDB_CONTROL_WIPE_DATABASE :
break ;
case CTDB_CONTROL_UPTIME :
len = ctdb_uptime_len ( cd - > data . uptime ) ;
break ;
case CTDB_CONTROL_START_RECOVERY :
break ;
case CTDB_CONTROL_END_RECOVERY :
break ;
case CTDB_CONTROL_RELOAD_NODES_FILE :
break ;
case CTDB_CONTROL_TRY_DELETE_RECORDS :
len = ctdb_rec_buffer_len ( cd - > data . recbuf ) ;
break ;
case CTDB_CONTROL_ENABLE_MONITOR :
break ;
case CTDB_CONTROL_DISABLE_MONITOR :
break ;
case CTDB_CONTROL_ADD_PUBLIC_IP :
break ;
case CTDB_CONTROL_DEL_PUBLIC_IP :
break ;
case CTDB_CONTROL_GET_CAPABILITIES :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . caps ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_RECD_PING :
break ;
case CTDB_CONTROL_RELEASE_IP :
break ;
case CTDB_CONTROL_TAKEOVER_IP :
break ;
case CTDB_CONTROL_GET_PUBLIC_IPS :
len = ctdb_public_ip_list_len ( cd - > data . pubip_list ) ;
break ;
case CTDB_CONTROL_GET_NODEMAP :
len = ctdb_node_map_len ( cd - > data . nodemap ) ;
break ;
case CTDB_CONTROL_TRAVERSE_KILL :
break ;
case CTDB_CONTROL_RECD_RECLOCK_LATENCY :
break ;
case CTDB_CONTROL_GET_RECLOCK_FILE :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . reclock_file ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_STOP_NODE :
break ;
case CTDB_CONTROL_CONTINUE_NODE :
break ;
case CTDB_CONTROL_SET_LMASTERROLE :
break ;
case CTDB_CONTROL_SET_RECMASTERROLE :
break ;
case CTDB_CONTROL_SET_BAN_STATE :
break ;
case CTDB_CONTROL_GET_BAN_STATE :
len = ctdb_ban_state_len ( cd - > data . ban_state ) ;
break ;
case CTDB_CONTROL_SET_DB_PRIORITY :
break ;
case CTDB_CONTROL_GET_DB_PRIORITY :
break ;
case CTDB_CONTROL_REGISTER_NOTIFY :
break ;
case CTDB_CONTROL_DEREGISTER_NOTIFY :
break ;
case CTDB_CONTROL_TRANS3_COMMIT :
break ;
case CTDB_CONTROL_GET_DB_SEQNUM :
2017-06-29 15:15:43 +03:00
len = ctdb_uint64_len ( & cd - > data . seqnum ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_SET_HEALTHY :
break ;
case CTDB_CONTROL_DB_GET_HEALTH :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . reason ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IP_INFO :
len = ctdb_public_ip_info_len ( cd - > data . ipinfo ) ;
break ;
case CTDB_CONTROL_GET_IFACES :
len = ctdb_iface_list_len ( cd - > data . iface_list ) ;
break ;
case CTDB_CONTROL_SET_IFACE_LINK_STATE :
break ;
case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE :
break ;
case CTDB_CONTROL_GET_STAT_HISTORY :
len = ctdb_statistics_list_len ( cd - > data . stats_list ) ;
break ;
case CTDB_CONTROL_SCHEDULE_FOR_DELETION :
break ;
case CTDB_CONTROL_SET_DB_READONLY :
break ;
case CTDB_CONTROL_CHECK_SRVIDS :
break ;
case CTDB_CONTROL_TRAVERSE_START_EXT :
break ;
case CTDB_CONTROL_GET_DB_STATISTICS :
len = ctdb_db_statistics_len ( cd - > data . dbstats ) ;
break ;
case CTDB_CONTROL_SET_DB_STICKY :
break ;
case CTDB_CONTROL_RELOAD_PUBLIC_IPS :
break ;
case CTDB_CONTROL_TRAVERSE_ALL_EXT :
break ;
case CTDB_CONTROL_RECEIVE_RECORDS :
len = ctdb_rec_buffer_len ( cd - > data . recbuf ) ;
break ;
case CTDB_CONTROL_IPREALLOCATED :
break ;
case CTDB_CONTROL_GET_RUNSTATE :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . runstate ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_DETACH :
break ;
case CTDB_CONTROL_GET_NODES_FILE :
len = ctdb_node_map_len ( cd - > data . nodemap ) ;
break ;
2015-07-31 18:47:22 +03:00
case CTDB_CONTROL_DB_FREEZE :
break ;
case CTDB_CONTROL_DB_THAW :
break ;
case CTDB_CONTROL_DB_TRANSACTION_START :
break ;
case CTDB_CONTROL_DB_TRANSACTION_COMMIT :
break ;
case CTDB_CONTROL_DB_TRANSACTION_CANCEL :
break ;
2016-02-19 02:54:15 +03:00
case CTDB_CONTROL_DB_PULL :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . num_records ) ;
2016-02-19 02:54:15 +03:00
break ;
case CTDB_CONTROL_DB_PUSH_START :
break ;
case CTDB_CONTROL_DB_PUSH_CONFIRM :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . num_records ) ;
2016-02-19 02:54:15 +03:00
break ;
2017-06-14 09:24:02 +03:00
case CTDB_CONTROL_DB_OPEN_FLAGS :
2017-06-29 15:09:26 +03:00
len = ctdb_int32_len ( & cd - > data . tdb_flags ) ;
2017-06-14 09:24:02 +03:00
break ;
2017-03-02 09:07:13 +03:00
case CTDB_CONTROL_DB_ATTACH_REPLICATED :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2017-03-02 09:07:13 +03:00
break ;
2015-04-14 10:20:05 +03:00
}
return len ;
}
static void ctdb_reply_control_data_push ( struct ctdb_reply_control_data * cd ,
uint8_t * buf )
{
2017-06-29 15:09:26 +03:00
size_t np ;
2015-04-14 10:20:05 +03:00
switch ( cd - > opcode ) {
case CTDB_CONTROL_STATISTICS :
2017-07-26 05:50:12 +03:00
ctdb_statistics_push ( cd - > data . stats , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETDBPATH :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . db_path , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETVNNMAP :
2017-06-29 12:04:56 +03:00
ctdb_vnn_map_push ( cd - > data . vnnmap , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DEBUG :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . loglevel , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DBMAP :
2017-06-29 12:33:04 +03:00
ctdb_dbid_map_push ( cd - > data . dbmap , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_PULL_DB :
2017-06-29 16:41:08 +03:00
ctdb_rec_buffer_push ( cd - > data . recbuf , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_PUSH_DB :
break ;
case CTDB_CONTROL_DB_ATTACH :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DBNAME :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . db_name , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DUMP_MEMORY :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . mem_str , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PID :
break ;
case CTDB_CONTROL_GET_RECMASTER :
break ;
case CTDB_CONTROL_GET_TUNABLE :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . tun_value , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_LIST_TUNABLES :
2017-06-29 18:28:26 +03:00
ctdb_var_list_push ( cd - > data . tun_var_list , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_ALL_TUNABLES :
2017-07-26 08:30:19 +03:00
ctdb_tunable_list_push ( cd - > data . tun_list , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_TCP_TICKLE_LIST :
2017-07-04 10:56:12 +03:00
ctdb_tickle_list_push ( cd - > data . tickles , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_ATTACH_PERSISTENT :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPTIME :
ctdb_uptime_push ( cd - > data . uptime , buf ) ;
break ;
case CTDB_CONTROL_TRY_DELETE_RECORDS :
2017-06-29 16:41:08 +03:00
ctdb_rec_buffer_push ( cd - > data . recbuf , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_CAPABILITIES :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . caps , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IPS :
ctdb_public_ip_list_push ( cd - > data . pubip_list , buf ) ;
break ;
case CTDB_CONTROL_GET_NODEMAP :
ctdb_node_map_push ( cd - > data . nodemap , buf ) ;
break ;
case CTDB_CONTROL_GET_RECLOCK_FILE :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . reclock_file , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_BAN_STATE :
ctdb_ban_state_push ( cd - > data . ban_state , buf ) ;
break ;
case CTDB_CONTROL_GET_DB_PRIORITY :
break ;
case CTDB_CONTROL_GET_DB_SEQNUM :
2017-06-29 15:15:43 +03:00
ctdb_uint64_push ( & cd - > data . seqnum , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_GET_HEALTH :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . reason , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IP_INFO :
ctdb_public_ip_info_push ( cd - > data . ipinfo , buf ) ;
break ;
case CTDB_CONTROL_GET_IFACES :
ctdb_iface_list_push ( cd - > data . iface_list , buf ) ;
break ;
case CTDB_CONTROL_GET_STAT_HISTORY :
ctdb_statistics_list_push ( cd - > data . stats_list , buf ) ;
break ;
case CTDB_CONTROL_CHECK_SRVIDS :
break ;
case CTDB_CONTROL_GET_DB_STATISTICS :
ctdb_db_statistics_push ( cd - > data . dbstats , buf ) ;
break ;
case CTDB_CONTROL_RECEIVE_RECORDS :
2017-06-29 16:41:08 +03:00
ctdb_rec_buffer_push ( cd - > data . recbuf , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_RUNSTATE :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . runstate , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_NODES_FILE :
ctdb_node_map_push ( cd - > data . nodemap , buf ) ;
break ;
2016-02-19 02:54:15 +03:00
case CTDB_CONTROL_DB_PULL :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . num_records , buf , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
case CTDB_CONTROL_DB_PUSH_CONFIRM :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . num_records , buf , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
2017-06-14 09:24:02 +03:00
case CTDB_CONTROL_DB_OPEN_FLAGS :
2017-06-29 15:09:26 +03:00
ctdb_int32_push ( & cd - > data . tdb_flags , buf , & np ) ;
2017-06-14 09:24:02 +03:00
break ;
2017-03-02 09:07:13 +03:00
case CTDB_CONTROL_DB_ATTACH_REPLICATED :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2017-03-02 09:07:13 +03:00
break ;
2015-04-14 10:20:05 +03:00
}
}
static int ctdb_reply_control_data_pull ( uint8_t * buf , size_t buflen ,
uint32_t opcode , TALLOC_CTX * mem_ctx ,
struct ctdb_reply_control_data * cd )
{
2017-06-29 15:09:26 +03:00
size_t np ;
2015-04-14 10:20:05 +03:00
int ret = 0 ;
2017-06-29 15:09:26 +03:00
2015-04-14 10:20:05 +03:00
cd - > opcode = opcode ;
switch ( opcode ) {
case CTDB_CONTROL_STATISTICS :
ret = ctdb_statistics_pull ( buf , buflen , mem_ctx ,
2017-07-26 05:50:12 +03:00
& cd - > data . stats , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETDBPATH :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . db_path , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETVNNMAP :
ret = ctdb_vnn_map_pull ( buf , buflen , mem_ctx ,
2017-06-29 12:04:56 +03:00
& cd - > data . vnnmap , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DEBUG :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . loglevel , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DBMAP :
ret = ctdb_dbid_map_pull ( buf , buflen , mem_ctx ,
2017-06-29 12:33:04 +03:00
& cd - > data . dbmap , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_PULL_DB :
ret = ctdb_rec_buffer_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:41:08 +03:00
& cd - > data . recbuf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_PUSH_DB :
break ;
case CTDB_CONTROL_DB_ATTACH :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DBNAME :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . db_name , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DUMP_MEMORY :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . mem_str , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PID :
break ;
case CTDB_CONTROL_GET_RECMASTER :
break ;
case CTDB_CONTROL_GET_TUNABLE :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . tun_value ,
& np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_LIST_TUNABLES :
ret = ctdb_var_list_pull ( buf , buflen , mem_ctx ,
2017-06-29 18:28:26 +03:00
& cd - > data . tun_var_list , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_ALL_TUNABLES :
ret = ctdb_tunable_list_pull ( buf , buflen , mem_ctx ,
2017-07-26 08:30:19 +03:00
& cd - > data . tun_list , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_TCP_TICKLE_LIST :
ret = ctdb_tickle_list_pull ( buf , buflen , mem_ctx ,
2017-07-04 10:56:12 +03:00
& cd - > data . tickles , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_ATTACH_PERSISTENT :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPTIME :
ret = ctdb_uptime_pull ( buf , buflen , mem_ctx ,
& cd - > data . uptime ) ;
break ;
case CTDB_CONTROL_TRY_DELETE_RECORDS :
ctdb_rec_buffer_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:41:08 +03:00
& cd - > data . recbuf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_CAPABILITIES :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . caps , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IPS :
ret = ctdb_public_ip_list_pull ( buf , buflen , mem_ctx ,
& cd - > data . pubip_list ) ;
break ;
case CTDB_CONTROL_GET_NODEMAP :
ret = ctdb_node_map_pull ( buf , buflen , mem_ctx ,
& cd - > data . nodemap ) ;
break ;
case CTDB_CONTROL_GET_RECLOCK_FILE :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . reclock_file , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_BAN_STATE :
ret = ctdb_ban_state_pull ( buf , buflen , mem_ctx ,
& cd - > data . ban_state ) ;
break ;
case CTDB_CONTROL_GET_DB_PRIORITY :
break ;
case CTDB_CONTROL_GET_DB_SEQNUM :
2017-06-29 15:15:43 +03:00
ret = ctdb_uint64_pull ( buf , buflen , & cd - > data . seqnum , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_GET_HEALTH :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . reason , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IP_INFO :
ret = ctdb_public_ip_info_pull ( buf , buflen , mem_ctx ,
& cd - > data . ipinfo ) ;
break ;
case CTDB_CONTROL_GET_IFACES :
ret = ctdb_iface_list_pull ( buf , buflen , mem_ctx ,
& cd - > data . iface_list ) ;
break ;
case CTDB_CONTROL_GET_STAT_HISTORY :
ret = ctdb_statistics_list_pull ( buf , buflen , mem_ctx ,
& cd - > data . stats_list ) ;
break ;
case CTDB_CONTROL_CHECK_SRVIDS :
break ;
case CTDB_CONTROL_GET_DB_STATISTICS :
ret = ctdb_db_statistics_pull ( buf , buflen , mem_ctx ,
& cd - > data . dbstats ) ;
break ;
case CTDB_CONTROL_RECEIVE_RECORDS :
ret = ctdb_rec_buffer_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:41:08 +03:00
& cd - > data . recbuf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_RUNSTATE :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . runstate , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_NODES_FILE :
ret = ctdb_node_map_pull ( buf , buflen , mem_ctx ,
& cd - > data . nodemap ) ;
break ;
2016-02-19 02:54:15 +03:00
case CTDB_CONTROL_DB_PULL :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . num_records ,
& np ) ;
2016-02-19 02:54:15 +03:00
break ;
case CTDB_CONTROL_DB_PUSH_CONFIRM :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . num_records ,
& np ) ;
2016-02-19 02:54:15 +03:00
break ;
2017-06-14 09:24:02 +03:00
case CTDB_CONTROL_DB_OPEN_FLAGS :
2017-06-29 15:09:26 +03:00
ret = ctdb_int32_pull ( buf , buflen , & cd - > data . tdb_flags , & np ) ;
2017-06-14 09:24:02 +03:00
break ;
2017-03-02 09:07:13 +03:00
case CTDB_CONTROL_DB_ATTACH_REPLICATED :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2017-03-02 09:07:13 +03:00
break ;
2015-04-14 10:20:05 +03:00
}
return ret ;
}
2016-04-21 17:45:01 +03:00
size_t ctdb_req_control_len ( struct ctdb_req_header * h ,
struct ctdb_req_control * c )
{
return offsetof ( struct ctdb_req_control_wire , data ) +
ctdb_req_control_data_len ( & c - > rdata ) ;
}
2015-04-14 10:20:05 +03:00
int ctdb_req_control_push ( struct ctdb_req_header * h ,
struct ctdb_req_control * request ,
2016-05-01 15:13:35 +03:00
uint8_t * buf , size_t * buflen )
2015-04-14 10:20:05 +03:00
{
2016-04-21 18:08:11 +03:00
struct ctdb_req_control_wire * wire =
( struct ctdb_req_control_wire * ) buf ;
size_t length ;
2015-04-14 10:20:05 +03:00
2016-04-29 08:35:12 +03:00
length = ctdb_req_control_len ( h , request ) ;
2016-05-01 15:13:35 +03:00
if ( * buflen < length ) {
* buflen = length ;
2016-04-21 18:08:11 +03:00
return EMSGSIZE ;
2015-04-14 10:20:05 +03:00
}
2016-05-01 15:13:35 +03:00
h - > length = * buflen ;
2016-04-21 17:19:49 +03:00
ctdb_req_header_push ( h , ( uint8_t * ) & wire - > hdr ) ;
2015-04-14 10:20:05 +03:00
wire - > opcode = request - > opcode ;
wire - > pad = request - > pad ;
wire - > srvid = request - > srvid ;
wire - > client_id = request - > client_id ;
wire - > flags = request - > flags ;
2016-04-29 08:35:12 +03:00
wire - > datalen = ctdb_req_control_data_len ( & request - > rdata ) ;
2015-04-14 10:20:05 +03:00
ctdb_req_control_data_push ( & request - > rdata , wire - > data ) ;
return 0 ;
}
2016-04-21 18:25:06 +03:00
int ctdb_req_control_pull ( uint8_t * buf , size_t buflen ,
2015-04-14 10:20:05 +03:00
struct ctdb_req_header * h ,
TALLOC_CTX * mem_ctx ,
2016-04-21 18:25:06 +03:00
struct ctdb_req_control * c )
2015-04-14 10:20:05 +03:00
{
struct ctdb_req_control_wire * wire =
2016-04-21 18:25:06 +03:00
( struct ctdb_req_control_wire * ) buf ;
2015-04-14 10:20:05 +03:00
size_t length ;
int ret ;
length = offsetof ( struct ctdb_req_control_wire , data ) ;
2016-04-21 18:25:06 +03:00
if ( buflen < length ) {
2015-04-14 10:20:05 +03:00
return EMSGSIZE ;
}
2016-05-03 05:53:24 +03:00
if ( wire - > datalen > buflen ) {
return EMSGSIZE ;
}
if ( length + wire - > datalen < length ) {
return EMSGSIZE ;
}
2016-04-21 18:25:06 +03:00
if ( buflen < length + wire - > datalen ) {
2015-04-14 10:20:05 +03:00
return EMSGSIZE ;
}
2016-03-10 07:43:37 +03:00
if ( h ! = NULL ) {
2016-04-21 18:25:06 +03:00
ret = ctdb_req_header_pull ( ( uint8_t * ) & wire - > hdr , buflen , h ) ;
2016-04-21 17:19:49 +03:00
if ( ret ! = 0 ) {
return ret ;
}
2016-03-10 07:43:37 +03:00
}
2015-04-14 10:20:05 +03:00
2016-04-21 18:25:06 +03:00
c - > opcode = wire - > opcode ;
c - > pad = wire - > pad ;
c - > srvid = wire - > srvid ;
c - > client_id = wire - > client_id ;
c - > flags = wire - > flags ;
2015-04-14 10:20:05 +03:00
ret = ctdb_req_control_data_pull ( wire - > data , wire - > datalen ,
2016-04-21 18:25:06 +03:00
c - > opcode , mem_ctx , & c - > rdata ) ;
2015-04-14 10:20:05 +03:00
if ( ret ! = 0 ) {
return ret ;
}
return 0 ;
}
2016-04-21 17:45:01 +03:00
size_t ctdb_reply_control_len ( struct ctdb_req_header * h ,
struct ctdb_reply_control * c )
{
return offsetof ( struct ctdb_reply_control_wire , data ) +
( c - > status = = 0 ?
ctdb_reply_control_data_len ( & c - > rdata ) :
2017-06-29 11:48:51 +03:00
ctdb_string_len ( & c - > errmsg ) ) ;
2016-04-21 17:45:01 +03:00
}
2015-04-14 10:20:05 +03:00
int ctdb_reply_control_push ( struct ctdb_req_header * h ,
struct ctdb_reply_control * reply ,
2016-05-01 15:13:35 +03:00
uint8_t * buf , size_t * buflen )
2015-04-14 10:20:05 +03:00
{
2016-04-21 18:08:11 +03:00
struct ctdb_reply_control_wire * wire =
( struct ctdb_reply_control_wire * ) buf ;
2017-06-29 11:48:51 +03:00
size_t length , np ;
2015-04-14 10:20:05 +03:00
2016-04-29 08:35:12 +03:00
length = ctdb_reply_control_len ( h , reply ) ;
2016-05-01 15:13:35 +03:00
if ( * buflen < length ) {
* buflen = length ;
2016-04-21 18:08:11 +03:00
return EMSGSIZE ;
2015-04-14 10:20:05 +03:00
}
2016-05-01 15:13:35 +03:00
h - > length = * buflen ;
2016-04-21 17:19:49 +03:00
ctdb_req_header_push ( h , ( uint8_t * ) & wire - > hdr ) ;
2015-04-14 10:20:05 +03:00
wire - > status = reply - > status ;
if ( reply - > status = = 0 ) {
2016-04-29 08:35:12 +03:00
wire - > datalen = ctdb_reply_control_data_len ( & reply - > rdata ) ;
2016-04-29 08:57:44 +03:00
wire - > errorlen = 0 ;
2015-04-14 10:20:05 +03:00
ctdb_reply_control_data_push ( & reply - > rdata , wire - > data ) ;
2016-04-29 08:35:12 +03:00
} else {
wire - > datalen = 0 ;
2017-06-29 11:48:51 +03:00
wire - > errorlen = ctdb_string_len ( & reply - > errmsg ) ;
ctdb_string_push ( & reply - > errmsg , wire - > data + wire - > datalen ,
& np ) ;
2015-04-14 10:20:05 +03:00
}
return 0 ;
}
2016-04-21 18:25:06 +03:00
int ctdb_reply_control_pull ( uint8_t * buf , size_t buflen , uint32_t opcode ,
2015-04-14 10:20:05 +03:00
struct ctdb_req_header * h ,
TALLOC_CTX * mem_ctx ,
2016-04-21 18:25:06 +03:00
struct ctdb_reply_control * c )
2015-04-14 10:20:05 +03:00
{
struct ctdb_reply_control_wire * wire =
2016-04-21 18:25:06 +03:00
( struct ctdb_reply_control_wire * ) buf ;
2017-06-29 11:48:51 +03:00
size_t length , np ;
2015-04-14 10:20:05 +03:00
int ret ;
length = offsetof ( struct ctdb_reply_control_wire , data ) ;
2016-04-21 18:25:06 +03:00
if ( buflen < length ) {
2015-04-14 10:20:05 +03:00
return EMSGSIZE ;
}
2016-05-03 05:53:24 +03:00
if ( wire - > datalen > buflen | | wire - > errorlen > buflen ) {
return EMSGSIZE ;
}
if ( length + wire - > datalen < length ) {
return EMSGSIZE ;
}
if ( length + wire - > datalen + wire - > errorlen < length ) {
return EMSGSIZE ;
}
2016-04-21 18:25:06 +03:00
if ( buflen < length + wire - > datalen + wire - > errorlen ) {
2015-04-14 10:20:05 +03:00
return EMSGSIZE ;
}
2016-03-10 07:43:37 +03:00
if ( h ! = NULL ) {
2016-04-21 18:25:06 +03:00
ret = ctdb_req_header_pull ( ( uint8_t * ) & wire - > hdr , buflen , h ) ;
2016-04-21 17:19:49 +03:00
if ( ret ! = 0 ) {
return ret ;
}
2016-03-10 07:43:37 +03:00
}
2015-04-14 10:20:05 +03:00
2016-04-21 18:25:06 +03:00
c - > status = wire - > status ;
2015-04-14 10:20:05 +03:00
2016-04-21 18:25:06 +03:00
if ( c - > status ! = - 1 ) {
2015-04-14 10:20:05 +03:00
ret = ctdb_reply_control_data_pull ( wire - > data , wire - > datalen ,
opcode , mem_ctx ,
2016-04-21 18:25:06 +03:00
& c - > rdata ) ;
2015-04-14 10:20:05 +03:00
if ( ret ! = 0 ) {
return ret ;
}
}
2016-04-21 16:49:33 +03:00
ret = ctdb_string_pull ( wire - > data + wire - > datalen , wire - > errorlen ,
2017-06-29 11:48:51 +03:00
mem_ctx , & c - > errmsg , & np ) ;
2016-04-21 16:49:33 +03:00
if ( ret ! = 0 ) {
return ret ;
2015-04-14 10:20:05 +03:00
}
return 0 ;
}