byaddr.c revision ec5347e2c775f027573ce5648b910361aa926c01
/*
* Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000-2003 Internet Software Consortium.
*
* 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 ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC 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.
*/
/* $Id: byaddr.c,v 1.38 2007/06/18 23:47:40 tbox Exp $ */
/*! \file */
#include <config.h>
#include <dns/rdataset.h>
#include <dns/rdatastruct.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;
};
#define MAX_RESTARTS 16
static char hex_digits[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};
{
/*
* We dropped bitstring labels, so all lookups will use nibbles.
*/
return (dns_byaddr_createptrname2(address,
}
{
char textname[128];
unsigned char *bytes;
int i;
char *cp;
unsigned int len;
/*
* 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.
*/
"%u.%u.%u.%u.in-addr.arpa.",
(bytes[0] & 0xff));
for (i = 15; i >= 0; i--) {
*cp++ = '.';
*cp++ = '.';
}
if ((options & DNS_BYADDROPT_IPV6INT) != 0)
else
} else
return (ISC_R_NOTIMPLEMENTED);
}
static inline isc_result_t
/*
* The caller must be holding the byaddr's lock.
*/
while (result == ISC_R_SUCCESS) {
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_NOMEMORY);
}
if (result != ISC_R_SUCCESS) {
return (ISC_R_NOMEMORY);
}
}
if (result == ISC_R_NOMORE)
return (result);
}
static void
} else
}
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;
if (result != ISC_R_SUCCESS)
goto cleanup_lock;
return (ISC_R_SUCCESS);
return (result);
}
void
}
}
void
}