Data Structures | Defines | Typedefs | Enumerations | Functions | Variables

ink_resolver.h File Reference

#include "ink_platform.h"
#include <ts/ink_inet.h>
#include <resolv.h>
#include <arpa/nameser.h>
Include dependency graph for ink_resolver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ts_imp_res_state

Defines

#define INK_RES_F_VC   0x00000001
#define INK_RES_F_CONN   0x00000002
#define INK_RES_F_EDNS0ERR   0x00000004
#define INK_RES_F__UNUSED   0x00000008
#define INK_RES_F_LASTMASK   0x000000F0
#define INK_RES_F_LASTSHIFT   4
#define INK_RES_GETLAST(res)   (((res)._flags & INK_RES_F_LASTMASK) >> INK_RES_F_LASTSHIFT)
#define INK_RES_EXHAUSTIVE   0x00000001
#define INK_RES_IPV4ONLY   0x00000002
#define INK_RES_IPV6ONLY   0x00000004
#define INK_RES_INIT   0x00000001
#define INK_RES_DEBUG   0x00000002
#define INK_RES_AAONLY   0x00000004
#define INK_RES_USEVC   0x00000008
#define INK_RES_PRIMARY   0x00000010
#define INK_RES_IGNTC   0x00000020
#define INK_RES_RECURSE   0x00000040
#define INK_RES_DEFNAMES   0x00000080
#define INK_RES_STAYOPEN   0x00000100
#define INK_RES_DNSRCH   0x00000200
#define INK_RES_INSECURE1   0x00000400
#define INK_RES_INSECURE2   0x00000800
#define INK_RES_NOALIASES   0x00001000
#define INK_RES_USE_INET6   0x00002000
#define INK_RES_ROTATE   0x00004000
#define INK_RES_NOCHECKNAME   0x00008000
#define INK_RES_KEEPTSIG   0x00010000
#define INK_RES_BLAST   0x00020000
#define INK_RES_NSID   0x00040000
#define INK_RES_NOTLDQUERY   0x00100000
#define INK_RES_USE_DNSSEC   0x00200000
#define INK_RES_USE_DNAME   0x10000000
#define INK_RES_USE_EDNS0   0x40000000
#define INK_RES_DEFAULT
#define INK_MAXNS   32
#define INK_MAXDFLSRCH   3
#define INK_MAXDNSRCH   6
#define INK_LOCALDOMAINPARTS   2
#define INK_RES_TIMEOUT   5
#define INK_RES_TIMEOUT   5
#define INK_RES_MAXNDOTS   15
#define INK_RES_MAXRETRANS   30
#define INK_RES_MAXRETRY   5
#define INK_RES_DFLRETRY   2
#define INK_RES_MAXTIME   65535
#define INK_NS_TYPE_ELT   0x40
#define INK_DNS_LABELTYPE_BITSTRING   0x41
#define NS_GET16(s, cp)
#define NS_GET32(l, cp)
#define NS_PUT16(s, cp)
#define NS_PUT32(l, cp)

Typedefs

typedef HostResPreference HostResPreferenceOrder [N_HOST_RES_PREFERENCE_ORDER]
 Storage for preference ordering.
typedef ts_imp_res_stateink_res_state

Enumerations

enum  HostResPreference { HOST_RES_PREFER_NONE = 0, HOST_RES_PREFER_CLIENT, HOST_RES_PREFER_IPV4, HOST_RES_PREFER_IPV6 }
 

IP family preference for DNS resolution.

More...
enum  HostResStyle {
  HOST_RES_NONE = 0, HOST_RES_IPV4, HOST_RES_IPV4_ONLY, HOST_RES_IPV6,
  HOST_RES_IPV6_ONLY
}
 

IP family to use in a DNS query for a host address.

More...

Functions

HostResStyle ats_host_res_from (int family, HostResPreferenceOrder)
 Caclulate the effective resolution preferences.
HostResStyle ats_host_res_match (sockaddr const *addr)
 Calculate the host resolution style to force a family match to addr.
void parse_host_res_preference (char const *value, HostResPreferenceOrder order)
 Parse a host resolution configuration string.
int ink_res_init (ink_res_state, IpEndpoint const *pHostList, size_t pHostListSize, const char *pDefDomain=NULL, const char *pSearchList=NULL, const char *pResolvConf=NULL)
int ink_res_mkquery (ink_res_state, int, const char *, int, int, const unsigned char *, int, const unsigned char *, unsigned char *, int)
int ink_ns_name_ntop (const u_char *src, char *dst, size_t dstsiz)
void ts_host_res_global_init ()
 Initialize global values for HttpProxyPort / Host Resolution.
