libctdb: reorganize headers: remove ctdb.h, add ctdb_client.h and ctdb_protocol.h
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 20 May 2010 05:48:30 +0000 (15:18 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 20 May 2010 05:48:30 +0000 (15:18 +0930)
ctdb_client.h is the existing internal client interface (which was mainly
in ctdb.h), and ctdb_protocol.h is the information needed for the wire
protocol only.

ctdb.h will be the new, shiny, libctdb API.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
16 files changed:
Makefile.in
common/cmdline.c
common/ctdb_io.c
common/ctdb_logging.c
include/ctdb_client.h [moved from include/ctdb.h with 72% similarity]
include/ctdb_private.h
include/ctdb_protocol.h [new file with mode: 0644]
include/includes.h
packaging/RPM/ctdb.spec.in
server/ctdb_banning.c
server/ctdb_daemon.c
server/ctdb_logging.c
server/ctdb_recoverd.c
tests/src/ctdb_bench.c
tools/ctdb.c
tools/ctdb_vacuum.c

index 4e70ce8e0b7cf7ee90763ee6ceb1ec230b8da5f0..36dffe09c13675b4d99ec93afa5f9666081ca322 100755 (executable)
@@ -207,7 +207,8 @@ install: all
        ${INSTALLCMD} -m 755 bin/ctdbd $(DESTDIR)$(sbindir)
        ${INSTALLCMD} -m 755 bin/smnotify $(DESTDIR)$(bindir)
        $(INSTALLCMD) -m 755 bin/ping_pong $(DESTDIR)$(bindir)
-       ${INSTALLCMD} -m 644 include/ctdb.h $(DESTDIR)$(includedir)
+       ${INSTALLCMD} -m 644 include/ctdb_client.h $(DESTDIR)$(includedir)
+       ${INSTALLCMD} -m 644 include/ctdb_protocol.h $(DESTDIR)$(includedir)
        ${INSTALLCMD} -m 644 include/ctdb_private.h $(DESTDIR)$(includedir) # for samba3
        ${INSTALLCMD} -m 644 config/functions $(DESTDIR)$(etcdir)/ctdb
        ${INSTALLCMD} -m 755 config/statd-callout $(DESTDIR)$(etcdir)/ctdb
index 332a448a6834ee4ccdcd67d45370705d8cebfad7..38af6ebb693c94e9ad2c76ece8d861a0ead4aea7 100644 (file)
@@ -21,7 +21,7 @@
 #include "lib/events/events.h"
 #include "system/filesys.h"
 #include "popt.h"
-#include "../include/ctdb.h"
+#include "../include/ctdb_client.h"
 #include "../include/ctdb_private.h"
 #include "../common/rb_tree.h"
 #include <ctype.h>
index b7feed9c118162257171354e4bdbdef9c0c65f3b..c9ac989c233d0425aa349134b9a29c7b29fa3231 100644 (file)
@@ -27,7 +27,7 @@
 #include "system/network.h"
 #include "system/filesys.h"
 #include "../include/ctdb_private.h"
-#include "../include/ctdb.h"
+#include "../include/ctdb_client.h"
 
 /* structures for packet queueing - see common/ctdb_io.c */
 struct ctdb_partial {
index ea4d2716302e8abd2281bd76db1a0dcdc550ec68..6acc060a21149c812eef40242e9c102e4bebd0bf 100644 (file)
@@ -22,7 +22,7 @@
 #include "lib/tdb/include/tdb.h"
 #include "system/time.h"
 #include "../include/ctdb_private.h"
-#include "../include/ctdb.h"
+#include "../include/ctdb_client.h"
 
 int log_ringbuf_size;
 
similarity index 72%
rename from include/ctdb.h
rename to include/ctdb_client.h
index 540ca98a8d2efeaa8989528a65cb71eb495c56e6..394b89ea9aac99ce1dee76529aec24f1ce81e9ee 100644 (file)
@@ -1,5 +1,5 @@
-/* 
-   ctdb database library
+/*
+   ctdb database library: old client interface
 
    Copyright (C) Andrew Tridgell  2006
 
    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/>.
 */
 
-#ifndef _CTDB_H
-#define _CTDB_H
-
-#define CTDB_IMMEDIATE_MIGRATION       0x00000001
-struct ctdb_call {
-       int call_id;
-       TDB_DATA key;
-       TDB_DATA call_data;
-       TDB_DATA reply_data;
-       uint32_t status;
-       uint32_t flags;
-};
-
-/*
-  structure passed to a ctdb call backend function
-*/
-struct ctdb_call_info {
-       TDB_DATA key;          /* record key */
-       TDB_DATA record_data;  /* current data in the record */
-       TDB_DATA *new_data;    /* optionally updated record data */
-       TDB_DATA *call_data;   /* optionally passed from caller */
-       TDB_DATA *reply_data;  /* optionally returned by function */
-       uint32_t status;       /* optional reply status - defaults to zero */
-};
-
-#define CTDB_ERR_INVALID 1
-#define CTDB_ERR_NOMEM 2
-
-/*
-  ctdb flags
-*/
-#define CTDB_FLAG_TORTURE      (1<<1)
-
-/* 
-   a message handler ID meaning "give me all messages"
- */
-#define CTDB_SRVID_ALL (~(uint64_t)0)
-
-/*
-  srvid type : RECOVERY
-*/
-#define CTDB_SRVID_RECOVERY    0xF100000000000000LL
-
-/* 
-   a message handler ID meaning that the cluster has been reconfigured
- */
-#define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL
-
-/* 
-   a message handler ID meaning that an IP address has been released
- */
-#define CTDB_SRVID_RELEASE_IP 0xF300000000000000LL
-
-/* 
-   a message ID to set the node flags in the recovery daemon
- */
-#define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL
-
-/* 
-   a message ID to ask the recovery daemon to update the expected node
-   assignment for a public ip
- */
-#define CTDB_SRVID_RECD_UPDATE_IP 0xF500000000000000LL
-
-/*
-  a message to tell the recovery daemon to fetch a set of records
- */
-#define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL
-
-/*
-  a message to tell the recovery daemon to write a talloc memdump
-  to the log
- */
-#define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
-
-/* 
-   a message ID to get the recovery daemon to push the node flags out
- */
-#define CTDB_SRVID_PUSH_NODE_FLAGS 0xF900000000000000LL
-
-/* 
-   a message ID to get the recovery daemon to reload the nodes file
- */
-#define CTDB_SRVID_RELOAD_NODES 0xFA00000000000000LL
-
-/* 
-   a message ID to get the recovery daemon to perform a takeover run
- */
-#define CTDB_SRVID_TAKEOVER_RUN 0xFB00000000000000LL
-
-/* A message id to ask the recovery daemon to temporarily disable the
-   public ip checks
-*/
-#define CTDB_SRVID_DISABLE_IP_CHECK  0xFC00000000000000LL
-
-/* A dummy port used for sending back ipreallocate resposnes to the main
-   daemon
-*/
-#define CTDB_SRVID_TAKEOVER_RUN_RESPONSE  0xFD00000000000000LL
-
-/* A port reserved for samba (top 32 bits)
- */
-#define CTDB_SRVID_SAMBA_NOTIFY  0xFE00000000000000LL
-
-/* 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 */
-#define CTDB_BROADCAST_ALL    0xF0000002
-/* send a broadcast to all nodes in the current vnn map */
-#define CTDB_BROADCAST_VNNMAP 0xF0000003
-/* send a broadcast to all connected nodes */
-#define CTDB_BROADCAST_CONNECTED 0xF0000004
-
-/* the key used for transaction locking on persistent databases */
-#define CTDB_TRANSACTION_LOCK_KEY "__transaction_lock__"
-
-/* the key used to store persistent db sequence number */
-#define CTDB_DB_SEQNUM_KEY "__db_sequence_number__"
+#ifndef _CTDB_CLIENT_H
+#define _CTDB_CLIENT_H
+#include <ctdb_protocol.h>
 
 enum control_state {CTDB_CONTROL_WAIT, CTDB_CONTROL_DONE, CTDB_CONTROL_ERROR, CTDB_CONTROL_TIMEOUT};
 
@@ -154,7 +39,7 @@ struct ctdb_client_control_state {
        struct {
                void (*fn)(struct ctdb_client_control_state *);
                void *private_data;
-       } async;        
+       } async;
 };
 
 struct ctdb_client_notify_register {
@@ -267,9 +152,9 @@ uint32_t ctdb_get_pnn(struct ctdb_context *ctdb);
 uint32_t ctdb_get_num_nodes(struct ctdb_context *ctdb);
 
 /* setup a handler for ctdb messages */
-typedef void (*ctdb_message_fn_t)(struct ctdb_context *, uint64_t srvid, 
+typedef void (*ctdb_message_fn_t)(struct ctdb_context *, uint64_t srvid,
                                  TDB_DATA data, void *);
-int ctdb_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid, 
+int ctdb_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid,
                             ctdb_message_fn_t handler,
                             void *private_data);
 
@@ -283,20 +168,20 @@ int ctdb_send_message(struct ctdb_context *ctdb, uint32_t pnn,
                      uint64_t srvid, TDB_DATA data);
 
 
-/* 
+/*
    Fetch a ctdb record from a remote node
  . Underneath this will force the
-   dmaster for the record to be moved to the local node. 
+   dmaster for the record to be moved to the local node.
 */
-struct ctdb_record_handle *ctdb_fetch_lock(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx, 
+struct ctdb_record_handle *ctdb_fetch_lock(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx,
                                           TDB_DATA key, TDB_DATA *data);
 
 int ctdb_record_store(struct ctdb_record_handle *h, TDB_DATA data);
 
-int ctdb_fetch(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx, 
+int ctdb_fetch(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx,
               TDB_DATA key, TDB_DATA *data);
 
-int ctdb_register_message_handler(struct ctdb_context *ctdb, 
+int ctdb_register_message_handler(struct ctdb_context *ctdb,
                                  TALLOC_CTX *mem_ctx,
                                  uint64_t srvid,
                                  ctdb_message_fn_t handler,
@@ -313,11 +198,11 @@ int ctdb_ctrl_statistics(struct ctdb_context *ctdb, uint32_t destnode, struct ct
 int ctdb_ctrl_shutdown(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
 
 struct ctdb_vnn_map;
-int ctdb_ctrl_getvnnmap(struct ctdb_context *ctdb, 
-               struct timeval timeout, uint32_t destnode, 
+int ctdb_ctrl_getvnnmap(struct ctdb_context *ctdb,
+               struct timeval timeout, uint32_t destnode,
                TALLOC_CTX *mem_ctx, struct ctdb_vnn_map **vnnmap);
 int ctdb_ctrl_setvnnmap(struct ctdb_context *ctdb,
-               struct timeval timeout, uint32_t destnode, 
+               struct timeval timeout, uint32_t destnode,
                TALLOC_CTX *mem_ctx, struct ctdb_vnn_map *vnnmap);
 
 /* table that contains a list of all dbids on a node
@@ -329,22 +214,22 @@ struct ctdb_dbid_map {
                bool persistent;
        } dbs[1];
 };
-int ctdb_ctrl_getdbmap(struct ctdb_context *ctdb, 
-       struct timeval timeout, uint32_t destnode, 
+int ctdb_ctrl_getdbmap(struct ctdb_context *ctdb,
+       struct timeval timeout, uint32_t destnode,
        TALLOC_CTX *mem_ctx, struct ctdb_dbid_map **dbmap);
 
 
 struct ctdb_node_map;
 
-int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb, 
-                   struct timeval timeout, uint32_t destnode, 
+int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb,
+                   struct timeval timeout, uint32_t destnode,
                    TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap);
 
-int ctdb_ctrl_getnodemapv4(struct ctdb_context *ctdb, 
-                   struct timeval timeout, uint32_t destnode, 
+int ctdb_ctrl_getnodemapv4(struct ctdb_context *ctdb,
+                   struct timeval timeout, uint32_t destnode,
                    TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap);
 
-int ctdb_ctrl_reload_nodes_file(struct ctdb_context *ctdb, 
+int ctdb_ctrl_reload_nodes_file(struct ctdb_context *ctdb,
                    struct timeval timeout, uint32_t destnode);
 
 struct ctdb_key_list {
@@ -384,9 +269,9 @@ int ctdb_ctrl_pushdb_recv(
        struct ctdb_client_control_state *state);
 
 
-int ctdb_ctrl_copydb(struct ctdb_context *ctdb, 
-       struct timeval timeout, uint32_t sourcenode, 
-       uint32_t destnode, uint32_t dbid, uint32_t lmaster, 
+int ctdb_ctrl_copydb(struct ctdb_context *ctdb,
+       struct timeval timeout, uint32_t sourcenode,
+       uint32_t destnode, uint32_t dbid, uint32_t lmaster,
        TALLOC_CTX *mem_ctx);
 
 int ctdb_ctrl_getdbpath(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t dbid, TALLOC_CTX *mem_ctx, const char **path);
@@ -410,8 +295,8 @@ int ctdb_ctrl_set_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, int32
 /*
   change dmaster for all keys in the database to the new value
  */
-int ctdb_ctrl_setdmaster(struct ctdb_context *ctdb, 
-       struct timeval timeout, uint32_t destnode, 
+int ctdb_ctrl_setdmaster(struct ctdb_context *ctdb,
+       struct timeval timeout, uint32_t destnode,
        TALLOC_CTX *mem_ctx, uint32_t dbid, uint32_t dmaster);
 
 /*
@@ -468,8 +353,8 @@ int ctdb_ctrl_getrecmaster_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
  */
 int ctdb_ctrl_setrecmaster(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmaster);
 
-uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb, 
-                                  struct timeval timeout, 
+uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb,
+                                  struct timeval timeout,
                                   TALLOC_CTX *mem_ctx,
                                   uint32_t *num_nodes);
 
@@ -488,17 +373,17 @@ int ctdb_dump_db(struct ctdb_db_context *ctdb_db, FILE *f);
  */
 int ctdb_ctrl_getpid(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *pid);
 
-int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout, 
+int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout,
                        uint32_t destnode);
-int ctdb_ctrl_freeze_priority(struct ctdb_context *ctdb, struct timeval timeout, 
+int ctdb_ctrl_freeze_priority(struct ctdb_context *ctdb, struct timeval timeout,
                              uint32_t destnode, uint32_t priority);
 
 struct ctdb_client_control_state *
-ctdb_ctrl_freeze_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, 
+ctdb_ctrl_freeze_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
                      struct timeval timeout, uint32_t destnode,
                      uint32_t priority);
 
-int ctdb_ctrl_freeze_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, 
+int ctdb_ctrl_freeze_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
                        struct ctdb_client_control_state *state);
 
 int ctdb_ctrl_thaw_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t priority);
@@ -506,25 +391,25 @@ int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t d
 
 int ctdb_ctrl_getpnn(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
 
-int ctdb_ctrl_get_tunable(struct ctdb_context *ctdb, 
-                         struct timeval timeout, 
+int ctdb_ctrl_get_tunable(struct ctdb_context *ctdb,
+                         struct timeval timeout,
                          uint32_t destnode,
                          const char *name, uint32_t *value);
 
-int ctdb_ctrl_set_tunable(struct ctdb_context *ctdb, 
-                         struct timeval timeout, 
+int ctdb_ctrl_set_tunable(struct ctdb_context *ctdb,
+                         struct timeval timeout,
                          uint32_t destnode,
                          const char *name, uint32_t value);
 
-int ctdb_ctrl_list_tunables(struct ctdb_context *ctdb, 
-                           struct timeval timeout, 
+int ctdb_ctrl_list_tunables(struct ctdb_context *ctdb,
+                           struct timeval timeout,
                            uint32_t destnode,
                            TALLOC_CTX *mem_ctx,
                            const char ***list, uint32_t *count);
 
-int ctdb_ctrl_modflags(struct ctdb_context *ctdb, 
-                      struct timeval timeout, 
-                      uint32_t destnode, 
+int ctdb_ctrl_modflags(struct ctdb_context *ctdb,
+                      struct timeval timeout,
+                      uint32_t destnode,
                       uint32_t set, uint32_t clear);
 
 enum ctdb_server_id_type { SERVER_TYPE_SAMBA=1 };
@@ -544,15 +429,15 @@ struct ctdb_server_id_list {
 int ctdb_ctrl_register_server_id(struct ctdb_context *ctdb,
                struct timeval timeout,
                struct ctdb_server_id *id);
-int ctdb_ctrl_unregister_server_id(struct ctdb_context *ctdb, 
-               struct timeval timeout, 
+int ctdb_ctrl_unregister_server_id(struct ctdb_context *ctdb,
+               struct timeval timeout,
                struct ctdb_server_id *id);
 int ctdb_ctrl_check_server_id(struct ctdb_context *ctdb,
-               struct timeval timeout, uint32_t destnode, 
+               struct timeval timeout, uint32_t destnode,
                struct ctdb_server_id *id, uint32_t *status);
 int ctdb_ctrl_get_server_id_list(struct ctdb_context *ctdb,
                TALLOC_CTX *mem_ctx,
-               struct timeval timeout, uint32_t destnode, 
+               struct timeval timeout, uint32_t destnode,
                struct ctdb_server_id_list **svid_list);
 
 struct ctdb_uptime {
@@ -576,7 +461,7 @@ typedef union {
 /*
   struct for tcp_client control
   this is an ipv4 only version of this structure used by samba
-  samba will later be migrated over to use the 
+  samba will later be migrated over to use the
   ctdb_control_tcp_addr structure instead
  */
 struct ctdb_control_tcp {
@@ -602,11 +487,11 @@ int ctdb_ctrl_uptime_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct
 
 int ctdb_ctrl_end_recovery(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
 
-int ctdb_ctrl_getreclock(struct ctdb_context *ctdb, 
-       struct timeval timeout, uint32_t destnode, 
+int ctdb_ctrl_getreclock(struct ctdb_context *ctdb,
+       struct timeval timeout, uint32_t destnode,
        TALLOC_CTX *mem_ctx, const char **reclock);
-int ctdb_ctrl_setreclock(struct ctdb_context *ctdb, 
-       struct timeval timeout, uint32_t destnode, 
+int ctdb_ctrl_setreclock(struct ctdb_context *ctdb,
+       struct timeval timeout, uint32_t destnode,
        const char *reclock);
 
 
@@ -643,7 +528,7 @@ int32_t ctdb_ctrl_transaction_active(struct ctdb_context *ctdb,
                                     uint32_t destnode,
                                     uint32_t db_id);
 
-struct ctdb_marshall_buffer *ctdb_marshall_add(TALLOC_CTX *mem_ctx, 
+struct ctdb_marshall_buffer *ctdb_marshall_add(TALLOC_CTX *mem_ctx,
                                               struct ctdb_marshall_buffer *m,
                                               uint64_t db_id,
                                               uint32_t reqid,
@@ -654,10 +539,10 @@ TDB_DATA ctdb_marshall_finish(struct ctdb_marshall_buffer *m);
 
 struct ctdb_transaction_handle *ctdb_transaction_start(struct ctdb_db_context *ctdb_db,
                                                       TALLOC_CTX *mem_ctx);
-int ctdb_transaction_fetch(struct ctdb_transaction_handle *h, 
-                          TALLOC_CTX *mem_ctx, 
+int ctdb_transaction_fetch(struct ctdb_transaction_handle *h,
+                          TALLOC_CTX *mem_ctx,
                           TDB_DATA key, TDB_DATA *data);
-int ctdb_transaction_store(struct ctdb_transaction_handle *h, 
+int ctdb_transaction_store(struct ctdb_transaction_handle *h,
                           TDB_DATA key, TDB_DATA data);
 int ctdb_transaction_commit(struct ctdb_transaction_handle *h);
 
@@ -665,47 +550,8 @@ int ctdb_ctrl_recd_ping(struct ctdb_context *ctdb);
 
 int switch_from_server_to_client(struct ctdb_context *ctdb);
 
-#define MONITOR_SCRIPT_OK      0
-#define MONITOR_SCRIPT_TIMEOUT 1
-
-#define MAX_SCRIPT_NAME 31
-#define MAX_SCRIPT_OUTPUT 511
-struct ctdb_script_wire {
-       char name[MAX_SCRIPT_NAME+1];
-       struct timeval start;
-       struct timeval finished;
-       int32_t status;
-       char output[MAX_SCRIPT_OUTPUT+1];
-};
-
-struct ctdb_scripts_wire {
-       uint32_t num_scripts;
-       struct ctdb_script_wire scripts[1];
-};
-
-/* different calls to event scripts. */
-enum ctdb_eventscript_call {
-       CTDB_EVENT_INIT,                /* CTDB starting up: no args */
-       CTDB_EVENT_SETUP,               /* CTDB starting up after transport is readdy: no args. */
-       CTDB_EVENT_STARTUP,             /* CTDB starting up after initial recovery: no args. */
-       CTDB_EVENT_START_RECOVERY,      /* CTDB recovery starting: no args. */
-       CTDB_EVENT_RECOVERED,           /* CTDB recovery finished: no args. */
-       CTDB_EVENT_TAKE_IP,             /* IP taken: interface, IP address, netmask bits. */
-       CTDB_EVENT_RELEASE_IP,          /* IP released: interface, IP address, netmask bits. */
-       CTDB_EVENT_STOPPED,             /* This node is stopped: no args. */
-       CTDB_EVENT_MONITOR,             /* Please check if service is healthy: no args. */
-       CTDB_EVENT_STATUS,              /* Report service status: no args. */
-       CTDB_EVENT_SHUTDOWN,            /* CTDB shutting down: no args. */
-       CTDB_EVENT_RELOAD,              /* magic */
-       CTDB_EVENT_UPDATE_IP,           /* IP updating: old interface, new interface, IP address, netmask bits. */
-       CTDB_EVENT_MAX
-};
-
-/* Mapping from enum to names. */
-extern const char *ctdb_eventscript_call_names[];
-
-int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb, 
-                   struct timeval timeout, uint32_t destnode, 
+int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb,
+                   struct timeval timeout, uint32_t destnode,
                    TALLOC_CTX *mem_ctx, enum ctdb_eventscript_call type,
                    struct ctdb_scripts_wire **script_status);
 
@@ -745,4 +591,4 @@ struct ctdb_db_priority {
 int ctdb_ctrl_set_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_db_priority *db_prio);
 int ctdb_ctrl_get_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t db_id, uint32_t *priority);
 
-#endif
+#endif /* _CTDB_CLIENT_H */
index c0621204dda41d2bc9eba6b58722bf18d07f2795..7b752c5726a9ad7d9aafe0794c3205595f489ac3 100644 (file)
 #ifndef _CTDB_PRIVATE_H
 #define _CTDB_PRIVATE_H
 
-#include "ctdb.h"
+#include "ctdb_client.h"
 #include <sys/socket.h>
 
-/* location of daemon socket */
-#define CTDB_PATH      "/tmp/ctdb.socket"
-
-/* default ctdb port number */
-#define CTDB_PORT 4379
-
-/* we must align packets to ensure ctdb works on all architectures (eg. sparc) */
-#define CTDB_DS_ALIGNMENT 8
-
-
-#define CTDB_NULL_FUNC      0xFF000001
-#define CTDB_FETCH_FUNC     0xFF000002
-
-
 /*
   recovery daemon memdump reply address
  */
@@ -514,139 +500,6 @@ struct ctdb_db_context {
           ctdb_fatal(ctdb, "Out of memory in " __location__ ); \
          }} while (0)
 
-/*
-  the extended header for records in the ltdb
-*/
-struct ctdb_ltdb_header {
-       uint64_t rsn;
-       uint32_t dmaster;
-       uint32_t laccessor;
-       uint32_t lacount;
-};
-
-enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0, 
-                   CTDB_CONTROL_STATISTICS              = 1, 
-                   /* #2 removed */
-                   CTDB_CONTROL_PING                    = 3,
-                   CTDB_CONTROL_GETDBPATH               = 4,
-                   CTDB_CONTROL_GETVNNMAP               = 5,
-                   CTDB_CONTROL_SETVNNMAP               = 6,
-                   CTDB_CONTROL_GET_DEBUG               = 7,
-                   CTDB_CONTROL_SET_DEBUG               = 8,
-                   CTDB_CONTROL_GET_DBMAP               = 9,
-                   CTDB_CONTROL_GET_NODEMAPv4           = 10, /* obsolete */
-                   CTDB_CONTROL_SET_DMASTER             = 11,
-                   /* #12 removed */
-                   CTDB_CONTROL_PULL_DB                 = 13,
-                   CTDB_CONTROL_PUSH_DB                 = 14,
-                   CTDB_CONTROL_GET_RECMODE             = 15,
-                   CTDB_CONTROL_SET_RECMODE             = 16,
-                   CTDB_CONTROL_STATISTICS_RESET        = 17,
-                   CTDB_CONTROL_DB_ATTACH               = 18,
-                   CTDB_CONTROL_SET_CALL                = 19,
-                   CTDB_CONTROL_TRAVERSE_START          = 20,
-                   CTDB_CONTROL_TRAVERSE_ALL            = 21,
-                   CTDB_CONTROL_TRAVERSE_DATA           = 22,
-                   CTDB_CONTROL_REGISTER_SRVID          = 23,
-                   CTDB_CONTROL_DEREGISTER_SRVID        = 24,
-                   CTDB_CONTROL_GET_DBNAME              = 25,
-                   CTDB_CONTROL_ENABLE_SEQNUM           = 26,
-                   CTDB_CONTROL_UPDATE_SEQNUM           = 27,
-                   /* #28 removed */
-                   CTDB_CONTROL_DUMP_MEMORY             = 29,
-                   CTDB_CONTROL_GET_PID                 = 30,
-                   CTDB_CONTROL_GET_RECMASTER           = 31,
-                   CTDB_CONTROL_SET_RECMASTER           = 32,
-                   CTDB_CONTROL_FREEZE                  = 33,
-                   CTDB_CONTROL_THAW                    = 34,
-                   CTDB_CONTROL_GET_PNN                 = 35,
-                   CTDB_CONTROL_SHUTDOWN                = 36,
-                   CTDB_CONTROL_GET_MONMODE             = 37,
-                   /* #38 removed */
-                   /* #39 removed */
-                   /* #40 removed */
-                   /* #41 removed */
-                   CTDB_CONTROL_TAKEOVER_IPv4           = 42, /* obsolete */
-                   CTDB_CONTROL_RELEASE_IPv4            = 43, /* obsolete */
-                   CTDB_CONTROL_TCP_CLIENT              = 44,
-                   CTDB_CONTROL_TCP_ADD                 = 45,
-                   CTDB_CONTROL_TCP_REMOVE              = 46,
-                   CTDB_CONTROL_STARTUP                 = 47,
-                   CTDB_CONTROL_SET_TUNABLE             = 48,
-                   CTDB_CONTROL_GET_TUNABLE             = 49,
-                   CTDB_CONTROL_LIST_TUNABLES           = 50,
-                   CTDB_CONTROL_GET_PUBLIC_IPSv4        = 51, /* obsolete */
-                   CTDB_CONTROL_MODIFY_FLAGS            = 52,
-                   CTDB_CONTROL_GET_ALL_TUNABLES        = 53,
-                   CTDB_CONTROL_KILL_TCP                = 54,
-                   CTDB_CONTROL_GET_TCP_TICKLE_LIST     = 55,
-                   CTDB_CONTROL_SET_TCP_TICKLE_LIST     = 56,
-                   CTDB_CONTROL_REGISTER_SERVER_ID      = 57,
-                   CTDB_CONTROL_UNREGISTER_SERVER_ID    = 58,
-                   CTDB_CONTROL_CHECK_SERVER_ID         = 59,
-                   CTDB_CONTROL_GET_SERVER_ID_LIST      = 60,
-                   CTDB_CONTROL_DB_ATTACH_PERSISTENT    = 61,
-                   CTDB_CONTROL_PERSISTENT_STORE        = 62,
-                   CTDB_CONTROL_UPDATE_RECORD           = 63,
-                   CTDB_CONTROL_SEND_GRATIOUS_ARP       = 64,
-                   CTDB_CONTROL_TRANSACTION_START       = 65,
-                   CTDB_CONTROL_TRANSACTION_COMMIT      = 66,
-                   CTDB_CONTROL_WIPE_DATABASE           = 67,
-                   /* #68 removed */
-                   CTDB_CONTROL_UPTIME                  = 69,
-                   CTDB_CONTROL_START_RECOVERY          = 70,
-                   CTDB_CONTROL_END_RECOVERY            = 71,
-                   CTDB_CONTROL_RELOAD_NODES_FILE       = 72,
-                   /* #73 removed */
-                   CTDB_CONTROL_TRY_DELETE_RECORDS      = 74,
-                   CTDB_CONTROL_ENABLE_MONITOR          = 75,
-                   CTDB_CONTROL_DISABLE_MONITOR         = 76,
-                   CTDB_CONTROL_ADD_PUBLIC_IP           = 77,
-                   CTDB_CONTROL_DEL_PUBLIC_IP           = 78,
-                   CTDB_CONTROL_RUN_EVENTSCRIPTS        = 79,
-                   CTDB_CONTROL_GET_CAPABILITIES        = 80,
-                   CTDB_CONTROL_START_PERSISTENT_UPDATE = 81,
-                   CTDB_CONTROL_CANCEL_PERSISTENT_UPDATE= 82,
-                   CTDB_CONTROL_TRANS2_COMMIT           = 83,
-                   CTDB_CONTROL_TRANS2_FINISHED         = 84,
-                   CTDB_CONTROL_TRANS2_ERROR            = 85,
-                   CTDB_CONTROL_TRANS2_COMMIT_RETRY     = 86,
-                   CTDB_CONTROL_RECD_PING               = 87,
-                   CTDB_CONTROL_RELEASE_IP              = 88,
-                   CTDB_CONTROL_TAKEOVER_IP             = 89,
-                   CTDB_CONTROL_GET_PUBLIC_IPS          = 90,
-                   CTDB_CONTROL_GET_NODEMAP             = 91,
-                   CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS = 96,
-                   CTDB_CONTROL_TRAVERSE_KILL           = 97,
-                   CTDB_CONTROL_RECD_RECLOCK_LATENCY    = 98,
-                   CTDB_CONTROL_GET_RECLOCK_FILE        = 99,
-                   CTDB_CONTROL_SET_RECLOCK_FILE        = 100,
-                   CTDB_CONTROL_STOP_NODE               = 101,
-                   CTDB_CONTROL_CONTINUE_NODE           = 102,
-                   CTDB_CONTROL_SET_NATGWSTATE          = 103,
-                   CTDB_CONTROL_SET_LMASTERROLE         = 104,
-                   CTDB_CONTROL_SET_RECMASTERROLE       = 105,
-                   CTDB_CONTROL_ENABLE_SCRIPT           = 107,
-                   CTDB_CONTROL_DISABLE_SCRIPT          = 108,
-                   CTDB_CONTROL_SET_BAN_STATE           = 109,
-                   CTDB_CONTROL_GET_BAN_STATE           = 110,
-                   CTDB_CONTROL_SET_DB_PRIORITY         = 111,
-                   CTDB_CONTROL_GET_DB_PRIORITY         = 112,
-                   CTDB_CONTROL_TRANSACTION_CANCEL      = 113,
-                   CTDB_CONTROL_REGISTER_NOTIFY         = 114,
-                   CTDB_CONTROL_DEREGISTER_NOTIFY       = 115,
-                   CTDB_CONTROL_TRANS2_ACTIVE           = 116,
-                   CTDB_CONTROL_GET_LOG                 = 117,
-                   CTDB_CONTROL_CLEAR_LOG               = 118,
-                   CTDB_CONTROL_TRANS3_COMMIT           = 119,
-                   CTDB_CONTROL_GET_DB_SEQNUM           = 120,
-                   CTDB_CONTROL_DB_SET_HEALTHY          = 121,
-                   CTDB_CONTROL_DB_GET_HEALTH           = 122,
-                   CTDB_CONTROL_GET_PUBLIC_IP_INFO      = 123,
-                   CTDB_CONTROL_GET_IFACES              = 124,
-                   CTDB_CONTROL_SET_IFACE_LINK_STATE    = 125,
-};     
-
 /*
   structure passed in set_call control
  */
@@ -751,134 +604,6 @@ struct ctdb_fetch_handle {
        struct ctdb_ltdb_header header;
 };
 
-/*
-  operation IDs
-*/
-enum ctdb_operation {
-       CTDB_REQ_CALL           = 0,
-       CTDB_REPLY_CALL         = 1,
-       CTDB_REQ_DMASTER        = 2,
-       CTDB_REPLY_DMASTER      = 3,
-       CTDB_REPLY_ERROR        = 4,
-       CTDB_REQ_MESSAGE        = 5,
-       /* #6 removed */
-       CTDB_REQ_CONTROL        = 7,
-       CTDB_REPLY_CONTROL      = 8,
-       CTDB_REQ_KEEPALIVE      = 9,
-};
-
-#define CTDB_MAGIC 0x43544442 /* CTDB */
-#define CTDB_VERSION 1
-
-/*
-  packet structures
-*/
-struct ctdb_req_header {
-       uint32_t length;
-       uint32_t ctdb_magic;
-       uint32_t ctdb_version;
-       uint32_t generation;
-       uint32_t operation;
-       uint32_t destnode;
-       uint32_t srcnode;
-       uint32_t reqid;
-};
-
-struct ctdb_req_call {
-       struct ctdb_req_header hdr;
-       uint32_t flags;
-       uint32_t db_id;
-       uint32_t callid;
-       uint32_t hopcount;
-       uint32_t keylen;
-       uint32_t calldatalen;
-       uint8_t data[1]; /* key[] followed by calldata[] */
-};
-
-struct ctdb_reply_call {
-       struct ctdb_req_header hdr;
-       uint32_t status;
-       uint32_t datalen;
-       uint8_t  data[1];
-};
-
-struct ctdb_reply_error {
-       struct ctdb_req_header hdr;
-       uint32_t status;
-       uint32_t msglen;
-       uint8_t  msg[1];
-};
-
-struct ctdb_req_dmaster {
-       struct ctdb_req_header hdr;
-       uint32_t db_id;
-       uint64_t rsn;
-       uint32_t dmaster;
-       uint32_t keylen;
-       uint32_t datalen;
-       uint8_t  data[1];
-};
-
-struct ctdb_reply_dmaster {
-       struct ctdb_req_header hdr;
-       uint32_t db_id;
-       uint64_t rsn;
-       uint32_t keylen;
-       uint32_t datalen;
-       uint8_t  data[1];
-};
-
-struct ctdb_req_message {
-       struct ctdb_req_header hdr;
-       uint64_t srvid;
-       uint32_t datalen;
-       uint8_t data[1];
-};
-
-struct ctdb_req_getdbpath {
-       struct ctdb_req_header hdr;
-       uint32_t db_id;
-};
-
-struct ctdb_reply_getdbpath {
-       struct ctdb_req_header hdr;
-       uint32_t datalen;
-       uint8_t data[1];
-};
-
-struct ctdb_req_control {
-       struct ctdb_req_header hdr;
-       uint32_t opcode;
-       uint64_t srvid;
-       uint32_t client_id;
-#define CTDB_CTRL_FLAG_NOREPLY   1
-#define CTDB_CTRL_FLAG_OPCODE_SPECIFIC   0xFFFF0000
-       uint32_t flags;
-       uint32_t datalen;
-       uint8_t data[1];
-};
-
-struct ctdb_reply_control {
-       struct ctdb_req_header hdr;
-       int32_t  status;
-       uint32_t datalen;
-       uint32_t errorlen;
-       uint8_t data[1];
-};
-
-struct ctdb_req_keepalive {
-       struct ctdb_req_header hdr;
-};
-
-
-/* types of failures possible from TRANS2_COMMIT */
-enum ctdb_trans2_commit_error {
-       CTDB_TRANS2_COMMIT_SUCCESS=0, /* all nodes committed successfully */
-       CTDB_TRANS2_COMMIT_TIMEOUT=1, /* at least one node timed out */
-       CTDB_TRANS2_COMMIT_ALLFAIL=2, /* all nodes failed the commit */
-       CTDB_TRANS2_COMMIT_SOMEFAIL=3 /* some nodes failed the commit, some allowed it */
-};
-
 /* internal prototypes */
 void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
 void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);
diff --git a/include/ctdb_protocol.h b/include/ctdb_protocol.h
new file mode 100644 (file)
index 0000000..2a334b9
--- /dev/null
@@ -0,0 +1,452 @@
+/*
+   ctdb database library
+
+   Copyright (C) Andrew Tridgell  2006
+
+   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/>.
+*/
+
+#ifndef _CTDB_PROTOCOL_H
+#define _CTDB_PROTOCOL_H
+
+/* location of daemon socket */
+#define CTDB_PATH      "/tmp/ctdb.socket"
+
+/* default ctdb port number */
+#define CTDB_PORT 4379
+
+/* we must align packets to ensure ctdb works on all architectures (eg. sparc) */
+#define CTDB_DS_ALIGNMENT 8
+
+
+#define CTDB_NULL_FUNC      0xFF000001
+#define CTDB_FETCH_FUNC     0xFF000002
+
+
+#define CTDB_IMMEDIATE_MIGRATION       0x00000001
+struct ctdb_call {
+       int call_id;
+       TDB_DATA key;
+       TDB_DATA call_data;
+       TDB_DATA reply_data;
+       uint32_t status;
+       uint32_t flags;
+};
+
+/*
+  structure passed to a ctdb call backend function
+*/
+struct ctdb_call_info {
+       TDB_DATA key;          /* record key */
+       TDB_DATA record_data;  /* current data in the record */
+       TDB_DATA *new_data;    /* optionally updated record data */
+       TDB_DATA *call_data;   /* optionally passed from caller */
+       TDB_DATA *reply_data;  /* optionally returned by function */
+       uint32_t status;       /* optional reply status - defaults to zero */
+};
+
+#define CTDB_ERR_INVALID 1
+#define CTDB_ERR_NOMEM 2
+
+/*
+  ctdb flags
+*/
+#define CTDB_FLAG_TORTURE      (1<<1)
+
+/*
+   a message handler ID meaning "give me all messages"
+ */
+#define CTDB_SRVID_ALL (~(uint64_t)0)
+
+/*
+  srvid type : RECOVERY
+*/
+#define CTDB_SRVID_RECOVERY    0xF100000000000000LL
+
+/*
+   a message handler ID meaning that the cluster has been reconfigured
+ */
+#define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL
+
+/*
+   a message handler ID meaning that an IP address has been released
+ */
+#define CTDB_SRVID_RELEASE_IP 0xF300000000000000LL
+
+/*
+   a message ID to set the node flags in the recovery daemon
+ */
+#define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL
+
+/*
+   a message ID to ask the recovery daemon to update the expected node
+   assignment for a public ip
+ */
+#define CTDB_SRVID_RECD_UPDATE_IP 0xF500000000000000LL
+
+/*
+  a message to tell the recovery daemon to fetch a set of records
+ */
+#define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL
+
+/*
+  a message to tell the recovery daemon to write a talloc memdump
+  to the log
+ */
+#define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
+
+/*
+   a message ID to get the recovery daemon to push the node flags out
+ */
+#define CTDB_SRVID_PUSH_NODE_FLAGS 0xF900000000000000LL
+
+/*
+   a message ID to get the recovery daemon to reload the nodes file
+ */
+#define CTDB_SRVID_RELOAD_NODES 0xFA00000000000000LL
+
+/*
+   a message ID to get the recovery daemon to perform a takeover run
+ */
+#define CTDB_SRVID_TAKEOVER_RUN 0xFB00000000000000LL
+
+/* A message id to ask the recovery daemon to temporarily disable the
+   public ip checks
+*/
+#define CTDB_SRVID_DISABLE_IP_CHECK  0xFC00000000000000LL
+
+/* A dummy port used for sending back ipreallocate resposnes to the main
+   daemon
+*/
+#define CTDB_SRVID_TAKEOVER_RUN_RESPONSE  0xFD00000000000000LL
+
+/* A port reserved for samba (top 32 bits)
+ */
+#define CTDB_SRVID_SAMBA_NOTIFY  0xFE00000000000000LL
+
+/* 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 */
+#define CTDB_BROADCAST_ALL    0xF0000002
+/* send a broadcast to all nodes in the current vnn map */
+#define CTDB_BROADCAST_VNNMAP 0xF0000003
+/* send a broadcast to all connected nodes */
+#define CTDB_BROADCAST_CONNECTED 0xF0000004
+
+/* the key used for transaction locking on persistent databases */
+#define CTDB_TRANSACTION_LOCK_KEY "__transaction_lock__"
+
+/* the key used to store persistent db sequence number */
+#define CTDB_DB_SEQNUM_KEY "__db_sequence_number__"
+
+#define MONITOR_SCRIPT_OK      0
+#define MONITOR_SCRIPT_TIMEOUT 1
+
+#define MAX_SCRIPT_NAME 31
+#define MAX_SCRIPT_OUTPUT 511
+struct ctdb_script_wire {
+       char name[MAX_SCRIPT_NAME+1];
+       struct timeval start;
+       struct timeval finished;
+       int32_t status;
+       char output[MAX_SCRIPT_OUTPUT+1];
+};
+
+struct ctdb_scripts_wire {
+       uint32_t num_scripts;
+       struct ctdb_script_wire scripts[1];
+};
+
+/* different calls to event scripts. */
+enum ctdb_eventscript_call {
+       CTDB_EVENT_INIT,                /* CTDB starting up: no args */
+       CTDB_EVENT_SETUP,               /* CTDB starting up after transport is readdy: no args. */
+       CTDB_EVENT_STARTUP,             /* CTDB starting up after initial recovery: no args. */
+       CTDB_EVENT_START_RECOVERY,      /* CTDB recovery starting: no args. */
+       CTDB_EVENT_RECOVERED,           /* CTDB recovery finished: no args. */
+       CTDB_EVENT_TAKE_IP,             /* IP taken: interface, IP address, netmask bits. */
+       CTDB_EVENT_RELEASE_IP,          /* IP released: interface, IP address, netmask bits. */
+       CTDB_EVENT_STOPPED,             /* This node is stopped: no args. */
+       CTDB_EVENT_MONITOR,             /* Please check if service is healthy: no args. */
+       CTDB_EVENT_STATUS,              /* Report service status: no args. */
+       CTDB_EVENT_SHUTDOWN,            /* CTDB shutting down: no args. */
+       CTDB_EVENT_RELOAD,              /* magic */
+       CTDB_EVENT_UPDATE_IP,           /* IP updating: old interface, new interface, IP address, netmask bits. */
+       CTDB_EVENT_MAX
+};
+
+/* Mapping from enum to names. */
+extern const char *ctdb_eventscript_call_names[];
+
+/*
+  operation IDs
+*/
+enum ctdb_operation {
+       CTDB_REQ_CALL           = 0,
+       CTDB_REPLY_CALL         = 1,
+       CTDB_REQ_DMASTER        = 2,
+       CTDB_REPLY_DMASTER      = 3,
+       CTDB_REPLY_ERROR        = 4,
+       CTDB_REQ_MESSAGE        = 5,
+       /* #6 removed */
+       CTDB_REQ_CONTROL        = 7,
+       CTDB_REPLY_CONTROL      = 8,
+       CTDB_REQ_KEEPALIVE      = 9,
+};
+
+#define CTDB_MAGIC 0x43544442 /* CTDB */
+#define CTDB_VERSION 1
+
+enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
+                   CTDB_CONTROL_STATISTICS              = 1,
+                   /* #2 removed */
+                   CTDB_CONTROL_PING                    = 3,
+                   CTDB_CONTROL_GETDBPATH               = 4,
+                   CTDB_CONTROL_GETVNNMAP               = 5,
+                   CTDB_CONTROL_SETVNNMAP               = 6,
+                   CTDB_CONTROL_GET_DEBUG               = 7,
+                   CTDB_CONTROL_SET_DEBUG               = 8,
+                   CTDB_CONTROL_GET_DBMAP               = 9,
+                   CTDB_CONTROL_GET_NODEMAPv4           = 10, /* obsolete */
+                   CTDB_CONTROL_SET_DMASTER             = 11,
+                   /* #12 removed */
+                   CTDB_CONTROL_PULL_DB                 = 13,
+                   CTDB_CONTROL_PUSH_DB                 = 14,
+                   CTDB_CONTROL_GET_RECMODE             = 15,
+                   CTDB_CONTROL_SET_RECMODE             = 16,
+                   CTDB_CONTROL_STATISTICS_RESET        = 17,
+                   CTDB_CONTROL_DB_ATTACH               = 18,
+                   CTDB_CONTROL_SET_CALL                = 19,
+                   CTDB_CONTROL_TRAVERSE_START          = 20,
+                   CTDB_CONTROL_TRAVERSE_ALL            = 21,
+                   CTDB_CONTROL_TRAVERSE_DATA           = 22,
+                   CTDB_CONTROL_REGISTER_SRVID          = 23,
+                   CTDB_CONTROL_DEREGISTER_SRVID        = 24,
+                   CTDB_CONTROL_GET_DBNAME              = 25,
+                   CTDB_CONTROL_ENABLE_SEQNUM           = 26,
+                   CTDB_CONTROL_UPDATE_SEQNUM           = 27,
+                   /* #28 removed */
+                   CTDB_CONTROL_DUMP_MEMORY             = 29,
+                   CTDB_CONTROL_GET_PID                 = 30,
+                   CTDB_CONTROL_GET_RECMASTER           = 31,
+                   CTDB_CONTROL_SET_RECMASTER           = 32,
+                   CTDB_CONTROL_FREEZE                  = 33,
+                   CTDB_CONTROL_THAW                    = 34,
+                   CTDB_CONTROL_GET_PNN                 = 35,
+                   CTDB_CONTROL_SHUTDOWN                = 36,
+                   CTDB_CONTROL_GET_MONMODE             = 37,
+                   /* #38 removed */
+                   /* #39 removed */
+                   /* #40 removed */
+                   /* #41 removed */
+                   CTDB_CONTROL_TAKEOVER_IPv4           = 42, /* obsolete */
+                   CTDB_CONTROL_RELEASE_IPv4            = 43, /* obsolete */
+                   CTDB_CONTROL_TCP_CLIENT              = 44,
+                   CTDB_CONTROL_TCP_ADD                 = 45,
+                   CTDB_CONTROL_TCP_REMOVE              = 46,
+                   CTDB_CONTROL_STARTUP                 = 47,
+                   CTDB_CONTROL_SET_TUNABLE             = 48,
+                   CTDB_CONTROL_GET_TUNABLE             = 49,
+                   CTDB_CONTROL_LIST_TUNABLES           = 50,
+                   CTDB_CONTROL_GET_PUBLIC_IPSv4        = 51, /* obsolete */
+                   CTDB_CONTROL_MODIFY_FLAGS            = 52,
+                   CTDB_CONTROL_GET_ALL_TUNABLES        = 53,
+                   CTDB_CONTROL_KILL_TCP                = 54,
+                   CTDB_CONTROL_GET_TCP_TICKLE_LIST     = 55,
+                   CTDB_CONTROL_SET_TCP_TICKLE_LIST     = 56,
+                   CTDB_CONTROL_REGISTER_SERVER_ID      = 57,
+                   CTDB_CONTROL_UNREGISTER_SERVER_ID    = 58,
+                   CTDB_CONTROL_CHECK_SERVER_ID         = 59,
+                   CTDB_CONTROL_GET_SERVER_ID_LIST      = 60,
+                   CTDB_CONTROL_DB_ATTACH_PERSISTENT    = 61,
+                   CTDB_CONTROL_PERSISTENT_STORE        = 62,
+                   CTDB_CONTROL_UPDATE_RECORD           = 63,
+                   CTDB_CONTROL_SEND_GRATIOUS_ARP       = 64,
+                   CTDB_CONTROL_TRANSACTION_START       = 65,
+                   CTDB_CONTROL_TRANSACTION_COMMIT      = 66,
+                   CTDB_CONTROL_WIPE_DATABASE           = 67,
+                   /* #68 removed */
+                   CTDB_CONTROL_UPTIME                  = 69,
+                   CTDB_CONTROL_START_RECOVERY          = 70,
+                   CTDB_CONTROL_END_RECOVERY            = 71,
+                   CTDB_CONTROL_RELOAD_NODES_FILE       = 72,
+                   /* #73 removed */
+                   CTDB_CONTROL_TRY_DELETE_RECORDS      = 74,
+                   CTDB_CONTROL_ENABLE_MONITOR          = 75,
+                   CTDB_CONTROL_DISABLE_MONITOR         = 76,
+                   CTDB_CONTROL_ADD_PUBLIC_IP           = 77,
+                   CTDB_CONTROL_DEL_PUBLIC_IP           = 78,
+                   CTDB_CONTROL_RUN_EVENTSCRIPTS        = 79,
+                   CTDB_CONTROL_GET_CAPABILITIES        = 80,
+                   CTDB_CONTROL_START_PERSISTENT_UPDATE = 81,
+                   CTDB_CONTROL_CANCEL_PERSISTENT_UPDATE= 82,
+                   CTDB_CONTROL_TRANS2_COMMIT           = 83,
+                   CTDB_CONTROL_TRANS2_FINISHED         = 84,
+                   CTDB_CONTROL_TRANS2_ERROR            = 85,
+                   CTDB_CONTROL_TRANS2_COMMIT_RETRY     = 86,
+                   CTDB_CONTROL_RECD_PING               = 87,
+                   CTDB_CONTROL_RELEASE_IP              = 88,
+                   CTDB_CONTROL_TAKEOVER_IP             = 89,
+                   CTDB_CONTROL_GET_PUBLIC_IPS          = 90,
+                   CTDB_CONTROL_GET_NODEMAP             = 91,
+                   CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS = 96,
+                   CTDB_CONTROL_TRAVERSE_KILL           = 97,
+                   CTDB_CONTROL_RECD_RECLOCK_LATENCY    = 98,
+                   CTDB_CONTROL_GET_RECLOCK_FILE        = 99,
+                   CTDB_CONTROL_SET_RECLOCK_FILE        = 100,
+                   CTDB_CONTROL_STOP_NODE               = 101,
+                   CTDB_CONTROL_CONTINUE_NODE           = 102,
+                   CTDB_CONTROL_SET_NATGWSTATE          = 103,
+                   CTDB_CONTROL_SET_LMASTERROLE         = 104,
+                   CTDB_CONTROL_SET_RECMASTERROLE       = 105,
+                   CTDB_CONTROL_ENABLE_SCRIPT           = 107,
+                   CTDB_CONTROL_DISABLE_SCRIPT          = 108,
+                   CTDB_CONTROL_SET_BAN_STATE           = 109,
+                   CTDB_CONTROL_GET_BAN_STATE           = 110,
+                   CTDB_CONTROL_SET_DB_PRIORITY         = 111,
+                   CTDB_CONTROL_GET_DB_PRIORITY         = 112,
+                   CTDB_CONTROL_TRANSACTION_CANCEL      = 113,
+                   CTDB_CONTROL_REGISTER_NOTIFY         = 114,
+                   CTDB_CONTROL_DEREGISTER_NOTIFY       = 115,
+                   CTDB_CONTROL_TRANS2_ACTIVE           = 116,
+                   CTDB_CONTROL_GET_LOG                 = 117,
+                   CTDB_CONTROL_CLEAR_LOG               = 118,
+                   CTDB_CONTROL_TRANS3_COMMIT           = 119,
+                   CTDB_CONTROL_GET_DB_SEQNUM           = 120,
+                   CTDB_CONTROL_DB_SET_HEALTHY          = 121,
+                   CTDB_CONTROL_DB_GET_HEALTH           = 122,
+                   CTDB_CONTROL_GET_PUBLIC_IP_INFO      = 123,
+                   CTDB_CONTROL_GET_IFACES              = 124,
+                   CTDB_CONTROL_SET_IFACE_LINK_STATE    = 125,
+};
+
+/*
+  packet structures
+*/
+struct ctdb_req_header {
+       uint32_t length;
+       uint32_t ctdb_magic;
+       uint32_t ctdb_version;
+       uint32_t generation;
+       uint32_t operation;
+       uint32_t destnode;
+       uint32_t srcnode;
+       uint32_t reqid;
+};
+
+struct ctdb_req_call {
+       struct ctdb_req_header hdr;
+       uint32_t flags;
+       uint32_t db_id;
+       uint32_t callid;
+       uint32_t hopcount;
+       uint32_t keylen;
+       uint32_t calldatalen;
+       uint8_t data[1]; /* key[] followed by calldata[] */
+};
+
+struct ctdb_reply_call {
+       struct ctdb_req_header hdr;
+       uint32_t status;
+       uint32_t datalen;
+       uint8_t  data[1];
+};
+
+struct ctdb_reply_error {
+       struct ctdb_req_header hdr;
+       uint32_t status;
+       uint32_t msglen;
+       uint8_t  msg[1];
+};
+
+struct ctdb_req_dmaster {
+       struct ctdb_req_header hdr;
+       uint32_t db_id;
+       uint64_t rsn;
+       uint32_t dmaster;
+       uint32_t keylen;
+       uint32_t datalen;
+       uint8_t  data[1];
+};
+
+struct ctdb_reply_dmaster {
+       struct ctdb_req_header hdr;
+       uint32_t db_id;
+       uint64_t rsn;
+       uint32_t keylen;
+       uint32_t datalen;
+       uint8_t  data[1];
+};
+
+struct ctdb_req_message {
+       struct ctdb_req_header hdr;
+       uint64_t srvid;
+       uint32_t datalen;
+       uint8_t data[1];
+};
+
+struct ctdb_req_getdbpath {
+       struct ctdb_req_header hdr;
+       uint32_t db_id;
+};
+
+struct ctdb_reply_getdbpath {
+       struct ctdb_req_header hdr;
+       uint32_t datalen;
+       uint8_t data[1];
+};
+
+struct ctdb_req_control {
+       struct ctdb_req_header hdr;
+       uint32_t opcode;
+       uint64_t srvid;
+       uint32_t client_id;
+#define CTDB_CTRL_FLAG_NOREPLY   1
+#define CTDB_CTRL_FLAG_OPCODE_SPECIFIC   0xFFFF0000
+       uint32_t flags;
+       uint32_t datalen;
+       uint8_t data[1];
+};
+
+struct ctdb_reply_control {
+       struct ctdb_req_header hdr;
+       int32_t  status;
+       uint32_t datalen;
+       uint32_t errorlen;
+       uint8_t data[1];
+};
+
+struct ctdb_req_keepalive {
+       struct ctdb_req_header hdr;
+};
+
+
+/* types of failures possible from TRANS2_COMMIT */
+enum ctdb_trans2_commit_error {
+       CTDB_TRANS2_COMMIT_SUCCESS=0, /* all nodes committed successfully */
+       CTDB_TRANS2_COMMIT_TIMEOUT=1, /* at least one node timed out */
+       CTDB_TRANS2_COMMIT_ALLFAIL=2, /* all nodes failed the commit */
+       CTDB_TRANS2_COMMIT_SOMEFAIL=3 /* some nodes failed the commit, some allowed it */
+};
+
+/*
+  the extended header for records in the ltdb
+*/
+struct ctdb_ltdb_header {
+       uint64_t rsn;
+       uint32_t dmaster;
+       uint32_t laccessor;
+       uint32_t lacount;
+};
+#endif
index 43a6a5ff68746a6c0fe8a488ec0780e78add469e..b3f8eb941b22ad6cce91a7180a3db6bf2f9e6677 100644 (file)
@@ -6,7 +6,7 @@
 #include "system/network.h"
 #include "tdb.h"
 #include "idtree.h"
-#include "ctdb.h"
+#include "ctdb_client.h"
 
 typedef bool BOOL;
 
index 8da7944c10777d772e37d0805b3a53723fcff46b..3e1ef8310ee6a8f6f43e1240c8c13dcee4a8883f 100644 (file)
@@ -121,7 +121,8 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man1/ctdb.1.gz
 %{_mandir}/man1/ctdbd.1.gz
 %{_mandir}/man1/onnode.1.gz
-%{_includedir}/ctdb.h
+%{_includedir}/ctdb_client.h
+%{_includedir}/ctdb_protocol.h
 %{_includedir}/ctdb_private.h
 %{_libdir}/pkgconfig/ctdb.pc
 
index a46f60b40f9a760b78c18ce9ae91c16f29977022..bb8abc8b6736803efc432fb21b09d9c5da4bce88 100644 (file)
@@ -23,7 +23,7 @@
 #include "system/network.h"
 #include "system/filesys.h"
 #include "system/wait.h"
-#include "../include/ctdb.h"
+#include "../include/ctdb_client.h"
 #include "../include/ctdb_private.h"
 
 
index 275a2071534ad1695f8de58e3e042c084722ce60..39fb4edd61dbb067019b626b52b4855b3c5622c2 100644 (file)
@@ -25,7 +25,7 @@
 #include "system/network.h"
 #include "system/filesys.h"
 #include "system/wait.h"
-#include "../include/ctdb.h"
+#include "../include/ctdb_client.h"
 #include "../include/ctdb_private.h"
 #include <sys/socket.h>
 
index a7ca1a1df99aeba36437779e5872aa8622dcee2a..807bb179e0b152353a2c329354c7504616a21060 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "includes.h"
 #include "lib/events/events.h"
-#include "../include/ctdb.h"
+#include "../include/ctdb_client.h"
 #include "../include/ctdb_private.h"
 #include "system/syslog.h"
 #include "system/time.h"
index c0d5b17f151fb176c3b9e8cc4038371954e18058..ae4242f4cd969af8b90f7418d74dd877bcb32f01 100644 (file)
@@ -25,7 +25,7 @@
 #include "system/wait.h"
 #include "popt.h"
 #include "cmdline.h"
-#include "../include/ctdb.h"
+#include "../include/ctdb_client.h"
 #include "../include/ctdb_private.h"
 #include "db_wrap.h"
 #include "dlinklist.h"
index 52e5b509a0b5437438b7b11065da86e3b23cdffd..b1fb5502a1d9fcd7915e865cfa20b660c38c3008 100644 (file)
@@ -22,7 +22,7 @@
 #include "system/filesys.h"
 #include "popt.h"
 #include "cmdline.h"
-#include "ctdb.h"
+#include "ctdb_client.h"
 #include "ctdb_private.h"
 
 #include <sys/time.h>
index e698c407b45e970fbfeab4cb32910ad749eade8f..b9f650f09d3403af6588147b919a55a8e8d5cb9f 100644 (file)
@@ -26,7 +26,7 @@
 #include "system/locale.h"
 #include "popt.h"
 #include "cmdline.h"
-#include "../include/ctdb.h"
+#include "../include/ctdb_client.h"
 #include "../include/ctdb_private.h"
 #include "../common/rb_tree.h"
 #include "db_wrap.h"
index bd45287f2ce7f5c205877ac6ffe24aa65cfe6a7d..315912cc351a2e1dee3256c41bd72368fe7176cd 100644 (file)
@@ -21,7 +21,7 @@
 #include "lib/events/events.h"
 #include "system/filesys.h"
 #include "system/network.h"
-#include "../include/ctdb.h"
+#include "../include/ctdb_client.h"
 #include "../include/ctdb_private.h"
 #include "../common/rb_tree.h"
 #include "db_wrap.h"