Ejemplo n.º 1
0
static void test_req_dmaster_test(void)
{
	TALLOC_CTX *mem_ctx;
	uint8_t *pkt;
	size_t pkt_len;
	int ret;
	struct ctdb_req_header h, h2;
	struct ctdb_req_dmaster c, c2;

	printf("ctdb_req_dmaster\n");
	fflush(stdout);

	mem_ctx = talloc_new(NULL);
	assert(mem_ctx != NULL);

	ctdb_req_header_fill(&h, GENERATION, CTDB_REQ_DMASTER,
			     DESTNODE, SRCNODE, REQID);

	fill_ctdb_req_dmaster(mem_ctx, &c);
	ret = ctdb_req_dmaster_push(&h, &c, mem_ctx, &pkt, &pkt_len);
	assert(ret == 0);
	ret = ctdb_req_dmaster_pull(pkt, pkt_len, &h2, mem_ctx, &c2);
	assert(ret == 0);
	verify_ctdb_req_header(&h, &h2);
	verify_ctdb_req_dmaster(&c, &c2);

	talloc_free(mem_ctx);
}
Ejemplo n.º 2
0
static void ctdb_req_dmaster_parse(uint8_t *buf, size_t buflen, FILE *fp,
				   TALLOC_CTX *mem_ctx)
{
	struct ctdb_req_dmaster c;
	int ret;

	ret = ctdb_req_dmaster_pull(buf, buflen, NULL, mem_ctx, &c);
	if (ret != 0) {
		fprintf(fp, "Failed to parse CTDB_REQ_DMASTER\n");
		return;
	}

	ctdb_req_dmaster_print(&c, fp);
}