int ts_host_res_order_to_string (HostResPreferenceOrder const &order, char *out, int size)
 Generate a string representation of a host resolution preference ordering.

Variables

static int const N_HOST_RES_PREFERENCE = HOST_RES_PREFER_IPV6+1
 # of preference values.
static int const N_HOST_RES_PREFERENCE_ORDER = 3
 # of entries in a preference ordering.
HostResPreferenceOrder const HOST_RES_DEFAULT_PREFERENCE_ORDER
 Global, hard wired default value for preference ordering.
HostResPreferenceOrder host_res_default_preference_order
 Global (configurable) default.
char const *const HOST_RES_PREFERENCE_STRING [N_HOST_RES_PREFERENCE]
 String versions of FamilyPreference.
char const *const HOST_RES_STYLE_STRING []
 Strings for host resolution styles.

Define Documentation

#define INK_DNS_LABELTYPE_BITSTRING   0x41

Definition at line 146 of file ink_resolver.h.

Referenced by ink_ns_name_ntop(), labellen(), and ns_name_ntop().

#define INK_LOCALDOMAINPARTS   2

Definition at line 136 of file ink_resolver.h.

Referenced by ink_res_init().

#define INK_MAXDFLSRCH   3

Definition at line 134 of file ink_resolver.h.

Referenced by ink_res_init().

#define INK_MAXDNSRCH   6

Definition at line 135 of file ink_resolver.h.

#define INK_MAXNS   32

Definition at line 133 of file ink_resolver.h.

Referenced by ink_res_init(), and ink_res_setservers().

#define INK_NS_TYPE_ELT   0x40

Definition at line 145 of file ink_resolver.h.

Referenced by ink_ns_name_ntop(), labellen(), and ns_name_ntop().

#define INK_RES_AAONLY   0x00000004

Definition at line 106 of file ink_resolver.h.

#define INK_RES_BLAST   0x00020000

Definition at line 121 of file ink_resolver.h.

#define INK_RES_DEBUG   0x00000002

Definition at line 105 of file ink_resolver.h.

Referenced by ink_res_init(), and ink_res_setoptions().

#define INK_RES_DEFAULT
Value:
(INK_RES_RECURSE | INK_RES_DEFNAMES | \
                         INK_RES_DNSRCH)

Definition at line 130 of file ink_resolver.h.

#define INK_RES_DEFNAMES   0x00000080

Definition at line 111 of file ink_resolver.h.

#define INK_RES_DFLRETRY   2

Definition at line 142 of file ink_resolver.h.

#define INK_RES_DNSRCH   0x00000200

Definition at line 113 of file ink_resolver.h.

#define INK_RES_EXHAUSTIVE   0x00000001

Definition at line 96 of file ink_resolver.h.

#define INK_RES_F__UNUSED   0x00000008

Definition at line 90 of file ink_resolver.h.

#define INK_RES_F_CONN   0x00000002

Definition at line 88 of file ink_resolver.h.

#define INK_RES_F_EDNS0ERR   0x00000004

Definition at line 89 of file ink_resolver.h.

#define INK_RES_F_LASTMASK   0x000000F0

Definition at line 91 of file ink_resolver.h.

#define INK_RES_F_LASTSHIFT   4

Definition at line 92 of file ink_resolver.h.

#define INK_RES_F_VC   0x00000001

Definition at line 87 of file ink_resolver.h.

Referenced by ink_res_nclose().

#define INK_RES_GETLAST (   res  )     (((res)._flags & INK_RES_F_LASTMASK) >> INK_RES_F_LASTSHIFT)

Definition at line 93 of file ink_resolver.h.

#define INK_RES_IGNTC   0x00000020

Definition at line 109 of file ink_resolver.h.

#define INK_RES_INIT   0x00000001

Definition at line 104 of file ink_resolver.h.

#define INK_RES_INSECURE1   0x00000400

Definition at line 114 of file ink_resolver.h.

#define INK_RES_INSECURE2   0x00000800

Definition at line 115 of file ink_resolver.h.

#define INK_RES_IPV4ONLY   0x00000002

Definition at line 97 of file ink_resolver.h.

#define INK_RES_IPV6ONLY   0x00000004

Definition at line 98 of file ink_resolver.h.

#define INK_RES_KEEPTSIG   0x00010000

