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