From 79d1507c16b872e18987cbf9d3a4ed8994d282db Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Fri, 22 Apr 2016 00:12:16 +1000 Subject: ctdb-protocol: Fix marshalling of ctdb_req_header Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke --- ctdb/protocol/protocol_api.h | 4 +++- ctdb/protocol/protocol_header.c | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'ctdb/protocol') 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; } -- cgit v1.2.1