2 CTDB protocol marshalling
4 Copyright (C) Amitay Isaacs 2015-2017
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/>.
21 #include "system/network.h"
27 #include "protocol_private.h"
28 #include "protocol_api.h"
30 size_t ctdb_tdb_data_len(TDB_DATA *in)
32 return in->dsize > UINT32_MAX ? UINT32_MAX : in->dsize;
35 void ctdb_tdb_data_push(TDB_DATA *in, uint8_t *buf, size_t *npush)
37 size_t len = ctdb_tdb_data_len(in);
40 memcpy(buf, in->dptr, len);
46 int ctdb_tdb_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
47 TDB_DATA *out, size_t *npull)
51 if (buflen > UINT32_MAX) {
57 val.dptr = talloc_memdup(mem_ctx, buf, buflen);
58 if (val.dptr == NULL) {
70 size_t ctdb_tdb_datan_len(TDB_DATA *in)
72 uint32_t u32 = ctdb_tdb_data_len(in);
74 return ctdb_uint32_len(&u32) + u32;
77 void ctdb_tdb_datan_push(TDB_DATA *in, uint8_t *buf, size_t *npush)
79 size_t offset = 0, np;
80 uint32_t u32 = ctdb_tdb_data_len(in);
82 ctdb_uint32_push(&u32, buf+offset, &np);
85 ctdb_tdb_data_push(in, buf+offset, &np);
91 int ctdb_tdb_datan_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
92 TDB_DATA *out, size_t *npull)
94 size_t offset = 0, np;
98 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &u32, &np);
104 if (buflen-offset < u32) {
108 ret = ctdb_tdb_data_pull(buf+offset, u32, mem_ctx, out, &np);
118 size_t ctdb_latency_counter_len(struct ctdb_latency_counter *in)
120 return ctdb_int32_len(&in->num) +
121 ctdb_padding_len(4) +
122 ctdb_double_len(&in->min) +
123 ctdb_double_len(&in->max) +
124 ctdb_double_len(&in->total);
127 void ctdb_latency_counter_push(struct ctdb_latency_counter *in, uint8_t *buf,
130 size_t offset = 0, np;
132 ctdb_int32_push(&in->num, buf+offset, &np);
135 ctdb_padding_push(4, buf+offset, &np);
138 ctdb_double_push(&in->min, buf+offset, &np);
141 ctdb_double_push(&in->max, buf+offset, &np);
144 ctdb_double_push(&in->total, buf+offset, &np);
150 int ctdb_latency_counter_pull(uint8_t *buf, size_t buflen,
151 struct ctdb_latency_counter *out, size_t *npull)
153 size_t offset = 0, np;
156 ret = ctdb_int32_pull(buf+offset, buflen-offset, &out->num, &np);
162 ret = ctdb_padding_pull(buf+offset, buflen-offset, 4, &np);
168 ret = ctdb_double_pull(buf+offset, buflen-offset, &out->min, &np);
174 ret = ctdb_double_pull(buf+offset, buflen-offset, &out->max, &np);
180 ret = ctdb_double_pull(buf+offset, buflen-offset, &out->total, &np);
190 size_t ctdb_statistics_len(struct ctdb_statistics *in)
192 return ctdb_uint32_len(&in->num_clients) +
193 ctdb_uint32_len(&in->frozen) +
194 ctdb_uint32_len(&in->recovering) +
195 ctdb_uint32_len(&in->client_packets_sent) +
196 ctdb_uint32_len(&in->client_packets_recv) +
197 ctdb_uint32_len(&in->node_packets_sent) +
198 ctdb_uint32_len(&in->node_packets_recv) +
199 ctdb_uint32_len(&in->keepalive_packets_sent) +
200 ctdb_uint32_len(&in->keepalive_packets_recv) +
201 ctdb_uint32_len(&in->node.req_call) +
202 ctdb_uint32_len(&in->node.reply_call) +
203 ctdb_uint32_len(&in->node.req_dmaster) +
204 ctdb_uint32_len(&in->node.reply_dmaster) +
205 ctdb_uint32_len(&in->node.reply_error) +
206 ctdb_uint32_len(&in->node.req_message) +
207 ctdb_uint32_len(&in->node.req_control) +
208 ctdb_uint32_len(&in->node.reply_control) +
209 ctdb_uint32_len(&in->client.req_call) +
210 ctdb_uint32_len(&in->client.req_message) +
211 ctdb_uint32_len(&in->client.req_control) +
212 ctdb_uint32_len(&in->timeouts.call) +
213 ctdb_uint32_len(&in->timeouts.control) +
214 ctdb_uint32_len(&in->timeouts.traverse) +
215 ctdb_padding_len(4) +
216 ctdb_latency_counter_len(&in->reclock.ctdbd) +
217 ctdb_latency_counter_len(&in->reclock.recd) +
218 ctdb_uint32_len(&in->locks.num_calls) +
219 ctdb_uint32_len(&in->locks.num_current) +
220 ctdb_uint32_len(&in->locks.num_pending) +
221 ctdb_uint32_len(&in->locks.num_failed) +
222 ctdb_latency_counter_len(&in->locks.latency) +
223 MAX_COUNT_BUCKETS * ctdb_uint32_len(&in->locks.buckets[0]) +
224 ctdb_uint32_len(&in->total_calls) +
225 ctdb_uint32_len(&in->pending_calls) +
226 ctdb_uint32_len(&in->childwrite_calls) +
227 ctdb_uint32_len(&in->pending_childwrite_calls) +
228 ctdb_uint32_len(&in->memory_used) +
229 ctdb_uint32_len(&in->__last_counter) +
230 ctdb_uint32_len(&in->max_hop_count) +
232 ctdb_uint32_len(&in->hop_count_bucket[0]) +
233 ctdb_padding_len(4) +
234 ctdb_latency_counter_len(&in->call_latency) +
235 ctdb_latency_counter_len(&in->childwrite_latency) +
236 ctdb_uint32_len(&in->num_recoveries) +
237 ctdb_padding_len(4) +
238 ctdb_timeval_len(&in->statistics_start_time) +
239 ctdb_timeval_len(&in->statistics_current_time) +
240 ctdb_uint32_len(&in->total_ro_delegations) +
241 ctdb_uint32_len(&in->total_ro_revokes);
244 void ctdb_statistics_push(struct ctdb_statistics *in, uint8_t *buf,
247 size_t offset = 0, np;
250 ctdb_uint32_push(&in->num_clients, buf+offset, &np);
253 ctdb_uint32_push(&in->frozen, buf+offset, &np);
256 ctdb_uint32_push(&in->recovering, buf+offset, &np);
259 ctdb_uint32_push(&in->client_packets_sent, buf+offset, &np);
262 ctdb_uint32_push(&in->client_packets_recv, buf+offset, &np);
265 ctdb_uint32_push(&in->node_packets_sent, buf+offset, &np);
268 ctdb_uint32_push(&in->node_packets_recv, buf+offset, &np);
271 ctdb_uint32_push(&in->keepalive_packets_sent, buf+offset, &np);
274 ctdb_uint32_push(&in->keepalive_packets_recv, buf+offset, &np);
277 ctdb_uint32_push(&in->node.req_call, buf+offset, &np);
280 ctdb_uint32_push(&in->node.reply_call, buf+offset, &np);
283 ctdb_uint32_push(&in->node.req_dmaster, buf+offset, &np);
286 ctdb_uint32_push(&in->node.reply_dmaster, buf+offset, &np);
289 ctdb_uint32_push(&in->node.reply_error, buf+offset, &np);
292 ctdb_uint32_push(&in->node.req_message, buf+offset, &np);
295 ctdb_uint32_push(&in->node.req_control, buf+offset, &np);
298 ctdb_uint32_push(&in->node.reply_control, buf+offset, &np);
301 ctdb_uint32_push(&in->client.req_call, buf+offset, &np);
304 ctdb_uint32_push(&in->client.req_message, buf+offset, &np);
307 ctdb_uint32_push(&in->client.req_control, buf+offset, &np);
310 ctdb_uint32_push(&in->timeouts.call, buf+offset, &np);
313 ctdb_uint32_push(&in->timeouts.control, buf+offset, &np);
316 ctdb_uint32_push(&in->timeouts.traverse, buf+offset, &np);
319 ctdb_padding_push(4, buf+offset, &np);
322 ctdb_latency_counter_push(&in->reclock.ctdbd, buf+offset, &np);
325 ctdb_latency_counter_push(&in->reclock.recd, buf+offset, &np);
328 ctdb_uint32_push(&in->locks.num_calls, buf+offset, &np);
331 ctdb_uint32_push(&in->locks.num_current, buf+offset, &np);
334 ctdb_uint32_push(&in->locks.num_pending, buf+offset, &np);
337 ctdb_uint32_push(&in->locks.num_failed, buf+offset, &np);
340 ctdb_latency_counter_push(&in->locks.latency, buf+offset, &np);
343 for (i=0; i<MAX_COUNT_BUCKETS; i++) {
344 ctdb_uint32_push(&in->locks.buckets[i], buf+offset, &np);
348 ctdb_uint32_push(&in->total_calls, buf+offset, &np);
351 ctdb_uint32_push(&in->pending_calls, buf+offset, &np);
354 ctdb_uint32_push(&in->childwrite_calls, buf+offset, &np);
357 ctdb_uint32_push(&in->pending_childwrite_calls, buf+offset, &np);
360 ctdb_uint32_push(&in->memory_used, buf+offset, &np);
363 ctdb_uint32_push(&in->__last_counter, buf+offset, &np);
366 ctdb_uint32_push(&in->max_hop_count, buf+offset, &np);
369 for (i=0; i<MAX_COUNT_BUCKETS; i++) {
370 ctdb_uint32_push(&in->hop_count_bucket[i], buf+offset, &np);
374 ctdb_padding_push(4, buf+offset, &np);
377 ctdb_latency_counter_push(&in->call_latency, buf+offset, &np);
380 ctdb_latency_counter_push(&in->childwrite_latency, buf+offset, &np);
383 ctdb_uint32_push(&in->num_recoveries, buf+offset, &np);
386 ctdb_padding_push(4, buf+offset, &np);
389 ctdb_timeval_push(&in->statistics_start_time, buf+offset, &np);
392 ctdb_timeval_push(&in->statistics_current_time, buf+offset, &np);
395 ctdb_uint32_push(&in->total_ro_delegations, buf+offset, &np);
398 ctdb_uint32_push(&in->total_ro_revokes, buf+offset, &np);
404 static int ctdb_statistics_pull_elems(uint8_t *buf, size_t buflen,
406 struct ctdb_statistics *out,
409 size_t offset = 0, np;
412 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &out->num_clients,
419 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &out->frozen, &np);
425 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &out->recovering,
432 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
433 &out->client_packets_sent, &np);
439 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
440 &out->client_packets_recv, &np);
446 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
447 &out->node_packets_sent, &np);
453 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
454 &out->node_packets_recv, &np);
460 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
461 &out->keepalive_packets_sent, &np);
467 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
468 &out->keepalive_packets_recv, &np);
474 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
475 &out->node.req_call, &np);
481 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
482 &out->node.reply_call, &np);
488 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
489 &out->node.req_dmaster, &np);
495 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
496 &out->node.reply_dmaster, &np);
502 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
503 &out->node.reply_error, &np);
509 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
510 &out->node.req_message, &np);
516 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
517 &out->node.req_control, &np);
523 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
524 &out->node.reply_control, &np);
530 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
531 &out->client.req_call, &np);
537 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
538 &out->client.req_message, &np);
544 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
545 &out->client.req_control, &np);
551 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
552 &out->timeouts.call, &np);
558 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
559 &out->timeouts.control, &np);
565 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
566 &out->timeouts.traverse, &np);
572 ret = ctdb_padding_pull(buf+offset, buflen-offset, 4, &np);
578 ret = ctdb_latency_counter_pull(buf+offset, buflen-offset,
579 &out->reclock.ctdbd, &np);
585 ret = ctdb_latency_counter_pull(buf+offset, buflen-offset,
586 &out->reclock.recd, &np);
592 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
593 &out->locks.num_calls, &np);
599 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
600 &out->locks.num_current, &np);
606 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
607 &out->locks.num_pending, &np);
613 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
614 &out->locks.num_failed, &np);
620 ret = ctdb_latency_counter_pull(buf+offset, buflen-offset,
621 &out->locks.latency, &np);
627 for (i=0; i<MAX_COUNT_BUCKETS; i++) {
628 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
629 &out->locks.buckets[i], &np);
636 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
637 &out->total_calls, &np);
643 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
644 &out->pending_calls, &np);
650 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
651 &out->childwrite_calls, &np);
657 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
658 &out->pending_childwrite_calls, &np);
664 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &out->memory_used,
671 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
672 &out->__last_counter, &np);
678 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
679 &out->max_hop_count, &np);
685 for (i=0; i<MAX_COUNT_BUCKETS; i++) {
686 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
687 &out->hop_count_bucket[i], &np);
694 ret = ctdb_padding_pull(buf+offset, buflen-offset, 4, &np);
700 ret = ctdb_latency_counter_pull(buf+offset, buflen-offset,
701 &out->call_latency, &np);
707 ret = ctdb_latency_counter_pull(buf+offset, buflen-offset,
708 &out->childwrite_latency, &np);
714 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
715 &out->num_recoveries, &np);
721 ret = ctdb_padding_pull(buf+offset, buflen-offset, 4, &np);
727 ret = ctdb_timeval_pull(buf+offset, buflen-offset,
728 &out->statistics_start_time, &np);
734 ret = ctdb_timeval_pull(buf+offset, buflen-offset,
735 &out->statistics_current_time, &np);
741 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
742 &out->total_ro_delegations, &np);
748 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
749 &out->total_ro_revokes, &np);
759 int ctdb_statistics_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
760 struct ctdb_statistics **out, size_t *npull)
762 struct ctdb_statistics *val;
766 val = talloc(mem_ctx, struct ctdb_statistics);
771 ret = ctdb_statistics_pull_elems(buf, buflen, val, val, &np);
782 struct ctdb_statistics_list_wire {
784 struct ctdb_statistics stats[1];
787 size_t ctdb_statistics_list_len(struct ctdb_statistics_list *stats_list)
789 return offsetof(struct ctdb_statistics_list_wire, stats) +
790 stats_list->num * sizeof(struct ctdb_statistics);
793 void ctdb_statistics_list_push(struct ctdb_statistics_list *stats_list,
796 struct ctdb_statistics_list_wire *wire =
797 (struct ctdb_statistics_list_wire *)buf;
799 wire->num = stats_list->num;
800 memcpy(wire->stats, stats_list->stats,
801 stats_list->num * sizeof(struct ctdb_statistics));
804 int ctdb_statistics_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
805 struct ctdb_statistics_list **out)
807 struct ctdb_statistics_list *stats_list;
808 struct ctdb_statistics_list_wire *wire =
809 (struct ctdb_statistics_list_wire *)buf;
811 if (buflen < offsetof(struct ctdb_statistics_list_wire, stats)) {
814 if (wire->num > buflen / sizeof(struct ctdb_statistics)) {
817 if (offsetof(struct ctdb_statistics_list_wire, stats) +
818 wire->num * sizeof(struct ctdb_statistics) <
819 offsetof(struct ctdb_statistics_list_wire, stats)) {
822 if (buflen < offsetof(struct ctdb_statistics_list_wire, stats) +
823 wire->num * sizeof(struct ctdb_statistics)) {
827 stats_list = talloc(mem_ctx, struct ctdb_statistics_list);
828 if (stats_list == NULL) {
832 stats_list->num = wire->num;
834 stats_list->stats = talloc_array(stats_list, struct ctdb_statistics,
836 if (stats_list->stats == NULL) {
837 talloc_free(stats_list);
841 memcpy(stats_list->stats, wire->stats,
842 wire->num * sizeof(struct ctdb_statistics));
848 size_t ctdb_vnn_map_len(struct ctdb_vnn_map *in)
852 len = ctdb_uint32_len(&in->generation) + ctdb_uint32_len(&in->size);
854 len += in->size * ctdb_uint32_len(&in->map[0]);
860 void ctdb_vnn_map_push(struct ctdb_vnn_map *in, uint8_t *buf, size_t *npush)
862 size_t offset = 0, np;
865 ctdb_uint32_push(&in->generation, buf+offset, &np);
868 ctdb_uint32_push(&in->size, buf+offset, &np);
871 for (i=0; i<in->size; i++) {
872 ctdb_uint32_push(&in->map[i], buf+offset, &np);
879 int ctdb_vnn_map_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
880 struct ctdb_vnn_map **out, size_t *npull)
882 struct ctdb_vnn_map *val;
883 size_t offset = 0, np;
887 val = talloc(mem_ctx, struct ctdb_vnn_map);
892 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->generation,
899 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->size, &np);
905 if (val->size == 0) {
910 val->map = talloc_array(val, uint32_t, val->size);
911 if (val->map == NULL) {
916 for (i=0; i<val->size; i++) {
917 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
935 size_t ctdb_dbid_len(struct ctdb_dbid *in)
937 return ctdb_uint32_len(&in->db_id) +
938 ctdb_uint8_len(&in->flags) +
942 void ctdb_dbid_push(struct ctdb_dbid *in, uint8_t *buf, size_t *npush)
944 size_t offset = 0, np;
946 ctdb_uint32_push(&in->db_id, buf+offset, &np);
949 ctdb_uint8_push(&in->flags, buf+offset, &np);
952 ctdb_padding_push(3, buf+offset, &np);
958 static int ctdb_dbid_pull_elems(uint8_t *buf, size_t buflen,
959 TALLOC_CTX *mem_ctx, struct ctdb_dbid *out,
962 size_t offset = 0, np;
965 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &out->db_id, &np);
971 ret = ctdb_uint8_pull(buf+offset, buflen-offset, &out->flags, &np);
977 ret = ctdb_padding_pull(buf+offset, buflen-offset, 3, &np);
987 int ctdb_dbid_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
988 struct ctdb_dbid **out, size_t *npull)
990 struct ctdb_dbid *val;
994 val = talloc(mem_ctx, struct ctdb_dbid);
999 ret = ctdb_dbid_pull_elems(buf, buflen, val, val, &np);
1010 size_t ctdb_dbid_map_len(struct ctdb_dbid_map *in)
1014 len = ctdb_uint32_len(&in->num);
1016 len += in->num * ctdb_dbid_len(&in->dbs[0]);
1022 void ctdb_dbid_map_push(struct ctdb_dbid_map *in, uint8_t *buf, size_t *npush)
1024 size_t offset = 0, np;
1027 ctdb_uint32_push(&in->num, buf+offset, &np);
1030 for (i=0; i<in->num; i++) {
1031 ctdb_dbid_push(&in->dbs[i], buf+offset, &np);
1038 int ctdb_dbid_map_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
1039 struct ctdb_dbid_map **out, size_t *npull)
1041 struct ctdb_dbid_map *val;
1042 size_t offset = 0, np;
1046 val = talloc(mem_ctx, struct ctdb_dbid_map);
1051 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->num, &np);
1057 if (val->num == 0) {
1062 val->dbs = talloc_array(val, struct ctdb_dbid, val->num);
1063 if (val->dbs == NULL) {
1068 for (i=0; i<val->num; i++) {
1069 ret = ctdb_dbid_pull_elems(buf+offset, buflen-offset, val,
1087 size_t ctdb_pulldb_len(struct ctdb_pulldb *in)
1089 return ctdb_uint32_len(&in->db_id) +
1090 ctdb_uint32_len(&in->lmaster);
1093 void ctdb_pulldb_push(struct ctdb_pulldb *in, uint8_t *buf, size_t *npush)
1095 size_t offset = 0, np;
1097 ctdb_uint32_push(&in->db_id, buf+offset, &np);
1100 ctdb_uint32_push(&in->lmaster, buf+offset, &np);
1106 int ctdb_pulldb_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
1107 struct ctdb_pulldb **out, size_t *npull)
1109 struct ctdb_pulldb *val;
1110 size_t offset = 0, np;
1113 val = talloc(mem_ctx, struct ctdb_pulldb);
1118 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->db_id, &np);
1125 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->lmaster, &np);
1137 size_t ctdb_pulldb_ext_len(struct ctdb_pulldb_ext *in)
1139 return ctdb_uint32_len(&in->db_id) +
1140 ctdb_uint32_len(&in->lmaster) +
1141 ctdb_uint64_len(&in->srvid);
1144 void ctdb_pulldb_ext_push(struct ctdb_pulldb_ext *in, uint8_t *buf,
1147 size_t offset = 0, np;
1149 ctdb_uint32_push(&in->db_id, buf+offset, &np);
1152 ctdb_uint32_push(&in->lmaster, buf+offset, &np);
1155 ctdb_uint64_push(&in->srvid, buf+offset, &np);
1161 int ctdb_pulldb_ext_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
1162 struct ctdb_pulldb_ext **out, size_t *npull)
1164 struct ctdb_pulldb_ext *val;
1165 size_t offset = 0, np;
1168 val = talloc(mem_ctx, struct ctdb_pulldb_ext);
1173 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->db_id, &np);
1179 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->lmaster, &np);
1185 ret = ctdb_uint64_pull(buf+offset, buflen-offset, &val->srvid, &np);
1200 size_t ctdb_ltdb_header_len(struct ctdb_ltdb_header *in)
1202 return ctdb_uint64_len(&in->rsn) +
1203 ctdb_uint32_len(&in->dmaster) +
1204 ctdb_uint32_len(&in->reserved1) +
1205 ctdb_uint32_len(&in->flags) +
1206 ctdb_padding_len(4);
1209 void ctdb_ltdb_header_push(struct ctdb_ltdb_header *in, uint8_t *buf,
1212 size_t offset = 0, np;
1214 ctdb_uint64_push(&in->rsn, buf+offset, &np);
1217 ctdb_uint32_push(&in->dmaster, buf+offset, &np);
1220 ctdb_uint32_push(&in->reserved1, buf+offset, &np);
1223 ctdb_uint32_push(&in->flags, buf+offset, &np);
1226 ctdb_padding_push(4, buf+offset, &np);
1232 int ctdb_ltdb_header_pull(uint8_t *buf, size_t buflen,
1233 struct ctdb_ltdb_header *out, size_t *npull)
1235 size_t offset = 0, np;
1238 ret = ctdb_uint64_pull(buf+offset, buflen-offset, &out->rsn, &np);
1244 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &out->dmaster, &np);
1250 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &out->reserved1,
1257 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &out->flags, &np);
1263 ret = ctdb_padding_pull(buf+offset, buflen-offset, 4, &np);
1273 int ctdb_ltdb_header_extract(TDB_DATA *data, struct ctdb_ltdb_header *header)
1278 ret = ctdb_ltdb_header_pull(data->dptr, data->dsize, header, &np);
1289 size_t ctdb_rec_data_len(struct ctdb_rec_data *in)
1293 u32 = ctdb_uint32_len(&in->reqid) +
1294 ctdb_tdb_datan_len(&in->key) +
1295 ctdb_tdb_datan_len(&in->data);
1297 if (in->header != NULL) {
1298 u32 += ctdb_ltdb_header_len(in->header);
1301 return ctdb_uint32_len(&u32) + u32;
1304 void ctdb_rec_data_push(struct ctdb_rec_data *in, uint8_t *buf, size_t *npush)
1306 size_t offset = 0, np;
1309 u32 = ctdb_rec_data_len(in);
1310 ctdb_uint32_push(&u32, buf+offset, &np);
1313 ctdb_uint32_push(&in->reqid, buf+offset, &np);
1316 u32 = ctdb_tdb_data_len(&in->key);
1317 ctdb_uint32_push(&u32, buf+offset, &np);
1320 u32 = ctdb_tdb_data_len(&in->data);
1321 if (in->header != NULL) {
1322 u32 += ctdb_ltdb_header_len(in->header);
1325 ctdb_uint32_push(&u32, buf+offset, &np);
1328 ctdb_tdb_data_push(&in->key, buf+offset, &np);
1331 /* If ltdb header is not NULL, then it is pushed as part of the data */
1332 if (in->header != NULL) {
1333 ctdb_ltdb_header_push(in->header, buf+offset, &np);
1336 ctdb_tdb_data_push(&in->data, buf+offset, &np);
1342 static int ctdb_rec_data_pull_data(uint8_t *buf, size_t buflen,
1344 TDB_DATA *key, TDB_DATA *data,
1347 size_t offset = 0, np;
1352 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &u32, &np);
1363 ret = ctdb_uint32_pull(buf+offset, len-offset, reqid, &np);
1369 ret = ctdb_uint32_pull(buf+offset, len-offset, &u32, &np);
1376 ret = ctdb_uint32_pull(buf+offset, len-offset, &u32, &np);
1383 if (len-offset < key->dsize) {
1387 key->dptr = buf+offset;
1388 offset += key->dsize;
1390 if (len-offset < data->dsize) {
1394 data->dptr = buf+offset;
1395 offset += data->dsize;
1401 static int ctdb_rec_data_pull_elems(uint8_t *buf, size_t buflen,
1402 TALLOC_CTX *mem_ctx,
1403 struct ctdb_rec_data *out,
1411 ret = ctdb_rec_data_pull_data(buf, buflen, &reqid, &key, &data, &np);
1418 /* Always set header to NULL. If it is required, extract it using
1419 * ctdb_rec_data_extract_header()
1423 out->key.dsize = key.dsize;
1424 if (key.dsize > 0) {
1425 out->key.dptr = talloc_memdup(mem_ctx, key.dptr, key.dsize);
1426 if (out->key.dptr == NULL) {
1431 out->data.dsize = data.dsize;
1432 if (data.dsize > 0) {
1433 out->data.dptr = talloc_memdup(mem_ctx, data.dptr, data.dsize);
1434 if (out->data.dptr == NULL) {
1443 int ctdb_rec_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
1444 struct ctdb_rec_data **out, size_t *npull)
1446 struct ctdb_rec_data *val;
1450 val = talloc(mem_ctx, struct ctdb_rec_data);
1455 ret = ctdb_rec_data_pull_elems(buf, buflen, val, val, &np);
1466 size_t ctdb_rec_buffer_len(struct ctdb_rec_buffer *in)
1468 return ctdb_uint32_len(&in->db_id) +
1469 ctdb_uint32_len(&in->count) +
1473 void ctdb_rec_buffer_push(struct ctdb_rec_buffer *in, uint8_t *buf,
1476 size_t offset = 0, np;
1478 ctdb_uint32_push(&in->db_id, buf+offset, &np);
1481 ctdb_uint32_push(&in->count, buf+offset, &np);
1484 memcpy(buf+offset, in->buf, in->buflen);
1485 offset += in->buflen;
1490 int ctdb_rec_buffer_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
1491 struct ctdb_rec_buffer **out, size_t *npull)
1493 struct ctdb_rec_buffer *val;
1494 size_t offset = 0, np;
1498 val = talloc(mem_ctx, struct ctdb_rec_buffer);
1503 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->db_id, &np);
1509 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->count, &np);
1515 /* Since there is no buflen provided, walk the records to
1516 * validate the length of the buffer.
1518 val->buf = buf+offset;
1519 val->buflen = buflen-offset;
1522 ret = ctdb_rec_buffer_traverse(val, NULL, &length);
1527 if (length > buflen-offset) {
1532 val->buf = talloc_memdup(val, buf+offset, length);
1533 if (val->buf == NULL) {
1537 val->buflen = length;
1549 struct ctdb_rec_buffer *ctdb_rec_buffer_init(TALLOC_CTX *mem_ctx,
1552 struct ctdb_rec_buffer *recbuf;
1554 recbuf = talloc_zero(mem_ctx, struct ctdb_rec_buffer);
1555 if (recbuf == NULL) {
1559 recbuf->db_id = db_id;
1564 int ctdb_rec_buffer_add(TALLOC_CTX *mem_ctx, struct ctdb_rec_buffer *recbuf,
1565 uint32_t reqid, struct ctdb_ltdb_header *header,
1566 TDB_DATA key, TDB_DATA data)
1568 struct ctdb_rec_data recdata;
1572 recdata.reqid = reqid;
1573 recdata.header = header;
1575 recdata.data = data;
1577 len = ctdb_rec_data_len(&recdata);
1579 ptr = talloc_realloc(mem_ctx, recbuf->buf, uint8_t,
1580 recbuf->buflen + len);
1585 ctdb_rec_data_push(&recdata, &ptr[recbuf->buflen], &np);
1589 recbuf->buflen += np;
1593 int ctdb_rec_buffer_traverse(struct ctdb_rec_buffer *recbuf,
1594 ctdb_rec_parser_func_t func,
1599 size_t offset, reclen;
1603 for (i=0; i<recbuf->count; i++) {
1604 ret = ctdb_rec_data_pull_data(&recbuf->buf[offset],
1605 recbuf->buflen - offset,
1606 &reqid, &key, &data, &reclen);
1612 ret = func(reqid, NULL, key, data, private_data);
1626 size_t *length = (size_t *)private_data;
1634 int ctdb_rec_buffer_write(struct ctdb_rec_buffer *recbuf, int fd)
1638 n = write(fd, &recbuf->db_id, sizeof(uint32_t));
1639 if (n == -1 || n != sizeof(uint32_t)) {
1640 return (errno != 0 ? errno : EIO);
1642 n = write(fd, &recbuf->count, sizeof(uint32_t));
1643 if (n == -1 || n != sizeof(uint32_t)) {
1644 return (errno != 0 ? errno : EIO);
1646 n = write(fd, &recbuf->buflen, sizeof(size_t));
1647 if (n == -1 || n != sizeof(size_t)) {
1648 return (errno != 0 ? errno : EIO);
1650 n = write(fd, recbuf->buf, recbuf->buflen);
1651 if (n == -1 || n != recbuf->buflen) {
1652 return (errno != 0 ? errno : EIO);
1658 int ctdb_rec_buffer_read(int fd, TALLOC_CTX *mem_ctx,
1659 struct ctdb_rec_buffer **out)
1661 struct ctdb_rec_buffer *recbuf;
1664 recbuf = talloc(mem_ctx, struct ctdb_rec_buffer);
1665 if (recbuf == NULL) {
1669 n = read(fd, &recbuf->db_id, sizeof(uint32_t));
1670 if (n == -1 || n != sizeof(uint32_t)) {
1671 return (errno != 0 ? errno : EIO);
1673 n = read(fd, &recbuf->count, sizeof(uint32_t));
1674 if (n == -1 || n != sizeof(uint32_t)) {
1675 return (errno != 0 ? errno : EIO);
1677 n = read(fd, &recbuf->buflen, sizeof(size_t));
1678 if (n == -1 || n != sizeof(size_t)) {
1679 return (errno != 0 ? errno : EIO);
1682 recbuf->buf = talloc_size(recbuf, recbuf->buflen);
1683 if (recbuf->buf == NULL) {
1687 n = read(fd, recbuf->buf, recbuf->buflen);
1688 if (n == -1 || n != recbuf->buflen) {
1689 return (errno != 0 ? errno : EIO);
1696 size_t ctdb_traverse_start_len(struct ctdb_traverse_start *in)
1698 return ctdb_uint32_len(&in->db_id) +
1699 ctdb_uint32_len(&in->reqid) +
1700 ctdb_uint64_len(&in->srvid);
1703 void ctdb_traverse_start_push(struct ctdb_traverse_start *in, uint8_t *buf,
1706 size_t offset = 0, np;
1708 ctdb_uint32_push(&in->db_id, buf+offset, &np);
1711 ctdb_uint32_push(&in->reqid, buf+offset, &np);
1714 ctdb_uint64_push(&in->srvid, buf+offset, &np);
1720 int ctdb_traverse_start_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
1721 struct ctdb_traverse_start **out, size_t *npull)
1723 struct ctdb_traverse_start *val;
1724 size_t offset = 0, np;
1727 val = talloc(mem_ctx, struct ctdb_traverse_start);
1732 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->db_id, &np);
1738 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->reqid, &np);
1744 ret = ctdb_uint64_pull(buf+offset, buflen-offset, &val->srvid, &np);
1759 size_t ctdb_traverse_all_len(struct ctdb_traverse_all *in)
1761 return ctdb_uint32_len(&in->db_id) +
1762 ctdb_uint32_len(&in->reqid) +
1763 ctdb_uint32_len(&in->pnn) +
1764 ctdb_uint32_len(&in->client_reqid) +
1765 ctdb_uint64_len(&in->srvid);
1768 void ctdb_traverse_all_push(struct ctdb_traverse_all *in, uint8_t *buf,
1771 size_t offset = 0, np;
1773 ctdb_uint32_push(&in->db_id, buf+offset, &np);
1776 ctdb_uint32_push(&in->reqid, buf+offset, &np);
1779 ctdb_uint32_push(&in->pnn, buf+offset, &np);
1782 ctdb_uint32_push(&in->client_reqid, buf+offset, &np);
1785 ctdb_uint64_push(&in->srvid, buf+offset, &np);
1791 int ctdb_traverse_all_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
1792 struct ctdb_traverse_all **out, size_t *npull)
1794 struct ctdb_traverse_all *val;
1795 size_t offset = 0, np;
1798 val = talloc(mem_ctx, struct ctdb_traverse_all);
1803 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->db_id, &np);
1809 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->reqid, &np);
1815 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->pnn, &np);
1821 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->client_reqid,
1828 ret = ctdb_uint64_pull(buf+offset, buflen-offset, &val->srvid, &np);
1843 size_t ctdb_traverse_start_ext_len(struct ctdb_traverse_start_ext *in)
1845 return ctdb_uint32_len(&in->db_id) +
1846 ctdb_uint32_len(&in->reqid) +
1847 ctdb_uint64_len(&in->srvid) +
1848 ctdb_bool_len(&in->withemptyrecords) +
1849 ctdb_padding_len(7);
1852 void ctdb_traverse_start_ext_push(struct ctdb_traverse_start_ext *in,
1853 uint8_t *buf, size_t *npush)
1855 size_t offset = 0, np;
1857 ctdb_uint32_push(&in->db_id, buf+offset, &np);
1860 ctdb_uint32_push(&in->reqid, buf+offset, &np);
1863 ctdb_uint64_push(&in->srvid, buf+offset, &np);
1866 ctdb_bool_push(&in->withemptyrecords, buf+offset, &np);
1869 ctdb_padding_push(7, buf+offset, &np);
1875 int ctdb_traverse_start_ext_pull(uint8_t *buf, size_t buflen,
1876 TALLOC_CTX *mem_ctx,
1877 struct ctdb_traverse_start_ext **out,
1880 struct ctdb_traverse_start_ext *val;
1881 size_t offset = 0, np;
1884 val = talloc(mem_ctx, struct ctdb_traverse_start_ext);
1889 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->db_id, &np);
1895 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->reqid, &np);
1901 ret = ctdb_uint64_pull(buf+offset, buflen-offset, &val->srvid, &np);
1907 ret = ctdb_bool_pull(buf+offset, buflen-offset,
1908 &val->withemptyrecords, &np);
1914 ret = ctdb_padding_pull(buf+offset, buflen-offset, 7, &np);
1929 size_t ctdb_traverse_all_ext_len(struct ctdb_traverse_all_ext *in)
1931 return ctdb_uint32_len(&in->db_id) +
1932 ctdb_uint32_len(&in->reqid) +
1933 ctdb_uint32_len(&in->pnn) +
1934 ctdb_uint32_len(&in->client_reqid) +
1935 ctdb_uint64_len(&in->srvid) +
1936 ctdb_bool_len(&in->withemptyrecords) +
1937 ctdb_padding_len(7);
1940 void ctdb_traverse_all_ext_push(struct ctdb_traverse_all_ext *in,
1941 uint8_t *buf, size_t *npush)
1943 size_t offset = 0, np;
1945 ctdb_uint32_push(&in->db_id, buf+offset, &np);
1948 ctdb_uint32_push(&in->reqid, buf+offset, &np);
1951 ctdb_uint32_push(&in->pnn, buf+offset, &np);
1954 ctdb_uint32_push(&in->client_reqid, buf+offset, &np);
1957 ctdb_uint64_push(&in->srvid, buf+offset, &np);
1960 ctdb_bool_push(&in->withemptyrecords, buf+offset, &np);
1963 ctdb_padding_push(7, buf+offset, &np);
1969 int ctdb_traverse_all_ext_pull(uint8_t *buf, size_t buflen,
1970 TALLOC_CTX *mem_ctx,
1971 struct ctdb_traverse_all_ext **out,
1974 struct ctdb_traverse_all_ext *val;
1975 size_t offset = 0, np;
1978 val = talloc(mem_ctx, struct ctdb_traverse_all_ext);
1983 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->db_id, &np);
1989 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->reqid, &np);
1995 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->pnn, &np);
2001 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->client_reqid,
2008 ret = ctdb_uint64_pull(buf+offset, buflen-offset, &val->srvid, &np);
2014 ret = ctdb_bool_pull(buf+offset, buflen-offset,
2015 &val->withemptyrecords, &np);
2021 ret = ctdb_padding_pull(buf+offset, buflen-offset, 7, &np);
2036 size_t ctdb_sock_addr_len(ctdb_sock_addr *in)
2038 return sizeof(ctdb_sock_addr);
2041 void ctdb_sock_addr_push(ctdb_sock_addr *in, uint8_t *buf, size_t *npush)
2043 memcpy(buf, in, sizeof(ctdb_sock_addr));
2044 *npush = sizeof(ctdb_sock_addr);
2047 int ctdb_sock_addr_pull_elems(uint8_t *buf, size_t buflen,
2048 TALLOC_CTX *mem_ctx, ctdb_sock_addr *out,
2051 if (buflen < sizeof(ctdb_sock_addr)) {
2055 memcpy(out, buf, sizeof(ctdb_sock_addr));
2056 *npull = sizeof(ctdb_sock_addr);
2061 int ctdb_sock_addr_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
2062 ctdb_sock_addr **out, size_t *npull)
2064 ctdb_sock_addr *val;
2068 val = talloc(mem_ctx, ctdb_sock_addr);
2073 ret = ctdb_sock_addr_pull_elems(buf, buflen, val, val, &np);
2084 size_t ctdb_connection_len(struct ctdb_connection *in)
2086 return ctdb_sock_addr_len(&in->src) +
2087 ctdb_sock_addr_len(&in->dst);
2090 void ctdb_connection_push(struct ctdb_connection *in, uint8_t *buf,
2093 size_t offset = 0, np;
2095 ctdb_sock_addr_push(&in->src, buf+offset, &np);
2098 ctdb_sock_addr_push(&in->dst, buf+offset, &np);
2104 static int ctdb_connection_pull_elems(uint8_t *buf, size_t buflen,
2105 TALLOC_CTX *mem_ctx,
2106 struct ctdb_connection *out,
2109 size_t offset = 0, np;
2112 ret = ctdb_sock_addr_pull_elems(buf+offset, buflen-offset,
2113 mem_ctx, &out->src, &np);
2119 ret = ctdb_sock_addr_pull_elems(buf+offset, buflen-offset,
2120 mem_ctx, &out->dst, &np);
2130 int ctdb_connection_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
2131 struct ctdb_connection **out, size_t *npull)
2133 struct ctdb_connection *val;
2137 val = talloc(mem_ctx, struct ctdb_connection);
2142 ret = ctdb_connection_pull_elems(buf, buflen, val, val, &np);
2153 size_t ctdb_tunable_len(struct ctdb_tunable *in)
2155 return ctdb_uint32_len(&in->value) +
2156 ctdb_stringn_len(&in->name);
2159 void ctdb_tunable_push(struct ctdb_tunable *in, uint8_t *buf, size_t *npush)
2161 size_t offset = 0, np;
2163 ctdb_uint32_push(&in->value, buf+offset, &np);
2166 ctdb_stringn_push(&in->name, buf+offset, &np);
2172 int ctdb_tunable_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
2173 struct ctdb_tunable **out, size_t *npull)
2175 struct ctdb_tunable *val;
2176 size_t offset = 0, np;
2179 val = talloc(mem_ctx, struct ctdb_tunable);
2184 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->value, &np);
2190 ret = ctdb_stringn_pull(buf+offset, buflen-offset, mem_ctx,
2206 size_t ctdb_node_flag_change_len(struct ctdb_node_flag_change *in)
2208 return ctdb_uint32_len(&in->pnn) +
2209 ctdb_uint32_len(&in->new_flags) +
2210 ctdb_uint32_len(&in->old_flags);
2213 void ctdb_node_flag_change_push(struct ctdb_node_flag_change *in,
2214 uint8_t *buf, size_t *npush)
2216 size_t offset = 0, np;
2218 ctdb_uint32_push(&in->pnn, buf+offset, &np);
2221 ctdb_uint32_push(&in->new_flags, buf+offset, &np);
2224 ctdb_uint32_push(&in->old_flags, buf+offset, &np);
2230 int ctdb_node_flag_change_pull(uint8_t *buf, size_t buflen,
2231 TALLOC_CTX *mem_ctx,
2232 struct ctdb_node_flag_change **out,
2235 struct ctdb_node_flag_change *val;
2236 size_t offset = 0, np;
2239 val = talloc(mem_ctx, struct ctdb_node_flag_change);
2244 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->pnn, &np);
2250 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->new_flags,
2257 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->old_flags,
2273 size_t ctdb_var_list_len(struct ctdb_var_list *in)
2278 for (i=0; i<in->count; i++) {
2279 u32 += ctdb_string_len(&in->var[i]);
2282 return ctdb_uint32_len(&u32) + u32;
2285 void ctdb_var_list_push(struct ctdb_var_list *in, uint8_t *buf, size_t *npush)
2287 size_t offset = 0, np;
2292 /* The length only corresponds to the payload size */
2293 u32 = ctdb_var_list_len(in);
2294 u32 -= ctdb_uint32_len(&u32);
2296 ctdb_uint32_push(&u32, buf+offset, &np);
2299 /* The variables are separated by ':' and the complete string is null
2302 for (i=0; i<in->count; i++) {
2303 ctdb_string_push(&in->var[i], buf+offset, &np);
2306 if (i < in->count - 1) {
2307 /* Replace '\0' with ':' */
2308 ctdb_uint8_push(&sep, buf+offset-1, &np);
2315 int ctdb_var_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
2316 struct ctdb_var_list **out, size_t *npull)
2318 struct ctdb_var_list *val;
2319 const char *str, **list;
2320 char *s, *tok, *ptr = NULL;
2321 size_t offset = 0, np;
2325 val = talloc_zero(mem_ctx, struct ctdb_var_list);
2330 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &u32, &np);
2336 if (buflen-offset < u32) {
2341 ret = ctdb_string_pull(buf+offset, u32, val, &str, &np);
2347 s = discard_const(str);
2348 while ((tok = strtok_r(s, ":", &ptr)) != NULL) {
2349 list = talloc_realloc(val, val->var, const char *,
2358 s = talloc_strdup(val, tok);
2364 val->var[val->count] = s;
2369 talloc_free(discard_const(str));
2379 size_t ctdb_tunable_list_len(struct ctdb_tunable_list *in)
2381 return ctdb_uint32_len(&in->max_redirect_count) +
2382 ctdb_uint32_len(&in->seqnum_interval) +
2383 ctdb_uint32_len(&in->control_timeout) +
2384 ctdb_uint32_len(&in->traverse_timeout) +
2385 ctdb_uint32_len(&in->keepalive_interval) +
2386 ctdb_uint32_len(&in->keepalive_limit) +
2387 ctdb_uint32_len(&in->recover_timeout) +
2388 ctdb_uint32_len(&in->recover_interval) +
2389 ctdb_uint32_len(&in->election_timeout) +
2390 ctdb_uint32_len(&in->takeover_timeout) +
2391 ctdb_uint32_len(&in->monitor_interval) +
2392 ctdb_uint32_len(&in->tickle_update_interval) +
2393 ctdb_uint32_len(&in->script_timeout) +
2394 ctdb_uint32_len(&in->monitor_timeout_count) +
2395 ctdb_uint32_len(&in->script_unhealthy_on_timeout) +
2396 ctdb_uint32_len(&in->recovery_grace_period) +
2397 ctdb_uint32_len(&in->recovery_ban_period) +
2398 ctdb_uint32_len(&in->database_hash_size) +
2399 ctdb_uint32_len(&in->database_max_dead) +
2400 ctdb_uint32_len(&in->rerecovery_timeout) +
2401 ctdb_uint32_len(&in->enable_bans) +
2402 ctdb_uint32_len(&in->deterministic_public_ips) +
2403 ctdb_uint32_len(&in->reclock_ping_period) +
2404 ctdb_uint32_len(&in->no_ip_failback) +
2405 ctdb_uint32_len(&in->disable_ip_failover) +
2406 ctdb_uint32_len(&in->verbose_memory_names) +
2407 ctdb_uint32_len(&in->recd_ping_timeout) +
2408 ctdb_uint32_len(&in->recd_ping_failcount) +
2409 ctdb_uint32_len(&in->log_latency_ms) +
2410 ctdb_uint32_len(&in->reclock_latency_ms) +
2411 ctdb_uint32_len(&in->recovery_drop_all_ips) +
2412 ctdb_uint32_len(&in->verify_recovery_lock) +
2413 ctdb_uint32_len(&in->vacuum_interval) +
2414 ctdb_uint32_len(&in->vacuum_max_run_time) +
2415 ctdb_uint32_len(&in->repack_limit) +
2416 ctdb_uint32_len(&in->vacuum_limit) +
2417 ctdb_uint32_len(&in->max_queue_depth_drop_msg) +
2418 ctdb_uint32_len(&in->allow_unhealthy_db_read) +
2419 ctdb_uint32_len(&in->stat_history_interval) +
2420 ctdb_uint32_len(&in->deferred_attach_timeout) +
2421 ctdb_uint32_len(&in->vacuum_fast_path_count) +
2422 ctdb_uint32_len(&in->lcp2_public_ip_assignment) +
2423 ctdb_uint32_len(&in->allow_client_db_attach) +
2424 ctdb_uint32_len(&in->recover_pdb_by_seqnum) +
2425 ctdb_uint32_len(&in->deferred_rebalance_on_node_add) +
2426 ctdb_uint32_len(&in->fetch_collapse) +
2427 ctdb_uint32_len(&in->hopcount_make_sticky) +
2428 ctdb_uint32_len(&in->sticky_duration) +
2429 ctdb_uint32_len(&in->sticky_pindown) +
2430 ctdb_uint32_len(&in->no_ip_takeover) +
2431 ctdb_uint32_len(&in->db_record_count_warn) +
2432 ctdb_uint32_len(&in->db_record_size_warn) +
2433 ctdb_uint32_len(&in->db_size_warn) +
2434 ctdb_uint32_len(&in->pulldb_preallocation_size) +
2435 ctdb_uint32_len(&in->no_ip_host_on_all_disabled) +
2436 ctdb_uint32_len(&in->samba3_hack) +
2437 ctdb_uint32_len(&in->mutex_enabled) +
2438 ctdb_uint32_len(&in->lock_processes_per_db) +
2439 ctdb_uint32_len(&in->rec_buffer_size_limit) +
2440 ctdb_uint32_len(&in->queue_buffer_size) +
2441 ctdb_uint32_len(&in->ip_alloc_algorithm) +
2442 ctdb_uint32_len(&in->allow_mixed_versions);
2445 void ctdb_tunable_list_push(struct ctdb_tunable_list *in, uint8_t *buf,
2448 size_t offset = 0, np;
2450 ctdb_uint32_push(&in->max_redirect_count, buf+offset, &np);
2453 ctdb_uint32_push(&in->seqnum_interval, buf+offset, &np);
2456 ctdb_uint32_push(&in->control_timeout, buf+offset, &np);
2459 ctdb_uint32_push(&in->traverse_timeout, buf+offset, &np);
2462 ctdb_uint32_push(&in->keepalive_interval, buf+offset, &np);
2465 ctdb_uint32_push(&in->keepalive_limit, buf+offset, &np);
2468 ctdb_uint32_push(&in->recover_timeout, buf+offset, &np);
2471 ctdb_uint32_push(&in->recover_interval, buf+offset, &np);
2474 ctdb_uint32_push(&in->election_timeout, buf+offset, &np);
2477 ctdb_uint32_push(&in->takeover_timeout, buf+offset, &np);
2480 ctdb_uint32_push(&in->monitor_interval, buf+offset, &np);
2483 ctdb_uint32_push(&in->tickle_update_interval, buf+offset, &np);
2486 ctdb_uint32_push(&in->script_timeout, buf+offset, &np);
2489 ctdb_uint32_push(&in->monitor_timeout_count, buf+offset, &np);
2492 ctdb_uint32_push(&in->script_unhealthy_on_timeout, buf+offset, &np);
2495 ctdb_uint32_push(&in->recovery_grace_period, buf+offset, &np);
2498 ctdb_uint32_push(&in->recovery_ban_period, buf+offset, &np);
2501 ctdb_uint32_push(&in->database_hash_size, buf+offset, &np);
2504 ctdb_uint32_push(&in->database_max_dead, buf+offset, &np);
2507 ctdb_uint32_push(&in->rerecovery_timeout, buf+offset, &np);
2510 ctdb_uint32_push(&in->enable_bans, buf+offset, &np);
2513 ctdb_uint32_push(&in->deterministic_public_ips, buf+offset, &np);
2516 ctdb_uint32_push(&in->reclock_ping_period, buf+offset, &np);
2519 ctdb_uint32_push(&in->no_ip_failback, buf+offset, &np);
2522 ctdb_uint32_push(&in->disable_ip_failover, buf+offset, &np);
2525 ctdb_uint32_push(&in->verbose_memory_names, buf+offset, &np);
2528 ctdb_uint32_push(&in->recd_ping_timeout, buf+offset, &np);
2531 ctdb_uint32_push(&in->recd_ping_failcount, buf+offset, &np);
2534 ctdb_uint32_push(&in->log_latency_ms, buf+offset, &np);
2537 ctdb_uint32_push(&in->reclock_latency_ms, buf+offset, &np);
2540 ctdb_uint32_push(&in->recovery_drop_all_ips, buf+offset, &np);
2543 ctdb_uint32_push(&in->verify_recovery_lock, buf+offset, &np);
2546 ctdb_uint32_push(&in->vacuum_interval, buf+offset, &np);
2549 ctdb_uint32_push(&in->vacuum_max_run_time, buf+offset, &np);
2552 ctdb_uint32_push(&in->repack_limit, buf+offset, &np);
2555 ctdb_uint32_push(&in->vacuum_limit, buf+offset, &np);
2558 ctdb_uint32_push(&in->max_queue_depth_drop_msg, buf+offset, &np);
2561 ctdb_uint32_push(&in->allow_unhealthy_db_read, buf+offset, &np);
2564 ctdb_uint32_push(&in->stat_history_interval, buf+offset, &np);
2567 ctdb_uint32_push(&in->deferred_attach_timeout, buf+offset, &np);
2570 ctdb_uint32_push(&in->vacuum_fast_path_count, buf+offset, &np);
2573 ctdb_uint32_push(&in->lcp2_public_ip_assignment, buf+offset, &np);
2576 ctdb_uint32_push(&in->allow_client_db_attach, buf+offset, &np);
2579 ctdb_uint32_push(&in->recover_pdb_by_seqnum, buf+offset, &np);
2582 ctdb_uint32_push(&in->deferred_rebalance_on_node_add, buf+offset, &np);
2585 ctdb_uint32_push(&in->fetch_collapse, buf+offset, &np);
2588 ctdb_uint32_push(&in->hopcount_make_sticky, buf+offset, &np);
2591 ctdb_uint32_push(&in->sticky_duration, buf+offset, &np);
2594 ctdb_uint32_push(&in->sticky_pindown, buf+offset, &np);
2597 ctdb_uint32_push(&in->no_ip_takeover, buf+offset, &np);
2600 ctdb_uint32_push(&in->db_record_count_warn, buf+offset, &np);
2603 ctdb_uint32_push(&in->db_record_size_warn, buf+offset, &np);
2606 ctdb_uint32_push(&in->db_size_warn, buf+offset, &np);
2609 ctdb_uint32_push(&in->pulldb_preallocation_size, buf+offset, &np);
2612 ctdb_uint32_push(&in->no_ip_host_on_all_disabled, buf+offset, &np);
2615 ctdb_uint32_push(&in->samba3_hack, buf+offset, &np);
2618 ctdb_uint32_push(&in->mutex_enabled, buf+offset, &np);
2621 ctdb_uint32_push(&in->lock_processes_per_db, buf+offset, &np);
2624 ctdb_uint32_push(&in->rec_buffer_size_limit, buf+offset, &np);
2627 ctdb_uint32_push(&in->queue_buffer_size, buf+offset, &np);
2630 ctdb_uint32_push(&in->ip_alloc_algorithm, buf+offset, &np);
2633 ctdb_uint32_push(&in->allow_mixed_versions, buf+offset, &np);
2639 static int ctdb_tunable_list_pull_elems(uint8_t *buf, size_t buflen,
2640 TALLOC_CTX *mem_ctx,
2641 struct ctdb_tunable_list *out,
2644 size_t offset = 0, np;
2647 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2648 &out->max_redirect_count, &np);
2654 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2655 &out->seqnum_interval, &np);
2661 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2662 &out->control_timeout, &np);
2668 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2669 &out->traverse_timeout, &np);
2675 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2676 &out->keepalive_interval, &np);
2682 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2683 &out->keepalive_limit, &np);
2689 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2690 &out->recover_timeout, &np);
2696 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2697 &out->recover_interval, &np);
2703 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2704 &out->election_timeout, &np);
2710 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2711 &out->takeover_timeout, &np);
2717 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2718 &out->monitor_interval, &np);
2724 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2725 &out->tickle_update_interval, &np);
2731 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2732 &out->script_timeout, &np);
2738 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2739 &out->monitor_timeout_count, &np);
2745 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2746 &out->script_unhealthy_on_timeout, &np);
2752 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2753 &out->recovery_grace_period, &np);
2759 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2760 &out->recovery_ban_period, &np);
2766 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2767 &out->database_hash_size, &np);
2773 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2774 &out->database_max_dead, &np);
2780 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2781 &out->rerecovery_timeout, &np);
2787 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2788 &out->enable_bans, &np);
2794 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2795 &out->deterministic_public_ips, &np);
2801 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2802 &out->reclock_ping_period, &np);
2808 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2809 &out->no_ip_failback, &np);
2815 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2816 &out->disable_ip_failover, &np);
2822 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2823 &out->verbose_memory_names, &np);
2829 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2830 &out->recd_ping_timeout, &np);
2836 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2837 &out->recd_ping_failcount, &np);
2843 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2844 &out->log_latency_ms, &np);
2850 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2851 &out->reclock_latency_ms, &np);
2857 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2858 &out->recovery_drop_all_ips, &np);
2864 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2865 &out->verify_recovery_lock, &np);
2871 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2872 &out->vacuum_interval, &np);
2878 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2879 &out->vacuum_max_run_time, &np);
2885 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2886 &out->repack_limit, &np);
2892 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2893 &out->vacuum_limit, &np);
2899 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2900 &out->max_queue_depth_drop_msg, &np);
2906 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2907 &out->allow_unhealthy_db_read, &np);
2913 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2914 &out->stat_history_interval, &np);
2920 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2921 &out->deferred_attach_timeout, &np);
2927 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2928 &out->vacuum_fast_path_count, &np);
2934 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2935 &out->lcp2_public_ip_assignment, &np);
2941 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2942 &out->allow_client_db_attach, &np);
2948 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2949 &out->recover_pdb_by_seqnum, &np);
2955 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2956 &out->deferred_rebalance_on_node_add, &np);
2962 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2963 &out->fetch_collapse, &np);
2969 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2970 &out->hopcount_make_sticky, &np);
2976 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2977 &out->sticky_duration, &np);
2983 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2984 &out->sticky_pindown, &np);
2990 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2991 &out->no_ip_takeover, &np);
2997 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
2998 &out->db_record_count_warn, &np);
3004 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
3005 &out->db_record_size_warn, &np);
3011 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
3012 &out->db_size_warn, &np);
3018 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
3019 &out->pulldb_preallocation_size, &np);
3025 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
3026 &out->no_ip_host_on_all_disabled, &np);
3032 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
3033 &out->samba3_hack, &np);
3039 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
3040 &out->mutex_enabled, &np);
3046 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
3047 &out->lock_processes_per_db, &np);
3053 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
3054 &out->rec_buffer_size_limit, &np);
3060 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
3061 &out->queue_buffer_size, &np);
3067 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
3068 &out->ip_alloc_algorithm, &np);
3074 ret = ctdb_uint32_pull(buf+offset, buflen-offset,
3075 &out->allow_mixed_versions, &np);
3085 int ctdb_tunable_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
3086 struct ctdb_tunable_list **out, size_t *npull)
3088 struct ctdb_tunable_list *val;
3092 val = talloc(mem_ctx, struct ctdb_tunable_list);
3097 ret = ctdb_tunable_list_pull_elems(buf, buflen, val, val, &np);
3108 size_t ctdb_tickle_list_len(struct ctdb_tickle_list *in)
3112 len = ctdb_sock_addr_len(&in->addr) +
3113 ctdb_uint32_len(&in->num);
3115 len += in->num * ctdb_connection_len(&in->conn[0]);
3121 void ctdb_tickle_list_push(struct ctdb_tickle_list *in, uint8_t *buf,
3124 size_t offset = 0, np;
3127 ctdb_sock_addr_push(&in->addr, buf+offset, &np);
3130 ctdb_uint32_push(&in->num, buf+offset, &np);
3133 for (i=0; i<in->num; i++) {
3134 ctdb_connection_push(&in->conn[i], buf+offset, &np);
3141 int ctdb_tickle_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
3142 struct ctdb_tickle_list **out, size_t *npull)
3144 struct ctdb_tickle_list *val;
3145 size_t offset = 0, np;
3149 val = talloc(mem_ctx, struct ctdb_tickle_list);
3154 ret = ctdb_sock_addr_pull_elems(buf+offset, buflen-offset, val,
3161 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->num, &np);
3167 if (val->num == 0) {
3172 val->conn = talloc_array(val, struct ctdb_connection, val->num);
3173 if (val->conn == NULL) {
3178 for (i=0; i<val->num; i++) {
3179 ret = ctdb_connection_pull_elems(buf+offset, buflen-offset,
3180 val, &val->conn[i], &np);
3197 size_t ctdb_addr_info_len(struct ctdb_addr_info *in)
3199 return ctdb_sock_addr_len(&in->addr) +
3200 ctdb_uint32_len(&in->mask) +
3201 ctdb_stringn_len(&in->iface);
3204 void ctdb_addr_info_push(struct ctdb_addr_info *in, uint8_t *buf,
3207 size_t offset = 0, np;
3209 ctdb_sock_addr_push(&in->addr, buf+offset, &np);
3212 ctdb_uint32_push(&in->mask, buf+offset, &np);
3215 ctdb_stringn_push(&in->iface, buf+offset, &np);
3221 int ctdb_addr_info_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
3222 struct ctdb_addr_info **out, size_t *npull)
3224 struct ctdb_addr_info *val;
3225 size_t offset = 0, np;
3228 val = talloc(mem_ctx, struct ctdb_addr_info);
3233 ret = ctdb_sock_addr_pull_elems(buf+offset, buflen-offset, val,
3240 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->mask, &np);
3246 ret = ctdb_stringn_pull(buf+offset, buflen-offset, val, &val->iface,
3262 size_t ctdb_transdb_len(struct ctdb_transdb *in)
3264 return ctdb_uint32_len(&in->db_id) +
3265 ctdb_uint32_len(&in->tid);
3268 void ctdb_transdb_push(struct ctdb_transdb *in, uint8_t *buf, size_t *npush)
3270 size_t offset = 0, np;
3272 ctdb_uint32_push(&in->db_id, buf+offset, &np);
3275 ctdb_uint32_push(&in->tid, buf+offset, &np);
3281 int ctdb_transdb_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
3282 struct ctdb_transdb **out, size_t *npull)
3284 struct ctdb_transdb *val;
3285 size_t offset = 0, np;
3288 val = talloc(mem_ctx, struct ctdb_transdb);
3293 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->db_id, &np);
3299 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->tid, &np);
3314 size_t ctdb_uptime_len(struct ctdb_uptime *in)
3316 return ctdb_timeval_len(&in->current_time) +
3317 ctdb_timeval_len(&in->ctdbd_start_time) +
3318 ctdb_timeval_len(&in->last_recovery_started) +
3319 ctdb_timeval_len(&in->last_recovery_finished);
3322 void ctdb_uptime_push(struct ctdb_uptime *in, uint8_t *buf, size_t *npush)
3324 size_t offset = 0, np;
3326 ctdb_timeval_push(&in->current_time, buf+offset, &np);
3329 ctdb_timeval_push(&in->ctdbd_start_time, buf+offset, &np);
3332 ctdb_timeval_push(&in->last_recovery_started, buf+offset, &np);
3335 ctdb_timeval_push(&in->last_recovery_finished, buf+offset, &np);
3341 int ctdb_uptime_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
3342 struct ctdb_uptime **out, size_t *npull)
3344 struct ctdb_uptime *val;
3345 size_t offset = 0, np;
3348 val = talloc(mem_ctx, struct ctdb_uptime);
3353 ret = ctdb_timeval_pull(buf+offset, buflen-offset, &val->current_time,
3360 ret = ctdb_timeval_pull(buf+offset, buflen-offset,
3361 &val->ctdbd_start_time, &np);
3367 ret = ctdb_timeval_pull(buf+offset, buflen-offset,
3368 &val->last_recovery_started, &np);
3374 ret = ctdb_timeval_pull(buf+offset, buflen-offset,
3375 &val->last_recovery_finished, &np);
3390 size_t ctdb_public_ip_len(struct ctdb_public_ip *in)
3392 return ctdb_uint32_len(&in->pnn) +
3393 ctdb_sock_addr_len(&in->addr);
3396 void ctdb_public_ip_push(struct ctdb_public_ip *in, uint8_t *buf,
3399 size_t offset = 0, np;
3401 ctdb_uint32_push(&in->pnn, buf+offset, &np);
3404 ctdb_sock_addr_push(&in->addr, buf+offset, &np);
3410 static int ctdb_public_ip_pull_elems(uint8_t *buf, size_t buflen,
3411 TALLOC_CTX *mem_ctx,
3412 struct ctdb_public_ip *out, size_t *npull)
3414 size_t offset = 0, np;
3417 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &out->pnn, &np);
3423 ret = ctdb_sock_addr_pull_elems(buf+offset, buflen-offset, mem_ctx,
3434 int ctdb_public_ip_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
3435 struct ctdb_public_ip **out, size_t *npull)
3437 struct ctdb_public_ip *val;
3441 val = talloc(mem_ctx, struct ctdb_public_ip);
3446 ret = ctdb_public_ip_pull_elems(buf, buflen, val, val, &np);
3457 size_t ctdb_public_ip_list_len(struct ctdb_public_ip_list *in)
3461 len = ctdb_uint32_len(&in->num);
3463 len += in->num * ctdb_public_ip_len(&in->ip[0]);
3469 void ctdb_public_ip_list_push(struct ctdb_public_ip_list *in, uint8_t *buf,
3472 size_t offset = 0, np;
3475 ctdb_uint32_push(&in->num, buf+offset, &np);
3478 for (i=0; i<in->num; i++) {
3479 ctdb_public_ip_push(&in->ip[i], buf+offset, &np);
3486 int ctdb_public_ip_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
3487 struct ctdb_public_ip_list **out, size_t *npull)
3489 struct ctdb_public_ip_list *val;
3490 size_t offset = 0, np;
3494 val = talloc(mem_ctx, struct ctdb_public_ip_list);
3499 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->num, &np);
3505 if (val->num == 0) {
3510 val->ip = talloc_array(val, struct ctdb_public_ip, val->num);
3511 if (val->ip == NULL) {
3516 for (i=0; i<val->num; i++) {
3517 ret = ctdb_public_ip_pull_elems(buf+offset, buflen-offset,
3518 val->ip, &val->ip[i], &np);
3535 size_t ctdb_node_and_flags_len(struct ctdb_node_and_flags *in)
3537 return ctdb_uint32_len(&in->pnn) +
3538 ctdb_uint32_len(&in->flags) +
3539 ctdb_sock_addr_len(&in->addr);
3542 void ctdb_node_and_flags_push(struct ctdb_node_and_flags *in, uint8_t *buf,
3545 size_t offset = 0, np;
3547 ctdb_uint32_push(&in->pnn, buf+offset, &np);
3550 ctdb_uint32_push(&in->flags, buf+offset, &np);
3553 ctdb_sock_addr_push(&in->addr, buf+offset, &np);
3559 static int ctdb_node_and_flags_pull_elems(uint8_t *buf, size_t buflen,
3560 TALLOC_CTX *mem_ctx,
3561 struct ctdb_node_and_flags *out,
3564 size_t offset = 0, np;
3567 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &out->pnn, &np);
3573 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &out->flags, &np);
3579 ret = ctdb_sock_addr_pull_elems(buf+offset, buflen-offset, mem_ctx,
3590 int ctdb_node_and_flags_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
3591 struct ctdb_node_and_flags **out, size_t *npull)
3593 struct ctdb_node_and_flags *val;
3597 val = talloc(mem_ctx, struct ctdb_node_and_flags);
3602 ret = ctdb_node_and_flags_pull_elems(buf, buflen, val, val, &np);
3613 size_t ctdb_node_map_len(struct ctdb_node_map *in)
3617 len = ctdb_uint32_len(&in->num);
3619 len += in->num * ctdb_node_and_flags_len(&in->node[0]);
3625 void ctdb_node_map_push(struct ctdb_node_map *in, uint8_t *buf, size_t *npush)
3627 size_t offset = 0, np;
3630 ctdb_uint32_push(&in->num, buf+offset, &np);
3633 for (i=0; i<in->num; i++) {
3634 ctdb_node_and_flags_push(&in->node[i], buf+offset, &np);
3641 int ctdb_node_map_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
3642 struct ctdb_node_map **out, size_t *npull)
3644 struct ctdb_node_map *val;
3645 size_t offset = 0, np;
3649 val = talloc(mem_ctx, struct ctdb_node_map);
3654 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->num, &np);
3660 if (val->num == 0) {
3665 val->node = talloc_array(val, struct ctdb_node_and_flags, val->num);
3666 if (val->node == NULL) {
3671 for (i=0; i<val->num; i++) {
3672 ret = ctdb_node_and_flags_pull_elems(buf+offset,
3674 val->node, &val->node[i],
3692 size_t ctdb_script_len(struct ctdb_script *in)
3694 return ctdb_chararray_len(in->name, MAX_SCRIPT_NAME+1) +
3695 ctdb_timeval_len(&in->start) +
3696 ctdb_timeval_len(&in->finished) +
3697 ctdb_int32_len(&in->status) +
3698 ctdb_chararray_len(in->output, MAX_SCRIPT_OUTPUT+1) +
3699 ctdb_padding_len(4);
3702 void ctdb_script_push(struct ctdb_script *in, uint8_t *buf, size_t *npush)
3704 size_t offset = 0, np;
3706 ctdb_chararray_push(in->name, MAX_SCRIPT_NAME+1, buf+offset, &np);
3709 ctdb_timeval_push(&in->start, buf+offset, &np);
3712 ctdb_timeval_push(&in->finished, buf+offset, &np);
3715 ctdb_int32_push(&in->status, buf+offset, &np);
3718 ctdb_chararray_push(in->output, MAX_SCRIPT_OUTPUT+1, buf+offset, &np);
3721 ctdb_padding_push(4, buf+offset, &np);
3727 static int ctdb_script_pull_elems(uint8_t *buf, size_t buflen,
3728 TALLOC_CTX *mem_ctx,
3729 struct ctdb_script *out, size_t *npull)
3731 size_t offset = 0, np;
3734 ret = ctdb_chararray_pull(buf+offset, buflen-offset,
3735 out->name, MAX_SCRIPT_NAME+1, &np);
3741 ret = ctdb_timeval_pull(buf+offset, buflen-offset, &out->start, &np);
3747 ret = ctdb_timeval_pull(buf+offset, buflen-offset, &out->finished,
3754 ret = ctdb_int32_pull(buf+offset, buflen-offset, &out->status, &np);
3760 ret = ctdb_chararray_pull(buf+offset, buflen-offset,
3761 out->output, MAX_SCRIPT_OUTPUT+1, &np);
3767 ret = ctdb_padding_pull(buf+offset, buflen-offset, 4, &np);
3777 int ctdb_script_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
3778 struct ctdb_script **out, size_t *npull)
3780 struct ctdb_script *val;
3784 val = talloc(mem_ctx, struct ctdb_script);
3789 ret = ctdb_script_pull_elems(buf, buflen, val, val, &np);
3800 size_t ctdb_script_list_len(struct ctdb_script_list *in)
3808 len = ctdb_uint32_len(&in->num_scripts) + ctdb_padding_len(4);
3809 if (in->num_scripts > 0) {
3810 len += in->num_scripts * ctdb_script_len(&in->script[0]);
3816 void ctdb_script_list_push(struct ctdb_script_list *in, uint8_t *buf,
3819 size_t offset = 0, np;
3827 ctdb_uint32_push(&in->num_scripts, buf+offset, &np);
3830 ctdb_padding_push(4, buf+offset, &np);
3833 for (i=0; i<in->num_scripts; i++) {
3834 ctdb_script_push(&in->script[i], buf+offset, &np);
3841 int ctdb_script_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
3842 struct ctdb_script_list **out, size_t *npull)
3844 struct ctdb_script_list *val;
3845 size_t offset = 0, np;
3849 /* If event scripts have never been run, the result will be NULL */
3855 val = talloc(mem_ctx, struct ctdb_script_list);
3860 ret = ctdb_uint32_pull(buf+offset, buflen-offset, &val->num_scripts,
3867 ret = ctdb_padding_pull(buf+offset, buflen-offset, 4, &np);
3873 if (val->num_scripts == 0) {
3878 val->script = talloc_array(val, struct ctdb_script, val->num_scripts);
3879 if (val->script == NULL) {
3884 for (i=0; i<val->num_scripts; i++) {
3885 ret = ctdb_script_pull_elems(buf+offset, buflen-offset,
3886 val, &val->script[i], &np);
3903 size_t ctdb_ban_state_len(struct ctdb_ban_state *ban_state)
3905 return sizeof(struct ctdb_ban_state);
3908 void ctdb_ban_state_push(struct ctdb_ban_state *ban_state, uint8_t *buf)
3910 memcpy(buf, ban_state, sizeof(struct ctdb_ban_state));
3913 int ctdb_ban_state_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
3914 struct ctdb_ban_state **out)
3916 struct ctdb_ban_state *ban_state;
3918 if (buflen < sizeof(struct ctdb_ban_state)) {
3922 ban_state = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_ban_state));
3923 if (ban_state == NULL) {
3931 struct ctdb_notify_data_wire {
3937 size_t ctdb_notify_data_len(struct ctdb_notify_data *notify)
3939 return offsetof(struct ctdb_notify_data_wire, data) +
3943 void ctdb_notify_data_push(struct ctdb_notify_data *notify, uint8_t *buf)
3945 struct ctdb_notify_data_wire *wire =
3946 (struct ctdb_notify_data_wire *)buf;
3948 wire->srvid = notify->srvid;
3949 wire->len = notify->data.dsize;
3950 memcpy(wire->data, notify->data.dptr, notify->data.dsize);
3953 int ctdb_notify_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
3954 struct ctdb_notify_data **out)
3956 struct ctdb_notify_data *notify;
3957 struct ctdb_notify_data_wire *wire =
3958 (struct ctdb_notify_data_wire *)buf;
3960 if (buflen < offsetof(struct ctdb_notify_data_wire, data)) {
3963 if (wire->len > buflen) {
3966 if (offsetof(struct ctdb_notify_data_wire, data) + wire->len <
3967 offsetof(struct ctdb_notify_data_wire, data)) {
3970 if (buflen < offsetof(struct ctdb_notify_data_wire, data) + wire->len) {
3974 notify = talloc(mem_ctx, struct ctdb_notify_data);
3975 if (notify == NULL) {
3979 notify->srvid = wire->srvid;
3980 notify->data.dsize = wire->len;
3981 notify->data.dptr = talloc_memdup(notify, wire->data, wire->len);
3982 if (notify->data.dptr == NULL) {
3983 talloc_free(notify);
3991 size_t ctdb_iface_len(struct ctdb_iface *iface)
3993 return sizeof(struct ctdb_iface);
3996 void ctdb_iface_push(struct ctdb_iface *iface, uint8_t *buf)
3998 memcpy(buf, iface, sizeof(struct ctdb_iface));
4001 static int ctdb_iface_pull_elems(uint8_t *buf, size_t buflen,
4002 TALLOC_CTX *mem_ctx,
4003 struct ctdb_iface *out)
4005 if (buflen < sizeof(struct ctdb_iface)) {
4009 memcpy(out, buf, sizeof(struct ctdb_iface));
4014 int ctdb_iface_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
4015 struct ctdb_iface **out)
4017 struct ctdb_iface *iface;
4020 iface = talloc(mem_ctx, struct ctdb_iface);
4021 if (iface == NULL) {
4025 ret = ctdb_iface_pull_elems(buf, buflen, iface, iface);
4034 struct ctdb_iface_list_wire {
4036 struct ctdb_iface iface[1];
4039 size_t ctdb_iface_list_len(struct ctdb_iface_list *iface_list)
4041 return sizeof(uint32_t) +
4042 iface_list->num * sizeof(struct ctdb_iface);
4045 void ctdb_iface_list_push(struct ctdb_iface_list *iface_list, uint8_t *buf)
4047 struct ctdb_iface_list_wire *wire =
4048 (struct ctdb_iface_list_wire *)buf;
4050 wire->num = iface_list->num;
4051 memcpy(wire->iface, iface_list->iface,
4052 iface_list->num * sizeof(struct ctdb_iface));
4055 int ctdb_iface_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
4056 struct ctdb_iface_list **out)
4058 struct ctdb_iface_list *iface_list;
4059 struct ctdb_iface_list_wire *wire =
4060 (struct ctdb_iface_list_wire *)buf;
4062 if (buflen < sizeof(uint32_t)) {
4065 if (wire->num > buflen / sizeof(struct ctdb_iface)) {
4068 if (sizeof(uint32_t) + wire->num * sizeof(struct ctdb_iface) <
4072 if (buflen < sizeof(uint32_t) + wire->num * sizeof(struct ctdb_iface)) {
4076 iface_list = talloc(mem_ctx, struct ctdb_iface_list);
4077 if (iface_list == NULL) {
4081 iface_list->num = wire->num;
4082 iface_list->iface = talloc_array(iface_list, struct ctdb_iface,
4084 if (iface_list->iface == NULL) {
4085 talloc_free(iface_list);
4089 memcpy(iface_list->iface, wire->iface,
4090 wire->num * sizeof(struct ctdb_iface));
4096 struct ctdb_public_ip_info_wire {
4097 struct ctdb_public_ip ip;
4098 uint32_t active_idx;
4100 struct ctdb_iface ifaces[1];
4103 size_t ctdb_public_ip_info_len(struct ctdb_public_ip_info *ipinfo)
4105 return offsetof(struct ctdb_public_ip_info_wire, num) +
4106 ctdb_iface_list_len(ipinfo->ifaces);
4109 void ctdb_public_ip_info_push(struct ctdb_public_ip_info *ipinfo, uint8_t *buf)
4111 struct ctdb_public_ip_info_wire *wire =
4112 (struct ctdb_public_ip_info_wire *)buf;
4115 offset = offsetof(struct ctdb_public_ip_info_wire, num);
4116 memcpy(wire, ipinfo, offset);
4117 wire->num = ipinfo->ifaces->num;
4118 memcpy(wire->ifaces, ipinfo->ifaces->iface,
4119 ipinfo->ifaces->num * sizeof(struct ctdb_iface));
4122 int ctdb_public_ip_info_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
4123 struct ctdb_public_ip_info **out)
4125 struct ctdb_public_ip_info *ipinfo;
4126 struct ctdb_public_ip_info_wire *wire =
4127 (struct ctdb_public_ip_info_wire *)buf;
4129 if (buflen < offsetof(struct ctdb_public_ip_info_wire, ifaces)) {
4132 if (wire->num > buflen / sizeof(struct ctdb_iface)) {
4135 if (offsetof(struct ctdb_public_ip_info_wire, ifaces) +
4136 wire->num * sizeof(struct ctdb_iface) <
4137 offsetof(struct ctdb_public_ip_info_wire, ifaces)) {
4140 if (buflen < offsetof(struct ctdb_public_ip_info_wire, ifaces) +
4141 wire->num * sizeof(struct ctdb_iface)) {
4145 ipinfo = talloc(mem_ctx, struct ctdb_public_ip_info);
4146 if (ipinfo == NULL) {
4150 memcpy(ipinfo, wire, offsetof(struct ctdb_public_ip_info_wire, num));
4152 ipinfo->ifaces = talloc(ipinfo, struct ctdb_iface_list);
4153 if (ipinfo->ifaces == NULL) {
4154 talloc_free(ipinfo);
4158 ipinfo->ifaces->num = wire->num;
4159 ipinfo->ifaces->iface = talloc_array(ipinfo->ifaces, struct ctdb_iface,
4161 if (ipinfo->ifaces->iface == NULL) {
4162 talloc_free(ipinfo);
4166 memcpy(ipinfo->ifaces->iface, wire->ifaces,
4167 wire->num * sizeof(struct ctdb_iface));
4173 struct ctdb_key_data_wire {
4175 struct ctdb_ltdb_header header;
4180 size_t ctdb_key_data_len(struct ctdb_key_data *key)
4182 return offsetof(struct ctdb_key_data_wire, key) + key->key.dsize;
4185 void ctdb_key_data_push(struct ctdb_key_data *key, uint8_t *buf)
4187 struct ctdb_key_data_wire *wire = (struct ctdb_key_data_wire *)buf;
4189 memcpy(wire, key, offsetof(struct ctdb_key_data, key));
4190 wire->keylen = key->key.dsize;
4191 memcpy(wire->key, key->key.dptr, key->key.dsize);
4194 int ctdb_key_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
4195 struct ctdb_key_data **out)
4197 struct ctdb_key_data *key_data;
4198 struct ctdb_key_data_wire *wire = (struct ctdb_key_data_wire *)buf;
4200 if (buflen < offsetof(struct ctdb_key_data_wire, key)) {
4203 if (wire->keylen > buflen) {
4206 if (offsetof(struct ctdb_key_data_wire, key) + wire->keylen <
4207 offsetof(struct ctdb_key_data_wire, key)) {
4210 if (buflen < offsetof(struct ctdb_key_data_wire, key) + wire->keylen) {
4214 key_data = talloc(mem_ctx, struct ctdb_key_data);
4215 if (key_data == NULL) {
4219 memcpy(key_data, wire, offsetof(struct ctdb_key_data, key));
4221 key_data->key.dsize = wire->keylen;
4222 key_data->key.dptr = talloc_memdup(key_data, wire->key, wire->keylen);
4223 if (key_data->key.dptr == NULL) {
4224 talloc_free(key_data);
4232 struct ctdb_db_statistics_wire {
4233 struct ctdb_db_statistics dbstats;
4234 char hot_keys_wire[1];
4237 size_t ctdb_db_statistics_len(struct ctdb_db_statistics *dbstats)
4242 len = sizeof(struct ctdb_db_statistics);
4243 for (i=0; i<MAX_HOT_KEYS; i++) {
4244 len += dbstats->hot_keys[i].key.dsize;
4249 void ctdb_db_statistics_push(struct ctdb_db_statistics *dbstats, void *buf)
4251 struct ctdb_db_statistics_wire *wire =
4252 (struct ctdb_db_statistics_wire *)buf;
4256 dbstats->num_hot_keys = MAX_HOT_KEYS;
4257 memcpy(wire, dbstats, sizeof(struct ctdb_db_statistics));
4260 for (i=0; i<MAX_HOT_KEYS; i++) {
4261 memcpy(&wire->hot_keys_wire[offset],
4262 dbstats->hot_keys[i].key.dptr,
4263 dbstats->hot_keys[i].key.dsize);
4264 offset += dbstats->hot_keys[i].key.dsize;
4268 int ctdb_db_statistics_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
4269 struct ctdb_db_statistics **out)
4271 struct ctdb_db_statistics *dbstats;
4272 struct ctdb_db_statistics_wire *wire =
4273 (struct ctdb_db_statistics_wire *)buf;
4277 if (buflen < sizeof(struct ctdb_db_statistics)) {
4282 for (i=0; i<wire->dbstats.num_hot_keys; i++) {
4283 if (wire->dbstats.hot_keys[i].key.dsize > buflen) {
4286 if (offset + wire->dbstats.hot_keys[i].key.dsize < offset) {
4289 offset += wire->dbstats.hot_keys[i].key.dsize;
4290 if (offset > buflen) {
4294 if (sizeof(struct ctdb_db_statistics) + offset <
4295 sizeof(struct ctdb_db_statistics)) {
4298 if (buflen < sizeof(struct ctdb_db_statistics) + offset) {
4302 dbstats = talloc(mem_ctx, struct ctdb_db_statistics);
4303 if (dbstats == NULL) {
4307 memcpy(dbstats, wire, sizeof(struct ctdb_db_statistics));
4310 for (i=0; i<wire->dbstats.num_hot_keys; i++) {
4314 key_size = dbstats->hot_keys[i].key.dsize;
4315 ptr = talloc_memdup(mem_ctx, &wire->hot_keys_wire[offset],
4318 talloc_free(dbstats);
4321 dbstats->hot_keys[i].key.dptr = ptr;
4329 size_t ctdb_election_message_len(struct ctdb_election_message *election)
4331 return sizeof(struct ctdb_election_message);
4334 void ctdb_election_message_push(struct ctdb_election_message *election,
4337 memcpy(buf, election, sizeof(struct ctdb_election_message));
4340 int ctdb_election_message_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
4341 struct ctdb_election_message **out)
4343 struct ctdb_election_message *election;
4345 if (buflen < sizeof(struct ctdb_election_message)) {
4349 election = talloc_memdup(mem_ctx, buf,
4350 sizeof(struct ctdb_election_message));
4351 if (election == NULL) {
4359 size_t ctdb_srvid_message_len(struct ctdb_srvid_message *msg)
4361 return sizeof(struct ctdb_srvid_message);
4364 void ctdb_srvid_message_push(struct ctdb_srvid_message *msg, uint8_t *buf)
4366 memcpy(buf, msg, sizeof(struct ctdb_srvid_message));
4369 int ctdb_srvid_message_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
4370 struct ctdb_srvid_message **out)
4372 struct ctdb_srvid_message *msg;
4374 if (buflen < sizeof(struct ctdb_srvid_message)) {
4378 msg = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_srvid_message));
4387 size_t ctdb_disable_message_len(struct ctdb_disable_message *disable)
4389 return sizeof(struct ctdb_disable_message);
4392 void ctdb_disable_message_push(struct ctdb_disable_message *disable,
4395 memcpy(buf, disable, sizeof(struct ctdb_disable_message));
4398 int ctdb_disable_message_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
4399 struct ctdb_disable_message **out)
4401 struct ctdb_disable_message *disable;
4403 if (buflen < sizeof(struct ctdb_disable_message)) {
4407 disable = talloc_memdup(mem_ctx, buf,
4408 sizeof(struct ctdb_disable_message));
4409 if (disable == NULL) {
4417 size_t ctdb_server_id_len(struct ctdb_server_id *sid)
4419 return sizeof(struct ctdb_server_id);
4422 void ctdb_server_id_push(struct ctdb_server_id *sid, uint8_t *buf)
4424 memcpy(buf, sid, sizeof(struct ctdb_server_id));
4427 int ctdb_server_id_pull(uint8_t *buf, size_t buflen,
4428 struct ctdb_server_id *sid)
4430 if (buflen < sizeof(struct ctdb_server_id)) {
4434 memcpy(sid, buf, sizeof(struct ctdb_server_id));
4438 size_t ctdb_g_lock_len(struct ctdb_g_lock *lock)
4440 return sizeof(struct ctdb_g_lock);
4443 void ctdb_g_lock_push(struct ctdb_g_lock *lock, uint8_t *buf)
4445 memcpy(buf, lock, sizeof(struct ctdb_g_lock));
4448 int ctdb_g_lock_pull(uint8_t *buf, size_t buflen, struct ctdb_g_lock *lock)
4450 if (buflen < sizeof(struct ctdb_g_lock)) {
4454 memcpy(lock, buf, sizeof(struct ctdb_g_lock));
4458 size_t ctdb_g_lock_list_len(struct ctdb_g_lock_list *lock_list)
4460 return lock_list->num * sizeof(struct ctdb_g_lock);
4463 void ctdb_g_lock_list_push(struct ctdb_g_lock_list *lock_list, uint8_t *buf)
4468 for (i=0; i<lock_list->num; i++) {
4469 ctdb_g_lock_push(&lock_list->lock[i], &buf[offset]);
4470 offset += sizeof(struct ctdb_g_lock);
4474 int ctdb_g_lock_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
4475 struct ctdb_g_lock_list **out)
4477 struct ctdb_g_lock_list *lock_list;
4482 lock_list = talloc_zero(mem_ctx, struct ctdb_g_lock_list);
4483 if (lock_list == NULL) {
4487 count = buflen / sizeof(struct ctdb_g_lock);
4488 lock_list->lock = talloc_array(lock_list, struct ctdb_g_lock, count);
4489 if (lock_list->lock == NULL) {
4490 talloc_free(lock_list);
4495 for (i=0; i<count; i++) {
4496 ret = ctdb_g_lock_pull(&buf[offset], buflen-offset,
4497 &lock_list->lock[i]);
4499 talloc_free(lock_list);
4502 offset += sizeof(struct ctdb_g_lock);
4505 lock_list->num = count;