wire = (struct ctdb_req_call_wire *)buf;
h->length = buflen;
- memcpy(&wire->hdr, h, sizeof(struct ctdb_req_header));
+ ctdb_req_header_push(h, (uint8_t *)&wire->hdr);
wire->flags = c->flags;
wire->db_id = c->db_id;
}
if (h != NULL) {
- memcpy(h, &wire->hdr, sizeof(struct ctdb_req_header));
+ ret = ctdb_req_header_pull((uint8_t *)&wire->hdr, pkt_len, h);
+ if (ret != 0) {
+ return ret;
+ }
}
c->flags = wire->flags;
wire = (struct ctdb_reply_call_wire *)buf;
h->length = buflen;
- memcpy(&wire->hdr, h, sizeof(struct ctdb_req_header));
+ ctdb_req_header_push(h, (uint8_t *)&wire->hdr);
wire->status = c->status;
wire->datalen = ctdb_tdb_data_len(c->data);
}
if (h != NULL) {
- memcpy(h, &wire->hdr, sizeof(struct ctdb_req_header));
+ ret = ctdb_req_header_pull((uint8_t *)&wire->hdr, pkt_len, h);
+ if (ret != 0) {
+ return ret;
+ }
}
c->status = wire->status;
wire = (struct ctdb_reply_error_wire *)buf;
h->length = buflen;
- memcpy(&wire->hdr, h, sizeof(struct ctdb_req_header));
+ ctdb_req_header_push(h, (uint8_t *)&wire->hdr);
wire->status = c->status;
wire->msglen = ctdb_tdb_data_len(c->msg);
}
if (h != NULL) {
- memcpy(h, &wire->hdr, sizeof(struct ctdb_req_header));
+ ret = ctdb_req_header_pull((uint8_t *)&wire->hdr, pkt_len, h);
+ if (ret != 0) {
+ return ret;
+ }
}
c->status = wire->status;
wire = (struct ctdb_req_dmaster_wire *)buf;
h->length = buflen;
- memcpy(&wire->hdr, h, sizeof(struct ctdb_req_header));
+ ctdb_req_header_push(h, (uint8_t *)&wire->hdr);
wire->db_id = c->db_id;
wire->rsn = c->rsn;
}
if (h != NULL) {
- memcpy(h, &wire->hdr, sizeof(struct ctdb_req_header));
+ ret = ctdb_req_header_pull((uint8_t *)&wire->hdr, pkt_len, h);
+ if (ret != 0) {
+ return ret;
+ }
}
c->db_id = wire->db_id;
wire = (struct ctdb_reply_dmaster_wire *)buf;
h->length = buflen;
- memcpy(&wire->hdr, h, sizeof(struct ctdb_req_header));
+ ctdb_req_header_push(h, (uint8_t *)&wire->hdr);
wire->db_id = c->db_id;
wire->rsn = c->rsn;
}
if (h != NULL) {
- memcpy(h, &wire->hdr, sizeof(struct ctdb_req_header));
+ ret = ctdb_req_header_pull((uint8_t *)&wire->hdr, pkt_len, h);
+ if (ret != 0) {
+ return ret;
+ }
}
c->db_id = wire->db_id;
wire = (struct ctdb_req_control_wire *)buf;
h->length = buflen;
- memcpy(&wire->hdr, h, sizeof(struct ctdb_req_header));
+ ctdb_req_header_push(h, (uint8_t *)&wire->hdr);
wire->opcode = request->opcode;
wire->pad = request->pad;
}
if (h != NULL) {
- memcpy(h, &wire->hdr, sizeof(struct ctdb_req_header));
+ ret = ctdb_req_header_pull((uint8_t *)&wire->hdr, pkt_len, h);
+ if (ret != 0) {
+ return ret;
+ }
}
request->opcode = wire->opcode;
wire = (struct ctdb_reply_control_wire *)buf;
h->length = buflen;
- memcpy(&wire->hdr, h, sizeof(struct ctdb_req_header));
+ ctdb_req_header_push(h, (uint8_t *)&wire->hdr);
wire->status = reply->status;
}
if (h != NULL) {
- memcpy(h, &wire->hdr, sizeof(struct ctdb_req_header));
+ ret = ctdb_req_header_pull((uint8_t *)&wire->hdr, pkt_len, h);
+ if (ret != 0) {
+ return ret;
+ }
}
reply->status = wire->status;
wire = (struct ctdb_req_message_wire *)buf;
h->length = buflen;
- memcpy(&wire->hdr, h, sizeof(struct ctdb_req_header));
+ ctdb_req_header_push(h, (uint8_t *)&wire->hdr);
wire->srvid = message->srvid;
wire->datalen = datalen;
}
if (h != NULL) {
- memcpy(h, &wire->hdr, sizeof(struct ctdb_req_header));
+ ret = ctdb_req_header_pull((uint8_t *)&wire->hdr, pkt_len, h);
+ if (ret != 0) {
+ return ret;
+ }
}
message->srvid = wire->srvid;
wire = (struct ctdb_req_message_wire *)buf;
h->length = buflen;
- memcpy(&wire->hdr, h, sizeof(struct ctdb_req_header));
+ ctdb_req_header_push(h, (uint8_t *)&wire->hdr);
wire->srvid = message->srvid;
wire->datalen = ctdb_tdb_data_len(message->data);
}
if (h != NULL) {
- memcpy(h, &wire->hdr, sizeof(struct ctdb_req_header));
+ ret = ctdb_req_header_pull((uint8_t *)&wire->hdr, pkt_len, h);
+ if (ret != 0) {
+ return ret;
+ }
}
message->srvid = wire->srvid;
static void verify_ctdb_req_header(struct ctdb_req_header *h,
struct ctdb_req_header *h2)
{
- verify_buffer(h, h2, sizeof(struct ctdb_req_header));
+ verify_buffer(h, h2, ctdb_req_header_len(h));
}
static void fill_ctdb_req_call(TALLOC_CTX *mem_ctx,
TALLOC_CTX *mem_ctx;
uint8_t *pkt;
size_t pkt_len;
- struct ctdb_req_header *h, h2;
+ struct ctdb_req_header h, h2;
int ret;
printf("ctdb_req_header\n");
mem_ctx = talloc_new(NULL);
assert(mem_ctx != NULL);
- ret = allocate_pkt(mem_ctx, sizeof(struct ctdb_req_header),
+ ctdb_req_header_fill(&h, GENERATION, OPERATION, DESTNODE, SRCNODE,
+ REQID);
+
+ ret = allocate_pkt(mem_ctx, ctdb_req_header_len(&h),
&pkt, &pkt_len);
assert(ret == 0);
+ assert(pkt != NULL);
+ assert(pkt_len >= ctdb_req_header_len(&h));
- h = (struct ctdb_req_header *)pkt;
- ctdb_req_header_fill(h, GENERATION, OPERATION, DESTNODE, SRCNODE,
- REQID);
+ ctdb_req_header_push(&h, pkt);
ret = ctdb_req_header_pull(pkt, pkt_len, &h2);
assert(ret == 0);
- verify_ctdb_req_header(h, &h2);
+ verify_ctdb_req_header(&h, &h2);
talloc_free(mem_ctx);
}