add max hop count buckets to see how bad hopcounts are
[kai/samba-autobuild/.git] / ctdb / include / ctdb_protocol.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_PROTOCOL_H
21 #define _CTDB_PROTOCOL_H
22
23 /* location of daemon socket */
24 #define CTDB_PATH       "/tmp/ctdb.socket"
25
26 /* default ctdb port number */
27 #define CTDB_PORT 4379
28
29 /* we must align packets to ensure ctdb works on all architectures (eg. sparc) */
30 #define CTDB_DS_ALIGNMENT 8
31
32
33 #define CTDB_NULL_FUNC                  0xFF000001
34 #define CTDB_FETCH_FUNC                 0xFF000002
35 #define CTDB_FETCH_WITH_HEADER_FUNC     0xFF000003
36
37
38 struct ctdb_call {
39         int call_id;
40         TDB_DATA key;
41         TDB_DATA call_data;
42         TDB_DATA reply_data;
43         uint32_t status;
44 #define CTDB_IMMEDIATE_MIGRATION                0x00000001
45 #define CTDB_CALL_FLAG_VACUUM_MIGRATION         0x00000002
46 #define CTDB_WANT_READONLY                      0x00000004
47         uint32_t flags;
48 };
49
50 /*
51   structure passed to a ctdb call backend function
52 */
53 struct ctdb_call_info {
54         TDB_DATA key;          /* record key */
55         struct ctdb_ltdb_header *header;
56         TDB_DATA record_data;  /* current data in the record */
57         TDB_DATA *new_data;    /* optionally updated record data */
58         TDB_DATA *call_data;   /* optionally passed from caller */
59         TDB_DATA *reply_data;  /* optionally returned by function */
60         uint32_t status;       /* optional reply status - defaults to zero */
61 };
62
63 #define CTDB_ERR_INVALID 1
64 #define CTDB_ERR_NOMEM 2
65
66 /*
67   ctdb flags
68 */
69 #define CTDB_FLAG_TORTURE      (1<<1)
70
71 /*
72    a message handler ID meaning "give me all messages"
73  */
74 #define CTDB_SRVID_ALL (~(uint64_t)0)
75
76 /*
77   srvid type : RECOVERY
78 */
79 #define CTDB_SRVID_RECOVERY     0xF100000000000000LL
80
81 /*
82    a message handler ID meaning that the cluster has been reconfigured
83  */
84 #define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL
85
86 /*
87    a message handler ID meaning that an IP address has been released
88  */
89 #define CTDB_SRVID_RELEASE_IP 0xF300000000000000LL
90
91 /*
92    a message handler ID meaning that an IP address has been taken
93  */
94 #define CTDB_SRVID_TAKE_IP 0xF301000000000000LL
95
96 /*
97    a message ID to set the node flags in the recovery daemon
98  */
99 #define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL
100
101 /*
102    a message ID to ask the recovery daemon to update the expected node
103    assignment for a public ip
104  */
105 #define CTDB_SRVID_RECD_UPDATE_IP 0xF500000000000000LL
106
107 /*
108   a message to tell the recovery daemon to fetch a set of records
109  */
110 #define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL
111
112 /*
113   a message to tell the recovery daemon to write a talloc memdump
114   to the log
115  */
116 #define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
117
118 /*
119    a message ID to get the recovery daemon to push the node flags out
120  */
121 #define CTDB_SRVID_PUSH_NODE_FLAGS 0xF900000000000000LL
122
123 /*
124    a message ID to get the recovery daemon to reload the nodes file
125  */
126 #define CTDB_SRVID_RELOAD_NODES 0xFA00000000000000LL
127
128 /*
129    a message ID to get the recovery daemon to perform a takeover run
130  */
131 #define CTDB_SRVID_TAKEOVER_RUN 0xFB00000000000000LL
132
133 /* request recovery daemon to rebalance ips for a node.
134    input is uint32_t for the node id.
135 */
136 #define CTDB_SRVID_REBALANCE_NODE 0xFB01000000000000LL
137
138 /* A message id to ask the recovery daemon to temporarily disable the
139    public ip checks
140 */
141 #define CTDB_SRVID_DISABLE_IP_CHECK  0xFC00000000000000LL
142
143 /* A dummy port used for sending back ipreallocate resposnes to the main
144    daemon
145 */
146 #define CTDB_SRVID_TAKEOVER_RUN_RESPONSE  0xFD00000000000000LL
147
148 /* A range of ports reserved for registering a PID (top 8 bits)
149  * All ports matching the 8 top bits are reserved for exclusive use by
150  * registering a SRVID that matches the process-id of the requesting process
151  */
152 #define CTDB_SRVID_PID_RANGE   0x0000000000000000LL
153
154 /* A range of ports reserved for samba (top 8 bits)
155  * All ports matching the 8 top bits are reserved for exclusive use by
156  * CIFS server
157  */
158 #define CTDB_SRVID_SAMBA_NOTIFY  0xFE00000000000000LL
159 #define CTDB_SRVID_SAMBA_RANGE   0xFE00000000000000LL
160
161 /* A range of ports reserved for a CTDB NFS server (top 8 bits)
162  * All ports matching the 8 top bits are reserved for exclusive use by
163  * NFS server
164  */
165 #define CTDB_SRVID_NFSD_RANGE  0xEE00000000000000LL
166
167 /* A range of ports reserved for a CTDB ISCSI server (top 8 bits)
168  * All ports matching the 8 top bits are reserved for exclusive use by
169  * ISCSI server
170  */
171 #define CTDB_SRVID_ISCSID_RANGE  0xDE00000000000000LL
172
173 /* A range of ports reserved for testing (top 8 bits)
174  * All ports matching the 8 top bits are reserved for exclusive use by
175  * test applications
176  */
177 #define CTDB_SRVID_TEST_RANGE  0xCE00000000000000LL
178
179 /* Range of ports reserved for traversals */
180 #define CTDB_SRVID_TRAVERSE_RANGE  0xBE00000000000000LL
181
182 /* used on the domain socket, send a pdu to the local daemon */
183 #define CTDB_CURRENT_NODE     0xF0000001
184 /* send a broadcast to all nodes in the cluster, active or not */
185 #define CTDB_BROADCAST_ALL    0xF0000002
186 /* send a broadcast to all nodes in the current vnn map */
187 #define CTDB_BROADCAST_VNNMAP 0xF0000003
188 /* send a broadcast to all connected nodes */
189 #define CTDB_BROADCAST_CONNECTED 0xF0000004
190 /* send a broadcast to selected connected nodes */
191 #define CTDB_MULTICAST 0xF0000005
192
193 /* the key used for transaction locking on persistent databases */
194 #define CTDB_TRANSACTION_LOCK_KEY "__transaction_lock__"
195
196 /* the key used to store persistent db sequence number */
197 #define CTDB_DB_SEQNUM_KEY "__db_sequence_number__"
198
199 #define MONITOR_SCRIPT_OK      0
200 #define MONITOR_SCRIPT_TIMEOUT 1
201
202 #define MAX_SCRIPT_NAME 31
203 #define MAX_SCRIPT_OUTPUT 511
204 struct ctdb_script_wire {
205         char name[MAX_SCRIPT_NAME+1];
206         struct timeval start;
207         struct timeval finished;
208         int32_t status;
209         char output[MAX_SCRIPT_OUTPUT+1];
210 };
211
212 struct ctdb_scripts_wire {
213         uint32_t num_scripts;
214         struct ctdb_script_wire scripts[1];
215 };
216
217 /* different calls to event scripts. */
218 enum ctdb_eventscript_call {
219         CTDB_EVENT_INIT,                /* CTDB starting up: no args */
220         CTDB_EVENT_SETUP,               /* CTDB starting up after transport is readdy: no args. */
221         CTDB_EVENT_STARTUP,             /* CTDB starting up after initial recovery: no args. */
222         CTDB_EVENT_START_RECOVERY,      /* CTDB recovery starting: no args. */
223         CTDB_EVENT_RECOVERED,           /* CTDB recovery finished: no args. */
224         CTDB_EVENT_TAKE_IP,             /* IP taken: interface, IP address, netmask bits. */
225         CTDB_EVENT_RELEASE_IP,          /* IP released: interface, IP address, netmask bits. */
226         CTDB_EVENT_STOPPED,             /* This node is stopped: no args. */
227         CTDB_EVENT_MONITOR,             /* Please check if service is healthy: no args. */
228         CTDB_EVENT_STATUS,              /* Report service status: no args. */
229         CTDB_EVENT_SHUTDOWN,            /* CTDB shutting down: no args. */
230         CTDB_EVENT_RELOAD,              /* magic */
231         CTDB_EVENT_UPDATE_IP,           /* IP updating: old interface, new interface, IP address, netmask bits. */
232         CTDB_EVENT_IPREALLOCATED,       /* when a takeover_run() completes */
233         CTDB_EVENT_MAX
234 };
235
236 /* Mapping from enum to names. */
237 extern const char *ctdb_eventscript_call_names[];
238
239 /*
240   operation IDs
241 */
242 enum ctdb_operation {
243         CTDB_REQ_CALL           = 0,
244         CTDB_REPLY_CALL         = 1,
245         CTDB_REQ_DMASTER        = 2,
246         CTDB_REPLY_DMASTER      = 3,
247         CTDB_REPLY_ERROR        = 4,
248         CTDB_REQ_MESSAGE        = 5,
249         /* #6 removed */
250         CTDB_REQ_CONTROL        = 7,
251         CTDB_REPLY_CONTROL      = 8,
252         CTDB_REQ_KEEPALIVE      = 9,
253 };
254
255 #define CTDB_MAGIC 0x43544442 /* CTDB */
256 #define CTDB_VERSION 1
257
258 enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
259                     CTDB_CONTROL_STATISTICS              = 1,
260                     /* #2 removed */
261                     CTDB_CONTROL_PING                    = 3,
262                     CTDB_CONTROL_GETDBPATH               = 4,
263                     CTDB_CONTROL_GETVNNMAP               = 5,
264                     CTDB_CONTROL_SETVNNMAP               = 6,
265                     CTDB_CONTROL_GET_DEBUG               = 7,
266                     CTDB_CONTROL_SET_DEBUG               = 8,
267                     CTDB_CONTROL_GET_DBMAP               = 9,
268                     CTDB_CONTROL_GET_NODEMAPv4           = 10, /* obsolete */
269                     CTDB_CONTROL_SET_DMASTER             = 11,
270                     /* #12 removed */
271                     CTDB_CONTROL_PULL_DB                 = 13,
272                     CTDB_CONTROL_PUSH_DB                 = 14,
273                     CTDB_CONTROL_GET_RECMODE             = 15,
274                     CTDB_CONTROL_SET_RECMODE             = 16,
275                     CTDB_CONTROL_STATISTICS_RESET        = 17,
276                     CTDB_CONTROL_DB_ATTACH               = 18,
277                     CTDB_CONTROL_SET_CALL                = 19,
278                     CTDB_CONTROL_TRAVERSE_START          = 20,
279                     CTDB_CONTROL_TRAVERSE_ALL            = 21,
280                     CTDB_CONTROL_TRAVERSE_DATA           = 22,
281                     CTDB_CONTROL_REGISTER_SRVID          = 23,
282                     CTDB_CONTROL_DEREGISTER_SRVID        = 24,
283                     CTDB_CONTROL_GET_DBNAME              = 25,
284                     CTDB_CONTROL_ENABLE_SEQNUM           = 26,
285                     CTDB_CONTROL_UPDATE_SEQNUM           = 27,
286                     /* #28 removed */
287                     CTDB_CONTROL_DUMP_MEMORY             = 29,
288                     CTDB_CONTROL_GET_PID                 = 30,
289                     CTDB_CONTROL_GET_RECMASTER           = 31,
290                     CTDB_CONTROL_SET_RECMASTER           = 32,
291                     CTDB_CONTROL_FREEZE                  = 33,
292                     CTDB_CONTROL_THAW                    = 34,
293                     CTDB_CONTROL_GET_PNN                 = 35,
294                     CTDB_CONTROL_SHUTDOWN                = 36,
295                     CTDB_CONTROL_GET_MONMODE             = 37,
296                     /* #38 removed */
297                     /* #39 removed */
298                     /* #40 removed */
299                     /* #41 removed */
300                     CTDB_CONTROL_TAKEOVER_IPv4           = 42, /* obsolete */
301                     CTDB_CONTROL_RELEASE_IPv4            = 43, /* obsolete */
302                     CTDB_CONTROL_TCP_CLIENT              = 44,
303                     CTDB_CONTROL_TCP_ADD                 = 45,
304                     CTDB_CONTROL_TCP_REMOVE              = 46,
305                     CTDB_CONTROL_STARTUP                 = 47,
306                     CTDB_CONTROL_SET_TUNABLE             = 48,
307                     CTDB_CONTROL_GET_TUNABLE             = 49,
308                     CTDB_CONTROL_LIST_TUNABLES           = 50,
309                     CTDB_CONTROL_GET_PUBLIC_IPSv4        = 51, /* obsolete */
310                     CTDB_CONTROL_MODIFY_FLAGS            = 52,
311                     CTDB_CONTROL_GET_ALL_TUNABLES        = 53,
312                     CTDB_CONTROL_KILL_TCP                = 54,
313                     CTDB_CONTROL_GET_TCP_TICKLE_LIST     = 55,
314                     CTDB_CONTROL_SET_TCP_TICKLE_LIST     = 56,
315                     CTDB_CONTROL_REGISTER_SERVER_ID      = 57,
316                     CTDB_CONTROL_UNREGISTER_SERVER_ID    = 58,
317                     CTDB_CONTROL_CHECK_SERVER_ID         = 59,
318                     CTDB_CONTROL_GET_SERVER_ID_LIST      = 60,
319                     CTDB_CONTROL_DB_ATTACH_PERSISTENT    = 61,
320                     CTDB_CONTROL_PERSISTENT_STORE        = 62,
321                     CTDB_CONTROL_UPDATE_RECORD           = 63,
322                     CTDB_CONTROL_SEND_GRATIOUS_ARP       = 64,
323                     CTDB_CONTROL_TRANSACTION_START       = 65,
324                     CTDB_CONTROL_TRANSACTION_COMMIT      = 66,
325                     CTDB_CONTROL_WIPE_DATABASE           = 67,
326                     /* #68 removed */
327                     CTDB_CONTROL_UPTIME                  = 69,
328                     CTDB_CONTROL_START_RECOVERY          = 70,
329                     CTDB_CONTROL_END_RECOVERY            = 71,
330                     CTDB_CONTROL_RELOAD_NODES_FILE       = 72,
331                     /* #73 removed */
332                     CTDB_CONTROL_TRY_DELETE_RECORDS      = 74,
333                     CTDB_CONTROL_ENABLE_MONITOR          = 75,
334                     CTDB_CONTROL_DISABLE_MONITOR         = 76,
335                     CTDB_CONTROL_ADD_PUBLIC_IP           = 77,
336                     CTDB_CONTROL_DEL_PUBLIC_IP           = 78,
337                     CTDB_CONTROL_RUN_EVENTSCRIPTS        = 79,
338                     CTDB_CONTROL_GET_CAPABILITIES        = 80,
339                     CTDB_CONTROL_START_PERSISTENT_UPDATE = 81,
340                     CTDB_CONTROL_CANCEL_PERSISTENT_UPDATE= 82,
341                     CTDB_CONTROL_TRANS2_COMMIT           = 83,
342                     CTDB_CONTROL_TRANS2_FINISHED         = 84,
343                     CTDB_CONTROL_TRANS2_ERROR            = 85,
344                     CTDB_CONTROL_TRANS2_COMMIT_RETRY     = 86,
345                     CTDB_CONTROL_RECD_PING               = 87,
346                     CTDB_CONTROL_RELEASE_IP              = 88,
347                     CTDB_CONTROL_TAKEOVER_IP             = 89,
348                     CTDB_CONTROL_GET_PUBLIC_IPS          = 90,
349                     CTDB_CONTROL_GET_NODEMAP             = 91,
350                     CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS = 96,
351                     CTDB_CONTROL_TRAVERSE_KILL           = 97,
352                     CTDB_CONTROL_RECD_RECLOCK_LATENCY    = 98,
353                     CTDB_CONTROL_GET_RECLOCK_FILE        = 99,
354                     CTDB_CONTROL_SET_RECLOCK_FILE        = 100,
355                     CTDB_CONTROL_STOP_NODE               = 101,
356                     CTDB_CONTROL_CONTINUE_NODE           = 102,
357                     CTDB_CONTROL_SET_NATGWSTATE          = 103,
358                     CTDB_CONTROL_SET_LMASTERROLE         = 104,
359                     CTDB_CONTROL_SET_RECMASTERROLE       = 105,
360                     CTDB_CONTROL_ENABLE_SCRIPT           = 107,
361                     CTDB_CONTROL_DISABLE_SCRIPT          = 108,
362                     CTDB_CONTROL_SET_BAN_STATE           = 109,
363                     CTDB_CONTROL_GET_BAN_STATE           = 110,
364                     CTDB_CONTROL_SET_DB_PRIORITY         = 111,
365                     CTDB_CONTROL_GET_DB_PRIORITY         = 112,
366                     CTDB_CONTROL_TRANSACTION_CANCEL      = 113,
367                     CTDB_CONTROL_REGISTER_NOTIFY         = 114,
368                     CTDB_CONTROL_DEREGISTER_NOTIFY       = 115,
369                     CTDB_CONTROL_TRANS2_ACTIVE           = 116,
370                     CTDB_CONTROL_GET_LOG                 = 117,
371                     CTDB_CONTROL_CLEAR_LOG               = 118,
372                     CTDB_CONTROL_TRANS3_COMMIT           = 119,
373                     CTDB_CONTROL_GET_DB_SEQNUM           = 120,
374                     CTDB_CONTROL_DB_SET_HEALTHY          = 121,
375                     CTDB_CONTROL_DB_GET_HEALTH           = 122,
376                     CTDB_CONTROL_GET_PUBLIC_IP_INFO      = 123,
377                     CTDB_CONTROL_GET_IFACES              = 124,
378                     CTDB_CONTROL_SET_IFACE_LINK_STATE    = 125,
379                     CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE  = 126,
380                     CTDB_CONTROL_GET_STAT_HISTORY        = 127,
381                     CTDB_CONTROL_SCHEDULE_FOR_DELETION   = 128,
382                     CTDB_CONTROL_SET_DB_READONLY         = 129,
383                     CTDB_CONTROL_CHECK_SRVIDS            = 130,
384                     CTDB_CONTROL_TRAVERSE_START_EXT      = 131,
385                     CTDB_CONTROL_GET_DB_STATISTICS       = 132,
386 };
387
388 /*
389   packet structures
390 */
391 struct ctdb_req_header {
392         uint32_t length;
393         uint32_t ctdb_magic;
394         uint32_t ctdb_version;
395         uint32_t generation;
396         uint32_t operation;
397         uint32_t destnode;
398         uint32_t srcnode;
399         uint32_t reqid;
400 };
401
402 struct ctdb_req_call {
403         struct ctdb_req_header hdr;
404         uint32_t flags;
405         uint32_t db_id;
406         uint32_t callid;
407         uint32_t hopcount;
408         uint32_t keylen;
409         uint32_t calldatalen;
410         uint8_t data[1]; /* key[] followed by calldata[] */
411 };
412
413 struct ctdb_reply_call {
414         struct ctdb_req_header hdr;
415         uint32_t status;
416         uint32_t datalen;
417         uint8_t  data[1];
418 };
419
420 struct ctdb_reply_error {
421         struct ctdb_req_header hdr;
422         uint32_t status;
423         uint32_t msglen;
424         uint8_t  msg[1];
425 };
426
427 struct ctdb_req_dmaster {
428         struct ctdb_req_header hdr;
429         uint32_t db_id;
430         uint64_t rsn;
431         uint32_t dmaster;
432         uint32_t keylen;
433         uint32_t datalen;
434         uint8_t  data[1];
435 };
436
437 struct ctdb_reply_dmaster {
438         struct ctdb_req_header hdr;
439         uint32_t db_id;
440         uint64_t rsn;
441         uint32_t keylen;
442         uint32_t datalen;
443         uint8_t  data[1];
444 };
445
446 struct ctdb_req_message {
447         struct ctdb_req_header hdr;
448         uint64_t srvid;
449         uint32_t datalen;
450         uint8_t data[1];
451 };
452
453 struct ctdb_req_getdbpath {
454         struct ctdb_req_header hdr;
455         uint32_t db_id;
456 };
457
458 struct ctdb_reply_getdbpath {
459         struct ctdb_req_header hdr;
460         uint32_t datalen;
461         uint8_t data[1];
462 };
463
464 struct ctdb_req_control {
465         struct ctdb_req_header hdr;
466         uint32_t opcode;
467         uint32_t pad;
468         uint64_t srvid;
469         uint32_t client_id;
470 #define CTDB_CTRL_FLAG_NOREPLY   1
471 #define CTDB_CTRL_FLAG_OPCODE_SPECIFIC   0xFFFF0000
472         uint32_t flags;
473         uint32_t datalen;
474         uint8_t data[1];
475 };
476
477 struct ctdb_reply_control {
478         struct ctdb_req_header hdr;
479         int32_t  status;
480         uint32_t datalen;
481         uint32_t errorlen;
482         uint8_t data[1];
483 };
484
485 struct ctdb_req_keepalive {
486         struct ctdb_req_header hdr;
487 };
488
489
490 /* types of failures possible from TRANS2_COMMIT */
491 enum ctdb_trans2_commit_error {
492         CTDB_TRANS2_COMMIT_SUCCESS=0, /* all nodes committed successfully */
493         CTDB_TRANS2_COMMIT_TIMEOUT=1, /* at least one node timed out */
494         CTDB_TRANS2_COMMIT_ALLFAIL=2, /* all nodes failed the commit */
495         CTDB_TRANS2_COMMIT_SOMEFAIL=3 /* some nodes failed the commit, some allowed it */
496 };
497
498 /*
499   the extended header for records in the ltdb
500 */
501 struct ctdb_ltdb_header {
502         uint64_t rsn;
503         uint32_t dmaster;
504         uint32_t reserved1;
505 #define CTDB_REC_FLAG_DEFAULT                   0x00000000
506 #define CTDB_REC_FLAG_MIGRATED_WITH_DATA        0x00010000
507 #define CTDB_REC_FLAG_VACUUM_MIGRATED           0x00020000
508 #define CTDB_REC_FLAG_AUTOMATIC                 0x00040000
509 #define CTDB_REC_RO_HAVE_DELEGATIONS            0x01000000
510 #define CTDB_REC_RO_HAVE_READONLY               0x02000000
511 #define CTDB_REC_RO_REVOKING_READONLY           0x04000000
512 #define CTDB_REC_RO_REVOKE_COMPLETE             0x08000000
513         uint32_t flags;
514 };
515
516
517 /*
518   definitions for different socket structures
519  */
520 typedef struct sockaddr_in ctdb_addr_in;
521 typedef struct sockaddr_in6 ctdb_addr_in6;
522 typedef union {
523         struct sockaddr sa;
524         ctdb_addr_in    ip;
525         ctdb_addr_in6   ip6;
526 } ctdb_sock_addr;
527
528 /*
529    A structure describing a single node, its flags and its address
530 */
531 struct ctdb_node_and_flags {
532         uint32_t pnn;
533         uint32_t flags;
534         ctdb_sock_addr addr;
535 };
536
537
538 /*
539    Structure used for a nodemap. 
540    The nodemap is the structure containing a list of all nodes
541    known to the cluster and their associated flags.
542 */
543 struct ctdb_node_map {
544         uint32_t num;
545         struct ctdb_node_and_flags nodes[1];
546 };
547
548 /*
549  * Node flags
550  */
551 #define NODE_FLAGS_DISCONNECTED         0x00000001 /* node isn't connected */
552 #define NODE_FLAGS_UNHEALTHY            0x00000002 /* monitoring says node is unhealthy */
553 #define NODE_FLAGS_PERMANENTLY_DISABLED 0x00000004 /* administrator has disabled node */
554 #define NODE_FLAGS_BANNED               0x00000008 /* recovery daemon has banned the node */
555 #define NODE_FLAGS_DELETED              0x00000010 /* this node has been deleted */
556 #define NODE_FLAGS_STOPPED              0x00000020 /* this node has been stopped */
557 #define NODE_FLAGS_DISABLED             (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
558 #define NODE_FLAGS_INACTIVE             (NODE_FLAGS_DELETED|NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)
559
560
561 struct ctdb_public_ip {
562         uint32_t pnn;
563         ctdb_sock_addr addr;
564 };
565
566 struct ctdb_all_public_ips {
567         uint32_t num;
568         struct ctdb_public_ip ips[1];
569 };
570
571
572 struct latency_counter {
573         int num;
574         double min;
575         double max;
576         double total;
577 };
578
579 /*
580   structure used to pass record data between the child and parent
581  */
582 struct ctdb_rec_data {
583         uint32_t length;
584         uint32_t reqid;
585         uint32_t keylen;
586         uint32_t datalen;
587         uint8_t  data[1];
588 };
589
590 struct ctdb_traverse_start {
591         uint32_t db_id;
592         uint32_t reqid;
593         uint64_t srvid;
594 };
595
596 struct ctdb_traverse_start_ext {
597         uint32_t db_id;
598         uint32_t reqid;
599         uint64_t srvid;
600         bool withemptyrecords;
601 };
602
603 /*
604   ctdb statistics information
605  */
606 struct ctdb_statistics {
607         uint32_t num_clients;
608         uint32_t frozen;
609         uint32_t recovering;
610         uint32_t client_packets_sent;
611         uint32_t client_packets_recv;
612         uint32_t node_packets_sent;
613         uint32_t node_packets_recv;
614         uint32_t keepalive_packets_sent;
615         uint32_t keepalive_packets_recv;
616         struct {
617                 uint32_t req_call;
618                 uint32_t reply_call;
619                 uint32_t req_dmaster;
620                 uint32_t reply_dmaster;
621                 uint32_t reply_error;
622                 uint32_t req_message;
623                 uint32_t req_control;
624                 uint32_t reply_control;
625         } node;
626         struct {
627                 uint32_t req_call;
628                 uint32_t req_message;
629                 uint32_t req_control;
630         } client;
631         struct {
632                 uint32_t call;
633                 uint32_t control;
634                 uint32_t traverse;
635         } timeouts;
636         struct {
637                 struct latency_counter ctdbd;
638                 struct latency_counter recd;
639         } reclock;
640         uint32_t total_calls;
641         uint32_t pending_calls;
642         uint32_t lockwait_calls;
643         uint32_t pending_lockwait_calls;
644         uint32_t childwrite_calls;
645         uint32_t pending_childwrite_calls;
646         uint32_t memory_used;
647         uint32_t __last_counter; /* hack for control_statistics_all */
648         uint32_t max_hop_count;
649 #define MAX_HOP_COUNT_BUCKETS 16
650         uint32_t hop_count_bucket[MAX_HOP_COUNT_BUCKETS];
651         struct latency_counter call_latency;
652         struct latency_counter lockwait_latency;
653         struct latency_counter childwrite_latency;
654         uint32_t num_recoveries;
655         struct timeval statistics_start_time;
656         struct timeval statistics_current_time;
657         uint32_t total_ro_delegations;
658         uint32_t total_ro_revokes;
659 };
660
661 /*
662  * wire format for statistics history
663  */
664 struct ctdb_statistics_wire {
665         uint32_t num;
666         struct ctdb_statistics stats[1];
667 };
668
669 /*
670  * db statistics
671  */
672 struct ctdb_db_statistics {
673         uint32_t db_ro_delegations;
674         uint32_t db_ro_revokes;
675 };
676
677 /*
678  * wire format for interface list
679  */
680 #ifdef IFNAMSIZ
681 #define CTDB_IFACE_SIZE IFNAMSIZ
682 #else
683 #define CTDB_IFACE_SIZE 16
684 #endif
685
686 struct ctdb_iface_info {
687         char name[CTDB_IFACE_SIZE+2];
688         uint16_t link_state;
689         uint32_t references;
690 };
691
692 struct ctdb_ifaces_list {
693         uint32_t num;
694         struct ctdb_iface_info ifaces[1];
695 };
696
697 #define INVALID_GENERATION 1
698 /* table that contains the mapping between a hash value and lmaster
699  */
700 struct ctdb_vnn_map {
701         uint32_t generation;
702         uint32_t size;
703         uint32_t *map;
704 };
705
706 /* 
707    a wire representation of the vnn map
708  */
709 struct ctdb_vnn_map_wire {
710         uint32_t generation;
711         uint32_t size;
712         uint32_t map[1];
713 };
714
715 #endif