This follows the convention used for marshalling routines for ctdb data types.
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
/* From protocol/protocol_call.c */
+size_t ctdb_req_call_len(struct ctdb_req_header *h,
+ struct ctdb_req_call *c);
+
int ctdb_req_call_push(struct ctdb_req_header *h,
struct ctdb_req_call *c,
TALLOC_CTX *mem_ctx,
TALLOC_CTX *mem_ctx,
struct ctdb_req_call *c);
+size_t ctdb_reply_call_len(struct ctdb_req_header *h,
+ struct ctdb_reply_call *c);
+
int ctdb_reply_call_push(struct ctdb_req_header *h,
struct ctdb_reply_call *c,
TALLOC_CTX *mem_ctx,
TALLOC_CTX *mem_ctx,
struct ctdb_reply_call *c);
+size_t ctdb_reply_error_len(struct ctdb_req_header *h,
+ struct ctdb_reply_error *c);
+
int ctdb_reply_error_push(struct ctdb_req_header *h,
struct ctdb_reply_error *c,
TALLOC_CTX *mem_ctx,
TALLOC_CTX *mem_ctx,
struct ctdb_reply_error *c);
+size_t ctdb_req_dmaster_len(struct ctdb_req_header *h,
+ struct ctdb_req_dmaster *c);
+
int ctdb_req_dmaster_push(struct ctdb_req_header *h,
struct ctdb_req_dmaster *c,
TALLOC_CTX *mem_ctx,
TALLOC_CTX *mem_ctx,
struct ctdb_req_dmaster *c);
+size_t ctdb_reply_dmaster_len(struct ctdb_req_header *h,
+ struct ctdb_reply_dmaster *c);
+
int ctdb_reply_dmaster_push(struct ctdb_req_header *h,
struct ctdb_reply_dmaster *c,
TALLOC_CTX *mem_ctx,
/* From protocol/protocol_control.c */
+size_t ctdb_req_control_len(struct ctdb_req_header *h,
+ struct ctdb_req_control *c);
+
int ctdb_req_control_push(struct ctdb_req_header *h,
struct ctdb_req_control *c,
TALLOC_CTX *mem_ctx,
TALLOC_CTX *mem_ctx,
struct ctdb_req_control *c);
+size_t ctdb_reply_control_len(struct ctdb_req_header *h,
+ struct ctdb_reply_control *c);
+
int ctdb_reply_control_push(struct ctdb_req_header *h,
struct ctdb_reply_control *c,
TALLOC_CTX *mem_ctx,
/* From protocol/protocol_message.c */
+size_t ctdb_req_message_len(struct ctdb_req_header *h,
+ struct ctdb_req_message *c);
+
int ctdb_req_message_push(struct ctdb_req_header *h,
struct ctdb_req_message *c,
TALLOC_CTX *mem_ctx,
TALLOC_CTX *mem_ctx,
struct ctdb_req_message *c);
+size_t ctdb_req_message_data_len(struct ctdb_req_header *h,
+ struct ctdb_req_message_data *c);
+
int ctdb_req_message_data_push(struct ctdb_req_header *h,
struct ctdb_req_message_data *message,
TALLOC_CTX *mem_ctx,
uint8_t data[1];
};
+size_t ctdb_req_call_len(struct ctdb_req_header *h, struct ctdb_req_call *c)
+{
+ return offsetof(struct ctdb_req_call_wire, data) +
+ ctdb_tdb_data_len(c->key) + ctdb_tdb_data_len(c->calldata);
+}
+
int ctdb_req_call_push(struct ctdb_req_header *h, struct ctdb_req_call *c,
TALLOC_CTX *mem_ctx, uint8_t **pkt, size_t *pkt_len)
{
return 0;
}
+size_t ctdb_reply_call_len(struct ctdb_req_header *h,
+ struct ctdb_reply_call *c)
+{
+ return offsetof(struct ctdb_reply_call_wire, data) +
+ ctdb_tdb_data_len(c->data);
+}
+
int ctdb_reply_call_push(struct ctdb_req_header *h, struct ctdb_reply_call *c,
TALLOC_CTX *mem_ctx, uint8_t **pkt, size_t *pkt_len)
{
return 0;
}
+size_t ctdb_reply_error_len(struct ctdb_req_header *h,
+ struct ctdb_reply_error *c)
+{
+ return offsetof(struct ctdb_reply_error_wire, msg) +
+ ctdb_tdb_data_len(c->msg);
+}
+
int ctdb_reply_error_push(struct ctdb_req_header *h, struct ctdb_reply_error *c,
TALLOC_CTX *mem_ctx, uint8_t **pkt, size_t *pkt_len)
{
return 0;
}
+size_t ctdb_req_dmaster_len(struct ctdb_req_header *h,
+ struct ctdb_req_dmaster *c)
+{
+ return offsetof(struct ctdb_req_dmaster_wire, data) +
+ ctdb_tdb_data_len(c->key) + ctdb_tdb_data_len(c->data);
+}
+
int ctdb_req_dmaster_push(struct ctdb_req_header *h, struct ctdb_req_dmaster *c,
TALLOC_CTX *mem_ctx, uint8_t **pkt, size_t *pkt_len)
{
return 0;
}
+size_t ctdb_reply_dmaster_len(struct ctdb_req_header *h,
+ struct ctdb_reply_dmaster *c)
+{
+ return offsetof(struct ctdb_reply_dmaster_wire, data) +
+ ctdb_tdb_data_len(c->key) + ctdb_tdb_data_len(c->data);
+}
+
int ctdb_reply_dmaster_push(struct ctdb_req_header *h,
struct ctdb_reply_dmaster *c,
TALLOC_CTX *mem_ctx, uint8_t **pkt, size_t *pkt_len)
return ret;
}
+size_t ctdb_req_control_len(struct ctdb_req_header *h,
+ struct ctdb_req_control *c)
+{
+ return offsetof(struct ctdb_req_control_wire, data) +
+ ctdb_req_control_data_len(&c->rdata);
+}
+
int ctdb_req_control_push(struct ctdb_req_header *h,
struct ctdb_req_control *request,
TALLOC_CTX *mem_ctx,
return 0;
}
+size_t ctdb_reply_control_len(struct ctdb_req_header *h,
+ struct ctdb_reply_control *c)
+{
+ return offsetof(struct ctdb_reply_control_wire, data) +
+ (c->status == 0 ?
+ ctdb_reply_control_data_len(&c->rdata) :
+ ctdb_string_len(c->errmsg));
+}
+
int ctdb_reply_control_push(struct ctdb_req_header *h,
struct ctdb_reply_control *reply,
TALLOC_CTX *mem_ctx,
return ret;
}
+size_t ctdb_req_message_len(struct ctdb_req_header *h,
+ struct ctdb_req_message *c)
+{
+ return offsetof(struct ctdb_req_message_wire, data) +
+ ctdb_message_data_len(&c->data, c->srvid);
+}
+
int ctdb_req_message_push(struct ctdb_req_header *h,
struct ctdb_req_message *message,
TALLOC_CTX *mem_ctx,
return ret;
}
+size_t ctdb_req_message_data_len(struct ctdb_req_header *h,
+ struct ctdb_req_message_data *c)
+{
+ return offsetof(struct ctdb_req_message_wire, data) +
+ ctdb_tdb_data_len(c->data);
+}
+
int ctdb_req_message_data_push(struct ctdb_req_header *h,
struct ctdb_req_message_data *message,
TALLOC_CTX *mem_ctx,