36 logmsg(
fatal,111,FATAL,
"out of memory");
46 if (
len >=
sizeof(
buf))
goto NOQ;
48 if (header[2] & 128)
goto NOQ;
49 if (header[4])
goto NOQ;
50 if (header[5] != 1)
goto NOQ;
61 if (byte_diff(qclass,2,
DNS_C_ANY))
goto WEIRDCLASS;
63 if (!(header[2] & 1))
response[2] &= ~1;
65 if (header[2] & 126)
goto NOTIMP;
66 if (byte_equal(qtype,2,
DNS_T_AXFR))
goto NOTIMP;
89 qlog(ip,
port,
"\0\0",
"",
"\0\0",
" / ");
102 logmsg(
fatal,111,ERROR,
"IP not set");
103 if (case_equals(
x,
"::")) {
105 }
else if (case_equals(
x,
":0")) {
110 logmsg(
fatal,111,FATAL,B(
"unable to parse IPv6 address: ",
x));
113 if (ip6_isv4mapped(
ip))
114 udp53 = socket_udp4();
116 udp53 = socket_udp();
118 logmsg(
fatal,111,FATAL,
"unable to create UDP socket");
123 logmsg(
fatal,111,FATAL,
"unable to bind UDP socket");
130 socket_tryreservein(udp53,65536);
136 if (
len < 0)
continue;
137 if (!
doit())
continue;
unsigned int doit(char *buf, unsigned int len, unsigned int pos)
unsigned int dns_packet_copy(const char *, unsigned int, unsigned int, char *, unsigned int)
unsigned int dns_domain_length(const char *)
unsigned int dns_packet_getname(const char *, unsigned int, unsigned int, char **)
void droproot(const char *fatal)
void qlog(const char ip[16], uint16 port, const char id[2], const char *q, const char qtype[2], const char *result)
void log_start(const char *s, const char ip[16], uint32 scope)
void response_id(const char id[2])
unsigned int response_len
int response_query(const char *q, const char qtype[2], const char qclass[2])
int respond(char *, char *, char *)