}
*/
-static int ctdb_reply_control_generic(struct ctdb_reply_control *reply)
+static int ctdb_reply_control_generic(struct ctdb_reply_control *reply,
+ uint32_t opcode)
{
+ if (reply->rdata.opcode != opcode) {
+ return EPROTO;
+ }
+
return reply->status;
}
int ctdb_reply_control_process_exists(struct ctdb_reply_control *reply,
int *status)
{
- if (reply->rdata.opcode == CTDB_CONTROL_PROCESS_EXISTS) {
- *status = reply->status;
- reply->status = 0;
-
+ if (reply->rdata.opcode != CTDB_CONTROL_PROCESS_EXISTS) {
+ return EPROTO;
}
+
+ *status = reply->status;
+ reply->status = 0;
+
return reply->status;
}
TALLOC_CTX *mem_ctx,
struct ctdb_statistics **stats)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_STATISTICS) {
+ if (reply->rdata.opcode != CTDB_CONTROL_STATISTICS) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*stats = talloc_steal(mem_ctx, reply->rdata.data.stats);
}
return reply->status;
int ctdb_reply_control_ping(struct ctdb_reply_control *reply,
int *num_clients)
{
+ if (reply->rdata.opcode != CTDB_CONTROL_PING) {
+ return EPROTO;
+ }
+
if (reply->status >= 0) {
*num_clients = reply->status;
reply->status = 0;
int ctdb_reply_control_getdbpath(struct ctdb_reply_control *reply,
TALLOC_CTX *mem_ctx, const char **db_path)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GETDBPATH) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GETDBPATH) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*db_path = talloc_steal(mem_ctx, reply->rdata.data.db_path);
}
return reply->status;
TALLOC_CTX *mem_ctx,
struct ctdb_vnn_map **vnnmap)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GETVNNMAP) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GETVNNMAP) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*vnnmap = talloc_steal(mem_ctx, reply->rdata.data.vnnmap);
}
return reply->status;
int ctdb_reply_control_setvnnmap(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_SETVNNMAP);
}
/* CTDB_CONTROL_GET_DEBUG */
int ctdb_reply_control_get_debug(struct ctdb_reply_control *reply,
uint32_t *loglevel)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_DEBUG) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_DEBUG) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*loglevel = reply->rdata.data.loglevel;
}
return reply->status;
int ctdb_reply_control_set_debug(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_DEBUG);
}
/* CTDB_CONTROL_GET_DBMAP */
TALLOC_CTX *mem_ctx,
struct ctdb_dbid_map **dbmap)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_DBMAP) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_DBMAP) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*dbmap = talloc_steal(mem_ctx, reply->rdata.data.dbmap);
}
return reply->status;
TALLOC_CTX *mem_ctx,
struct ctdb_rec_buffer **recbuf)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_PULL_DB) {
+ if (reply->rdata.opcode != CTDB_CONTROL_PULL_DB) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*recbuf = talloc_steal(mem_ctx, reply->rdata.data.recbuf);
}
return reply->status;
int ctdb_reply_control_push_db(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_PUSH_DB);
}
/* CTDB_CONTROL_GET_RECMODE */
int ctdb_reply_control_get_recmode(struct ctdb_reply_control *reply,
int *recmode)
{
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_RECMODE) {
+ return EPROTO;
+ }
+
if (reply->status >= 0) {
*recmode = reply->status;
reply->status = 0;
int ctdb_reply_control_set_recmode(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_RECMODE);
}
/* CTDB_CONTROL_STATISTICS_RESET */
int ctdb_reply_control_statistics_reset(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_STATISTICS_RESET);
}
/* CTDB_CONTROL_DB_ATTACH */
int ctdb_reply_control_db_attach(struct ctdb_reply_control *reply,
uint32_t *db_id)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_DB_ATTACH) {
+ if (reply->rdata.opcode != CTDB_CONTROL_DB_ATTACH) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*db_id = reply->rdata.data.db_id;
}
return reply->status;
int ctdb_reply_control_traverse_start(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_TRAVERSE_START);
}
/* CTDB_CONTROL_TRAVERSE_ALL */
int ctdb_reply_control_register_srvid(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_REGISTER_SRVID);
}
/* CTDB_CONTROL_DEREGISTER_SRVID */
int ctdb_reply_control_deregister_srvid(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_DEREGISTER_SRVID);
}
/* CTDB_CONTROL_GET_DBNAME */
int ctdb_reply_control_get_dbname(struct ctdb_reply_control *reply,
TALLOC_CTX *mem_ctx, const char **db_name)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_DBNAME) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_DBNAME) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*db_name = talloc_steal(mem_ctx, reply->rdata.data.db_name);
}
return reply->status;
int ctdb_reply_control_enable_seqnum(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_ENABLE_SEQNUM);
}
/* CTDB_CONTROL_UPDATE_SEQNUM */
int ctdb_reply_control_update_seqnum(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_UPDATE_SEQNUM);
}
/* CTDB_CONTROL_DUMP_MEMORY */
int ctdb_reply_control_dump_memory(struct ctdb_reply_control *reply,
TALLOC_CTX *mem_ctx, const char **mem_str)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_DUMP_MEMORY) {
+ if (reply->rdata.opcode != CTDB_CONTROL_DUMP_MEMORY) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*mem_str = talloc_steal(mem_ctx, reply->rdata.data.mem_str);
}
return reply->status;
int ctdb_reply_control_get_pid(struct ctdb_reply_control *reply,
pid_t *pid)
{
- if (reply->rdata.opcode == CTDB_CONTROL_GET_PID) {
- *pid = reply->status;
- reply->status = 0;
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_PID) {
+ return EPROTO;
}
+
+ *pid = reply->status;
+ reply->status = 0;
+
return reply->status;
}
int ctdb_reply_control_get_recmaster(struct ctdb_reply_control *reply,
uint32_t *recmaster)
{
- if (reply->rdata.opcode == CTDB_CONTROL_GET_RECMASTER) {
- *recmaster = reply->status;
- reply->status = 0;
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_RECMASTER) {
+ return EPROTO;
}
+
+ *recmaster = reply->status;
+ reply->status = 0;
+
return reply->status;
}
int ctdb_reply_control_set_recmaster(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_RECMASTER);
}
/* CTDB_CONTROL_FREEZE */
int ctdb_reply_control_freeze(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_FREEZE);
}
/* CTDB_CONTROL_THAW */
int ctdb_reply_control_thaw(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_THAW);
}
/* CTDB_CONTROL_GET_PNN */
int ctdb_reply_control_get_pnn(struct ctdb_reply_control *reply,
uint32_t *pnn)
{
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_PNN) {
+ return EPROTO;
+ }
+
if (reply->status >= 0) {
*pnn = reply->status;
reply->status = 0;
int ctdb_reply_control_shutdown(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_SHUTDOWN);
}
/* CTDB_CONTROL_GET_MONMODE */
int ctdb_reply_control_get_monmode(struct ctdb_reply_control *reply,
int *mon_mode)
{
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_MONMODE) {
+ return EPROTO;
+ }
+
if (reply->status >= 0) {
*mon_mode = reply->status;
reply->status = 0;
int ctdb_reply_control_tcp_client(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_TCP_CLIENT);
}
/* CTDB_CONTROL_TCP_ADD */
int ctdb_reply_control_tcp_add(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_TCP_ADD);
}
/* CTDB_CONTROL_TCP_REMOVE */
int ctdb_reply_control_tcp_remove(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_TCP_REMOVE);
}
/* CTDB_CONTROL_STARTUP */
int ctdb_reply_control_startup(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_STARTUP);
}
/* CTDB_CONTROL_SET_TUNABLE */
int ctdb_reply_control_set_tunable(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_TUNABLE);
}
/* CTDB_CONTROL_GET_TUNABLE */
int ctdb_reply_control_get_tunable(struct ctdb_reply_control *reply,
uint32_t *value)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_TUNABLE) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_TUNABLE) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*value = reply->rdata.data.tun_value;
}
return reply->status;
TALLOC_CTX *mem_ctx,
struct ctdb_var_list **tun_var_list)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_LIST_TUNABLES) {
+ if (reply->rdata.opcode != CTDB_CONTROL_LIST_TUNABLES) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*tun_var_list = talloc_steal(mem_ctx,
reply->rdata.data.tun_var_list);
}
int ctdb_reply_control_modify_flags(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_MODIFY_FLAGS);
}
/* CTDB_CONTROL_GET_ALL_TUNABLES */
TALLOC_CTX *mem_ctx,
struct ctdb_tunable_list **tun_list)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_ALL_TUNABLES) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_ALL_TUNABLES) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*tun_list = talloc_steal(mem_ctx, reply->rdata.data.tun_list);
}
return reply->status;
TALLOC_CTX *mem_ctx,
struct ctdb_tickle_list **tickles)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_TCP_TICKLE_LIST) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_TCP_TICKLE_LIST) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*tickles = talloc_steal(mem_ctx, reply->rdata.data.tickles);
}
return reply->status;
int ctdb_reply_control_set_tcp_tickle_list(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_SET_TCP_TICKLE_LIST);
}
/* CTDB_CONTROL_DB_ATTACH_PERSISTENT */
int ctdb_reply_control_db_attach_persistent(struct ctdb_reply_control *reply,
uint32_t *db_id)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_DB_ATTACH_PERSISTENT) {
+ if (reply->rdata.opcode != CTDB_CONTROL_DB_ATTACH_PERSISTENT) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*db_id = reply->rdata.data.db_id;
}
return reply->status;
int ctdb_reply_control_update_record(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_UPDATE_RECORD);
}
/* CTDB_CONTROL_SEND_GRATUITOUS_ARP */
int ctdb_reply_control_send_gratuitous_arp(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_SEND_GRATUITOUS_ARP);
}
/* CTDB_CONTROL_TRANSACTION_START */
int ctdb_reply_control_transaction_start(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_TRANSACTION_START);
}
/* CTDB_CONTROL_TRANSACTION_COMMIT */
int ctdb_reply_control_transaction_commit(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_TRANSACTION_COMMIT);
}
/* CTDB_CONTROL_WIPE_DATABASE */
int ctdb_reply_control_wipe_database(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_WIPE_DATABASE);
}
/* CTDB_CONTROL_UPTIME */
int ctdb_reply_control_uptime(struct ctdb_reply_control *reply,
TALLOC_CTX *mem_ctx, struct ctdb_uptime **uptime)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_UPTIME) {
+ if (reply->rdata.opcode != CTDB_CONTROL_UPTIME) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*uptime = talloc_steal(mem_ctx, reply->rdata.data.uptime);
}
return reply->status;
int ctdb_reply_control_start_recovery(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_START_RECOVERY);
}
/* CTDB_CONTROL_END_RECOVERY */
int ctdb_reply_control_end_recovery(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_END_RECOVERY);
}
/* CTDB_CONTROL_RELOAD_NODES_FILE */
int ctdb_reply_control_reload_nodes_file(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_RELOAD_NODES_FILE);
}
/* CTDB_CONTROL_TRY_DELETE_RECORDS */
TALLOC_CTX *mem_ctx,
struct ctdb_rec_buffer **recbuf)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_TRY_DELETE_RECORDS) {
+ if (reply->rdata.opcode != CTDB_CONTROL_TRY_DELETE_RECORDS) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*recbuf = talloc_steal(mem_ctx, reply->rdata.data.recbuf);
}
return reply->status;
int ctdb_reply_control_enable_monitor(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_ENABLE_MONITOR);
}
/* CTDB_CONTROL_DISABLE_MONITOR */
int ctdb_reply_control_disable_monitor(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_DISABLE_MONITOR);
}
/* CTDB_CONTROL_ADD_PUBLIC_IP */
int ctdb_reply_control_add_public_ip(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_ADD_PUBLIC_IP);
}
/* CTDB_CONTROL_DEL_PUBLIC_IP */
int ctdb_reply_control_del_public_ip(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_DEL_PUBLIC_IP);
}
/* CTDB_CONTROL_RUN_EVENTSCRIPTS */
int ctdb_reply_control_run_eventscripts(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_RUN_EVENTSCRIPTS);
}
/* CTDB_CONTROL_GET_CAPABILITIES */
int ctdb_reply_control_get_capabilities(struct ctdb_reply_control *reply,
uint32_t *caps)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_CAPABILITIES) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_CAPABILITIES) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*caps = reply->rdata.data.caps;
}
return reply->status;
int ctdb_reply_control_recd_ping(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_RECD_PING);
}
/* CTDB_CONTROL_RELEASE_IP */
int ctdb_reply_control_release_ip(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_RELEASE_IP);
}
/* CTDB_CONTROL_TAKEOVER_IP */
int ctdb_reply_control_takeover_ip(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_TAKEOVER_IP);
}
/* CTDB_CONTROL_GET_PUBLIC_IPS */
TALLOC_CTX *mem_ctx,
struct ctdb_public_ip_list **pubip_list)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_PUBLIC_IPS) {
- *pubip_list = talloc_steal(mem_ctx, reply->rdata.data.pubip_list);
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_PUBLIC_IPS) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
+ *pubip_list = talloc_steal(mem_ctx,
+ reply->rdata.data.pubip_list);
}
return reply->status;
}
TALLOC_CTX *mem_ctx,
struct ctdb_node_map **nodemap)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_NODEMAP) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_NODEMAP) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*nodemap = talloc_steal(mem_ctx, reply->rdata.data.nodemap);
}
return reply->status;
TALLOC_CTX *mem_ctx,
struct ctdb_script_list **slist)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*slist = talloc_steal(mem_ctx, reply->rdata.data.script_list);
}
return reply->status;
int ctdb_reply_control_traverse_kill(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_TRAVERSE_KILL);
}
/* CTDB_CONTROL_RECD_RECLOCK_LATENCY */
int ctdb_reply_control_recd_reclock_latency(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_RECD_RECLOCK_LATENCY);
}
/* CTDB_CONTROL_GET_RECLOCK_FILE */
TALLOC_CTX *mem_ctx,
const char **reclock_file)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_RECLOCK_FILE) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_RECLOCK_FILE) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*reclock_file = talloc_steal(mem_ctx,
reply->rdata.data.reclock_file);
}
int ctdb_reply_control_set_reclock_file(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_SET_RECLOCK_FILE);
}
int ctdb_reply_control_stop_node(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_STOP_NODE);
}
/* CTDB_CONTROL_CONTINUE_NODE */
int ctdb_reply_control_continue_node(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_CONTINUE_NODE);
}
/* CTDB_CONTROL_SET_LMASTERROLE */
int ctdb_reply_control_set_lmasterrole(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_LMASTERROLE);
}
/* CTDB_CONTROL_SET_RECMASTERROLE */
int ctdb_reply_control_set_recmasterrole(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_SET_RECMASTERROLE);
}
/* CTDB_CONTROL_ENABLE_SCRIPT */
int ctdb_reply_control_enable_script(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_ENABLE_SCRIPT);
}
/* CTDB_CONTROL_DISABLE_SCRIPT */
int ctdb_reply_control_disable_script(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_DISABLE_SCRIPT);
}
/* CTDB_CONTROL_SET_BAN_STATE */
int ctdb_reply_control_set_ban_state(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_BAN_STATE);
}
/* CTDB_CONTROL_GET_BAN_STATE */
TALLOC_CTX *mem_ctx,
struct ctdb_ban_state **ban_state)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_BAN_STATE) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_BAN_STATE) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*ban_state = talloc_steal(mem_ctx,
reply->rdata.data.ban_state);
}
int ctdb_reply_control_set_db_priority(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_DB_PRIORITY);
}
/* CTDB_CONTROL_GET_DB_PRIORITY */
int ctdb_reply_control_get_db_priority(struct ctdb_reply_control *reply,
uint32_t *priority)
{
- if (reply->rdata.opcode == CTDB_CONTROL_GET_DB_PRIORITY) {
- *priority = reply->status;
- reply->status = 0;
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_DB_PRIORITY) {
+ return EPROTO;
}
+
+ *priority = reply->status;
+ reply->status = 0;
+
return reply->status;
}
int ctdb_reply_control_transaction_cancel(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_TRANSACTION_CANCEL);
}
/* CTDB_CONTROL_REGISTER_NOTIFY */
int ctdb_reply_control_register_notify(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_REGISTER_NOTIFY);
}
/* CTDB_CONTROL_DEREGISTER_NOTIFY */
int ctdb_reply_control_deregister_notify(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_DEREGISTER_NOTIFY);
}
/* CTDB_CONTROL_TRANS3_COMMIT */
int ctdb_reply_control_trans3_commit(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_TRANS3_COMMIT);
}
/* CTDB_CONTROL_GET_DB_SEQNUM */
int ctdb_reply_control_get_db_seqnum(struct ctdb_reply_control *reply,
uint64_t *seqnum)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_DB_SEQNUM) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_DB_SEQNUM) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*seqnum = reply->rdata.data.seqnum;
}
return reply->status;
int ctdb_reply_control_db_set_healthy(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_DB_SET_HEALTHY);
}
/* CTDB_CONTROL_DB_GET_HEALTH */
int ctdb_reply_control_db_get_health(struct ctdb_reply_control *reply,
TALLOC_CTX *mem_ctx, const char **reason)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_DB_GET_HEALTH) {
+ if (reply->rdata.opcode != CTDB_CONTROL_DB_GET_HEALTH) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*reason = talloc_steal(mem_ctx, reply->rdata.data.reason);
}
return reply->status;
TALLOC_CTX *mem_ctx,
struct ctdb_public_ip_info **ipinfo)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_PUBLIC_IP_INFO) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_PUBLIC_IP_INFO) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*ipinfo = talloc_steal(mem_ctx, reply->rdata.data.ipinfo);
}
return reply->status;
TALLOC_CTX *mem_ctx,
struct ctdb_iface_list **iface_list)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_IFACES) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_IFACES) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*iface_list = talloc_steal(mem_ctx,
reply->rdata.data.iface_list);
}
int ctdb_reply_control_set_iface_link_state(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_SET_IFACE_LINK_STATE);
}
/* CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE */
int ctdb_reply_control_tcp_add_delayed_update(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE);
}
/* CTDB_CONTROL_GET_STAT_HISTORY */
TALLOC_CTX *mem_ctx,
struct ctdb_statistics_list **stats_list)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_STAT_HISTORY) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_STAT_HISTORY) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*stats_list = talloc_steal(mem_ctx,
reply->rdata.data.stats_list);
}
int ctdb_reply_control_schedule_for_deletion(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_SCHEDULE_FOR_DELETION);
}
/* CTDB_CONTROL_SET_DB_READONLY */
int ctdb_reply_control_set_db_readonly(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_DB_READONLY);
}
/* CTDB_CONTROL_CHECK_SRVIDS */
TALLOC_CTX *mem_ctx,
struct ctdb_uint8_array **u8_array)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_CHECK_SRVIDS) {
+ if (reply->rdata.opcode != CTDB_CONTROL_CHECK_SRVIDS) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*u8_array = talloc_steal(mem_ctx, reply->rdata.data.u8_array);
}
return reply->status;
int ctdb_reply_control_traverse_start_ext(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_TRAVERSE_START_EXT);
}
/* CTDB_CONTROL_GET_DB_STATISTICS */
TALLOC_CTX *mem_ctx,
struct ctdb_db_statistics **dbstats)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_DB_STATISTICS) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_DB_STATISTICS) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*dbstats = talloc_steal(mem_ctx, reply->rdata.data.dbstats);
}
return reply->status;
int ctdb_reply_control_set_db_sticky(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_DB_STICKY);
}
/* CTDB_CONTROL_RELOAD_PUBLIC_IPS */
int ctdb_reply_control_reload_public_ips(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_RELOAD_PUBLIC_IPS);
}
/* CTDB_CONTROL_TRAVERSE_ALL_EXT */
TALLOC_CTX *mem_ctx,
struct ctdb_rec_buffer **recbuf)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_RECEIVE_RECORDS) {
+ if (reply->rdata.opcode != CTDB_CONTROL_RECEIVE_RECORDS) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*recbuf = talloc_steal(mem_ctx, reply->rdata.data.recbuf);
}
return reply->status;
int ctdb_reply_control_ipreallocated(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_IPREALLOCATED);
}
/* CTDB_CONTROL_GET_RUNSTATE */
int ctdb_reply_control_get_runstate(struct ctdb_reply_control *reply,
enum ctdb_runstate *runstate)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_RUNSTATE) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_RUNSTATE) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*runstate = reply->rdata.data.runstate;
}
return reply->status;
int ctdb_reply_control_db_detach(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_DB_DETACH);
}
/* CTDB_CONTROL_GET_NODES_FILE */
TALLOC_CTX *mem_ctx,
struct ctdb_node_map **nodemap)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_GET_NODES_FILE) {
+ if (reply->rdata.opcode != CTDB_CONTROL_GET_NODES_FILE) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*nodemap = talloc_steal(mem_ctx, reply->rdata.data.nodemap);
}
return reply->status;
int ctdb_reply_control_db_freeze(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_DB_FREEZE);
}
/* CTDB_CONTROL_DB_THAW */
int ctdb_reply_control_db_thaw(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_DB_THAW);
}
/* CTDB_CONTROL_DB_TRANSACTION_START */
int ctdb_reply_control_db_transaction_start(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_DB_TRANSACTION_START);
}
/* CTDB_CONTROL_DB_TRANSACTION_COMMIT */
int ctdb_reply_control_db_transaction_commit(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_DB_TRANSACTION_COMMIT);
}
/* CTDB_CONTROL_DB_TRANSACTION_CANCEL */
int ctdb_reply_control_db_transaction_cancel(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply,
+ CTDB_CONTROL_DB_TRANSACTION_CANCEL);
}
/* CTDB_CONTROL_DB_PULL */
int ctdb_reply_control_db_pull(struct ctdb_reply_control *reply,
uint32_t *num_records)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_DB_PULL) {
+ if (reply->rdata.opcode != CTDB_CONTROL_DB_PULL) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*num_records = reply->rdata.data.num_records;
}
return reply->status;
int ctdb_reply_control_db_push_start(struct ctdb_reply_control *reply)
{
- return ctdb_reply_control_generic(reply);
+ return ctdb_reply_control_generic(reply, CTDB_CONTROL_DB_PUSH_START);
}
/* CTDB_CONTROL_DB_PUSH_CONFIRM */
int ctdb_reply_control_db_push_confirm(struct ctdb_reply_control *reply,
uint32_t *num_records)
{
- if (reply->status == 0 &&
- reply->rdata.opcode == CTDB_CONTROL_DB_PUSH_CONFIRM) {
+ if (reply->rdata.opcode != CTDB_CONTROL_DB_PUSH_CONFIRM) {
+ return EPROTO;
+ }
+
+ if (reply->status == 0) {
*num_records = reply->rdata.data.num_records;
}
return reply->status;