byaddr.c revision 6028d1ce0380d0ba7f6c6ecd1ad20b31ddd1becb
/*
* Copyright (C) 2000 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#include <config.h>
#include <dns/rdataset.h>
#include <dns/resolver.h>
/*
* XXXRTH We could use a static event...
*/
struct dns_byaddr {
/* Unlocked. */
unsigned int magic;
/* Locked by lock. */
unsigned int options;
isc_task_t * task;
dns_view_t * view;
dns_fetch_t * fetch;
unsigned int restarts;
};
#define VALID_BYADDR(b) ((b) != NULL && \
(b)->magic == BYADDR_MAGIC)
#define MAX_RESTARTS 16
static char hex_digits[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};
static inline isc_result_t
char textname[128];
unsigned char *bytes;
int i;
char *cp;
unsigned int len;
/*
* The caller must be holding the byaddr's lock.
*/
/*
* We create the text representation and then convert to a
* dns_name_t. This is not maximally efficient, but it keeps all
* of the knowledge of wire format in the dns_name_ routines.
*/
(bytes[0] & 0xff));
for (i = 15; i >= 0; i--) {
*cp++ = '.';
*cp++ = '.';
}
} else {
*cp++ = '\\';
*cp++ = '[';
*cp++ = 'x';
for (i = 0; i < 16; i += 2) {
}
}
} else
return (ISC_R_NOTIMPLEMENTED);
}
static inline isc_result_t
isc_region_t r;
/*
* The caller must be holding the byaddr's lock.
*/
while (result == ISC_R_SUCCESS) {
dns_name_fromregion(&target, &r);
return (ISC_R_NOMEMORY);
if (result != ISC_R_SUCCESS) {
return (ISC_R_NOMEMORY);
}
}
if (result == ISC_R_NOMORE)
return (result);
}
static void
}
static inline isc_result_t
/*
* The caller must be holding the byaddr's lock.
*/
return (result);
}
static void
isc_region_t r;
int order;
do {
dns_rdatatype_ptr, 0, 0,
if (result == ISC_R_NOTFOUND) {
/*
* We don't know anything about the name.
* Launch a fetch.
*/
if (result != ISC_R_SUCCESS)
goto done;
}
} else {
/*
* Detach (if necessary) from things we know we
* don't care about.
*/
}
/*
* If we've been canceled, forget about the result.
*/
switch (result) {
case ISC_R_SUCCESS:
break;
case DNS_R_CNAME:
/*
* Copy the CNAME's target into the byaddr's
* query name and start over.
*/
if (result != ISC_R_SUCCESS)
break;
dns_name_fromregion(&tname, &r);
NULL);
if (result == ISC_R_SUCCESS)
break;
case DNS_R_DNAME:
/*
* Get the target name of the DNAME.
*/
if (result != ISC_R_SUCCESS)
break;
dns_name_fromregion(&tname, &r);
/*
* Construct the new query name and start over.
*/
NULL);
if (result != ISC_R_SUCCESS)
break;
NULL);
if (result == ISC_R_SUCCESS)
break;
default:
}
done:
}
/*
* Limit the number of restarts.
*/
}
} while (want_restart);
if (send_event) {
}
}
static void
}
}
{
return (ISC_R_NOMEMORY);
goto cleanup_byaddr;
}
if (result != ISC_R_SUCCESS)
goto cleanup_event;
if (result != ISC_R_SUCCESS)
goto cleanup_lock;
return (ISC_R_SUCCESS);
return (result);
}
void
}
}
}
void
}