Merge commit 'origin/master'
[sahlberg/ctdb.git] / include / ctdb.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_H
21 #define _CTDB_H
22
23 #define CTDB_IMMEDIATE_MIGRATION        0x00000001
24 struct ctdb_call {
25         int call_id;
26         TDB_DATA key;
27         TDB_DATA call_data;
28         TDB_DATA reply_data;
29         uint32_t status;
30         uint32_t flags;
31 };
32
33 /*
34   structure passed to a ctdb call backend function
35 */
36 struct ctdb_call_info {
37         TDB_DATA key;          /* record key */
38         TDB_DATA record_data;  /* current data in the record */
39         TDB_DATA *new_data;    /* optionally updated record data */
40         TDB_DATA *call_data;   /* optionally passed from caller */
41         TDB_DATA *reply_data;  /* optionally returned by function */
42         uint32_t status;       /* optional reply status - defaults to zero */
43 };
44
45 #define CTDB_ERR_INVALID 1
46 #define CTDB_ERR_NOMEM 2
47
48 /*
49   ctdb flags
50 */
51 #define CTDB_FLAG_TORTURE      (1<<1)
52
53 /* 
54    a message handler ID meaning "give me all messages"
55  */
56 #define CTDB_SRVID_ALL (~(uint64_t)0)
57
58 /*
59   srvid type : RECOVERY
60 */
61 #define CTDB_SRVID_RECOVERY     0xF100000000000000LL
62
63 /* 
64    a message handler ID meaning that the cluster has been reconfigured
65  */
66 #define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL
67
68 /* 
69    a message handler ID meaning that an IP address has been released
70  */
71 #define CTDB_SRVID_RELEASE_IP 0xF300000000000000LL
72
73 /* 
74    a message ID to set the node flags in the recovery daemon
75  */
76 #define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL
77
78 /*
79   a message to tell the recovery daemon to fetch a set of records
80  */
81 #define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL
82
83 /*
84   a message to tell the recovery daemon to write a talloc memdump
85   to the log
86  */
87 #define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
88
89 /* 
90    a message ID to get the recovery daemon to push the node flags out
91  */
92 #define CTDB_SRVID_PUSH_NODE_FLAGS 0xF900000000000000LL
93
94 /* 
95    a message ID to get the recovery daemon to reload the nodes file
96  */
97 #define CTDB_SRVID_RELOAD_NODES 0xFA00000000000000LL
98
99 /* 
100    a message ID to get the recovery daemon to perform a takeover run
101  */
102 #define CTDB_SRVID_TAKEOVER_RUN 0xFB00000000000000LL
103
104 /* A message id to ask the recovery daemon to temporarily disable the
105    public ip checks
106 */
107 #define CTDB_SRVID_DISABLE_IP_CHECK  0xFC00000000000000LL
108
109 /* A dummy port used for sending back ipreallocate resposnes to the main
110    daemon
111 */
112 #define CTDB_SRVID_TAKEOVER_RUN_RESPONSE  0xFD00000000000000LL
113
114 /* used on the domain socket, send a pdu to the local daemon */
115 #define CTDB_CURRENT_NODE     0xF0000001
116 /* send a broadcast to all nodes in the cluster, active or not */
117 #define CTDB_BROADCAST_ALL    0xF0000002
118 /* send a broadcast to all nodes in the current vnn map */
119 #define CTDB_BROADCAST_VNNMAP 0xF0000003
120 /* send a broadcast to all connected nodes */
121 #define CTDB_BROADCAST_CONNECTED 0xF0000004
122
123 /* the key used for transaction locking on persistent databases */
124 #define CTDB_TRANSACTION_LOCK_KEY "__transaction_lock__"
125
126 enum control_state {CTDB_CONTROL_WAIT, CTDB_CONTROL_DONE, CTDB_CONTROL_ERROR, CTDB_CONTROL_TIMEOUT};
127
128 struct ctdb_client_control_state {
129         struct ctdb_context *ctdb;
130         uint32_t reqid;
131         int32_t status;
132         TDB_DATA outdata;
133         enum control_state state;
134         char *errormsg;
135         struct ctdb_req_control *c;
136
137         /* if we have a callback registered for the completion (or failure) of
138            this control
139            if a callback is used, it MUST talloc_free the cb_data passed to it
140         */
141         struct {
142                 void (*fn)(struct ctdb_client_control_state *);
143                 void *private_data;
144         } async;        
145 };
146
147
148 struct event_context;
149
150 /*
151   initialise ctdb subsystem
152 */
153 struct ctdb_context *ctdb_init(struct event_context *ev);
154
155 /*
156   choose the transport
157 */
158 int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
159
160 /*
161   set the directory for the local databases
162 */
163 int ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir);
164 int ctdb_set_tdb_dir_persistent(struct ctdb_context *ctdb, const char *dir);
165
166 /*
167   set some flags
168 */
169 void ctdb_set_flags(struct ctdb_context *ctdb, unsigned flags);
170
171 /*
172   set max acess count before a dmaster migration
173 */
174 void ctdb_set_max_lacount(struct ctdb_context *ctdb, unsigned count);
175
176 /*
177   tell ctdb what address to listen on, in transport specific format
178 */
179 int ctdb_set_address(struct ctdb_context *ctdb, const char *address);
180
181 int ctdb_set_socketname(struct ctdb_context *ctdb, const char *socketname);
182
183 /*
184   tell ctdb what nodes are available. This takes a filename, which will contain
185   1 node address per line, in a transport specific format
186 */
187 int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist);
188
189 /*
190   Check that a specific ip address exists in the node list and returns
191   the id for the node or -1
192 */
193 int ctdb_ip_to_nodeid(struct ctdb_context *ctdb, const char *nodeip);
194
195 /*
196   start the ctdb protocol
197 */
198 int ctdb_start(struct ctdb_context *ctdb);
199 int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork);
200
201 /*
202   attach to a ctdb database
203 */
204 struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name, bool persistent, uint32_t tdb_flags);
205
206 /*
207   find an attached ctdb_db handle given a name
208  */
209 struct ctdb_db_context *ctdb_db_handle(struct ctdb_context *ctdb, const char *name);
210
211 /*
212   error string for last ctdb error
213 */
214 const char *ctdb_errstr(struct ctdb_context *);
215
216 /* a ctdb call function */
217 typedef int (*ctdb_fn_t)(struct ctdb_call_info *);
218
219 /*
220   setup a ctdb call function
221 */
222 int ctdb_set_call(struct ctdb_db_context *ctdb_db, ctdb_fn_t fn, uint32_t id);
223
224
225
226 /*
227   make a ctdb call. The associated ctdb call function will be called on the DMASTER
228   for the given record
229 */
230 int ctdb_call(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
231
232 /*
233   initiate an ordered ctdb cluster shutdown
234   this function will never return
235 */
236 void ctdb_shutdown(struct ctdb_context *ctdb);
237
238 /* return pnn of this node */
239 uint32_t ctdb_get_pnn(struct ctdb_context *ctdb);
240
241 /*
242   return the number of nodes
243 */
244 uint32_t ctdb_get_num_nodes(struct ctdb_context *ctdb);
245
246 /* setup a handler for ctdb messages */
247 typedef void (*ctdb_message_fn_t)(struct ctdb_context *, uint64_t srvid, 
248                                   TDB_DATA data, void *);
249 int ctdb_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid, 
250                              ctdb_message_fn_t handler,
251                              void *private_data);
252
253
254 int ctdb_call(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
255 struct ctdb_client_call_state *ctdb_call_send(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
256 int ctdb_call_recv(struct ctdb_client_call_state *state, struct ctdb_call *call);
257
258 /* send a ctdb message */
259 int ctdb_send_message(struct ctdb_context *ctdb, uint32_t pnn,
260                       uint64_t srvid, TDB_DATA data);
261
262
263 /* 
264    Fetch a ctdb record from a remote node
265  . Underneath this will force the
266    dmaster for the record to be moved to the local node. 
267 */
268 struct ctdb_record_handle *ctdb_fetch_lock(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx, 
269                                            TDB_DATA key, TDB_DATA *data);
270
271 int ctdb_record_store(struct ctdb_record_handle *h, TDB_DATA data);
272
273 int ctdb_fetch(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx, 
274                TDB_DATA key, TDB_DATA *data);
275
276 int ctdb_register_message_handler(struct ctdb_context *ctdb, 
277                                   TALLOC_CTX *mem_ctx,
278                                   uint64_t srvid,
279                                   ctdb_message_fn_t handler,
280                                   void *private_data);
281
282 struct ctdb_db_context *find_ctdb_db(struct ctdb_context *ctdb, uint32_t id);
283
284
285 struct ctdb_context *ctdb_cmdline_client(struct event_context *ev);
286
287 struct ctdb_statistics;
288 int ctdb_ctrl_statistics(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_statistics *status);
289
290 int ctdb_ctrl_shutdown(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
291
292 struct ctdb_vnn_map;
293 int ctdb_ctrl_getvnnmap(struct ctdb_context *ctdb, 
294                 struct timeval timeout, uint32_t destnode, 
295                 TALLOC_CTX *mem_ctx, struct ctdb_vnn_map **vnnmap);
296 int ctdb_ctrl_setvnnmap(struct ctdb_context *ctdb,
297                 struct timeval timeout, uint32_t destnode, 
298                 TALLOC_CTX *mem_ctx, struct ctdb_vnn_map *vnnmap);
299
300 /* table that contains a list of all dbids on a node
301  */
302 struct ctdb_dbid_map {
303         uint32_t num;
304         struct ctdb_dbid {
305                 uint32_t dbid;
306                 bool persistent;
307         } dbs[1];
308 };
309 int ctdb_ctrl_getdbmap(struct ctdb_context *ctdb, 
310         struct timeval timeout, uint32_t destnode, 
311         TALLOC_CTX *mem_ctx, struct ctdb_dbid_map **dbmap);
312
313
314 struct ctdb_node_map;
315
316 int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb, 
317                     struct timeval timeout, uint32_t destnode, 
318                     TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap);
319
320 int ctdb_ctrl_getnodemapv4(struct ctdb_context *ctdb, 
321                     struct timeval timeout, uint32_t destnode, 
322                     TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap);
323
324 int ctdb_ctrl_reload_nodes_file(struct ctdb_context *ctdb, 
325                     struct timeval timeout, uint32_t destnode);
326
327 struct ctdb_key_list {
328         uint32_t dbid;
329         uint32_t num;
330         TDB_DATA *keys;
331         struct ctdb_ltdb_header *headers;
332         TDB_DATA *data;
333 };
334
335 int ctdb_ctrl_pulldb(
336        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
337        uint32_t lmaster, TALLOC_CTX *mem_ctx,
338        struct timeval timeout, TDB_DATA *outdata);
339
340 struct ctdb_client_control_state *ctdb_ctrl_pulldb_send(
341        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
342        uint32_t lmaster, TALLOC_CTX *mem_ctx, struct timeval timeout);
343
344 int ctdb_ctrl_pulldb_recv(
345        struct ctdb_context *ctdb,
346        TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state,
347        TDB_DATA *outdata);
348
349 int ctdb_ctrl_pushdb(
350        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
351        TALLOC_CTX *mem_ctx,
352        struct timeval timeout, TDB_DATA indata);
353
354 struct ctdb_client_control_state *ctdb_ctrl_pushdb_send(
355        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
356        TALLOC_CTX *mem_ctx, struct timeval timeout,
357        TDB_DATA indata);
358
359 int ctdb_ctrl_pushdb_recv(
360        struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
361        struct ctdb_client_control_state *state);
362
363
364 int ctdb_ctrl_copydb(struct ctdb_context *ctdb, 
365         struct timeval timeout, uint32_t sourcenode, 
366         uint32_t destnode, uint32_t dbid, uint32_t lmaster, 
367         TALLOC_CTX *mem_ctx);
368
369 int ctdb_ctrl_getdbpath(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t dbid, TALLOC_CTX *mem_ctx, const char **path);
370 int ctdb_ctrl_getdbname(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t dbid, TALLOC_CTX *mem_ctx, const char **name);
371 int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, const char *name, bool persistent);
372
373 int ctdb_ctrl_process_exists(struct ctdb_context *ctdb, uint32_t destnode, pid_t pid);
374
375 int ctdb_ctrl_ping(struct ctdb_context *ctdb, uint32_t destnode);
376
377 int ctdb_ctrl_get_config(struct ctdb_context *ctdb);
378
379 int ctdb_ctrl_get_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, int32_t *level);
380 int ctdb_ctrl_set_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, int32_t level);
381
382 /*
383   change dmaster for all keys in the database to the new value
384  */
385 int ctdb_ctrl_setdmaster(struct ctdb_context *ctdb, 
386         struct timeval timeout, uint32_t destnode, 
387         TALLOC_CTX *mem_ctx, uint32_t dbid, uint32_t dmaster);
388
389 /*
390   write a record on a specific db (this implicitely updates dmaster of the record to locally be the vnn of the node where the control is executed on)
391  */
392 int ctdb_ctrl_write_record(struct ctdb_context *ctdb, uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t dbid, TDB_DATA key, TDB_DATA data);
393
394 #define CTDB_RECOVERY_NORMAL            0
395 #define CTDB_RECOVERY_ACTIVE            1
396
397 /*
398   get the recovery mode of a remote node
399  */
400 int ctdb_ctrl_getrecmode(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, uint32_t *recmode);
401
402 struct ctdb_client_control_state *ctdb_ctrl_getrecmode_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
403
404 int ctdb_ctrl_getrecmode_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, uint32_t *recmode);
405
406
407 /*
408   set the recovery mode of a remote node
409  */
410 int ctdb_ctrl_setrecmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmode);
411 /*
412   get the monitoring mode of a remote node
413  */
414 int ctdb_ctrl_getmonmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *monmode);
415
416 /*
417   set the monitoring mode of a remote node to active
418  */
419 int ctdb_ctrl_enable_monmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
420
421 /*
422   set the monitoring mode of a remote node to disabled
423  */
424 int ctdb_ctrl_disable_monmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
425
426
427 /*
428   get the recovery master of a remote node
429  */
430 int ctdb_ctrl_getrecmaster(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, uint32_t *recmaster);
431
432 struct ctdb_client_control_state *ctdb_ctrl_getrecmaster_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
433
434 int ctdb_ctrl_getrecmaster_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, uint32_t *recmaster);
435
436
437
438 /*
439   set the recovery master of a remote node
440  */
441 int ctdb_ctrl_setrecmaster(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmaster);
442
443 uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb, 
444                                    struct timeval timeout, 
445                                    TALLOC_CTX *mem_ctx,
446                                    uint32_t *num_nodes);
447
448 int ctdb_statistics_reset(struct ctdb_context *ctdb, uint32_t destnode);
449
450 int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile, bool use_syslog);
451
452 typedef int (*ctdb_traverse_func)(struct ctdb_context *, TDB_DATA, TDB_DATA, void *);
453 int ctdb_traverse(struct ctdb_db_context *ctdb_db, ctdb_traverse_func fn, void *private_data);
454
455 int ctdb_dump_db(struct ctdb_db_context *ctdb_db, FILE *f);
456
457 /*
458   get the pid of a ctdb daemon
459  */
460 int ctdb_ctrl_getpid(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *pid);
461
462 int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout, 
463                         uint32_t destnode);
464 int ctdb_ctrl_freeze_priority(struct ctdb_context *ctdb, struct timeval timeout, 
465                               uint32_t destnode, uint32_t priority);
466
467 struct ctdb_client_control_state *
468 ctdb_ctrl_freeze_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, 
469                       struct timeval timeout, uint32_t destnode,
470                       uint32_t priority);
471
472 int ctdb_ctrl_freeze_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, 
473                         struct ctdb_client_control_state *state);
474
475 int ctdb_ctrl_thaw_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t priority);
476 int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
477
478 int ctdb_ctrl_getpnn(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
479
480 int ctdb_ctrl_get_tunable(struct ctdb_context *ctdb, 
481                           struct timeval timeout, 
482                           uint32_t destnode,
483                           const char *name, uint32_t *value);
484
485 int ctdb_ctrl_set_tunable(struct ctdb_context *ctdb, 
486                           struct timeval timeout, 
487                           uint32_t destnode,
488                           const char *name, uint32_t value);
489
490 int ctdb_ctrl_list_tunables(struct ctdb_context *ctdb, 
491                             struct timeval timeout, 
492                             uint32_t destnode,
493                             TALLOC_CTX *mem_ctx,
494                             const char ***list, uint32_t *count);
495
496 int ctdb_ctrl_modflags(struct ctdb_context *ctdb, 
497                        struct timeval timeout, 
498                        uint32_t destnode, 
499                        uint32_t set, uint32_t clear);
500
501 enum ctdb_server_id_type { SERVER_TYPE_SAMBA=1 };
502
503 struct ctdb_server_id {
504         enum ctdb_server_id_type type;
505         uint32_t pnn;
506         uint32_t server_id;
507 };
508
509 struct ctdb_server_id_list {
510         uint32_t num;
511         struct ctdb_server_id server_ids[1];
512 };
513
514
515 int ctdb_ctrl_register_server_id(struct ctdb_context *ctdb,
516                 struct timeval timeout,
517                 struct ctdb_server_id *id);
518 int ctdb_ctrl_unregister_server_id(struct ctdb_context *ctdb, 
519                 struct timeval timeout, 
520                 struct ctdb_server_id *id);
521 int ctdb_ctrl_check_server_id(struct ctdb_context *ctdb,
522                 struct timeval timeout, uint32_t destnode, 
523                 struct ctdb_server_id *id, uint32_t *status);
524 int ctdb_ctrl_get_server_id_list(struct ctdb_context *ctdb,
525                 TALLOC_CTX *mem_ctx,
526                 struct timeval timeout, uint32_t destnode, 
527                 struct ctdb_server_id_list **svid_list);
528
529 struct ctdb_uptime {
530         struct timeval current_time;
531         struct timeval ctdbd_start_time;
532         struct timeval last_recovery_started;
533         struct timeval last_recovery_finished;
534 };
535
536 /*
537   definitions for different socket structures
538  */
539 typedef struct sockaddr_in ctdb_addr_in;
540 typedef struct sockaddr_in6 ctdb_addr_in6;
541 typedef union {
542         struct sockaddr sa;
543         ctdb_addr_in    ip;
544         ctdb_addr_in6   ip6;
545 } ctdb_sock_addr;
546
547 /*
548   struct for tcp_client control
549   this is an ipv4 only version of this structure used by samba
550   samba will later be migrated over to use the 
551   ctdb_control_tcp_addr structure instead
552  */
553 struct ctdb_control_tcp {
554         struct sockaddr_in src; // samba uses this
555         struct sockaddr_in dest;// samba uses this
556 };
557 /* new style structure */
558 struct ctdb_control_tcp_addr {
559         ctdb_sock_addr src;
560         ctdb_sock_addr dest;
561 };
562
563 int ctdb_socket_connect(struct ctdb_context *ctdb);
564
565 /*
566   get the uptime of a remote node
567  */
568 int ctdb_ctrl_uptime(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, struct ctdb_uptime **uptime);
569
570 struct ctdb_client_control_state *ctdb_ctrl_uptime_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
571
572 int ctdb_ctrl_uptime_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, struct ctdb_uptime **uptime);
573
574 int ctdb_ctrl_end_recovery(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
575
576 int ctdb_ctrl_getreclock(struct ctdb_context *ctdb, 
577         struct timeval timeout, uint32_t destnode, 
578         TALLOC_CTX *mem_ctx, const char **reclock);
579 int ctdb_ctrl_setreclock(struct ctdb_context *ctdb, 
580         struct timeval timeout, uint32_t destnode, 
581         const char *reclock);
582
583
584 uint32_t *list_of_connected_nodes(struct ctdb_context *ctdb,
585                                 struct ctdb_node_map *node_map,
586                                 TALLOC_CTX *mem_ctx,
587                                 bool include_self);
588 uint32_t *list_of_active_nodes(struct ctdb_context *ctdb,
589                                 struct ctdb_node_map *node_map,
590                                 TALLOC_CTX *mem_ctx,
591                                 bool include_self);
592 uint32_t *list_of_vnnmap_nodes(struct ctdb_context *ctdb,
593                                 struct ctdb_vnn_map *vnn_map,
594                                 TALLOC_CTX *mem_ctx,
595                                 bool include_self);
596 uint32_t *list_of_active_nodes_except_pnn(struct ctdb_context *ctdb,
597                                 struct ctdb_node_map *node_map,
598                                 TALLOC_CTX *mem_ctx,
599                                 uint32_t pnn);
600
601 int ctdb_read_pnn_lock(int fd, int32_t pnn);
602
603 /*
604   get capabilities of a remote node
605  */
606 int ctdb_ctrl_getcapabilities(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *capabilities);
607
608 struct ctdb_client_control_state *ctdb_ctrl_getcapabilities_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
609
610 int ctdb_ctrl_getcapabilities_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, uint32_t *capabilities);
611
612 struct ctdb_marshall_buffer *ctdb_marshall_add(TALLOC_CTX *mem_ctx, 
613                                                struct ctdb_marshall_buffer *m,
614                                                uint64_t db_id,
615                                                uint32_t reqid,
616                                                TDB_DATA key,
617                                                struct ctdb_ltdb_header *header,
618                                                TDB_DATA data);
619 TDB_DATA ctdb_marshall_finish(struct ctdb_marshall_buffer *m);
620
621 struct ctdb_transaction_handle *ctdb_transaction_start(struct ctdb_db_context *ctdb_db,
622                                                        TALLOC_CTX *mem_ctx);
623 int ctdb_transaction_fetch(struct ctdb_transaction_handle *h, 
624                            TALLOC_CTX *mem_ctx, 
625                            TDB_DATA key, TDB_DATA *data);
626 int ctdb_transaction_store(struct ctdb_transaction_handle *h, 
627                            TDB_DATA key, TDB_DATA data);
628 int ctdb_transaction_commit(struct ctdb_transaction_handle *h);
629
630 int ctdb_ctrl_recd_ping(struct ctdb_context *ctdb);
631
632 int switch_from_server_to_client(struct ctdb_context *ctdb);
633
634 #define MONITOR_SCRIPT_OK      0
635 #define MONITOR_SCRIPT_TIMEOUT 1
636
637 #define MAX_SCRIPT_NAME 31
638 #define MAX_SCRIPT_OUTPUT 511
639 struct ctdb_monitoring_script_wire {
640         char name[MAX_SCRIPT_NAME+1];
641         struct timeval start;
642         struct timeval finished;
643         int32_t disabled;
644         int32_t status;
645         int32_t timedout;
646         char output[MAX_SCRIPT_OUTPUT+1];
647 };
648
649 struct ctdb_monitoring_wire {
650         uint32_t num_scripts;
651         struct ctdb_monitoring_script_wire scripts[1];
652 };
653
654 int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb, 
655                     struct timeval timeout, uint32_t destnode, 
656                     TALLOC_CTX *mem_ctx, struct ctdb_monitoring_wire **script_status);
657
658
659 struct debug_levels {
660         int32_t level;
661         const char *description;
662 };
663 extern struct debug_levels debug_levels[];
664
665 const char *get_debug_by_level(int32_t level);
666 int32_t get_debug_by_desc(const char *desc);
667
668 int ctdb_ctrl_stop_node(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
669 int ctdb_ctrl_continue_node(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
670
671 int ctdb_ctrl_setnatgwstate(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t natgwstate);
672 int ctdb_ctrl_setlmasterrole(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t lmasterrole);
673 int ctdb_ctrl_setrecmasterrole(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmasterrole);
674
675 int ctdb_ctrl_enablescript(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, const char *script);
676 int ctdb_ctrl_disablescript(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, const char *script);
677
678 struct ctdb_ban_time {
679         uint32_t pnn;
680         uint32_t time;
681 };
682
683 int ctdb_ctrl_set_ban(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_ban_time *bantime);
684 int ctdb_ctrl_get_ban(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, struct ctdb_ban_time **bantime);
685
686 struct ctdb_db_priority {
687         uint32_t db_id;
688         uint32_t priority;
689 };
690
691 int ctdb_ctrl_set_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_db_priority *db_prio);
692 int ctdb_ctrl_get_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t db_id, uint32_t *priority);
693
694 #endif