10unsigned int printrecord_cat(stralloc *out,
const char *
buf,
unsigned int len,
unsigned int pos,
const char *q,
const char qtype[2])
26 uint16_unpack_big(misc + 8,&datalen);
27 newpos = pos + datalen;
32 if (byte_diff(qtype,2,misc) && byte_diff(qtype,2,
DNS_T_ANY))
37 if (!stralloc_cats(
out,
" "))
return 0;
38 uint32_unpack_big(misc + 4,&
u32);
39 if (!stralloc_catulong0(
out,
u32,0))
return 0;
41 if (byte_diff(misc + 2,2,
DNS_C_IN)) {
42 if (!stralloc_cats(
out,
" weird class\n"))
return 0;
47 if (byte_equal(misc,2,
DNS_T_NS))
x =
" NS ";
52 if (!stralloc_cats(
out,
x))
return 0;
55 else if (byte_equal(misc,2,
DNS_T_MX)) {
56 if (!stralloc_cats(
out,
" MX "))
return 0;
59 uint16_unpack_big(misc,&u16);
60 if (!stralloc_catulong0(
out,u16,0))
return 0;
61 if (!stralloc_cats(
out,
" "))
return 0;
65 if (!stralloc_cats(
out,
" SOA "))
return 0;
68 if (!stralloc_cats(
out,
" "))
return 0;
72 for (i = 0; i < 5; ++i) {
73 if (!stralloc_cats(
out,
" "))
return 0;
74 uint32_unpack_big(misc + 4 * i,&
u32);
75 if (!stralloc_catulong0(
out,
u32,0))
return 0;
78 else if (byte_equal(misc,2,
DNS_T_A)) {
79 if (datalen != 4) { errno = EPROTO;
return 0; }
80 if (!stralloc_cats(
out,
" A "))
return 0;
82 stringlen = ip4_fmt(
ip4str,misc);
83 if (!stralloc_catb(
out,
ip4str,stringlen))
return 0;
86 if (datalen != 16) { errno = EPROTO;
return 0; }
87 if (!stralloc_cats(
out,
" AAAA "))
return 0;
89 stringlen = ip6_fmt(
ip6str,misc);
90 if (!stralloc_catb(
out,
ip6str,stringlen))
return 0;
93 if (!stralloc_cats(
out,
" "))
return 0;
94 uint16_unpack_big(misc,&u16);
95 if (!stralloc_catulong0(
out,u16,0))
return 0;
96 if (!stralloc_cats(
out,
" "))
return 0;
99 if ((misc[0] >= 32) && (misc[0] <= 126) && (misc[0] !=
'\\')) {
100 if (!stralloc_catb(
out,misc,1))
return 0;
104 misc[3] =
'0' + (7 & ch); ch >>= 3;
105 misc[2] =
'0' + (7 & ch); ch >>= 3;
106 misc[1] =
'0' + (7 & ch);
108 if (!stralloc_catb(
out,misc,4))
return 0;
109 if (!stralloc_catb(
out,
"?",1))
return 0;
114 if (!stralloc_cats(
out,
"\n"))
return 0;
115 if (pos != newpos) { errno = EPROTO;
return 0; }
119unsigned int printrecord(stralloc *out,
const char *
buf,
unsigned int len,
unsigned int pos,
const char *q,
const char qtype[2])
121 if (!stralloc_copys(
out,
""))
return 0;
int dns_domain_equal(const char *dn1, const char *dn2)
int dns_domain_todot_cat(stralloc *out, const char *d)
unsigned int dns_packet_getname(const char *buf, unsigned int len, unsigned int pos, char **d)
unsigned int dns_packet_copy(const char *buf, unsigned int len, unsigned int pos, char *out, unsigned int outlen)
void out(const char *s, unsigned int len)
unsigned int printrecord_cat(stralloc *out, const char *buf, unsigned int len, unsigned int pos, const char *q, const char qtype[2])
unsigned int printrecord(stralloc *out, const char *buf, unsigned int len, unsigned int pos, const char *q, const char qtype[2])