Example #1
0
/* void dns_readable(int fd, void *ptr)
 * Input: An fd which has become readable, ptr not used.
 * Output: None.
 * Side effects: Read DNS responses from DNS servers.
 * Note: Called by the fd system.
 */
void
dns_readable(int fd, void *ptr)
{
	adns_processreadable(dns_state, fd, &SystemTime);
	dns_do_callbacks();
	dns_select();
}
Example #2
0
/* void delete_adns_queries(struct DNSQuery *q)
 * Input: A pointer to the applicable DNSQuery structure.
 * Output: None
 * Side effects: Cancels a DNS query.
 */
void
delete_adns_queries(struct DNSQuery *q)
{
	if(q != NULL && q->query != NULL)
	{
		adns_cancel(q->query);
		q->callback = NULL;
	}
	dns_select();
}
Example #3
0
/* int adns_gethost(const char *name, int aftype, struct DNSQuery *req);
 * Input: A name, an address family, a DNSQuery structure.
 * Output: None
 * Side effects: Sets up a query structure and sends off a DNS query to
 *               the DNS server to resolve an "A"(address) entry by name.
 */
int
adns_gethost(const char *name, int aftype, struct DNSQuery *req)
{
	int result;
	assert(dns_state->nservers > 0);
#ifdef IPV6
	if(aftype == AF_INET6)
		result = adns_submit(dns_state, name, adns_r_addr6, adns_qf_owner, req, &req->query);
	else
#endif
		result = adns_submit(dns_state, name, adns_r_addr, adns_qf_owner, req, &req->query);
	dns_select();
	return result;
}
Example #4
0
/* void init_resolver(void)
 * Input: None
 * Output: None
 * Side effects: Reads the ADNS configuration and sets up the ADNS server
 *               polling and query timeouts.
 */
void init_resolver(void)
{
  int r;

  r = adns_init(&dns_state, adns_if_noautosys, 0);    
 
  if(dns_state == NULL) 
  {
    ilog(L_CRIT, "Error opening /etc/resolv.conf: %s; r = %d", strerror(errno), r);
    exit(76);
  }
  
  eventAddIsh("timeout_adns", timeout_adns, NULL, 2);
  dns_select();
}
Example #5
0
/* int adns_getaddr(struct irc_inaddr *addr, int aftype,
 *                   struct DNSQuery *req, int arpa_type);
 * Input: An address, an address family, a DNSQuery structure.
 * Output: None
 * Side effects: Sets up a query entry and sends it to the DNS server to
 *               resolve an IP address to a domain name.
 */
int
adns_getaddr(struct sockaddr *addr, int aftype, struct DNSQuery *req)
{
	int result;
	int flags = adns_r_ptr;
	assert(dns_state->nservers > 0);
#ifdef IPV6
	if(addr->sa_family == AF_INET6)
		flags = adns_r_ptr_ip6;
#endif
	result = adns_submit_reverse(dns_state,
				    (struct sockaddr *) addr,
				    flags,
				    adns_qf_owner | adns_qf_cname_loose |
				    adns_qf_quoteok_anshost, req, &req->query);
	dns_select();
	return result;
}