s3:libsmb: Honor disable_netbios option in smbsock_connect_send
[Samba.git] / ctdb / tests / src / protocol_types_compat_test.c
blob59d6958a568bc8d502ec55d1d03cb059f7a28cd1
1 /*
2 protocol types backward compatibility test
4 Copyright (C) Amitay Isaacs 2015
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.
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.
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/>.
20 #include "replace.h"
21 #include "system/filesys.h"
23 #include <assert.h>
25 #include "protocol/protocol_basic.c"
26 #include "protocol/protocol_types.c"
28 #include "tests/src/protocol_common.h"
30 #define COMPAT_TEST_FUNC(NAME) test_ ##NAME## _compat
31 #define OLD_LEN_FUNC(NAME) NAME## _len_old
32 #define OLD_PUSH_FUNC(NAME) NAME## _push_old
33 #define OLD_PULL_FUNC(NAME) NAME## _pull_old
35 #define COMPAT_TYPE1_TEST(TYPE, NAME) \
36 static void COMPAT_TEST_FUNC(NAME)(void) \
37 { \
38 TALLOC_CTX *mem_ctx; \
39 uint8_t *buf1, *buf2; \
40 TYPE p = { 0 }, p1, p2; \
41 size_t buflen1, buflen2, np = 0; \
42 int ret; \
44 mem_ctx = talloc_new(NULL); \
45 assert(mem_ctx != NULL); \
46 FILL_FUNC(NAME)(&p); \
47 buflen1 = LEN_FUNC(NAME)(&p); \
48 buflen2 = OLD_LEN_FUNC(NAME)(&p); \
49 assert(buflen1 == buflen2); \
50 buf1 = talloc_zero_size(mem_ctx, buflen1); \
51 assert(buf1 != NULL); \
52 buf2 = talloc_zero_size(mem_ctx, buflen2); \
53 assert(buf2 != NULL); \
54 PUSH_FUNC(NAME)(&p, buf1, &np); \
55 OLD_PUSH_FUNC(NAME)(&p, buf2); \
56 assert(memcmp(buf1, buf2, buflen1) == 0); \
57 ret = PULL_FUNC(NAME)(buf1, buflen1, &p1, &np); \
58 assert(ret == 0); \
59 ret = OLD_PULL_FUNC(NAME)(buf2, buflen2, &p2); \
60 assert(ret == 0); \
61 VERIFY_FUNC(NAME)(&p1, &p2); \
62 talloc_free(mem_ctx); \
65 #define COMPAT_TYPE3_TEST(TYPE, NAME) \
66 static void COMPAT_TEST_FUNC(NAME)(void) \
67 { \
68 TALLOC_CTX *mem_ctx; \
69 uint8_t *buf1, *buf2; \
70 TYPE *p, *p1, *p2; \
71 size_t buflen1, buflen2, np = 0; \
72 int ret; \
74 mem_ctx = talloc_new(NULL); \
75 assert(mem_ctx != NULL); \
76 p = talloc_zero(mem_ctx, TYPE); \
77 assert(p != NULL); \
78 FILL_FUNC(NAME)(p, p); \
79 buflen1 = LEN_FUNC(NAME)(p); \
80 buflen2 = OLD_LEN_FUNC(NAME)(p); \
81 assert(buflen1 == buflen2); \
82 buf1 = talloc_zero_size(mem_ctx, buflen1); \
83 assert(buf1 != NULL); \
84 buf2 = talloc_zero_size(mem_ctx, buflen2); \
85 assert(buf2 != NULL); \
86 PUSH_FUNC(NAME)(p, buf1, &np); \
87 OLD_PUSH_FUNC(NAME)(p, buf2); \
88 assert(memcmp(buf1, buf2, buflen1) == 0); \
89 ret = PULL_FUNC(NAME)(buf1, buflen1, mem_ctx, &p1, &np); \
90 assert(ret == 0); \
91 ret = OLD_PULL_FUNC(NAME)(buf2, buflen2, mem_ctx, &p2); \
92 assert(ret == 0); \
93 VERIFY_FUNC(NAME)(p1, p2); \
94 talloc_free(mem_ctx); \
98 static size_t ctdb_statistics_len_old(struct ctdb_statistics *in)
100 return sizeof(struct ctdb_statistics);
103 static void ctdb_statistics_push_old(struct ctdb_statistics *in, uint8_t *buf)
105 memcpy(buf, in, sizeof(struct ctdb_statistics));
108 static int ctdb_statistics_pull_old(uint8_t *buf, size_t buflen,
109 TALLOC_CTX *mem_ctx,
110 struct ctdb_statistics **out)
112 struct ctdb_statistics *val;
114 if (buflen < sizeof(struct ctdb_statistics)) {
115 return EMSGSIZE;
118 val = talloc(mem_ctx, struct ctdb_statistics);
119 if (val == NULL) {
120 return ENOMEM;
123 memcpy(val, buf, sizeof(struct ctdb_statistics));
125 *out = val;
126 return 0;
129 struct ctdb_vnn_map_wire {
130 uint32_t generation;
131 uint32_t size;
132 uint32_t map[1];
135 static size_t ctdb_vnn_map_len_old(struct ctdb_vnn_map *in)
137 return offsetof(struct ctdb_vnn_map, map) +
138 in->size * sizeof(uint32_t);
141 static void ctdb_vnn_map_push_old(struct ctdb_vnn_map *in, uint8_t *buf)
143 struct ctdb_vnn_map_wire *wire = (struct ctdb_vnn_map_wire *)buf;
145 memcpy(wire, in, offsetof(struct ctdb_vnn_map, map));
146 memcpy(wire->map, in->map, in->size * sizeof(uint32_t));
149 static int ctdb_vnn_map_pull_old(uint8_t *buf, size_t buflen,
150 TALLOC_CTX *mem_ctx,
151 struct ctdb_vnn_map **out)
153 struct ctdb_vnn_map *val;
154 struct ctdb_vnn_map_wire *wire = (struct ctdb_vnn_map_wire *)buf;
156 if (buflen < offsetof(struct ctdb_vnn_map_wire, map)) {
157 return EMSGSIZE;
159 if (wire->size > buflen / sizeof(uint32_t)) {
160 return EMSGSIZE;
162 if (offsetof(struct ctdb_vnn_map_wire, map) +
163 wire->size * sizeof(uint32_t) <
164 offsetof(struct ctdb_vnn_map_wire, map)) {
165 return EMSGSIZE;
167 if (buflen < offsetof(struct ctdb_vnn_map_wire, map) +
168 wire->size * sizeof(uint32_t)) {
169 return EMSGSIZE;
172 val = talloc(mem_ctx, struct ctdb_vnn_map);
173 if (val == NULL) {
174 return ENOMEM;
177 memcpy(val, wire, offsetof(struct ctdb_vnn_map, map));
179 val->map = talloc_memdup(val, wire->map,
180 wire->size * sizeof(uint32_t));
181 if (val->map == NULL) {
182 talloc_free(val);
183 return ENOMEM;
186 *out = val;
187 return 0;
190 struct ctdb_dbid_map_wire {
191 uint32_t num;
192 struct ctdb_dbid dbs[1];
195 static size_t ctdb_dbid_map_len_old(struct ctdb_dbid_map *in)
197 return sizeof(uint32_t) + in->num * sizeof(struct ctdb_dbid);
200 static void ctdb_dbid_map_push_old(struct ctdb_dbid_map *in, uint8_t *buf)
202 struct ctdb_dbid_map_wire *wire = (struct ctdb_dbid_map_wire *)buf;
204 wire->num = in->num;
205 memcpy(wire->dbs, in->dbs, in->num * sizeof(struct ctdb_dbid));
208 static int ctdb_dbid_map_pull_old(uint8_t *buf, size_t buflen,
209 TALLOC_CTX *mem_ctx,
210 struct ctdb_dbid_map **out)
212 struct ctdb_dbid_map *val;
213 struct ctdb_dbid_map_wire *wire = (struct ctdb_dbid_map_wire *)buf;
215 if (buflen < sizeof(uint32_t)) {
216 return EMSGSIZE;
218 if (wire->num > buflen / sizeof(struct ctdb_dbid)) {
219 return EMSGSIZE;
221 if (sizeof(uint32_t) + wire->num * sizeof(struct ctdb_dbid) <
222 sizeof(uint32_t)) {
223 return EMSGSIZE;
225 if (buflen < sizeof(uint32_t) + wire->num * sizeof(struct ctdb_dbid)) {
226 return EMSGSIZE;
229 val = talloc(mem_ctx, struct ctdb_dbid_map);
230 if (val == NULL) {
231 return ENOMEM;
234 val->num = wire->num;
236 val->dbs = talloc_memdup(val, wire->dbs,
237 wire->num * sizeof(struct ctdb_dbid));
238 if (val->dbs == NULL) {
239 talloc_free(val);
240 return ENOMEM;
243 *out = val;
244 return 0;
247 static size_t ctdb_pulldb_len_old(struct ctdb_pulldb *in)
249 return sizeof(struct ctdb_pulldb);
252 static void ctdb_pulldb_push_old(struct ctdb_pulldb *in, uint8_t *buf)
254 memcpy(buf, in, sizeof(struct ctdb_pulldb));
257 static int ctdb_pulldb_pull_old(uint8_t *buf, size_t buflen,
258 TALLOC_CTX *mem_ctx, struct ctdb_pulldb **out)
260 struct ctdb_pulldb *val;
262 if (buflen < sizeof(struct ctdb_pulldb)) {
263 return EMSGSIZE;
266 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_pulldb));
267 if (val == NULL) {
268 return ENOMEM;
271 *out = val;
272 return 0;
275 static size_t ctdb_pulldb_ext_len_old(struct ctdb_pulldb_ext *in)
277 return sizeof(struct ctdb_pulldb_ext);
280 static void ctdb_pulldb_ext_push_old(struct ctdb_pulldb_ext *in, uint8_t *buf)
282 memcpy(buf, in, sizeof(struct ctdb_pulldb_ext));
285 static int ctdb_pulldb_ext_pull_old(uint8_t *buf, size_t buflen,
286 TALLOC_CTX *mem_ctx,
287 struct ctdb_pulldb_ext **out)
289 struct ctdb_pulldb_ext *val;
291 if (buflen < sizeof(struct ctdb_pulldb_ext)) {
292 return EMSGSIZE;
295 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_pulldb_ext));
296 if (val == NULL) {
297 return ENOMEM;
300 *out = val;
301 return 0;
304 static size_t ctdb_ltdb_header_len_old(struct ctdb_ltdb_header *in)
306 return sizeof(struct ctdb_ltdb_header);
309 static void ctdb_ltdb_header_push_old(struct ctdb_ltdb_header *in,
310 uint8_t *buf)
312 memcpy(buf, in, sizeof(struct ctdb_ltdb_header));
315 static int ctdb_ltdb_header_pull_old(uint8_t *buf, size_t buflen,
316 struct ctdb_ltdb_header *out)
318 if (buflen < sizeof(struct ctdb_ltdb_header)) {
319 return EMSGSIZE;
322 memcpy(out, buf, sizeof(struct ctdb_ltdb_header));
323 return 0;
326 struct ctdb_rec_data_wire {
327 uint32_t length;
328 uint32_t reqid;
329 uint32_t keylen;
330 uint32_t datalen;
331 uint8_t data[1];
334 static size_t ctdb_rec_data_len_old(struct ctdb_rec_data *in)
336 return offsetof(struct ctdb_rec_data_wire, data) +
337 in->key.dsize + in->data.dsize +
338 (in->header == NULL ? 0 : sizeof(struct ctdb_ltdb_header));
341 static void ctdb_rec_data_push_old(struct ctdb_rec_data *in, uint8_t *buf)
343 struct ctdb_rec_data_wire *wire = (struct ctdb_rec_data_wire *)buf;
344 size_t offset;
346 wire->length = ctdb_rec_data_len(in);
347 wire->reqid = in->reqid;
348 wire->keylen = in->key.dsize;
349 wire->datalen = in->data.dsize;
350 if (in->header != NULL) {
351 wire->datalen += sizeof(struct ctdb_ltdb_header);
354 memcpy(wire->data, in->key.dptr, in->key.dsize);
355 offset = in->key.dsize;
356 if (in->header != NULL) {
357 memcpy(&wire->data[offset], in->header,
358 sizeof(struct ctdb_ltdb_header));
359 offset += sizeof(struct ctdb_ltdb_header);
361 if (in->data.dsize > 0) {
362 memcpy(&wire->data[offset], in->data.dptr, in->data.dsize);
366 static int ctdb_rec_data_pull_data_old(uint8_t *buf, size_t buflen,
367 uint32_t *reqid,
368 struct ctdb_ltdb_header **header,
369 TDB_DATA *key, TDB_DATA *data,
370 size_t *reclen)
372 struct ctdb_rec_data_wire *wire = (struct ctdb_rec_data_wire *)buf;
373 size_t offset;
375 if (buflen < offsetof(struct ctdb_rec_data_wire, data)) {
376 return EMSGSIZE;
378 if (wire->keylen > buflen || wire->datalen > buflen) {
379 return EMSGSIZE;
381 if (offsetof(struct ctdb_rec_data_wire, data) + wire->keylen <
382 offsetof(struct ctdb_rec_data_wire, data)) {
383 return EMSGSIZE;
385 if (offsetof(struct ctdb_rec_data_wire, data) +
386 wire->keylen + wire->datalen <
387 offsetof(struct ctdb_rec_data_wire, data)) {
388 return EMSGSIZE;
390 if (buflen < offsetof(struct ctdb_rec_data_wire, data) +
391 wire->keylen + wire->datalen) {
392 return EMSGSIZE;
395 *reqid = wire->reqid;
397 key->dsize = wire->keylen;
398 key->dptr = wire->data;
399 offset = wire->keylen;
401 /* Always set header to NULL. If it is required, exact it using
402 * ctdb_rec_data_extract_header()
404 *header = NULL;
406 data->dsize = wire->datalen;
407 data->dptr = &wire->data[offset];
409 *reclen = offsetof(struct ctdb_rec_data_wire, data) +
410 wire->keylen + wire->datalen;
412 return 0;
415 static int ctdb_rec_data_pull_elems_old(uint8_t *buf, size_t buflen,
416 TALLOC_CTX *mem_ctx,
417 struct ctdb_rec_data *out)
419 uint32_t reqid;
420 struct ctdb_ltdb_header *header;
421 TDB_DATA key, data;
422 size_t reclen;
423 int ret;
425 ret = ctdb_rec_data_pull_data_old(buf, buflen, &reqid, &header,
426 &key, &data, &reclen);
427 if (ret != 0) {
428 return ret;
431 out->reqid = reqid;
432 out->header = NULL;
434 out->key.dsize = key.dsize;
435 if (key.dsize > 0) {
436 out->key.dptr = talloc_memdup(mem_ctx, key.dptr, key.dsize);
437 if (out->key.dptr == NULL) {
438 return ENOMEM;
442 out->data.dsize = data.dsize;
443 if (data.dsize > 0) {
444 out->data.dptr = talloc_memdup(mem_ctx, data.dptr, data.dsize);
445 if (out->data.dptr == NULL) {
446 return ENOMEM;
450 return 0;
453 static int ctdb_rec_data_pull_old(uint8_t *buf, size_t buflen,
454 TALLOC_CTX *mem_ctx,
455 struct ctdb_rec_data **out)
457 struct ctdb_rec_data *val;
458 int ret;
460 val = talloc(mem_ctx, struct ctdb_rec_data);
461 if (val == NULL) {
462 return ENOMEM;
465 ret = ctdb_rec_data_pull_elems_old(buf, buflen, val, val);
466 if (ret != 0) {
467 TALLOC_FREE(val);
468 return ret;
471 *out = val;
472 return ret;
475 struct ctdb_rec_buffer_wire {
476 uint32_t db_id;
477 uint32_t count;
478 uint8_t data[1];
481 static size_t ctdb_rec_buffer_len_old(struct ctdb_rec_buffer *in)
483 return offsetof(struct ctdb_rec_buffer_wire, data) + in->buflen;
486 static void ctdb_rec_buffer_push_old(struct ctdb_rec_buffer *in, uint8_t *buf)
488 struct ctdb_rec_buffer_wire *wire = (struct ctdb_rec_buffer_wire *)buf;
490 wire->db_id = in->db_id;
491 wire->count = in->count;
492 if (in->buflen > 0) {
493 memcpy(wire->data, in->buf, in->buflen);
497 static int ctdb_rec_buffer_pull_old(uint8_t *buf, size_t buflen,
498 TALLOC_CTX *mem_ctx,
499 struct ctdb_rec_buffer **out)
501 struct ctdb_rec_buffer *val;
502 struct ctdb_rec_buffer_wire *wire = (struct ctdb_rec_buffer_wire *)buf;
503 size_t offset;
505 if (buflen < offsetof(struct ctdb_rec_buffer_wire, data)) {
506 return EMSGSIZE;
509 val = talloc(mem_ctx, struct ctdb_rec_buffer);
510 if (val == NULL) {
511 return ENOMEM;
514 val->db_id = wire->db_id;
515 val->count = wire->count;
517 offset = offsetof(struct ctdb_rec_buffer_wire, data);
518 val->buflen = buflen - offset;
519 val->buf = talloc_memdup(val, wire->data, val->buflen);
520 if (val->buf == NULL) {
521 talloc_free(val);
522 return ENOMEM;
525 *out = val;
526 return 0;
529 static size_t ctdb_traverse_start_len_old(struct ctdb_traverse_start *in)
531 return sizeof(struct ctdb_traverse_start);
534 static void ctdb_traverse_start_push_old(struct ctdb_traverse_start *in,
535 uint8_t *buf)
537 memcpy(buf, in, sizeof(struct ctdb_traverse_start));
540 static int ctdb_traverse_start_pull_old(uint8_t *buf, size_t buflen,
541 TALLOC_CTX *mem_ctx,
542 struct ctdb_traverse_start **out)
544 struct ctdb_traverse_start *val;
546 if (buflen < sizeof(struct ctdb_traverse_start)) {
547 return EMSGSIZE;
550 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_traverse_start));
551 if (val == NULL) {
552 return ENOMEM;
555 *out = val;
556 return 0;
559 static size_t ctdb_traverse_all_len_old(struct ctdb_traverse_all *in)
561 return sizeof(struct ctdb_traverse_all);
564 static void ctdb_traverse_all_push_old(struct ctdb_traverse_all *in,
565 uint8_t *buf)
567 memcpy(buf, in, sizeof(struct ctdb_traverse_all));
570 static int ctdb_traverse_all_pull_old(uint8_t *buf, size_t buflen,
571 TALLOC_CTX *mem_ctx,
572 struct ctdb_traverse_all **out)
574 struct ctdb_traverse_all *val;
576 if (buflen < sizeof(struct ctdb_traverse_all)) {
577 return EMSGSIZE;
580 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_traverse_all));
581 if (val == NULL) {
582 return ENOMEM;
585 *out = val;
586 return 0;
589 static size_t ctdb_traverse_start_ext_len_old(
590 struct ctdb_traverse_start_ext *in)
592 return sizeof(struct ctdb_traverse_start_ext);
595 static void ctdb_traverse_start_ext_push_old(
596 struct ctdb_traverse_start_ext *in, uint8_t *buf)
598 memcpy(buf, in, sizeof(struct ctdb_traverse_start_ext));
601 static int ctdb_traverse_start_ext_pull_old(uint8_t *buf, size_t buflen,
602 TALLOC_CTX *mem_ctx,
603 struct ctdb_traverse_start_ext **out)
605 struct ctdb_traverse_start_ext *val;
607 if (buflen < sizeof(struct ctdb_traverse_start_ext)) {
608 return EMSGSIZE;
611 val = talloc_memdup(mem_ctx, buf,
612 sizeof(struct ctdb_traverse_start_ext));
613 if (val == NULL) {
614 return ENOMEM;
617 *out = val;
618 return 0;
621 static size_t ctdb_traverse_all_ext_len_old(struct ctdb_traverse_all_ext *in)
623 return sizeof(struct ctdb_traverse_all_ext);
626 static void ctdb_traverse_all_ext_push_old(struct ctdb_traverse_all_ext *in,
627 uint8_t *buf)
629 memcpy(buf, in, sizeof(struct ctdb_traverse_all_ext));
632 static int ctdb_traverse_all_ext_pull_old(uint8_t *buf, size_t buflen,
633 TALLOC_CTX *mem_ctx,
634 struct ctdb_traverse_all_ext **out)
636 struct ctdb_traverse_all_ext *val;
638 if (buflen < sizeof(struct ctdb_traverse_all_ext)) {
639 return EMSGSIZE;
642 val = talloc_memdup(mem_ctx, buf,
643 sizeof(struct ctdb_traverse_all_ext));
644 if (val == NULL) {
645 return ENOMEM;
648 *out = val;
649 return 0;
652 static size_t ctdb_sock_addr_len_old(ctdb_sock_addr *in)
654 return sizeof(ctdb_sock_addr);
657 static void ctdb_sock_addr_push_old(ctdb_sock_addr *in, uint8_t *buf)
659 memcpy(buf, in, sizeof(ctdb_sock_addr));
662 static int ctdb_sock_addr_pull_elems_old(uint8_t *buf, size_t buflen,
663 TALLOC_CTX *mem_ctx,
664 ctdb_sock_addr *out)
666 if (buflen < sizeof(ctdb_sock_addr)) {
667 return EMSGSIZE;
670 memcpy(out, buf, sizeof(ctdb_sock_addr));
672 return 0;
675 static int ctdb_sock_addr_pull_old(uint8_t *buf, size_t buflen,
676 TALLOC_CTX *mem_ctx, ctdb_sock_addr **out)
678 ctdb_sock_addr *val;
679 int ret;
681 val = talloc(mem_ctx, ctdb_sock_addr);
682 if (val == NULL) {
683 return ENOMEM;
686 ret = ctdb_sock_addr_pull_elems_old(buf, buflen, val, val);
687 if (ret != 0) {
688 TALLOC_FREE(val);
689 return ret;
692 *out = val;
693 return ret;
696 static size_t ctdb_connection_len_old(struct ctdb_connection *in)
698 return sizeof(struct ctdb_connection);
701 static void ctdb_connection_push_old(struct ctdb_connection *in, uint8_t *buf)
703 memcpy(buf, in, sizeof(struct ctdb_connection));
706 static int ctdb_connection_pull_elems_old(uint8_t *buf, size_t buflen,
707 TALLOC_CTX *mem_ctx,
708 struct ctdb_connection *out)
710 if (buflen < sizeof(struct ctdb_connection)) {
711 return EMSGSIZE;
714 memcpy(out, buf, sizeof(struct ctdb_connection));
716 return 0;
719 static int ctdb_connection_pull_old(uint8_t *buf, size_t buflen,
720 TALLOC_CTX *mem_ctx,
721 struct ctdb_connection **out)
723 struct ctdb_connection *val;
724 int ret;
726 val = talloc(mem_ctx, struct ctdb_connection);
727 if (val == NULL) {
728 return ENOMEM;
731 ret = ctdb_connection_pull_elems_old(buf, buflen, val, val);
732 if (ret != 0) {
733 TALLOC_FREE(val);
734 return ret;
737 *out = val;
738 return ret;
741 struct ctdb_tunable_wire {
742 uint32_t value;
743 uint32_t length;
744 uint8_t name[1];
747 static size_t ctdb_tunable_len_old(struct ctdb_tunable *in)
749 return offsetof(struct ctdb_tunable_wire, name) +
750 strlen(in->name) + 1;
753 static void ctdb_tunable_push_old(struct ctdb_tunable *in, uint8_t *buf)
755 struct ctdb_tunable_wire *wire = (struct ctdb_tunable_wire *)buf;
757 wire->value = in->value;
758 wire->length = strlen(in->name) + 1;
759 memcpy(wire->name, in->name, wire->length);
762 static int ctdb_tunable_pull_old(uint8_t *buf, size_t buflen,
763 TALLOC_CTX *mem_ctx,
764 struct ctdb_tunable **out)
766 struct ctdb_tunable *val;
767 struct ctdb_tunable_wire *wire = (struct ctdb_tunable_wire *)buf;
769 if (buflen < offsetof(struct ctdb_tunable_wire, name)) {
770 return EMSGSIZE;
772 if (wire->length > buflen) {
773 return EMSGSIZE;
775 if (offsetof(struct ctdb_tunable_wire, name) + wire->length <
776 offsetof(struct ctdb_tunable_wire, name)) {
777 return EMSGSIZE;
779 if (buflen < offsetof(struct ctdb_tunable_wire, name) + wire->length) {
780 return EMSGSIZE;
783 val = talloc(mem_ctx, struct ctdb_tunable);
784 if (val == NULL) {
785 return ENOMEM;
788 val->value = wire->value;
789 val->name = talloc_memdup(val, wire->name, wire->length);
790 if (val->name == NULL) {
791 talloc_free(val);
792 return ENOMEM;
795 *out = val;
796 return 0;
799 static size_t ctdb_node_flag_change_len_old(struct ctdb_node_flag_change *in)
801 return sizeof(struct ctdb_node_flag_change);
804 static void ctdb_node_flag_change_push_old(struct ctdb_node_flag_change *in,
805 uint8_t *buf)
807 memcpy(buf, in, sizeof(struct ctdb_node_flag_change));
810 static int ctdb_node_flag_change_pull_old(uint8_t *buf, size_t buflen,
811 TALLOC_CTX *mem_ctx,
812 struct ctdb_node_flag_change **out)
814 struct ctdb_node_flag_change *val;
816 if (buflen < sizeof(struct ctdb_node_flag_change)) {
817 return EMSGSIZE;
820 val = talloc_memdup(mem_ctx, buf,
821 sizeof(struct ctdb_node_flag_change));
822 if (val == NULL) {
823 return ENOMEM;
826 *out = val;
827 return 0;
830 struct ctdb_var_list_wire {
831 uint32_t length;
832 char list_str[1];
835 static size_t ctdb_var_list_len_old(struct ctdb_var_list *in)
837 int i;
838 size_t len = sizeof(uint32_t);
840 for (i=0; i<in->count; i++) {
841 len += strlen(in->var[i]) + 1;
843 return len;
846 static void ctdb_var_list_push_old(struct ctdb_var_list *in, uint8_t *buf)
848 struct ctdb_var_list_wire *wire = (struct ctdb_var_list_wire *)buf;
849 int i, n;
850 size_t offset = 0;
852 if (in->count > 0) {
853 n = sprintf(wire->list_str, "%s", in->var[0]);
854 offset += n;
856 for (i=1; i<in->count; i++) {
857 n = sprintf(&wire->list_str[offset], ":%s", in->var[i]);
858 offset += n;
860 wire->length = offset + 1;
863 static int ctdb_var_list_pull_old(uint8_t *buf, size_t buflen,
864 TALLOC_CTX *mem_ctx,
865 struct ctdb_var_list **out)
867 struct ctdb_var_list *val = NULL;
868 struct ctdb_var_list_wire *wire = (struct ctdb_var_list_wire *)buf;
869 char *str, *s, *tok, *ptr;
870 const char **list;
872 if (buflen < sizeof(uint32_t)) {
873 return EMSGSIZE;
875 if (wire->length > buflen) {
876 return EMSGSIZE;
878 if (sizeof(uint32_t) + wire->length < sizeof(uint32_t)) {
879 return EMSGSIZE;
881 if (buflen < sizeof(uint32_t) + wire->length) {
882 return EMSGSIZE;
885 str = talloc_strndup(mem_ctx, (char *)wire->list_str, wire->length);
886 if (str == NULL) {
887 return ENOMEM;
890 val = talloc_zero(mem_ctx, struct ctdb_var_list);
891 if (val == NULL) {
892 goto fail;
895 s = str;
896 while ((tok = strtok_r(s, ":", &ptr)) != NULL) {
897 s = NULL;
898 list = talloc_realloc(val, val->var, const char *,
899 val->count+1);
900 if (list == NULL) {
901 goto fail;
904 val->var = list;
905 val->var[val->count] = talloc_strdup(val, tok);
906 if (val->var[val->count] == NULL) {
907 goto fail;
909 val->count++;
912 talloc_free(str);
913 *out = val;
914 return 0;
916 fail:
917 talloc_free(str);
918 talloc_free(val);
919 return ENOMEM;
922 static size_t ctdb_tunable_list_len_old(struct ctdb_tunable_list *in)
924 return sizeof(struct ctdb_tunable_list);
927 static void ctdb_tunable_list_push_old(struct ctdb_tunable_list *in,
928 uint8_t *buf)
930 memcpy(buf, in, sizeof(struct ctdb_tunable_list));
933 static int ctdb_tunable_list_pull_old(uint8_t *buf, size_t buflen,
934 TALLOC_CTX *mem_ctx,
935 struct ctdb_tunable_list **out)
937 struct ctdb_tunable_list *val;
939 if (buflen < sizeof(struct ctdb_tunable_list)) {
940 return EMSGSIZE;
943 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_tunable_list));
944 if (val == NULL) {
945 return ENOMEM;
948 *out = val;
949 return 0;
952 struct ctdb_tickle_list_wire {
953 ctdb_sock_addr addr;
954 uint32_t num;
955 struct ctdb_connection conn[1];
958 static size_t ctdb_tickle_list_len_old(struct ctdb_tickle_list *in)
960 return offsetof(struct ctdb_tickle_list, conn) +
961 in->num * sizeof(struct ctdb_connection);
964 static void ctdb_tickle_list_push_old(struct ctdb_tickle_list *in,
965 uint8_t *buf)
967 struct ctdb_tickle_list_wire *wire =
968 (struct ctdb_tickle_list_wire *)buf;
969 size_t offset;
970 int i;
972 memcpy(&wire->addr, &in->addr, sizeof(ctdb_sock_addr));
973 wire->num = in->num;
975 offset = offsetof(struct ctdb_tickle_list_wire, conn);
976 for (i=0; i<in->num; i++) {
977 ctdb_connection_push_old(&in->conn[i], &buf[offset]);
978 offset += ctdb_connection_len_old(&in->conn[i]);
982 static int ctdb_tickle_list_pull_old(uint8_t *buf, size_t buflen,
983 TALLOC_CTX *mem_ctx,
984 struct ctdb_tickle_list **out)
986 struct ctdb_tickle_list *val;
987 struct ctdb_tickle_list_wire *wire =
988 (struct ctdb_tickle_list_wire *)buf;
989 size_t offset;
990 int i, ret;
992 if (buflen < offsetof(struct ctdb_tickle_list_wire, conn)) {
993 return EMSGSIZE;
995 if (wire->num > buflen / sizeof(struct ctdb_connection)) {
996 return EMSGSIZE;
998 if (offsetof(struct ctdb_tickle_list_wire, conn) +
999 wire->num * sizeof(struct ctdb_connection) <
1000 offsetof(struct ctdb_tickle_list_wire, conn)) {
1001 return EMSGSIZE;
1003 if (buflen < offsetof(struct ctdb_tickle_list_wire, conn) +
1004 wire->num * sizeof(struct ctdb_connection)) {
1005 return EMSGSIZE;
1008 val = talloc(mem_ctx, struct ctdb_tickle_list);
1009 if (val == NULL) {
1010 return ENOMEM;
1013 offset = offsetof(struct ctdb_tickle_list, conn);
1014 memcpy(val, wire, offset);
1016 val->conn = talloc_array(val, struct ctdb_connection, wire->num);
1017 if (val->conn == NULL) {
1018 talloc_free(val);
1019 return ENOMEM;
1022 for (i=0; i<wire->num; i++) {
1023 ret = ctdb_connection_pull_elems_old(&buf[offset],
1024 buflen-offset,
1025 val->conn,
1026 &val->conn[i]);
1027 if (ret != 0) {
1028 talloc_free(val);
1029 return ret;
1031 offset += ctdb_connection_len_old(&val->conn[i]);
1034 *out = val;
1035 return 0;
1038 struct ctdb_addr_info_wire {
1039 ctdb_sock_addr addr;
1040 uint32_t mask;
1041 uint32_t len;
1042 char iface[1];
1045 static size_t ctdb_addr_info_len_old(struct ctdb_addr_info *in)
1047 uint32_t len;
1049 len = offsetof(struct ctdb_addr_info_wire, iface);
1050 if (in->iface != NULL) {
1051 len += strlen(in->iface)+1;
1054 return len;
1057 static void ctdb_addr_info_push_old(struct ctdb_addr_info *in, uint8_t *buf)
1059 struct ctdb_addr_info_wire *wire = (struct ctdb_addr_info_wire *)buf;
1061 wire->addr = in->addr;
1062 wire->mask = in->mask;
1063 if (in->iface == NULL) {
1064 wire->len = 0;
1065 } else {
1066 wire->len = strlen(in->iface)+1;
1067 memcpy(wire->iface, in->iface, wire->len);
1071 static int ctdb_addr_info_pull_old(uint8_t *buf, size_t buflen,
1072 TALLOC_CTX *mem_ctx,
1073 struct ctdb_addr_info **out)
1075 struct ctdb_addr_info *val;
1076 struct ctdb_addr_info_wire *wire = (struct ctdb_addr_info_wire *)buf;
1078 if (buflen < offsetof(struct ctdb_addr_info_wire, iface)) {
1079 return EMSGSIZE;
1081 if (wire->len > buflen) {
1082 return EMSGSIZE;
1084 if (offsetof(struct ctdb_addr_info_wire, iface) + wire->len <
1085 offsetof(struct ctdb_addr_info_wire, iface)) {
1086 return EMSGSIZE;
1088 if (buflen < offsetof(struct ctdb_addr_info_wire, iface) + wire->len) {
1089 return EMSGSIZE;
1092 val = talloc(mem_ctx, struct ctdb_addr_info);
1093 if (val == NULL) {
1094 return ENOMEM;
1097 val->addr = wire->addr;
1098 val->mask = wire->mask;
1100 if (wire->len == 0) {
1101 val->iface = NULL;
1102 } else {
1103 val->iface = talloc_strndup(val, wire->iface, wire->len);
1104 if (val->iface == NULL) {
1105 talloc_free(val);
1106 return ENOMEM;
1110 *out = val;
1111 return 0;
1114 static size_t ctdb_transdb_len_old(struct ctdb_transdb *in)
1116 return sizeof(struct ctdb_transdb);
1119 static void ctdb_transdb_push_old(struct ctdb_transdb *in, uint8_t *buf)
1121 memcpy(buf, in, sizeof(struct ctdb_transdb));
1124 static int ctdb_transdb_pull_old(uint8_t *buf, size_t buflen,
1125 TALLOC_CTX *mem_ctx,
1126 struct ctdb_transdb **out)
1128 struct ctdb_transdb *val;
1130 if (buflen < sizeof(struct ctdb_transdb)) {
1131 return EMSGSIZE;
1134 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_transdb));
1135 if (val == NULL) {
1136 return ENOMEM;
1139 *out = val;
1140 return 0;
1143 static size_t ctdb_uptime_len_old(struct ctdb_uptime *in)
1145 return sizeof(struct ctdb_uptime);
1148 static void ctdb_uptime_push_old(struct ctdb_uptime *in, uint8_t *buf)
1150 memcpy(buf, in, sizeof(struct ctdb_uptime));
1153 static int ctdb_uptime_pull_old(uint8_t *buf, size_t buflen,
1154 TALLOC_CTX *mem_ctx, struct ctdb_uptime **out)
1156 struct ctdb_uptime *val;
1158 if (buflen < sizeof(struct ctdb_uptime)) {
1159 return EMSGSIZE;
1162 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_uptime));
1163 if (val == NULL) {
1164 return ENOMEM;
1167 *out = val;
1168 return 0;
1171 static size_t ctdb_public_ip_len_old(struct ctdb_public_ip *in)
1173 return sizeof(struct ctdb_public_ip);
1176 static void ctdb_public_ip_push_old(struct ctdb_public_ip *in, uint8_t *buf)
1178 memcpy(buf, in, sizeof(struct ctdb_public_ip));
1181 static int ctdb_public_ip_pull_elems_old(uint8_t *buf, size_t buflen,
1182 TALLOC_CTX *mem_ctx,
1183 struct ctdb_public_ip *out)
1185 if (buflen < sizeof(struct ctdb_public_ip)) {
1186 return EMSGSIZE;
1189 memcpy(out, buf, sizeof(struct ctdb_public_ip));
1191 return 0;
1194 static int ctdb_public_ip_pull_old(uint8_t *buf, size_t buflen,
1195 TALLOC_CTX *mem_ctx,
1196 struct ctdb_public_ip **out)
1198 struct ctdb_public_ip *val;
1199 int ret;
1201 val = talloc(mem_ctx, struct ctdb_public_ip);
1202 if (val == NULL) {
1203 return ENOMEM;
1206 ret = ctdb_public_ip_pull_elems_old(buf, buflen, val, val);
1207 if (ret != 0) {
1208 TALLOC_FREE(val);
1209 return ret;
1212 *out = val;
1213 return ret;
1216 struct ctdb_public_ip_list_wire {
1217 uint32_t num;
1218 struct ctdb_public_ip ip[1];
1221 static size_t ctdb_public_ip_list_len_old(struct ctdb_public_ip_list *in)
1223 int i;
1224 size_t len;
1226 len = sizeof(uint32_t);
1227 for (i=0; i<in->num; i++) {
1228 len += ctdb_public_ip_len_old(&in->ip[i]);
1230 return len;
1233 static void ctdb_public_ip_list_push_old(struct ctdb_public_ip_list *in,
1234 uint8_t *buf)
1236 struct ctdb_public_ip_list_wire *wire =
1237 (struct ctdb_public_ip_list_wire *)buf;
1238 size_t offset;
1239 int i;
1241 wire->num = in->num;
1243 offset = offsetof(struct ctdb_public_ip_list_wire, ip);
1244 for (i=0; i<in->num; i++) {
1245 ctdb_public_ip_push_old(&in->ip[i], &buf[offset]);
1246 offset += ctdb_public_ip_len_old(&in->ip[i]);
1250 static int ctdb_public_ip_list_pull_old(uint8_t *buf, size_t buflen,
1251 TALLOC_CTX *mem_ctx,
1252 struct ctdb_public_ip_list **out)
1254 struct ctdb_public_ip_list *val;
1255 struct ctdb_public_ip_list_wire *wire =
1256 (struct ctdb_public_ip_list_wire *)buf;
1257 size_t offset;
1258 int i;
1259 bool ret;
1261 if (buflen < sizeof(uint32_t)) {
1262 return EMSGSIZE;
1264 if (wire->num > buflen / sizeof(struct ctdb_public_ip)) {
1265 return EMSGSIZE;
1267 if (sizeof(uint32_t) + wire->num * sizeof(struct ctdb_public_ip) <
1268 sizeof(uint32_t)) {
1269 return EMSGSIZE;
1271 if (buflen < sizeof(uint32_t) +
1272 wire->num * sizeof(struct ctdb_public_ip)) {
1273 return EMSGSIZE;
1276 val = talloc(mem_ctx, struct ctdb_public_ip_list);
1277 if (val == NULL) {
1278 return ENOMEM;
1281 val->num = wire->num;
1282 if (wire->num == 0) {
1283 val->ip = NULL;
1284 *out = val;
1285 return 0;
1287 val->ip = talloc_array(val, struct ctdb_public_ip, wire->num);
1288 if (val->ip == NULL) {
1289 talloc_free(val);
1290 return ENOMEM;
1293 offset = offsetof(struct ctdb_public_ip_list_wire, ip);
1294 for (i=0; i<wire->num; i++) {
1295 ret = ctdb_public_ip_pull_elems_old(&buf[offset],
1296 buflen-offset,
1297 val->ip,
1298 &val->ip[i]);
1299 if (ret != 0) {
1300 talloc_free(val);
1301 return ret;
1303 offset += ctdb_public_ip_len_old(&val->ip[i]);
1306 *out = val;
1307 return 0;
1310 static size_t ctdb_node_and_flags_len_old(struct ctdb_node_and_flags *in)
1312 return sizeof(struct ctdb_node_and_flags);
1315 static void ctdb_node_and_flags_push_old(struct ctdb_node_and_flags *in,
1316 uint8_t *buf)
1318 memcpy(buf, in, sizeof(struct ctdb_node_and_flags));
1321 static int ctdb_node_and_flags_pull_elems_old(TALLOC_CTX *mem_ctx,
1322 uint8_t *buf, size_t buflen,
1323 struct ctdb_node_and_flags *out)
1325 if (buflen < sizeof(struct ctdb_node_and_flags)) {
1326 return EMSGSIZE;
1329 memcpy(out, buf, sizeof(struct ctdb_node_and_flags));
1331 return 0;
1334 static int ctdb_node_and_flags_pull_old(uint8_t *buf, size_t buflen,
1335 TALLOC_CTX *mem_ctx,
1336 struct ctdb_node_and_flags **out)
1338 struct ctdb_node_and_flags *val;
1339 int ret;
1341 val = talloc(mem_ctx, struct ctdb_node_and_flags);
1342 if (val == NULL) {
1343 return ENOMEM;
1346 ret = ctdb_node_and_flags_pull_elems_old(val, buf, buflen, val);
1347 if (ret != 0) {
1348 TALLOC_FREE(val);
1349 return ret;
1352 *out = val;
1353 return ret;
1356 struct ctdb_node_map_wire {
1357 uint32_t num;
1358 struct ctdb_node_and_flags node[1];
1361 static size_t ctdb_node_map_len_old(struct ctdb_node_map *in)
1363 return sizeof(uint32_t) +
1364 in->num * sizeof(struct ctdb_node_and_flags);
1367 static void ctdb_node_map_push_old(struct ctdb_node_map *in, uint8_t *buf)
1369 struct ctdb_node_map_wire *wire = (struct ctdb_node_map_wire *)buf;
1370 size_t offset;
1371 int i;
1373 wire->num = in->num;
1375 offset = offsetof(struct ctdb_node_map_wire, node);
1376 for (i=0; i<in->num; i++) {
1377 ctdb_node_and_flags_push_old(&in->node[i], &buf[offset]);
1378 offset += ctdb_node_and_flags_len_old(&in->node[i]);
1382 static int ctdb_node_map_pull_old(uint8_t *buf, size_t buflen,
1383 TALLOC_CTX *mem_ctx,
1384 struct ctdb_node_map **out)
1386 struct ctdb_node_map *val;
1387 struct ctdb_node_map_wire *wire = (struct ctdb_node_map_wire *)buf;
1388 size_t offset;
1389 int i;
1390 bool ret;
1392 if (buflen < sizeof(uint32_t)) {
1393 return EMSGSIZE;
1395 if (wire->num > buflen / sizeof(struct ctdb_node_and_flags)) {
1396 return EMSGSIZE;
1398 if (sizeof(uint32_t) + wire->num * sizeof(struct ctdb_node_and_flags) <
1399 sizeof(uint32_t)) {
1400 return EMSGSIZE;
1402 if (buflen < sizeof(uint32_t) +
1403 wire->num * sizeof(struct ctdb_node_and_flags)) {
1404 return EMSGSIZE;
1407 val = talloc(mem_ctx, struct ctdb_node_map);
1408 if (val == NULL) {
1409 return ENOMEM;
1412 val->num = wire->num;
1413 val->node = talloc_array(val, struct ctdb_node_and_flags, wire->num);
1414 if (val->node == NULL) {
1415 talloc_free(val);
1416 return ENOMEM;
1419 offset = offsetof(struct ctdb_node_map_wire, node);
1420 for (i=0; i<wire->num; i++) {
1421 ret = ctdb_node_and_flags_pull_elems_old(val->node,
1422 &buf[offset],
1423 buflen-offset,
1424 &val->node[i]);
1425 if (ret != 0) {
1426 talloc_free(val);
1427 return ret;
1429 offset += ctdb_node_and_flags_len_old(&val->node[i]);
1432 *out = val;
1433 return 0;
1436 static size_t ctdb_script_len_old(struct ctdb_script *in)
1438 return sizeof(struct ctdb_script);
1441 static void ctdb_script_push_old(struct ctdb_script *in, uint8_t *buf)
1443 memcpy(buf, in, sizeof(struct ctdb_script));
1446 static int ctdb_script_pull_elems_old(uint8_t *buf, size_t buflen,
1447 TALLOC_CTX *mem_ctx,
1448 struct ctdb_script *out)
1450 if (buflen < sizeof(struct ctdb_script)) {
1451 return EMSGSIZE;
1454 memcpy(out, buf, sizeof(struct ctdb_script));
1456 return 0;
1459 static int ctdb_script_pull_old(uint8_t *buf, size_t buflen,
1460 TALLOC_CTX *mem_ctx, struct ctdb_script **out)
1462 struct ctdb_script *val;
1463 int ret;
1465 val = talloc(mem_ctx, struct ctdb_script);
1466 if (val == NULL) {
1467 return ENOMEM;
1470 ret = ctdb_script_pull_elems_old(buf, buflen, val, val);
1471 if (ret != 0) {
1472 TALLOC_FREE(val);
1473 return ret;
1476 *out = val;
1477 return ret;
1480 struct ctdb_script_list_wire {
1481 uint32_t num_scripts;
1482 struct ctdb_script script[1];
1485 static size_t ctdb_script_list_len_old(struct ctdb_script_list *in)
1487 int i;
1488 size_t len;
1490 if (in == NULL) {
1491 return 0;
1494 len = offsetof(struct ctdb_script_list_wire, script);
1495 for (i=0; i<in->num_scripts; i++) {
1496 len += ctdb_script_len_old(&in->script[i]);
1498 return len;
1501 static void ctdb_script_list_push_old(struct ctdb_script_list *in,
1502 uint8_t *buf)
1504 struct ctdb_script_list_wire *wire =
1505 (struct ctdb_script_list_wire *)buf;
1506 size_t offset;
1507 int i;
1509 if (in == NULL) {
1510 return;
1513 wire->num_scripts = in->num_scripts;
1515 offset = offsetof(struct ctdb_script_list_wire, script);
1516 for (i=0; i<in->num_scripts; i++) {
1517 ctdb_script_push_old(&in->script[i], &buf[offset]);
1518 offset += ctdb_script_len_old(&in->script[i]);
1522 static int ctdb_script_list_pull_old(uint8_t *buf, size_t buflen,
1523 TALLOC_CTX *mem_ctx,
1524 struct ctdb_script_list **out)
1526 struct ctdb_script_list *val;
1527 struct ctdb_script_list_wire *wire =
1528 (struct ctdb_script_list_wire *)buf;
1529 size_t offset;
1530 int i;
1531 bool ret;
1533 /* If event scripts have never been run, the result will be NULL */
1534 if (buflen == 0) {
1535 *out = NULL;
1536 return 0;
1539 offset = offsetof(struct ctdb_script_list_wire, script);
1541 if (buflen < offset) {
1542 return EMSGSIZE;
1544 if (wire->num_scripts > buflen / sizeof(struct ctdb_script)) {
1545 return EMSGSIZE;
1547 if (offset + wire->num_scripts * sizeof(struct ctdb_script) < offset) {
1548 return EMSGSIZE;
1550 if (buflen < offset + wire->num_scripts * sizeof(struct ctdb_script)) {
1551 return EMSGSIZE;
1554 val = talloc(mem_ctx, struct ctdb_script_list);
1555 if (val == NULL) {
1556 return ENOMEM;
1560 val->num_scripts = wire->num_scripts;
1561 val->script = talloc_array(val, struct ctdb_script, wire->num_scripts);
1562 if (val->script == NULL) {
1563 talloc_free(val);
1564 return ENOMEM;
1567 for (i=0; i<wire->num_scripts; i++) {
1568 ret = ctdb_script_pull_elems_old(&buf[offset], buflen-offset,
1569 val->script,
1570 &val->script[i]);
1571 if (ret != 0) {
1572 talloc_free(val);
1573 return ret;
1575 offset += ctdb_script_len_old(&val->script[i]);
1578 *out = val;
1579 return 0;
1582 static size_t ctdb_ban_state_len_old(struct ctdb_ban_state *in)
1584 return sizeof(struct ctdb_ban_state);
1587 static void ctdb_ban_state_push_old(struct ctdb_ban_state *in, uint8_t *buf)
1589 memcpy(buf, in, sizeof(struct ctdb_ban_state));
1592 static int ctdb_ban_state_pull_old(uint8_t *buf, size_t buflen,
1593 TALLOC_CTX *mem_ctx,
1594 struct ctdb_ban_state **out)
1596 struct ctdb_ban_state *val;
1598 if (buflen < sizeof(struct ctdb_ban_state)) {
1599 return EMSGSIZE;
1602 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_ban_state));
1603 if (val == NULL) {
1604 return ENOMEM;
1607 *out = val;
1608 return 0;
1611 struct ctdb_notify_data_wire {
1612 uint64_t srvid;
1613 uint32_t len;
1614 uint8_t data[1];
1617 static size_t ctdb_notify_data_len_old(struct ctdb_notify_data *in)
1619 return offsetof(struct ctdb_notify_data_wire, data) +
1620 in->data.dsize;
1623 static void ctdb_notify_data_push_old(struct ctdb_notify_data *in,
1624 uint8_t *buf)
1626 struct ctdb_notify_data_wire *wire =
1627 (struct ctdb_notify_data_wire *)buf;
1629 wire->srvid = in->srvid;
1630 wire->len = in->data.dsize;
1631 memcpy(wire->data, in->data.dptr, in->data.dsize);
1634 static int ctdb_notify_data_pull_old(uint8_t *buf, size_t buflen,
1635 TALLOC_CTX *mem_ctx,
1636 struct ctdb_notify_data **out)
1638 struct ctdb_notify_data *val;
1639 struct ctdb_notify_data_wire *wire =
1640 (struct ctdb_notify_data_wire *)buf;
1642 if (buflen < offsetof(struct ctdb_notify_data_wire, data)) {
1643 return EMSGSIZE;
1645 if (wire->len > buflen) {
1646 return EMSGSIZE;
1648 if (offsetof(struct ctdb_notify_data_wire, data) + wire->len <
1649 offsetof(struct ctdb_notify_data_wire, data)) {
1650 return EMSGSIZE;
1652 if (buflen < offsetof(struct ctdb_notify_data_wire, data) + wire->len) {
1653 return EMSGSIZE;
1656 val = talloc(mem_ctx, struct ctdb_notify_data);
1657 if (val == NULL) {
1658 return ENOMEM;
1661 val->srvid = wire->srvid;
1662 val->data.dsize = wire->len;
1663 val->data.dptr = talloc_memdup(val, wire->data, wire->len);
1664 if (val->data.dptr == NULL) {
1665 talloc_free(val);
1666 return ENOMEM;
1669 *out = val;
1670 return 0;
1673 static size_t ctdb_iface_len_old(struct ctdb_iface *in)
1675 return sizeof(struct ctdb_iface);
1678 static void ctdb_iface_push_old(struct ctdb_iface *in, uint8_t *buf)
1680 memcpy(buf, in, sizeof(struct ctdb_iface));
1683 static int ctdb_iface_pull_elems_old(uint8_t *buf, size_t buflen,
1684 TALLOC_CTX *mem_ctx,
1685 struct ctdb_iface *out)
1687 if (buflen < sizeof(struct ctdb_iface)) {
1688 return EMSGSIZE;
1691 memcpy(out, buf, sizeof(struct ctdb_iface));
1693 return 0;
1696 static int ctdb_iface_pull_old(uint8_t *buf, size_t buflen,
1697 TALLOC_CTX *mem_ctx, struct ctdb_iface **out)
1699 struct ctdb_iface *val;
1700 int ret;
1702 val = talloc(mem_ctx, struct ctdb_iface);
1703 if (val == NULL) {
1704 return ENOMEM;
1707 ret = ctdb_iface_pull_elems_old(buf, buflen, val, val);
1708 if (ret != 0) {
1709 TALLOC_FREE(val);
1710 return ret;
1713 *out = val;
1714 return ret;
1717 struct ctdb_iface_list_wire {
1718 uint32_t num;
1719 struct ctdb_iface iface[1];
1722 static size_t ctdb_iface_list_len_old(struct ctdb_iface_list *in)
1724 return sizeof(uint32_t) +
1725 in->num * sizeof(struct ctdb_iface);
1728 static void ctdb_iface_list_push_old(struct ctdb_iface_list *in, uint8_t *buf)
1730 struct ctdb_iface_list_wire *wire =
1731 (struct ctdb_iface_list_wire *)buf;
1733 wire->num = in->num;
1734 memcpy(wire->iface, in->iface, in->num * sizeof(struct ctdb_iface));
1737 static int ctdb_iface_list_pull_old(uint8_t *buf, size_t buflen,
1738 TALLOC_CTX *mem_ctx,
1739 struct ctdb_iface_list **out)
1741 struct ctdb_iface_list *val;
1742 struct ctdb_iface_list_wire *wire =
1743 (struct ctdb_iface_list_wire *)buf;
1745 if (buflen < sizeof(uint32_t)) {
1746 return EMSGSIZE;
1748 if (wire->num > buflen / sizeof(struct ctdb_iface)) {
1749 return EMSGSIZE;
1751 if (sizeof(uint32_t) + wire->num * sizeof(struct ctdb_iface) <
1752 sizeof(uint32_t)) {
1753 return EMSGSIZE;
1755 if (buflen < sizeof(uint32_t) + wire->num * sizeof(struct ctdb_iface)) {
1756 return EMSGSIZE;
1759 val = talloc(mem_ctx, struct ctdb_iface_list);
1760 if (val == NULL) {
1761 return ENOMEM;
1764 val->num = wire->num;
1765 val->iface = talloc_array(val, struct ctdb_iface, wire->num);
1766 if (val->iface == NULL) {
1767 talloc_free(val);
1768 return ENOMEM;
1771 memcpy(val->iface, wire->iface, wire->num * sizeof(struct ctdb_iface));
1773 *out = val;
1774 return 0;
1777 struct ctdb_public_ip_info_wire {
1778 struct ctdb_public_ip ip;
1779 uint32_t active_idx;
1780 uint32_t num;
1781 struct ctdb_iface ifaces[1];
1784 static size_t ctdb_public_ip_info_len_old(struct ctdb_public_ip_info *in)
1786 return offsetof(struct ctdb_public_ip_info_wire, num) +
1787 ctdb_iface_list_len_old(in->ifaces);
1790 static void ctdb_public_ip_info_push_old(struct ctdb_public_ip_info *in,
1791 uint8_t *buf)
1793 struct ctdb_public_ip_info_wire *wire =
1794 (struct ctdb_public_ip_info_wire *)buf;
1795 size_t offset;
1797 offset = offsetof(struct ctdb_public_ip_info_wire, num);
1798 memcpy(wire, in, offset);
1799 wire->num = in->ifaces->num;
1800 memcpy(wire->ifaces, in->ifaces->iface,
1801 in->ifaces->num * sizeof(struct ctdb_iface));
1804 static int ctdb_public_ip_info_pull_old(uint8_t *buf, size_t buflen,
1805 TALLOC_CTX *mem_ctx,
1806 struct ctdb_public_ip_info **out)
1808 struct ctdb_public_ip_info *val;
1809 struct ctdb_public_ip_info_wire *wire =
1810 (struct ctdb_public_ip_info_wire *)buf;
1812 if (buflen < offsetof(struct ctdb_public_ip_info_wire, ifaces)) {
1813 return EMSGSIZE;
1815 if (wire->num > buflen / sizeof(struct ctdb_iface)) {
1816 return EMSGSIZE;
1818 if (offsetof(struct ctdb_public_ip_info_wire, ifaces) +
1819 wire->num * sizeof(struct ctdb_iface) <
1820 offsetof(struct ctdb_public_ip_info_wire, ifaces)) {
1821 return EMSGSIZE;
1823 if (buflen < offsetof(struct ctdb_public_ip_info_wire, ifaces) +
1824 wire->num * sizeof(struct ctdb_iface)) {
1825 return EMSGSIZE;
1828 val = talloc(mem_ctx, struct ctdb_public_ip_info);
1829 if (val == NULL) {
1830 return ENOMEM;
1833 memcpy(val, wire, offsetof(struct ctdb_public_ip_info_wire, num));
1835 val->ifaces = talloc(val, struct ctdb_iface_list);
1836 if (val->ifaces == NULL) {
1837 talloc_free(val);
1838 return ENOMEM;
1841 val->ifaces->num = wire->num;
1842 val->ifaces->iface = talloc_array(val->ifaces, struct ctdb_iface,
1843 wire->num);
1844 if (val->ifaces->iface == NULL) {
1845 talloc_free(val);
1846 return ENOMEM;
1849 memcpy(val->ifaces->iface, wire->ifaces,
1850 wire->num * sizeof(struct ctdb_iface));
1852 *out = val;
1853 return 0;
1856 struct ctdb_statistics_list_wire {
1857 uint32_t num;
1858 struct ctdb_statistics stats[1];
1861 static size_t ctdb_statistics_list_len_old(struct ctdb_statistics_list *in)
1863 return offsetof(struct ctdb_statistics_list_wire, stats) +
1864 in->num * sizeof(struct ctdb_statistics);
1867 static void ctdb_statistics_list_push_old(struct ctdb_statistics_list *in,
1868 uint8_t *buf)
1870 struct ctdb_statistics_list_wire *wire =
1871 (struct ctdb_statistics_list_wire *)buf;
1873 wire->num = in->num;
1874 memcpy(wire->stats, in->stats,
1875 in->num * sizeof(struct ctdb_statistics));
1878 static int ctdb_statistics_list_pull_old(uint8_t *buf, size_t buflen,
1879 TALLOC_CTX *mem_ctx,
1880 struct ctdb_statistics_list **out)
1882 struct ctdb_statistics_list *val;
1883 struct ctdb_statistics_list_wire *wire =
1884 (struct ctdb_statistics_list_wire *)buf;
1886 if (buflen < offsetof(struct ctdb_statistics_list_wire, stats)) {
1887 return EMSGSIZE;
1889 if (wire->num > buflen / sizeof(struct ctdb_statistics)) {
1890 return EMSGSIZE;
1892 if (offsetof(struct ctdb_statistics_list_wire, stats) +
1893 wire->num * sizeof(struct ctdb_statistics) <
1894 offsetof(struct ctdb_statistics_list_wire, stats)) {
1895 return EMSGSIZE;
1897 if (buflen < offsetof(struct ctdb_statistics_list_wire, stats) +
1898 wire->num * sizeof(struct ctdb_statistics)) {
1899 return EMSGSIZE;
1902 val = talloc(mem_ctx, struct ctdb_statistics_list);
1903 if (val == NULL) {
1904 return ENOMEM;
1907 val->num = wire->num;
1909 val->stats = talloc_array(val, struct ctdb_statistics, wire->num);
1910 if (val->stats == NULL) {
1911 talloc_free(val);
1912 return ENOMEM;
1915 memcpy(val->stats, wire->stats,
1916 wire->num * sizeof(struct ctdb_statistics));
1918 *out = val;
1919 return 0;
1922 struct ctdb_key_data_wire {
1923 uint32_t db_id;
1924 struct ctdb_ltdb_header header;
1925 uint32_t keylen;
1926 uint8_t key[1];
1929 static size_t ctdb_key_data_len_old(struct ctdb_key_data *in)
1931 return offsetof(struct ctdb_key_data_wire, key) + in->key.dsize;
1934 static void ctdb_key_data_push_old(struct ctdb_key_data *in, uint8_t *buf)
1936 struct ctdb_key_data_wire *wire = (struct ctdb_key_data_wire *)buf;
1938 memcpy(wire, in, offsetof(struct ctdb_key_data, key));
1939 wire->keylen = in->key.dsize;
1940 memcpy(wire->key, in->key.dptr, in->key.dsize);
1943 static int ctdb_key_data_pull_old(uint8_t *buf, size_t buflen,
1944 TALLOC_CTX *mem_ctx,
1945 struct ctdb_key_data **out)
1947 struct ctdb_key_data *val;
1948 struct ctdb_key_data_wire *wire = (struct ctdb_key_data_wire *)buf;
1950 if (buflen < offsetof(struct ctdb_key_data_wire, key)) {
1951 return EMSGSIZE;
1953 if (wire->keylen > buflen) {
1954 return EMSGSIZE;
1956 if (offsetof(struct ctdb_key_data_wire, key) + wire->keylen <
1957 offsetof(struct ctdb_key_data_wire, key)) {
1958 return EMSGSIZE;
1960 if (buflen < offsetof(struct ctdb_key_data_wire, key) + wire->keylen) {
1961 return EMSGSIZE;
1964 val = talloc(mem_ctx, struct ctdb_key_data);
1965 if (val == NULL) {
1966 return ENOMEM;
1969 memcpy(val, wire, offsetof(struct ctdb_key_data, key));
1971 val->key.dsize = wire->keylen;
1972 val->key.dptr = talloc_memdup(val, wire->key, wire->keylen);
1973 if (val->key.dptr == NULL) {
1974 talloc_free(val);
1975 return ENOMEM;
1978 *out = val;
1979 return 0;
1982 struct ctdb_db_statistics_wire {
1983 struct ctdb_db_statistics dbstats;
1984 char hot_keys_wire[1];
1987 static size_t ctdb_db_statistics_len_old(struct ctdb_db_statistics *in)
1989 size_t len;
1990 int i;
1992 len = sizeof(struct ctdb_db_statistics);
1993 for (i=0; i<MAX_HOT_KEYS; i++) {
1994 len += in->hot_keys[i].key.dsize;
1996 return len;
1999 static void ctdb_db_statistics_push_old(struct ctdb_db_statistics *in,
2000 void *buf)
2002 struct ctdb_db_statistics_wire *wire =
2003 (struct ctdb_db_statistics_wire *)buf;
2004 size_t offset;
2005 int i;
2007 in->num_hot_keys = MAX_HOT_KEYS;
2008 memcpy(wire, in, sizeof(struct ctdb_db_statistics));
2010 offset = 0;
2011 for (i=0; i<MAX_HOT_KEYS; i++) {
2012 memcpy(&wire->hot_keys_wire[offset],
2013 in->hot_keys[i].key.dptr,
2014 in->hot_keys[i].key.dsize);
2015 offset += in->hot_keys[i].key.dsize;
2019 static int ctdb_db_statistics_pull_old(uint8_t *buf, size_t buflen,
2020 TALLOC_CTX *mem_ctx,
2021 struct ctdb_db_statistics **out)
2023 struct ctdb_db_statistics *val;
2024 struct ctdb_db_statistics_wire *wire =
2025 (struct ctdb_db_statistics_wire *)buf;
2026 size_t offset;
2027 int i;
2029 if (buflen < sizeof(struct ctdb_db_statistics)) {
2030 return EMSGSIZE;
2033 offset = 0;
2034 for (i=0; i<wire->dbstats.num_hot_keys; i++) {
2035 if (wire->dbstats.hot_keys[i].key.dsize > buflen) {
2036 return EMSGSIZE;
2038 if (offset + wire->dbstats.hot_keys[i].key.dsize < offset) {
2039 return EMSGSIZE;
2041 offset += wire->dbstats.hot_keys[i].key.dsize;
2042 if (offset > buflen) {
2043 return EMSGSIZE;
2046 if (sizeof(struct ctdb_db_statistics) + offset <
2047 sizeof(struct ctdb_db_statistics)) {
2048 return EMSGSIZE;
2050 if (buflen < sizeof(struct ctdb_db_statistics) + offset) {
2051 return EMSGSIZE;
2054 val = talloc(mem_ctx, struct ctdb_db_statistics);
2055 if (val == NULL) {
2056 return ENOMEM;
2059 memcpy(val, wire, sizeof(struct ctdb_db_statistics));
2061 offset = 0;
2062 for (i=0; i<wire->dbstats.num_hot_keys; i++) {
2063 uint8_t *ptr;
2064 size_t key_size;
2066 key_size = val->hot_keys[i].key.dsize;
2067 ptr = talloc_memdup(mem_ctx, &wire->hot_keys_wire[offset],
2068 key_size);
2069 if (ptr == NULL) {
2070 talloc_free(val);
2071 return ENOMEM;
2073 val->hot_keys[i].key.dptr = ptr;
2074 offset += key_size;
2077 *out = val;
2078 return 0;
2081 static size_t ctdb_election_message_len_old(struct ctdb_election_message *in)
2083 return sizeof(struct ctdb_election_message);
2086 static void ctdb_election_message_push_old(struct ctdb_election_message *in,
2087 uint8_t *buf)
2089 memcpy(buf, in, sizeof(struct ctdb_election_message));
2092 static int ctdb_election_message_pull_old(uint8_t *buf, size_t buflen,
2093 TALLOC_CTX *mem_ctx,
2094 struct ctdb_election_message **out)
2096 struct ctdb_election_message *val;
2098 if (buflen < sizeof(struct ctdb_election_message)) {
2099 return EMSGSIZE;
2102 val = talloc_memdup(mem_ctx, buf,
2103 sizeof(struct ctdb_election_message));
2104 if (val == NULL) {
2105 return ENOMEM;
2108 *out = val;
2109 return 0;
2112 static size_t ctdb_srvid_message_len_old(struct ctdb_srvid_message *in)
2114 return sizeof(struct ctdb_srvid_message);
2117 static void ctdb_srvid_message_push_old(struct ctdb_srvid_message *in,
2118 uint8_t *buf)
2120 memcpy(buf, in, sizeof(struct ctdb_srvid_message));
2123 static int ctdb_srvid_message_pull_old(uint8_t *buf, size_t buflen,
2124 TALLOC_CTX *mem_ctx,
2125 struct ctdb_srvid_message **out)
2127 struct ctdb_srvid_message *val;
2129 if (buflen < sizeof(struct ctdb_srvid_message)) {
2130 return EMSGSIZE;
2133 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_srvid_message));
2134 if (val == NULL) {
2135 return ENOMEM;
2138 *out = val;
2139 return 0;
2142 static size_t ctdb_disable_message_len_old(struct ctdb_disable_message *in)
2144 return sizeof(struct ctdb_disable_message);
2147 static void ctdb_disable_message_push_old(struct ctdb_disable_message *in,
2148 uint8_t *buf)
2150 memcpy(buf, in, sizeof(struct ctdb_disable_message));
2153 static int ctdb_disable_message_pull_old(uint8_t *buf, size_t buflen,
2154 TALLOC_CTX *mem_ctx,
2155 struct ctdb_disable_message **out)
2157 struct ctdb_disable_message *val;
2159 if (buflen < sizeof(struct ctdb_disable_message)) {
2160 return EMSGSIZE;
2163 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_disable_message));
2164 if (val == NULL) {
2165 return ENOMEM;
2168 *out = val;
2169 return 0;
2172 static size_t ctdb_server_id_len_old(struct ctdb_server_id *in)
2174 return sizeof(struct ctdb_server_id);
2177 static void ctdb_server_id_push_old(struct ctdb_server_id *in, uint8_t *buf)
2179 memcpy(buf, in, sizeof(struct ctdb_server_id));
2182 static int ctdb_server_id_pull_old(uint8_t *buf, size_t buflen,
2183 struct ctdb_server_id *out)
2185 if (buflen < sizeof(struct ctdb_server_id)) {
2186 return EMSGSIZE;
2189 memcpy(out, buf, sizeof(struct ctdb_server_id));
2190 return 0;
2193 static size_t ctdb_g_lock_len_old(struct ctdb_g_lock *in)
2195 return sizeof(struct ctdb_g_lock);
2198 static void ctdb_g_lock_push_old(struct ctdb_g_lock *in, uint8_t *buf)
2200 memcpy(buf, in, sizeof(struct ctdb_g_lock));
2203 static int ctdb_g_lock_pull_old(uint8_t *buf, size_t buflen,
2204 struct ctdb_g_lock *out)
2206 if (buflen < sizeof(struct ctdb_g_lock)) {
2207 return EMSGSIZE;
2210 memcpy(out, buf, sizeof(struct ctdb_g_lock));
2211 return 0;
2214 static size_t ctdb_g_lock_list_len_old(struct ctdb_g_lock_list *in)
2216 return in->num * sizeof(struct ctdb_g_lock);
2219 static void ctdb_g_lock_list_push_old(struct ctdb_g_lock_list *in,
2220 uint8_t *buf)
2222 size_t offset = 0;
2223 int i;
2225 for (i=0; i<in->num; i++) {
2226 ctdb_g_lock_push_old(&in->lock[i], &buf[offset]);
2227 offset += sizeof(struct ctdb_g_lock);
2231 static int ctdb_g_lock_list_pull_old(uint8_t *buf, size_t buflen,
2232 TALLOC_CTX *mem_ctx,
2233 struct ctdb_g_lock_list **out)
2235 struct ctdb_g_lock_list *val;
2236 unsigned count;
2237 size_t offset;
2238 int ret, i;
2240 val = talloc_zero(mem_ctx, struct ctdb_g_lock_list);
2241 if (val == NULL) {
2242 return ENOMEM;
2245 count = buflen / sizeof(struct ctdb_g_lock);
2246 val->lock = talloc_array(val, struct ctdb_g_lock, count);
2247 if (val->lock == NULL) {
2248 talloc_free(val);
2249 return ENOMEM;
2252 offset = 0;
2253 for (i=0; i<count; i++) {
2254 ret = ctdb_g_lock_pull_old(&buf[offset], buflen-offset,
2255 &val->lock[i]);
2256 if (ret != 0) {
2257 talloc_free(val);
2258 return ret;
2260 offset += sizeof(struct ctdb_g_lock);
2263 val->num = count;
2265 *out = val;
2266 return 0;
2269 COMPAT_TYPE3_TEST(struct ctdb_statistics, ctdb_statistics);
2270 COMPAT_TYPE3_TEST(struct ctdb_vnn_map, ctdb_vnn_map);
2271 COMPAT_TYPE3_TEST(struct ctdb_dbid_map, ctdb_dbid_map);
2272 COMPAT_TYPE3_TEST(struct ctdb_pulldb, ctdb_pulldb);
2273 COMPAT_TYPE3_TEST(struct ctdb_pulldb_ext, ctdb_pulldb_ext);
2275 COMPAT_TYPE1_TEST(struct ctdb_ltdb_header, ctdb_ltdb_header);
2277 COMPAT_TYPE3_TEST(struct ctdb_rec_data, ctdb_rec_data);
2278 COMPAT_TYPE3_TEST(struct ctdb_rec_buffer, ctdb_rec_buffer);
2279 COMPAT_TYPE3_TEST(struct ctdb_traverse_start, ctdb_traverse_start);
2280 COMPAT_TYPE3_TEST(struct ctdb_traverse_all, ctdb_traverse_all);
2281 COMPAT_TYPE3_TEST(struct ctdb_traverse_start_ext, ctdb_traverse_start_ext);
2282 COMPAT_TYPE3_TEST(struct ctdb_traverse_all_ext, ctdb_traverse_all_ext);
2283 COMPAT_TYPE3_TEST(ctdb_sock_addr, ctdb_sock_addr);
2284 COMPAT_TYPE3_TEST(struct ctdb_connection, ctdb_connection);
2285 COMPAT_TYPE3_TEST(struct ctdb_tunable, ctdb_tunable);
2286 COMPAT_TYPE3_TEST(struct ctdb_node_flag_change, ctdb_node_flag_change);
2287 COMPAT_TYPE3_TEST(struct ctdb_var_list, ctdb_var_list);
2288 COMPAT_TYPE3_TEST(struct ctdb_tunable_list, ctdb_tunable_list);
2289 COMPAT_TYPE3_TEST(struct ctdb_tickle_list, ctdb_tickle_list);
2290 COMPAT_TYPE3_TEST(struct ctdb_addr_info, ctdb_addr_info);
2291 COMPAT_TYPE3_TEST(struct ctdb_transdb, ctdb_transdb);
2292 COMPAT_TYPE3_TEST(struct ctdb_uptime, ctdb_uptime);
2293 COMPAT_TYPE3_TEST(struct ctdb_public_ip, ctdb_public_ip);
2294 COMPAT_TYPE3_TEST(struct ctdb_public_ip_list, ctdb_public_ip_list);
2295 COMPAT_TYPE3_TEST(struct ctdb_node_and_flags, ctdb_node_and_flags);
2296 COMPAT_TYPE3_TEST(struct ctdb_node_map, ctdb_node_map);
2297 COMPAT_TYPE3_TEST(struct ctdb_script, ctdb_script);
2298 COMPAT_TYPE3_TEST(struct ctdb_script_list, ctdb_script_list);
2299 COMPAT_TYPE3_TEST(struct ctdb_ban_state, ctdb_ban_state);
2300 COMPAT_TYPE3_TEST(struct ctdb_notify_data, ctdb_notify_data);
2301 COMPAT_TYPE3_TEST(struct ctdb_iface, ctdb_iface);
2302 COMPAT_TYPE3_TEST(struct ctdb_iface_list, ctdb_iface_list);
2303 COMPAT_TYPE3_TEST(struct ctdb_public_ip_info, ctdb_public_ip_info);
2304 COMPAT_TYPE3_TEST(struct ctdb_statistics_list, ctdb_statistics_list);
2305 COMPAT_TYPE3_TEST(struct ctdb_key_data, ctdb_key_data);
2306 COMPAT_TYPE3_TEST(struct ctdb_db_statistics, ctdb_db_statistics);
2308 COMPAT_TYPE3_TEST(struct ctdb_election_message, ctdb_election_message);
2309 COMPAT_TYPE3_TEST(struct ctdb_srvid_message, ctdb_srvid_message);
2310 COMPAT_TYPE3_TEST(struct ctdb_disable_message, ctdb_disable_message);
2312 COMPAT_TYPE1_TEST(struct ctdb_server_id, ctdb_server_id);
2313 COMPAT_TYPE1_TEST(struct ctdb_g_lock, ctdb_g_lock);
2315 COMPAT_TYPE3_TEST(struct ctdb_g_lock_list, ctdb_g_lock_list);
2317 int main(int argc, char *argv[])
2319 if (argc == 2) {
2320 int seed = atoi(argv[1]);
2321 srandom(seed);
2324 COMPAT_TEST_FUNC(ctdb_statistics)();
2325 COMPAT_TEST_FUNC(ctdb_vnn_map)();
2326 COMPAT_TEST_FUNC(ctdb_dbid_map)();
2327 COMPAT_TEST_FUNC(ctdb_pulldb)();
2328 COMPAT_TEST_FUNC(ctdb_pulldb_ext)();
2329 COMPAT_TEST_FUNC(ctdb_ltdb_header)();
2330 COMPAT_TEST_FUNC(ctdb_rec_data)();
2331 COMPAT_TEST_FUNC(ctdb_rec_buffer)();
2332 COMPAT_TEST_FUNC(ctdb_traverse_start)();
2333 COMPAT_TEST_FUNC(ctdb_traverse_all)();
2334 COMPAT_TEST_FUNC(ctdb_traverse_start_ext)();
2335 COMPAT_TEST_FUNC(ctdb_traverse_all_ext)();
2336 COMPAT_TEST_FUNC(ctdb_sock_addr)();
2337 COMPAT_TEST_FUNC(ctdb_connection)();
2338 COMPAT_TEST_FUNC(ctdb_tunable)();
2339 COMPAT_TEST_FUNC(ctdb_node_flag_change)();
2340 COMPAT_TEST_FUNC(ctdb_var_list)();
2341 COMPAT_TEST_FUNC(ctdb_tunable_list)();
2342 COMPAT_TEST_FUNC(ctdb_tickle_list)();
2343 COMPAT_TEST_FUNC(ctdb_addr_info)();
2344 COMPAT_TEST_FUNC(ctdb_transdb)();
2345 COMPAT_TEST_FUNC(ctdb_uptime)();
2346 COMPAT_TEST_FUNC(ctdb_public_ip)();
2347 COMPAT_TEST_FUNC(ctdb_public_ip_list)();
2348 COMPAT_TEST_FUNC(ctdb_node_and_flags)();
2349 COMPAT_TEST_FUNC(ctdb_node_map)();
2350 COMPAT_TEST_FUNC(ctdb_script)();
2351 COMPAT_TEST_FUNC(ctdb_script_list)();
2352 COMPAT_TEST_FUNC(ctdb_ban_state)();
2353 COMPAT_TEST_FUNC(ctdb_notify_data)();
2354 COMPAT_TEST_FUNC(ctdb_iface)();
2355 COMPAT_TEST_FUNC(ctdb_iface_list)();
2356 COMPAT_TEST_FUNC(ctdb_public_ip_info)();
2357 COMPAT_TEST_FUNC(ctdb_statistics_list)();
2358 COMPAT_TEST_FUNC(ctdb_key_data)();
2359 COMPAT_TEST_FUNC(ctdb_db_statistics)();
2361 COMPAT_TEST_FUNC(ctdb_election_message)();
2362 COMPAT_TEST_FUNC(ctdb_srvid_message)();
2363 COMPAT_TEST_FUNC(ctdb_disable_message)();
2364 COMPAT_TEST_FUNC(ctdb_server_id)();
2365 COMPAT_TEST_FUNC(ctdb_g_lock)();
2366 COMPAT_TEST_FUNC(ctdb_g_lock_list)();
2368 return 0;