NAME
dns_packet_* - The dns_packet library interface
SYNOPSIS
#include <dns.h>
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;
DESCRIPTION
dns_packet_copy reads outlen bytes from position pos of a DNS packet
stored at buf, copies the bytes into out, and returns pos + outlen.
However, if reading the bytes would require reading past the first len
bytes of the packet, dns_packet_copy returns 0, setting errno
appropriately.
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.
SEE ALSO
dns_domain(3), dns_ip4(3), dns_ip4_qualify(3), dns_mx(3), dns_name4(3),
dns_random(3), dns_transmit(3), dns_txt(3)
http://cr.yp.to/djbdns/blurb/library.html
dns_packet_*(3)