ctdb-protocol: Fix marshalling of ctdb_req_header
authorAmitay Isaacs <amitay@gmail.com>
Thu, 21 Apr 2016 14:12:16 +0000 (00:12 +1000)
committerMartin Schwenke <martins@samba.org>
Tue, 3 May 2016 02:43:20 +0000 (04:43 +0200)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/protocol/protocol_api.h
ctdb/protocol/protocol_header.c

index eb1baaffc2b5620e3d315811c19e10d4c9c09a8c..d358d40ca4d5a7db44a50923cbb85220482736b2 100644 (file)
@@ -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);
index b802d082dcd7b83d5bcd1acf47f5921d39706882..178065af1d8eb7d7319000cc763c87b94b565ab0 100644 (file)
@@ -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;
 }