summaryrefslogtreecommitdiff
path: root/ctdb/protocol
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2017-08-30 15:13:12 +1000
committerMartin Schwenke <martins@samba.org>2017-09-21 08:53:26 +0200
commit5d12006e29a898c503a885115069fe26f2e084bc (patch)
tree184e77812639511160bf91e82e1552a0a70126ca /ctdb/protocol
parente5b133a127ff2a34689e679397bdd211fa2aada6 (diff)
downloadsamba-5d12006e29a898c503a885115069fe26f2e084bc.tar.gz
ctdb-protocol: Add marshalling for struct ctdb_pid_srvid
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb/protocol')
-rw-r--r--ctdb/protocol/protocol_private.h6
-rw-r--r--ctdb/protocol/protocol_types.c53
2 files changed, 59 insertions, 0 deletions
diff --git a/ctdb/protocol/protocol_private.h b/ctdb/protocol/protocol_private.h
index 9e3ae8dfb8f..c3fab3f3a24 100644
--- a/ctdb/protocol/protocol_private.h
+++ b/ctdb/protocol/protocol_private.h
@@ -312,6 +312,12 @@ void ctdb_db_statistics_push(struct ctdb_db_statistics *in, uint8_t *buf,
int ctdb_db_statistics_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
struct ctdb_db_statistics **out, size_t *npull);
+size_t ctdb_pid_srvid_len(struct ctdb_pid_srvid *in);
+void ctdb_pid_srvid_push(struct ctdb_pid_srvid *in, uint8_t *buf,
+ size_t *npush);
+int ctdb_pid_srvid_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
+ struct ctdb_pid_srvid **out, size_t *npull);
+
size_t ctdb_election_message_len(struct ctdb_election_message *in);
void ctdb_election_message_push(struct ctdb_election_message *in,
uint8_t *buf, size_t *npush);
diff --git a/ctdb/protocol/protocol_types.c b/ctdb/protocol/protocol_types.c
index 57ad07a3324..83d5d78fa6e 100644
--- a/ctdb/protocol/protocol_types.c
+++ b/ctdb/protocol/protocol_types.c
@@ -4704,6 +4704,59 @@ int ctdb_db_statistics_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
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 *npush)
+{
+ size_t offset = 0, np;
+
+ ctdb_pid_push(&in->pid, buf+offset, &np);
+ offset += np;
+
+ ctdb_uint64_push(&in->srvid, buf+offset, &np);
+ offset += np;
+
+ *npush = offset;
+}
+
+int ctdb_pid_srvid_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
+ struct ctdb_pid_srvid **out, size_t *npull)
+{
+ struct ctdb_pid_srvid *val;
+ size_t offset = 0, np;
+ int ret;
+
+ val = talloc(mem_ctx, struct ctdb_pid_srvid);
+ if (val == NULL) {
+ return ENOMEM;
+ }
+
+ ret = ctdb_pid_pull(buf+offset, buflen-offset, &val->pid, &np);
+ if (ret != 0) {
+ goto fail;
+ }
+ offset += np;
+
+ ret = ctdb_uint64_pull(buf+offset, buflen-offset, &val->srvid, &np);
+ if (ret != 0) {
+ goto fail;
+ }
+ offset += np;
+
+ *out = val;
+ *npull = offset;
+ return 0;
+
+fail:
+ talloc_free(val);
+ return ret;
+}
+
size_t ctdb_election_message_len(struct ctdb_election_message *in)
{
return ctdb_uint32_len(&in->num_connected) +