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