dns_nw.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 1996-1999 by 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#endif /* LIBC_SCCS and not lint */
/* Imports. */
#include "port_before.h"
#include <ctype.h>
#include <errno.h>
#include <netdb.h>
#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "dns_p.h"
#ifdef SPRINTF_CHAR
#else
#endif
/* Definitions. */
#define MAXALIASES 35
struct pvt {
char * ali[MAXALIASES];
struct __res_state * res;
void (*free_res)(void *);
};
typedef union {
long al;
char ac;
} align;
/* Forwards. */
static void nw_minimize(struct irs_nw *);
struct __res_state *res,
void (*free_res)(void *));
static int make1101inaddr(const u_char *, int, char *, int);
static void normalize_name(char *name);
/* Exports. */
struct irs_nw *
return (NULL);
}
return (NULL);
}
return (nw);
}
/* Methods. */
static void
}
static struct nwent *
return (NULL);
switch (af) {
case AF_INET:
default:
(void)NULL;
}
return (NULL);
}
static struct nwent *
return (NULL);
switch (af) {
case AF_INET:
default:
(void)NULL;
}
return (NULL);
}
static struct nwent *
return (NULL);
}
static void
/* NOOP */
}
static void
}
static struct __res_state *
struct __res_state *res;
if (!res) {
return (NULL);
}
}
}
static void
void (*free_res)(void *)) {
}
}
/* Private. */
static struct nwent *
int anslen;
return (NULL);
}
if (anslen < 0) {
return (NULL);
}
return (result);
}
static struct nwent *
char qbuf[sizeof "255.255.255.255.in-addr.arpa"];
int anslen;
return (NULL);
}
return (NULL);
return (NULL);
}
if (anslen < 0) {
return (NULL);
}
return (result);
}
static struct nwent *
{
/* Initialize, and parse header. */
return (NULL);
}
while (qdcount-- > 0) {
return (NULL);
}
}
if (!ancount) {
else
return (NULL);
}
/* Prepare a return structure. */
/* Save input key if given. */
switch (by_what) {
case by_name:
return (NULL);
}
#ifdef HAVE_STRLCPY
#else
#endif
bp += n;
}
break;
case by_addr:
return (NULL);
}
}
break;
default:
abort();
}
/* Parse the answer, collect aliases. */
haveanswer = 0;
cp += n; /* Owner */
return (NULL);
}
int nn;
return (NULL);
}
switch (by_what) {
case by_addr: {
break;
else
haveanswer++;
break;
}
case by_name: {
break;
return (NULL);
}
haveanswer++;
}
}
}
cp += n; /* RDATA */
}
if (!haveanswer) {
return (NULL);
}
}
static struct nwent *
if (!nwent)
return (NULL);
< 0) {
/* "First, do no harm." */
return (nwent);
}
return (NULL);
}
/* Query for the A RR that would hold this network's mask. */
return (nwent);
}
/* Initialize, and parse header. */
while (qdcount-- > 0) {
return (nwent);
}
}
/* Parse the answer, collect aliases. */
break;
cp += n; /* Owner */
break;
break;
/* This A RR indicates the actual netmask. */
else
break;
}
cp += n; /* RDATA */
}
return (nwent);
}
static int
int n, m;
char *ep;
/* Zero fill any whole bytes left out of the prefix. */
goto emsgsize;
name += m;
}
/* Format the partial byte, if any, within the prefix. */
if ((n = bits % 8) != 0) {
goto emsgsize;
name += m;
}
/* Format the whole bytes within the prefix. */
for (n = bits / 8; n > 0; n--) {
goto emsgsize;
name += m;
}
/* Add the static text. */
goto emsgsize;
return (0);
return (-1);
}
static void
normalize_name(char *name) {
char *t;
/* Make lower case. */
for (t = name; *t; t++)
*t = tolower(*t);
/* Remove trailing dots. */
*--t = '\0';
}
static int
return (-1);
return (-1);
return (0);
}