ctdb-tests: Iterate protocol tests internally
[samba.git] / ctdb / tests / src / protocol_types_compat_test.c
blob140ea86078cf6ba38bb553b98775819c1ad91743
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 assert(in->var[i] != NULL);
842 len += strlen(in->var[i]) + 1;
844 return len;
847 static void ctdb_var_list_push_old(struct ctdb_var_list *in, uint8_t *buf)
849 struct ctdb_var_list_wire *wire = (struct ctdb_var_list_wire *)buf;
850 int i, n;
851 size_t offset = 0;
853 if (in->count > 0) {
854 n = sprintf(wire->list_str, "%s", in->var[0]);
855 offset += n;
857 for (i=1; i<in->count; i++) {
858 n = sprintf(&wire->list_str[offset], ":%s", in->var[i]);
859 offset += n;
861 wire->length = offset + 1;
864 static int ctdb_var_list_pull_old(uint8_t *buf, size_t buflen,
865 TALLOC_CTX *mem_ctx,
866 struct ctdb_var_list **out)
868 struct ctdb_var_list *val = NULL;
869 struct ctdb_var_list_wire *wire = (struct ctdb_var_list_wire *)buf;
870 char *str, *s, *tok, *ptr;
871 const char **list;
873 if (buflen < sizeof(uint32_t)) {
874 return EMSGSIZE;
876 if (wire->length > buflen) {
877 return EMSGSIZE;
879 if (sizeof(uint32_t) + wire->length < sizeof(uint32_t)) {
880 return EMSGSIZE;
882 if (buflen < sizeof(uint32_t) + wire->length) {
883 return EMSGSIZE;
886 str = talloc_strndup(mem_ctx, (char *)wire->list_str, wire->length);
887 if (str == NULL) {
888 return ENOMEM;
891 val = talloc_zero(mem_ctx, struct ctdb_var_list);
892 if (val == NULL) {
893 goto fail;
896 s = str;
897 while ((tok = strtok_r(s, ":", &ptr)) != NULL) {
898 s = NULL;
899 list = talloc_realloc(val, val->var, const char *,
900 val->count+1);
901 if (list == NULL) {
902 goto fail;
905 val->var = list;
906 val->var[val->count] = talloc_strdup(val, tok);
907 if (val->var[val->count] == NULL) {
908 goto fail;
910 val->count++;
913 talloc_free(str);
914 *out = val;
915 return 0;
917 fail:
918 talloc_free(str);
919 talloc_free(val);
920 return ENOMEM;
923 static size_t ctdb_tunable_list_len_old(struct ctdb_tunable_list *in)
925 return sizeof(struct ctdb_tunable_list);
928 static void ctdb_tunable_list_push_old(struct ctdb_tunable_list *in,
929 uint8_t *buf)
931 memcpy(buf, in, sizeof(struct ctdb_tunable_list));
934 static int ctdb_tunable_list_pull_old(uint8_t *buf, size_t buflen,
935 TALLOC_CTX *mem_ctx,
936 struct ctdb_tunable_list **out)
938 struct ctdb_tunable_list *val;
940 if (buflen < sizeof(struct ctdb_tunable_list)) {
941 return EMSGSIZE;
944 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_tunable_list));
945 if (val == NULL) {
946 return ENOMEM;
949 *out = val;
950 return 0;
953 struct ctdb_tickle_list_wire {
954 ctdb_sock_addr addr;
955 uint32_t num;
956 struct ctdb_connection conn[1];
959 static size_t ctdb_tickle_list_len_old(struct ctdb_tickle_list *in)
961 return offsetof(struct ctdb_tickle_list, conn) +
962 in->num * sizeof(struct ctdb_connection);
965 static void ctdb_tickle_list_push_old(struct ctdb_tickle_list *in,
966 uint8_t *buf)
968 struct ctdb_tickle_list_wire *wire =
969 (struct ctdb_tickle_list_wire *)buf;
970 size_t offset;
971 unsigned int i;
973 memcpy(&wire->addr, &in->addr, sizeof(ctdb_sock_addr));
974 wire->num = in->num;
976 offset = offsetof(struct ctdb_tickle_list_wire, conn);
977 for (i=0; i<in->num; i++) {
978 ctdb_connection_push_old(&in->conn[i], &buf[offset]);
979 offset += ctdb_connection_len_old(&in->conn[i]);
983 static int ctdb_tickle_list_pull_old(uint8_t *buf, size_t buflen,
984 TALLOC_CTX *mem_ctx,
985 struct ctdb_tickle_list **out)
987 struct ctdb_tickle_list *val;
988 struct ctdb_tickle_list_wire *wire =
989 (struct ctdb_tickle_list_wire *)buf;
990 size_t offset;
991 unsigned int i;
992 int ret;
994 if (buflen < offsetof(struct ctdb_tickle_list_wire, conn)) {
995 return EMSGSIZE;
997 if (wire->num > buflen / sizeof(struct ctdb_connection)) {
998 return EMSGSIZE;
1000 if (offsetof(struct ctdb_tickle_list_wire, conn) +
1001 wire->num * sizeof(struct ctdb_connection) <
1002 offsetof(struct ctdb_tickle_list_wire, conn)) {
1003 return EMSGSIZE;
1005 if (buflen < offsetof(struct ctdb_tickle_list_wire, conn) +
1006 wire->num * sizeof(struct ctdb_connection)) {
1007 return EMSGSIZE;
1010 val = talloc(mem_ctx, struct ctdb_tickle_list);
1011 if (val == NULL) {
1012 return ENOMEM;
1015 offset = offsetof(struct ctdb_tickle_list, conn);
1016 memcpy(val, wire, offset);
1018 val->conn = talloc_array(val, struct ctdb_connection, wire->num);
1019 if (val->conn == NULL) {
1020 talloc_free(val);
1021 return ENOMEM;
1024 for (i=0; i<wire->num; i++) {
1025 ret = ctdb_connection_pull_elems_old(&buf[offset],
1026 buflen-offset,
1027 val->conn,
1028 &val->conn[i]);
1029 if (ret != 0) {
1030 talloc_free(val);
1031 return ret;
1033 offset += ctdb_connection_len_old(&val->conn[i]);
1036 *out = val;
1037 return 0;
1040 struct ctdb_addr_info_wire {
1041 ctdb_sock_addr addr;
1042 uint32_t mask;
1043 uint32_t len;
1044 char iface[1];
1047 static size_t ctdb_addr_info_len_old(struct ctdb_addr_info *in)
1049 uint32_t len;
1051 len = offsetof(struct ctdb_addr_info_wire, iface);
1052 if (in->iface != NULL) {
1053 len += strlen(in->iface)+1;
1056 return len;
1059 static void ctdb_addr_info_push_old(struct ctdb_addr_info *in, uint8_t *buf)
1061 struct ctdb_addr_info_wire *wire = (struct ctdb_addr_info_wire *)buf;
1063 wire->addr = in->addr;
1064 wire->mask = in->mask;
1065 if (in->iface == NULL) {
1066 wire->len = 0;
1067 } else {
1068 wire->len = strlen(in->iface)+1;
1069 memcpy(wire->iface, in->iface, wire->len);
1073 static int ctdb_addr_info_pull_old(uint8_t *buf, size_t buflen,
1074 TALLOC_CTX *mem_ctx,
1075 struct ctdb_addr_info **out)
1077 struct ctdb_addr_info *val;
1078 struct ctdb_addr_info_wire *wire = (struct ctdb_addr_info_wire *)buf;
1080 if (buflen < offsetof(struct ctdb_addr_info_wire, iface)) {
1081 return EMSGSIZE;
1083 if (wire->len > buflen) {
1084 return EMSGSIZE;
1086 if (offsetof(struct ctdb_addr_info_wire, iface) + wire->len <
1087 offsetof(struct ctdb_addr_info_wire, iface)) {
1088 return EMSGSIZE;
1090 if (buflen < offsetof(struct ctdb_addr_info_wire, iface) + wire->len) {
1091 return EMSGSIZE;
1094 val = talloc(mem_ctx, struct ctdb_addr_info);
1095 if (val == NULL) {
1096 return ENOMEM;
1099 val->addr = wire->addr;
1100 val->mask = wire->mask;
1102 if (wire->len == 0) {
1103 val->iface = NULL;
1104 } else {
1105 val->iface = talloc_strndup(val, wire->iface, wire->len);
1106 if (val->iface == NULL) {
1107 talloc_free(val);
1108 return ENOMEM;
1112 *out = val;
1113 return 0;
1116 static size_t ctdb_transdb_len_old(struct ctdb_transdb *in)
1118 return sizeof(struct ctdb_transdb);
1121 static void ctdb_transdb_push_old(struct ctdb_transdb *in, uint8_t *buf)
1123 memcpy(buf, in, sizeof(struct ctdb_transdb));
1126 static int ctdb_transdb_pull_old(uint8_t *buf, size_t buflen,
1127 TALLOC_CTX *mem_ctx,
1128 struct ctdb_transdb **out)
1130 struct ctdb_transdb *val;
1132 if (buflen < sizeof(struct ctdb_transdb)) {
1133 return EMSGSIZE;
1136 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_transdb));
1137 if (val == NULL) {
1138 return ENOMEM;
1141 *out = val;
1142 return 0;
1145 static size_t ctdb_uptime_len_old(struct ctdb_uptime *in)
1147 return sizeof(struct ctdb_uptime);
1150 static void ctdb_uptime_push_old(struct ctdb_uptime *in, uint8_t *buf)
1152 memcpy(buf, in, sizeof(struct ctdb_uptime));
1155 static int ctdb_uptime_pull_old(uint8_t *buf, size_t buflen,
1156 TALLOC_CTX *mem_ctx, struct ctdb_uptime **out)
1158 struct ctdb_uptime *val;
1160 if (buflen < sizeof(struct ctdb_uptime)) {
1161 return EMSGSIZE;
1164 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_uptime));
1165 if (val == NULL) {
1166 return ENOMEM;
1169 *out = val;
1170 return 0;
1173 static size_t ctdb_public_ip_len_old(struct ctdb_public_ip *in)
1175 return sizeof(struct ctdb_public_ip);
1178 static void ctdb_public_ip_push_old(struct ctdb_public_ip *in, uint8_t *buf)
1180 memcpy(buf, in, sizeof(struct ctdb_public_ip));
1183 static int ctdb_public_ip_pull_elems_old(uint8_t *buf, size_t buflen,
1184 TALLOC_CTX *mem_ctx,
1185 struct ctdb_public_ip *out)
1187 if (buflen < sizeof(struct ctdb_public_ip)) {
1188 return EMSGSIZE;
1191 memcpy(out, buf, sizeof(struct ctdb_public_ip));
1193 return 0;
1196 static int ctdb_public_ip_pull_old(uint8_t *buf, size_t buflen,
1197 TALLOC_CTX *mem_ctx,
1198 struct ctdb_public_ip **out)
1200 struct ctdb_public_ip *val;
1201 int ret;
1203 val = talloc(mem_ctx, struct ctdb_public_ip);
1204 if (val == NULL) {
1205 return ENOMEM;
1208 ret = ctdb_public_ip_pull_elems_old(buf, buflen, val, val);
1209 if (ret != 0) {
1210 TALLOC_FREE(val);
1211 return ret;
1214 *out = val;
1215 return ret;
1218 struct ctdb_public_ip_list_wire {
1219 uint32_t num;
1220 struct ctdb_public_ip ip[1];
1223 static size_t ctdb_public_ip_list_len_old(struct ctdb_public_ip_list *in)
1225 unsigned int i;
1226 size_t len;
1228 len = sizeof(uint32_t);
1229 for (i=0; i<in->num; i++) {
1230 len += ctdb_public_ip_len_old(&in->ip[i]);
1232 return len;
1235 static void ctdb_public_ip_list_push_old(struct ctdb_public_ip_list *in,
1236 uint8_t *buf)
1238 struct ctdb_public_ip_list_wire *wire =
1239 (struct ctdb_public_ip_list_wire *)buf;
1240 size_t offset;
1241 unsigned int i;
1243 wire->num = in->num;
1245 offset = offsetof(struct ctdb_public_ip_list_wire, ip);
1246 for (i=0; i<in->num; i++) {
1247 ctdb_public_ip_push_old(&in->ip[i], &buf[offset]);
1248 offset += ctdb_public_ip_len_old(&in->ip[i]);
1252 static int ctdb_public_ip_list_pull_old(uint8_t *buf, size_t buflen,
1253 TALLOC_CTX *mem_ctx,
1254 struct ctdb_public_ip_list **out)
1256 struct ctdb_public_ip_list *val;
1257 struct ctdb_public_ip_list_wire *wire =
1258 (struct ctdb_public_ip_list_wire *)buf;
1259 size_t offset;
1260 unsigned int i;
1261 bool ret;
1263 if (buflen < sizeof(uint32_t)) {
1264 return EMSGSIZE;
1266 if (wire->num > buflen / sizeof(struct ctdb_public_ip)) {
1267 return EMSGSIZE;
1269 if (sizeof(uint32_t) + wire->num * sizeof(struct ctdb_public_ip) <
1270 sizeof(uint32_t)) {
1271 return EMSGSIZE;
1273 if (buflen < sizeof(uint32_t) +
1274 wire->num * sizeof(struct ctdb_public_ip)) {
1275 return EMSGSIZE;
1278 val = talloc(mem_ctx, struct ctdb_public_ip_list);
1279 if (val == NULL) {
1280 return ENOMEM;
1283 val->num = wire->num;
1284 if (wire->num == 0) {
1285 val->ip = NULL;
1286 *out = val;
1287 return 0;
1289 val->ip = talloc_array(val, struct ctdb_public_ip, wire->num);
1290 if (val->ip == NULL) {
1291 talloc_free(val);
1292 return ENOMEM;
1295 offset = offsetof(struct ctdb_public_ip_list_wire, ip);
1296 for (i=0; i<wire->num; i++) {
1297 ret = ctdb_public_ip_pull_elems_old(&buf[offset],
1298 buflen-offset,
1299 val->ip,
1300 &val->ip[i]);
1301 if (ret != 0) {
1302 talloc_free(val);
1303 return ret;
1305 offset += ctdb_public_ip_len_old(&val->ip[i]);
1308 *out = val;
1309 return 0;
1312 static size_t ctdb_node_and_flags_len_old(struct ctdb_node_and_flags *in)
1314 return sizeof(struct ctdb_node_and_flags);
1317 static void ctdb_node_and_flags_push_old(struct ctdb_node_and_flags *in,
1318 uint8_t *buf)
1320 memcpy(buf, in, sizeof(struct ctdb_node_and_flags));
1323 static int ctdb_node_and_flags_pull_elems_old(TALLOC_CTX *mem_ctx,
1324 uint8_t *buf, size_t buflen,
1325 struct ctdb_node_and_flags *out)
1327 if (buflen < sizeof(struct ctdb_node_and_flags)) {
1328 return EMSGSIZE;
1331 memcpy(out, buf, sizeof(struct ctdb_node_and_flags));
1333 return 0;
1336 static int ctdb_node_and_flags_pull_old(uint8_t *buf, size_t buflen,
1337 TALLOC_CTX *mem_ctx,
1338 struct ctdb_node_and_flags **out)
1340 struct ctdb_node_and_flags *val;
1341 int ret;
1343 val = talloc(mem_ctx, struct ctdb_node_and_flags);
1344 if (val == NULL) {
1345 return ENOMEM;
1348 ret = ctdb_node_and_flags_pull_elems_old(val, buf, buflen, val);
1349 if (ret != 0) {
1350 TALLOC_FREE(val);
1351 return ret;
1354 *out = val;
1355 return ret;
1358 struct ctdb_node_map_wire {
1359 uint32_t num;
1360 struct ctdb_node_and_flags node[1];
1363 static size_t ctdb_node_map_len_old(struct ctdb_node_map *in)
1365 return sizeof(uint32_t) +
1366 in->num * sizeof(struct ctdb_node_and_flags);
1369 static void ctdb_node_map_push_old(struct ctdb_node_map *in, uint8_t *buf)
1371 struct ctdb_node_map_wire *wire = (struct ctdb_node_map_wire *)buf;
1372 size_t offset;
1373 unsigned int i;
1375 wire->num = in->num;
1377 offset = offsetof(struct ctdb_node_map_wire, node);
1378 for (i=0; i<in->num; i++) {
1379 ctdb_node_and_flags_push_old(&in->node[i], &buf[offset]);
1380 offset += ctdb_node_and_flags_len_old(&in->node[i]);
1384 static int ctdb_node_map_pull_old(uint8_t *buf, size_t buflen,
1385 TALLOC_CTX *mem_ctx,
1386 struct ctdb_node_map **out)
1388 struct ctdb_node_map *val;
1389 struct ctdb_node_map_wire *wire = (struct ctdb_node_map_wire *)buf;
1390 size_t offset;
1391 unsigned int i;
1392 bool ret;
1394 if (buflen < sizeof(uint32_t)) {
1395 return EMSGSIZE;
1397 if (wire->num > buflen / sizeof(struct ctdb_node_and_flags)) {
1398 return EMSGSIZE;
1400 if (sizeof(uint32_t) + wire->num * sizeof(struct ctdb_node_and_flags) <
1401 sizeof(uint32_t)) {
1402 return EMSGSIZE;
1404 if (buflen < sizeof(uint32_t) +
1405 wire->num * sizeof(struct ctdb_node_and_flags)) {
1406 return EMSGSIZE;
1409 val = talloc(mem_ctx, struct ctdb_node_map);
1410 if (val == NULL) {
1411 return ENOMEM;
1414 val->num = wire->num;
1415 val->node = talloc_array(val, struct ctdb_node_and_flags, wire->num);
1416 if (val->node == NULL) {
1417 talloc_free(val);
1418 return ENOMEM;
1421 offset = offsetof(struct ctdb_node_map_wire, node);
1422 for (i=0; i<wire->num; i++) {
1423 ret = ctdb_node_and_flags_pull_elems_old(val->node,
1424 &buf[offset],
1425 buflen-offset,
1426 &val->node[i]);
1427 if (ret != 0) {
1428 talloc_free(val);
1429 return ret;
1431 offset += ctdb_node_and_flags_len_old(&val->node[i]);
1434 *out = val;
1435 return 0;
1438 static size_t ctdb_script_len_old(struct ctdb_script *in)
1440 return sizeof(struct ctdb_script);
1443 static void ctdb_script_push_old(struct ctdb_script *in, uint8_t *buf)
1445 memcpy(buf, in, sizeof(struct ctdb_script));
1448 static int ctdb_script_pull_elems_old(uint8_t *buf, size_t buflen,
1449 TALLOC_CTX *mem_ctx,
1450 struct ctdb_script *out)
1452 if (buflen < sizeof(struct ctdb_script)) {
1453 return EMSGSIZE;
1456 memcpy(out, buf, sizeof(struct ctdb_script));
1458 return 0;
1461 static int ctdb_script_pull_old(uint8_t *buf, size_t buflen,
1462 TALLOC_CTX *mem_ctx, struct ctdb_script **out)
1464 struct ctdb_script *val;
1465 int ret;
1467 val = talloc(mem_ctx, struct ctdb_script);
1468 if (val == NULL) {
1469 return ENOMEM;
1472 ret = ctdb_script_pull_elems_old(buf, buflen, val, val);
1473 if (ret != 0) {
1474 TALLOC_FREE(val);
1475 return ret;
1478 *out = val;
1479 return ret;
1482 struct ctdb_script_list_wire {
1483 uint32_t num_scripts;
1484 struct ctdb_script script[1];
1487 static size_t ctdb_script_list_len_old(struct ctdb_script_list *in)
1489 unsigned int i;
1490 size_t len;
1492 if (in == NULL) {
1493 return 0;
1496 len = offsetof(struct ctdb_script_list_wire, script);
1497 for (i=0; i<in->num_scripts; i++) {
1498 len += ctdb_script_len_old(&in->script[i]);
1500 return len;
1503 static void ctdb_script_list_push_old(struct ctdb_script_list *in,
1504 uint8_t *buf)
1506 struct ctdb_script_list_wire *wire =
1507 (struct ctdb_script_list_wire *)buf;
1508 size_t offset;
1509 unsigned int i;
1511 if (in == NULL) {
1512 return;
1515 wire->num_scripts = in->num_scripts;
1517 offset = offsetof(struct ctdb_script_list_wire, script);
1518 for (i=0; i<in->num_scripts; i++) {
1519 ctdb_script_push_old(&in->script[i], &buf[offset]);
1520 offset += ctdb_script_len_old(&in->script[i]);
1524 static int ctdb_script_list_pull_old(uint8_t *buf, size_t buflen,
1525 TALLOC_CTX *mem_ctx,
1526 struct ctdb_script_list **out)
1528 struct ctdb_script_list *val;
1529 struct ctdb_script_list_wire *wire =
1530 (struct ctdb_script_list_wire *)buf;
1531 size_t offset;
1532 unsigned int i;
1533 bool ret;
1535 /* If event scripts have never been run, the result will be NULL */
1536 if (buflen == 0) {
1537 *out = NULL;
1538 return 0;
1541 offset = offsetof(struct ctdb_script_list_wire, script);
1543 if (buflen < offset) {
1544 return EMSGSIZE;
1546 if (wire->num_scripts > buflen / sizeof(struct ctdb_script)) {
1547 return EMSGSIZE;
1549 if (offset + wire->num_scripts * sizeof(struct ctdb_script) < offset) {
1550 return EMSGSIZE;
1552 if (buflen < offset + wire->num_scripts * sizeof(struct ctdb_script)) {
1553 return EMSGSIZE;
1556 val = talloc(mem_ctx, struct ctdb_script_list);
1557 if (val == NULL) {
1558 return ENOMEM;
1562 val->num_scripts = wire->num_scripts;
1563 val->script = talloc_array(val, struct ctdb_script, wire->num_scripts);
1564 if (val->script == NULL) {
1565 talloc_free(val);
1566 return ENOMEM;
1569 for (i=0; i<wire->num_scripts; i++) {
1570 ret = ctdb_script_pull_elems_old(&buf[offset], buflen-offset,
1571 val->script,
1572 &val->script[i]);
1573 if (ret != 0) {
1574 talloc_free(val);
1575 return ret;
1577 offset += ctdb_script_len_old(&val->script[i]);
1580 *out = val;
1581 return 0;
1584 static size_t ctdb_ban_state_len_old(struct ctdb_ban_state *in)
1586 return sizeof(struct ctdb_ban_state);
1589 static void ctdb_ban_state_push_old(struct ctdb_ban_state *in, uint8_t *buf)
1591 memcpy(buf, in, sizeof(struct ctdb_ban_state));
1594 static int ctdb_ban_state_pull_old(uint8_t *buf, size_t buflen,
1595 TALLOC_CTX *mem_ctx,
1596 struct ctdb_ban_state **out)
1598 struct ctdb_ban_state *val;
1600 if (buflen < sizeof(struct ctdb_ban_state)) {
1601 return EMSGSIZE;
1604 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_ban_state));
1605 if (val == NULL) {
1606 return ENOMEM;
1609 *out = val;
1610 return 0;
1613 struct ctdb_notify_data_wire {
1614 uint64_t srvid;
1615 uint32_t len;
1616 uint8_t data[1];
1619 static size_t ctdb_notify_data_len_old(struct ctdb_notify_data *in)
1621 return offsetof(struct ctdb_notify_data_wire, data) +
1622 in->data.dsize;
1625 static void ctdb_notify_data_push_old(struct ctdb_notify_data *in,
1626 uint8_t *buf)
1628 struct ctdb_notify_data_wire *wire =
1629 (struct ctdb_notify_data_wire *)buf;
1631 wire->srvid = in->srvid;
1632 wire->len = in->data.dsize;
1633 memcpy(wire->data, in->data.dptr, in->data.dsize);
1636 static int ctdb_notify_data_pull_old(uint8_t *buf, size_t buflen,
1637 TALLOC_CTX *mem_ctx,
1638 struct ctdb_notify_data **out)
1640 struct ctdb_notify_data *val;
1641 struct ctdb_notify_data_wire *wire =
1642 (struct ctdb_notify_data_wire *)buf;
1644 if (buflen < offsetof(struct ctdb_notify_data_wire, data)) {
1645 return EMSGSIZE;
1647 if (wire->len > buflen) {
1648 return EMSGSIZE;
1650 if (offsetof(struct ctdb_notify_data_wire, data) + wire->len <
1651 offsetof(struct ctdb_notify_data_wire, data)) {
1652 return EMSGSIZE;
1654 if (buflen < offsetof(struct ctdb_notify_data_wire, data) + wire->len) {
1655 return EMSGSIZE;
1658 val = talloc(mem_ctx, struct ctdb_notify_data);
1659 if (val == NULL) {
1660 return ENOMEM;
1663 val->srvid = wire->srvid;
1664 val->data.dsize = wire->len;
1665 val->data.dptr = talloc_memdup(val, wire->data, wire->len);
1666 if (val->data.dptr == NULL) {
1667 talloc_free(val);
1668 return ENOMEM;
1671 *out = val;
1672 return 0;
1675 static size_t ctdb_iface_len_old(struct ctdb_iface *in)
1677 return sizeof(struct ctdb_iface);
1680 static void ctdb_iface_push_old(struct ctdb_iface *in, uint8_t *buf)
1682 memcpy(buf, in, sizeof(struct ctdb_iface));
1685 static int ctdb_iface_pull_elems_old(uint8_t *buf, size_t buflen,
1686 TALLOC_CTX *mem_ctx,
1687 struct ctdb_iface *out)
1689 if (buflen < sizeof(struct ctdb_iface)) {
1690 return EMSGSIZE;
1693 memcpy(out, buf, sizeof(struct ctdb_iface));
1695 return 0;
1698 static int ctdb_iface_pull_old(uint8_t *buf, size_t buflen,
1699 TALLOC_CTX *mem_ctx, struct ctdb_iface **out)
1701 struct ctdb_iface *val;
1702 int ret;
1704 val = talloc(mem_ctx, struct ctdb_iface);
1705 if (val == NULL) {
1706 return ENOMEM;
1709 ret = ctdb_iface_pull_elems_old(buf, buflen, val, val);
1710 if (ret != 0) {
1711 TALLOC_FREE(val);
1712 return ret;
1715 *out = val;
1716 return ret;
1719 struct ctdb_iface_list_wire {
1720 uint32_t num;
1721 struct ctdb_iface iface[1];
1724 static size_t ctdb_iface_list_len_old(struct ctdb_iface_list *in)
1726 return sizeof(uint32_t) +
1727 in->num * sizeof(struct ctdb_iface);
1730 static void ctdb_iface_list_push_old(struct ctdb_iface_list *in, uint8_t *buf)
1732 struct ctdb_iface_list_wire *wire =
1733 (struct ctdb_iface_list_wire *)buf;
1735 wire->num = in->num;
1736 memcpy(wire->iface, in->iface, in->num * sizeof(struct ctdb_iface));
1739 static int ctdb_iface_list_pull_old(uint8_t *buf, size_t buflen,
1740 TALLOC_CTX *mem_ctx,
1741 struct ctdb_iface_list **out)
1743 struct ctdb_iface_list *val;
1744 struct ctdb_iface_list_wire *wire =
1745 (struct ctdb_iface_list_wire *)buf;
1747 if (buflen < sizeof(uint32_t)) {
1748 return EMSGSIZE;
1750 if (wire->num > buflen / sizeof(struct ctdb_iface)) {
1751 return EMSGSIZE;
1753 if (sizeof(uint32_t) + wire->num * sizeof(struct ctdb_iface) <
1754 sizeof(uint32_t)) {
1755 return EMSGSIZE;
1757 if (buflen < sizeof(uint32_t) + wire->num * sizeof(struct ctdb_iface)) {
1758 return EMSGSIZE;
1761 val = talloc(mem_ctx, struct ctdb_iface_list);
1762 if (val == NULL) {
1763 return ENOMEM;
1766 val->num = wire->num;
1767 val->iface = talloc_array(val, struct ctdb_iface, wire->num);
1768 if (val->iface == NULL) {
1769 talloc_free(val);
1770 return ENOMEM;
1773 memcpy(val->iface, wire->iface, wire->num * sizeof(struct ctdb_iface));
1775 *out = val;
1776 return 0;
1779 struct ctdb_public_ip_info_wire {
1780 struct ctdb_public_ip ip;
1781 uint32_t active_idx;
1782 uint32_t num;
1783 struct ctdb_iface ifaces[1];
1786 static size_t ctdb_public_ip_info_len_old(struct ctdb_public_ip_info *in)
1788 return offsetof(struct ctdb_public_ip_info_wire, num) +
1789 ctdb_iface_list_len_old(in->ifaces);
1792 static void ctdb_public_ip_info_push_old(struct ctdb_public_ip_info *in,
1793 uint8_t *buf)
1795 struct ctdb_public_ip_info_wire *wire =
1796 (struct ctdb_public_ip_info_wire *)buf;
1797 size_t offset;
1799 offset = offsetof(struct ctdb_public_ip_info_wire, num);
1800 memcpy(wire, in, offset);
1801 wire->num = in->ifaces->num;
1802 memcpy(wire->ifaces, in->ifaces->iface,
1803 in->ifaces->num * sizeof(struct ctdb_iface));
1806 static int ctdb_public_ip_info_pull_old(uint8_t *buf, size_t buflen,
1807 TALLOC_CTX *mem_ctx,
1808 struct ctdb_public_ip_info **out)
1810 struct ctdb_public_ip_info *val;
1811 struct ctdb_public_ip_info_wire *wire =
1812 (struct ctdb_public_ip_info_wire *)buf;
1814 if (buflen < offsetof(struct ctdb_public_ip_info_wire, ifaces)) {
1815 return EMSGSIZE;
1817 if (wire->num > buflen / sizeof(struct ctdb_iface)) {
1818 return EMSGSIZE;
1820 if (offsetof(struct ctdb_public_ip_info_wire, ifaces) +
1821 wire->num * sizeof(struct ctdb_iface) <
1822 offsetof(struct ctdb_public_ip_info_wire, ifaces)) {
1823 return EMSGSIZE;
1825 if (buflen < offsetof(struct ctdb_public_ip_info_wire, ifaces) +
1826 wire->num * sizeof(struct ctdb_iface)) {
1827 return EMSGSIZE;
1830 val = talloc(mem_ctx, struct ctdb_public_ip_info);
1831 if (val == NULL) {
1832 return ENOMEM;
1835 memcpy(val, wire, offsetof(struct ctdb_public_ip_info_wire, num));
1837 val->ifaces = talloc(val, struct ctdb_iface_list);
1838 if (val->ifaces == NULL) {
1839 talloc_free(val);
1840 return ENOMEM;
1843 val->ifaces->num = wire->num;
1844 val->ifaces->iface = talloc_array(val->ifaces, struct ctdb_iface,
1845 wire->num);
1846 if (val->ifaces->iface == NULL) {
1847 talloc_free(val);
1848 return ENOMEM;
1851 memcpy(val->ifaces->iface, wire->ifaces,
1852 wire->num * sizeof(struct ctdb_iface));
1854 *out = val;
1855 return 0;
1858 struct ctdb_statistics_list_wire {
1859 uint32_t num;
1860 struct ctdb_statistics stats[1];
1863 static size_t ctdb_statistics_list_len_old(struct ctdb_statistics_list *in)
1865 return offsetof(struct ctdb_statistics_list_wire, stats) +
1866 in->num * sizeof(struct ctdb_statistics);
1869 static void ctdb_statistics_list_push_old(struct ctdb_statistics_list *in,
1870 uint8_t *buf)
1872 struct ctdb_statistics_list_wire *wire =
1873 (struct ctdb_statistics_list_wire *)buf;
1875 wire->num = in->num;
1876 memcpy(wire->stats, in->stats,
1877 in->num * sizeof(struct ctdb_statistics));
1880 static int ctdb_statistics_list_pull_old(uint8_t *buf, size_t buflen,
1881 TALLOC_CTX *mem_ctx,
1882 struct ctdb_statistics_list **out)
1884 struct ctdb_statistics_list *val;
1885 struct ctdb_statistics_list_wire *wire =
1886 (struct ctdb_statistics_list_wire *)buf;
1888 if (buflen < offsetof(struct ctdb_statistics_list_wire, stats)) {
1889 return EMSGSIZE;
1891 if (wire->num > buflen / sizeof(struct ctdb_statistics)) {
1892 return EMSGSIZE;
1894 if (offsetof(struct ctdb_statistics_list_wire, stats) +
1895 wire->num * sizeof(struct ctdb_statistics) <
1896 offsetof(struct ctdb_statistics_list_wire, stats)) {
1897 return EMSGSIZE;
1899 if (buflen < offsetof(struct ctdb_statistics_list_wire, stats) +
1900 wire->num * sizeof(struct ctdb_statistics)) {
1901 return EMSGSIZE;
1904 val = talloc(mem_ctx, struct ctdb_statistics_list);
1905 if (val == NULL) {
1906 return ENOMEM;
1909 val->num = wire->num;
1911 val->stats = talloc_array(val, struct ctdb_statistics, wire->num);
1912 if (val->stats == NULL) {
1913 talloc_free(val);
1914 return ENOMEM;
1917 memcpy(val->stats, wire->stats,
1918 wire->num * sizeof(struct ctdb_statistics));
1920 *out = val;
1921 return 0;
1924 struct ctdb_key_data_wire {
1925 uint32_t db_id;
1926 struct ctdb_ltdb_header header;
1927 uint32_t keylen;
1928 uint8_t key[1];
1931 static size_t ctdb_key_data_len_old(struct ctdb_key_data *in)
1933 return offsetof(struct ctdb_key_data_wire, key) + in->key.dsize;
1936 static void ctdb_key_data_push_old(struct ctdb_key_data *in, uint8_t *buf)
1938 struct ctdb_key_data_wire *wire = (struct ctdb_key_data_wire *)buf;
1940 memcpy(wire, in, offsetof(struct ctdb_key_data, key));
1941 wire->keylen = in->key.dsize;
1942 memcpy(wire->key, in->key.dptr, in->key.dsize);
1945 static int ctdb_key_data_pull_old(uint8_t *buf, size_t buflen,
1946 TALLOC_CTX *mem_ctx,
1947 struct ctdb_key_data **out)
1949 struct ctdb_key_data *val;
1950 struct ctdb_key_data_wire *wire = (struct ctdb_key_data_wire *)buf;
1952 if (buflen < offsetof(struct ctdb_key_data_wire, key)) {
1953 return EMSGSIZE;
1955 if (wire->keylen > buflen) {
1956 return EMSGSIZE;
1958 if (offsetof(struct ctdb_key_data_wire, key) + wire->keylen <
1959 offsetof(struct ctdb_key_data_wire, key)) {
1960 return EMSGSIZE;
1962 if (buflen < offsetof(struct ctdb_key_data_wire, key) + wire->keylen) {
1963 return EMSGSIZE;
1966 val = talloc(mem_ctx, struct ctdb_key_data);
1967 if (val == NULL) {
1968 return ENOMEM;
1971 memcpy(val, wire, offsetof(struct ctdb_key_data, key));
1973 val->key.dsize = wire->keylen;
1974 val->key.dptr = talloc_memdup(val, wire->key, wire->keylen);
1975 if (val->key.dptr == NULL) {
1976 talloc_free(val);
1977 return ENOMEM;
1980 *out = val;
1981 return 0;
1984 struct ctdb_db_statistics_wire {
1985 struct ctdb_db_statistics dbstats;
1986 char hot_keys_wire[1];
1989 static size_t ctdb_db_statistics_len_old(struct ctdb_db_statistics *in)
1991 size_t len;
1992 int i;
1994 len = sizeof(struct ctdb_db_statistics);
1995 for (i=0; i<MAX_HOT_KEYS; i++) {
1996 len += in->hot_keys[i].key.dsize;
1998 return len;
2001 static void ctdb_db_statistics_push_old(struct ctdb_db_statistics *in,
2002 void *buf)
2004 struct ctdb_db_statistics_wire *wire =
2005 (struct ctdb_db_statistics_wire *)buf;
2006 size_t offset;
2007 int i;
2009 in->num_hot_keys = MAX_HOT_KEYS;
2010 memcpy(wire, in, sizeof(struct ctdb_db_statistics));
2012 offset = 0;
2013 for (i=0; i<MAX_HOT_KEYS; i++) {
2014 memcpy(&wire->hot_keys_wire[offset],
2015 in->hot_keys[i].key.dptr,
2016 in->hot_keys[i].key.dsize);
2017 offset += in->hot_keys[i].key.dsize;
2021 static int ctdb_db_statistics_pull_old(uint8_t *buf, size_t buflen,
2022 TALLOC_CTX *mem_ctx,
2023 struct ctdb_db_statistics **out)
2025 struct ctdb_db_statistics *val;
2026 struct ctdb_db_statistics_wire *wire =
2027 (struct ctdb_db_statistics_wire *)buf;
2028 size_t offset;
2029 unsigned int i;
2031 if (buflen < sizeof(struct ctdb_db_statistics)) {
2032 return EMSGSIZE;
2035 offset = 0;
2036 for (i=0; i<wire->dbstats.num_hot_keys; i++) {
2037 if (wire->dbstats.hot_keys[i].key.dsize > buflen) {
2038 return EMSGSIZE;
2040 if (offset + wire->dbstats.hot_keys[i].key.dsize < offset) {
2041 return EMSGSIZE;
2043 offset += wire->dbstats.hot_keys[i].key.dsize;
2044 if (offset > buflen) {
2045 return EMSGSIZE;
2048 if (sizeof(struct ctdb_db_statistics) + offset <
2049 sizeof(struct ctdb_db_statistics)) {
2050 return EMSGSIZE;
2052 if (buflen < sizeof(struct ctdb_db_statistics) + offset) {
2053 return EMSGSIZE;
2056 val = talloc(mem_ctx, struct ctdb_db_statistics);
2057 if (val == NULL) {
2058 return ENOMEM;
2061 memcpy(val, wire, sizeof(struct ctdb_db_statistics));
2063 offset = 0;
2064 for (i=0; i<wire->dbstats.num_hot_keys; i++) {
2065 uint8_t *ptr;
2066 size_t key_size;
2068 key_size = val->hot_keys[i].key.dsize;
2069 ptr = talloc_memdup(mem_ctx, &wire->hot_keys_wire[offset],
2070 key_size);
2071 if (ptr == NULL) {
2072 talloc_free(val);
2073 return ENOMEM;
2075 val->hot_keys[i].key.dptr = ptr;
2076 offset += key_size;
2079 *out = val;
2080 return 0;
2083 static size_t ctdb_election_message_len_old(struct ctdb_election_message *in)
2085 return sizeof(struct ctdb_election_message);
2088 static void ctdb_election_message_push_old(struct ctdb_election_message *in,
2089 uint8_t *buf)
2091 memcpy(buf, in, sizeof(struct ctdb_election_message));
2094 static int ctdb_election_message_pull_old(uint8_t *buf, size_t buflen,
2095 TALLOC_CTX *mem_ctx,
2096 struct ctdb_election_message **out)
2098 struct ctdb_election_message *val;
2100 if (buflen < sizeof(struct ctdb_election_message)) {
2101 return EMSGSIZE;
2104 val = talloc_memdup(mem_ctx, buf,
2105 sizeof(struct ctdb_election_message));
2106 if (val == NULL) {
2107 return ENOMEM;
2110 *out = val;
2111 return 0;
2114 static size_t ctdb_srvid_message_len_old(struct ctdb_srvid_message *in)
2116 return sizeof(struct ctdb_srvid_message);
2119 static void ctdb_srvid_message_push_old(struct ctdb_srvid_message *in,
2120 uint8_t *buf)
2122 memcpy(buf, in, sizeof(struct ctdb_srvid_message));
2125 static int ctdb_srvid_message_pull_old(uint8_t *buf, size_t buflen,
2126 TALLOC_CTX *mem_ctx,
2127 struct ctdb_srvid_message **out)
2129 struct ctdb_srvid_message *val;
2131 if (buflen < sizeof(struct ctdb_srvid_message)) {
2132 return EMSGSIZE;
2135 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_srvid_message));
2136 if (val == NULL) {
2137 return ENOMEM;
2140 *out = val;
2141 return 0;
2144 static size_t ctdb_disable_message_len_old(struct ctdb_disable_message *in)
2146 return sizeof(struct ctdb_disable_message);
2149 static void ctdb_disable_message_push_old(struct ctdb_disable_message *in,
2150 uint8_t *buf)
2152 memcpy(buf, in, sizeof(struct ctdb_disable_message));
2155 static int ctdb_disable_message_pull_old(uint8_t *buf, size_t buflen,
2156 TALLOC_CTX *mem_ctx,
2157 struct ctdb_disable_message **out)
2159 struct ctdb_disable_message *val;
2161 if (buflen < sizeof(struct ctdb_disable_message)) {
2162 return EMSGSIZE;
2165 val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_disable_message));
2166 if (val == NULL) {
2167 return ENOMEM;
2170 *out = val;
2171 return 0;
2174 static size_t ctdb_server_id_len_old(struct ctdb_server_id *in)
2176 return sizeof(struct ctdb_server_id);
2179 static void ctdb_server_id_push_old(struct ctdb_server_id *in, uint8_t *buf)
2181 memcpy(buf, in, sizeof(struct ctdb_server_id));
2184 static int ctdb_server_id_pull_old(uint8_t *buf, size_t buflen,
2185 struct ctdb_server_id *out)
2187 if (buflen < sizeof(struct ctdb_server_id)) {
2188 return EMSGSIZE;
2191 memcpy(out, buf, sizeof(struct ctdb_server_id));
2192 return 0;
2195 static size_t ctdb_g_lock_len_old(struct ctdb_g_lock *in)
2197 return sizeof(struct ctdb_g_lock);
2200 static void ctdb_g_lock_push_old(struct ctdb_g_lock *in, uint8_t *buf)
2202 memcpy(buf, in, sizeof(struct ctdb_g_lock));
2205 static int ctdb_g_lock_pull_old(uint8_t *buf, size_t buflen,
2206 struct ctdb_g_lock *out)
2208 if (buflen < sizeof(struct ctdb_g_lock)) {
2209 return EMSGSIZE;
2212 memcpy(out, buf, sizeof(struct ctdb_g_lock));
2213 return 0;
2216 static size_t ctdb_g_lock_list_len_old(struct ctdb_g_lock_list *in)
2218 return in->num * sizeof(struct ctdb_g_lock);
2221 static void ctdb_g_lock_list_push_old(struct ctdb_g_lock_list *in,
2222 uint8_t *buf)
2224 size_t offset = 0;
2225 unsigned int i;
2227 for (i=0; i<in->num; i++) {
2228 ctdb_g_lock_push_old(&in->lock[i], &buf[offset]);
2229 offset += sizeof(struct ctdb_g_lock);
2233 static int ctdb_g_lock_list_pull_old(uint8_t *buf, size_t buflen,
2234 TALLOC_CTX *mem_ctx,
2235 struct ctdb_g_lock_list **out)
2237 struct ctdb_g_lock_list *val;
2238 unsigned count;
2239 size_t offset;
2240 unsigned int i;
2241 int ret;
2243 val = talloc_zero(mem_ctx, struct ctdb_g_lock_list);
2244 if (val == NULL) {
2245 return ENOMEM;
2248 count = buflen / sizeof(struct ctdb_g_lock);
2249 val->lock = talloc_array(val, struct ctdb_g_lock, count);
2250 if (val->lock == NULL) {
2251 talloc_free(val);
2252 return ENOMEM;
2255 offset = 0;
2256 for (i=0; i<count; i++) {
2257 ret = ctdb_g_lock_pull_old(&buf[offset], buflen-offset,
2258 &val->lock[i]);
2259 if (ret != 0) {
2260 talloc_free(val);
2261 return ret;
2263 offset += sizeof(struct ctdb_g_lock);
2266 val->num = count;
2268 *out = val;
2269 return 0;
2272 COMPAT_TYPE3_TEST(struct ctdb_statistics, ctdb_statistics);
2273 COMPAT_TYPE3_TEST(struct ctdb_vnn_map, ctdb_vnn_map);
2274 COMPAT_TYPE3_TEST(struct ctdb_dbid_map, ctdb_dbid_map);
2275 COMPAT_TYPE3_TEST(struct ctdb_pulldb, ctdb_pulldb);
2276 COMPAT_TYPE3_TEST(struct ctdb_pulldb_ext, ctdb_pulldb_ext);
2278 COMPAT_TYPE1_TEST(struct ctdb_ltdb_header, ctdb_ltdb_header);
2280 COMPAT_TYPE3_TEST(struct ctdb_rec_data, ctdb_rec_data);
2281 COMPAT_TYPE3_TEST(struct ctdb_rec_buffer, ctdb_rec_buffer);
2282 COMPAT_TYPE3_TEST(struct ctdb_traverse_start, ctdb_traverse_start);
2283 COMPAT_TYPE3_TEST(struct ctdb_traverse_all, ctdb_traverse_all);
2284 COMPAT_TYPE3_TEST(struct ctdb_traverse_start_ext, ctdb_traverse_start_ext);
2285 COMPAT_TYPE3_TEST(struct ctdb_traverse_all_ext, ctdb_traverse_all_ext);
2286 COMPAT_TYPE3_TEST(ctdb_sock_addr, ctdb_sock_addr);
2287 COMPAT_TYPE3_TEST(struct ctdb_connection, ctdb_connection);
2288 COMPAT_TYPE3_TEST(struct ctdb_tunable, ctdb_tunable);
2289 COMPAT_TYPE3_TEST(struct ctdb_node_flag_change, ctdb_node_flag_change);
2290 COMPAT_TYPE3_TEST(struct ctdb_var_list, ctdb_var_list);
2291 COMPAT_TYPE3_TEST(struct ctdb_tunable_list, ctdb_tunable_list);
2292 COMPAT_TYPE3_TEST(struct ctdb_tickle_list, ctdb_tickle_list);
2293 COMPAT_TYPE3_TEST(struct ctdb_addr_info, ctdb_addr_info);
2294 COMPAT_TYPE3_TEST(struct ctdb_transdb, ctdb_transdb);
2295 COMPAT_TYPE3_TEST(struct ctdb_uptime, ctdb_uptime);
2296 COMPAT_TYPE3_TEST(struct ctdb_public_ip, ctdb_public_ip);
2297 COMPAT_TYPE3_TEST(struct ctdb_public_ip_list, ctdb_public_ip_list);
2298 COMPAT_TYPE3_TEST(struct ctdb_node_and_flags, ctdb_node_and_flags);
2299 COMPAT_TYPE3_TEST(struct ctdb_node_map, ctdb_node_map);
2300 COMPAT_TYPE3_TEST(struct ctdb_script, ctdb_script);
2301 COMPAT_TYPE3_TEST(struct ctdb_script_list, ctdb_script_list);
2302 COMPAT_TYPE3_TEST(struct ctdb_ban_state, ctdb_ban_state);
2303 COMPAT_TYPE3_TEST(struct ctdb_notify_data, ctdb_notify_data);
2304 COMPAT_TYPE3_TEST(struct ctdb_iface, ctdb_iface);
2305 COMPAT_TYPE3_TEST(struct ctdb_iface_list, ctdb_iface_list);
2306 COMPAT_TYPE3_TEST(struct ctdb_public_ip_info, ctdb_public_ip_info);
2307 COMPAT_TYPE3_TEST(struct ctdb_statistics_list, ctdb_statistics_list);
2308 COMPAT_TYPE3_TEST(struct ctdb_key_data, ctdb_key_data);
2309 COMPAT_TYPE3_TEST(struct ctdb_db_statistics, ctdb_db_statistics);
2311 COMPAT_TYPE3_TEST(struct ctdb_election_message, ctdb_election_message);
2312 COMPAT_TYPE3_TEST(struct ctdb_srvid_message, ctdb_srvid_message);
2313 COMPAT_TYPE3_TEST(struct ctdb_disable_message, ctdb_disable_message);
2315 COMPAT_TYPE1_TEST(struct ctdb_server_id, ctdb_server_id);
2316 COMPAT_TYPE1_TEST(struct ctdb_g_lock, ctdb_g_lock);
2318 COMPAT_TYPE3_TEST(struct ctdb_g_lock_list, ctdb_g_lock_list);
2320 static void protocol_types_compat_test(void)
2322 COMPAT_TEST_FUNC(ctdb_statistics)();
2323 COMPAT_TEST_FUNC(ctdb_vnn_map)();
2324 COMPAT_TEST_FUNC(ctdb_dbid_map)();
2325 COMPAT_TEST_FUNC(ctdb_pulldb)();
2326 COMPAT_TEST_FUNC(ctdb_pulldb_ext)();
2327 COMPAT_TEST_FUNC(ctdb_ltdb_header)();
2328 COMPAT_TEST_FUNC(ctdb_rec_data)();
2329 COMPAT_TEST_FUNC(ctdb_rec_buffer)();
2330 COMPAT_TEST_FUNC(ctdb_traverse_start)();
2331 COMPAT_TEST_FUNC(ctdb_traverse_all)();
2332 COMPAT_TEST_FUNC(ctdb_traverse_start_ext)();
2333 COMPAT_TEST_FUNC(ctdb_traverse_all_ext)();
2334 COMPAT_TEST_FUNC(ctdb_sock_addr)();
2335 COMPAT_TEST_FUNC(ctdb_connection)();
2336 COMPAT_TEST_FUNC(ctdb_tunable)();
2337 COMPAT_TEST_FUNC(ctdb_node_flag_change)();
2338 COMPAT_TEST_FUNC(ctdb_var_list)();
2339 COMPAT_TEST_FUNC(ctdb_tunable_list)();
2340 COMPAT_TEST_FUNC(ctdb_tickle_list)();
2341 COMPAT_TEST_FUNC(ctdb_addr_info)();
2342 COMPAT_TEST_FUNC(ctdb_transdb)();
2343 COMPAT_TEST_FUNC(ctdb_uptime)();
2344 COMPAT_TEST_FUNC(ctdb_public_ip)();
2345 COMPAT_TEST_FUNC(ctdb_public_ip_list)();
2346 COMPAT_TEST_FUNC(ctdb_node_and_flags)();
2347 COMPAT_TEST_FUNC(ctdb_node_map)();
2348 COMPAT_TEST_FUNC(ctdb_script)();
2349 COMPAT_TEST_FUNC(ctdb_script_list)();
2350 COMPAT_TEST_FUNC(ctdb_ban_state)();
2351 COMPAT_TEST_FUNC(ctdb_notify_data)();
2352 COMPAT_TEST_FUNC(ctdb_iface)();
2353 COMPAT_TEST_FUNC(ctdb_iface_list)();
2354 COMPAT_TEST_FUNC(ctdb_public_ip_info)();
2355 COMPAT_TEST_FUNC(ctdb_statistics_list)();
2356 COMPAT_TEST_FUNC(ctdb_key_data)();
2357 COMPAT_TEST_FUNC(ctdb_db_statistics)();
2359 COMPAT_TEST_FUNC(ctdb_election_message)();
2360 COMPAT_TEST_FUNC(ctdb_srvid_message)();
2361 COMPAT_TEST_FUNC(ctdb_disable_message)();
2362 COMPAT_TEST_FUNC(ctdb_server_id)();
2363 COMPAT_TEST_FUNC(ctdb_g_lock)();
2364 COMPAT_TEST_FUNC(ctdb_g_lock_list)();
2367 int main(int argc, const char *argv[])
2369 protocol_test_iterate(argc, argv, protocol_types_compat_test);
2370 return 0;