mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
Bitstring labels are independent of DNAMEs.
Provide a runtime mechanism to set the IPv6 suffixes for reverse lookups. Provide a runtime mechanism to disable each of the IPv6 reverse lookup methods. Provide a mechanism to free memory allocated by res_{n}init().
This commit is contained in:
@@ -50,7 +50,7 @@
|
||||
|
||||
/*
|
||||
* @(#)resolv.h 8.1 (Berkeley) 6/2/93
|
||||
* $Id: resolv.h,v 1.2 2001/04/02 07:53:19 marka Exp $
|
||||
* $Id: resolv.h,v 1.3 2001/05/21 14:31:29 marka Exp $
|
||||
*/
|
||||
|
||||
#ifndef _RESOLV_H_
|
||||
@@ -218,6 +218,8 @@ typedef struct __res_state *res_state;
|
||||
#define RES_NOCHECKNAME 0x00008000 /* do not check names for sanity. */
|
||||
#define RES_KEEPTSIG 0x00010000 /* do not strip TSIG records */
|
||||
#define RES_BLAST 0x00020000 /* blast all recursive servers */
|
||||
#define RES_NO_NIBBLE 0x00040000 /* disable IPv6 nibble mode reverse */
|
||||
#define RES_NO_BITSTRING 0x00080000 /* disable IPv6 bits tring mode reverse */
|
||||
/* KAME extensions: use higher bit to avoid conflict with ISC use */
|
||||
#define RES_USE_EDNS0 0x40000000 /* use EDNS0 if configured */
|
||||
#define RES_USE_A6 0x20000000 /* use A6 */
|
||||
@@ -350,6 +352,7 @@ extern const struct res_sym __p_rcode_syms[];
|
||||
#define sym_ntos __sym_ntos
|
||||
#define sym_ston __sym_ston
|
||||
#define res_nopt __res_nopt
|
||||
#define res_ndestroy __res_ndestroy
|
||||
__BEGIN_DECLS
|
||||
int res_hnok __P((const char *));
|
||||
int res_ownok __P((const char *));
|
||||
@@ -424,6 +427,9 @@ const char * res_servicename __P((u_int16_t port, const char *proto));
|
||||
const char * res_protocolname __P((int num));
|
||||
void res_destroyprotolist __P((void));
|
||||
void res_buildprotolist __P((void));
|
||||
const char * res_get_nibblesuffix __P((res_state));
|
||||
const char * res_get_bitstringsuffix __P((res_state));
|
||||
void res_ndestroy __P((res_state));
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_RESOLV_H_ */
|
||||
|
@@ -52,7 +52,7 @@
|
||||
/* BIND Id: gethnamaddr.c,v 8.15 1996/05/22 04:56:30 vixie Exp $ */
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static const char rcsid[] = "$Id: dns_ho.c,v 1.1 2001/03/29 06:31:42 marka Exp $";
|
||||
static const char rcsid[] = "$Id: dns_ho.c,v 1.2 2001/05/21 14:31:30 marka Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* Imports. */
|
||||
@@ -388,17 +388,18 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
|
||||
q.answer = q.qbuf.buf;
|
||||
q.anslen = sizeof(q.qbuf);
|
||||
q.next = &q2;
|
||||
#ifdef RES_USE_DNAME
|
||||
if ((pvt->res->options & RES_USE_DNAME) == 0)
|
||||
if ((pvt->res->options & RES_NO_BITSTRING) != 0)
|
||||
q.action = RESTGT_IGNORE;
|
||||
else
|
||||
#endif
|
||||
q.action = RESTGT_DOALWAYS;
|
||||
q2.qclass = C_IN;
|
||||
q2.qtype = T_PTR;
|
||||
q2.answer = q2.qbuf.buf;
|
||||
q2.anslen = sizeof(q2.qbuf);
|
||||
q2.action = RESTGT_AFTERFAILURE;
|
||||
if ((pvt->res->options & RES_NO_NIBBLE) != 0)
|
||||
q2.action = RESTGT_IGNORE;
|
||||
else
|
||||
q2.action = RESTGT_AFTERFAILURE;
|
||||
break;
|
||||
default:
|
||||
errno = EAFNOSUPPORT;
|
||||
@@ -425,15 +426,18 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
|
||||
qp += SPRINTF((qp, "\\[x"));
|
||||
for (n = 0; n < IN6ADDRSZ; n++)
|
||||
qp += SPRINTF((qp, "%02x", uaddr[n]));
|
||||
strcpy(qp, "/128].ip6.arpa");
|
||||
SPRINTF((qp, "/128].%s",
|
||||
res_get_bitstringsuffix(pvt->res)));
|
||||
}
|
||||
qp = q2.qname;
|
||||
for (n = IN6ADDRSZ - 1; n >= 0; n--) {
|
||||
qp += SPRINTF((qp, "%x.%x.",
|
||||
uaddr[n] & 0xf,
|
||||
(uaddr[n] >> 4) & 0xf));
|
||||
if (q2.action != RESTGT_IGNORE) {
|
||||
qp = q2.qname;
|
||||
for (n = IN6ADDRSZ - 1; n >= 0; n--) {
|
||||
qp += SPRINTF((qp, "%x.%x.",
|
||||
uaddr[n] & 0xf,
|
||||
(uaddr[n] >> 4) & 0xf));
|
||||
}
|
||||
strcpy(qp, res_get_nibblesuffix(pvt->res));
|
||||
}
|
||||
strcpy(qp, "ip6.int");
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
@@ -1048,6 +1052,7 @@ gethostans(struct irs_ho *this,
|
||||
int (*name_ok)(const char *);
|
||||
const HEADER *hp;
|
||||
const u_char *eom;
|
||||
const u_char *eor;
|
||||
const u_char *cp;
|
||||
const char *tname;
|
||||
const char *hname;
|
||||
@@ -1155,11 +1160,12 @@ gethostans(struct irs_ho *this,
|
||||
cp += n;
|
||||
continue;
|
||||
}
|
||||
eor = cp + n;
|
||||
if ((qtype == T_A || qtype == T_AAAA || qtype == ns_t_a6 ||
|
||||
qtype == T_ANY) && type == T_CNAME) {
|
||||
if (ap >= &pvt->host_aliases[MAXALIASES-1])
|
||||
continue;
|
||||
n = dn_expand(ansbuf, eom, cp, tbuf, sizeof tbuf);
|
||||
n = dn_expand(ansbuf, eor, cp, tbuf, sizeof tbuf);
|
||||
if (n < 0 || !maybe_ok(pvt->res, tbuf, name_ok)) {
|
||||
had_error++;
|
||||
continue;
|
||||
@@ -1188,11 +1194,11 @@ gethostans(struct irs_ho *this,
|
||||
|
||||
/*
|
||||
* just replace the query target; do not update the
|
||||
* aliase list. (Or should we?)
|
||||
* alias list. (Or should we?)
|
||||
*/
|
||||
t0 = (qtype == T_PTR) ? tname : hname;
|
||||
|
||||
n = dn_expand(ansbuf, eom, cp, tbuf, sizeof(tbuf));
|
||||
n = dn_expand(ansbuf, eor, cp, tbuf, sizeof(tbuf));
|
||||
if (n < 0 || !maybe_dnok(pvt->res, tbuf)) {
|
||||
had_error++;
|
||||
continue;
|
||||
@@ -1231,7 +1237,7 @@ gethostans(struct irs_ho *this,
|
||||
continue;
|
||||
}
|
||||
if (qtype == T_PTR && type == T_CNAME) {
|
||||
n = dn_expand(ansbuf, eom, cp, tbuf, sizeof tbuf);
|
||||
n = dn_expand(ansbuf, eor, cp, tbuf, sizeof tbuf);
|
||||
if (n < 0 || !maybe_dnok(pvt->res, tbuf)) {
|
||||
had_error++;
|
||||
continue;
|
||||
@@ -1283,7 +1289,7 @@ gethostans(struct irs_ho *this,
|
||||
cp += n;
|
||||
continue;
|
||||
}
|
||||
n = dn_expand(ansbuf, eom, cp, bp, buflen);
|
||||
n = dn_expand(ansbuf, eor, cp, bp, buflen);
|
||||
if (n < 0 || !maybe_hnok(pvt->res, bp) ||
|
||||
n >= MAXHOSTNAMELEN) {
|
||||
had_error++;
|
||||
|
@@ -70,7 +70,7 @@
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
|
||||
static const char rcsid[] = "$Id: res_init.c,v 1.3 2001/04/06 05:35:41 marka Exp $";
|
||||
static const char rcsid[] = "$Id: res_init.c,v 1.4 2001/05/21 14:31:31 marka Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "port_before.h"
|
||||
@@ -189,6 +189,8 @@ __res_vinit(res_state statp, int preinit) {
|
||||
if (statp->_u._ext.ext != NULL) {
|
||||
memset(statp->_u._ext.ext, 0, sizeof(*statp->_u._ext.ext));
|
||||
statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr;
|
||||
strcpy(statp->_u._ext.ext->nsuffix, "ip6.int");
|
||||
strcpy(statp->_u._ext.ext->bsuffix, "ip6.arpa");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,6 +440,7 @@ res_setoptions(res_state statp, const char *options, const char *source)
|
||||
{
|
||||
const char *cp = options;
|
||||
int i;
|
||||
struct __res_state_ext *ext = statp->_u._ext.ext;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (statp->options & RES_DEBUG)
|
||||
@@ -500,9 +503,40 @@ res_setoptions(res_state statp, const char *options, const char *source)
|
||||
else if (!strncmp(cp, "dname", sizeof("dname") - 1)) {
|
||||
statp->options |= RES_USE_DNAME;
|
||||
}
|
||||
else if (!strncmp(cp, "nibble:", sizeof("nibble:") - 1)) {
|
||||
if (ext == NULL)
|
||||
goto skip;
|
||||
cp += sizeof("nibble:") - 1;
|
||||
i = MIN(strcspn(cp, " \t"), sizeof(ext->nsuffix) - 1);
|
||||
strncpy(ext->nsuffix, cp, i);
|
||||
ext->nsuffix[i] = '\0';
|
||||
}
|
||||
else if (!strncmp(cp, "bitstring:", sizeof("bitstring:") - 1)) {
|
||||
if (ext == NULL)
|
||||
goto skip;
|
||||
cp += sizeof("bitstring:") - 1;
|
||||
i = MIN(strcspn(cp, " \t"), sizeof(ext->bsuffix) - 1);
|
||||
strncpy(ext->bsuffix, cp, i);
|
||||
ext->bsuffix[i] = '\0';
|
||||
}
|
||||
else if (!strncmp(cp, "v6revmode:", sizeof("v6revmode:") - 1)) {
|
||||
cp += sizeof("v6revmode:") - 1;
|
||||
if (!strncmp(cp, "nibble", sizeof("nibble") - 1)) {
|
||||
statp->options &= ~RES_NO_NIBBLE;
|
||||
statp->options |= RES_NO_BITSTRING;
|
||||
} else if (!strncmp(cp, "bitstring",
|
||||
sizeof("bitstring") - 1)) {
|
||||
statp->options |= RES_NO_NIBBLE;
|
||||
statp->options &= ~RES_NO_BITSTRING;
|
||||
} else if (!strncmp(cp, "both", sizeof("both") - 1)) {
|
||||
statp->options &=
|
||||
~(RES_NO_NIBBLE|RES_NO_BITSTRING);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* XXX - print a warning here? */
|
||||
}
|
||||
skip:
|
||||
/* skip to next run of spaces */
|
||||
while (*cp && *cp != ' ' && *cp != '\t')
|
||||
cp++;
|
||||
@@ -556,3 +590,26 @@ res_nclose(res_state statp) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
res_ndestroy(res_state statp) {
|
||||
res_nclose(statp);
|
||||
if (statp->_u._ext.ext != NULL)
|
||||
free(statp->_u._ext.ext);
|
||||
statp->options &= ~RES_INIT;
|
||||
statp->_u._ext.ext = NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
res_get_nibblesuffix(res_state statp) {
|
||||
if (statp->_u._ext.ext)
|
||||
return (statp->_u._ext.ext->nsuffix);
|
||||
return ("ip6.int");
|
||||
}
|
||||
|
||||
const char *
|
||||
res_get_bitstringsuffix(res_state statp) {
|
||||
if (statp->_u._ext.ext)
|
||||
return (statp->_u._ext.ext->bsuffix);
|
||||
return ("ip6.arpa");
|
||||
}
|
||||
|
@@ -17,6 +17,8 @@ struct __res_state_ext {
|
||||
struct in6_addr in6a;
|
||||
} addr, mask;
|
||||
} sort_list[MAXRESOLVSORT];
|
||||
char nsuffix[64];
|
||||
char bsuffix[64];
|
||||
};
|
||||
|
||||
extern int
|
||||
|
Reference in New Issue
Block a user