diff options
author | Martin Schwenke <martin@meltin.net> | 2012-07-18 14:24:08 +1000 |
---|---|---|
committer | Martin Schwenke <martin@meltin.net> | 2012-09-28 17:05:34 +1000 |
commit | e05fc0e7b0cb78ad6e6b0ce5119d93f418886662 (patch) | |
tree | 0e1906dead0e00e4c924bd8f70f37f21dd9b775a | |
parent | 110cb67e2ae5efc6324663e50de080097c5cdda7 (diff) | |
download | samba-e05fc0e7b0cb78ad6e6b0ce5119d93f418886662.tar.gz samba-e05fc0e7b0cb78ad6e6b0ce5119d93f418886662.tar.xz samba-e05fc0e7b0cb78ad6e6b0ce5119d93f418886662.zip |
libctdb: add ctdb_getcapabilities()
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit 140fafef23050d40d66f5b5558c7efcb78f80cd2)
-rw-r--r-- | ctdb/include/ctdb.h | 50 | ||||
-rw-r--r-- | ctdb/include/ctdb_private.h | 8 | ||||
-rw-r--r-- | ctdb/include/ctdb_protocol.h | 11 | ||||
-rw-r--r-- | ctdb/libctdb/control.c | 28 | ||||
-rw-r--r-- | ctdb/libctdb/sync.c | 17 |
5 files changed, 106 insertions, 8 deletions
diff --git a/ctdb/include/ctdb.h b/ctdb/include/ctdb.h index 93224cbdaa..c3da06897c 100644 --- a/ctdb/include/ctdb.h +++ b/ctdb/include/ctdb.h @@ -585,6 +585,35 @@ ctdb_check_message_handlers_recv(struct ctdb_connection *ctdb, /** + * ctdb_getcapabilities_send - read the capabilities of a node + * @ctdb: the ctdb_connection from ctdb_connect. + * @destnode: the destination node (see below) + * @callback: the callback when ctdb replies to our message (typesafe) + * @cbdata: the argument to callback() + * + * There are several special values for destnode, detailed in + * ctdb_protocol.h, particularly CTDB_CURRENT_NODE which means the + * local ctdbd. + */ +struct ctdb_request * +ctdb_getcapabilities_send(struct ctdb_connection *ctdb, + uint32_t destnode, + ctdb_callback_t callback, void *cbdata); + +/** + * ctdb_getcapabilities_recv - read an ctdb_getcapabilities reply from ctdbd + * @ctdb: the ctdb_connection from ctdb_connect. + * @req: the completed request. + * @capabilities: a pointer to the capabilities to fill in + * + * This returns false if something went wrong, or otherwise fills in + * capabilities. + */ +bool ctdb_getcapabilities_recv(struct ctdb_connection *ctdb, + struct ctdb_request *handle, + uint32_t *capabilities); + +/** * ctdb_getdbseqnum_send - read the sequence number off a db * @ctdb: the ctdb_connection from ctdb_connect. * @destnode: the destination node (see below) @@ -950,6 +979,23 @@ ctdb_check_message_handlers(struct ctdb_connection *ctdb, uint8_t *result); /** + * ctdb_getcapabilities - read the capabilities of a node (synchronous) + * @ctdb: the ctdb_connection from ctdb_connect. + * @destnode: the destination node (see below) + * @capabilities: a pointer to the capabilities to fill in + * + * There are several special values for destnode, detailed in + * ctdb_protocol.h, particularly CTDB_CURRENT_NODE which means the + * local ctdbd. + * + * Returns true and fills in *capabilities on success. + */ +bool ctdb_getcapabilities(struct ctdb_connection *ctdb, + uint32_t destnode, + uint32_t *capabilities); + + +/** * ctdb_getdbseqnum - read the seqnum of a database * @ctdb: the ctdb_connection from ctdb_connect. * @destnode: the destination node (see below) @@ -1145,6 +1191,10 @@ void ctdb_free_vnnmap(struct ctdb_vnn_map *vnnmap); ctdb_getpnn_send((ctdb), (destnode), \ ctdb_sendcb((cb), (cbdata)), (cbdata)) +#define ctdb_getcapabilities_send(ctdb, destnode, cb, cbdata) \ + ctdb_getcapabilities_send((ctdb), (destnode), \ + ctdb_sendcb((cb), (cbdata)), (cbdata)) + #define ctdb_getdbstat_send(ctdb, destnode, db_id, cb, cbdata) \ ctdb_getdbstat_send((ctdb), (destnode), (db_id), \ ctdb_sendcb((cb), (cbdata)), (cbdata)) diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 0f9da360c6..984dc355a8 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -394,14 +394,6 @@ enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN #define CTDB_MONITORING_ACTIVE 0 #define CTDB_MONITORING_DISABLED 1 -/* The different capabilities of the ctdb daemon. */ -#define CTDB_CAP_RECMASTER 0x00000001 -#define CTDB_CAP_LMASTER 0x00000002 -/* This capability is set if CTDB_LVS_PUBLIC_IP is set */ -#define CTDB_CAP_LVS 0x00000004 -/* This capability is set if NATGW is enabled */ -#define CTDB_CAP_NATGW 0x00000008 - #define NUM_DB_PRIORITIES 3 /* main state of the ctdb daemon */ struct ctdb_context { diff --git a/ctdb/include/ctdb_protocol.h b/ctdb/include/ctdb_protocol.h index 33187c7842..96827563c1 100644 --- a/ctdb/include/ctdb_protocol.h +++ b/ctdb/include/ctdb_protocol.h @@ -568,6 +568,17 @@ struct ctdb_node_map { #define NODE_FLAGS_NOIPTAKEOVER 0x01000000 /* this node can takeover any new ip addresses, this flag is ONLY valid within the recovery daemon */ +/* + * Node capabilities + */ +#define CTDB_CAP_RECMASTER 0x00000001 +#define CTDB_CAP_LMASTER 0x00000002 +/* This capability is set if CTDB_LVS_PUBLIC_IP is set */ +#define CTDB_CAP_LVS 0x00000004 +/* This capability is set if NATGW is enabled */ +#define CTDB_CAP_NATGW 0x00000008 + + struct ctdb_public_ip { uint32_t pnn; ctdb_sock_addr addr; diff --git a/ctdb/libctdb/control.c b/ctdb/libctdb/control.c index e8a5cd71ea..176c48c896 100644 --- a/ctdb/libctdb/control.c +++ b/ctdb/libctdb/control.c @@ -33,6 +33,7 @@ #undef ctdb_getdbseqnum_send #undef ctdb_getifaces_send #undef ctdb_getvnnmap_send +#undef ctdb_getcapabilities_send bool ctdb_getrecmaster_recv(struct ctdb_connection *ctdb, struct ctdb_request *req, uint32_t *recmaster) @@ -515,3 +516,30 @@ struct ctdb_request *ctdb_getvnnmap_send(struct ctdb_connection *ctdb, NULL, 0, callback, private_data); } +bool ctdb_getcapabilities_recv(struct ctdb_connection *ctdb, + struct ctdb_request *req, uint32_t *capabilities) +{ + struct ctdb_reply_control *reply; + + reply = unpack_reply_control(req, CTDB_CONTROL_GET_CAPABILITIES); + if (!reply) { + return false; + } + if (reply->status == -1) { + DEBUG(ctdb, LOG_ERR, "ctdb_getcapabilities_recv: status -1"); + return false; + } + *capabilities = *((uint32_t *)reply->data); + return true; +} + +struct ctdb_request *ctdb_getcapabilities_send(struct ctdb_connection *ctdb, + uint32_t destnode, + ctdb_callback_t callback, + void *private_data) +{ + return new_ctdb_control_request(ctdb, CTDB_CONTROL_GET_CAPABILITIES, + destnode, + NULL, 0, callback, private_data); +} + diff --git a/ctdb/libctdb/sync.c b/ctdb/libctdb/sync.c index 0e175f7f12..9a827476e9 100644 --- a/ctdb/libctdb/sync.c +++ b/ctdb/libctdb/sync.c @@ -338,3 +338,20 @@ bool ctdb_getvnnmap(struct ctdb_connection *ctdb, return ret; } +bool ctdb_getcapabilities(struct ctdb_connection *ctdb, + uint32_t destnode, uint32_t *capabilities) +{ + struct ctdb_request *req; + bool done = false; + bool ret = false; + + req = synchronous(ctdb, + ctdb_getcapabilities_send(ctdb, destnode, set, &done), + &done); + if (req != NULL) { + ret = ctdb_getcapabilities_recv(ctdb, req, capabilities); + ctdb_request_free(req); + } + return ret; +} + |