Definition at line 120 of file ink_resolver.h.

#define INK_RES_MAXNDOTS   15

Definition at line 139 of file ink_resolver.h.

Referenced by ink_res_setoptions().

#define INK_RES_MAXRETRANS   30

Definition at line 140 of file ink_resolver.h.

Referenced by ink_res_setoptions().

#define INK_RES_MAXRETRY   5

Definition at line 141 of file ink_resolver.h.

Referenced by ink_res_setoptions().

#define INK_RES_MAXTIME   65535

Definition at line 143 of file ink_resolver.h.

#define INK_RES_NOALIASES   0x00001000

Definition at line 116 of file ink_resolver.h.

#define INK_RES_NOCHECKNAME   0x00008000

Definition at line 119 of file ink_resolver.h.

#define INK_RES_NOTLDQUERY   0x00100000

Definition at line 123 of file ink_resolver.h.

#define INK_RES_NSID   0x00040000

Definition at line 122 of file ink_resolver.h.

#define INK_RES_PRIMARY   0x00000010

Definition at line 108 of file ink_resolver.h.

#define INK_RES_RECURSE   0x00000040

Definition at line 110 of file ink_resolver.h.

#define INK_RES_ROTATE   0x00004000

Definition at line 118 of file ink_resolver.h.

#define INK_RES_STAYOPEN   0x00000100

Definition at line 112 of file ink_resolver.h.

#define INK_RES_TIMEOUT   5

Definition at line 138 of file ink_resolver.h.

#define INK_RES_TIMEOUT   5

Definition at line 138 of file ink_resolver.h.

#define INK_RES_USE_DNAME   0x10000000

Definition at line 127 of file ink_resolver.h.

#define INK_RES_USE_DNSSEC   0x00200000

Definition at line 124 of file ink_resolver.h.

#define INK_RES_USE_EDNS0   0x40000000

Definition at line 128 of file ink_resolver.h.

#define INK_RES_USE_INET6   0x00002000

Definition at line 117 of file ink_resolver.h.

#define INK_RES_USEVC   0x00000008

Definition at line 107 of file ink_resolver.h.

#define NS_GET16 (   s,
  cp 
)
Value:
do { \
        const u_char *t_cp = (const u_char *)(cp); \
        (s) = ((u_int16_t)t_cp[0] << 8) \
            | ((u_int16_t)t_cp[1]) \
            ; \
        (cp) += NS_INT16SZ; \
} while (0)

Definition at line 201 of file ink_resolver.h.

Referenced by dns_process(), and ink_get16().

#define NS_GET32 (   l,
  cp 
)
Value:
do { \
        const u_char *t_cp = (const u_char *)(cp); \
        (l) = ((u_int32_t)t_cp[0] << 24) \
            | ((u_int32_t)t_cp[1] << 16) \
            | ((u_int32_t)t_cp[2] << 8) \
            | ((u_int32_t)t_cp[3]) \
            ; \
        (cp) += NS_INT32SZ; \
} while (0)

Definition at line 211 of file ink_resolver.h.

Referenced by dns_process().

#define NS_PUT16 (   s,
  cp 
)
Value:
do { \
        u_int16_t t_s = (u_int16_t)(s); \
        u_char *t_cp = (u_char *)(cp); \
        *t_cp++ = t_s >> 8; \
        *t_cp   = t_s; \
        (cp) += NS_INT16SZ; \
} while (0)

Definition at line 223 of file ink_resolver.h.

Referenced by ink_res_mkquery().

#define NS_PUT32 (   l,
  cp 
)
Value:
do { \
        u_int32_t t_l = (u_int32_t)(l); \
        u_char *t_cp = (u_char *)(cp); \
        *t_cp++ = t_l >> 24; \
        *t_cp++ = t_l >> 16; \
        *t_cp++ = t_l >> 8; \
        *t_cp   = t_l; \
        (cp) += NS_INT32SZ; \
} while (0)

Definition at line 233 of file ink_resolver.h.

Referenced by ink_res_mkquery().


Typedef Documentation

Storage for preference ordering.

Definition at line 161 of file ink_resolver.h.

Definition at line 274 of file ink_resolver.h.


Enumeration Type Documentation

IP family preference for DNS resolution.

Used for configuration.

Enumerator:
HOST_RES_PREFER_NONE 

Invalid / init value.

HOST_RES_PREFER_CLIENT 

Prefer family of client connection.

HOST_RES_PREFER_IPV4 

Prefer IPv4.

