cb7c165f5e663005e8cd059cfdd784bc3a58ae62
[metze/ctdb/wip.git] / include / ctdb_private.h
1 /* 
2    ctdb database library
3
4    Copyright (C) Andrew Tridgell  2006
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef _CTDB_PRIVATE_H
21 #define _CTDB_PRIVATE_H
22
23 #include "ctdb.h"
24 #include <sys/socket.h>
25
26 /* location of daemon socket */
27 #define CTDB_PATH       "/tmp/ctdb.socket"
28
29 /* default ctdb port number */
30 #define CTDB_PORT 4379
31
32 /* we must align packets to ensure ctdb works on all architectures (eg. sparc) */
33 #define CTDB_DS_ALIGNMENT 8
34
35
36 #define CTDB_NULL_FUNC      0xFF000001
37 #define CTDB_FETCH_FUNC     0xFF000002
38
39
40 /*
41   recovery daemon memdump reply address
42  */
43 struct rd_memdump_reply {
44         uint32_t pnn;
45         uint64_t srvid;
46 };
47
48 /*
49   description for a TAKEOVER_RUN message reply address
50  */
51 struct takeover_run_reply {
52         uint32_t pnn;
53         uint64_t srvid;
54 };
55
56 /*
57  * pid of the ctdbd daemon
58  */
59 extern pid_t ctdbd_pid;
60
61 /*
62   a tcp connection description
63  */
64 struct ctdb_tcp_connection {
65         ctdb_sock_addr src_addr;
66         ctdb_sock_addr dst_addr;
67 };
68
69 /* the wire representation for a tcp tickle array */
70 struct ctdb_tcp_wire_array {
71         uint32_t num;
72         struct ctdb_tcp_connection connections[1];
73 };      
74
75 /* the list of tcp tickles used by get/set tcp tickle list */
76 struct ctdb_control_tcp_tickle_list {
77         ctdb_sock_addr addr;
78         struct ctdb_tcp_wire_array tickles;
79 };
80
81 /*
82   array of tcp connections
83  */
84 struct ctdb_tcp_array {
85         uint32_t num;
86         struct ctdb_tcp_connection *connections;
87 };      
88
89
90 /* all tunable variables go in here */
91 struct ctdb_tunable {
92         uint32_t max_redirect_count;
93         uint32_t seqnum_interval; /* unit is ms */
94         uint32_t control_timeout;
95         uint32_t traverse_timeout;
96         uint32_t keepalive_interval;
97         uint32_t keepalive_limit;
98         uint32_t max_lacount;
99         uint32_t recover_timeout;
100         uint32_t recover_interval;
101         uint32_t election_timeout;
102         uint32_t takeover_timeout;
103         uint32_t monitor_interval;
104         uint32_t tickle_update_interval;
105         uint32_t script_timeout;
106         uint32_t script_timeout_count; /* allow dodgy scripts to hang this many times in a row before we mark the node unhealthy */
107         uint32_t script_unhealthy_on_timeout; /* obsolete */
108         uint32_t recovery_grace_period;
109         uint32_t recovery_ban_period;
110         uint32_t database_hash_size;
111         uint32_t database_max_dead;
112         uint32_t rerecovery_timeout;
113         uint32_t enable_bans;
114         uint32_t deterministic_public_ips;
115         uint32_t reclock_ping_period;
116         uint32_t no_ip_failback;
117         uint32_t verbose_memory_names;
118         uint32_t recd_ping_timeout;
119         uint32_t recd_ping_failcount;
120         uint32_t log_latency_ms;
121         uint32_t reclock_latency_ms;
122         uint32_t recovery_drop_all_ips;
123         uint32_t verify_recovery_lock;
124         uint32_t vacuum_default_interval;
125         uint32_t vacuum_max_run_time;
126         uint32_t repack_limit;
127         uint32_t vacuum_limit;
128         uint32_t vacuum_min_interval;
129         uint32_t vacuum_max_interval;
130         uint32_t max_queue_depth_drop_msg;
131         uint32_t use_status_events_for_monitoring;
132         uint32_t allow_unhealthy_db_read;
133 };
134
135 /*
136   an installed ctdb remote call
137 */
138 struct ctdb_registered_call {
139         struct ctdb_registered_call *next, *prev;
140         uint32_t id;
141         ctdb_fn_t fn;
142 };
143
144 /*
145   this address structure might need to be generalised later for some
146   transports
147 */
148 struct ctdb_address {
149         const char *address;
150         int port;
151 };
152
153 /*
154   check that a pnn is valid
155  */
156 #define ctdb_validate_pnn(ctdb, pnn) (((uint32_t)(pnn)) < (ctdb)->num_nodes)
157
158
159 /* called from the queue code when a packet comes in. Called with data==NULL
160    on error */
161 typedef void (*ctdb_queue_cb_fn_t)(uint8_t *data, size_t length,
162                                    void *private_data);
163
164 /* used for callbacks in ctdb_control requests */
165 typedef void (*ctdb_control_callback_fn_t)(struct ctdb_context *,
166                                            int32_t status, TDB_DATA data, 
167                                            const char *errormsg,
168                                            void *private_data);
169 /*
170   structure describing a connected client in the daemon
171  */
172 struct ctdb_client {
173         struct ctdb_context *ctdb;
174         int fd;
175         struct ctdb_queue *queue;
176         uint32_t client_id;
177         pid_t pid;
178         struct ctdb_tcp_list *tcp_list;
179         uint32_t db_id;
180         uint32_t num_persistent_updates;
181         struct ctdb_client_notify_list *notify;
182 };
183
184 struct ctdb_iface;
185
186 /* state associated with a public ip address */
187 struct ctdb_vnn {
188         struct ctdb_vnn *prev, *next;
189
190         struct ctdb_iface *iface;
191         const char **ifaces;
192         ctdb_sock_addr public_address;
193         uint8_t public_netmask_bits;
194
195         /* the node number that is serving this public address, if any. 
196            If no node serves this ip it is set to -1 */
197         int32_t pnn;
198
199         /* List of clients to tickle for this public address */
200         struct ctdb_tcp_array *tcp_array;
201
202         /* whether we need to update the other nodes with changes to our list
203            of connected clients */
204         bool tcp_update_needed;
205
206         /* a context to hang sending gratious arp events off */
207         TALLOC_CTX *takeover_ctx;
208
209         struct ctdb_kill_tcp *killtcp;
210 };
211
212 /*
213   state associated with one node
214 */
215 struct ctdb_node {
216         struct ctdb_context *ctdb;
217         struct ctdb_address address;
218         const char *name; /* for debug messages */
219         void *private_data; /* private to transport */
220         uint32_t pnn;
221 #define NODE_FLAGS_DISCONNECTED         0x00000001 /* node isn't connected */
222 #define NODE_FLAGS_UNHEALTHY            0x00000002 /* monitoring says node is unhealthy */
223 #define NODE_FLAGS_PERMANENTLY_DISABLED 0x00000004 /* administrator has disabled node */
224 #define NODE_FLAGS_BANNED               0x00000008 /* recovery daemon has banned the node */
225 #define NODE_FLAGS_DELETED              0x00000010 /* this node has been deleted */
226 #define NODE_FLAGS_STOPPED              0x00000020 /* this node has been stopped */
227 #define NODE_FLAGS_DISABLED             (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
228 #define NODE_FLAGS_INACTIVE             (NODE_FLAGS_DELETED|NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)
229         uint32_t flags;
230
231         /* used by the dead node monitoring */
232         uint32_t dead_count;
233         uint32_t rx_cnt;
234         uint32_t tx_cnt;
235
236         /* used to track node capabilities, is only valid/tracked inside the
237            recovery daemon.
238         */
239         uint32_t capabilities;
240
241         /* a list of controls pending to this node, so we can time them out quickly
242            if the node becomes disconnected */
243         struct daemon_control_state *pending_controls;
244
245         /* used by the recovery daemon when distributing ip addresses 
246            across the nodes.  it needs to know which public ip's can be handled
247            by each node.
248         */
249         struct ctdb_all_public_ips *known_public_ips;
250         struct ctdb_all_public_ips *available_public_ips;
251         /* used by the recovery dameon to track when a node should be banned */
252         struct ctdb_banning_state *ban_state; 
253 };
254
255 /*
256   transport specific methods
257 */
258 struct ctdb_methods {
259         int (*initialise)(struct ctdb_context *); /* initialise transport structures */ 
260         int (*start)(struct ctdb_context *); /* start the transport */
261         int (*add_node)(struct ctdb_node *); /* setup a new node */     
262         int (*connect_node)(struct ctdb_node *); /* connect to node */
263         int (*queue_pkt)(struct ctdb_node *, uint8_t *data, uint32_t length);
264         void *(*allocate_pkt)(TALLOC_CTX *mem_ctx, size_t );
265         void (*shutdown)(struct ctdb_context *); /* shutdown transport */
266         void (*restart)(struct ctdb_node *); /* stop and restart the connection */
267 };
268
269 /*
270   transport calls up to the ctdb layer
271 */
272 struct ctdb_upcalls {
273         /* recv_pkt is called when a packet comes in */
274         void (*recv_pkt)(struct ctdb_context *, uint8_t *data, uint32_t length);
275
276         /* node_dead is called when an attempt to send to a node fails */
277         void (*node_dead)(struct ctdb_node *);
278
279         /* node_connected is called when a connection to a node is established */
280         void (*node_connected)(struct ctdb_node *);
281 };
282
283 /* list of message handlers - needs to be changed to a more efficient data
284    structure so we can find a message handler given a srvid quickly */
285 struct ctdb_message_list {
286         struct ctdb_context *ctdb;
287         struct ctdb_message_list *next, *prev;
288         uint64_t srvid;
289         ctdb_message_fn_t message_handler;
290         void *message_private;
291 };
292
293 /* additional data required for the daemon mode */
294 struct ctdb_daemon_data {
295         int sd;
296         char *name;
297         struct ctdb_queue *queue;
298 };
299
300 /*
301   ctdb status information
302  */
303 struct ctdb_statistics {
304         uint32_t num_clients;
305         uint32_t frozen;
306         uint32_t recovering;
307         uint32_t client_packets_sent;
308         uint32_t client_packets_recv;
309         uint32_t node_packets_sent;
310         uint32_t node_packets_recv;
311         uint32_t keepalive_packets_sent;
312         uint32_t keepalive_packets_recv;
313         struct {
314                 uint32_t req_call;
315                 uint32_t reply_call;
316                 uint32_t req_dmaster;
317                 uint32_t reply_dmaster;
318                 uint32_t reply_error;
319                 uint32_t req_message;
320                 uint32_t req_control;
321                 uint32_t reply_control;
322         } node;
323         struct {
324                 uint32_t req_call;
325                 uint32_t req_message;
326                 uint32_t req_control;
327         } client;
328         struct {
329                 uint32_t call;
330                 uint32_t control;
331                 uint32_t traverse;
332         } timeouts;
333         struct {
334                 double ctdbd;
335                 double recd;
336         } reclock;
337         uint32_t total_calls;
338         uint32_t pending_calls;
339         uint32_t lockwait_calls;
340         uint32_t pending_lockwait_calls;
341         uint32_t childwrite_calls;
342         uint32_t pending_childwrite_calls;
343         uint32_t memory_used;
344         uint32_t __last_counter; /* hack for control_statistics_all */
345         uint32_t max_hop_count;
346         double max_call_latency;
347         double max_lockwait_latency;
348         double max_childwrite_latency;
349 };
350
351
352 #define INVALID_GENERATION 1
353 /* table that contains the mapping between a hash value and lmaster
354  */
355 struct ctdb_vnn_map {
356         uint32_t generation;
357         uint32_t size;
358         uint32_t *map;
359 };
360
361 /* 
362    a wire representation of the vnn map
363  */
364 struct ctdb_vnn_map_wire {
365         uint32_t generation;
366         uint32_t size;
367         uint32_t map[1];
368 };
369
370 /* a structure that contains the elements required for the write record
371    control
372 */
373 struct ctdb_write_record {
374         uint32_t dbid;
375         uint32_t keylen;
376         uint32_t datalen;
377         unsigned char blob[1];
378 };
379
380 enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN};
381
382 #define CTDB_MONITORING_ACTIVE          0
383 #define CTDB_MONITORING_DISABLED        1
384
385 /* The different capabilities of the ctdb daemon. */
386 #define CTDB_CAP_RECMASTER              0x00000001
387 #define CTDB_CAP_LMASTER                0x00000002
388 /* This capability is set if CTDB_LVS_PUBLIC_IP is set */
389 #define CTDB_CAP_LVS                    0x00000004
390 /* This capability is set if NATGW is enabled */
391 #define CTDB_CAP_NATGW                  0x00000008
392
393 #define NUM_DB_PRIORITIES 3
394 /* main state of the ctdb daemon */
395 struct ctdb_context {
396         struct event_context *ev;
397         struct timeval ctdbd_start_time;
398         struct timeval last_recovery_started;
399         struct timeval last_recovery_finished;
400         uint32_t recovery_mode;
401         TALLOC_CTX *tickle_update_context;
402         TALLOC_CTX *keepalive_ctx;
403         struct ctdb_tunable tunable;
404         enum ctdb_freeze_mode freeze_mode[NUM_DB_PRIORITIES+1];
405         struct ctdb_freeze_handle *freeze_handles[NUM_DB_PRIORITIES+1];
406         bool freeze_transaction_started;
407         uint32_t freeze_transaction_id;
408         struct ctdb_address address;
409         const char *name;
410         const char *db_directory;
411         const char *db_directory_persistent;
412         const char *db_directory_state;
413         struct tdb_wrap *db_persistent_health;
414         uint32_t db_persistent_startup_generation;
415         uint64_t db_persistent_check_errors;
416         uint64_t max_persistent_check_errors;
417         const char *transport;
418         char *recovery_lock_file;
419         int recovery_lock_fd;
420         uint32_t pnn; /* our own pnn */
421         uint32_t num_nodes;
422         uint32_t num_connected;
423         unsigned flags;
424         uint32_t capabilities;
425         struct idr_context *idr;
426         uint16_t idr_cnt;
427         struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
428         struct ctdb_vnn *vnn; /* list of public ip addresses and interfaces */
429         struct ctdb_vnn *single_ip_vnn; /* a structure for the single ip */
430         struct ctdb_iface *ifaces; /* list of local interfaces */
431         char *err_msg;
432         const struct ctdb_methods *methods; /* transport methods */
433         const struct ctdb_upcalls *upcalls; /* transport upcalls */
434         void *private_data; /* private to transport */
435         struct ctdb_db_context *db_list;
436         struct ctdb_message_list *message_list;
437         struct ctdb_daemon_data daemon;
438         struct ctdb_statistics statistics;
439         struct ctdb_vnn_map *vnn_map;
440         uint32_t num_clients;
441         uint32_t recovery_master;
442         struct ctdb_call_state *pending_calls;
443         struct ctdb_client_ip *client_ip_list;
444         bool do_checkpublicip;
445         struct trbt_tree *server_ids;   
446         const char *event_script_dir;
447         const char *notification_script;
448         const char *default_public_interface;
449         pid_t ctdbd_pid;
450         pid_t recoverd_pid;
451         pid_t syslogd_pid;
452         bool done_startup;
453         const char *node_ip;
454         struct ctdb_monitor_state *monitor;
455         struct ctdb_log_state *log;
456         int start_as_disabled;
457         int start_as_stopped;
458         bool valgrinding;
459         uint32_t event_script_timeouts; /* counting how many consecutive times an eventscript has timedout */
460         uint32_t *recd_ping_count;
461         TALLOC_CTX *release_ips_ctx; /* a context used to automatically drop all IPs if we fail to recover the node */
462
463         TALLOC_CTX *event_script_ctx;
464
465         struct ctdb_event_script_state *current_monitor;
466         struct ctdb_scripts_wire *last_status[CTDB_EVENT_MAX];
467
468         TALLOC_CTX *banning_ctx;
469
470         /* mapping from pid to ctdb_client * */
471         struct ctdb_client_pid_list *client_pids;
472
473         /* used in the recovery daemon to remember the ip allocation */
474         struct trbt_tree *ip_tree;
475 };
476
477 struct ctdb_db_context {
478         struct ctdb_db_context *next, *prev;
479         struct ctdb_context *ctdb;
480         uint32_t db_id;
481         uint32_t priority;
482         bool persistent;
483         const char *db_name;
484         const char *db_path;
485         struct tdb_wrap *ltdb;
486         struct ctdb_registered_call *calls; /* list of registered calls */
487         uint32_t seqnum;
488         struct timed_event *seqnum_update;
489         struct ctdb_traverse_local_handle *traverse;
490         bool transaction_active;
491         struct ctdb_vacuum_handle *vacuum_handle;
492         char *unhealthy_reason;
493 };
494
495
496 #define CTDB_NO_MEMORY(ctdb, p) do { if (!(p)) { \
497           DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
498           ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
499           return -1; }} while (0)
500
501 #define CTDB_NO_MEMORY_VOID(ctdb, p) do { if (!(p)) { \
502           DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
503           ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
504           return; }} while (0)
505
506 #define CTDB_NO_MEMORY_NULL(ctdb, p) do { if (!(p)) { \
507           DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
508           ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
509           return NULL; }} while (0)
510
511 #define CTDB_NO_MEMORY_FATAL(ctdb, p) do { if (!(p)) { \
512           DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
513           ctdb_fatal(ctdb, "Out of memory in " __location__ ); \
514           }} while (0)
515
516 /*
517   the extended header for records in the ltdb
518 */
519 struct ctdb_ltdb_header {
520         uint64_t rsn;
521         uint32_t dmaster;
522         uint32_t laccessor;
523         uint32_t lacount;
524 };
525
526 enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0, 
527                     CTDB_CONTROL_STATISTICS              = 1, 
528                     /* #2 removed */
529                     CTDB_CONTROL_PING                    = 3,
530                     CTDB_CONTROL_GETDBPATH               = 4,
531                     CTDB_CONTROL_GETVNNMAP               = 5,
532                     CTDB_CONTROL_SETVNNMAP               = 6,
533                     CTDB_CONTROL_GET_DEBUG               = 7,
534                     CTDB_CONTROL_SET_DEBUG               = 8,
535                     CTDB_CONTROL_GET_DBMAP               = 9,
536                     CTDB_CONTROL_GET_NODEMAPv4           = 10, /* obsolete */
537                     CTDB_CONTROL_SET_DMASTER             = 11,
538                     /* #12 removed */
539                     CTDB_CONTROL_PULL_DB                 = 13,
540                     CTDB_CONTROL_PUSH_DB                 = 14,
541                     CTDB_CONTROL_GET_RECMODE             = 15,
542                     CTDB_CONTROL_SET_RECMODE             = 16,
543                     CTDB_CONTROL_STATISTICS_RESET        = 17,
544                     CTDB_CONTROL_DB_ATTACH               = 18,
545                     CTDB_CONTROL_SET_CALL                = 19,
546                     CTDB_CONTROL_TRAVERSE_START          = 20,
547                     CTDB_CONTROL_TRAVERSE_ALL            = 21,
548                     CTDB_CONTROL_TRAVERSE_DATA           = 22,
549                     CTDB_CONTROL_REGISTER_SRVID          = 23,
550                     CTDB_CONTROL_DEREGISTER_SRVID        = 24,
551                     CTDB_CONTROL_GET_DBNAME              = 25,
552                     CTDB_CONTROL_ENABLE_SEQNUM           = 26,
553                     CTDB_CONTROL_UPDATE_SEQNUM           = 27,
554                     /* #28 removed */
555                     CTDB_CONTROL_DUMP_MEMORY             = 29,
556                     CTDB_CONTROL_GET_PID                 = 30,
557                     CTDB_CONTROL_GET_RECMASTER           = 31,
558                     CTDB_CONTROL_SET_RECMASTER           = 32,
559                     CTDB_CONTROL_FREEZE                  = 33,
560                     CTDB_CONTROL_THAW                    = 34,
561                     CTDB_CONTROL_GET_PNN                 = 35,
562                     CTDB_CONTROL_SHUTDOWN                = 36,
563                     CTDB_CONTROL_GET_MONMODE             = 37,
564                     /* #38 removed */
565                     /* #39 removed */
566                     /* #40 removed */
567                     /* #41 removed */
568                     CTDB_CONTROL_TAKEOVER_IPv4           = 42, /* obsolete */
569                     CTDB_CONTROL_RELEASE_IPv4            = 43, /* obsolete */
570                     CTDB_CONTROL_TCP_CLIENT              = 44,
571                     CTDB_CONTROL_TCP_ADD                 = 45,
572                     CTDB_CONTROL_TCP_REMOVE              = 46,
573                     CTDB_CONTROL_STARTUP                 = 47,
574                     CTDB_CONTROL_SET_TUNABLE             = 48,
575                     CTDB_CONTROL_GET_TUNABLE             = 49,
576                     CTDB_CONTROL_LIST_TUNABLES           = 50,
577                     CTDB_CONTROL_GET_PUBLIC_IPSv4        = 51, /* obsolete */
578                     CTDB_CONTROL_MODIFY_FLAGS            = 52,
579                     CTDB_CONTROL_GET_ALL_TUNABLES        = 53,
580                     CTDB_CONTROL_KILL_TCP                = 54,
581                     CTDB_CONTROL_GET_TCP_TICKLE_LIST     = 55,
582                     CTDB_CONTROL_SET_TCP_TICKLE_LIST     = 56,
583                     CTDB_CONTROL_REGISTER_SERVER_ID      = 57,
584                     CTDB_CONTROL_UNREGISTER_SERVER_ID    = 58,
585                     CTDB_CONTROL_CHECK_SERVER_ID         = 59,
586                     CTDB_CONTROL_GET_SERVER_ID_LIST      = 60,
587                     CTDB_CONTROL_DB_ATTACH_PERSISTENT    = 61,
588                     CTDB_CONTROL_PERSISTENT_STORE        = 62,
589                     CTDB_CONTROL_UPDATE_RECORD           = 63,
590                     CTDB_CONTROL_SEND_GRATIOUS_ARP       = 64,
591                     CTDB_CONTROL_TRANSACTION_START       = 65,
592                     CTDB_CONTROL_TRANSACTION_COMMIT      = 66,
593                     CTDB_CONTROL_WIPE_DATABASE           = 67,
594                     /* #68 removed */
595                     CTDB_CONTROL_UPTIME                  = 69,
596                     CTDB_CONTROL_START_RECOVERY          = 70,
597                     CTDB_CONTROL_END_RECOVERY            = 71,
598                     CTDB_CONTROL_RELOAD_NODES_FILE       = 72,
599                     /* #73 removed */
600                     CTDB_CONTROL_TRY_DELETE_RECORDS      = 74,
601                     CTDB_CONTROL_ENABLE_MONITOR          = 75,
602                     CTDB_CONTROL_DISABLE_MONITOR         = 76,
603                     CTDB_CONTROL_ADD_PUBLIC_IP           = 77,
604                     CTDB_CONTROL_DEL_PUBLIC_IP           = 78,
605                     CTDB_CONTROL_RUN_EVENTSCRIPTS        = 79,
606                     CTDB_CONTROL_GET_CAPABILITIES        = 80,
607                     CTDB_CONTROL_START_PERSISTENT_UPDATE = 81,
608                     CTDB_CONTROL_CANCEL_PERSISTENT_UPDATE= 82,
609                     CTDB_CONTROL_TRANS2_COMMIT           = 83,
610                     CTDB_CONTROL_TRANS2_FINISHED         = 84,
611                     CTDB_CONTROL_TRANS2_ERROR            = 85,
612                     CTDB_CONTROL_TRANS2_COMMIT_RETRY     = 86,
613                     CTDB_CONTROL_RECD_PING               = 87,
614                     CTDB_CONTROL_RELEASE_IP              = 88,
615                     CTDB_CONTROL_TAKEOVER_IP             = 89,
616                     CTDB_CONTROL_GET_PUBLIC_IPS          = 90,
617                     CTDB_CONTROL_GET_NODEMAP             = 91,
618                     CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS = 96,
619                     CTDB_CONTROL_TRAVERSE_KILL           = 97,
620                     CTDB_CONTROL_RECD_RECLOCK_LATENCY    = 98,
621                     CTDB_CONTROL_GET_RECLOCK_FILE        = 99,
622                     CTDB_CONTROL_SET_RECLOCK_FILE        = 100,
623                     CTDB_CONTROL_STOP_NODE               = 101,
624                     CTDB_CONTROL_CONTINUE_NODE           = 102,
625                     CTDB_CONTROL_SET_NATGWSTATE          = 103,
626                     CTDB_CONTROL_SET_LMASTERROLE         = 104,
627                     CTDB_CONTROL_SET_RECMASTERROLE       = 105,
628                     CTDB_CONTROL_ENABLE_SCRIPT           = 107,
629                     CTDB_CONTROL_DISABLE_SCRIPT          = 108,
630                     CTDB_CONTROL_SET_BAN_STATE           = 109,
631                     CTDB_CONTROL_GET_BAN_STATE           = 110,
632                     CTDB_CONTROL_SET_DB_PRIORITY         = 111,
633                     CTDB_CONTROL_GET_DB_PRIORITY         = 112,
634                     CTDB_CONTROL_TRANSACTION_CANCEL      = 113,
635                     CTDB_CONTROL_REGISTER_NOTIFY         = 114,
636                     CTDB_CONTROL_DEREGISTER_NOTIFY       = 115,
637                     CTDB_CONTROL_TRANS2_ACTIVE           = 116,
638                     CTDB_CONTROL_GET_LOG                 = 117,
639                     CTDB_CONTROL_CLEAR_LOG               = 118,
640                     CTDB_CONTROL_TRANS3_COMMIT           = 119,
641                     CTDB_CONTROL_GET_DB_SEQNUM           = 120,
642                     CTDB_CONTROL_DB_SET_HEALTHY          = 121,
643                     CTDB_CONTROL_DB_GET_HEALTH           = 122,
644                     CTDB_CONTROL_GET_PUBLIC_IP_INFO      = 123,
645                     CTDB_CONTROL_GET_IFACES              = 124,
646                     CTDB_CONTROL_SET_IFACE_LINK_STATE    = 125,
647 };      
648
649 /*
650   structure passed in set_call control
651  */
652 struct ctdb_control_set_call {
653         uint32_t db_id;
654         ctdb_fn_t fn;
655         uint32_t id;
656 };
657
658 /*
659   struct for kill_tcp control
660  */
661 struct ctdb_control_killtcp {
662         ctdb_sock_addr src_addr;
663         ctdb_sock_addr dst_addr;
664 };
665
666 /*
667   struct holding a ctdb_sock_addr and an interface name,
668   used to add/remove public addresses
669  */
670 struct ctdb_control_ip_iface {
671         ctdb_sock_addr addr;
672         uint32_t mask;
673         uint32_t len;
674         char iface[1];
675 };
676
677 /*
678   struct holding a ctdb_sock_addr and an interface name,
679   used for send_gratious_arp
680  */
681 struct ctdb_control_gratious_arp {
682         ctdb_sock_addr addr;
683         uint32_t mask;
684         uint32_t len;
685         char iface[1];
686 };
687
688 /*
689   struct for tcp_add and tcp_remove controls
690  */
691 struct ctdb_control_tcp_vnn {
692         ctdb_sock_addr src;
693         ctdb_sock_addr dest;
694 };
695
696 /*
697   persistent store control - update this record on all other nodes
698  */
699 struct ctdb_control_persistent_store {
700         uint32_t db_id;
701         uint32_t len;
702         uint8_t  data[1];
703 };
704
705 /*
706   structure used for CTDB_SRVID_NODE_FLAGS_CHANGED
707  */
708 struct ctdb_node_flag_change {
709         uint32_t pnn;
710         uint32_t new_flags;
711         uint32_t old_flags;
712 };
713
714 /*
715   struct for admin setting a ban
716  */
717 struct ctdb_ban_info {
718         uint32_t pnn;
719         uint32_t ban_time;
720 };
721
722 enum call_state {CTDB_CALL_WAIT, CTDB_CALL_DONE, CTDB_CALL_ERROR};
723
724 #define CTDB_LMASTER_ANY        0xffffffff
725
726 /*
727   state of a in-progress ctdb call
728 */
729 struct ctdb_call_state {
730         struct ctdb_call_state *next, *prev;
731         enum call_state state;
732         uint32_t reqid;
733         struct ctdb_req_call *c;
734         struct ctdb_db_context *ctdb_db;
735         const char *errmsg;
736         struct ctdb_call *call;
737         uint32_t generation;
738         struct {
739                 void (*fn)(struct ctdb_call_state *);
740                 void *private_data;
741         } async;
742 };
743
744
745 /* used for fetch_lock */
746 struct ctdb_fetch_handle {
747         struct ctdb_db_context *ctdb_db;
748         TDB_DATA key;
749         TDB_DATA *data;
750         struct ctdb_ltdb_header header;
751 };
752
753 /*
754   operation IDs
755 */
756 enum ctdb_operation {
757         CTDB_REQ_CALL           = 0,
758         CTDB_REPLY_CALL         = 1,
759         CTDB_REQ_DMASTER        = 2,
760         CTDB_REPLY_DMASTER      = 3,
761         CTDB_REPLY_ERROR        = 4,
762         CTDB_REQ_MESSAGE        = 5,
763         /* #6 removed */
764         CTDB_REQ_CONTROL        = 7,
765         CTDB_REPLY_CONTROL      = 8,
766         CTDB_REQ_KEEPALIVE      = 9,
767 };
768
769 #define CTDB_MAGIC 0x43544442 /* CTDB */
770 #define CTDB_VERSION 1
771
772 /*
773   packet structures
774 */
775 struct ctdb_req_header {
776         uint32_t length;
777         uint32_t ctdb_magic;
778         uint32_t ctdb_version;
779         uint32_t generation;
780         uint32_t operation;
781         uint32_t destnode;
782         uint32_t srcnode;
783         uint32_t reqid;
784 };
785
786 struct ctdb_req_call {
787         struct ctdb_req_header hdr;
788         uint32_t flags;
789         uint32_t db_id;
790         uint32_t callid;
791         uint32_t hopcount;
792         uint32_t keylen;
793         uint32_t calldatalen;
794         uint8_t data[1]; /* key[] followed by calldata[] */
795 };
796
797 struct ctdb_reply_call {
798         struct ctdb_req_header hdr;
799         uint32_t status;
800         uint32_t datalen;
801         uint8_t  data[1];
802 };
803
804 struct ctdb_reply_error {
805         struct ctdb_req_header hdr;
806         uint32_t status;
807         uint32_t msglen;
808         uint8_t  msg[1];
809 };
810
811 struct ctdb_req_dmaster {
812         struct ctdb_req_header hdr;
813         uint32_t db_id;
814         uint64_t rsn;
815         uint32_t dmaster;
816         uint32_t keylen;
817         uint32_t datalen;
818         uint8_t  data[1];
819 };
820
821 struct ctdb_reply_dmaster {
822         struct ctdb_req_header hdr;
823         uint32_t db_id;
824         uint64_t rsn;
825         uint32_t keylen;
826         uint32_t datalen;
827         uint8_t  data[1];
828 };
829
830 struct ctdb_req_message {
831         struct ctdb_req_header hdr;
832         uint64_t srvid;
833         uint32_t datalen;
834         uint8_t data[1];
835 };
836
837 struct ctdb_req_getdbpath {
838         struct ctdb_req_header hdr;
839         uint32_t db_id;
840 };
841
842 struct ctdb_reply_getdbpath {
843         struct ctdb_req_header hdr;
844         uint32_t datalen;
845         uint8_t data[1];
846 };
847
848 struct ctdb_req_control {
849         struct ctdb_req_header hdr;
850         uint32_t opcode;
851         uint64_t srvid;
852         uint32_t client_id;
853 #define CTDB_CTRL_FLAG_NOREPLY   1
854 #define CTDB_CTRL_FLAG_OPCODE_SPECIFIC   0xFFFF0000
855         uint32_t flags;
856         uint32_t datalen;
857         uint8_t data[1];
858 };
859
860 struct ctdb_reply_control {
861         struct ctdb_req_header hdr;
862         int32_t  status;
863         uint32_t datalen;
864         uint32_t errorlen;
865         uint8_t data[1];
866 };
867
868 struct ctdb_req_keepalive {
869         struct ctdb_req_header hdr;
870 };
871
872
873 /* types of failures possible from TRANS2_COMMIT */
874 enum ctdb_trans2_commit_error {
875         CTDB_TRANS2_COMMIT_SUCCESS=0, /* all nodes committed successfully */
876         CTDB_TRANS2_COMMIT_TIMEOUT=1, /* at least one node timed out */
877         CTDB_TRANS2_COMMIT_ALLFAIL=2, /* all nodes failed the commit */
878         CTDB_TRANS2_COMMIT_SOMEFAIL=3 /* some nodes failed the commit, some allowed it */
879 };
880
881 /* internal prototypes */
882 void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
883 void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);
884 bool ctdb_same_address(struct ctdb_address *a1, struct ctdb_address *a2);
885 int ctdb_parse_address(struct ctdb_context *ctdb,
886                        TALLOC_CTX *mem_ctx, const char *str,
887                        struct ctdb_address *address);
888 bool ctdb_same_ip(const ctdb_sock_addr *ip1, const ctdb_sock_addr *ip2);
889 bool ctdb_same_sockaddr(const ctdb_sock_addr *ip1, const ctdb_sock_addr *ip2);
890 uint32_t ctdb_hash(const TDB_DATA *key);
891 uint32_t ctdb_hash_string(const char *str);
892 void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
893 void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
894 void ctdb_request_message(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
895 void ctdb_reply_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
896 void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
897 void ctdb_reply_error(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
898
899 uint32_t ctdb_lmaster(struct ctdb_context *ctdb, const TDB_DATA *key);
900 int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db, 
901                     TDB_DATA key, struct ctdb_ltdb_header *header, 
902                     TALLOC_CTX *mem_ctx, TDB_DATA *data);
903 int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key, 
904                     struct ctdb_ltdb_header *header, TDB_DATA data);
905 int32_t ctdb_control_start_persistent_update(struct ctdb_context *ctdb, 
906                         struct ctdb_req_control *c,
907                         TDB_DATA recdata);
908 int32_t ctdb_control_cancel_persistent_update(struct ctdb_context *ctdb, 
909                         struct ctdb_req_control *c,
910                         TDB_DATA recdata);
911 void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
912 void ctdb_queue_packet_opcode(struct ctdb_context *ctdb, struct ctdb_req_header *hdr, unsigned opcode);
913 int ctdb_ltdb_lock_requeue(struct ctdb_db_context *ctdb_db, 
914                            TDB_DATA key, struct ctdb_req_header *hdr,
915                            void (*recv_pkt)(void *, struct ctdb_req_header *),
916                            void *recv_context, bool ignore_generation);
917 int ctdb_ltdb_lock_fetch_requeue(struct ctdb_db_context *ctdb_db, 
918                                  TDB_DATA key, struct ctdb_ltdb_header *header, 
919                                  struct ctdb_req_header *hdr, TDB_DATA *data,
920                                  void (*recv_pkt)(void *, struct ctdb_req_header *),
921                                  void *recv_context, bool ignore_generation);
922 void ctdb_input_pkt(struct ctdb_context *ctdb, struct ctdb_req_header *);
923
924 struct ctdb_call_state *ctdb_call_local_send(struct ctdb_db_context *ctdb_db, 
925                                              struct ctdb_call *call,
926                                              struct ctdb_ltdb_header *header,
927                                              TDB_DATA *data);
928
929
930 int ctdbd_start(struct ctdb_context *ctdb);
931 struct ctdb_call_state *ctdbd_call_send(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
932 int ctdbd_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
933
934 /*
935   queue a packet for sending
936 */
937 int ctdb_queue_send(struct ctdb_queue *queue, uint8_t *data, uint32_t length);
938
939 /*
940   setup the fd used by the queue
941  */
942 int ctdb_queue_set_fd(struct ctdb_queue *queue, int fd);
943
944 /*
945   setup a packet queue on a socket
946  */
947 struct ctdb_queue *ctdb_queue_setup(struct ctdb_context *ctdb,
948                                     TALLOC_CTX *mem_ctx, int fd, int alignment,
949                                     
950                                     ctdb_queue_cb_fn_t callback,
951                                     void *private_data);
952
953 /*
954   allocate a packet for use in client<->daemon communication
955  */
956 struct ctdb_req_header *_ctdbd_allocate_pkt(struct ctdb_context *ctdb,
957                                             TALLOC_CTX *mem_ctx, 
958                                             enum ctdb_operation operation, 
959                                             size_t length, size_t slength,
960                                             const char *type);
961 #define ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, type) \
962         (type *)_ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, sizeof(type), #type)
963
964 struct ctdb_req_header *_ctdb_transport_allocate(struct ctdb_context *ctdb,
965                                                  TALLOC_CTX *mem_ctx, 
966                                                  enum ctdb_operation operation, 
967                                                  size_t length, size_t slength,
968                                                  const char *type);
969 #define ctdb_transport_allocate(ctdb, mem_ctx, operation, length, type) \
970         (type *)_ctdb_transport_allocate(ctdb, mem_ctx, operation, length, sizeof(type), #type)
971
972 int ctdb_queue_length(struct ctdb_queue *queue);
973
974 /*
975   lock a record in the ltdb, given a key
976  */
977 int ctdb_ltdb_lock(struct ctdb_db_context *ctdb_db, TDB_DATA key);
978
979 /*
980   unlock a record in the ltdb, given a key
981  */
982 int ctdb_ltdb_unlock(struct ctdb_db_context *ctdb_db, TDB_DATA key);
983
984
985 /*
986   make a ctdb call to the local daemon - async send. Called from client context.
987
988   This constructs a ctdb_call request and queues it for processing. 
989   This call never blocks.
990 */
991 struct ctdb_call_state *ctdb_client_call_send(struct ctdb_db_context *ctdb_db, 
992                                               struct ctdb_call *call);
993
994 /*
995   make a recv call to the local ctdb daemon - called from client context
996
997   This is called when the program wants to wait for a ctdb_call to complete and get the 
998   results. This call will block unless the call has already completed.
999 */
1000 int ctdb_client_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
1001
1002 int ctdb_daemon_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid, 
1003                              ctdb_message_fn_t handler,
1004                              void *private_data);
1005
1006 int ctdb_client_send_message(struct ctdb_context *ctdb, uint32_t vnn,
1007                              uint64_t srvid, TDB_DATA data);
1008
1009 /*
1010   send a ctdb message
1011 */
1012 int ctdb_daemon_send_message(struct ctdb_context *ctdb, uint32_t pnn,
1013                              uint64_t srvid, TDB_DATA data);
1014
1015
1016 struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
1017                                       TDB_DATA key,
1018                                       void (*callback)(void *), void *private_data);
1019
1020 struct ctdb_call_state *ctdb_daemon_call_send(struct ctdb_db_context *ctdb_db, 
1021                                               struct ctdb_call *call);
1022
1023 int ctdb_daemon_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
1024
1025 struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctdb_db, 
1026                                                      struct ctdb_call *call, 
1027                                                      struct ctdb_ltdb_header *header);
1028
1029 int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
1030                     struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx, TDB_DATA *data,
1031                     uint32_t caller);
1032
1033 #define ctdb_reqid_find(ctdb, reqid, type)      (type *)_ctdb_reqid_find(ctdb, reqid, #type, __location__)
1034
1035 void ctdb_recv_raw_pkt(void *p, uint8_t *data, uint32_t length);
1036
1037 int ctdb_socket_connect(struct ctdb_context *ctdb);
1038
1039 void ctdb_latency(struct ctdb_db_context *ctdb_db, const char *name, double *latency, struct timeval t);
1040 void ctdb_reclock_latency(struct ctdb_context *ctdb, const char *name, double *latency, double l);
1041
1042 uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state);
1043 void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location);
1044 void ctdb_reqid_remove(struct ctdb_context *ctdb, uint32_t reqid);
1045
1046 void ctdb_request_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
1047 void ctdb_reply_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
1048
1049 int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode,
1050                              uint64_t srvid, uint32_t opcode, uint32_t client_id, uint32_t flags,
1051                              TDB_DATA data,
1052                              ctdb_control_callback_fn_t callback,
1053                              void *private_data);
1054
1055 int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata, 
1056                                TDB_DATA *outdata, uint64_t tdb_flags, bool persistent);
1057
1058 int ctdb_daemon_set_call(struct ctdb_context *ctdb, uint32_t db_id,
1059                          ctdb_fn_t fn, int id);
1060
1061 int ctdb_control(struct ctdb_context *ctdb, uint32_t destnode, uint64_t srvid, 
1062                  uint32_t opcode, uint32_t flags, TDB_DATA data, 
1063                  TALLOC_CTX *mem_ctx, TDB_DATA *outdata, int32_t *status,
1064                  struct timeval *timeout, char **errormsg);
1065 int ctdb_control_recv(struct ctdb_context *ctdb, 
1066                 struct ctdb_client_control_state *state, 
1067                 TALLOC_CTX *mem_ctx,
1068                 TDB_DATA *outdata, int32_t *status, char **errormsg);
1069
1070 struct ctdb_client_control_state *
1071 ctdb_control_send(struct ctdb_context *ctdb, 
1072                 uint32_t destnode, uint64_t srvid, 
1073                 uint32_t opcode, uint32_t flags, TDB_DATA data, 
1074                 TALLOC_CTX *mem_ctx,
1075                 struct timeval *timeout,
1076                 char **errormsg);
1077
1078
1079
1080
1081 #define CHECK_CONTROL_DATA_SIZE(size) do { \
1082  if (indata.dsize != size) { \
1083          DEBUG(0,(__location__ " Invalid data size in opcode %u. Got %u expected %u\n", \
1084                   opcode, (unsigned)indata.dsize, (unsigned)size));     \
1085          return -1; \
1086  } \
1087  } while (0)
1088
1089 int ctdb_control_getvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
1090 int ctdb_control_setvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
1091 int ctdb_control_getdbmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
1092 int ctdb_control_getnodemapv4(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
1093 int ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
1094 int ctdb_control_writerecord(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
1095
1096
1097 struct ctdb_traverse_start {
1098         uint32_t db_id;
1099         uint32_t reqid;
1100         uint64_t srvid;
1101 };
1102
1103 /*
1104   structure used to pass record data between the child and parent
1105  */
1106 struct ctdb_rec_data {
1107         uint32_t length;
1108         uint32_t reqid;
1109         uint32_t keylen;
1110         uint32_t datalen;
1111         uint8_t  data[1];
1112 };
1113                                    
1114
1115 /* structure used for pulldb control */
1116 struct ctdb_control_pulldb {
1117         uint32_t db_id;
1118         uint32_t lmaster;
1119 };
1120
1121 /* structure used for sending lists of records */
1122 struct ctdb_marshall_buffer {
1123         uint32_t db_id;
1124         uint32_t count;
1125         uint8_t data[1];
1126 };
1127
1128 /* set dmaster control structure */
1129 struct ctdb_control_set_dmaster {
1130         uint32_t db_id;
1131         uint32_t dmaster;
1132 };
1133
1134 /*
1135   structure for setting a tunable
1136  */
1137 struct ctdb_control_set_tunable {
1138         uint32_t value;
1139         uint32_t length;
1140         uint8_t  name[1];
1141 };
1142
1143 /*
1144   structure for getting a tunable
1145  */
1146 struct ctdb_control_get_tunable {
1147         uint32_t length;
1148         uint8_t  name[1];
1149 };
1150
1151 /*
1152   structure for listing tunables
1153  */
1154 struct ctdb_control_list_tunable {
1155         uint32_t length;
1156         /* returns a : separated list of tunable names */
1157         uint8_t  data[1];
1158 };
1159
1160
1161 /* table that contains a list of all nodes a ctdb knows about and their 
1162    status
1163  */
1164 struct ctdb_node_and_flags {
1165         uint32_t pnn;
1166         uint32_t flags;
1167         ctdb_sock_addr addr;
1168 };
1169
1170 struct ctdb_node_map {
1171         uint32_t num;
1172         struct ctdb_node_and_flags nodes[1];
1173 };
1174
1175 struct ctdb_node_and_flagsv4 {
1176         uint32_t pnn;
1177         uint32_t flags;
1178         struct sockaddr_in sin;
1179 };
1180
1181 struct ctdb_node_mapv4 {
1182         uint32_t num;
1183         struct ctdb_node_and_flagsv4 nodes[1];
1184 };
1185
1186 struct ctdb_control_wipe_database {
1187         uint32_t db_id;
1188         uint32_t transaction_id;
1189 };
1190
1191 /*
1192   state of a in-progress ctdb call in client
1193 */
1194 struct ctdb_client_call_state {
1195         enum call_state state;
1196         uint32_t reqid;
1197         struct ctdb_db_context *ctdb_db;
1198         struct ctdb_call *call;
1199         struct {
1200                 void (*fn)(struct ctdb_client_call_state *);
1201                 void *private_data;
1202         } async;
1203 };
1204
1205
1206 int32_t ctdb_control_traverse_start(struct ctdb_context *ctdb, TDB_DATA indata, 
1207                                     TDB_DATA *outdata, uint32_t srcnode, uint32_t client_id);
1208 int32_t ctdb_control_traverse_all(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
1209 int32_t ctdb_control_traverse_data(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
1210 int32_t ctdb_control_traverse_kill(struct ctdb_context *ctdb, TDB_DATA indata, 
1211                                     TDB_DATA *outdata, uint32_t srcnode);
1212
1213 int ctdb_dispatch_message(struct ctdb_context *ctdb, uint64_t srvid, TDB_DATA data);
1214
1215 int daemon_register_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid);
1216 int ctdb_deregister_message_handler(struct ctdb_context *ctdb, uint64_t srvid, void *private_data);
1217 int daemon_deregister_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid);
1218
1219 int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id);
1220 int32_t ctdb_ltdb_update_seqnum(struct ctdb_context *ctdb, uint32_t db_id, uint32_t srcnode);
1221
1222 struct ctdb_rec_data *ctdb_marshall_record(TALLOC_CTX *mem_ctx, uint32_t reqid, 
1223                                            TDB_DATA key, struct ctdb_ltdb_header *, TDB_DATA data);
1224
1225 struct ctdb_rec_data *ctdb_marshall_loop_next(struct ctdb_marshall_buffer *m, struct ctdb_rec_data *r,
1226                                               uint32_t *reqid,
1227                                               struct ctdb_ltdb_header *header,
1228                                               TDB_DATA *key, TDB_DATA *data);
1229
1230 int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
1231 int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata);
1232 int32_t ctdb_control_set_dmaster(struct ctdb_context *ctdb, TDB_DATA indata);
1233
1234 int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb, 
1235                                  struct ctdb_req_control *c,
1236                                  TDB_DATA indata, bool *async_reply,
1237                                  const char **errormsg);
1238 void ctdb_request_control_reply(struct ctdb_context *ctdb, struct ctdb_req_control *c,
1239                                 TDB_DATA *outdata, int32_t status, const char *errormsg);
1240
1241 int32_t ctdb_control_freeze(struct ctdb_context *ctdb, struct ctdb_req_control *c, bool *async_reply);
1242 int32_t ctdb_control_thaw(struct ctdb_context *ctdb, uint32_t priority);
1243
1244 int ctdb_start_recoverd(struct ctdb_context *ctdb);
1245 void ctdb_stop_recoverd(struct ctdb_context *ctdb);
1246
1247 uint32_t ctdb_get_num_active_nodes(struct ctdb_context *ctdb);
1248
1249 void ctdb_disable_monitoring(struct ctdb_context *ctdb);
1250 void ctdb_enable_monitoring(struct ctdb_context *ctdb);
1251 void ctdb_stop_monitoring(struct ctdb_context *ctdb);
1252 void ctdb_start_monitoring(struct ctdb_context *ctdb);
1253 void ctdb_start_tcp_tickle_update(struct ctdb_context *ctdb);
1254 void ctdb_send_keepalive(struct ctdb_context *ctdb, uint32_t destnode);
1255 void ctdb_start_keepalive(struct ctdb_context *ctdb);
1256 void ctdb_stop_keepalive(struct ctdb_context *ctdb);
1257 int32_t ctdb_run_eventscripts(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA data, bool *async_reply);
1258
1259
1260 void ctdb_daemon_cancel_controls(struct ctdb_context *ctdb, struct ctdb_node *node);
1261 void ctdb_call_resend_all(struct ctdb_context *ctdb);
1262 void ctdb_node_dead(struct ctdb_node *node);
1263 void ctdb_node_connected(struct ctdb_node *node);
1264 bool ctdb_blocking_freeze(struct ctdb_context *ctdb);
1265 void ctdb_high_priority(struct ctdb_context *ctdb);
1266 void ctdb_reduce_priority(struct ctdb_context *ctdb);
1267 int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb, 
1268                                  struct ctdb_req_control *c,
1269                                  TDB_DATA indata, 
1270                                  bool *async_reply);
1271 int32_t ctdb_control_takeover_ipv4(struct ctdb_context *ctdb, 
1272                                  struct ctdb_req_control *c,
1273                                  TDB_DATA indata, 
1274                                  bool *async_reply);
1275 int32_t ctdb_control_release_ip(struct ctdb_context *ctdb, 
1276                                  struct ctdb_req_control *c,
1277                                  TDB_DATA indata, 
1278                                  bool *async_reply);
1279 int32_t ctdb_control_release_ipv4(struct ctdb_context *ctdb, 
1280                                  struct ctdb_req_control *c,
1281                                  TDB_DATA indata, 
1282                                  bool *async_reply);
1283 int32_t ctdb_control_start_recovery(struct ctdb_context *ctdb, 
1284                                  struct ctdb_req_control *c,
1285                                  bool *async_reply);
1286 int32_t ctdb_control_end_recovery(struct ctdb_context *ctdb, 
1287                                  struct ctdb_req_control *c,
1288                                  bool *async_reply);
1289
1290 struct ctdb_public_ipv4 {
1291         uint32_t pnn;
1292         struct sockaddr_in sin;
1293 };
1294
1295 struct ctdb_public_ip {
1296         uint32_t pnn;
1297         ctdb_sock_addr addr;
1298 };
1299 int ctdb_ctrl_takeover_ip(struct ctdb_context *ctdb, struct timeval timeout, 
1300                           uint32_t destnode, struct ctdb_public_ip *ip);
1301 int ctdb_ctrl_release_ip(struct ctdb_context *ctdb, struct timeval timeout, 
1302                          uint32_t destnode, struct ctdb_public_ip *ip);
1303
1304 struct ctdb_all_public_ipsv4 {
1305         uint32_t num;
1306         struct ctdb_public_ipv4 ips[1];
1307 };
1308
1309 struct ctdb_all_public_ips {
1310         uint32_t num;
1311         struct ctdb_public_ip ips[1];
1312 };
1313 int32_t ctdb_control_get_public_ipsv4(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA *outdata);
1314 int32_t ctdb_control_get_public_ips(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA *outdata);
1315 int ctdb_ctrl_get_public_ips(struct ctdb_context *ctdb, 
1316                              struct timeval timeout,
1317                              uint32_t destnode,
1318                              TALLOC_CTX *mem_ctx,
1319                              struct ctdb_all_public_ips **ips);
1320 #define CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE 0x00010000
1321 int ctdb_ctrl_get_public_ips_flags(struct ctdb_context *ctdb,
1322                                    struct timeval timeout, uint32_t destnode,
1323                                    TALLOC_CTX *mem_ctx,
1324                                    uint32_t flags,
1325                                    struct ctdb_all_public_ips **ips);
1326 int ctdb_ctrl_get_public_ipsv4(struct ctdb_context *ctdb, 
1327                         struct timeval timeout, uint32_t destnode, 
1328                         TALLOC_CTX *mem_ctx, struct ctdb_all_public_ips **ips);
1329
1330 #ifdef IFNAMSIZ
1331 #define CTDB_IFACE_SIZE IFNAMSIZ
1332 #else
1333 #define CTDB_IFACE_SIZE 16
1334 #endif
1335
1336 struct ctdb_control_iface_info {
1337         char name[CTDB_IFACE_SIZE+2];
1338         uint16_t link_state;
1339         uint32_t references;
1340 };
1341
1342 struct ctdb_control_public_ip_info {
1343         struct ctdb_public_ip ip;
1344         uint32_t active_idx;
1345         uint32_t num;
1346         struct ctdb_control_iface_info ifaces[1];
1347 };
1348
1349 struct ctdb_control_get_ifaces {
1350         uint32_t num;
1351         struct ctdb_control_iface_info ifaces[1];
1352 };
1353
1354 int32_t ctdb_control_get_public_ip_info(struct ctdb_context *ctdb,
1355                                         struct ctdb_req_control *c,
1356                                         TDB_DATA indata,
1357                                         TDB_DATA *outdata);
1358 int32_t ctdb_control_get_ifaces(struct ctdb_context *ctdb,
1359                                 struct ctdb_req_control *c,
1360                                 TDB_DATA *outdata);
1361 int32_t ctdb_control_set_iface_link(struct ctdb_context *ctdb,
1362                                     struct ctdb_req_control *c,
1363                                     TDB_DATA indata);
1364 int ctdb_ctrl_get_public_ip_info(struct ctdb_context *ctdb,
1365                                  struct timeval timeout, uint32_t destnode,
1366                                  TALLOC_CTX *mem_ctx,
1367                                  const ctdb_sock_addr *addr,
1368                                  struct ctdb_control_public_ip_info **info);
1369 int ctdb_ctrl_get_ifaces(struct ctdb_context *ctdb,
1370                          struct timeval timeout, uint32_t destnode,
1371                          TALLOC_CTX *mem_ctx,
1372                          struct ctdb_control_get_ifaces **ifaces);
1373 int ctdb_ctrl_set_iface_link(struct ctdb_context *ctdb,
1374                              struct timeval timeout, uint32_t destnode,
1375                              TALLOC_CTX *mem_ctx,
1376                              const struct ctdb_control_iface_info *info);
1377
1378 /* from takeover/system.c */
1379 uint32_t uint16_checksum(uint16_t *data, size_t n);
1380 int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface);
1381 bool ctdb_sys_have_ip(ctdb_sock_addr *addr);
1382 int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, 
1383                       const ctdb_sock_addr *src,
1384                       uint32_t seq, uint32_t ack, int rst);
1385
1386 int ctdb_set_public_addresses(struct ctdb_context *ctdb, const char *alist);
1387 int ctdb_set_single_public_ip(struct ctdb_context *ctdb,
1388                               const char *iface,
1389                               const char *ip);
1390 int ctdb_set_event_script(struct ctdb_context *ctdb, const char *script);
1391 int ctdb_set_event_script_dir(struct ctdb_context *ctdb, const char *script_dir);
1392 int ctdb_set_notification_script(struct ctdb_context *ctdb, const char *script);
1393 int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap);
1394
1395 int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id, 
1396                                 TDB_DATA indata);
1397 int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata);
1398 int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata);
1399 int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t vnn);
1400 int32_t ctdb_control_kill_tcp(struct ctdb_context *ctdb, TDB_DATA indata);
1401 int32_t ctdb_control_send_gratious_arp(struct ctdb_context *ctdb, TDB_DATA indata);
1402 int32_t ctdb_control_get_tcp_tickle_list(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
1403 int32_t ctdb_control_set_tcp_tickle_list(struct ctdb_context *ctdb, TDB_DATA indata);
1404
1405 void ctdb_takeover_client_destructor_hook(struct ctdb_client *client);
1406 int ctdb_event_script(struct ctdb_context *ctdb, enum ctdb_eventscript_call call);
1407 int ctdb_event_script_args(struct ctdb_context *ctdb, enum ctdb_eventscript_call call,
1408                            const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
1409 int ctdb_event_script_callback(struct ctdb_context *ctdb, 
1410                                TALLOC_CTX *mem_ctx,
1411                                void (*callback)(struct ctdb_context *, int, void *),
1412                                void *private_data,
1413                                bool from_user,
1414                                enum ctdb_eventscript_call call,
1415                                const char *fmt, ...) PRINTF_ATTRIBUTE(7,8);
1416 void ctdb_release_all_ips(struct ctdb_context *ctdb);
1417
1418 void set_nonblocking(int fd);
1419 void set_close_on_exec(int fd);
1420
1421 bool ctdb_recovery_lock(struct ctdb_context *ctdb, bool keep);
1422
1423 int ctdb_set_recovery_lock_file(struct ctdb_context *ctdb, const char *file);
1424
1425 int32_t ctdb_control_get_tunable(struct ctdb_context *ctdb, TDB_DATA indata, 
1426                                  TDB_DATA *outdata);
1427 int32_t ctdb_control_set_tunable(struct ctdb_context *ctdb, TDB_DATA indata);
1428 int32_t ctdb_control_list_tunables(struct ctdb_context *ctdb, TDB_DATA *outdata);
1429 int32_t ctdb_control_try_delete_records(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
1430 int32_t ctdb_control_add_public_address(struct ctdb_context *ctdb, TDB_DATA indata);
1431 int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb, TDB_DATA indata);
1432
1433 void ctdb_tunables_set_defaults(struct ctdb_context *ctdb);
1434
1435 int32_t ctdb_control_modflags(struct ctdb_context *ctdb, TDB_DATA indata);
1436
1437 int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb, 
1438                                struct timeval timeout, 
1439                                uint32_t destnode,
1440                                struct ctdb_tunable *tunables);
1441
1442 int ctdb_start_freeze(struct ctdb_context *ctdb, uint32_t priority);
1443
1444 bool parse_ip_mask(const char *s, const char *iface, ctdb_sock_addr *addr, unsigned *mask);
1445 bool parse_ip_port(const char *s, ctdb_sock_addr *addr);
1446 bool parse_ip(const char *s, const char *iface, unsigned port, ctdb_sock_addr *addr);
1447 bool parse_ipv4(const char *s, unsigned port, struct sockaddr_in *sin);
1448  
1449
1450 int ctdb_sys_open_capture_socket(const char *iface, void **private_data);
1451 int ctdb_sys_close_capture_socket(void *private_data);
1452 int ctdb_sys_read_tcp_packet(int s, void *private_data, ctdb_sock_addr *src, ctdb_sock_addr *dst, uint32_t *ack_seq, uint32_t *seq);
1453
1454 int ctdb_ctrl_killtcp(struct ctdb_context *ctdb, 
1455                       struct timeval timeout, 
1456                       uint32_t destnode,
1457                       struct ctdb_control_killtcp *killtcp);
1458
1459 int ctdb_ctrl_add_public_ip(struct ctdb_context *ctdb, 
1460                       struct timeval timeout, 
1461                       uint32_t destnode,
1462                       struct ctdb_control_ip_iface *pub);
1463
1464 int ctdb_ctrl_del_public_ip(struct ctdb_context *ctdb, 
1465                       struct timeval timeout, 
1466                       uint32_t destnode,
1467                       struct ctdb_control_ip_iface *pub);
1468
1469 int ctdb_ctrl_gratious_arp(struct ctdb_context *ctdb, 
1470                       struct timeval timeout, 
1471                       uint32_t destnode,
1472                       ctdb_sock_addr *addr,
1473                       const char *ifname);
1474
1475 int ctdb_ctrl_get_tcp_tickles(struct ctdb_context *ctdb, 
1476                       struct timeval timeout, 
1477                       uint32_t destnode,
1478                       TALLOC_CTX *mem_ctx,
1479                       ctdb_sock_addr *addr,
1480                       struct ctdb_control_tcp_tickle_list **list);
1481
1482
1483 int32_t ctdb_control_register_server_id(struct ctdb_context *ctdb, 
1484                       uint32_t client_id,
1485                       TDB_DATA indata);
1486 int32_t ctdb_control_check_server_id(struct ctdb_context *ctdb, 
1487                       TDB_DATA indata);
1488 int32_t ctdb_control_unregister_server_id(struct ctdb_context *ctdb, 
1489                       TDB_DATA indata);
1490 int32_t ctdb_control_get_server_id_list(struct ctdb_context *ctdb, 
1491                       TDB_DATA *outdata);
1492 int32_t ctdb_control_uptime(struct ctdb_context *ctdb, 
1493                       TDB_DATA *outdata);
1494
1495 int ctdb_attach_databases(struct ctdb_context *ctdb);
1496
1497 int32_t ctdb_control_persistent_store(struct ctdb_context *ctdb, 
1498                                       struct ctdb_req_control *c, 
1499                                       TDB_DATA recdata, bool *async_reply);
1500 int32_t ctdb_control_update_record(struct ctdb_context *ctdb, 
1501                                    struct ctdb_req_control *c, TDB_DATA recdata, 
1502                                    bool *async_reply);
1503 int32_t ctdb_control_trans2_commit(struct ctdb_context *ctdb, 
1504                                    struct ctdb_req_control *c, 
1505                                    TDB_DATA recdata, bool *async_reply);
1506
1507 int32_t ctdb_control_trans3_commit(struct ctdb_context *ctdb,
1508                                    struct ctdb_req_control *c,
1509                                    TDB_DATA recdata, bool *async_reply);
1510
1511 int32_t ctdb_control_transaction_start(struct ctdb_context *ctdb, uint32_t id);
1512 int32_t ctdb_control_transaction_commit(struct ctdb_context *ctdb, uint32_t id);
1513 int32_t ctdb_control_transaction_cancel(struct ctdb_context *ctdb);
1514 int32_t ctdb_control_wipe_database(struct ctdb_context *ctdb, TDB_DATA indata);
1515 int32_t ctdb_control_db_set_healthy(struct ctdb_context *ctdb, TDB_DATA indata);
1516 int32_t ctdb_control_db_get_health(struct ctdb_context *ctdb,
1517                                    TDB_DATA indata,
1518                                    TDB_DATA *outdata);
1519
1520
1521 int ctdb_vacuum(struct ctdb_context *ctdb, int argc, const char **argv);
1522 int ctdb_repack(struct ctdb_context *ctdb, int argc, const char **argv);
1523
1524 void ctdb_block_signal(int signum);
1525 void ctdb_unblock_signal(int signum);
1526 int32_t ctdb_monitoring_mode(struct ctdb_context *ctdb);
1527 int ctdb_set_child_logging(struct ctdb_context *ctdb);
1528 void ctdb_lockdown_memory(struct ctdb_context *ctdb);
1529
1530 typedef void (*client_async_callback)(struct ctdb_context *ctdb, uint32_t node_pnn, int32_t res, TDB_DATA outdata, void *callback_data);
1531
1532 struct client_async_data {
1533         enum ctdb_controls opcode;
1534         bool dont_log_errors;
1535         uint32_t count;
1536         uint32_t fail_count;
1537         client_async_callback callback;
1538         client_async_callback fail_callback;
1539         void *callback_data;
1540 };
1541 void ctdb_client_async_add(struct client_async_data *data, struct ctdb_client_control_state *state);
1542 int ctdb_client_async_wait(struct ctdb_context *ctdb, struct client_async_data *data);
1543 int ctdb_client_async_control(struct ctdb_context *ctdb,
1544                                 enum ctdb_controls opcode,
1545                                 uint32_t *nodes,
1546                                 uint64_t srvid,
1547                                 struct timeval timeout,
1548                                 bool dont_log_errors,
1549                                 TDB_DATA data,
1550                                 client_async_callback client_callback,
1551                                 client_async_callback fail_callback,
1552                                 void *callback_data);
1553
1554 void ctdb_load_nodes_file(struct ctdb_context *ctdb);
1555
1556 int ctdb_control_reload_nodes_file(struct ctdb_context *ctdb, uint32_t opcode);
1557
1558 int32_t ctdb_dump_memory(struct ctdb_context *ctdb, TDB_DATA *outdata);
1559 int32_t ctdb_control_get_capabilities(struct ctdb_context *ctdb, TDB_DATA *outdata);
1560
1561 int32_t ctdb_control_trans2_finished(struct ctdb_context *ctdb, 
1562                                      struct ctdb_req_control *c);
1563 int32_t ctdb_control_trans2_error(struct ctdb_context *ctdb, 
1564                                   struct ctdb_req_control *c);
1565 int32_t ctdb_control_trans2_active(struct ctdb_context *ctdb,
1566                                    struct ctdb_req_control *c,
1567                                    uint32_t db_id);
1568
1569 char *ctdb_addr_to_str(ctdb_sock_addr *addr);
1570 unsigned ctdb_addr_to_port(ctdb_sock_addr *addr);
1571 void ctdb_canonicalize_ip(const ctdb_sock_addr *ip, ctdb_sock_addr *cip);
1572
1573 int32_t ctdb_control_recd_ping(struct ctdb_context *ctdb);
1574 int32_t ctdb_control_set_recmaster(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata);
1575
1576 extern int script_log_level;
1577
1578 int32_t ctdb_control_get_event_script_status(struct ctdb_context *ctdb,
1579                                              uint32_t call_type,
1580                                              TDB_DATA *outdata);
1581
1582 int ctdb_log_event_script_output(struct ctdb_context *ctdb, char *str, uint16_t len);
1583 int ctdb_ctrl_report_recd_lock_latency(struct ctdb_context *ctdb, struct timeval timeout, double latency);
1584
1585 int32_t ctdb_control_stop_node(struct ctdb_context *ctdb, struct ctdb_req_control *c, bool *async_reply);
1586 int32_t ctdb_control_continue_node(struct ctdb_context *ctdb);
1587
1588 int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db);
1589
1590 int32_t ctdb_control_enable_script(struct ctdb_context *ctdb, TDB_DATA indata);
1591 int32_t ctdb_control_disable_script(struct ctdb_context *ctdb, TDB_DATA indata);
1592
1593 int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata);
1594 int32_t ctdb_control_get_ban_state(struct ctdb_context *ctdb, TDB_DATA *outdata);
1595 int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata);
1596 void ctdb_ban_self(struct ctdb_context *ctdb);
1597
1598 int32_t ctdb_control_register_notify(struct ctdb_context *ctdb, uint32_t client_id, TDB_DATA indata);
1599
1600 int32_t ctdb_control_deregister_notify(struct ctdb_context *ctdb, uint32_t client_id, TDB_DATA indata);
1601
1602 int start_syslog_daemon(struct ctdb_context *ctdb);
1603
1604 /* Where to send the log messages back to */
1605 struct ctdb_get_log_addr {
1606         uint32_t pnn;
1607         uint64_t srvid;
1608         int32_t level;
1609 };
1610
1611 extern int log_ringbuf_size;
1612
1613 int32_t ctdb_control_get_log(struct ctdb_context *ctdb, TDB_DATA addr);
1614 int32_t ctdb_control_clear_log(struct ctdb_context *ctdb);
1615
1616
1617 struct ctdb_log_state *ctdb_fork_with_logging(TALLOC_CTX *mem_ctx,
1618                                               struct ctdb_context *ctdb,
1619                                               void (*logfn)(const char *, uint16_t, void *),
1620                                               void *logfn_private, pid_t *pid);
1621
1622 int32_t ctdb_control_process_exists(struct ctdb_context *ctdb, pid_t pid);
1623 struct ctdb_client *ctdb_find_client_by_pid(struct ctdb_context *ctdb, pid_t pid);
1624
1625 int32_t ctdb_control_get_db_seqnum(struct ctdb_context *ctdb,
1626                                    TDB_DATA indata,
1627                                    TDB_DATA *outdata);
1628
1629 int ctdb_load_persistent_health(struct ctdb_context *ctdb,
1630                                 struct ctdb_db_context *ctdb_db);
1631 int ctdb_update_persistent_health(struct ctdb_context *ctdb,
1632                                   struct ctdb_db_context *ctdb_db,
1633                                   const char *reason,/* NULL means healthy */
1634                                   int num_healthy_nodes);
1635 int ctdb_recheck_persistent_health(struct ctdb_context *ctdb);
1636
1637 void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event);
1638
1639 void ctdb_fault_setup(void);
1640
1641 int verify_remote_ip_allocation(struct ctdb_context *ctdb, 
1642                                 struct ctdb_all_public_ips *ips);
1643 int update_ip_assignment_tree(struct ctdb_context *ctdb,
1644                                 struct ctdb_public_ip *ip);
1645
1646 #endif