diff options
| author | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2010-09-15 14:56:57 +1000 |
|---|---|---|
| committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2010-09-15 14:58:11 +1000 |
| commit | 22ea35f17ddb7c21bc2e3df5a1f7f7c4a0743ca2 (patch) | |
| tree | a96c7593d8c0a65d665a96c3b7021962a01bc560 /ctdb/include | |
| parent | 0b5bd411ca3c4ce9ff8f8e4224bc9b63319f0ffc (diff) | |
adda GETPUBLICIPS control to libctdb and use this in the test example
enhance the test example to show the new releaseip/takeip messages
(This used to be ctdb commit 21cc57883e6c02b0e037211b26d1d866d5d7f03d)
Diffstat (limited to 'ctdb/include')
| -rw-r--r-- | ctdb/include/ctdb.h | 72 | ||||
| -rw-r--r-- | ctdb/include/ctdb_private.h | 8 | ||||
| -rw-r--r-- | ctdb/include/ctdb_protocol.h | 16 |
3 files changed, 88 insertions, 8 deletions
diff --git a/ctdb/include/ctdb.h b/ctdb/include/ctdb.h index 92f4626868..1c6cf353f2 100644 --- a/ctdb/include/ctdb.h +++ b/ctdb/include/ctdb.h @@ -444,6 +444,43 @@ bool ctdb_getnodemap_recv(struct ctdb_connection *ctdb, struct ctdb_request *req, struct ctdb_node_map **nodemap); /** + * ctdb_getpublicips_send - read the public ip list from 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() + * + * This control returns the list of public ips known to the local node. + * Deamons only know about those ips that are listed in the local + * public addresses file, which means the returned list of ips may + * be only a subset of all ips across the entire cluster. + * + * 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_getpublicips_send(struct ctdb_connection *ctdb, + uint32_t destnode, + ctdb_callback_t callback, + void *cbdata); +/** + * ctdb_getpublicips_recv - read the public ip list from a node + * @ctdb: the ctdb_connection from ctdb_connect. + * @req: the completed request. + * @ips: a pointer to the returned public ip list + * + * This returns false if something went wrong. + * If the command failed, it guarantees to set ips to NULL. + * A non-NULL value for nodemap means the command was successful. + * + * A non-NULL value of the nodemap must be release released/freed + * by ctdb_free_publicips(). + */ +bool ctdb_getpublicips_recv(struct ctdb_connection *ctdb, + struct ctdb_request *req, struct ctdb_all_public_ips **ips); + +/** * ctdb_getrecmaster_send - read the recovery master of a node * @ctdb: the ctdb_connection from ctdb_connect. * @destnode: the destination node (see below) @@ -612,6 +649,37 @@ bool ctdb_getnodemap(struct ctdb_connection *ctdb, void ctdb_free_nodemap(struct ctdb_node_map *nodemap); +/** + * ctdb_getpublicips - read the public ip list from a node. + * @ctdb: the ctdb_connection from ctdb_connect. + * @destnode: the destination node (see below) + * @ips: a pointer to the returned public ip list + * + * This control returns the list of public ips known to the local node. + * Deamons only know about those ips that are listed in the local + * public addresses file, which means the returned list of ips may + * be only a subset of all ips across the entire cluster. + * + * There are several special values for destnode, detailed in + * ctdb_protocol.h, particularly CTDB_CURRENT_NODE which means the + * local ctdbd. + * + * This returns false if something went wrong. + * If the command failed, it guarantees to set ips to NULL. + * A non-NULL value for nodemap means the command was successful. + * + * A non-NULL value of the nodemap must be release released/freed + * by ctdb_free_publicips(). + */ +bool ctdb_getpublicips(struct ctdb_connection *ctdb, + uint32_t destnode, struct ctdb_all_public_ips **ips); + +/* + * This function is used to release/free the public ip structure returned + * by ctdb_getpublicips() and ctdb_getpublicips_recv() + */ +void ctdb_free_publicips(struct ctdb_all_public_ips *ips); + /* These ugly macro wrappers make the callbacks typesafe. */ #include <ctdb_typesafe_cb.h> @@ -669,4 +737,8 @@ void ctdb_free_nodemap(struct ctdb_node_map *nodemap); ctdb_getnodemap_send((ctdb), (destnode), \ ctdb_sendcb((cb), (cbdata)), (cbdata)) +#define ctdb_getpublicips_send(ctdb, destnode, cb, cbdata) \ + ctdb_getpublicips_send((ctdb), (destnode), \ + ctdb_sendcb((cb), (cbdata)), (cbdata)) + #endif diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 89b8f08b6f..8ceae204d6 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -991,10 +991,6 @@ struct ctdb_public_ipv4 { struct sockaddr_in sin; }; -struct ctdb_public_ip { - uint32_t pnn; - ctdb_sock_addr addr; -}; int ctdb_ctrl_takeover_ip(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_public_ip *ip); int ctdb_ctrl_release_ip(struct ctdb_context *ctdb, struct timeval timeout, @@ -1005,10 +1001,6 @@ struct ctdb_all_public_ipsv4 { struct ctdb_public_ipv4 ips[1]; }; -struct ctdb_all_public_ips { - uint32_t num; - struct ctdb_public_ip ips[1]; -}; int32_t ctdb_control_get_public_ipsv4(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA *outdata); int32_t ctdb_control_get_public_ips(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA *outdata); int ctdb_ctrl_get_public_ips(struct ctdb_context *ctdb, diff --git a/ctdb/include/ctdb_protocol.h b/ctdb/include/ctdb_protocol.h index a9f6249d61..f04b3f39fb 100644 --- a/ctdb/include/ctdb_protocol.h +++ b/ctdb/include/ctdb_protocol.h @@ -155,6 +155,12 @@ struct ctdb_call_info { */ #define CTDB_SRVID_ISCSID_RANGE 0xFE02000000000000LL +/* A range of ports reserved for testing (top 32 bits) + * All ports matching the 32 top bits are reserved for exclusive use by + * test applications + */ +#define CTDB_SRVID_TEST_RANGE 0xFE03000000000000LL + /* used on the domain socket, send a pdu to the local daemon */ #define CTDB_CURRENT_NODE 0xF0000001 /* send a broadcast to all nodes in the cluster, active or not */ @@ -518,4 +524,14 @@ struct ctdb_node_map { #define NODE_FLAGS_INACTIVE (NODE_FLAGS_DELETED|NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED) +struct ctdb_public_ip { + uint32_t pnn; + ctdb_sock_addr addr; +}; + +struct ctdb_all_public_ips { + uint32_t num; + struct ctdb_public_ip ips[1]; +}; + #endif |
