diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-10-19 22:06:20 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-10-19 22:06:20 +0300 |
commit | 0d8954ca25771bc6c6f5d9cf9bfa38a2b1bbba6e (patch) | |
tree | cba9192cbf520ef5527e3b1c7efccf69df24a334 /lib/dns.h | |
parent | b5a739de9d8ada25c4ce7cf5f365ecde89f470e5 (diff) | |
download | mailfromd-0d8954ca25771bc6c6f5d9cf9bfa38a2b1bbba6e.tar.gz mailfromd-0d8954ca25771bc6c6f5d9cf9bfa38a2b1bbba6e.tar.bz2 |
Improve DNS resolver API
Remove arbitrary size limits.
* NEWS: Version 8.2.90
* configure.ac: Likewise. Require Mailutils 3.3
* doc/calloutd.texi: Update.
* doc/functions.texi: Update.
* doc/mailfromd.texi: Update.
* doc/upgrade.texi: Update.
* lib/dns.c: Rewrite.
* lib/dns.h (MAXMXCOUNT, MXF_MAX): Remove.
(mxbuf_init,dns_resolve_ipstr)
(a_lookup,ptr_lookup,txt_lookup)
(spf_lookup): Change protos.
(dns_reply): New struct.
(dns_reply_free,dns_reply_ip): New functions.
* lib/libmf.h (getmxip): Change proto.
* src/builtin/dns.bi: Remove runtime configuration statements:
max-dns-reply-a, max-dns-reply-ptr, and max-dns-reply-mx. Rewrite using
the new DNS API.
* src/callout.c: Update.
* src/mailfromd.h: Update.
* src/main.c: Remove the max-match-mx configuration statement.
* src/prog.c: Update.
* src/spf.c: Update.
* src/spf.h: Update.
* src/srvcfg.c: Remove the max-callout-mx configuration statement.
Diffstat (limited to 'lib/dns.h')
-rw-r--r-- | lib/dns.h | 46 |
1 files changed, 30 insertions, 16 deletions
@@ -31,9 +31,6 @@ typedef enum { # define MAXPACKET 8192 /* max packet size used internally by BIND */ #endif -#define MAXMXCOUNT 32 - -#define MXF_MAX 0x01 #define MXF_REUSE 0x02 struct mxbuf { @@ -78,7 +75,7 @@ struct mxbuf { #define UPDATE_TTL(m, ttl) do { if ((m) > (ttl)) (m) = (ttl); } while(0) -void mxbuf_init(struct mxbuf *mxbuf); +void mxbuf_init(struct mxbuf *mxbuf, size_t n); void mxbuf_free(struct mxbuf *mxbuf); int dns_str_is_ipv4(const char *addr); @@ -89,25 +86,42 @@ int dns_reverse_ipstr(const char *ipstr, char *revipstr); dns_status dns_resolve_ipstr(const char *ipstr, const char *domain, unsigned char *answer, size_t answer_size, - char *hbuf, size_t hbsize, unsigned long *ttl); + char **hbuf, unsigned long *ttl); dns_status dns_resolve_hostname(const char *host, unsigned 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, - unsigned char *answer, size_t answer_size); + char **ipbuf, unsigned long *ttl); + +struct dns_reply { + size_t count; + size_t max; + + void **base; + size_t last_len; + size_t last_max; +}; + +void dns_reply_free(struct dns_reply *r); + +static inline GACOPYZ_UINT32_T +dns_reply_ip(struct dns_reply const *repl, size_t n) +{ + return *(GACOPYZ_UINT32_T*)repl->base[n]; +} + +dns_status a_lookup(const char *host, + struct dns_reply *repl, unsigned long *ttl); dns_status ptr_lookup(struct in_addr ip, - char **names, size_t maxnames, unsigned long *ttl, - unsigned char *answer, size_t answer_size); + struct dns_reply *repl, unsigned long *ttl); dns_status txt_lookup(const char *name, - char **names, size_t maxnames, unsigned long *ttl, - unsigned char *answer, size_t answer_size); + struct dns_reply *repl, unsigned long *ttl); dns_status ptr_validate(const char *ipstr, char ***vnptr, size_t *vcount, unsigned long *pttl); - + +dns_status spf_lookup(const char *domain, + char ***txtv, size_t *txtc, unsigned long *ttl); + + #endif |