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