/* This file is part of Mailfromd. Copyright (C) 2005, 2006, 2007, 2008 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ typedef enum { dns_success, dns_not_found, dns_failure, dns_temp_failure, } dns_status; #define NELEMS(c) (sizeof(c)/sizeof((c)[0])) /* Libresolv-related defines and DNS functions */ #ifndef MAXPACKET # define MAXPACKET 8192 /* max packet size used internally by BIND */ #endif #define MAXMXCOUNT 32 typedef char *mxbuf_t[MAXMXCOUNT]; #define MAXCNAMEDEPTH 24 /* FIXME */ #ifdef HAVE_PTHREAD # define MUTEX_DCL(name) \ static pthread_mutex_t name = PTHREAD_MUTEX_INITIALIZER; # define MUTEX_LOCK(name) \ pthread_mutex_lock(&name) # define MUTEX_UNLOCK(name) \ pthread_mutex_unlock(&name); #else # define MUTEX_DCL(name) # define MUTEX_LOCK(name) # define MUTEX_UNLOCK(name) #endif #if !defined res_ninit && !defined HAVE_RES_NINIT # define res_ninit(s) #endif #if !defined res_nclose && !defined HAVE_RES_NCLOSE # define res_nclose(s) #endif #if !defined res_nquery && !defined HAVE_RES_NQUERY # define res_nquery(stat,name,class,type,answer,anslen) \ res_query(name,class,type,answer,anslen) #endif #if !defined res_nquerydomain && !defined HAVE_RES_NQUERYDOMAIN # define res_nquerydomain(stat,name,domain,class,type,answer,anslen) \ res_querydomain(name,domain,class,type,answer,anslen) #endif #define UPDATE_TTL(m, ttl) do { if ((m) > (ttl)) (m) = (ttl); } while(0) int dns_str_is_ipv4(const char *addr); dns_status dns_get_mx_records(const char *host, int maxdepth, mxbuf_t mxbuf, size_t *mxcount, unsigned long *ttl); void dns_freemx(mxbuf_t mxbuf); int dns_reverse_ipstr(const char *ipstr, char *revipstr); dns_status dns_resolve_ipstr(const char *ipstr, const char *domain, char *answer, size_t answer_size, char *hbuf, size_t hbsize, unsigned long *ttl); dns_status dns_resolve_hostname(const char *host, char *answer, size_t answer_size, char *ipbuf, size_t ipbsize, unsigned long *ttl); dns_status a_lookup(const char *host, GACOPYZ_UINT32_T *ipbuf, size_t ipbsize, size_t *ipcount, unsigned long *ttl, char *answer, size_t answer_size); dns_status ptr_lookup(struct in_addr ip, char **names, size_t maxnames, unsigned long *ttl, char *answer, size_t answer_size); dns_status txt_lookup(const char *name, char **names, size_t maxnames, unsigned long *ttl, char *answer, size_t answer_size); dns_status ptr_validate(const char *ipstr, char ***vnptr, size_t *vcount, unsigned long *pttl);