HOST_RES_PREFER_IPV6 

Prefer IPv6.

Definition at line 150 of file ink_resolver.h.

IP family to use in a DNS query for a host address.

Used during DNS query operations.

Enumerator:
HOST_RES_NONE 

No preference / unspecified / init value.

HOST_RES_IPV4 

Use IPv4 if possible.

HOST_RES_IPV4_ONLY 

Resolve on IPv4 addresses.

HOST_RES_IPV6 

Use IPv6 if possible.

HOST_RES_IPV6_ONLY 

Resolve only IPv6 addresses.

Definition at line 171 of file ink_resolver.h.


Function Documentation

HostResStyle ats_host_res_from ( int  family,
HostResPreferenceOrder   
)

Caclulate the effective resolution preferences.

Parameters:
family Connection family

Definition at line 505 of file ink_res_mkquery.cc.

References HOST_RES_PREFER_CLIENT, HOST_RES_PREFER_IPV4, HOST_RES_PREFER_IPV6, and N_HOST_RES_PREFERENCE_ORDER.

Referenced by HttpSessionAccept::accept().

HostResStyle ats_host_res_match ( sockaddr const *  addr  ) 

Calculate the host resolution style to force a family match to addr.

Definition at line 529 of file ink_res_mkquery.cc.

References ats_is_ip4(), and ats_is_ip6().

Referenced by HttpTransact::handle_response_from_server().

int ink_ns_name_ntop ( const u_char *  src,
char *  dst,
size_t  dstsiz 
)
int ink_res_init ( ink_res_state  ,
IpEndpoint const *  pHostList,
size_t  pHostListSize,
const char *  pDefDomain = NULL,
const char *  pSearchList = NULL,
const char *  pResolvConf = NULL 
)
int ink_res_mkquery ( ink_res_state  ,
int  ,
const char *  ,
int  ,
int  ,
const unsigned char *  ,
int  ,
const unsigned char *  ,
unsigned char *  ,
int   
)
void parse_host_res_preference ( char const *  value,
HostResPreferenceOrder  order 
)

Parse a host resolution configuration string.

Parameters:
[in] value Configuration string.
[out] order Order to update.

Definition at line 582 of file ink_res_init.cc.

References HOST_RES_PREFER_IPV4, HOST_RES_PREFER_IPV6, HOST_RES_PREFER_NONE, HOST_RES_PREFERENCE_STRING, Tokenizer::Initialize(), N_HOST_RES_PREFERENCE, and N_HOST_RES_PREFERENCE_ORDER.

Referenced by HttpProxyPort::processFamilyPreference(), and ts_host_res_global_init().

void ts_host_res_global_init (  ) 

Initialize global values for HttpProxyPort / Host Resolution.

Definition at line 562 of file RecHttp.cc.

References ats_free(), HOST_RES_DEFAULT_PREFERENCE_ORDER, host_res_default_preference_order, memcpy, parse_host_res_preference(), and REC_ConfigReadString().

Referenced by ink_hostdb_init().

int ts_host_res_order_to_string ( HostResPreferenceOrder const &  order,
char *  out,
int  size 
)

Generate a string representation of a host resolution preference ordering.

Returns:
The length of the string.
Parameters:
order order to print
out Target buffer for string.
size Size of buffer.

Definition at line 630 of file ink_res_init.cc.

References HOST_RES_PREFER_NONE, HOST_RES_PREFERENCE_STRING, and N_HOST_RES_PREFERENCE_ORDER.

Referenced by HttpProxyPort::print().


Variable Documentation

Global, hard wired default value for preference ordering.

Definition at line 97 of file ink_res_init.cc.

Referenced by ts_host_res_global_init().

String versions of FamilyPreference.

Definition at line 105 of file ink_res_init.cc.

Referenced by parse_host_res_preference(), HttpProxyPort::processOptions(), and ts_host_res_order_to_string().

char const* const HOST_RES_STYLE_STRING[]

Strings for host resolution styles.

Definition at line 109 of file ink_res_init.cc.

int const N_HOST_RES_PREFERENCE = HOST_RES_PREFER_IPV6+1 [static]

# of preference values.

Definition at line 157 of file ink_resolver.h.

Referenced by parse_host_res_preference().

int const N_HOST_RES_PREFERENCE_ORDER = 3 [static]

# of entries in a preference ordering.

Definition at line 159 of file ink_resolver.h.

Referenced by ats_host_res_from(), parse_host_res_preference(), and ts_host_res_order_to_string().