newpos =
dns_packet_copy(buf,
len, pos, out, outlen);
char
*buf;
unsigned int
len;
unsigned int
pos;
unsigned int
newpos;
char
*out;
unsigned int
outlen;
newpos =
dns_packet_getname(buf,
len, pos, &dn);
char
*buf;
unsigned int
len;
unsigned int
pos;
unsigned int
newpos;
char
*dn
= 0;
newpos =
dns_packet_skipname(buf,
len, pos);
char
*buf;
unsigned int
len;
unsigned int
pos;
unsigned int
newpos;
dns_packet_getname reads a compressed domain name from position pos of a DNS packet stored at buf, copies the name into dn, and returns the position in the packet immediately after the name.
If the name is misformatted, or if reading the name would require reading past the first len bytes of the packet, or if there is not enough memory for dn, dns_packet_getname returns 0, setting errno appropriately, and leaves dn alone.
dns_packet_skipname is like dns_packet_getname but discards the resulting domain name. It does not allocate memory.
Beware that, even if dns_packet_skipname returns nonzero, a future dns_packet_getname from the same position may fail: it may run out of memory, or encounter a format error not detected by dns_packet_skipname.
http://cr.yp.to/djbdns/blurb/library.html