Ejemplo n.º 1
0
wdns_res
wdns_str_to_rdata(const char * str, uint16_t rrtype, uint16_t rrclass,
		   uint8_t **rdata, size_t *rdlen) {
	ubuf *u;
	wdns_res res;

	u = ubuf_new();
	res = _wdns_str_to_rdata_ubuf(u, str, rrtype, rrclass);
	if (res == wdns_res_success) {
		ubuf_detach(u, (uint8_t **) rdata, rdlen);
	}
	ubuf_destroy(&u);
	return (res);
}
Ejemplo n.º 2
0
char *
wdns_rdata_to_str(const uint8_t *rdata, uint16_t rdlen,
		  uint16_t rrtype, uint16_t rrclass)
{
	char *ret;
	size_t retsz;
	ubuf *u;

	u = ubuf_new();
	_wdns_rdata_to_ubuf(u, rdata, rdlen, rrtype, rrclass);
	ubuf_cterm(u);
	ubuf_detach(u, (uint8_t **) &ret, &retsz);
	ubuf_destroy(&u);
	return (ret);
}
Ejemplo n.º 3
0
static void *
thr_producer(void *arg)
{
	struct producer *p = (struct producer *) arg;

	memset(&p->pstat, 0, sizeof(p->pstat));

	for (unsigned i = 0; i < p->num_messages; i++) {
		fstrm_res res;
		size_t len = 0;
		uint8_t *message = NULL;
		ubuf *u = ubuf_init(512);

		unsigned ndups = (p->pstat.count_generated % 4) + 1;
		for (unsigned j = 0; j < ndups; j++)
			ubuf_add_cstr(u, test_string);

		ubuf_detach(u, &message, &len);
		ubuf_destroy(&u);

		res = fstrm_iothr_submit(p->iothr, p->ioq,
			message, len, fstrm_free_wrapper, NULL);
		if (res == fstrm_res_success) {
			p->pstat.count_submitted++;
			p->pstat.bytes_submitted += len;
		} else {
			free(message);
		}
		p->pstat.count_generated++;
		p->pstat.bytes_generated += len;

		if ((i % 1000) == 0)
			poll(NULL, 0, 1);
	}

	return NULL;
}