summaryrefslogtreecommitdiff
path: root/ctdb/protocol
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2016-04-22 00:12:16 +1000
committerMartin Schwenke <martins@samba.org>2016-05-03 04:43:20 +0200
commit79d1507c16b872e18987cbf9d3a4ed8994d282db (patch)
tree7a06cf9e55b8a822d2cbe17ac5f3e30a2f847e79 /ctdb/protocol
parent2e14d4e4e3fb627d2ad276b3c9a812382ad0b44b (diff)
downloadsamba-79d1507c16b872e18987cbf9d3a4ed8994d282db.tar.gz
ctdb-protocol: Fix marshalling of ctdb_req_header
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_api.h4
-rw-r--r--ctdb/protocol/protocol_header.c16
2 files changed, 16 insertions, 4 deletions
diff --git a/ctdb/protocol/protocol_api.h b/ctdb/protocol/protocol_api.h
index eb1baaffc2b..d358d40ca4d 100644
--- a/ctdb/protocol/protocol_api.h
+++ b/ctdb/protocol/protocol_api.h
@@ -76,7 +76,9 @@ void ctdb_req_header_fill(struct ctdb_req_header *h, uint32_t generation,
uint32_t operation, uint32_t destnode,
uint32_t srcnode, uint32_t reqid);
-int ctdb_req_header_pull(uint8_t *pkt, size_t pkt_len,
+size_t ctdb_req_header_len(struct ctdb_req_header *h);
+void ctdb_req_header_push(struct ctdb_req_header *h, uint8_t *buf);
+int ctdb_req_header_pull(uint8_t *buf, size_t buflen,
struct ctdb_req_header *h);
int ctdb_req_header_verify(struct ctdb_req_header *h, uint32_t operation);
diff --git a/ctdb/protocol/protocol_header.c b/ctdb/protocol/protocol_header.c
index b802d082dcd..178065af1d8 100644
--- a/ctdb/protocol/protocol_header.c
+++ b/ctdb/protocol/protocol_header.c
@@ -61,13 +61,23 @@ void ctdb_req_header_fill(struct ctdb_req_header *h, uint32_t generation,
h->reqid = reqid;
}
-int ctdb_req_header_pull(uint8_t *pkt, size_t pkt_len,
+size_t ctdb_req_header_len(struct ctdb_req_header *h)
+{
+ return sizeof(struct ctdb_req_header);
+}
+
+void ctdb_req_header_push(struct ctdb_req_header *h, uint8_t *buf)
+{
+ memcpy(buf, h, sizeof(struct ctdb_req_header));
+}
+
+int ctdb_req_header_pull(uint8_t *buf, size_t buflen,
struct ctdb_req_header *h)
{
- if (pkt_len < sizeof(struct ctdb_req_header)) {
+ if (buflen < sizeof(struct ctdb_req_header)) {
return EMSGSIZE;
}
- memcpy(h, pkt, sizeof(struct ctdb_req_header));
+ memcpy(h, buf, sizeof(struct ctdb_req_header));
return 0;
}