ctdb-protocol: Add API to extract ctdb_ltdb_header from TDB_DATA
authorAmitay Isaacs <amitay@gmail.com>
Tue, 10 Nov 2015 07:29:39 +0000 (18:29 +1100)
committerMartin Schwenke <martins@samba.org>
Wed, 25 Nov 2015 09:16:20 +0000 (10:16 +0100)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
ctdb/protocol/protocol_api.h
ctdb/protocol/protocol_types.c

index 72f78ecf8e67c9bc438e379bdecdcaf531451419..6fb9cec9d4dbaae844e276bb772516fd5d1b66a4 100644 (file)
@@ -31,6 +31,8 @@ void ctdb_ltdb_header_push(struct ctdb_ltdb_header *header, uint8_t *buf);
 int ctdb_ltdb_header_pull(uint8_t *buf, size_t buflen,
                          struct ctdb_ltdb_header *header);
 
+int ctdb_ltdb_header_extract(TDB_DATA *data, struct ctdb_ltdb_header *header);
+
 size_t ctdb_rec_data_len(struct ctdb_rec_data *rec);
 void ctdb_rec_data_push(struct ctdb_rec_data *rec, uint8_t *buf);
 int ctdb_rec_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
index fc7c43380cbc45c2bb4da0380f9c8404e072c38e..709194ff003448b267d3ba03c8ebedfa92439795 100644 (file)
@@ -494,6 +494,21 @@ int ctdb_ltdb_header_pull(uint8_t *buf, size_t buflen,
        return 0;
 }
 
+int ctdb_ltdb_header_extract(TDB_DATA *data, struct ctdb_ltdb_header *header)
+{
+       int ret;
+
+       ret = ctdb_ltdb_header_pull(data->dptr, data->dsize, header);
+       if (ret != 0) {
+               return ret;
+       }
+
+       data->dptr += sizeof(struct ctdb_ltdb_header);
+       data->dsize -= sizeof(struct ctdb_ltdb_header);
+
+       return 0;
+}
+
 struct ctdb_rec_data_wire {
        uint32_t length;
        uint32_t reqid;