1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

ctdb-protocol: Fix marshalling of ctdb_req_header

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
Amitay Isaacs 2016-04-22 00:12:16 +10:00 committed by Martin Schwenke
parent 2e14d4e4e3
commit 79d1507c16
2 changed files with 16 additions and 4 deletions

View 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 operation, uint32_t destnode,
uint32_t srcnode, uint32_t reqid); 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); struct ctdb_req_header *h);
int ctdb_req_header_verify(struct ctdb_req_header *h, uint32_t operation); int ctdb_req_header_verify(struct ctdb_req_header *h, uint32_t operation);

View File

@ -61,13 +61,23 @@ void ctdb_req_header_fill(struct ctdb_req_header *h, uint32_t generation,
h->reqid = reqid; 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) struct ctdb_req_header *h)
{ {
if (pkt_len < sizeof(struct ctdb_req_header)) { if (buflen < sizeof(struct ctdb_req_header)) {
return EMSGSIZE; return EMSGSIZE;
} }
memcpy(h, pkt, sizeof(struct ctdb_req_header)); memcpy(h, buf, sizeof(struct ctdb_req_header));
return 0; return 0;
} }