summaryrefslogtreecommitdiffstats
path: root/include/resolv.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/resolv.h')
-rw-r--r--include/resolv.h107
1 files changed, 72 insertions, 35 deletions
diff --git a/include/resolv.h b/include/resolv.h
index 546de96a9..f253cef1a 100644
--- a/include/resolv.h
+++ b/include/resolv.h
@@ -98,56 +98,87 @@ typedef res_sendhookact (*res_send_rhook) (const struct sockaddr_in *ns,
# define RES_MAXNDOTS 15 /* should reflect bit field size */
# define RES_MAXRETRANS 30 /* only for resolv.conf/RES_OPTIONS */
# define RES_MAXRETRY 5 /* only for resolv.conf/RES_OPTIONS */
-# define RES_DFLRETRY 2 /* Default #/tries. */
+# define RES_DFLRETRY 3 /* Default #/tries. */
+/* (glibc uses RES_DFLRETRY of 2 but also does _res.retry = 4 sometimes (!) */
# define RES_MAXTIME 65535 /* Infinity, in milliseconds. */
+/* _res (an instance of this structure) uses 0.5kb in bss
+ * in "ordinary" libc's (glibc, xBSD). We want to be less wasteful.
+ * We (1) shuffle and shrink some integer fields,
+ * and (2) can switch off stuff we don't support.
+ * Everything inside __UCLIBC_HAS_COMPAT_RES_STATE__
+ * is not actually used by uclibc and can be configured off.
+ * However, this will prevent some programs from building.
+ * Really obscure stuff with no observed users in the wild is under
+ * __UCLIBC_HAS_EXTRA_COMPAT_RES_STATE__.
+ * I guess it's safe to set that to N.
+ */
struct __res_state {
- int retrans; /* retransmition time interval */
+#ifdef __UCLIBC_HAS_COMPAT_RES_STATE__
+ int retrans; /* retransmission time interval */
int retry; /* number of times to retransmit */
- u_long options; /* option flags - see below. */
- int nscount; /* number of name servers */
- struct sockaddr_in
- nsaddr_list[MAXNS]; /* address of name server */
-# define nsaddr nsaddr_list[0] /* for backward compatibility */
- u_short id; /* current message id */
- char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
+#endif
+ u_int32_t options; /* (was: ulong) option flags - see below. */
+ struct sockaddr_in nsaddr_list[MAXNS]; /* address of name server */
+#define nsaddr nsaddr_list[0] /* for backward compatibility */
+ char *dnsrch[MAXDNSRCH + 1]; /* components of domain to search */
+#ifdef __UCLIBC_HAS_COMPAT_RES_STATE__
+ /* googling for "_res.defdname" says it's still sometimes used.
+ * Pity. It's huge, I want to move it to EXTRA_COMPAT... */
char defdname[256]; /* default domain (deprecated) */
- u_long pfcode; /* RES_PRF_ flags - see below. */
- unsigned ndots:4; /* threshold for initial abs. query */
- unsigned nsort:4; /* number of elements in sort_list[] */
- char unused[3];
+#endif
+ u_int8_t nscount; /* (was: int) number of name servers */
+ u_int8_t ndots; /* (was: unsigned:4) threshold for initial abs. query */
+#ifdef __UCLIBC_HAS_COMPAT_RES_STATE__
+ u_int8_t nsort; /* (was: unsigned:4) number of elements in sort_list[] */
+ u_int16_t pfcode; /* (was: ulong) RES_PRF_ flags. Used by dig. */
+ unsigned short id; /* current message id */
+ int res_h_errno; /* last one set for this context */
struct {
struct in_addr addr;
u_int32_t mask;
} sort_list[MAXRESOLVSORT];
- res_send_qhook qhook; /* query hook */
- res_send_rhook rhook; /* response hook */
- int res_h_errno; /* last one set for this context */
- int _vcsock; /* PRIVATE: for res_send VC i/o */
- u_int _flags; /* PRIVATE: see below */
+#endif
+
+#ifdef __UCLIBC_HAS_IPV6__
+ /* I assume that the intention is to store all
+ * DNS servers' addresses here, and duplicate in nsaddr_list[]
+ * those which have IPv4 address. In the case of IPv4 address
+ * _u._ext.nsaddrs[x] will point to some nsaddr_list[y],
+ * otherwise it will point into malloc'ed sockaddr_in6.
+ * nscount is the number of IPv4 addresses and _u._ext.nscount
+ * is the number of addresses of all kinds.
+ *
+ * If this differs from established usage and you need
+ * to change this, please describe how it is supposed to work.
+ */
union {
- char pad[52]; /* On an i386 this means 512b total. */
struct {
- u_int16_t nscount;
-#if 0
- u_int16_t nsmap[MAXNS];
-#else
- u_int16_t nstimes[MAXNS]; /* ms. */
-#endif
+ struct sockaddr_in6 *nsaddrs[MAXNS];
+ u_int8_t nscount; /* (was: u_int16_t) */
+#ifdef __UCLIBC_HAS_COMPAT_RES_STATE__
+ /* rather obscure, and differs in BSD and glibc */
+ u_int16_t nstimes[MAXNS];
int nssocks[MAXNS];
u_int16_t nscount6;
u_int16_t nsinit;
- struct sockaddr_in6 *nsaddrs[MAXNS];
-#if 0
-#ifdef _LIBC
- unsigned long long int initstamp
- __attribute__((packed));
-#else
- unsigned int _initstamp[2];
-#endif
+ /* glibc also has: */
+ /*u_int16_t nsmap[MAXNS];*/
+ /*unsigned long long initstamp;*/
#endif
} _ext;
} _u;
+#endif
+
+#ifdef __UCLIBC_HAS_EXTRA_COMPAT_RES_STATE__
+ /* Truly obscure stuff.
+ * Googling for "_res.XXX" for these members
+ * turned up basically empty */
+ res_send_qhook qhook; /* query hook */
+ res_send_rhook rhook; /* response hook */
+ int _vcsock; /* PRIVATE: for res_send VC i/o */
+ unsigned _flags; /* PRIVATE: see below */
+#endif
};
typedef struct __res_state *res_state;
@@ -196,6 +227,7 @@ struct res_sym {
/*
* Resolver options (keep these in synch with res_debug.c, please)
+ * (which of these do we really implement??)
*/
#define RES_INIT 0x00000001 /* address initialized */
#define RES_DEBUG 0x00000002 /* print debug messages */
@@ -247,10 +279,14 @@ struct res_sym {
/* 0x00008000 */
/* Things involving an internal (static) resolver context. */
+#if 0
__BEGIN_DECLS
extern struct __res_state *__res_state(void) __attribute__ ((__const__));
__END_DECLS
#define _res (*__res_state())
+#else
+extern struct __res_state _res;
+#endif
#define fp_nquery __fp_nquery
#define fp_query __fp_query
@@ -274,12 +310,15 @@ void p_query (const u_char *) __THROW;
void res_close (void) __THROW;
#endif
int res_init (void) __THROW;
+libc_hidden_proto(res_init)
int res_isourserver (const struct sockaddr_in *) __THROW;
int res_mkquery (int, const char *, int, int, const u_char *,
int, const u_char *, u_char *, int) __THROW;
int res_query (const char *, int, int, u_char *, int) __THROW;
+libc_hidden_proto(res_query)
int res_querydomain (const char *, const char *, int, int,
u_char *, int) __THROW;
+libc_hidden_proto(res_querydomain)
int res_search (const char *, int, int, u_char *, int) __THROW;
int res_send (const u_char *, int, u_char *, int) __THROW;
__END_DECLS
@@ -386,7 +425,6 @@ int res_nsend (res_state, const u_char *, int, u_char *, int)
__THROW;
void res_nclose (res_state) __THROW;
__END_DECLS
-
# if _LIBC
# ifdef __UCLIBC_HAS_THREADS__
# if defined __UCLIBC_HAS_THREADS_NATIVE__ \
@@ -404,5 +442,4 @@ extern __thread struct __res_state *__resp attribute_tls_model_ie;
# endif /* __UCLIBC_HAS_THREADS_NATIVE__ */
# endif /* __UCLIBC_HAS_THREADS__ */
# endif /* _LIBC */
-
#endif /* !_RESOLV_H_ */