1 char *
wdns_rdata_to_str(const uint8_t * rdata,uint16_t rdlen,uint16_t rrtype,uint16_t rrclass)2 wdns_rdata_to_str(const uint8_t *rdata, uint16_t rdlen,
3 uint16_t rrtype, uint16_t rrclass)
4 {
5 char *ret;
6 size_t retsz;
7 ubuf *u;
8
9 u = ubuf_new();
10 _wdns_rdata_to_ubuf(u, rdata, rdlen, rrtype, rrclass);
11 ubuf_cterm(u);
12 ubuf_detach(u, (uint8_t **) &ret, &retsz);
13 ubuf_destroy(&u);
14 return (ret);
15 }
16
17 wdns_res
wdns_str_to_rdata(const char * str,uint16_t rrtype,uint16_t rrclass,uint8_t ** rdata,size_t * rdlen)18 wdns_str_to_rdata(const char * str, uint16_t rrtype, uint16_t rrclass,
19 uint8_t **rdata, size_t *rdlen) {
20 ubuf *u;
21 wdns_res res;
22
23 u = ubuf_new();
24 res = _wdns_str_to_rdata_ubuf(u, str, rrtype, rrclass);
25 if (res == wdns_res_success) {
26 ubuf_detach(u, (uint8_t **) rdata, rdlen);
27 }
28 ubuf_destroy(&u);
29 return (res);
30 }
31