mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
ctdb-protocol: Expose function to allocate a packet
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
e834e0a2c0
commit
0eca31baf7
@ -682,6 +682,11 @@ int ctdb_req_message_data_pull(uint8_t *pkt, size_t pkt_len,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
struct ctdb_req_message_data *message);
|
||||
|
||||
/* From protocol/protocol_packet.c */
|
||||
|
||||
int ctdb_allocate_pkt(TALLOC_CTX *mem_ctx, size_t datalen,
|
||||
uint8_t **buf, size_t *buflen);
|
||||
|
||||
/* From protocol/protocol_util.c */
|
||||
|
||||
const char *ctdb_runstate_to_string(enum ctdb_runstate runstate);
|
||||
|
@ -91,7 +91,7 @@ int ctdb_req_call_push(struct ctdb_req_header *h, struct ctdb_req_call *c,
|
||||
|
||||
length = ctdb_req_call_len(h, c);
|
||||
|
||||
ret = allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
ret = ctdb_allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
@ -178,7 +178,7 @@ int ctdb_reply_call_push(struct ctdb_req_header *h, struct ctdb_reply_call *c,
|
||||
|
||||
length = ctdb_reply_call_len(h, c);
|
||||
|
||||
ret = allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
ret = ctdb_allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
@ -251,7 +251,7 @@ int ctdb_reply_error_push(struct ctdb_req_header *h, struct ctdb_reply_error *c,
|
||||
|
||||
length = ctdb_reply_error_len(h, c);
|
||||
|
||||
ret = allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
ret = ctdb_allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
@ -324,7 +324,7 @@ int ctdb_req_dmaster_push(struct ctdb_req_header *h, struct ctdb_req_dmaster *c,
|
||||
|
||||
length = ctdb_req_dmaster_len(h, c);
|
||||
|
||||
ret = allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
ret = ctdb_allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
@ -410,7 +410,7 @@ int ctdb_reply_dmaster_push(struct ctdb_req_header *h,
|
||||
|
||||
length = ctdb_reply_dmaster_len(h, c);
|
||||
|
||||
ret = allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
ret = ctdb_allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -1909,7 +1909,7 @@ int ctdb_req_control_push(struct ctdb_req_header *h,
|
||||
|
||||
length = ctdb_req_control_len(h, request);
|
||||
|
||||
ret = allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
ret = ctdb_allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
@ -1995,7 +1995,7 @@ int ctdb_reply_control_push(struct ctdb_req_header *h,
|
||||
|
||||
length = ctdb_reply_control_len(h, reply);
|
||||
|
||||
ret = allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
ret = ctdb_allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ int ctdb_req_message_push(struct ctdb_req_header *h,
|
||||
|
||||
length = ctdb_req_message_len(h, message);
|
||||
|
||||
ret = allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
ret = ctdb_allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
@ -369,7 +369,7 @@ int ctdb_req_message_data_push(struct ctdb_req_header *h,
|
||||
|
||||
length = ctdb_req_message_data_len(h, message);
|
||||
|
||||
ret = allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
ret = ctdb_allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -23,12 +23,12 @@
|
||||
#include <talloc.h>
|
||||
#include <tdb.h>
|
||||
|
||||
#include "protocol_private.h"
|
||||
#include "protocol_api.h"
|
||||
|
||||
#define CTDB_DS_ALIGNMENT 8
|
||||
|
||||
int allocate_pkt(TALLOC_CTX *mem_ctx, size_t length,
|
||||
uint8_t **buf, size_t *buflen)
|
||||
int ctdb_allocate_pkt(TALLOC_CTX *mem_ctx, size_t length,
|
||||
uint8_t **buf, size_t *buflen)
|
||||
{
|
||||
size_t new_length;
|
||||
|
||||
|
@ -22,9 +22,6 @@
|
||||
|
||||
#include "protocol.h"
|
||||
|
||||
int allocate_pkt(TALLOC_CTX *mem_ctx, size_t length,
|
||||
uint8_t **buf, size_t *buflen);
|
||||
|
||||
size_t ctdb_uint32_len(uint32_t val);
|
||||
void ctdb_uint32_push(uint32_t val, uint8_t *buf);
|
||||
int ctdb_uint32_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
|
||||
|
@ -1957,8 +1957,8 @@ static void test_ctdb_req_header(void)
|
||||
ctdb_req_header_fill(&h, GENERATION, OPERATION, DESTNODE, SRCNODE,
|
||||
REQID);
|
||||
|
||||
ret = allocate_pkt(mem_ctx, ctdb_req_header_len(&h),
|
||||
&pkt, &pkt_len);
|
||||
ret = ctdb_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));
|
||||
|
Loading…
Reference in New Issue
Block a user