int ctdb_db_statistics_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
struct ctdb_db_statistics **out);
+size_t ctdb_pid_srvid_len(struct ctdb_pid_srvid *in);
+void ctdb_pid_srvid_push(struct ctdb_pid_srvid *in, uint8_t *buf);
+int ctdb_pid_srvid_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
+ struct ctdb_pid_srvid **out);
+
size_t ctdb_election_message_len(struct ctdb_election_message *election);
void ctdb_election_message_push(struct ctdb_election_message *election,
uint8_t *buf);
return 0;
}
+size_t ctdb_pid_srvid_len(struct ctdb_pid_srvid *in)
+{
+ return ctdb_pid_len(in->pid) +
+ ctdb_uint64_len(in->srvid);
+}
+
+void ctdb_pid_srvid_push(struct ctdb_pid_srvid *in, uint8_t *buf)
+{
+ size_t offset = 0;
+
+ ctdb_pid_push(in->pid, buf+offset);
+ offset += ctdb_pid_len(in->pid);
+
+ ctdb_uint64_push(in->srvid, buf+offset);
+}
+
+int ctdb_pid_srvid_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
+ struct ctdb_pid_srvid **out)
+{
+ struct ctdb_pid_srvid *val;
+ size_t offset = 0;
+ int ret;
+
+ val = talloc(mem_ctx, struct ctdb_pid_srvid);
+ if (val == NULL) {
+ return ENOMEM;
+ }
+
+ ret = ctdb_pid_pull(buf+offset, buflen-offset, val, &val->pid);
+ if (ret != 0) {
+ goto fail;
+ }
+ offset += ctdb_pid_len(val->pid);
+
+ ret = ctdb_uint64_pull(buf+offset, buflen-offset, val, &val->srvid);
+ if (ret != 0) {
+ goto fail;
+ }
+
+ *out = val;
+ return 0;
+
+fail:
+ talloc_free(val);
+ return ret;
+}
+
size_t ctdb_election_message_len(struct ctdb_election_message *election)
{
return sizeof(struct ctdb_election_message);
#ifndef PROTOCOL_TEST
+static void fill_ctdb_pid_srvid(TALLOC_CTX *mem_ctx, struct ctdb_pid_srvid *p)
+{
+ p->pid = rand32();
+ p->srvid = rand64();
+}
+
+static void verify_ctdb_pid_srvid(struct ctdb_pid_srvid *p1,
+ struct ctdb_pid_srvid *p2)
+{
+ assert(p1->pid == p2->pid);
+ assert(p1->srvid == p2->srvid);
+}
+
static void fill_ctdb_election_message(TALLOC_CTX *mem_ctx,
struct ctdb_election_message *p)
{
DEFINE_TEST(struct ctdb_uint8_array, ctdb_uint8_array);
DEFINE_TEST(struct ctdb_uint64_array, ctdb_uint64_array);
DEFINE_TEST(struct ctdb_db_statistics, ctdb_db_statistics);
+DEFINE_TEST(struct ctdb_pid_srvid, ctdb_pid_srvid);
DEFINE_TEST(struct ctdb_election_message, ctdb_election_message);
DEFINE_TEST(struct ctdb_srvid_message, ctdb_srvid_message);
DEFINE_TEST(struct ctdb_disable_message, ctdb_disable_message);
TEST_FUNC(ctdb_uint8_array)();
TEST_FUNC(ctdb_uint64_array)();
TEST_FUNC(ctdb_db_statistics)();
+ TEST_FUNC(ctdb_pid_srvid)();
TEST_FUNC(ctdb_election_message)();
TEST_FUNC(ctdb_srvid_message)();
TEST_FUNC(ctdb_disable_message)();