diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2011-06-10 14:01:17 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2011-07-13 12:35:45 -0400 |
commit | 90f150f678347f1f73ee4280cd523021e307d861 (patch) | |
tree | fe93aa07c20d98522fd0c359f50c69b7519f49e0 /src/resolv/async_resolv.h | |
parent | 401bfa7e4f8c2ed555576576881a2bd9622c1e2e (diff) | |
download | sssd-90f150f678347f1f73ee4280cd523021e307d861.tar.gz sssd-90f150f678347f1f73ee4280cd523021e307d861.tar.xz sssd-90f150f678347f1f73ee4280cd523021e307d861.zip |
Honor the TTL value of SRV record lookups
Add new resolv_hostent data structure and utility functions
Resolve hosts by name from files into resolv_hostent
Resolve hosts by name from DNS into resolv_hostent
Switch resolver to using resolv_hostent and honor TTL
Conflicts:
src/providers/fail_over.c
Provide TTL structure names for c-ares < 1.7
https://fedorahosted.org/sssd/ticket/898
In c-ares 1.7, the upstream renamed the addrttl/addr6ttl structures to
ares_addrttl/ares_addr6ttl so they are in the ares_ namespace.
Because they are committed to stable ABI, the contents are the same, just
the name changed -- so it is safe to just #define the new name for older
c-ares version in case the new one is not detected in configure time.
Diffstat (limited to 'src/resolv/async_resolv.h')
-rw-r--r-- | src/resolv/async_resolv.h | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/src/resolv/async_resolv.h b/src/resolv/async_resolv.h index d6cbe1494..907865f7a 100644 --- a/src/resolv/async_resolv.h +++ b/src/resolv/async_resolv.h @@ -37,6 +37,10 @@ #include "resolv/ares/ares_data.h" #endif /* HAVE_ARES_DATA */ +#ifndef RESOLV_DEFAULT_TTL +#define RESOLV_DEFAULT_TTL 7200 +#endif /* RESOLV_DEFAULT_TTL */ + /* * An opaque structure which holds context for a module using the async * resolver. Is should be used as a "local-global" variable - in sssd, @@ -53,10 +57,22 @@ void resolv_reread_configuration(void); const char *resolv_strerror(int ares_code); -struct hostent *resolv_copy_hostent(TALLOC_CTX *mem_ctx, - struct hostent *src); +struct resolv_hostent * +resolv_copy_hostent(TALLOC_CTX *mem_ctx, struct hostent *src); + +struct resolv_hostent * +resolv_copy_hostent_ares(TALLOC_CTX *mem_ctx, struct hostent *src, + int family, void *ares_ttl_data, + int num_ares_ttl_data); /** Get host by name **/ +enum host_database { + DB_FILES, + DB_DNS, + + DB_SENTINEL +}; + enum restrict_family { IPV4_ONLY, IPV4_FIRST, @@ -64,20 +80,39 @@ enum restrict_family { IPV6_FIRST }; +/* If resolv_hostent->family is AF_INET, then ipaddr points to + * struct in_addr, else if family is AF_INET6, ipaddr points to + * struct in6_addr + */ +struct resolv_addr { + uint8_t *ipaddr; + int ttl; +}; + +struct resolv_hostent { + char *name; /* official name of host */ + char **aliases; /* alias list */ + int family; /* host address type */ + + struct resolv_addr **addr_list; /* list of addresses */ +}; + +/* The default database order */ +extern enum host_database default_host_dbs[]; + struct tevent_req *resolv_gethostbyname_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct resolv_ctx *ctx, const char *name, - enum restrict_family family_order); + enum restrict_family family_order, + enum host_database *db); -int resolv_gethostbyname_recv(struct tevent_req *req, - TALLOC_CTX *mem_ctx, - int *status, - int *timeouts, - struct hostent **hostent); +int resolv_gethostbyname_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, + int *status, int *timeouts, + struct resolv_hostent **rhostent); char * -resolv_get_string_address(TALLOC_CTX *mem_ctx, struct hostent *hostent); +resolv_get_string_address(TALLOC_CTX *mem_ctx, struct resolv_hostent *hostent); /** Get SRV record **/ struct tevent_req *resolv_getsrv_send(TALLOC_CTX *mem_ctx, |