+ struct sockaddr_in *ip, *ip_fwd;
+ ip = (struct sockaddr_in *) &query->addr;
+ ip_fwd = (struct sockaddr_in *) &reply->addr;
+
+ if(ip->sin_addr.s_addr == ip_fwd->sin_addr.s_addr)
+ hostname = reply->h_name;
+ }
+#ifdef RB_IPV6
+ else if(query->type == QUERY_PTR_AAAA)
+ {
+ struct sockaddr_in6 *ip, *ip_fwd;
+ ip = (struct sockaddr_in6 *) &query->addr;
+ ip_fwd = (struct sockaddr_in6 *) &reply->addr;
+
+ if(memcmp(&ip->sin6_addr, &ip_fwd->sin6_addr, sizeof(struct in6_addr)) == 0)
+ hostname = reply->h_name;
+ }
+#endif
+ else
+ {
+ /* Shouldn't happen */
+ warn_opers(L_CRIT, "DNS: handle_lookup_hostname_reply: unknown query type %d",
+ query->type);
+ exit(EX_DNS_ERROR);
+ }
+end:
+ if(query->callback)
+ query->callback(hostname, hostname != NULL, query->type, query->data);
+
+ rb_free(query);
+}
+
+static void
+submit_dns_answer(const char *reply, bool status, query_type type, void *data)
+{
+ char *id = data;
+
+ if(!id || type == QUERY_INVALID)
+ {
+ warn_opers(L_CRIT, "DNS: submit_dns_answer gave us a bad query");
+ exit(EX_DNS_ERROR);
+ }
+
+ if(reply == NULL || status == false)
+ {
+ rb_helper_write(authd_helper, "E %s E %c *", id, type);
+ rb_free(id);
+ return;
+ }
+
+ rb_helper_write(authd_helper, "E %s O %c %s", id, type, reply);
+ rb_free(id);
+}
+
+void
+handle_resolve_dns(int parc, char *parv[])
+{
+ char *id = rb_strdup(parv[1]);
+ char qtype = *parv[2];
+ char *record = parv[3];
+ int aftype = AF_INET;
+
+ switch(qtype)
+ {
+#ifdef RB_IPV6