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

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

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

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

	fill_ctdb_reply_dmaster(mem_ctx, &c);
	ret = ctdb_reply_dmaster_push(&h, &c, mem_ctx, &pkt, &pkt_len);
	assert(ret == 0);
	ret = ctdb_reply_dmaster_pull(pkt, pkt_len, &h2, mem_ctx, &c2);
	assert(ret == 0);
	verify_ctdb_req_header(&h, &h2);
	verify_ctdb_reply_dmaster(&c, &c2);

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

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

	ctdb_reply_dmaster_print(&c, fp);
}