mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18: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,
|
TALLOC_CTX *mem_ctx,
|
||||||
struct ctdb_req_message_data *message);
|
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 */
|
/* From protocol/protocol_util.c */
|
||||||
|
|
||||||
const char *ctdb_runstate_to_string(enum ctdb_runstate runstate);
|
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);
|
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) {
|
if (ret != 0) {
|
||||||
return ret;
|
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);
|
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) {
|
if (ret != 0) {
|
||||||
return ret;
|
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);
|
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) {
|
if (ret != 0) {
|
||||||
return ret;
|
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);
|
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) {
|
if (ret != 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -410,7 +410,7 @@ int ctdb_reply_dmaster_push(struct ctdb_req_header *h,
|
|||||||
|
|
||||||
length = ctdb_reply_dmaster_len(h, c);
|
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) {
|
if (ret != 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1909,7 +1909,7 @@ int ctdb_req_control_push(struct ctdb_req_header *h,
|
|||||||
|
|
||||||
length = ctdb_req_control_len(h, request);
|
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) {
|
if (ret != 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1995,7 +1995,7 @@ int ctdb_reply_control_push(struct ctdb_req_header *h,
|
|||||||
|
|
||||||
length = ctdb_reply_control_len(h, reply);
|
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) {
|
if (ret != 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -299,7 +299,7 @@ int ctdb_req_message_push(struct ctdb_req_header *h,
|
|||||||
|
|
||||||
length = ctdb_req_message_len(h, message);
|
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) {
|
if (ret != 0) {
|
||||||
return ret;
|
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);
|
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) {
|
if (ret != 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,11 @@
|
|||||||
#include <talloc.h>
|
#include <talloc.h>
|
||||||
#include <tdb.h>
|
#include <tdb.h>
|
||||||
|
|
||||||
#include "protocol_private.h"
|
#include "protocol_api.h"
|
||||||
|
|
||||||
#define CTDB_DS_ALIGNMENT 8
|
#define CTDB_DS_ALIGNMENT 8
|
||||||
|
|
||||||
int allocate_pkt(TALLOC_CTX *mem_ctx, size_t length,
|
int ctdb_allocate_pkt(TALLOC_CTX *mem_ctx, size_t length,
|
||||||
uint8_t **buf, size_t *buflen)
|
uint8_t **buf, size_t *buflen)
|
||||||
{
|
{
|
||||||
size_t new_length;
|
size_t new_length;
|
||||||
|
@ -22,9 +22,6 @@
|
|||||||
|
|
||||||
#include "protocol.h"
|
#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);
|
size_t ctdb_uint32_len(uint32_t val);
|
||||||
void ctdb_uint32_push(uint32_t val, uint8_t *buf);
|
void ctdb_uint32_push(uint32_t val, uint8_t *buf);
|
||||||
int ctdb_uint32_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
|
int ctdb_uint32_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
|
||||||
|
@ -1957,7 +1957,7 @@ static void test_ctdb_req_header(void)
|
|||||||
ctdb_req_header_fill(&h, GENERATION, OPERATION, DESTNODE, SRCNODE,
|
ctdb_req_header_fill(&h, GENERATION, OPERATION, DESTNODE, SRCNODE,
|
||||||
REQID);
|
REQID);
|
||||||
|
|
||||||
ret = allocate_pkt(mem_ctx, ctdb_req_header_len(&h),
|
ret = ctdb_allocate_pkt(mem_ctx, ctdb_req_header_len(&h),
|
||||||
&pkt, &pkt_len);
|
&pkt, &pkt_len);
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
assert(pkt != NULL);
|
assert(pkt != NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user