In preparation for the BIND 9.6.1rc1 import, remove this directory.

The libbind library is no longer distributed as part of the main
BIND package, and we never built it in any case.
This commit is contained in:
Doug Barton 2009-05-30 23:50:12 +00:00
parent de7e1db19d
commit 9097ac2a7f
209 changed files with 0 additions and 59367 deletions

View File

@ -1,133 +0,0 @@
# Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2001-2003 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 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: Makefile.in,v 1.22.18.7 2006/06/24 00:25:39 marka Exp $
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
@LIBBIND_API@
LIBS = @LIBS@
DAEMON_OBJS=bsd/daemon.@O@
STRSEP_OBJS=bsd/strsep.@O@
BSDOBJS= @DAEMON_OBJS@ @STRSEP_OBJS@ bsd/ftruncate.@O@ bsd/gettimeofday.@O@ \
bsd/mktemp.@O@ bsd/putenv.@O@ bsd/readv.@O@ bsd/setenv.@O@ \
bsd/setitimer.@O@ bsd/strcasecmp.@O@ bsd/strdup.@O@ \
bsd/strerror.@O@ bsd/strpbrk.@O@ bsd/strtoul.@O@ bsd/utimes.@O@ \
bsd/writev.@O@
DSTOBJS= dst/dst_api.@O@ dst/hmac_link.@O@ dst/md5_dgst.@O@ dst/support.@O@
INETOBJS= inet/inet_addr.@O@ inet/inet_cidr_ntop.@O@ inet/inet_cidr_pton.@O@ \
inet/inet_data.@O@ inet/inet_lnaof.@O@ inet/inet_makeaddr.@O@ \
inet/inet_net_ntop.@O@ inet/inet_net_pton.@O@ inet/inet_neta.@O@ \
inet/inet_netof.@O@ inet/inet_network.@O@ inet/inet_ntoa.@O@ \
inet/inet_ntop.@O@ inet/inet_pton.@O@ inet/nsap_addr.@O@
WANT_IRS_THREADS_OBJS= irs/gethostent_r.@O@ irs/getnetent_r.@O@ \
irs/getnetgrent_r.@O@ irs/getprotoent_r.@O@ irs/getservent_r.@O@
WANT_IRS_NISGR_OBJS= irs/nis_gr.@O@
WANT_IRS_GR_OBJS= irs/dns_gr.@O@ irs/irp_gr.@O@ irs/lcl_gr.@O@ irs/gen_gr.@O@ \
irs/getgrent.@O@ @WANT_IRS_NISGR_OBJS@ @WANT_IRS_THREADSGR_OBJS@
WANT_IRS_THREADSPW_OBJS=irs/getpwent_r.@O@
WANT_IRS_NISPW_OBJS= irs/nis_pw.@O@
WANT_IRS_DBPW_OBJS=irs/irp_pw.@O@ irs/lcl_pw.@O@
WANT_IRS_PW_OBJS= irs/dns_pw.@O@ irs/gen_pw.@O@ irs/getpwent.@O@ \
@WANT_IRS_DBPW_OBJS@ @WANT_IRS_NISPW_OBJS@ @WANT_IRS_THREADSPW_OBJS@
WANT_IRS_NIS_OBJS= irs/nis_ho.@O@ irs/nis_ng.@O@ irs/nis_nw.@O@ \
irs/nis_pr.@O@ irs/nis_sv.@O@
IRSOBJS= @WANT_IRS_GR_OBJS@ @WANT_IRS_NIS_OBJS@ @WANT_IRS_THREADS_OBJS@ \
@WANT_IRS_PW_OBJS@ \
irs/dns.@O@ irs/dns_ho.@O@ irs/dns_nw.@O@ irs/dns_pr.@O@ \
irs/dns_sv.@O@ irs/gai_strerror.@O@ irs/gen.@O@ irs/gen_ho.@O@ \
irs/gen_ng.@O@ irs/gen_nw.@O@ irs/gen_pr.@O@ irs/gen_sv.@O@ \
irs/getaddrinfo.@O@ irs/gethostent.@O@ irs/getnameinfo.@O@ \
irs/getnetent.@O@ irs/getnetgrent.@O@ \
irs/getprotoent.@O@ irs/getservent.@O@ irs/hesiod.@O@ \
irs/irp.@O@ irs/irp_ho.@O@ irs/irp_ng.@O@ irs/irp_nw.@O@ \
irs/irp_pr.@O@ irs/irp_sv.@O@ irs/irpmarshall.@O@ irs/irs_data.@O@ \
irs/lcl.@O@ irs/lcl_ho.@O@ irs/lcl_ng.@O@ irs/lcl_nw.@O@ \
irs/lcl_pr.@O@ irs/lcl_sv.@O@ irs/nis.@O@ irs/nul_ng.@O@ irs/util.@O@
WANT_IRS_THREADSGR_OBJS=irs/getgrent_r.@O@
ISCOBJS= isc/assertions.@O@ isc/base64.@O@ isc/bitncmp.@O@ isc/ctl_clnt.@O@ \
isc/ctl_p.@O@ isc/ctl_srvr.@O@ isc/ev_connects.@O@ isc/ev_files.@O@ \
isc/ev_streams.@O@ isc/ev_timers.@O@ isc/ev_waits.@O@ \
isc/eventlib.@O@ isc/heap.@O@ isc/hex.@O@ isc/logging.@O@ \
isc/memcluster.@O@ isc/movefile.@O@ isc/tree.@O@
NAMESEROBJS= nameser/ns_date.@O@ nameser/ns_name.@O@ nameser/ns_netint.@O@ \
nameser/ns_parse.@O@ nameser/ns_print.@O@ nameser/ns_samedomain.@O@ \
nameser/ns_sign.@O@ nameser/ns_ttl.@O@ nameser/ns_verify.@O@
RESOLVOBJS= resolv/herror.@O@ resolv/mtctxres.@O@ resolv/res_comp.@O@ \
resolv/res_data.@O@ resolv/res_debug.@O@ resolv/res_findzonecut.@O@ \
resolv/res_init.@O@ resolv/res_mkquery.@O@ resolv/res_mkupdate.@O@ \
resolv/res_query.@O@ resolv/res_send.@O@ resolv/res_sendsigned.@O@ \
resolv/res_update.@O@
SUBDIRS = bsd dst include inet irs isc nameser resolv @PORT_INCLUDE@
TARGETS= timestamp
OBJS= ${BSDOBJS} ${DSTOBJS} ${INETOBJS} ${IRSOBJS} ${ISCOBJS} \
${NAMESEROBJS} ${RESOLVOBJS}
@BIND9_MAKE_RULES@
# Attempt to disable parallel processing.
.NOTPARALLEL:
.NO_PARALLEL:
libbind.@SA@: ${OBJS}
${AR} ${ARFLAGS} $@ ${OBJS}
${RANLIB} $@
libbind.la: ${OBJS}
${LIBTOOL_MODE_LINK} \
${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libbind.la -rpath ${libdir} \
-version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \
${OBJS} ${LIBS}
timestamp: libbind.@A@
touch timestamp
installdirs:
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${libdir}
install:: timestamp installdirs
${LIBTOOL_MODE_INSTALL} ${INSTALL_DATA} libbind.@A@ ${DESTDIR}${libdir}
clean distclean::
rm -f libbind.@SA@ libbind.la
distclean::
rm -f make/rules make/includes make/mkdep
distclean::
rm -f config.cache config.h config.log config.status libtool
rm -f port_before.h port_after.h configure.lineno
rm -f port/Makefile @PORT_DIR@/Makefile
man:

View File

@ -1,4 +0,0 @@
--with-irs-gr=yes #define WANT_IRS_GR
--with-irs-nis=yes #define WANT_IRS_NIS
--with-irs-pw=yes #define WANT_IRS_PW

2
lib/bind/aclocal.m4 vendored
View File

@ -1,2 +0,0 @@
sinclude(../../libtool.m4)dnl

View File

@ -1,3 +0,0 @@
LIBINTERFACE = 5
LIBREVISION = 2
LIBAGE = 1

View File

@ -1,39 +0,0 @@
# Copyright (C) 2004, 2008 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2001 Internet Software Consortium.
#
# Permission to use, copy, modify, and/or 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 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: Makefile.in,v 1.7.18.2 2008/03/20 23:46:01 tbox Exp $
srcdir= @srcdir@
VPATH = @srcdir@
DAEMON_OBJS=daemon.@O@
STRSEP_OBJS=strsep.@O@
OBJS= @DAEMON_OBJS@ @STRSEP_OBJS@ ftruncate.@O@ gettimeofday.@O@ \
mktemp.@O@ putenv.@O@ \
readv.@O@ setenv.@O@ setitimer.@O@ strcasecmp.@O@ strdup.@O@ \
strerror.@O@ strpbrk.@O@ strtoul.@O@ utimes.@O@ \
writev.@O@
SRCS= daemon.c ftruncate.c gettimeofday.c mktemp.c putenv.c \
readv.c setenv.c setitimer.c strcasecmp.c strdup.c \
strerror.c strpbrk.c strsep.c strtoul.c utimes.c \
writev.c
TARGETS= ${OBJS}
CINCLUDES= -I.. -I../include -I${srcdir}/../include
@BIND9_MAKE_RULES@

View File

@ -1,81 +0,0 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)daemon.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: daemon.c,v 1.1.352.1 2005/04/27 05:00:42 sra Exp $";
#endif /* LIBC_SCCS and not lint */
/*
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "port_before.h"
#include <fcntl.h>
#include <paths.h>
#include <unistd.h>
#include "port_after.h"
#ifndef NEED_DAEMON
int __bind_daemon__;
#else
int
daemon(int nochdir, int noclose) {
int fd;
switch (fork()) {
case -1:
return (-1);
case 0:
break;
default:
_exit(0);
}
if (setsid() == -1)
return (-1);
if (!nochdir)
(void)chdir("/");
if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
(void)dup2(fd, STDIN_FILENO);
(void)dup2(fd, STDOUT_FILENO);
(void)dup2(fd, STDERR_FILENO);
if (fd > 2)
(void)close (fd);
}
return (0);
}
#endif
/*! \file */

View File

@ -1,64 +0,0 @@
#ifndef LINT
static const char rcsid[] = "$Id: ftruncate.c,v 1.1.352.3 2005/06/22 22:05:45 marka Exp $";
#endif
/*! \file
* \brief
* ftruncate - set file size, BSD Style
*
* shortens or enlarges the file as neeeded
* uses some undocumented locking call. It is known to work on SCO unix,
* other vendors should try.
* The #error directive prevents unsupported OSes
*/
#include "port_before.h"
#if defined(M_UNIX)
#define OWN_FTRUNCATE
#include <stdio.h>
#ifdef _XOPEN_SOURCE
#undef _XOPEN_SOURCE
#endif
#ifdef _POSIX_SOURCE
#undef _POSIX_SOURCE
#endif
#include <fcntl.h>
#include "port_after.h"
int
__ftruncate(int fd, long wantsize) {
long cursize;
/* determine current file size */
if ((cursize = lseek(fd, 0L, 2)) == -1)
return (-1);
/* maybe lengthen... */
if (cursize < wantsize) {
if (lseek(fd, wantsize - 1, 0) == -1 ||
write(fd, "", 1) == -1) {
return (-1);
}
return (0);
}
/* maybe shorten... */
if (wantsize < cursize) {
struct flock fl;
fl.l_whence = 0;
fl.l_len = 0;
fl.l_start = wantsize;
fl.l_type = F_WRLCK;
return (fcntl(fd, F_FREESP, &fl));
}
return (0);
}
#endif
#ifndef OWN_FTRUNCATE
int __bindcompat_ftruncate;
#endif

View File

@ -1,64 +0,0 @@
#ifndef LINT
static const char rcsid[] = "$Id: gettimeofday.c,v 1.3.332.1 2005/04/27 05:00:43 sra Exp $";
#endif
#include "port_before.h"
#include <stdio.h>
#include <syslog.h>
#include <sys/time.h>
#include "port_after.h"
#if !defined(NEED_GETTIMEOFDAY)
/*%
* gettimeofday() occasionally returns invalid tv_usec on some platforms.
*/
#define MILLION 1000000
#undef gettimeofday
int
isc__gettimeofday(struct timeval *tp, struct timezone *tzp) {
int res;
res = gettimeofday(tp, tzp);
if (res < 0)
return (res);
if (tp == NULL)
return (res);
if (tp->tv_usec < 0) {
do {
tp->tv_usec += MILLION;
tp->tv_sec--;
} while (tp->tv_usec < 0);
goto log;
} else if (tp->tv_usec > MILLION) {
do {
tp->tv_usec -= MILLION;
tp->tv_sec++;
} while (tp->tv_usec > MILLION);
goto log;
}
return (res);
log:
syslog(LOG_ERR, "gettimeofday: tv_usec out of range\n");
return (res);
}
#else
int
gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp) {
time_t clock, time(time_t *);
if (time(&clock) == (time_t) -1)
return (-1);
if (tvp) {
tvp->tv_sec = clock;
tvp->tv_usec = 0;
}
if (tzp) {
tzp->tz_minuteswest = 0;
tzp->tz_dsttime = 0;
}
return (0);
}
#endif /*NEED_GETTIMEOFDAY*/
/*! \file */

View File

@ -1,156 +0,0 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: mktemp.c,v 1.1.352.1 2005/04/27 05:00:43 sra Exp $";
#endif /* LIBC_SCCS and not lint */
/*
* Copyright (c) 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
* 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, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
* CORPORATION 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 "port_before.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include "port_after.h"
#if (!defined(NEED_MKTEMP)) && (!defined(NEED_MKSTEMP))
int __mktemp_unneeded__;
#else
static int gettemp(char *path, int *doopen);
#ifdef NEED_MKSTEMP
mkstemp(char *path) {
int fd;
return (gettemp(path, &fd) ? fd : -1);
}
#endif
#ifdef NEED_MKTEMP
char *
mktemp(char *path) {
return(gettemp(path, (int *)NULL) ? path : (char *)NULL);
}
#endif
static int
gettemp(char *path, int *doopen) {
char *start, *trv;
struct stat sbuf;
u_int pid;
pid = getpid();
for (trv = path; *trv; ++trv); /*%< extra X's get set to 0's */
while (*--trv == 'X') {
*trv = (pid % 10) + '0';
pid /= 10;
}
/*
* check the target directory; if you have six X's and it
* doesn't exist this runs for a *very* long time.
*/
for (start = trv + 1;; --trv) {
if (trv <= path)
break;
if (*trv == '/') {
*trv = '\0';
if (stat(path, &sbuf))
return(0);
if (!S_ISDIR(sbuf.st_mode)) {
errno = ENOTDIR;
return(0);
}
*trv = '/';
break;
}
}
for (;;) {
if (doopen) {
if ((*doopen =
open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0)
return(1);
if (errno != EEXIST)
return(0);
}
else if (stat(path, &sbuf))
return(errno == ENOENT ? 1 : 0);
/* tricky little algorithm for backward compatibility */
for (trv = start;;) {
if (!*trv)
return(0);
if (*trv == 'z')
*trv++ = 'a';
else {
if (isdigit(*trv))
*trv = 'a';
else
++*trv;
break;
}
}
}
/*NOTREACHED*/
}
#endif /*NEED_MKTEMP*/
/*! \file */

View File

@ -1,27 +0,0 @@
#ifndef LINT
static const char rcsid[] = "$Id: putenv.c,v 1.1.352.1 2005/04/27 05:00:43 sra Exp $";
#endif
#include "port_before.h"
#include "port_after.h"
/*%
* To give a little credit to Sun, SGI,
* and many vendors in the SysV world.
*/
#if !defined(NEED_PUTENV)
int __bindcompat_putenv;
#else
int
putenv(char *str) {
char *tmp;
for (tmp = str; *tmp && (*tmp != '='); tmp++)
;
return (setenv(str, tmp, 1));
}
#endif
/*! \file */

View File

@ -1,39 +0,0 @@
#ifndef LINT
static const char rcsid[] = "$Id: readv.c,v 1.1.352.1 2005/04/27 05:00:43 sra Exp $";
#endif
#include "port_before.h"
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include "port_after.h"
#ifndef NEED_READV
int __bindcompat_readv;
#else
int
__readv(fd, vp, vpcount)
int fd;
const struct iovec *vp;
int vpcount;
{
int count = 0;
while (vpcount-- > 0) {
int bytes = read(fd, vp->iov_base, vp->iov_len);
if (bytes < 0)
return (-1);
count += bytes;
if (bytes != vp->iov_len)
break;
vp++;
}
return (count);
}
#endif /* NEED_READV */
/*! \file */

View File

@ -1,151 +0,0 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)setenv.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: setenv.c,v 1.1.352.1 2005/04/27 05:00:44 sra Exp $";
#endif /* LIBC_SCCS and not lint */
/*
* Copyright (c) 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "port_before.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "port_after.h"
#if !defined(NEED_SETENV)
int __bindcompat_setenv;
#else
extern char **environ;
static char *findenv(const char *name, int *offset);
/*%
* setenv --
* Set the value of the environmental variable "name" to be
* "value". If rewrite is set, replace any current value.
*/
setenv(const char *name, const char *value, int rewrite) {
extern char **environ;
static int alloced; /*%< if allocated space before */
char *c;
int l_value, offset;
if (*value == '=') /*%< no `=' in value */
++value;
l_value = strlen(value);
if ((c = findenv(name, &offset))) { /*%< find if already exists */
if (!rewrite)
return (0);
if (strlen(c) >= l_value) { /*%< old larger; copy over */
while (*c++ = *value++);
return (0);
}
} else { /*%< create new slot */
int cnt;
char **p;
for (p = environ, cnt = 0; *p; ++p, ++cnt);
if (alloced) { /*%< just increase size */
environ = (char **)realloc((char *)environ,
(size_t)(sizeof(char *) * (cnt + 2)));
if (!environ)
return (-1);
}
else { /*%< get new space */
alloced = 1; /*%< copy old entries into it */
p = malloc((size_t)(sizeof(char *) * (cnt + 2)));
if (!p)
return (-1);
memcpy(p, environ, cnt * sizeof(char *));
environ = p;
}
environ[cnt + 1] = NULL;
offset = cnt;
}
for (c = (char *)name; *c && *c != '='; ++c); /*%< no `=' in name */
if (!(environ[offset] = /*%< name + `=' + value */
malloc((size_t)((int)(c - name) + l_value + 2))))
return (-1);
for (c = environ[offset]; (*c = *name++) && *c != '='; ++c);
for (*c++ = '='; *c++ = *value++;);
return (0);
}
/*%
* unsetenv(name) --
* Delete environmental variable "name".
*/
void
unsetenv(const char *name) {
char **p;
int offset;
while (findenv(name, &offset)) /*%< if set multiple times */
for (p = &environ[offset];; ++p)
if (!(*p = *(p + 1)))
break;
}
/*%
* findenv --
* Returns pointer to value associated with name, if any, else NULL.
* Sets offset to be the offset of the name/value combination in the
* environmental array, for use by setenv(3) and unsetenv(3).
* Explicitly removes '=' in argument name.
*
* This routine *should* be a static; don't use it.
*/
static char *
findenv(const char *name, int *offset) {
const char *np;
char **p, *c;
int len;
if (name == NULL || environ == NULL)
return (NULL);
for (np = name; *np && *np != '='; ++np)
continue;
len = np - name;
for (p = environ; (c = *p) != NULL; ++p)
if (strncmp(c, name, len) == 0 && c[len] == '=') {
*offset = p - environ;
return (c + len + 1);
}
return (NULL);
}
#endif
/*! \file */

View File

@ -1,29 +0,0 @@
#ifndef LINT
static const char rcsid[] = "$Id: setitimer.c,v 1.1.352.1 2005/04/27 05:00:44 sra Exp $";
#endif
#include "port_before.h"
#include <sys/time.h>
#include "port_after.h"
/*%
* Setitimer emulation routine.
*/
#ifndef NEED_SETITIMER
int __bindcompat_setitimer;
#else
int
__setitimer(int which, const struct itimerval *value,
struct itimerval *ovalue)
{
if (alarm(value->it_value.tv_sec) >= 0)
return (0);
else
return (-1);
}
#endif
/*! \file */

View File

@ -1,124 +0,0 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)strcasecmp.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: strcasecmp.c,v 1.1.352.1 2005/04/27 05:00:45 sra Exp $";
#endif /* LIBC_SCCS and not lint */
/*
* Copyright (c) 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "port_before.h"
#include <sys/param.h>
#include <sys/types.h>
#include <sys/cdefs.h>
#include <string.h>
#include "port_after.h"
#ifndef NEED_STRCASECMP
int __strcasecmp_unneeded__;
#else
/*%
* This array is designed for mapping upper and lower case letter
* together for a case independent comparison. The mappings are
* based upon ascii character sequences.
*/
static const u_char charmap[] = {
0000, 0001, 0002, 0003, 0004, 0005, 0006, 0007,
0010, 0011, 0012, 0013, 0014, 0015, 0016, 0017,
0020, 0021, 0022, 0023, 0024, 0025, 0026, 0027,
0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037,
0040, 0041, 0042, 0043, 0044, 0045, 0046, 0047,
0050, 0051, 0052, 0053, 0054, 0055, 0056, 0057,
0060, 0061, 0062, 0063, 0064, 0065, 0066, 0067,
0070, 0071, 0072, 0073, 0074, 0075, 0076, 0077,
0100, 0141, 0142, 0143, 0144, 0145, 0146, 0147,
0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157,
0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167,
0170, 0171, 0172, 0133, 0134, 0135, 0136, 0137,
0140, 0141, 0142, 0143, 0144, 0145, 0146, 0147,
0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157,
0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167,
0170, 0171, 0172, 0173, 0174, 0175, 0176, 0177,
0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207,
0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217,
0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227,
0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237,
0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247,
0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257,
0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267,
0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277,
0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307,
0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317,
0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327,
0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337,
0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347,
0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357,
0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367,
0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377
};
int
strcasecmp(const char *s1, const char *s2) {
const u_char *cm = charmap,
*us1 = (const u_char *)s1,
*us2 = (const u_char *)s2;
while (cm[*us1] == cm[*us2++])
if (*us1++ == '\0')
return (0);
return (cm[*us1] - cm[*--us2]);
}
int
strncasecmp(const char *s1, const char *s2, size_t n) {
if (n != 0) {
const u_char *cm = charmap,
*us1 = (const u_char *)s1,
*us2 = (const u_char *)s2;
do {
if (cm[*us1] != cm[*us2++])
return (cm[*us1] - cm[*--us2]);
if (*us1++ == '\0')
break;
} while (--n != 0);
}
return (0);
}
#endif /*NEED_STRCASECMP*/
/*! \file */

View File

@ -1,20 +0,0 @@
#include "port_before.h"
#include <stdlib.h>
#include "port_after.h"
#ifndef NEED_STRDUP
int __bind_strdup_unneeded;
#else
char *
strdup(const char *src) {
char *dst = malloc(strlen(src) + 1);
if (dst)
strcpy(dst, src);
return (dst);
}
#endif
/*! \file */

View File

@ -1,94 +0,0 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)strerror.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: strerror.c,v 1.4.332.2 2008/02/18 04:04:06 marka Exp $";
#endif /* LIBC_SCCS and not lint */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "port_before.h"
#include <sys/param.h>
#include <sys/types.h>
#include <string.h>
#include "port_after.h"
#ifndef NEED_STRERROR
int __strerror_unneeded__;
#else
#ifdef USE_SYSERROR_LIST
extern int sys_nerr;
extern char *sys_errlist[];
#endif
const char *
isc_strerror(int num) {
#define UPREFIX "Unknown error: "
static char ebuf[40] = UPREFIX; /*%< 64-bit number + slop */
u_int errnum;
char *p, *t;
#ifndef USE_SYSERROR_LIST
const char *ret;
#endif
char tmp[40];
errnum = num; /*%< convert to unsigned */
#ifdef USE_SYSERROR_LIST
if (errnum < (u_int)sys_nerr)
return (sys_errlist[errnum]);
#else
#undef strerror
ret = strerror(num); /*%< call strerror() in libc */
if (ret != NULL)
return(ret);
#endif
/* Do this by hand, so we don't include stdio(3). */
t = tmp;
do {
*t++ = "0123456789"[errnum % 10];
} while (errnum /= 10);
for (p = ebuf + sizeof(UPREFIX) - 1;;) {
*p++ = *--t;
if (t <= tmp)
break;
}
return (ebuf);
}
#endif /*NEED_STRERROR*/
/*! \file */

View File

@ -1,70 +0,0 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)strpbrk.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: strpbrk.c,v 1.1.352.1 2005/04/27 05:00:46 sra Exp $";
#endif /* LIBC_SCCS and not lint */
/*
* Copyright (c) 1985, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "port_before.h"
#include <sys/param.h>
#include <sys/cdefs.h>
#include <string.h>
#include "port_after.h"
#ifndef NEED_STRPBRK
int __strpbrk_unneeded__;
#else
/*%
* Find the first occurrence in s1 of a character in s2 (excluding NUL).
*/
char *
strpbrk(const char *s1, const char *s2) {
const char *scanp;
int c, sc;
while ((c = *s1++) != 0) {
for (scanp = s2; (sc = *scanp++) != 0;)
if (sc == c)
return ((char *)(s1 - 1));
}
return (NULL);
}
#endif /*NEED_STRPBRK*/
/*! \file */

View File

@ -1,88 +0,0 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "strsep.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: strsep.c,v 1.1.352.1 2005/04/27 05:00:47 sra Exp $";
#endif /* LIBC_SCCS and not lint */
/*
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "port_before.h"
#include <sys/cdefs.h>
#include <string.h>
#include <stdio.h>
#include "port_after.h"
#ifndef NEED_STRSEP
int __strsep_unneeded__;
#else
/*%
* Get next token from string *stringp, where tokens are possibly-empty
* strings separated by characters from delim.
*
* Writes NULs into the string at *stringp to end tokens.
* delim need not remain constant from call to call.
* On return, *stringp points past the last NUL written (if there might
* be further tokens), or is NULL (if there are definitely no more tokens).
*
* If *stringp is NULL, strsep returns NULL.
*/
char *
strsep(char **stringp, const char *delim) {
char *s;
const char *spanp;
int c, sc;
char *tok;
if ((s = *stringp) == NULL)
return (NULL);
for (tok = s;;) {
c = *s++;
spanp = delim;
do {
if ((sc = *spanp++) == c) {
if (c == 0)
s = NULL;
else
s[-1] = 0;
*stringp = s;
return (tok);
}
} while (sc != 0);
}
/* NOTREACHED */
}
#endif /*NEED_STRSEP*/
/*! \file */

View File

@ -1,119 +0,0 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)strtoul.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: strtoul.c,v 1.2.164.2 2008/02/18 04:04:06 marka Exp $";
#endif /* LIBC_SCCS and not lint */
/*
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "port_before.h"
#include <sys/types.h>
#include <sys/param.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include "port_after.h"
#ifndef NEED_STRTOUL
int __strtoul_unneeded__;
#else
/*%
* Convert a string to an unsigned long integer.
*
* Ignores `locale' stuff. Assumes that the upper and lower case
* alphabets and digits are each contiguous.
*/
u_long
strtoul(const char *nptr, char **endptr, int base) {
const char *s = nptr;
u_long acc, cutoff;
int neg, c, any, cutlim;
neg = 0;
/*
* See strtol for comments as to the logic used.
*/
do {
c = *(const unsigned char *)s++;
} while (isspace(c));
if (c == '-') {
neg = 1;
c = *s++;
} else if (c == '+')
c = *s++;
if ((base == 0 || base == 16) &&
c == '0' && (*s == 'x' || *s == 'X')) {
c = s[1];
s += 2;
base = 16;
}
if (base == 0)
base = c == '0' ? 8 : 10;
cutoff = (u_long)ULONG_MAX / (u_long)base;
cutlim = (u_long)ULONG_MAX % (u_long)base;
for (acc = 0, any = 0;; c = *(const unsigned char*)s++) {
if (isdigit(c))
c -= '0';
else if (isalpha(c))
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
else
break;
if (c >= base)
break;
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
any = -1;
else {
any = 1;
acc *= base;
acc += c;
}
}
if (any < 0) {
acc = ULONG_MAX;
errno = ERANGE;
} else if (neg)
acc = -acc;
if (endptr != 0)
DE_CONST((any ? s - 1 : nptr), *endptr);
return (acc);
}
#endif /*NEED_STRTOUL*/
/*! \file */

View File

@ -1,40 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1997,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 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.
*/
#include "port_before.h"
#include <sys/types.h>
#include <sys/time.h>
#include <utime.h>
#include "port_after.h"
#ifndef NEED_UTIMES
int __bind_utimes_unneeded;
#else
int
__utimes(char *filename, struct timeval *tvp) {
struct utimbuf utb;
utb.actime = (time_t)tvp[0].tv_sec;
utb.modtime = (time_t)tvp[1].tv_sec;
return (utime(filename, &utb));
}
#endif /* NEED_UTIMES */
/*! \file */

View File

@ -1,89 +0,0 @@
#ifndef LINT
static const char rcsid[] = "$Id: writev.c,v 1.2.164.1 2005/04/27 05:00:47 sra Exp $";
#endif
#include "port_before.h"
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include "port_after.h"
#ifndef NEED_WRITEV
int __bindcompat_writev;
#else
#ifdef _CRAY
#define OWN_WRITEV
int
__writev(int fd, struct iovec *iov, int iovlen)
{
struct stat statbuf;
if (fstat(fd, &statbuf) < 0)
return (-1);
/*
* Allow for atomic writes to network.
*/
if (statbuf.st_mode & S_IFSOCK) {
struct msghdr mesg;
memset(&mesg, 0, sizeof(mesg));
mesg.msg_name = 0;
mesg.msg_namelen = 0;
mesg.msg_iov = iov;
mesg.msg_iovlen = iovlen;
mesg.msg_accrights = 0;
mesg.msg_accrightslen = 0;
return (sendmsg(fd, &mesg, 0));
} else {
struct iovec *tv;
int i, rcode = 0, count = 0;
for (i = 0, tv = iov; i <= iovlen; tv++) {
rcode = write(fd, tv->iov_base, tv->iov_len);
if (rcode < 0)
break;
count += rcode;
}
if (count == 0)
return (rcode);
else
return (count);
}
}
#else /*_CRAY*/
int
__writev(fd, vp, vpcount)
int fd;
const struct iovec *vp;
int vpcount;
{
int count = 0;
while (vpcount-- > 0) {
int written = write(fd, vp->iov_base, vp->iov_len);
if (written < 0)
return (-1);
count += written;
if (written != vp->iov_len)
break;
vp++;
}
return (count);
}
#endif /*_CRAY*/
#endif /*NEED_WRITEV*/
/*! \file */

View File

@ -1,68 +0,0 @@
#undef _SOCKADDR_LEN
#undef HAVE_FCNTL_H
#undef HAVE_PATHS_H
#undef HAVE_INTTYPES_H
#undef HAVE_STROPTS_H
#undef HAVE_SYS_TIMERS_H
#undef HAVE_SYS_SELECT_H
#undef HAVE_MEMORY_H
#undef SYS_CDEFS_H
#undef _POSIX_PTHREAD_SEMANTICS
#undef POSIX_GETPWUID_R
#undef POSIX_GETPWNAM_R
#undef POSIX_GETGRGID_R
#undef POSIX_GETGRNAM_R
#undef HAVE_MEMMOVE
#undef HAVE_MEMCHR
#undef SPRINTF_CHAR
#undef VSPRINTF_CHAR
#undef USE_SYSERROR_LIST
#undef NEED_STRTOUL
#undef NEED_SUN4PROTOS
#undef REENABLE_SEND
#undef NEED_SETGROUPENT
#undef NEED_GETGROUPLIST
/* define if prototype for getgrnam_r() is required */
#undef NEED_GETGRNAM_R
#undef NEED_GETGRGID_R
#undef NEED_GETGRENT_R
#undef NEED_SETGRENT_R
#undef NEED_ENDGRENT_R
#undef NEED_INNETGR_R
#undef NEED_SETNETGRENT_R
#undef NEED_ENDNETGRENT_R
#undef NEED_GETPWNAM_R
#undef NEED_GETPWUID_R
#undef NEED_SETPWENT_R
#undef NEED_SETPASSENT_R
#undef NEED_SETPWENT_R
#undef NEED_GETPWENT_R
#undef NEED_ENDPWENT_R
#undef NEED_SETPASSENT
#undef HAS_PW_CLASS
#undef ssize_t
#undef uintptr_t
/* Shut up warnings about sputaux in stdio.h on BSD/OS pre-4.1 */
#undef SHUTUP_SPUTAUX
#ifdef SHUTUP_SPUTAUX
struct __sFILE;
extern __inline int __sputaux(int _c, struct __sFILE *_p);
#endif
#undef BROKEN_IN6ADDR_INIT_MACROS
#undef HAVE_STRLCAT
/* Shut up warnings about missing braces */
#undef SHUTUP_MUTEX_INITIALIZER
#ifdef SHUTUP_MUTEX_INITIALIZER
#define LIBBIND_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER }
#else
#define LIBBIND_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,32 +0,0 @@
# Copyright (C) 2004, 2008 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2001 Internet Software Consortium.
#
# Permission to use, copy, modify, and/or 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 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: Makefile.in,v 1.6.18.2 2008/03/20 23:46:01 tbox Exp $
srcdir= @srcdir@
VPATH = @srcdir@
OBJS= dst_api.@O@ hmac_link.@O@ md5_dgst.@O@ support.@O@
SRCS= dst_api.c hmac_link.c md5_dgst.c support.c
TARGETS= ${OBJS}
CRYPTFLAGS= -DCYLINK_DSS -DHMAC_MD5 -DUSE_MD5 -DDNSSAFE
CINCLUDES= -I.. -I../include -I${srcdir}/../include ${CRYPTINCL}
CDEFINES= ${CRYPTFLAGS}
@BIND9_MAKE_RULES@

File diff suppressed because it is too large Load Diff

View File

@ -1,155 +0,0 @@
#ifndef DST_INTERNAL_H
#define DST_INTERNAL_H
/*
* Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
*
* 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 TRUSTED INFORMATION SYSTEMS
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* TRUSTED INFORMATION SYSTEMS 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 THE SOFTWARE.
*/
#include <limits.h>
#include <sys/param.h>
#if (!defined(BSD)) || (BSD < 199306)
# include <sys/bitypes.h>
#else
# include <sys/types.h>
#endif
#ifndef PATH_MAX
# ifdef POSIX_PATH_MAX
# define PATH_MAX POSIX_PATH_MAX
# else
# define PATH_MAX 255 /*%< this is the value of POSIX_PATH_MAX */
# endif
#endif
typedef struct dst_key {
char *dk_key_name; /*%< name of the key */
int dk_key_size; /*%< this is the size of the key in bits */
int dk_proto; /*%< what protocols this key can be used for */
int dk_alg; /*%< algorithm number from key record */
u_int32_t dk_flags; /*%< and the flags of the public key */
u_int16_t dk_id; /*%< identifier of the key */
void *dk_KEY_struct; /*%< pointer to key in crypto pkg fmt */
struct dst_func *dk_func; /*%< point to cryptto pgk specific function table */
} DST_KEY;
#define HAS_DST_KEY
#include <isc/dst.h>
/*
* define what crypto systems are supported for RSA,
* BSAFE is prefered over RSAREF; only one can be set at any time
*/
#if defined(BSAFE) && defined(RSAREF)
# error "Cannot have both BSAFE and RSAREF defined"
#endif
/* Declare dst_lib specific constants */
#define KEY_FILE_FORMAT "1.2"
/* suffixes for key file names */
#define PRIVATE_KEY "private"
#define PUBLIC_KEY "key"
/* error handling */
#ifdef REPORT_ERRORS
#define EREPORT(str) printf str
#else
#define EREPORT(str) (void)0
#endif
/* use our own special macro to FRRE memory */
#ifndef SAFE_FREE
#define SAFE_FREE(a) \
do{if(a != NULL){memset(a,0, sizeof(*a)); free(a); a=NULL;}} while (0)
#define SAFE_FREE2(a,s) if (a != NULL && (long)s > 0){memset(a,0, s);free(a); a=NULL;}
#endif
typedef struct dst_func {
int (*sign)(const int mode, DST_KEY *key, void **context,
const u_int8_t *data, const int len,
u_int8_t *signature, const int sig_len);
int (*verify)(const int mode, DST_KEY *key, void **context,
const u_int8_t *data, const int len,
const u_int8_t *signature, const int sig_len);
int (*compare)(const DST_KEY *key1, const DST_KEY *key2);
int (*generate)(DST_KEY *key, int parms);
void *(*destroy)(void *key);
/* conversion functions */
int (*to_dns_key)(const DST_KEY *key, u_int8_t *out,
const int out_len);
int (*from_dns_key)(DST_KEY *key, const u_int8_t *str,
const int str_len);
int (*to_file_fmt)(const DST_KEY *key, char *out,
const int out_len);
int (*from_file_fmt)(DST_KEY *key, const char *out,
const int out_len);
} dst_func;
extern dst_func *dst_t_func[DST_MAX_ALGS];
extern const char *key_file_fmt_str;
extern const char *dst_path;
#ifndef DST_HASH_SIZE
#define DST_HASH_SIZE 20 /*%< RIPEMD160 and SHA-1 are 20 bytes MD5 is 16 */
#endif
int dst_bsafe_init(void);
int dst_rsaref_init(void);
int dst_hmac_md5_init(void);
int dst_cylink_init(void);
int dst_eay_dss_init(void);
/* from higher level support routines */
int dst_s_calculate_bits( const u_int8_t *str, const int max_bits);
int dst_s_verify_str( const char **buf, const char *str);
/* conversion between dns names and key file names */
size_t dst_s_filename_length( const char *name, const char *suffix);
int dst_s_build_filename( char *filename, const char *name,
u_int16_t id, int alg, const char *suffix,
size_t filename_length);
FILE *dst_s_fopen (const char *filename, const char *mode, int perm);
/*%
* read and write network byte order into u_int?_t
* all of these should be retired
*/
u_int16_t dst_s_get_int16( const u_int8_t *buf);
void dst_s_put_int16( u_int8_t *buf, const u_int16_t val);
u_int32_t dst_s_get_int32( const u_int8_t *buf);
void dst_s_put_int32( u_int8_t *buf, const u_int32_t val);
#ifdef DUMP
# undef DUMP
# define DUMP(a,b,c,d) dst_s_dump(a,b,c,d)
#else
# define DUMP(a,b,c,d)
#endif
void
dst_s_dump(const int mode, const u_char *data, const int size,
const char *msg);
#endif /* DST_INTERNAL_H */
/*! \file */

View File

@ -1,489 +0,0 @@
#ifdef HMAC_MD5
#ifndef LINT
static const char rcsid[] = "$Header: /proj/cvs/prod/bind9/lib/bind/dst/Attic/hmac_link.c,v 1.3.164.5 2007/09/26 04:41:47 each Exp $";
#endif
/*
* Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
*
* 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 TRUSTED INFORMATION SYSTEMS
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* TRUSTED INFORMATION SYSTEMS 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 THE SOFTWARE.
*/
/*%
* This file contains an implementation of the HMAC-MD5 algorithm.
*/
#include "port_before.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <sys/param.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include "dst_internal.h"
#ifdef USE_MD5
# ifndef HAVE_MD5
# include "md5.h"
# else
# ifdef SOLARIS2
# include <sys/md5.h>
# endif
# endif
# ifndef _MD5_H_
# define _MD5_H_ 1 /*%< make sure we do not include rsaref md5.h file */
# endif
#endif
#include "port_after.h"
#define HMAC_LEN 64
#define HMAC_IPAD 0x36
#define HMAC_OPAD 0x5c
#define MD5_LEN 16
typedef struct hmackey {
u_char hk_ipad[64], hk_opad[64];
} HMAC_Key;
/**************************************************************************
* dst_hmac_md5_sign
* Call HMAC signing functions to sign a block of data.
* There are three steps to signing, INIT (initialize structures),
* UPDATE (hash (more) data), FINAL (generate a signature). This
* routine performs one or more of these steps.
* Parameters
* mode SIG_MODE_INIT, SIG_MODE_UPDATE and/or SIG_MODE_FINAL.
* priv_key key to use for signing.
* context the context to be used in this digest
* data data to be signed.
* len length in bytes of data.
* signature location to store signature.
* sig_len size of the signature location
* returns
* N Success on SIG_MODE_FINAL = returns signature length in bytes
* 0 Success on SIG_MODE_INIT and UPDATE
* <0 Failure
*/
static int
dst_hmac_md5_sign(const int mode, DST_KEY *d_key, void **context,
const u_char *data, const int len,
u_char *signature, const int sig_len)
{
HMAC_Key *key;
int sign_len = 0;
MD5_CTX *ctx = NULL;
if (d_key == NULL || d_key->dk_KEY_struct == NULL)
return (-1);
if (mode & SIG_MODE_INIT)
ctx = (MD5_CTX *) malloc(sizeof(*ctx));
else if (context)
ctx = (MD5_CTX *) *context;
if (ctx == NULL)
return (-1);
key = (HMAC_Key *) d_key->dk_KEY_struct;
if (mode & SIG_MODE_INIT) {
MD5Init(ctx);
MD5Update(ctx, key->hk_ipad, HMAC_LEN);
}
if ((mode & SIG_MODE_UPDATE) && (data && len > 0))
MD5Update(ctx, data, len);
if (mode & SIG_MODE_FINAL) {
if (signature == NULL || sig_len < MD5_LEN)
return (SIGN_FINAL_FAILURE);
MD5Final(signature, ctx);
/* perform outer MD5 */
MD5Init(ctx);
MD5Update(ctx, key->hk_opad, HMAC_LEN);
MD5Update(ctx, signature, MD5_LEN);
MD5Final(signature, ctx);
sign_len = MD5_LEN;
SAFE_FREE(ctx);
}
else {
if (context == NULL)
return (-1);
*context = (void *) ctx;
}
return (sign_len);
}
/**************************************************************************
* dst_hmac_md5_verify()
* Calls HMAC verification routines. There are three steps to
* verification, INIT (initialize structures), UPDATE (hash (more) data),
* FINAL (generate a signature). This routine performs one or more of
* these steps.
* Parameters
* mode SIG_MODE_INIT, SIG_MODE_UPDATE and/or SIG_MODE_FINAL.
* dkey key to use for verify.
* data data signed.
* len length in bytes of data.
* signature signature.
* sig_len length in bytes of signature.
* returns
* 0 Success
* <0 Failure
*/
static int
dst_hmac_md5_verify(const int mode, DST_KEY *d_key, void **context,
const u_char *data, const int len,
const u_char *signature, const int sig_len)
{
HMAC_Key *key;
MD5_CTX *ctx = NULL;
if (d_key == NULL || d_key->dk_KEY_struct == NULL)
return (-1);
if (mode & SIG_MODE_INIT)
ctx = (MD5_CTX *) malloc(sizeof(*ctx));
else if (context)
ctx = (MD5_CTX *) *context;
if (ctx == NULL)
return (-1);
key = (HMAC_Key *) d_key->dk_KEY_struct;
if (mode & SIG_MODE_INIT) {
MD5Init(ctx);
MD5Update(ctx, key->hk_ipad, HMAC_LEN);
}
if ((mode & SIG_MODE_UPDATE) && (data && len > 0))
MD5Update(ctx, data, len);
if (mode & SIG_MODE_FINAL) {
u_char digest[MD5_LEN];
if (signature == NULL || key == NULL || sig_len != MD5_LEN)
return (VERIFY_FINAL_FAILURE);
MD5Final(digest, ctx);
/* perform outer MD5 */
MD5Init(ctx);
MD5Update(ctx, key->hk_opad, HMAC_LEN);
MD5Update(ctx, digest, MD5_LEN);
MD5Final(digest, ctx);
SAFE_FREE(ctx);
if (memcmp(digest, signature, MD5_LEN) != 0)
return (VERIFY_FINAL_FAILURE);
}
else {
if (context == NULL)
return (-1);
*context = (void *) ctx;
}
return (0);
}
/**************************************************************************
* dst_buffer_to_hmac_md5
* Converts key from raw data to an HMAC Key
* This function gets in a pointer to the data
* Parameters
* hkey the HMAC key to be filled in
* key the key in raw format
* keylen the length of the key
* Return
* 0 Success
* <0 Failure
*/
static int
dst_buffer_to_hmac_md5(DST_KEY *dkey, const u_char *key, const int keylen)
{
int i;
HMAC_Key *hkey = NULL;
MD5_CTX ctx;
int local_keylen = keylen;
u_char tk[MD5_LEN];
if (dkey == NULL || key == NULL || keylen < 0)
return (-1);
if ((hkey = (HMAC_Key *) malloc(sizeof(HMAC_Key))) == NULL)
return (-2);
memset(hkey->hk_ipad, 0, sizeof(hkey->hk_ipad));
memset(hkey->hk_opad, 0, sizeof(hkey->hk_opad));
/* if key is longer than HMAC_LEN bytes reset it to key=MD5(key) */
if (keylen > HMAC_LEN) {
MD5Init(&ctx);
MD5Update(&ctx, key, keylen);
MD5Final(tk, &ctx);
memset((void *) &ctx, 0, sizeof(ctx));
key = tk;
local_keylen = MD5_LEN;
}
/* start out by storing key in pads */
memcpy(hkey->hk_ipad, key, local_keylen);
memcpy(hkey->hk_opad, key, local_keylen);
/* XOR key with hk_ipad and opad values */
for (i = 0; i < HMAC_LEN; i++) {
hkey->hk_ipad[i] ^= HMAC_IPAD;
hkey->hk_opad[i] ^= HMAC_OPAD;
}
dkey->dk_key_size = local_keylen;
dkey->dk_KEY_struct = (void *) hkey;
return (1);
}
/**************************************************************************
* dst_hmac_md5_key_to_file_format
* Encodes an HMAC Key into the portable file format.
* Parameters
* hkey HMAC KEY structure
* buff output buffer
* buff_len size of output buffer
* Return
* 0 Failure - null input hkey
* -1 Failure - not enough space in output area
* N Success - Length of data returned in buff
*/
static int
dst_hmac_md5_key_to_file_format(const DST_KEY *dkey, char *buff,
const int buff_len)
{
char *bp;
int len, i, key_len;
u_char key[HMAC_LEN];
HMAC_Key *hkey;
if (dkey == NULL || dkey->dk_KEY_struct == NULL)
return (0);
/*
* Using snprintf() would be so much simpler here.
*/
if (buff == NULL ||
buff_len <= (int)(strlen(key_file_fmt_str) +
strlen(KEY_FILE_FORMAT) + 4))
return (-1); /*%< no OR not enough space in output area */
hkey = (HMAC_Key *) dkey->dk_KEY_struct;
memset(buff, 0, buff_len); /*%< just in case */
/* write file header */
sprintf(buff, key_file_fmt_str, KEY_FILE_FORMAT, KEY_HMAC_MD5, "HMAC");
bp = buff + strlen(buff);
memset(key, 0, HMAC_LEN);
for (i = 0; i < HMAC_LEN; i++)
key[i] = hkey->hk_ipad[i] ^ HMAC_IPAD;
for (i = HMAC_LEN - 1; i >= 0; i--)
if (key[i] != 0)
break;
key_len = i + 1;
if (buff_len - (bp - buff) < 6)
return (-1);
strcat(bp, "Key: ");
bp += strlen("Key: ");
len = b64_ntop(key, key_len, bp, buff_len - (bp - buff));
if (len < 0)
return (-1);
bp += len;
if (buff_len - (bp - buff) < 2)
return (-1);
*(bp++) = '\n';
*bp = '\0';
return (bp - buff);
}
/**************************************************************************
* dst_hmac_md5_key_from_file_format
* Converts contents of a key file into an HMAC key.
* Parameters
* hkey structure to put key into
* buff buffer containing the encoded key
* buff_len the length of the buffer
* Return
* n >= 0 Foot print of the key converted
* n < 0 Error in conversion
*/
static int
dst_hmac_md5_key_from_file_format(DST_KEY *dkey, const char *buff,
const int buff_len)
{
const char *p = buff, *eol;
u_char key[HMAC_LEN+1]; /* b64_pton needs more than 64 bytes do decode
* it should probably be fixed rather than doing
* this
*/
u_char *tmp;
int key_len, len;
if (dkey == NULL)
return (-2);
if (buff == NULL || buff_len < 0)
return (-1);
memset(key, 0, sizeof(key));
if (!dst_s_verify_str(&p, "Key: "))
return (-3);
eol = strchr(p, '\n');
if (eol == NULL)
return (-4);
len = eol - p;
tmp = malloc(len + 2);
if (tmp == NULL)
return (-5);
memcpy(tmp, p, len);
*(tmp + len) = 0x0;
key_len = b64_pton((char *)tmp, key, HMAC_LEN+1); /*%< see above */
SAFE_FREE2(tmp, len + 2);
if (dst_buffer_to_hmac_md5(dkey, key, key_len) < 0) {
return (-6);
}
return (0);
}
/*%
* dst_hmac_md5_to_dns_key()
* function to extract hmac key from DST_KEY structure
* intput:
* in_key: HMAC-MD5 key
* output:
* out_str: buffer to write ot
* out_len: size of output buffer
* returns:
* number of bytes written to output buffer
*/
static int
dst_hmac_md5_to_dns_key(const DST_KEY *in_key, u_char *out_str,
const int out_len)
{
HMAC_Key *hkey;
int i;
if (in_key == NULL || in_key->dk_KEY_struct == NULL ||
out_len <= in_key->dk_key_size || out_str == NULL)
return (-1);
hkey = (HMAC_Key *) in_key->dk_KEY_struct;
for (i = 0; i < in_key->dk_key_size; i++)
out_str[i] = hkey->hk_ipad[i] ^ HMAC_IPAD;
return (i);
}
/**************************************************************************
* dst_hmac_md5_compare_keys
* Compare two keys for equality.
* Return
* 0 The keys are equal
* NON-ZERO The keys are not equal
*/
static int
dst_hmac_md5_compare_keys(const DST_KEY *key1, const DST_KEY *key2)
{
HMAC_Key *hkey1 = (HMAC_Key *) key1->dk_KEY_struct;
HMAC_Key *hkey2 = (HMAC_Key *) key2->dk_KEY_struct;
return memcmp(hkey1->hk_ipad, hkey2->hk_ipad, HMAC_LEN);
}
/**************************************************************************
* dst_hmac_md5_free_key_structure
* Frees all (none) dynamically allocated structures in hkey
*/
static void *
dst_hmac_md5_free_key_structure(void *key)
{
HMAC_Key *hkey = key;
SAFE_FREE(hkey);
return (NULL);
}
/***************************************************************************
* dst_hmac_md5_generate_key
* Creates a HMAC key of size size with a maximum size of 63 bytes
* generating a HMAC key larger than 63 bytes makes no sense as that key
* is digested before use.
*/
static int
dst_hmac_md5_generate_key(DST_KEY *key, const int nothing)
{
(void)key;
(void)nothing;
return (-1);
}
/*%
* dst_hmac_md5_init() Function to answer set up function pointers for HMAC
* related functions
*/
int
#ifdef SUNW_LIBMD5
dst_md5_hmac_init()
#else
dst_hmac_md5_init()
#endif
{
if (dst_t_func[KEY_HMAC_MD5] != NULL)
return (1);
dst_t_func[KEY_HMAC_MD5] = malloc(sizeof(struct dst_func));
if (dst_t_func[KEY_HMAC_MD5] == NULL)
return (0);
memset(dst_t_func[KEY_HMAC_MD5], 0, sizeof(struct dst_func));
dst_t_func[KEY_HMAC_MD5]->sign = dst_hmac_md5_sign;
dst_t_func[KEY_HMAC_MD5]->verify = dst_hmac_md5_verify;
dst_t_func[KEY_HMAC_MD5]->compare = dst_hmac_md5_compare_keys;
dst_t_func[KEY_HMAC_MD5]->generate = dst_hmac_md5_generate_key;
dst_t_func[KEY_HMAC_MD5]->destroy = dst_hmac_md5_free_key_structure;
dst_t_func[KEY_HMAC_MD5]->to_dns_key = dst_hmac_md5_to_dns_key;
dst_t_func[KEY_HMAC_MD5]->from_dns_key = dst_buffer_to_hmac_md5;
dst_t_func[KEY_HMAC_MD5]->to_file_fmt = dst_hmac_md5_key_to_file_format;
dst_t_func[KEY_HMAC_MD5]->from_file_fmt = dst_hmac_md5_key_from_file_format;
return (1);
}
#else
#define dst_hmac_md5_init __dst_hmac_md5_init
int
dst_hmac_md5_init(){
return (0);
}
#endif
/*! \file */

View File

@ -1,108 +0,0 @@
/* crypto/md/md5.h */
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
#ifndef HEADER_MD5_H
#define HEADER_MD5_H
#ifndef HAVE_MD5
#ifdef __cplusplus
extern "C" {
#endif
#define MD5_CBLOCK 64
#define MD5_LBLOCK 16
#define MD5_BLOCK 16
#define MD5_LAST_BLOCK 56
#define MD5_LENGTH_BLOCK 8
#define MD5_DIGEST_LENGTH 16
typedef struct MD5state_st
{
unsigned long A,B,C,D;
unsigned long Nl,Nh;
unsigned long data[MD5_LBLOCK];
int num;
} MD5_CTX;
#ifndef NOPROTO
void MD5_Init(MD5_CTX *c);
void MD5_Update(MD5_CTX *c, const unsigned char *data, unsigned long len);
void MD5_Final(unsigned char *md, MD5_CTX *c);
unsigned char *MD5(unsigned char *d, unsigned long n, unsigned char *md);
#else
void MD5_Init();
void MD5_Update();
void MD5_Final();
unsigned char *MD5();
#endif
/* to provide backward compatabilty to RSAREF calls ogud@tis.com 1997/11/14 */
#define MD5Init(c) MD5_Init(c)
#define MD5Update(c,data, len) MD5_Update(c,data,len)
#define MD5Final(md, c) MD5_Final(md, c)
#ifdef __cplusplus
}
#endif
#endif
#else
#include <sys/md5.h>
#endif /* HAVE_MD5 */
/*! \file */

View File

@ -1,374 +0,0 @@
/* crypto/md/md5_dgst.c */
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
#ifdef USE_MD5 /*%< Added by ogud@tis.com 1998/1/26 */
#include <port_before.h>
#ifndef HAVE_MD5
#include <stdio.h>
#include "md5_locl.h"
#include <port_after.h>
const char *MD5_version="MD5 part of SSLeay 0.8.1 19-Jul-1997";
/*! \file
* \brief
* Implemented from RFC1321 The MD5 Message-Digest Algorithm
*/
#define INIT_DATA_A (unsigned long)0x67452301L
#define INIT_DATA_B (unsigned long)0xefcdab89L
#define INIT_DATA_C (unsigned long)0x98badcfeL
#define INIT_DATA_D (unsigned long)0x10325476L
#ifndef NOPROTO
static void md5_block(MD5_CTX *c, unsigned long *p);
#else
static void md5_block();
#endif
void MD5_Init(c)
MD5_CTX *c;
{
c->A=INIT_DATA_A;
c->B=INIT_DATA_B;
c->C=INIT_DATA_C;
c->D=INIT_DATA_D;
c->Nl=0;
c->Nh=0;
c->num=0;
}
void MD5_Update(c, data, len)
MD5_CTX *c;
register const unsigned char *data;
unsigned long len;
{
register ULONG *p;
int sw,sc;
ULONG l;
if (len == 0U) return;
l=(c->Nl+(len<<3))&0xffffffffL;
/* 95-05-24 eay Fixed a bug with the overflow handling, thanks to
* Wei Dai <weidai@eskimo.com> for pointing it out. */
if (l < c->Nl) /*%< overflow */
c->Nh++;
c->Nh+=(len>>29);
c->Nl=l;
if (c->num != 0)
{
p=c->data;
sw=c->num>>2;
sc=c->num&0x03;
if ((c->num+len) >= (size_t)MD5_CBLOCK)
{
l= p[sw];
p_c2l(data,l,sc);
p[sw++]=l;
for (; sw<MD5_LBLOCK; sw++)
{
c2l(data,l);
p[sw]=l;
}
len-=(MD5_CBLOCK-c->num);
md5_block(c,p);
c->num=0;
/* drop through and do the rest */
}
else
{
int ew,ec;
c->num+=(int)len;
if ((sc+len) < 4U) /*%< ugly, add char's to a word */
{
l= p[sw];
p_c2l_p(data,l,sc,len);
p[sw]=l;
}
else
{
ew=(c->num>>2);
ec=(c->num&0x03);
l= p[sw];
p_c2l(data,l,sc);
p[sw++]=l;
for (; sw < ew; sw++)
{ c2l(data,l); p[sw]=l; }
if (ec)
{
c2l_p(data,l,ec);
p[sw]=l;
}
}
return;
}
}
/* we now can process the input data in blocks of MD5_CBLOCK
* chars and save the leftovers to c->data. */
p=c->data;
while (len >= (size_t)MD5_CBLOCK)
{
#if defined(L_ENDIAN) || defined(B_ENDIAN)
memcpy(p,data,MD5_CBLOCK);
data+=MD5_CBLOCK;
#ifdef B_ENDIAN
for (sw=(MD5_LBLOCK/4); sw; sw--)
{
Endian_Reverse32(p[0]);
Endian_Reverse32(p[1]);
Endian_Reverse32(p[2]);
Endian_Reverse32(p[3]);
p+=4;
}
#endif
#else
for (sw=(MD5_LBLOCK/4); sw; sw--)
{
c2l(data,l); *(p++)=l;
c2l(data,l); *(p++)=l;
c2l(data,l); *(p++)=l;
c2l(data,l); *(p++)=l;
}
#endif
p=c->data;
md5_block(c,p);
len-=MD5_CBLOCK;
}
sc=(int)len;
c->num=sc;
if (sc)
{
sw=sc>>2; /*%< words to copy */
#ifdef L_ENDIAN
p[sw]=0;
memcpy(p,data,sc);
#else
sc&=0x03;
for ( ; sw; sw--)
{ c2l(data,l); *(p++)=l; }
c2l_p(data,l,sc);
*p=l;
#endif
}
}
static void md5_block(c, X)
MD5_CTX *c;
register ULONG *X;
{
register ULONG A,B,C,D;
A=c->A;
B=c->B;
C=c->C;
D=c->D;
/* Round 0 */
R0(A,B,C,D,X[ 0], 7,0xd76aa478L);
R0(D,A,B,C,X[ 1],12,0xe8c7b756L);
R0(C,D,A,B,X[ 2],17,0x242070dbL);
R0(B,C,D,A,X[ 3],22,0xc1bdceeeL);
R0(A,B,C,D,X[ 4], 7,0xf57c0fafL);
R0(D,A,B,C,X[ 5],12,0x4787c62aL);
R0(C,D,A,B,X[ 6],17,0xa8304613L);
R0(B,C,D,A,X[ 7],22,0xfd469501L);
R0(A,B,C,D,X[ 8], 7,0x698098d8L);
R0(D,A,B,C,X[ 9],12,0x8b44f7afL);
R0(C,D,A,B,X[10],17,0xffff5bb1L);
R0(B,C,D,A,X[11],22,0x895cd7beL);
R0(A,B,C,D,X[12], 7,0x6b901122L);
R0(D,A,B,C,X[13],12,0xfd987193L);
R0(C,D,A,B,X[14],17,0xa679438eL);
R0(B,C,D,A,X[15],22,0x49b40821L);
/* Round 1 */
R1(A,B,C,D,X[ 1], 5,0xf61e2562L);
R1(D,A,B,C,X[ 6], 9,0xc040b340L);
R1(C,D,A,B,X[11],14,0x265e5a51L);
R1(B,C,D,A,X[ 0],20,0xe9b6c7aaL);
R1(A,B,C,D,X[ 5], 5,0xd62f105dL);
R1(D,A,B,C,X[10], 9,0x02441453L);
R1(C,D,A,B,X[15],14,0xd8a1e681L);
R1(B,C,D,A,X[ 4],20,0xe7d3fbc8L);
R1(A,B,C,D,X[ 9], 5,0x21e1cde6L);
R1(D,A,B,C,X[14], 9,0xc33707d6L);
R1(C,D,A,B,X[ 3],14,0xf4d50d87L);
R1(B,C,D,A,X[ 8],20,0x455a14edL);
R1(A,B,C,D,X[13], 5,0xa9e3e905L);
R1(D,A,B,C,X[ 2], 9,0xfcefa3f8L);
R1(C,D,A,B,X[ 7],14,0x676f02d9L);
R1(B,C,D,A,X[12],20,0x8d2a4c8aL);
/* Round 2 */
R2(A,B,C,D,X[ 5], 4,0xfffa3942L);
R2(D,A,B,C,X[ 8],11,0x8771f681L);
R2(C,D,A,B,X[11],16,0x6d9d6122L);
R2(B,C,D,A,X[14],23,0xfde5380cL);
R2(A,B,C,D,X[ 1], 4,0xa4beea44L);
R2(D,A,B,C,X[ 4],11,0x4bdecfa9L);
R2(C,D,A,B,X[ 7],16,0xf6bb4b60L);
R2(B,C,D,A,X[10],23,0xbebfbc70L);
R2(A,B,C,D,X[13], 4,0x289b7ec6L);
R2(D,A,B,C,X[ 0],11,0xeaa127faL);
R2(C,D,A,B,X[ 3],16,0xd4ef3085L);
R2(B,C,D,A,X[ 6],23,0x04881d05L);
R2(A,B,C,D,X[ 9], 4,0xd9d4d039L);
R2(D,A,B,C,X[12],11,0xe6db99e5L);
R2(C,D,A,B,X[15],16,0x1fa27cf8L);
R2(B,C,D,A,X[ 2],23,0xc4ac5665L);
/* Round 3 */
R3(A,B,C,D,X[ 0], 6,0xf4292244L);
R3(D,A,B,C,X[ 7],10,0x432aff97L);
R3(C,D,A,B,X[14],15,0xab9423a7L);
R3(B,C,D,A,X[ 5],21,0xfc93a039L);
R3(A,B,C,D,X[12], 6,0x655b59c3L);
R3(D,A,B,C,X[ 3],10,0x8f0ccc92L);
R3(C,D,A,B,X[10],15,0xffeff47dL);
R3(B,C,D,A,X[ 1],21,0x85845dd1L);
R3(A,B,C,D,X[ 8], 6,0x6fa87e4fL);
R3(D,A,B,C,X[15],10,0xfe2ce6e0L);
R3(C,D,A,B,X[ 6],15,0xa3014314L);
R3(B,C,D,A,X[13],21,0x4e0811a1L);
R3(A,B,C,D,X[ 4], 6,0xf7537e82L);
R3(D,A,B,C,X[11],10,0xbd3af235L);
R3(C,D,A,B,X[ 2],15,0x2ad7d2bbL);
R3(B,C,D,A,X[ 9],21,0xeb86d391L);
c->A+=A&0xffffffffL;
c->B+=B&0xffffffffL;
c->C+=C&0xffffffffL;
c->D+=D&0xffffffffL;
}
void MD5_Final(md, c)
unsigned char *md;
MD5_CTX *c;
{
register int i,j;
register ULONG l;
register ULONG *p;
static unsigned char end[4]={0x80,0x00,0x00,0x00};
unsigned char *cp=end;
/* c->num should definitly have room for at least one more byte. */
p=c->data;
j=c->num;
i=j>>2;
/* purify often complains about the following line as an
* Uninitialized Memory Read. While this can be true, the
* following p_c2l macro will reset l when that case is true.
* This is because j&0x03 contains the number of 'valid' bytes
* already in p[i]. If and only if j&0x03 == 0, the UMR will
* occur but this is also the only time p_c2l will do
* l= *(cp++) instead of l|= *(cp++)
* Many thanks to Alex Tang <altitude@cic.net> for pickup this
* 'potential bug' */
#ifdef PURIFY
if ((j&0x03) == 0) p[i]=0;
#endif
l=p[i];
p_c2l(cp,l,j&0x03);
p[i]=l;
i++;
/* i is the next 'undefined word' */
if (c->num >= MD5_LAST_BLOCK)
{
for (; i<MD5_LBLOCK; i++)
p[i]=0;
md5_block(c,p);
i=0;
}
for (; i<(MD5_LBLOCK-2); i++)
p[i]=0;
p[MD5_LBLOCK-2]=c->Nl;
p[MD5_LBLOCK-1]=c->Nh;
md5_block(c,p);
cp=md;
l=c->A; l2c(l,cp);
l=c->B; l2c(l,cp);
l=c->C; l2c(l,cp);
l=c->D; l2c(l,cp);
/* clear stuff, md5_block may be leaving some stuff on the stack
* but I'm not worried :-) */
c->num=0;
/* memset((char *)&c,0,sizeof(c));*/
}
#ifdef undef
int printit(l)
unsigned long *l;
{
int i,ii;
for (i=0; i<2; i++)
{
for (ii=0; ii<8; ii++)
{
fprintf(stderr,"%08lx ",l[i*8+ii]);
}
fprintf(stderr,"\n");
}
}
#endif
#endif /* HAVE_MD5 */
#endif /* USE_MD5 */

View File

@ -1,193 +0,0 @@
/* crypto/md/md5_locl.h */
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
#include <stdlib.h>
#include <string.h>
#include "md5.h"
#define ULONG unsigned long
#define UCHAR unsigned char
#define UINT unsigned int
#if defined(NOCONST)
#define const
#endif
#undef c2l
#define c2l(c,l) (l = ((unsigned long)(*((c)++))) , \
l|=(((unsigned long)(*((c)++)))<< 8), \
l|=(((unsigned long)(*((c)++)))<<16), \
l|=(((unsigned long)(*((c)++)))<<24))
#undef p_c2l
#define p_c2l(c,l,n) { \
switch (n) { \
case 0: l =((unsigned long)(*((c)++))); \
case 1: l|=((unsigned long)(*((c)++)))<< 8; \
case 2: l|=((unsigned long)(*((c)++)))<<16; \
case 3: l|=((unsigned long)(*((c)++)))<<24; \
} \
}
/* NOTE the pointer is not incremented at the end of this */
#undef c2l_p
#define c2l_p(c,l,n) { \
l=0; \
(c)+=n; \
switch (n) { \
case 3: l =((unsigned long)(*(--(c))))<<16; \
case 2: l|=((unsigned long)(*(--(c))))<< 8; \
case 1: l|=((unsigned long)(*(--(c)))) ; \
} \
}
#undef p_c2l_p
#define p_c2l_p(c,l,sc,len) { \
switch (sc) \
{ \
case 0: l =((unsigned long)(*((c)++))); \
if (--len == 0U) break; \
case 1: l|=((unsigned long)(*((c)++)))<< 8; \
if (--len == 0U) break; \
case 2: l|=((unsigned long)(*((c)++)))<<16; \
} \
}
#undef l2c
#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
*((c)++)=(unsigned char)(((l)>> 8)&0xff), \
*((c)++)=(unsigned char)(((l)>>16)&0xff), \
*((c)++)=(unsigned char)(((l)>>24)&0xff))
/* NOTE - c is not incremented as per l2c */
#undef l2cn
#define l2cn(l1,l2,c,n) { \
c+=n; \
switch (n) { \
case 8: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
case 7: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
case 6: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
case 4: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
case 3: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
case 2: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
} \
}
/* A nice byte order reversal from Wei Dai <weidai@eskimo.com> */
#if defined(WIN32)
/* 5 instructions with rotate instruction, else 9 */
#define Endian_Reverse32(a) \
{ \
unsigned long l=(a); \
(a)=((ROTATE(l,8)&0x00FF00FF)|(ROTATE(l,24)&0xFF00FF00)); \
}
#else
/* 6 instructions with rotate instruction, else 8 */
#define Endian_Reverse32(a) \
{ \
unsigned long l=(a); \
l=(((l&0xFF00FF00)>>8L)|((l&0x00FF00FF)<<8L)); \
(a)=ROTATE(l,16L); \
}
#endif
/*%
#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
#define G(x,y,z) (((x) & (z)) | ((y) & (~(z))))
*/
/* As pointed out by Wei Dai <weidai@eskimo.com>, the above can be
* simplified to the code below. Wei attributes these optimisations
* to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel.
*/
#define F(x,y,z) ((((y) ^ (z)) & (x)) ^ (z))
#define G(x,y,z) ((((x) ^ (y)) & (z)) ^ (y))
#define H(x,y,z) ((x) ^ (y) ^ (z))
#define I(x,y,z) (((x) | (~(z))) ^ (y))
#undef ROTATE
#if defined(WIN32)
#define ROTATE(a,n) _lrotl(a,n)
#else
#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n))))
#endif
#define R0(a,b,c,d,k,s,t) { \
a+=((k)+(t)+F((b),(c),(d))); \
a=ROTATE(a,s); \
a+=b; };\
#define R1(a,b,c,d,k,s,t) { \
a+=((k)+(t)+G((b),(c),(d))); \
a=ROTATE(a,s); \
a+=b; };
#define R2(a,b,c,d,k,s,t) { \
a+=((k)+(t)+H((b),(c),(d))); \
a=ROTATE(a,s); \
a+=b; };
#define R3(a,b,c,d,k,s,t) { \
a+=((k)+(t)+I((b),(c),(d))); \
a=ROTATE(a,s); \
a+=b; };
/*! \file */

View File

@ -1,342 +0,0 @@
static const char rcsid[] = "$Header: /proj/cvs/prod/bind9/lib/bind/dst/Attic/support.c,v 1.3.332.3 2005/10/11 00:25:09 marka Exp $";
/*
* Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
*
* 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 TRUSTED INFORMATION SYSTEMS
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* TRUSTED INFORMATION SYSTEMS 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 THE SOFTWARE.
*/
#include "port_before.h"
#include <stdio.h>
#include <unistd.h>
#include <memory.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include "dst_internal.h"
#include "port_after.h"
/*%
* dst_s_verify_str()
* Validate that the input string(*str) is at the head of the input
* buffer(**buf). If so, move the buffer head pointer (*buf) to
* the first byte of data following the string(*str).
* Parameters
* buf Input buffer.
* str Input string.
* Return
* 0 *str is not the head of **buff
* 1 *str is the head of **buff, *buf is is advanced to
* the tail of **buf.
*/
int
dst_s_verify_str(const char **buf, const char *str)
{
int b, s;
if (*buf == NULL) /*%< error checks */
return (0);
if (str == NULL || *str == '\0')
return (1);
b = strlen(*buf); /*%< get length of strings */
s = strlen(str);
if (s > b || strncmp(*buf, str, s)) /*%< check if same */
return (0); /*%< not a match */
(*buf) += s; /*%< advance pointer */
return (1);
}
/*%
* dst_s_calculate_bits
* Given a binary number represented in a u_char[], determine
* the number of significant bits used.
* Parameters
* str An input character string containing a binary number.
* max_bits The maximum possible significant bits.
* Return
* N The number of significant bits in str.
*/
int
dst_s_calculate_bits(const u_char *str, const int max_bits)
{
const u_char *p = str;
u_char i, j = 0x80;
int bits;
for (bits = max_bits; *p == 0x00 && bits > 0; p++)
bits -= 8;
for (i = *p; (i & j) != j; j >>= 1)
bits--;
return (bits);
}
/*%
* calculates a checksum used in dst for an id.
* takes an array of bytes and a length.
* returns a 16 bit checksum.
*/
u_int16_t
dst_s_id_calc(const u_char *key, const int keysize)
{
u_int32_t ac;
const u_char *kp = key;
int size = keysize;
if (!key || (keysize <= 0))
return (0xffffU);
for (ac = 0; size > 1; size -= 2, kp += 2)
ac += ((*kp) << 8) + *(kp + 1);
if (size > 0)
ac += ((*kp) << 8);
ac += (ac >> 16) & 0xffff;
return (ac & 0xffff);
}
/*%
* dst_s_dns_key_id() Function to calculate DNSSEC footprint from KEY record
* rdata
* Input:
* dns_key_rdata: the raw data in wire format
* rdata_len: the size of the input data
* Output:
* the key footprint/id calculated from the key data
*/
u_int16_t
dst_s_dns_key_id(const u_char *dns_key_rdata, const int rdata_len)
{
if (!dns_key_rdata)
return 0;
/* compute id */
if (dns_key_rdata[3] == KEY_RSA) /*%< Algorithm RSA */
return dst_s_get_int16((const u_char *)
&dns_key_rdata[rdata_len - 3]);
else if (dns_key_rdata[3] == KEY_HMAC_MD5)
/* compatibility */
return 0;
else
/* compute a checksum on the key part of the key rr */
return dst_s_id_calc(dns_key_rdata, rdata_len);
}
/*%
* dst_s_get_int16
* This routine extracts a 16 bit integer from a two byte character
* string. The character string is assumed to be in network byte
* order and may be unaligned. The number returned is in host order.
* Parameter
* buf A two byte character string.
* Return
* The converted integer value.
*/
u_int16_t
dst_s_get_int16(const u_char *buf)
{
register u_int16_t a = 0;
a = ((u_int16_t)(buf[0] << 8)) | ((u_int16_t)(buf[1]));
return (a);
}
/*%
* dst_s_get_int32
* This routine extracts a 32 bit integer from a four byte character
* string. The character string is assumed to be in network byte
* order and may be unaligned. The number returned is in host order.
* Parameter
* buf A four byte character string.
* Return
* The converted integer value.
*/
u_int32_t
dst_s_get_int32(const u_char *buf)
{
register u_int32_t a = 0;
a = ((u_int32_t)(buf[0] << 24)) | ((u_int32_t)(buf[1] << 16)) |
((u_int32_t)(buf[2] << 8)) | ((u_int32_t)(buf[3]));
return (a);
}
/*%
* dst_s_put_int16
* Take a 16 bit integer and store the value in a two byte
* character string. The integer is assumed to be in network
* order and the string is returned in host order.
*
* Parameters
* buf Storage for a two byte character string.
* val 16 bit integer.
*/
void
dst_s_put_int16(u_int8_t *buf, const u_int16_t val)
{
buf[0] = (u_int8_t)(val >> 8);
buf[1] = (u_int8_t)(val);
}
/*%
* dst_s_put_int32
* Take a 32 bit integer and store the value in a four byte
* character string. The integer is assumed to be in network
* order and the string is returned in host order.
*
* Parameters
* buf Storage for a four byte character string.
* val 32 bit integer.
*/
void
dst_s_put_int32(u_int8_t *buf, const u_int32_t val)
{
buf[0] = (u_int8_t)(val >> 24);
buf[1] = (u_int8_t)(val >> 16);
buf[2] = (u_int8_t)(val >> 8);
buf[3] = (u_int8_t)(val);
}
/*%
* dst_s_filename_length
*
* This function returns the number of bytes needed to hold the
* filename for a key file. '/', '\' and ':' are not allowed.
* form: K&lt;keyname&gt;+&lt;alg&gt;+&lt;id&gt;.&lt;suffix&gt;
*
* Returns 0 if the filename would contain either '\', '/' or ':'
*/
size_t
dst_s_filename_length(const char *name, const char *suffix)
{
if (name == NULL)
return (0);
if (strrchr(name, '\\'))
return (0);
if (strrchr(name, '/'))
return (0);
if (strrchr(name, ':'))
return (0);
if (suffix == NULL)
return (0);
if (strrchr(suffix, '\\'))
return (0);
if (strrchr(suffix, '/'))
return (0);
if (strrchr(suffix, ':'))
return (0);
return (1 + strlen(name) + 6 + strlen(suffix));
}
/*%
* dst_s_build_filename ()
* Builds a key filename from the key name, it's id, and a
* suffix. '\', '/' and ':' are not allowed. fA filename is of the
* form: K&lt;keyname&gt;&lt;id&gt;.&lt;suffix&gt;
* form: K&lt;keyname&gt;+&lt;alg&gt;+&lt;id&gt;.&lt;suffix&gt;
*
* Returns -1 if the conversion fails:
* if the filename would be too long for space allotted
* if the filename would contain a '\', '/' or ':'
* Returns 0 on success
*/
int
dst_s_build_filename(char *filename, const char *name, u_int16_t id,
int alg, const char *suffix, size_t filename_length)
{
u_int32_t my_id;
if (filename == NULL)
return (-1);
memset(filename, 0, filename_length);
if (name == NULL)
return (-1);
if (suffix == NULL)
return (-1);
if (filename_length < 1 + strlen(name) + 4 + 6 + 1 + strlen(suffix))
return (-1);
my_id = id;
sprintf(filename, "K%s+%03d+%05d.%s", name, alg, my_id,
(const char *) suffix);
if (strrchr(filename, '/'))
return (-1);
if (strrchr(filename, '\\'))
return (-1);
if (strrchr(filename, ':'))
return (-1);
return (0);
}
/*%
* dst_s_fopen ()
* Open a file in the dst_path directory. If perm is specified, the
* file is checked for existence first, and not opened if it exists.
* Parameters
* filename File to open
* mode Mode to open the file (passed directly to fopen)
* perm File permission, if creating a new file.
* Returns
* NULL Failure
* NON-NULL (FILE *) of opened file.
*/
FILE *
dst_s_fopen(const char *filename, const char *mode, int perm)
{
FILE *fp;
char pathname[PATH_MAX];
if (strlen(filename) + strlen(dst_path) >= sizeof(pathname))
return (NULL);
if (*dst_path != '\0') {
strcpy(pathname, dst_path);
strcat(pathname, filename);
} else
strcpy(pathname, filename);
fp = fopen(pathname, mode);
if (perm)
chmod(pathname, perm);
return (fp);
}
void
dst_s_dump(const int mode, const u_char *data, const int size,
const char *msg)
{
UNUSED(data);
if (size > 0) {
#ifdef LONG_TEST
static u_char scratch[1000];
int n ;
n = b64_ntop(data, scratch, size, sizeof(scratch));
printf("%s: %x %d %s\n", msg, mode, n, scratch);
#else
printf("%s,%x %d\n", msg, mode, size);
#endif
}
}
/*! \file */

View File

@ -1,47 +0,0 @@
# Copyright (C) 2004, 2008 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2001 Internet Software Consortium.
#
# Permission to use, copy, modify, and/or 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 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: Makefile.in,v 1.4.18.2 2008/01/23 02:15:02 tbox Exp $
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
HEADERS=fd_setsize.h hesiod.h irp.h irs.h netdb.h netgroup.h res_update.h \
resolv.h
AHEADERS= arpa/inet.h arpa/nameser.h arpa/nameser_compat.h
IHEADERS= isc/assertions.h isc/ctl.h isc/dst.h isc/eventlib.h isc/heap.h \
isc/irpmarshall.h isc/list.h isc/logging.h isc/memcluster.h \
isc/misc.h isc/tree.h isc/platform.h.in
all:
@BIND9_MAKE_RULES@
installdirs:
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir} \
${DESTDIR}${includedir}/arpa ${DESTDIR}${includedir}/isc
install:: installdirs
for i in ${HEADERS}; do \
${INSTALL_DATA} ${srcdir}/$$i ${DESTDIR}${includedir}; \
done
for i in ${IHEADERS}; do \
${INSTALL_DATA} ${srcdir}/$$i ${DESTDIR}${includedir}/isc; \
done
for i in ${AHEADERS}; do \
${INSTALL_DATA} ${srcdir}/$$i ${DESTDIR}${includedir}/arpa; \
done

View File

@ -1,126 +0,0 @@
/*
* ++Copyright++ 1983, 1993
* -
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* -
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
* 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, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
* CORPORATION 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.
* -
* --Copyright--
*/
/*%
* @(#)inet.h 8.1 (Berkeley) 6/2/93
* $Id: inet.h,v 1.2.18.1 2005/04/27 05:00:50 sra Exp $
*/
#ifndef _INET_H_
#define _INET_H_
/* External definitions for functions in inet(3) */
#include <sys/param.h>
#if (!defined(BSD)) || (BSD < 199306)
# include <sys/bitypes.h>
#else
# include <sys/types.h>
#endif
#include <sys/cdefs.h>
#define inet_addr __inet_addr
#define inet_aton __inet_aton
#define inet_lnaof __inet_lnaof
#define inet_makeaddr __inet_makeaddr
#define inet_neta __inet_neta
#define inet_netof __inet_netof
#define inet_network __inet_network
#define inet_net_ntop __inet_net_ntop
#define inet_net_pton __inet_net_pton
#define inet_cidr_ntop __inet_cidr_ntop
#define inet_cidr_pton __inet_cidr_pton
#define inet_ntoa __inet_ntoa
#define inet_pton __inet_pton
#define inet_ntop __inet_ntop
#define inet_nsap_addr __inet_nsap_addr
#define inet_nsap_ntoa __inet_nsap_ntoa
__BEGIN_DECLS
unsigned long inet_addr __P((const char *));
int inet_aton __P((const char *, struct in_addr *));
unsigned long inet_lnaof __P((struct in_addr));
struct in_addr inet_makeaddr __P((u_long , u_long));
char * inet_neta __P((u_long, char *, size_t));
unsigned long inet_netof __P((struct in_addr));
unsigned long inet_network __P((const char *));
char *inet_net_ntop __P((int, const void *, int, char *, size_t));
int inet_net_pton __P((int, const char *, void *, size_t));
char *inet_cidr_ntop __P((int, const void *, int, char *, size_t));
int inet_cidr_pton __P((int, const char *, void *, int *));
/*const*/ char *inet_ntoa __P((struct in_addr));
int inet_pton __P((int, const char *, void *));
const char *inet_ntop __P((int, const void *, char *, size_t));
u_int inet_nsap_addr __P((const char *, u_char *, int));
char *inet_nsap_ntoa __P((int, const u_char *, char *));
__END_DECLS
#if defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
/*
* Macros for number representation conversion.
*
* netinet/in.h is another location for these macros
*/
#ifndef ntohl
#define ntohl(x) (x)
#define ntohs(x) (x)
#define htonl(x) (x)
#define htons(x) (x)
#endif
#endif
#endif /* !_INET_H_ */
/*! \file */

View File

@ -1,575 +0,0 @@
/*
* Copyright (c) 1983, 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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: nameser.h,v 1.7.18.2 2008/04/03 23:15:15 marka Exp $
*/
#ifndef _ARPA_NAMESER_H_
#define _ARPA_NAMESER_H_
/*! \file */
#define BIND_4_COMPAT
#include <sys/param.h>
#if (!defined(BSD)) || (BSD < 199306)
# include <sys/bitypes.h>
#else
# include <sys/types.h>
#endif
#include <sys/cdefs.h>
/*%
* Revision information. This is the release date in YYYYMMDD format.
* It can change every day so the right thing to do with it is use it
* in preprocessor commands such as "#if (__NAMESER > 19931104)". Do not
* compare for equality; rather, use it to determine whether your libbind.a
* contains a new enough lib/nameser/ to support the feature you need.
*/
#define __NAMESER 19991006 /*%< New interface version stamp. */
/*
* Define constants based on RFC0883, RFC1034, RFC 1035
*/
#define NS_PACKETSZ 512 /*%< default UDP packet size */
#define NS_MAXDNAME 1025 /*%< maximum domain name */
#define NS_MAXMSG 65535 /*%< maximum message size */
#define NS_MAXCDNAME 255 /*%< maximum compressed domain name */
#define NS_MAXLABEL 63 /*%< maximum length of domain label */
#define NS_HFIXEDSZ 12 /*%< #/bytes of fixed data in header */
#define NS_QFIXEDSZ 4 /*%< #/bytes of fixed data in query */
#define NS_RRFIXEDSZ 10 /*%< #/bytes of fixed data in r record */
#define NS_INT32SZ 4 /*%< #/bytes of data in a u_int32_t */
#define NS_INT16SZ 2 /*%< #/bytes of data in a u_int16_t */
#define NS_INT8SZ 1 /*%< #/bytes of data in a u_int8_t */
#define NS_INADDRSZ 4 /*%< IPv4 T_A */
#define NS_IN6ADDRSZ 16 /*%< IPv6 T_AAAA */
#define NS_CMPRSFLGS 0xc0 /*%< Flag bits indicating name compression. */
#define NS_DEFAULTPORT 53 /*%< For both TCP and UDP. */
/*
* These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord()
* in synch with it.
*/
typedef enum __ns_sect {
ns_s_qd = 0, /*%< Query: Question. */
ns_s_zn = 0, /*%< Update: Zone. */
ns_s_an = 1, /*%< Query: Answer. */
ns_s_pr = 1, /*%< Update: Prerequisites. */
ns_s_ns = 2, /*%< Query: Name servers. */
ns_s_ud = 2, /*%< Update: Update. */
ns_s_ar = 3, /*%< Query|Update: Additional records. */
ns_s_max = 4
} ns_sect;
/*%
* This is a message handle. It is caller allocated and has no dynamic data.
* This structure is intended to be opaque to all but ns_parse.c, thus the
* leading _'s on the member names. Use the accessor functions, not the _'s.
*/
typedef struct __ns_msg {
const u_char *_msg, *_eom;
u_int16_t _id, _flags, _counts[ns_s_max];
const u_char *_sections[ns_s_max];
ns_sect _sect;
int _rrnum;
const u_char *_msg_ptr;
} ns_msg;
/* Private data structure - do not use from outside library. */
struct _ns_flagdata { int mask, shift; };
extern struct _ns_flagdata _ns_flagdata[];
/* Accessor macros - this is part of the public interface. */
#define ns_msg_id(handle) ((handle)._id + 0)
#define ns_msg_base(handle) ((handle)._msg + 0)
#define ns_msg_end(handle) ((handle)._eom + 0)
#define ns_msg_size(handle) ((handle)._eom - (handle)._msg)
#define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
/*%
* This is a parsed record. It is caller allocated and has no dynamic data.
*/
typedef struct __ns_rr {
char name[NS_MAXDNAME];
u_int16_t type;
u_int16_t rr_class;
u_int32_t ttl;
u_int16_t rdlength;
const u_char * rdata;
} ns_rr;
/* Accessor macros - this is part of the public interface. */
#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".")
#define ns_rr_type(rr) ((ns_type)((rr).type + 0))
#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0))
#define ns_rr_ttl(rr) ((rr).ttl + 0)
#define ns_rr_rdlen(rr) ((rr).rdlength + 0)
#define ns_rr_rdata(rr) ((rr).rdata + 0)
/*%
* These don't have to be in the same order as in the packet flags word,
* and they can even overlap in some cases, but they will need to be kept
* in synch with ns_parse.c:ns_flagdata[].
*/
typedef enum __ns_flag {
ns_f_qr, /*%< Question/Response. */
ns_f_opcode, /*%< Operation code. */
ns_f_aa, /*%< Authoritative Answer. */
ns_f_tc, /*%< Truncation occurred. */
ns_f_rd, /*%< Recursion Desired. */
ns_f_ra, /*%< Recursion Available. */
ns_f_z, /*%< MBZ. */
ns_f_ad, /*%< Authentic Data (DNSSEC). */
ns_f_cd, /*%< Checking Disabled (DNSSEC). */
ns_f_rcode, /*%< Response code. */
ns_f_max
} ns_flag;
/*%
* Currently defined opcodes.
*/
typedef enum __ns_opcode {
ns_o_query = 0, /*%< Standard query. */
ns_o_iquery = 1, /*%< Inverse query (deprecated/unsupported). */
ns_o_status = 2, /*%< Name server status query (unsupported). */
/* Opcode 3 is undefined/reserved. */
ns_o_notify = 4, /*%< Zone change notification. */
ns_o_update = 5, /*%< Zone update message. */
ns_o_max = 6
} ns_opcode;
/*%
* Currently defined response codes.
*/
typedef enum __ns_rcode {
ns_r_noerror = 0, /*%< No error occurred. */
ns_r_formerr = 1, /*%< Format error. */
ns_r_servfail = 2, /*%< Server failure. */
ns_r_nxdomain = 3, /*%< Name error. */
ns_r_notimpl = 4, /*%< Unimplemented. */
ns_r_refused = 5, /*%< Operation refused. */
/* these are for BIND_UPDATE */
ns_r_yxdomain = 6, /*%< Name exists */
ns_r_yxrrset = 7, /*%< RRset exists */
ns_r_nxrrset = 8, /*%< RRset does not exist */
ns_r_notauth = 9, /*%< Not authoritative for zone */
ns_r_notzone = 10, /*%< Zone of record different from zone section */
ns_r_max = 11,
/* The following are EDNS extended rcodes */
ns_r_badvers = 16,
/* The following are TSIG errors */
ns_r_badsig = 16,
ns_r_badkey = 17,
ns_r_badtime = 18
} ns_rcode;
/* BIND_UPDATE */
typedef enum __ns_update_operation {
ns_uop_delete = 0,
ns_uop_add = 1,
ns_uop_max = 2
} ns_update_operation;
/*%
* This structure is used for TSIG authenticated messages
*/
struct ns_tsig_key {
char name[NS_MAXDNAME], alg[NS_MAXDNAME];
unsigned char *data;
int len;
};
typedef struct ns_tsig_key ns_tsig_key;
/*%
* This structure is used for TSIG authenticated TCP messages
*/
struct ns_tcp_tsig_state {
int counter;
struct dst_key *key;
void *ctx;
unsigned char sig[NS_PACKETSZ];
int siglen;
};
typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
#define NS_TSIG_FUDGE 300
#define NS_TSIG_TCP_COUNT 100
#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
#define NS_TSIG_ERROR_NO_TSIG -10
#define NS_TSIG_ERROR_NO_SPACE -11
#define NS_TSIG_ERROR_FORMERR -12
/*%
* Currently defined type values for resources and queries.
*/
typedef enum __ns_type {
ns_t_invalid = 0, /*%< Cookie. */
ns_t_a = 1, /*%< Host address. */
ns_t_ns = 2, /*%< Authoritative server. */
ns_t_md = 3, /*%< Mail destination. */
ns_t_mf = 4, /*%< Mail forwarder. */
ns_t_cname = 5, /*%< Canonical name. */
ns_t_soa = 6, /*%< Start of authority zone. */
ns_t_mb = 7, /*%< Mailbox domain name. */
ns_t_mg = 8, /*%< Mail group member. */
ns_t_mr = 9, /*%< Mail rename name. */
ns_t_null = 10, /*%< Null resource record. */
ns_t_wks = 11, /*%< Well known service. */
ns_t_ptr = 12, /*%< Domain name pointer. */
ns_t_hinfo = 13, /*%< Host information. */
ns_t_minfo = 14, /*%< Mailbox information. */
ns_t_mx = 15, /*%< Mail routing information. */
ns_t_txt = 16, /*%< Text strings. */
ns_t_rp = 17, /*%< Responsible person. */
ns_t_afsdb = 18, /*%< AFS cell database. */
ns_t_x25 = 19, /*%< X_25 calling address. */
ns_t_isdn = 20, /*%< ISDN calling address. */
ns_t_rt = 21, /*%< Router. */
ns_t_nsap = 22, /*%< NSAP address. */
ns_t_nsap_ptr = 23, /*%< Reverse NSAP lookup (deprecated). */
ns_t_sig = 24, /*%< Security signature. */
ns_t_key = 25, /*%< Security key. */
ns_t_px = 26, /*%< X.400 mail mapping. */
ns_t_gpos = 27, /*%< Geographical position (withdrawn). */
ns_t_aaaa = 28, /*%< Ip6 Address. */
ns_t_loc = 29, /*%< Location Information. */
ns_t_nxt = 30, /*%< Next domain (security). */
ns_t_eid = 31, /*%< Endpoint identifier. */
ns_t_nimloc = 32, /*%< Nimrod Locator. */
ns_t_srv = 33, /*%< Server Selection. */
ns_t_atma = 34, /*%< ATM Address */
ns_t_naptr = 35, /*%< Naming Authority PoinTeR */
ns_t_kx = 36, /*%< Key Exchange */
ns_t_cert = 37, /*%< Certification record */
ns_t_a6 = 38, /*%< IPv6 address (deprecates AAAA) */
ns_t_dname = 39, /*%< Non-terminal DNAME (for IPv6) */
ns_t_sink = 40, /*%< Kitchen sink (experimentatl) */
ns_t_opt = 41, /*%< EDNS0 option (meta-RR) */
ns_t_apl = 42, /*%< Address prefix list (RFC3123) */
ns_t_tkey = 249, /*%< Transaction key */
ns_t_tsig = 250, /*%< Transaction signature. */
ns_t_ixfr = 251, /*%< Incremental zone transfer. */
ns_t_axfr = 252, /*%< Transfer zone of authority. */
ns_t_mailb = 253, /*%< Transfer mailbox records. */
ns_t_maila = 254, /*%< Transfer mail agent records. */
ns_t_any = 255, /*%< Wildcard match. */
ns_t_zxfr = 256, /*%< BIND-specific, nonstandard. */
ns_t_max = 65536
} ns_type;
/* Exclusively a QTYPE? (not also an RTYPE) */
#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \
(t) == ns_t_mailb || (t) == ns_t_maila)
/* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */
#define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt)
/* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */
#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t))
#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr)
#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \
(t) == ns_t_zxfr)
/*%
* Values for class field
*/
typedef enum __ns_class {
ns_c_invalid = 0, /*%< Cookie. */
ns_c_in = 1, /*%< Internet. */
ns_c_2 = 2, /*%< unallocated/unsupported. */
ns_c_chaos = 3, /*%< MIT Chaos-net. */
ns_c_hs = 4, /*%< MIT Hesiod. */
/* Query class values which do not appear in resource records */
ns_c_none = 254, /*%< for prereq. sections in update requests */
ns_c_any = 255, /*%< Wildcard match. */
ns_c_max = 65536
} ns_class;
/* DNSSEC constants. */
typedef enum __ns_key_types {
ns_kt_rsa = 1, /*%< key type RSA/MD5 */
ns_kt_dh = 2, /*%< Diffie Hellman */
ns_kt_dsa = 3, /*%< Digital Signature Standard (MANDATORY) */
ns_kt_private = 254 /*%< Private key type starts with OID */
} ns_key_types;
typedef enum __ns_cert_types {
cert_t_pkix = 1, /*%< PKIX (X.509v3) */
cert_t_spki = 2, /*%< SPKI */
cert_t_pgp = 3, /*%< PGP */
cert_t_url = 253, /*%< URL private type */
cert_t_oid = 254 /*%< OID private type */
} ns_cert_types;
/* Flags field of the KEY RR rdata. */
#define NS_KEY_TYPEMASK 0xC000 /*%< Mask for "type" bits */
#define NS_KEY_TYPE_AUTH_CONF 0x0000 /*%< Key usable for both */
#define NS_KEY_TYPE_CONF_ONLY 0x8000 /*%< Key usable for confidentiality */
#define NS_KEY_TYPE_AUTH_ONLY 0x4000 /*%< Key usable for authentication */
#define NS_KEY_TYPE_NO_KEY 0xC000 /*%< No key usable for either; no key */
/* The type bits can also be interpreted independently, as single bits: */
#define NS_KEY_NO_AUTH 0x8000 /*%< Key unusable for authentication */
#define NS_KEY_NO_CONF 0x4000 /*%< Key unusable for confidentiality */
#define NS_KEY_RESERVED2 0x2000 /* Security is *mandatory* if bit=0 */
#define NS_KEY_EXTENDED_FLAGS 0x1000 /*%< reserved - must be zero */
#define NS_KEY_RESERVED4 0x0800 /*%< reserved - must be zero */
#define NS_KEY_RESERVED5 0x0400 /*%< reserved - must be zero */
#define NS_KEY_NAME_TYPE 0x0300 /*%< these bits determine the type */
#define NS_KEY_NAME_USER 0x0000 /*%< key is assoc. with user */
#define NS_KEY_NAME_ENTITY 0x0200 /*%< key is assoc. with entity eg host */
#define NS_KEY_NAME_ZONE 0x0100 /*%< key is zone key */
#define NS_KEY_NAME_RESERVED 0x0300 /*%< reserved meaning */
#define NS_KEY_RESERVED8 0x0080 /*%< reserved - must be zero */
#define NS_KEY_RESERVED9 0x0040 /*%< reserved - must be zero */
#define NS_KEY_RESERVED10 0x0020 /*%< reserved - must be zero */
#define NS_KEY_RESERVED11 0x0010 /*%< reserved - must be zero */
#define NS_KEY_SIGNATORYMASK 0x000F /*%< key can sign RR's of same name */
#define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \
NS_KEY_RESERVED4 | \
NS_KEY_RESERVED5 | \
NS_KEY_RESERVED8 | \
NS_KEY_RESERVED9 | \
NS_KEY_RESERVED10 | \
NS_KEY_RESERVED11 )
#define NS_KEY_RESERVED_BITMASK2 0xFFFF /*%< no bits defined here */
/* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */
#define NS_ALG_MD5RSA 1 /*%< MD5 with RSA */
#define NS_ALG_DH 2 /*%< Diffie Hellman KEY */
#define NS_ALG_DSA 3 /*%< DSA KEY */
#define NS_ALG_DSS NS_ALG_DSA
#define NS_ALG_EXPIRE_ONLY 253 /*%< No alg, no security */
#define NS_ALG_PRIVATE_OID 254 /*%< Key begins with OID giving alg */
/* Protocol values */
/* value 0 is reserved */
#define NS_KEY_PROT_TLS 1
#define NS_KEY_PROT_EMAIL 2
#define NS_KEY_PROT_DNSSEC 3
#define NS_KEY_PROT_IPSEC 4
#define NS_KEY_PROT_ANY 255
/* Signatures */
#define NS_MD5RSA_MIN_BITS 512 /*%< Size of a mod or exp in bits */
#define NS_MD5RSA_MAX_BITS 4096
/* Total of binary mod and exp */
#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3)
/* Max length of text sig block */
#define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4)
#define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8)
#define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8)
#define NS_DSA_SIG_SIZE 41
#define NS_DSA_MIN_SIZE 213
#define NS_DSA_MAX_BYTES 405
/* Offsets into SIG record rdata to find various values */
#define NS_SIG_TYPE 0 /*%< Type flags */
#define NS_SIG_ALG 2 /*%< Algorithm */
#define NS_SIG_LABELS 3 /*%< How many labels in name */
#define NS_SIG_OTTL 4 /*%< Original TTL */
#define NS_SIG_EXPIR 8 /*%< Expiration time */
#define NS_SIG_SIGNED 12 /*%< Signature time */
#define NS_SIG_FOOT 16 /*%< Key footprint */
#define NS_SIG_SIGNER 18 /*%< Domain name of who signed it */
/* How RR types are represented as bit-flags in NXT records */
#define NS_NXT_BITS 8
#define NS_NXT_BIT_SET( n,p) (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS)))
#define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS)))
#define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS)))
#define NS_NXT_MAX 127
/*%
* EDNS0 extended flags and option codes, host order.
*/
#define NS_OPT_DNSSEC_OK 0x8000U
#define NS_OPT_NSID 3
/*%
* Inline versions of get/put short/long. Pointer is advanced.
*/
#define NS_GET16(s, cp) do { \
register const u_char *t_cp = (const u_char *)(cp); \
(s) = ((u_int16_t)t_cp[0] << 8) \
| ((u_int16_t)t_cp[1]) \
; \
(cp) += NS_INT16SZ; \
} while (0)
#define NS_GET32(l, cp) do { \
register const u_char *t_cp = (const u_char *)(cp); \
(l) = ((u_int32_t)t_cp[0] << 24) \
| ((u_int32_t)t_cp[1] << 16) \
| ((u_int32_t)t_cp[2] << 8) \
| ((u_int32_t)t_cp[3]) \
; \
(cp) += NS_INT32SZ; \
} while (0)
#define NS_PUT16(s, cp) do { \
register u_int16_t t_s = (u_int16_t)(s); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_s >> 8; \
*t_cp = t_s; \
(cp) += NS_INT16SZ; \
} while (0)
#define NS_PUT32(l, cp) do { \
register u_int32_t t_l = (u_int32_t)(l); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_l >> 24; \
*t_cp++ = t_l >> 16; \
*t_cp++ = t_l >> 8; \
*t_cp = t_l; \
(cp) += NS_INT32SZ; \
} while (0)
/*%
* ANSI C identifier hiding for bind's lib/nameser.
*/
#define ns_msg_getflag __ns_msg_getflag
#define ns_get16 __ns_get16
#define ns_get32 __ns_get32
#define ns_put16 __ns_put16
#define ns_put32 __ns_put32
#define ns_initparse __ns_initparse
#define ns_skiprr __ns_skiprr
#define ns_parserr __ns_parserr
#define ns_sprintrr __ns_sprintrr
#define ns_sprintrrf __ns_sprintrrf
#define ns_format_ttl __ns_format_ttl
#define ns_parse_ttl __ns_parse_ttl
#define ns_datetosecs __ns_datetosecs
#define ns_name_ntol __ns_name_ntol
#define ns_name_ntop __ns_name_ntop
#define ns_name_pton __ns_name_pton
#define ns_name_unpack __ns_name_unpack
#define ns_name_pack __ns_name_pack
#define ns_name_compress __ns_name_compress
#define ns_name_uncompress __ns_name_uncompress
#define ns_name_skip __ns_name_skip
#define ns_name_rollback __ns_name_rollback
#define ns_sign __ns_sign
#define ns_sign2 __ns_sign2
#define ns_sign_tcp __ns_sign_tcp
#define ns_sign_tcp2 __ns_sign_tcp2
#define ns_sign_tcp_init __ns_sign_tcp_init
#define ns_find_tsig __ns_find_tsig
#define ns_verify __ns_verify
#define ns_verify_tcp __ns_verify_tcp
#define ns_verify_tcp_init __ns_verify_tcp_init
#define ns_samedomain __ns_samedomain
#define ns_subdomain __ns_subdomain
#define ns_makecanon __ns_makecanon
#define ns_samename __ns_samename
__BEGIN_DECLS
int ns_msg_getflag __P((ns_msg, int));
u_int ns_get16 __P((const u_char *));
u_long ns_get32 __P((const u_char *));
void ns_put16 __P((u_int, u_char *));
void ns_put32 __P((u_long, u_char *));
int ns_initparse __P((const u_char *, int, ns_msg *));
int ns_skiprr __P((const u_char *, const u_char *, ns_sect, int));
int ns_parserr __P((ns_msg *, ns_sect, int, ns_rr *));
int ns_sprintrr __P((const ns_msg *, const ns_rr *,
const char *, const char *, char *, size_t));
int ns_sprintrrf __P((const u_char *, size_t, const char *,
ns_class, ns_type, u_long, const u_char *,
size_t, const char *, const char *,
char *, size_t));
int ns_format_ttl __P((u_long, char *, size_t));
int ns_parse_ttl __P((const char *, u_long *));
u_int32_t ns_datetosecs __P((const char *cp, int *errp));
int ns_name_ntol __P((const u_char *, u_char *, size_t));
int ns_name_ntop __P((const u_char *, char *, size_t));
int ns_name_pton __P((const char *, u_char *, size_t));
int ns_name_unpack __P((const u_char *, const u_char *,
const u_char *, u_char *, size_t));
int ns_name_pack __P((const u_char *, u_char *, int,
const u_char **, const u_char **));
int ns_name_uncompress __P((const u_char *, const u_char *,
const u_char *, char *, size_t));
int ns_name_compress __P((const char *, u_char *, size_t,
const u_char **, const u_char **));
int ns_name_skip __P((const u_char **, const u_char *));
void ns_name_rollback __P((const u_char *, const u_char **,
const u_char **));
int ns_sign __P((u_char *, int *, int, int, void *,
const u_char *, int, u_char *, int *, time_t));
int ns_sign2 __P((u_char *, int *, int, int, void *,
const u_char *, int, u_char *, int *, time_t,
u_char **, u_char **));
int ns_sign_tcp __P((u_char *, int *, int, int,
ns_tcp_tsig_state *, int));
int ns_sign_tcp2 __P((u_char *, int *, int, int,
ns_tcp_tsig_state *, int,
u_char **, u_char **));
int ns_sign_tcp_init __P((void *, const u_char *, int,
ns_tcp_tsig_state *));
u_char *ns_find_tsig __P((u_char *, u_char *));
int ns_verify __P((u_char *, int *, void *,
const u_char *, int, u_char *, int *,
time_t *, int));
int ns_verify_tcp __P((u_char *, int *, ns_tcp_tsig_state *, int));
int ns_verify_tcp_init __P((void *, const u_char *, int,
ns_tcp_tsig_state *));
int ns_samedomain __P((const char *, const char *));
int ns_subdomain __P((const char *, const char *));
int ns_makecanon __P((const char *, char *, size_t));
int ns_samename __P((const char *, const char *));
__END_DECLS
#ifdef BIND_4_COMPAT
#include <arpa/nameser_compat.h>
#endif
#endif /* !_ARPA_NAMESER_H_ */
/*! \file */

View File

@ -1,232 +0,0 @@
/* Copyright (c) 1983, 1989
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*%
* from nameser.h 8.1 (Berkeley) 6/2/93
* $Id: nameser_compat.h,v 1.5.18.3 2006/05/19 02:36:00 marka Exp $
*/
#ifndef _ARPA_NAMESER_COMPAT_
#define _ARPA_NAMESER_COMPAT_
#define __BIND 19950621 /*%< (DEAD) interface version stamp. */
#ifndef BYTE_ORDER
#if (BSD >= 199103)
# include <machine/endian.h>
#else
#ifdef __linux
# include <endian.h>
#else
#define LITTLE_ENDIAN 1234 /*%< least-significant byte first (vax, pc) */
#define BIG_ENDIAN 4321 /*%< most-significant byte first (IBM, net) */
#define PDP_ENDIAN 3412 /*%< LSB first in word, MSW first in long (pdp) */
#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
defined(__i386__) || defined(__i386) || defined(__amd64__) || \
defined(__x86_64__) || defined(MIPSEL) || defined(_MIPSEL) || \
defined(BIT_ZERO_ON_RIGHT) || defined(__alpha__) || defined(__alpha) || \
(defined(__Lynx__) && defined(__x86__))
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
defined(apollo) || defined(__convex__) || defined(_CRAY) || \
defined(__hppa) || defined(__hp9000) || \
defined(__hp9000s300) || defined(__hp9000s700) || \
defined(__hp3000s900) || defined(__hpux) || defined(MPE) || \
defined (BIT_ZERO_ON_LEFT) || defined(m68k) || defined(__sparc) || \
(defined(__Lynx__) && \
(defined(__68k__) || defined(__sparc__) || defined(__powerpc__)))
#define BYTE_ORDER BIG_ENDIAN
#endif
#endif /* __linux */
#endif /* BSD */
#endif /* BYTE_ORDER */
#if !defined(BYTE_ORDER) || \
(BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
BYTE_ORDER != PDP_ENDIAN)
/* you must determine what the correct bit order is for
* your compiler - the next line is an intentional error
* which will force your compiles to bomb until you fix
* the above macros.
*/
error "Undefined or invalid BYTE_ORDER";
#endif
/*%
* Structure for query header. The order of the fields is machine- and
* compiler-dependent, depending on the byte/bit order and the layout
* of bit fields. We use bit fields only in int variables, as this
* is all ANSI requires. This requires a somewhat confusing rearrangement.
*/
typedef struct {
unsigned id :16; /*%< query identification number */
#if BYTE_ORDER == BIG_ENDIAN
/* fields in third byte */
unsigned qr: 1; /*%< response flag */
unsigned opcode: 4; /*%< purpose of message */
unsigned aa: 1; /*%< authoritive answer */
unsigned tc: 1; /*%< truncated message */
unsigned rd: 1; /*%< recursion desired */
/* fields in fourth byte */
unsigned ra: 1; /*%< recursion available */
unsigned unused :1; /*%< unused bits (MBZ as of 4.9.3a3) */
unsigned ad: 1; /*%< authentic data from named */
unsigned cd: 1; /*%< checking disabled by resolver */
unsigned rcode :4; /*%< response code */
#endif
#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
/* fields in third byte */
unsigned rd :1; /*%< recursion desired */
unsigned tc :1; /*%< truncated message */
unsigned aa :1; /*%< authoritive answer */
unsigned opcode :4; /*%< purpose of message */
unsigned qr :1; /*%< response flag */
/* fields in fourth byte */
unsigned rcode :4; /*%< response code */
unsigned cd: 1; /*%< checking disabled by resolver */
unsigned ad: 1; /*%< authentic data from named */
unsigned unused :1; /*%< unused bits (MBZ as of 4.9.3a3) */
unsigned ra :1; /*%< recursion available */
#endif
/* remaining bytes */
unsigned qdcount :16; /*%< number of question entries */
unsigned ancount :16; /*%< number of answer entries */
unsigned nscount :16; /*%< number of authority entries */
unsigned arcount :16; /*%< number of resource entries */
} HEADER;
#define PACKETSZ NS_PACKETSZ
#define MAXDNAME NS_MAXDNAME
#define MAXCDNAME NS_MAXCDNAME
#define MAXLABEL NS_MAXLABEL
#define HFIXEDSZ NS_HFIXEDSZ
#define QFIXEDSZ NS_QFIXEDSZ
#define RRFIXEDSZ NS_RRFIXEDSZ
#define INT32SZ NS_INT32SZ
#define INT16SZ NS_INT16SZ
#define INT8SZ NS_INT8SZ
#define INADDRSZ NS_INADDRSZ
#define IN6ADDRSZ NS_IN6ADDRSZ
#define INDIR_MASK NS_CMPRSFLGS
#define NAMESERVER_PORT NS_DEFAULTPORT
#define S_ZONE ns_s_zn
#define S_PREREQ ns_s_pr
#define S_UPDATE ns_s_ud
#define S_ADDT ns_s_ar
#define QUERY ns_o_query
#define IQUERY ns_o_iquery
#define STATUS ns_o_status
#define NS_NOTIFY_OP ns_o_notify
#define NS_UPDATE_OP ns_o_update
#define NOERROR ns_r_noerror
#define FORMERR ns_r_formerr
#define SERVFAIL ns_r_servfail
#define NXDOMAIN ns_r_nxdomain
#define NOTIMP ns_r_notimpl
#define REFUSED ns_r_refused
#define YXDOMAIN ns_r_yxdomain
#define YXRRSET ns_r_yxrrset
#define NXRRSET ns_r_nxrrset
#define NOTAUTH ns_r_notauth
#define NOTZONE ns_r_notzone
/*#define BADSIG ns_r_badsig*/
/*#define BADKEY ns_r_badkey*/
/*#define BADTIME ns_r_badtime*/
#define DELETE ns_uop_delete
#define ADD ns_uop_add
#define T_A ns_t_a
#define T_NS ns_t_ns
#define T_MD ns_t_md
#define T_MF ns_t_mf
#define T_CNAME ns_t_cname
#define T_SOA ns_t_soa
#define T_MB ns_t_mb
#define T_MG ns_t_mg
#define T_MR ns_t_mr
#define T_NULL ns_t_null
#define T_WKS ns_t_wks
#define T_PTR ns_t_ptr
#define T_HINFO ns_t_hinfo
#define T_MINFO ns_t_minfo
#define T_MX ns_t_mx
#define T_TXT ns_t_txt
#define T_RP ns_t_rp
#define T_AFSDB ns_t_afsdb
#define T_X25 ns_t_x25
#define T_ISDN ns_t_isdn
#define T_RT ns_t_rt
#define T_NSAP ns_t_nsap
#define T_NSAP_PTR ns_t_nsap_ptr
#define T_SIG ns_t_sig
#define T_KEY ns_t_key
#define T_PX ns_t_px
#define T_GPOS ns_t_gpos
#define T_AAAA ns_t_aaaa
#define T_LOC ns_t_loc
#define T_NXT ns_t_nxt
#define T_EID ns_t_eid
#define T_NIMLOC ns_t_nimloc
#define T_SRV ns_t_srv
#define T_ATMA ns_t_atma
#define T_NAPTR ns_t_naptr
#define T_A6 ns_t_a6
#define T_TSIG ns_t_tsig
#define T_IXFR ns_t_ixfr
#define T_AXFR ns_t_axfr
#define T_MAILB ns_t_mailb
#define T_MAILA ns_t_maila
#define T_ANY ns_t_any
#define C_IN ns_c_in
#define C_CHAOS ns_c_chaos
#define C_HS ns_c_hs
/* BIND_UPDATE */
#define C_NONE ns_c_none
#define C_ANY ns_c_any
#define GETSHORT NS_GET16
#define GETLONG NS_GET32
#define PUTSHORT NS_PUT16
#define PUTLONG NS_PUT32
#endif /* _ARPA_NAMESER_COMPAT_ */
/*! \file */

View File

@ -1,10 +0,0 @@
#ifndef _FD_SETSIZE_H
#define _FD_SETSIZE_H
/*%
* If you need a bigger FD_SETSIZE, this is NOT the place to set it.
* This file is a fallback for BIND ports which don't specify their own.
*/
#endif /* _FD_SETSIZE_H */
/*! \file */

View File

@ -1,39 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
/*! \file
* \brief
* This file is primarily maintained by <tytso@mit.edu> and <ghudson@mit.edu>.
*/
/*
* $Id: hesiod.h,v 1.3.18.1 2005/04/27 05:00:49 sra Exp $
*/
#ifndef _HESIOD_H_INCLUDED
#define _HESIOD_H_INCLUDED
int hesiod_init __P((void **));
void hesiod_end __P((void *));
char * hesiod_to_bind __P((void *, const char *, const char *));
char ** hesiod_resolve __P((void *, const char *, const char *));
void hesiod_free_list __P((void *, char **));
struct __res_state * __hesiod_res_get __P((void *));
void __hesiod_res_set __P((void *, struct __res_state *,
void (*)(void *)));
#endif /*_HESIOD_H_INCLUDED*/

View File

@ -1,107 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 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 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: irp.h,v 1.3.18.1 2005/04/27 05:00:49 sra Exp $
*/
#ifndef _IRP_H_INCLUDED
#define _IRP_H_INCLUDED
/*! \file */
#define IRPD_TIMEOUT 30 /*%< seconds */
#define IRPD_MAXSESS 50 /*%< number of simultaneous sessions. */
#define IRPD_PORT 6660 /*%< 10 times the number of the beast. */
#define IRPD_PATH "/var/run/irpd" /*%< af_unix socket path */
/* If sets the environment variable IRPDSERVER to an IP address
(e.g. "192.5.5.1"), then that's the host the client expects irpd to be
running on. */
#define IRPD_HOST_ENV "IRPDSERVER"
/* Protocol response codes. */
#define IRPD_WELCOME_CODE 200
#define IRPD_NOT_WELCOME_CODE 500
#define IRPD_GETHOST_ERROR 510
#define IRPD_GETHOST_NONE 210
#define IRPD_GETHOST_OK 211
#define IRPD_GETHOST_SETOK 212
#define IRPD_GETNET_ERROR 520
#define IRPD_GETNET_NONE 220
#define IRPD_GETNET_OK 221
#define IRPD_GETNET_SETOK 222
#define IRPD_GETUSER_ERROR 530
#define IRPD_GETUSER_NONE 230
#define IRPD_GETUSER_OK 231
#define IRPD_GETUSER_SETOK 232
#define IRPD_GETGROUP_ERROR 540
#define IRPD_GETGROUP_NONE 240
#define IRPD_GETGROUP_OK 241
#define IRPD_GETGROUP_SETOK 242
#define IRPD_GETSERVICE_ERROR 550
#define IRPD_GETSERVICE_NONE 250
#define IRPD_GETSERVICE_OK 251
#define IRPD_GETSERVICE_SETOK 252
#define IRPD_GETPROTO_ERROR 560
#define IRPD_GETPROTO_NONE 260
#define IRPD_GETPROTO_OK 261
#define IRPD_GETPROTO_SETOK 262
#define IRPD_GETNETGR_ERROR 570
#define IRPD_GETNETGR_NONE 270
#define IRPD_GETNETGR_OK 271
#define IRPD_GETNETGR_NOMORE 272
#define IRPD_GETNETGR_MATCHES 273
#define IRPD_GETNETGR_NOMATCH 274
#define IRPD_GETNETGR_SETOK 275
#define IRPD_GETNETGR_SETERR 276
#define irs_irp_read_body __irs_irp_read_body
#define irs_irp_read_response __irs_irp_read_response
#define irs_irp_disconnect __irs_irp_disconnect
#define irs_irp_connect __irs_irp_connect
#define irs_irp_connection_setup __irs_irp_connection_setup
#define irs_irp_send_command __irs_irp_send_command
struct irp_p;
char *irs_irp_read_body(struct irp_p *, size_t *);
int irs_irp_read_response(struct irp_p *, char *, size_t);
void irs_irp_disconnect(struct irp_p *);
int irs_irp_connect(struct irp_p *);
int irs_irp_is_connected(struct irp_p *);
int irs_irp_connection_setup(struct irp_p *, int *);
#ifdef __GNUC__
int irs_irp_send_command(struct irp_p *, const char *, ...)
__attribute__((__format__(__printf__, 2, 3)));
#else
int irs_irp_send_command(struct irp_p *, const char *, ...);
#endif
int irs_irp_get_full_response(struct irp_p *, int *, char *, size_t,
char **, size_t *);
int irs_irp_read_line(struct irp_p *, char *, int);
#endif
/*! \file */

View File

@ -1,348 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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: irs.h,v 1.4.18.1 2005/04/27 05:00:49 sra Exp $
*/
#ifndef _IRS_H_INCLUDED
#define _IRS_H_INCLUDED
/*! \file */
#include <sys/types.h>
#include <arpa/nameser.h>
#include <grp.h>
#include <netdb.h>
#include <resolv.h>
#include <pwd.h>
/*%
* This is the group map class.
*/
struct irs_gr {
void * private;
void (*close) __P((struct irs_gr *));
struct group * (*next) __P((struct irs_gr *));
struct group * (*byname) __P((struct irs_gr *, const char *));
struct group * (*bygid) __P((struct irs_gr *, gid_t));
int (*list) __P((struct irs_gr *, const char *,
gid_t, gid_t *, int *));
void (*rewind) __P((struct irs_gr *));
void (*minimize) __P((struct irs_gr *));
struct __res_state * (*res_get) __P((struct irs_gr *));
void (*res_set) __P((struct irs_gr *, res_state,
void (*)(void *)));
};
/*%
* This is the password map class.
*/
struct irs_pw {
void * private;
void (*close) __P((struct irs_pw *));
struct passwd * (*next) __P((struct irs_pw *));
struct passwd * (*byname) __P((struct irs_pw *, const char *));
struct passwd * (*byuid) __P((struct irs_pw *, uid_t));
void (*rewind) __P((struct irs_pw *));
void (*minimize) __P((struct irs_pw *));
struct __res_state * (*res_get) __P((struct irs_pw *));
void (*res_set) __P((struct irs_pw *, res_state,
void (*)(void *)));
};
/*%
* This is the service map class.
*/
struct irs_sv {
void * private;
void (*close) __P((struct irs_sv *));
struct servent *(*byname) __P((struct irs_sv *,
const char *, const char *));
struct servent *(*byport) __P((struct irs_sv *, int, const char *));
struct servent *(*next) __P((struct irs_sv *));
void (*rewind) __P((struct irs_sv *));
void (*minimize) __P((struct irs_sv *));
struct __res_state * (*res_get) __P((struct irs_sv *));
void (*res_set) __P((struct irs_sv *, res_state,
void (*)(void *)));
};
/*%
* This is the protocols map class.
*/
struct irs_pr {
void * private;
void (*close) __P((struct irs_pr *));
struct protoent *(*byname) __P((struct irs_pr *, const char *));
struct protoent *(*bynumber) __P((struct irs_pr *, int));
struct protoent *(*next) __P((struct irs_pr *));
void (*rewind) __P((struct irs_pr *));
void (*minimize) __P((struct irs_pr *));
struct __res_state * (*res_get) __P((struct irs_pr *));
void (*res_set) __P((struct irs_pr *, res_state,
void (*)(void *)));
};
/*%
* This is the hosts map class.
*/
struct irs_ho {
void * private;
void (*close) __P((struct irs_ho *));
struct hostent *(*byname) __P((struct irs_ho *, const char *));
struct hostent *(*byname2) __P((struct irs_ho *, const char *, int));
struct hostent *(*byaddr) __P((struct irs_ho *,
const void *, int, int));
struct hostent *(*next) __P((struct irs_ho *));
void (*rewind) __P((struct irs_ho *));
void (*minimize) __P((struct irs_ho *));
struct __res_state * (*res_get) __P((struct irs_ho *));
void (*res_set) __P((struct irs_ho *, res_state,
void (*)(void *)));
struct addrinfo *(*addrinfo) __P((struct irs_ho *, const char *,
const struct addrinfo *));
};
/*%
* This is the networks map class.
*/
struct irs_nw {
void * private;
void (*close) __P((struct irs_nw *));
struct nwent * (*byname) __P((struct irs_nw *, const char *, int));
struct nwent * (*byaddr) __P((struct irs_nw *, void *, int, int));
struct nwent * (*next) __P((struct irs_nw *));
void (*rewind) __P((struct irs_nw *));
void (*minimize) __P((struct irs_nw *));
struct __res_state * (*res_get) __P((struct irs_nw *));
void (*res_set) __P((struct irs_nw *, res_state,
void (*)(void *)));
};
/*%
* This is the netgroups map class.
*/
struct irs_ng {
void * private;
void (*close) __P((struct irs_ng *));
int (*next) __P((struct irs_ng *, const char **,
const char **, const char **));
int (*test) __P((struct irs_ng *, const char *,
const char *, const char *,
const char *));
void (*rewind) __P((struct irs_ng *, const char *));
void (*minimize) __P((struct irs_ng *));
};
/*%
* This is the generic map class, which copies the front of all others.
*/
struct irs_map {
void * private;
void (*close) __P((void *));
};
/*%
* This is the accessor class. It contains pointers to all of the
* initializers for the map classes for a particular accessor.
*/
struct irs_acc {
void * private;
void (*close) __P((struct irs_acc *));
struct irs_gr * (*gr_map) __P((struct irs_acc *));
struct irs_pw * (*pw_map) __P((struct irs_acc *));
struct irs_sv * (*sv_map) __P((struct irs_acc *));
struct irs_pr * (*pr_map) __P((struct irs_acc *));
struct irs_ho * (*ho_map) __P((struct irs_acc *));
struct irs_nw * (*nw_map) __P((struct irs_acc *));
struct irs_ng * (*ng_map) __P((struct irs_acc *));
struct __res_state * (*res_get) __P((struct irs_acc *));
void (*res_set) __P((struct irs_acc *, res_state,
void (*)(void *)));
};
/*%
* This is because the official definition of "struct netent" has no
* concept of CIDR even though it allows variant address families (on
* output but not input). The compatibility stubs convert the structs
* below into "struct netent"'s.
*/
struct nwent {
char *n_name; /*%< official name of net */
char **n_aliases; /*%< alias list */
int n_addrtype; /*%< net address type */
void *n_addr; /*%< network address */
int n_length; /*%< address length, in bits */
};
/*%
* Hide external function names from POSIX.
*/
#define irs_gen_acc __irs_gen_acc
#define irs_lcl_acc __irs_lcl_acc
#define irs_dns_acc __irs_dns_acc
#define irs_nis_acc __irs_nis_acc
#define irs_irp_acc __irs_irp_acc
#define irs_destroy __irs_destroy
#define irs_dns_gr __irs_dns_gr
#define irs_dns_ho __irs_dns_ho
#define irs_dns_nw __irs_dns_nw
#define irs_dns_pr __irs_dns_pr
#define irs_dns_pw __irs_dns_pw
#define irs_dns_sv __irs_dns_sv
#define irs_gen_gr __irs_gen_gr
#define irs_gen_ho __irs_gen_ho
#define irs_gen_ng __irs_gen_ng
#define irs_gen_nw __irs_gen_nw
#define irs_gen_pr __irs_gen_pr
#define irs_gen_pw __irs_gen_pw
#define irs_gen_sv __irs_gen_sv
#define irs_irp_get_full_response __irs_irp_get_full_response
#define irs_irp_gr __irs_irp_gr
#define irs_irp_ho __irs_irp_ho
#define irs_irp_is_connected __irs_irp_is_connected
#define irs_irp_ng __irs_irp_ng
#define irs_irp_nw __irs_irp_nw
#define irs_irp_pr __irs_irp_pr
#define irs_irp_pw __irs_irp_pw
#define irs_irp_read_line __irs_irp_read_line
#define irs_irp_sv __irs_irp_sv
#define irs_lcl_gr __irs_lcl_gr
#define irs_lcl_ho __irs_lcl_ho
#define irs_lcl_ng __irs_lcl_ng
#define irs_lcl_nw __irs_lcl_nw
#define irs_lcl_pr __irs_lcl_pr
#define irs_lcl_pw __irs_lcl_pw
#define irs_lcl_sv __irs_lcl_sv
#define irs_nis_gr __irs_nis_gr
#define irs_nis_ho __irs_nis_ho
#define irs_nis_ng __irs_nis_ng
#define irs_nis_nw __irs_nis_nw
#define irs_nis_pr __irs_nis_pr
#define irs_nis_pw __irs_nis_pw
#define irs_nis_sv __irs_nis_sv
#define net_data_create __net_data_create
#define net_data_destroy __net_data_destroy
#define net_data_minimize __net_data_minimize
/*%
* Externs.
*/
extern struct irs_acc * irs_gen_acc __P((const char *, const char *));
extern struct irs_acc * irs_lcl_acc __P((const char *));
extern struct irs_acc * irs_dns_acc __P((const char *));
extern struct irs_acc * irs_nis_acc __P((const char *));
extern struct irs_acc * irs_irp_acc __P((const char *));
extern void irs_destroy __P((void));
/*%
* These forward declarations are for the semi-private functions in
* the get*.c files. Each of these funcs implements the real get*
* functionality and the standard versions are just wrappers that
* call these. Apart from the wrappers, only irpd is expected to
* call these directly, hence these decls are put here and not in
* the /usr/include replacements.
*/
struct net_data; /*%< forward */
/*
* net_data_create gets a singleton net_data object. net_data_init
* creates as many net_data objects as times it is called. Clients using
* the default interface will use net_data_create by default. Servers will
* probably want net_data_init (one call per client)
*/
struct net_data *net_data_create __P((const char *));
struct net_data *net_data_init __P((const char *));
void net_data_destroy __P((void *));
extern struct group *getgrent_p __P((struct net_data *));
extern struct group *getgrnam_p __P((const char *, struct net_data *));
extern struct group *getgrgid_p __P((gid_t, struct net_data *));
extern int setgroupent_p __P((int, struct net_data *));
extern void endgrent_p __P((struct net_data *));
extern int getgrouplist_p __P((const char *, gid_t, gid_t *, int *,
struct net_data *));
#ifdef SETGRENT_VOID
extern void setgrent_p __P((struct net_data *));
#else
extern int setgrent_p __P((struct net_data *));
#endif
extern struct hostent *gethostbyname_p __P((const char *,
struct net_data *));
extern struct hostent *gethostbyname2_p __P((const char *, int,
struct net_data *));
extern struct hostent *gethostbyaddr_p __P((const char *, int, int,
struct net_data *));
extern struct hostent *gethostent_p __P((struct net_data *));
extern void sethostent_p __P((int, struct net_data *));
extern void endhostent_p __P((struct net_data *));
extern struct hostent *getipnodebyname_p __P((const char *, int, int, int *,
struct net_data *));
extern struct hostent *getipnodebyaddr_p __P((const void *, size_t,
int, int *, struct net_data *));
extern struct netent *getnetent_p __P((struct net_data *));
extern struct netent *getnetbyname_p __P((const char *, struct net_data *));
extern struct netent *getnetbyaddr_p __P((unsigned long, int,
struct net_data *));
extern void setnetent_p __P((int, struct net_data *));
extern void endnetent_p __P((struct net_data *));
extern void setnetgrent_p __P((const char *, struct net_data *));
extern void endnetgrent_p __P((struct net_data *));
extern int innetgr_p __P((const char *, const char *, const char *,
const char *, struct net_data *));
extern int getnetgrent_p __P((const char **, const char **,
const char **, struct net_data *));
extern struct protoent *getprotoent_p __P((struct net_data *));
extern struct protoent *getprotobyname_p __P((const char *,
struct net_data *));
extern struct protoent *getprotobynumber_p __P((int, struct net_data *));
extern void setprotoent_p __P((int, struct net_data *));
extern void endprotoent_p __P((struct net_data *));
extern struct passwd *getpwent_p __P((struct net_data *));
extern struct passwd *getpwnam_p __P((const char *, struct net_data *));
extern struct passwd *getpwuid_p __P((uid_t, struct net_data *));
extern int setpassent_p __P((int, struct net_data *));
extern void endpwent_p __P((struct net_data *));
#ifdef SETPWENT_VOID
extern void setpwent_p __P((struct net_data *));
#else
extern int setpwent_p __P((struct net_data *));
#endif
extern struct servent *getservent_p __P((struct net_data *));
extern struct servent *getservbyname_p __P((const char *, const char *,
struct net_data *));
extern struct servent *getservbyport_p __P((int, const char *,
struct net_data *));
extern void setservent_p __P((int, struct net_data *));
extern void endservent_p __P((struct net_data *));
#endif /*_IRS_H_INCLUDED*/
/*! \file */

View File

@ -1,123 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1997-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 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: assertions.h,v 1.2.18.2 2008/10/15 03:57:21 marka Exp $
*/
#ifndef ASSERTIONS_H
#define ASSERTIONS_H 1
typedef enum {
assert_require, assert_ensure, assert_insist, assert_invariant
} assertion_type;
typedef void (*assertion_failure_callback)(const char *, int, assertion_type,
const char *, int);
/* coverity[+kill] */
extern assertion_failure_callback __assertion_failed;
void set_assertion_failure_callback(assertion_failure_callback f);
const char *assertion_type_to_text(assertion_type type);
#if defined(CHECK_ALL) || defined(__COVERITY__)
#define CHECK_REQUIRE 1
#define CHECK_ENSURE 1
#define CHECK_INSIST 1
#define CHECK_INVARIANT 1
#endif
#if defined(CHECK_NONE) && !defined(__COVERITY__)
#define CHECK_REQUIRE 0
#define CHECK_ENSURE 0
#define CHECK_INSIST 0
#define CHECK_INVARIANT 0
#endif
#ifndef CHECK_REQUIRE
#define CHECK_REQUIRE 1
#endif
#ifndef CHECK_ENSURE
#define CHECK_ENSURE 1
#endif
#ifndef CHECK_INSIST
#define CHECK_INSIST 1
#endif
#ifndef CHECK_INVARIANT
#define CHECK_INVARIANT 1
#endif
#if CHECK_REQUIRE != 0
#define REQUIRE(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_require, \
#cond, 0), 0)))
#define REQUIRE_ERR(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_require, \
#cond, 1), 0)))
#else
#define REQUIRE(cond) ((void) (cond))
#define REQUIRE_ERR(cond) ((void) (cond))
#endif /* CHECK_REQUIRE */
#if CHECK_ENSURE != 0
#define ENSURE(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
#cond, 0), 0)))
#define ENSURE_ERR(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
#cond, 1), 0)))
#else
#define ENSURE(cond) ((void) (cond))
#define ENSURE_ERR(cond) ((void) (cond))
#endif /* CHECK_ENSURE */
#if CHECK_INSIST != 0
#define INSIST(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
#cond, 0), 0)))
#define INSIST_ERR(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
#cond, 1), 0)))
#else
#define INSIST(cond) ((void) (cond))
#define INSIST_ERR(cond) ((void) (cond))
#endif /* CHECK_INSIST */
#if CHECK_INVARIANT != 0
#define INVARIANT(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
#cond, 0), 0)))
#define INVARIANT_ERR(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
#cond, 1), 0)))
#else
#define INVARIANT(cond) ((void) (cond))
#define INVARIANT_ERR(cond) ((void) (cond))
#endif /* CHECK_INVARIANT */
#endif /* ASSERTIONS_H */
/*! \file */

View File

@ -1,112 +0,0 @@
#ifndef ISC_CTL_H
#define ISC_CTL_H
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1998,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 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: ctl.h,v 1.4.18.1 2005/04/27 05:00:51 sra Exp $
*/
/*! \file */
#include <sys/types.h>
#include <sys/socket.h>
#include <isc/eventlib.h>
/* Macros. */
#define CTL_MORE 0x0001 /*%< More will be / should be sent. */
#define CTL_EXIT 0x0002 /*%< Close connection after this. */
#define CTL_DATA 0x0004 /*%< Go into / this is DATA mode. */
/* Types. */
struct ctl_cctx;
struct ctl_sctx;
struct ctl_sess;
struct ctl_verb;
enum ctl_severity { ctl_debug, ctl_warning, ctl_error };
typedef void (*ctl_logfunc)(enum ctl_severity, const char *, ...);
typedef void (*ctl_verbfunc)(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *, const char *,
u_int, const void *, void *);
typedef void (*ctl_srvrdone)(struct ctl_sctx *, struct ctl_sess *, void *);
typedef void (*ctl_clntdone)(struct ctl_cctx *, void *, const char *, u_int);
struct ctl_verb {
const char * name;
ctl_verbfunc func;
const char * help;
};
/* General symbols. */
#define ctl_logger __ctl_logger
#ifdef __GNUC__
void ctl_logger(enum ctl_severity, const char *, ...)
__attribute__((__format__(__printf__, 2, 3)));
#else
void ctl_logger(enum ctl_severity, const char *, ...);
#endif
/* Client symbols. */
#define ctl_client __ctl_client
#define ctl_endclient __ctl_endclient
#define ctl_command __ctl_command
struct ctl_cctx * ctl_client(evContext, const struct sockaddr *, size_t,
const struct sockaddr *, size_t,
ctl_clntdone, void *,
u_int, ctl_logfunc);
void ctl_endclient(struct ctl_cctx *);
int ctl_command(struct ctl_cctx *, const char *, size_t,
ctl_clntdone, void *);
/* Server symbols. */
#define ctl_server __ctl_server
#define ctl_endserver __ctl_endserver
#define ctl_response __ctl_response
#define ctl_sendhelp __ctl_sendhelp
#define ctl_getcsctx __ctl_getcsctx
#define ctl_setcsctx __ctl_setcsctx
struct ctl_sctx * ctl_server(evContext, const struct sockaddr *, size_t,
const struct ctl_verb *,
u_int, u_int,
u_int, int, int,
ctl_logfunc, void *);
void ctl_endserver(struct ctl_sctx *);
void ctl_response(struct ctl_sess *, u_int,
const char *, u_int, const void *,
ctl_srvrdone, void *,
const char *, size_t);
void ctl_sendhelp(struct ctl_sess *, u_int);
void * ctl_getcsctx(struct ctl_sess *);
void * ctl_setcsctx(struct ctl_sess *, void *);
#endif /*ISC_CTL_H*/
/*! \file */

View File

@ -1,168 +0,0 @@
#ifndef DST_H
#define DST_H
#ifndef HAS_DST_KEY
typedef struct dst_key {
char *dk_key_name; /*%< name of the key */
int dk_key_size; /*%< this is the size of the key in bits */
int dk_proto; /*%< what protocols this key can be used for */
int dk_alg; /*%< algorithm number from key record */
u_int32_t dk_flags; /*%< and the flags of the public key */
u_int16_t dk_id; /*%< identifier of the key */
} DST_KEY;
#endif /* HAS_DST_KEY */
/*
* do not taint namespace
*/
#define dst_bsafe_init __dst_bsafe_init
#define dst_buffer_to_key __dst_buffer_to_key
#define dst_check_algorithm __dst_check_algorithm
#define dst_compare_keys __dst_compare_keys
#define dst_cylink_init __dst_cylink_init
#define dst_dnskey_to_key __dst_dnskey_to_key
#define dst_eay_dss_init __dst_eay_dss_init
#define dst_free_key __dst_free_key
#define dst_generate_key __dst_generate_key
#define dst_hmac_md5_init __dst_hmac_md5_init
#define dst_init __dst_init
#define dst_key_to_buffer __dst_key_to_buffer
#define dst_key_to_dnskey __dst_key_to_dnskey
#define dst_read_key __dst_read_key
#define dst_rsaref_init __dst_rsaref_init
#define dst_s_build_filename __dst_s_build_filename
#define dst_s_calculate_bits __dst_s_calculate_bits
#define dst_s_conv_bignum_b64_to_u8 __dst_s_conv_bignum_b64_to_u8
#define dst_s_conv_bignum_u8_to_b64 __dst_s_conv_bignum_u8_to_b64
#define dst_s_dns_key_id __dst_s_dns_key_id
#define dst_s_dump __dst_s_dump
#define dst_s_filename_length __dst_s_filename_length
#define dst_s_fopen __dst_s_fopen
#define dst_s_get_int16 __dst_s_get_int16
#define dst_s_get_int32 __dst_s_get_int32
#define dst_s_id_calc __dst_s_id_calc
#define dst_s_put_int16 __dst_s_put_int16
#define dst_s_put_int32 __dst_s_put_int32
#define dst_s_quick_random __dst_s_quick_random
#define dst_s_quick_random_set __dst_s_quick_random_set
#define dst_s_random __dst_s_random
#define dst_s_semi_random __dst_s_semi_random
#define dst_s_verify_str __dst_s_verify_str
#define dst_sig_size __dst_sig_size
#define dst_sign_data __dst_sign_data
#define dst_verify_data __dst_verify_data
#define dst_write_key __dst_write_key
/*
* DST Crypto API defintions
*/
void dst_init(void);
int dst_check_algorithm(const int);
int dst_sign_data(const int, /*!< specifies INIT/UPDATE/FINAL/ALL */
DST_KEY *, /*!< the key to use */
void **, /*!< pointer to state structure */
const u_char *, /*!< data to be signed */
const int, /*!< length of input data */
u_char *, /*!< buffer to write signature to */
const int); /*!< size of output buffer */
int dst_verify_data(const int, /*!< specifies INIT/UPDATE/FINAL/ALL */
DST_KEY *, /*!< the key to use */
void **, /*!< pointer to state structure */
const u_char *, /*!< data to be verified */
const int, /*!< length of input data */
const u_char *, /*!< buffer containing signature */
const int); /*!< length of signature */
DST_KEY *dst_read_key(const char *, /*!< name of key */
const u_int16_t, /*!< key tag identifier */
const int, /*!< key algorithm */
const int); /*!< Private/PublicKey wanted */
int dst_write_key(const DST_KEY *, /*!< key to write out */
const int); /*!< Public/Private */
DST_KEY *dst_dnskey_to_key(const char *, /*!< KEY record name */
const u_char *, /*!< KEY RDATA */
const int); /*!< size of input buffer */
int dst_key_to_dnskey(const DST_KEY *, /*!< key to translate */
u_char *, /*!< output buffer */
const int); /*!< size of out_storage */
DST_KEY *dst_buffer_to_key(const char *, /*!< name of the key */
const int, /*!< algorithm */
const int, /*!< dns flags */
const int, /*!< dns protocol */
const u_char *, /*!< key in dns wire fmt */
const int); /*!< size of key */
int dst_key_to_buffer(DST_KEY *, u_char *, int);
DST_KEY *dst_generate_key(const char *, /*!< name of new key */
const int, /*!< key algorithm to generate */
const int, /*!< size of new key */
const int, /*!< alg dependent parameter */
const int, /*!< key DNS flags */
const int); /*!< key DNS protocol */
DST_KEY *dst_free_key(DST_KEY *);
int dst_compare_keys(const DST_KEY *, const DST_KEY *);
int dst_sig_size(DST_KEY *);
/* support for dns key tags/ids */
u_int16_t dst_s_dns_key_id(const u_char *, const int);
u_int16_t dst_s_id_calc(const u_char *, const int);
/* Used by callers as well as by the library. */
#define RAW_KEY_SIZE 8192 /*%< large enough to store any key */
/* DST_API control flags */
/* These are used used in functions dst_sign_data and dst_verify_data */
#define SIG_MODE_INIT 1 /*%< initialize digest */
#define SIG_MODE_UPDATE 2 /*%< add data to digest */
#define SIG_MODE_FINAL 4 /*%< generate/verify signature */
#define SIG_MODE_ALL (SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL)
/* Flags for dst_read_private_key() */
#define DST_FORCE_READ 0x1000000
#define DST_CAN_SIGN 0x010F
#define DST_NO_AUTHEN 0x8000
#define DST_EXTEND_FLAG 0x1000
#define DST_STANDARD 0
#define DST_PRIVATE 0x2000000
#define DST_PUBLIC 0x4000000
#define DST_RAND_SEMI 1
#define DST_RAND_STD 2
#define DST_RAND_KEY 3
#define DST_RAND_DSS 4
/* DST algorithm codes */
#define KEY_RSA 1
#define KEY_DH 2
#define KEY_DSA 3
#define KEY_PRIVATE 254
#define KEY_EXPAND 255
#define KEY_HMAC_MD5 157
#define KEY_HMAC_SHA1 158
#define UNKNOWN_KEYALG 0
#define DST_MAX_ALGS KEY_HMAC_SHA1
/* DST constants to locations in KEY record changes in new KEY record */
#define DST_FLAGS_SIZE 2
#define DST_KEY_PROT 2
#define DST_KEY_ALG 3
#define DST_EXT_FLAG 4
#define DST_KEY_START 4
#ifndef SIGN_F_NOKEY
#define SIGN_F_NOKEY 0xC000
#endif
/* error codes from dst routines */
#define SIGN_INIT_FAILURE (-23)
#define SIGN_UPDATE_FAILURE (-24)
#define SIGN_FINAL_FAILURE (-25)
#define VERIFY_INIT_FAILURE (-26)
#define VERIFY_UPDATE_FAILURE (-27)
#define VERIFY_FINAL_FAILURE (-28)
#define MISSING_KEY_OR_SIGNATURE (-30)
#define UNSUPPORTED_KEYALG (-31)
#endif /* DST_H */
/*! \file */

View File

@ -1,206 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-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 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.
*/
/* eventlib.h - exported interfaces for eventlib
* vix 09sep95 [initial]
*
* $Id: eventlib.h,v 1.3.18.3 2008/01/23 02:12:01 marka Exp $
*/
#ifndef _EVENTLIB_H
#define _EVENTLIB_H
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/time.h>
#include <stdio.h>
#include <isc/platform.h>
#ifndef __P
# define __EVENTLIB_P_DEFINED
# ifdef __STDC__
# define __P(x) x
# else
# define __P(x) ()
# endif
#endif
/* In the absence of branded types... */
typedef struct { void *opaque; } evConnID;
typedef struct { void *opaque; } evFileID;
typedef struct { void *opaque; } evStreamID;
typedef struct { void *opaque; } evTimerID;
typedef struct { void *opaque; } evWaitID;
typedef struct { void *opaque; } evContext;
typedef struct { void *opaque; } evEvent;
#define evInitID(id) ((id)->opaque = NULL)
#define evTestID(id) ((id).opaque != NULL)
typedef void (*evConnFunc)__P((evContext, void *, int, const void *, int,
const void *, int));
typedef void (*evFileFunc)__P((evContext, void *, int, int));
typedef void (*evStreamFunc)__P((evContext, void *, int, int));
typedef void (*evTimerFunc)__P((evContext, void *,
struct timespec, struct timespec));
typedef void (*evWaitFunc)__P((evContext, void *, const void *));
typedef struct { unsigned char mask[256/8]; } evByteMask;
#define EV_BYTEMASK_BYTE(b) ((b) / 8)
#define EV_BYTEMASK_MASK(b) (1 << ((b) % 8))
#define EV_BYTEMASK_SET(bm, b) \
((bm).mask[EV_BYTEMASK_BYTE(b)] |= EV_BYTEMASK_MASK(b))
#define EV_BYTEMASK_CLR(bm, b) \
((bm).mask[EV_BYTEMASK_BYTE(b)] &= ~EV_BYTEMASK_MASK(b))
#define EV_BYTEMASK_TST(bm, b) \
((bm).mask[EV_BYTEMASK_BYTE(b)] & EV_BYTEMASK_MASK(b))
#define EV_POLL 1
#define EV_WAIT 2
#define EV_NULL 4
#define EV_READ 1
#define EV_WRITE 2
#define EV_EXCEPT 4
#define EV_WASNONBLOCKING 8 /* Internal library use. */
/* eventlib.c */
#define evCreate __evCreate
#define evSetDebug __evSetDebug
#define evDestroy __evDestroy
#define evGetNext __evGetNext
#define evDispatch __evDispatch
#define evDrop __evDrop
#define evMainLoop __evMainLoop
#define evHighestFD __evHighestFD
#define evGetOption __evGetOption
#define evSetOption __evSetOption
int evCreate __P((evContext *));
void evSetDebug __P((evContext, int, FILE *));
int evDestroy __P((evContext));
int evGetNext __P((evContext, evEvent *, int));
int evDispatch __P((evContext, evEvent));
void evDrop __P((evContext, evEvent));
int evMainLoop __P((evContext));
int evHighestFD __P((evContext));
int evGetOption __P((evContext *, const char *, int *));
int evSetOption __P((evContext *, const char *, int));
/* ev_connects.c */
#define evListen __evListen
#define evConnect __evConnect
#define evCancelConn __evCancelConn
#define evHold __evHold
#define evUnhold __evUnhold
#define evTryAccept __evTryAccept
int evListen __P((evContext, int, int, evConnFunc, void *, evConnID *));
int evConnect __P((evContext, int, const void *, int,
evConnFunc, void *, evConnID *));
int evCancelConn __P((evContext, evConnID));
int evHold __P((evContext, evConnID));
int evUnhold __P((evContext, evConnID));
int evTryAccept __P((evContext, evConnID, int *));
/* ev_files.c */
#define evSelectFD __evSelectFD
#define evDeselectFD __evDeselectFD
int evSelectFD __P((evContext, int, int, evFileFunc, void *, evFileID *));
int evDeselectFD __P((evContext, evFileID));
/* ev_streams.c */
#define evConsIovec __evConsIovec
#define evWrite __evWrite
#define evRead __evRead
#define evTimeRW __evTimeRW
#define evUntimeRW __evUntimeRW
#define evCancelRW __evCancelRW
struct iovec evConsIovec __P((void *, size_t));
int evWrite __P((evContext, int, const struct iovec *, int,
evStreamFunc func, void *, evStreamID *));
int evRead __P((evContext, int, const struct iovec *, int,
evStreamFunc func, void *, evStreamID *));
int evTimeRW __P((evContext, evStreamID, evTimerID timer));
int evUntimeRW __P((evContext, evStreamID));
int evCancelRW __P((evContext, evStreamID));
/* ev_timers.c */
#define evConsTime __evConsTime
#define evAddTime __evAddTime
#define evSubTime __evSubTime
#define evCmpTime __evCmpTime
#define evTimeSpec __evTimeSpec
#define evTimeVal __evTimeVal
#define evNowTime __evNowTime
#define evUTCTime __evUTCTime
#define evLastEventTime __evLastEventTime
#define evSetTimer __evSetTimer
#define evClearTimer __evClearTimer
#define evConfigTimer __evConfigTimer
#define evResetTimer __evResetTimer
#define evSetIdleTimer __evSetIdleTimer
#define evClearIdleTimer __evClearIdleTimer
#define evResetIdleTimer __evResetIdleTimer
#define evTouchIdleTimer __evTouchIdleTimer
struct timespec evConsTime __P((time_t sec, long nsec));
struct timespec evAddTime __P((struct timespec, struct timespec));
struct timespec evSubTime __P((struct timespec, struct timespec));
struct timespec evNowTime __P((void));
struct timespec evUTCTime __P((void));
struct timespec evLastEventTime __P((evContext));
struct timespec evTimeSpec __P((struct timeval));
struct timeval evTimeVal __P((struct timespec));
int evCmpTime __P((struct timespec, struct timespec));
int evSetTimer __P((evContext, evTimerFunc, void *, struct timespec,
struct timespec, evTimerID *));
int evClearTimer __P((evContext, evTimerID));
int evConfigTimer __P((evContext, evTimerID, const char *param,
int value));
int evResetTimer __P((evContext, evTimerID, evTimerFunc, void *,
struct timespec, struct timespec));
int evSetIdleTimer __P((evContext, evTimerFunc, void *, struct timespec,
evTimerID *));
int evClearIdleTimer __P((evContext, evTimerID));
int evResetIdleTimer __P((evContext, evTimerID, evTimerFunc, void *,
struct timespec));
int evTouchIdleTimer __P((evContext, evTimerID));
/* ev_waits.c */
#define evWaitFor __evWaitFor
#define evDo __evDo
#define evUnwait __evUnwait
#define evDefer __evDefer
int evWaitFor __P((evContext, const void *, evWaitFunc, void *, evWaitID *));
int evDo __P((evContext, const void *));
int evUnwait __P((evContext, evWaitID));
int evDefer __P((evContext, evWaitFunc, void *));
#ifdef __EVENTLIB_P_DEFINED
# undef __P
#endif
#endif /*_EVENTLIB_H*/
/*! \file */

View File

@ -1,49 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1997,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 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.
*/
typedef int (*heap_higher_priority_func)(void *, void *);
typedef void (*heap_index_func)(void *, int);
typedef void (*heap_for_each_func)(void *, void *);
typedef struct heap_context {
int array_size;
int array_size_increment;
int heap_size;
void **heap;
heap_higher_priority_func higher_priority;
heap_index_func index;
} *heap_context;
#define heap_new __heap_new
#define heap_free __heap_free
#define heap_insert __heap_insert
#define heap_delete __heap_delete
#define heap_increased __heap_increased
#define heap_decreased __heap_decreased
#define heap_element __heap_element
#define heap_for_each __heap_for_each
heap_context heap_new(heap_higher_priority_func, heap_index_func, int);
int heap_free(heap_context);
int heap_insert(heap_context, void *);
int heap_delete(heap_context, int);
int heap_increased(heap_context, int);
int heap_decreased(heap_context, int);
void * heap_element(heap_context, int);
int heap_for_each(heap_context, heap_for_each_func, void *);
/*! \file */

View File

@ -1,112 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 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 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: irpmarshall.h,v 1.3.18.1 2005/04/27 05:00:51 sra Exp $
*/
#ifndef _IRPMARSHALL_H_INCLUDED
#define _IRPMARSHALL_H_INCLUDED
/* Hide function names */
#define irp_marshall_gr __irp_marshall_gr
#define irp_marshall_ho __irp_marshall_ho
#define irp_marshall_ne __irp_marshall_ne
#define irp_marshall_ng __irp_marshall_ng
#define irp_marshall_nw __irp_marshall_nw
#define irp_marshall_pr __irp_marshall_pr
#define irp_marshall_pw __irp_marshall_pw
#define irp_marshall_sv __irp_marshall_sv
#define irp_unmarshall_gr __irp_unmarshall_gr
#define irp_unmarshall_ho __irp_unmarshall_ho
#define irp_unmarshall_ne __irp_unmarshall_ne
#define irp_unmarshall_ng __irp_unmarshall_ng
#define irp_unmarshall_nw __irp_unmarshall_nw
#define irp_unmarshall_pr __irp_unmarshall_pr
#define irp_unmarshall_pw __irp_unmarshall_pw
#define irp_unmarshall_sv __irp_unmarshall_sv
#define MAXPADDRSIZE (sizeof "255.255.255.255" + 1)
#define ADDR_T_STR(x) (x == AF_INET ? "AF_INET" :\
(x == AF_INET6 ? "AF_INET6" : "UNKNOWN"))
/* See comment below on usage */
int irp_marshall_pw(const struct passwd *, char **, size_t *);
int irp_unmarshall_pw(struct passwd *, char *);
int irp_marshall_gr(const struct group *, char **, size_t *);
int irp_unmarshall_gr(struct group *, char *);
int irp_marshall_sv(const struct servent *, char **, size_t *);
int irp_unmarshall_sv(struct servent *, char *);
int irp_marshall_pr(struct protoent *, char **, size_t *);
int irp_unmarshall_pr(struct protoent *, char *);
int irp_marshall_ho(struct hostent *, char **, size_t *);
int irp_unmarshall_ho(struct hostent *, char *);
int irp_marshall_ng(const char *, const char *, const char *,
char **, size_t *);
int irp_unmarshall_ng(const char **, const char **, const char **, char *);
int irp_marshall_nw(struct nwent *, char **, size_t *);
int irp_unmarshall_nw(struct nwent *, char *);
int irp_marshall_ne(struct netent *, char **, size_t *);
int irp_unmarshall_ne(struct netent *, char *);
/*! \file
* \brief
* Functions to marshall and unmarshall various system data structures. We
* use a printable ascii format that is as close to various system config
* files as reasonable (e.g. /etc/passwd format).
*
* We are not forgiving with unmarhsalling misformatted buffers. In
* particular whitespace in fields is not ignored. So a formatted password
* entry "brister :1364:100:...." will yield a username of "brister "
*
* We potentially do a lot of mallocs to fill fields that are of type
* (char **) like a hostent h_addr field. Building (for example) the
* h_addr field and its associated addresses all in one buffer is
* certainly possible, but not done here.
*
* The following description is true for all the marshalling functions:
*
* int irp_marshall_XX(struct yyyy *XX, char **buffer, size_t *len);
*
* The argument XX (of type struct passwd for example) is marshalled in the
* buffer pointed at by *BUFFER, which is of length *LEN. Returns 0
* on success and -1 on failure. Failure will occur if *LEN is
* smaller than needed.
*
* If BUFFER is NULL, then *LEN is set to the size of the buffer
* needed to marshall the data and no marshalling is actually done.
*
* If *BUFFER is NULL, then a buffer large enough will be allocated
* with memget() and the size allocated will be stored in *LEN. An extra 2
* bytes will be allocated for the client to append CRLF if wanted. The
* value of *LEN will include these two bytes.
*
* All the marshalling functions produce a buffer with the fields
* separated by colons (except for the hostent marshalling, which uses '@'
* to separate fields). Fields that have multiple subfields (like the
* gr_mem field in struct group) have their subparts separated by
* commas.
*
* int irp_unmarshall_XX(struct YYYYY *XX, char *buffer);
*
* The unmashalling functions break apart the buffer and store the
* values in the struct pointed to by XX. All pointer values inside
* XX are allocated with malloc. All arrays of pointers have a NULL
* as the last element.
*/
#endif

View File

@ -1,117 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1997,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 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.
*/
#ifndef LIST_H
#define LIST_H 1
#include <isc/assertions.h>
#define LIST(type) struct { type *head, *tail; }
#define INIT_LIST(list) \
do { (list).head = NULL; (list).tail = NULL; } while (0)
#define LINK(type) struct { type *prev, *next; }
#define INIT_LINK_TYPE(elt, link, type) \
do { \
(elt)->link.prev = (type *)(-1); \
(elt)->link.next = (type *)(-1); \
} while (0)
#define INIT_LINK(elt, link) \
INIT_LINK_TYPE(elt, link, void)
#define LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1))
#define HEAD(list) ((list).head)
#define TAIL(list) ((list).tail)
#define EMPTY(list) ((list).head == NULL)
#define PREPEND(list, elt, link) \
do { \
INSIST(!LINKED(elt, link));\
if ((list).head != NULL) \
(list).head->link.prev = (elt); \
else \
(list).tail = (elt); \
(elt)->link.prev = NULL; \
(elt)->link.next = (list).head; \
(list).head = (elt); \
} while (0)
#define APPEND(list, elt, link) \
do { \
INSIST(!LINKED(elt, link));\
if ((list).tail != NULL) \
(list).tail->link.next = (elt); \
else \
(list).head = (elt); \
(elt)->link.prev = (list).tail; \
(elt)->link.next = NULL; \
(list).tail = (elt); \
} while (0)
#define UNLINK_TYPE(list, elt, link, type) \
do { \
INSIST(LINKED(elt, link));\
if ((elt)->link.next != NULL) \
(elt)->link.next->link.prev = (elt)->link.prev; \
else { \
INSIST((list).tail == (elt)); \
(list).tail = (elt)->link.prev; \
} \
if ((elt)->link.prev != NULL) \
(elt)->link.prev->link.next = (elt)->link.next; \
else { \
INSIST((list).head == (elt)); \
(list).head = (elt)->link.next; \
} \
INIT_LINK_TYPE(elt, link, type); \
} while (0)
#define UNLINK(list, elt, link) \
UNLINK_TYPE(list, elt, link, void)
#define PREV(elt, link) ((elt)->link.prev)
#define NEXT(elt, link) ((elt)->link.next)
#define INSERT_BEFORE(list, before, elt, link) \
do { \
INSIST(!LINKED(elt, link));\
if ((before)->link.prev == NULL) \
PREPEND(list, elt, link); \
else { \
(elt)->link.prev = (before)->link.prev; \
(before)->link.prev = (elt); \
(elt)->link.prev->link.next = (elt); \
(elt)->link.next = (before); \
} \
} while (0)
#define INSERT_AFTER(list, after, elt, link) \
do { \
INSIST(!LINKED(elt, link));\
if ((after)->link.next == NULL) \
APPEND(list, elt, link); \
else { \
(elt)->link.next = (after)->link.next; \
(after)->link.next = (elt); \
(elt)->link.next->link.prev = (elt); \
(elt)->link.prev = (after); \
} \
} while (0)
#define ENQUEUE(list, elt, link) APPEND(list, elt, link)
#define DEQUEUE(list, elt, link) UNLINK(list, elt, link)
#endif /* LIST_H */
/*! \file */

View File

@ -1,113 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#ifndef LOGGING_H
#define LOGGING_H
#include <sys/types.h>
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
#define log_critical (-5)
#define log_error (-4)
#define log_warning (-3)
#define log_notice (-2)
#define log_info (-1)
#define log_debug(level) (level)
typedef enum { log_syslog, log_file, log_null } log_channel_type;
#define LOG_MAX_VERSIONS 99
#define LOG_CLOSE_STREAM 0x0001
#define LOG_TIMESTAMP 0x0002
#define LOG_TRUNCATE 0x0004
#define LOG_USE_CONTEXT_LEVEL 0x0008
#define LOG_PRINT_LEVEL 0x0010
#define LOG_REQUIRE_DEBUG 0x0020
#define LOG_CHANNEL_BROKEN 0x0040
#define LOG_PRINT_CATEGORY 0x0080
#define LOG_CHANNEL_OFF 0x0100
typedef struct log_context *log_context;
typedef struct log_channel *log_channel;
#define LOG_OPTION_DEBUG 0x01
#define LOG_OPTION_LEVEL 0x02
#define log_open_stream __log_open_stream
#define log_close_stream __log_close_stream
#define log_get_stream __log_get_stream
#define log_get_filename __log_get_filename
#define log_check_channel __log_check_channel
#define log_check __log_check
#define log_vwrite __log_vwrite
#define log_write __log_write
#define log_new_context __log_new_context
#define log_free_context __log_free_context
#define log_add_channel __log_add_channel
#define log_remove_channel __log_remove_channel
#define log_option __log_option
#define log_category_is_active __log_category_is_active
#define log_new_syslog_channel __log_new_syslog_channel
#define log_new_file_channel __log_new_file_channel
#define log_set_file_owner __log_set_file_owner
#define log_new_null_channel __log_new_null_channel
#define log_inc_references __log_inc_references
#define log_dec_references __log_dec_references
#define log_get_channel_type __log_get_channel_type
#define log_free_channel __log_free_channel
#define log_close_debug_channels __log_close_debug_channels
FILE * log_open_stream(log_channel);
int log_close_stream(log_channel);
FILE * log_get_stream(log_channel);
char * log_get_filename(log_channel);
int log_check_channel(log_context, int, log_channel);
int log_check(log_context, int, int);
#ifdef __GNUC__
void log_vwrite(log_context, int, int, const char *,
va_list args)
__attribute__((__format__(__printf__, 4, 0)));
void log_write(log_context, int, int, const char *, ...)
__attribute__((__format__(__printf__, 4, 5)));
#else
void log_vwrite(log_context, int, int, const char *,
va_list args);
void log_write(log_context, int, int, const char *, ...);
#endif
int log_new_context(int, char **, log_context *);
void log_free_context(log_context);
int log_add_channel(log_context, int, log_channel);
int log_remove_channel(log_context, int, log_channel);
int log_option(log_context, int, int);
int log_category_is_active(log_context, int);
log_channel log_new_syslog_channel(unsigned int, int, int);
log_channel log_new_file_channel(unsigned int, int, const char *,
FILE *, unsigned int,
unsigned long);
int log_set_file_owner(log_channel, uid_t, gid_t);
log_channel log_new_null_channel(void);
int log_inc_references(log_channel);
int log_dec_references(log_channel);
log_channel_type log_get_channel_type(log_channel);
int log_free_channel(log_channel);
void log_close_debug_channels(log_context);
#endif /* !LOGGING_H */
/*! \file */

View File

@ -1,50 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1997,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 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.
*/
#ifndef MEMCLUSTER_H
#define MEMCLUSTER_H
#include <stdio.h>
#define meminit __meminit
#ifdef MEMCLUSTER_DEBUG
#define memget(s) __memget_debug(s, __FILE__, __LINE__)
#define memput(p, s) __memput_debug(p, s, __FILE__, __LINE__)
#else /*MEMCLUSTER_DEBUG*/
#ifdef MEMCLUSTER_RECORD
#define memget(s) __memget_record(s, __FILE__, __LINE__)
#define memput(p, s) __memput_record(p, s, __FILE__, __LINE__)
#else /*MEMCLUSTER_RECORD*/
#define memget __memget
#define memput __memput
#endif /*MEMCLUSTER_RECORD*/
#endif /*MEMCLUSTER_DEBUG*/
#define memstats __memstats
#define memactive __memactive
int meminit(size_t, size_t);
void * __memget(size_t);
void __memput(void *, size_t);
void * __memget_debug(size_t, const char *, int);
void __memput_debug(void *, size_t, const char *, int);
void * __memget_record(size_t, const char *, int);
void __memput_record(void *, size_t, const char *, int);
void memstats(FILE *);
int memactive(void);
#endif /* MEMCLUSTER_H */
/*! \file */

View File

@ -1,44 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-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 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: misc.h,v 1.4.18.2 2008/02/18 04:04:06 marka Exp $
*/
#ifndef _ISC_MISC_H
#define _ISC_MISC_H
/*! \file */
#include <stdio.h>
#include <sys/types.h>
#define bitncmp __bitncmp
/*#define isc_movefile __isc_movefile */
extern int bitncmp(const void *, const void *, int);
extern int isc_movefile(const char *, const char *);
extern int isc_gethexstring(unsigned char *, size_t, int, FILE *,
int *);
extern void isc_puthexstring(FILE *, const unsigned char *, size_t,
size_t, size_t, const char *);
extern void isc_tohex(const unsigned char *, size_t, char *);
#endif /*_ISC_MISC_H*/
/*! \file */

View File

@ -1,36 +0,0 @@
/*
* Copyright (C) 2008 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or 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 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: platform.h.in,v 1.2.6.2 2008/01/23 02:15:02 tbox Exp $ */
/*! \file */
#ifndef ISC_PLATFORM_H
#define ISC_PLATFORM_H
/*
* Define if the OS does not define struct timespec.
*/
@ISC_PLATFORM_NEEDTIMESPEC@
#ifdef ISC_PLATFORM_NEEDTIMESPEC
#include <time.h> /* For time_t */
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
#endif
#endif

View File

@ -1,59 +0,0 @@
/* tree.h - declare structures used by tree library
*
* vix 22jan93 [revisited; uses RCS, ANSI, POSIX; has bug fixes]
* vix 27jun86 [broken out of tree.c]
*
* $Id: tree.h,v 1.2.164.1 2005/04/27 05:00:52 sra Exp $
*/
#ifndef _TREE_H_INCLUDED
#define _TREE_H_INCLUDED
#ifndef __P
# if defined(__STDC__) || defined(__GNUC__)
# define __P(x) x
# else
# define __P(x) ()
# endif
#endif
/*%
* tree_t is our package-specific anonymous pointer.
*/
#if defined(__STDC__) || defined(__GNUC__)
typedef void *tree_t;
#else
typedef char *tree_t;
#endif
/*%
* Do not taint namespace
*/
#define tree_add __tree_add
#define tree_delete __tree_delete
#define tree_init __tree_init
#define tree_mung __tree_mung
#define tree_srch __tree_srch
#define tree_trav __tree_trav
typedef struct tree_s {
tree_t data;
struct tree_s *left, *right;
short bal;
}
tree;
void tree_init __P((tree **));
tree_t tree_srch __P((tree **, int (*)(), tree_t));
tree_t tree_add __P((tree **, int (*)(), tree_t, void (*)()));
int tree_delete __P((tree **, int (*)(), tree_t, void (*)()));
int tree_trav __P((tree **, int (*)()));
void tree_mung __P((tree **, void (*)()));
#endif /* _TREE_H_INCLUDED */
/*! \file */

View File

@ -1,582 +0,0 @@
/*
* ++Copyright++ 1980, 1983, 1988, 1993
* -
* Copyright (c) 1980, 1983, 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* -
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
* 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, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
* CORPORATION 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.
* -
* Portions Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by WIDE Project and
* its contributors.
* 4. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* -
* --Copyright--
*/
/*
* @(#)netdb.h 8.1 (Berkeley) 6/2/93
* $Id: netdb.h,v 1.15.18.7 2008/02/28 05:49:37 marka Exp $
*/
#ifndef _NETDB_H_
#define _NETDB_H_
#include <sys/param.h>
#include <sys/types.h>
#if (!defined(BSD)) || (BSD < 199306)
# include <sys/bitypes.h>
#endif
#include <sys/cdefs.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#ifndef _PATH_HEQUIV
#define _PATH_HEQUIV "/etc/hosts.equiv"
#endif
#ifndef _PATH_HOSTS
#define _PATH_HOSTS "/etc/hosts"
#endif
#ifndef _PATH_NETWORKS
#define _PATH_NETWORKS "/etc/networks"
#endif
#ifndef _PATH_PROTOCOLS
#define _PATH_PROTOCOLS "/etc/protocols"
#endif
#ifndef _PATH_SERVICES
#define _PATH_SERVICES "/etc/services"
#endif
#if (__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)
#define __h_errno __h_errno_location
#endif
__BEGIN_DECLS
extern int * __h_errno __P((void));
__END_DECLS
#if defined(_REENTRANT) || \
(__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)
#define h_errno (*__h_errno())
#else
extern int h_errno;
#endif
/*%
* Structures returned by network data base library. All addresses are
* supplied in host order, and returned in network order (suitable for
* use in system calls).
*/
struct hostent {
char *h_name; /*%< official name of host */
char **h_aliases; /*%< alias list */
int h_addrtype; /*%< host address type */
int h_length; /*%< length of address */
char **h_addr_list; /*%< list of addresses from name server */
#define h_addr h_addr_list[0] /*%< address, for backward compatiblity */
};
/*%
* Assumption here is that a network number
* fits in an unsigned long -- probably a poor one.
*/
struct netent {
char *n_name; /*%< official name of net */
char **n_aliases; /*%< alias list */
int n_addrtype; /*%< net address type */
unsigned long n_net; /*%< network # */
};
struct servent {
char *s_name; /*%< official service name */
char **s_aliases; /*%< alias list */
int s_port; /*%< port # */
char *s_proto; /*%< protocol to use */
};
struct protoent {
char *p_name; /*%< official protocol name */
char **p_aliases; /*%< alias list */
int p_proto; /*%< protocol # */
};
struct addrinfo {
int ai_flags; /*%< AI_PASSIVE, AI_CANONNAME */
int ai_family; /*%< PF_xxx */
int ai_socktype; /*%< SOCK_xxx */
int ai_protocol; /*%< 0 or IPPROTO_xxx for IPv4 and IPv6 */
#if defined(sun) && defined(_SOCKLEN_T)
#ifdef __sparcv9
int _ai_pad;
#endif
socklen_t ai_addrlen;
#else
size_t ai_addrlen; /*%< length of ai_addr */
#endif
#ifdef __linux
struct sockaddr *ai_addr; /*%< binary address */
char *ai_canonname; /*%< canonical name for hostname */
#else
char *ai_canonname; /*%< canonical name for hostname */
struct sockaddr *ai_addr; /*%< binary address */
#endif
struct addrinfo *ai_next; /*%< next structure in linked list */
};
/*%
* Error return codes from gethostbyname() and gethostbyaddr()
* (left in extern int h_errno).
*/
#define NETDB_INTERNAL -1 /*%< see errno */
#define NETDB_SUCCESS 0 /*%< no problem */
#define HOST_NOT_FOUND 1 /*%< Authoritative Answer Host not found */
#define TRY_AGAIN 2 /*%< Non-Authoritive Host not found, or SERVERFAIL */
#define NO_RECOVERY 3 /*%< Non recoverable errors, FORMERR, REFUSED, NOTIMP */
#define NO_DATA 4 /*%< Valid name, no data record of requested type */
#define NO_ADDRESS NO_DATA /*%< no address, look for MX record */
/*
* Error return codes from getaddrinfo()
*/
#define EAI_ADDRFAMILY 1 /*%< address family for hostname not supported */
#define EAI_AGAIN 2 /*%< temporary failure in name resolution */
#define EAI_BADFLAGS 3 /*%< invalid value for ai_flags */
#define EAI_FAIL 4 /*%< non-recoverable failure in name resolution */
#define EAI_FAMILY 5 /*%< ai_family not supported */
#define EAI_MEMORY 6 /*%< memory allocation failure */
#define EAI_NODATA 7 /*%< no address associated with hostname */
#define EAI_NONAME 8 /*%< hostname nor servname provided, or not known */
#define EAI_SERVICE 9 /*%< servname not supported for ai_socktype */
#define EAI_SOCKTYPE 10 /*%< ai_socktype not supported */
#define EAI_SYSTEM 11 /*%< system error returned in errno */
#define EAI_BADHINTS 12
#define EAI_PROTOCOL 13
#define EAI_MAX 14
/*%
* Flag values for getaddrinfo()
*/
#define AI_PASSIVE 0x00000001
#define AI_CANONNAME 0x00000002
#define AI_NUMERICHOST 0x00000004
#define AI_MASK 0x00000007
/*%
* Flag values for getipnodebyname()
*/
#define AI_V4MAPPED 0x00000008
#define AI_ALL 0x00000010
#define AI_ADDRCONFIG 0x00000020
#define AI_DEFAULT (AI_V4MAPPED|AI_ADDRCONFIG)
/*%
* Constants for getnameinfo()
*/
#define NI_MAXHOST 1025
#define NI_MAXSERV 32
/*%
* Flag values for getnameinfo()
*/
#define NI_NOFQDN 0x00000001
#define NI_NUMERICHOST 0x00000002
#define NI_NAMEREQD 0x00000004
#define NI_NUMERICSERV 0x00000008
#define NI_DGRAM 0x00000010
#define NI_WITHSCOPEID 0x00000020
#define NI_NUMERICSCOPE 0x00000040
/*%
* Scope delimit character
*/
#define SCOPE_DELIMITER '%'
#ifdef _REENTRANT
#if defined (__hpux) || defined(__osf__) || defined(_AIX)
#define _MAXALIASES 35
#define _MAXLINELEN 1024
#define _MAXADDRS 35
#define _HOSTBUFSIZE (BUFSIZ + 1)
struct hostent_data {
struct in_addr host_addr;
char *h_addr_ptrs[_MAXADDRS + 1];
char hostaddr[_MAXADDRS];
char hostbuf[_HOSTBUFSIZE];
char *host_aliases[_MAXALIASES];
char *host_addrs[2];
FILE *hostf;
#ifdef __osf__
int svc_gethostflag;
int svc_gethostbind;
#endif
#ifdef __hpux
short _nsw_src;
short _flags;
char *current;
int currentlen;
#endif
};
struct netent_data {
FILE *net_fp;
#if defined(__osf__) || defined(_AIX)
char line[_MAXLINELEN];
#endif
#ifdef __hpux
char line[_MAXLINELEN+1];
#endif
char *net_aliases[_MAXALIASES];
#ifdef __osf__
int _net_stayopen;
int svc_getnetflag;
#endif
#ifdef __hpux
short _nsw_src;
short _flags;
char *current;
int currentlen;
#endif
#ifdef _AIX
int _net_stayopen;
char *current;
int currentlen;
void *_net_reserv1; /* reserved for future use */
void *_net_reserv2; /* reserved for future use */
#endif
};
struct protoent_data {
FILE *proto_fp;
#ifdef _AIX
int _proto_stayopen;
char line[_MAXLINELEN];
#endif
#ifdef __osf__
char line[1024];
#endif
#ifdef __hpux
char line[_MAXLINELEN+1];
#endif
char *proto_aliases[_MAXALIASES];
#ifdef __osf__
int _proto_stayopen;
int svc_getprotoflag;
#endif
#ifdef __hpux
short _nsw_src;
short _flags;
char *current;
int currentlen;
#endif
#ifdef _AIX
int currentlen;
char *current;
void *_proto_reserv1; /* reserved for future use */
void *_proto_reserv2; /* reserved for future use */
#endif
};
struct servent_data {
FILE *serv_fp;
#if defined(__osf__) || defined(_AIX)
char line[_MAXLINELEN];
#endif
#ifdef __hpux
char line[_MAXLINELEN+1];
#endif
char *serv_aliases[_MAXALIASES];
#ifdef __osf__
int _serv_stayopen;
int svc_getservflag;
#endif
#ifdef __hpux
short _nsw_src;
short _flags;
char *current;
int currentlen;
#endif
#ifdef _AIX
int _serv_stayopen;
char *current;
int currentlen;
void *_serv_reserv1; /* reserved for future use */
void *_serv_reserv2; /* reserved for future use */
#endif
};
#endif
#endif
__BEGIN_DECLS
void endhostent __P((void));
void endnetent __P((void));
void endprotoent __P((void));
void endservent __P((void));
void freehostent __P((struct hostent *));
struct hostent *gethostbyaddr __P((const char *, int, int));
struct hostent *gethostbyname __P((const char *));
struct hostent *gethostbyname2 __P((const char *, int));
struct hostent *gethostent __P((void));
struct hostent *getipnodebyaddr __P((const void *, size_t, int, int *));
struct hostent *getipnodebyname __P((const char *, int, int, int *));
struct netent *getnetbyaddr __P((unsigned long, int));
struct netent *getnetbyname __P((const char *));
struct netent *getnetent __P((void));
struct protoent *getprotobyname __P((const char *));
struct protoent *getprotobynumber __P((int));
struct protoent *getprotoent __P((void));
struct servent *getservbyname __P((const char *, const char *));
struct servent *getservbyport __P((int, const char *));
struct servent *getservent __P((void));
void herror __P((const char *));
const char *hstrerror __P((int));
void sethostent __P((int));
/* void sethostfile __P((const char *)); */
void setnetent __P((int));
void setprotoent __P((int));
void setservent __P((int));
int getaddrinfo __P((const char *, const char *,
const struct addrinfo *, struct addrinfo **));
int getnameinfo __P((const struct sockaddr *, size_t, char *,
size_t, char *, size_t, int));
void freeaddrinfo __P((struct addrinfo *));
const char *gai_strerror __P((int));
struct hostent *getipnodebyname __P((const char *, int, int, int *));
struct hostent *getipnodebyaddr __P((const void *, size_t, int, int *));
void freehostent __P((struct hostent *));
#ifdef __GLIBC__
int getnetgrent __P((/* const */ char **, /* const */ char **,
/* const */ char **));
void setnetgrent __P((const char *));
void endnetgrent __P((void));
int innetgr __P((const char *, const char *, const char *,
const char *));
#endif
#ifdef _REENTRANT
#if defined(__hpux) || defined(__osf__) || defined(_AIX)
int gethostbyaddr_r __P((const char *, int, int, struct hostent *,
struct hostent_data *));
int gethostbyname_r __P((const char *, struct hostent *,
struct hostent_data *));
int gethostent_r __P((struct hostent *, struct hostent_data *));
#if defined(_AIX)
void sethostent_r __P((int, struct hostent_data *));
#else
int sethostent_r __P((int, struct hostent_data *));
#endif
#if defined(__hpux)
int endhostent_r __P((struct hostent_data *));
#else
void endhostent_r __P((struct hostent_data *));
#endif
#if defined(__hpux) || defined(__osf__)
int getnetbyaddr_r __P((int, int,
struct netent *, struct netent_data *));
#else
int getnetbyaddr_r __P((long, int,
struct netent *, struct netent_data *));
#endif
int getnetbyname_r __P((const char *,
struct netent *, struct netent_data *));
int getnetent_r __P((struct netent *, struct netent_data *));
int setnetent_r __P((int, struct netent_data *));
#ifdef __hpux
int endnetent_r __P((struct netent_data *buffer));
#else
void endnetent_r __P((struct netent_data *buffer));
#endif
int getprotobyname_r __P((const char *,
struct protoent *, struct protoent_data *));
int getprotobynumber_r __P((int,
struct protoent *, struct protoent_data *));
int getprotoent_r __P((struct protoent *, struct protoent_data *));
int setprotoent_r __P((int, struct protoent_data *));
#ifdef __hpux
int endprotoent_r __P((struct protoent_data *));
#else
void endprotoent_r __P((struct protoent_data *));
#endif
int getservbyname_r __P((const char *, const char *,
struct servent *, struct servent_data *));
int getservbyport_r __P((int, const char *,
struct servent *, struct servent_data *));
int getservent_r __P((struct servent *, struct servent_data *));
int setservent_r __P((int, struct servent_data *));
#ifdef __hpux
int endservent_r __P((struct servent_data *));
#else
void endservent_r __P((struct servent_data *));
#endif
#ifdef _AIX
int setnetgrent_r __P((char *, void **));
void endnetgrent_r __P((void **));
/*
* Note: AIX's netdb.h declares innetgr_r() as:
* int innetgr_r(char *, char *, char *, char *, struct innetgr_data *);
*/
int innetgr_r __P((const char *, const char *, const char *,
const char *));
#endif
#else
/* defined(sun) || defined(bsdi) */
#if defined(__GLIBC__) || defined(__FreeBSD__) && (__FreeBSD_version + 0 >= 601103)
int gethostbyaddr_r __P((const char *, int, int, struct hostent *,
char *, size_t, struct hostent **, int *));
int gethostbyname_r __P((const char *, struct hostent *,
char *, size_t, struct hostent **, int *));
int gethostent_r __P((struct hostent *, char *, size_t,
struct hostent **, int *));
#else
struct hostent *gethostbyaddr_r __P((const char *, int, int, struct hostent *,
char *, int, int *));
struct hostent *gethostbyname_r __P((const char *, struct hostent *,
char *, int, int *));
struct hostent *gethostent_r __P((struct hostent *, char *, int, int *));
#endif
void sethostent_r __P((int));
void endhostent_r __P((void));
#if defined(__GLIBC__) || defined(__FreeBSD__) && (__FreeBSD_version + 0 >= 601103)
int getnetbyname_r __P((const char *, struct netent *,
char *, size_t, struct netent **, int*));
int getnetbyaddr_r __P((unsigned long int, int, struct netent *,
char *, size_t, struct netent **, int*));
int getnetent_r __P((struct netent *, char *, size_t, struct netent **, int*));
#else
struct netent *getnetbyname_r __P((const char *, struct netent *,
char *, int));
struct netent *getnetbyaddr_r __P((long, int, struct netent *,
char *, int));
struct netent *getnetent_r __P((struct netent *, char *, int));
#endif
void setnetent_r __P((int));
void endnetent_r __P((void));
#if defined(__GLIBC__) || defined(__FreeBSD__) && (__FreeBSD_version + 0 >= 601103)
int getprotobyname_r __P((const char *, struct protoent *, char *,
size_t, struct protoent **));
int getprotobynumber_r __P((int, struct protoent *, char *, size_t,
struct protoent **));
int getprotoent_r __P((struct protoent *, char *, size_t, struct protoent **));
#else
struct protoent *getprotobyname_r __P((const char *,
struct protoent *, char *, int));
struct protoent *getprotobynumber_r __P((int,
struct protoent *, char *, int));
struct protoent *getprotoent_r __P((struct protoent *, char *, int));
#endif
void setprotoent_r __P((int));
void endprotoent_r __P((void));
#if defined(__GLIBC__) || defined(__FreeBSD__) && (__FreeBSD_version + 0 >= 601103)
int getservbyname_r __P((const char *name, const char *,
struct servent *, char *, size_t, struct servent **));
int getservbyport_r __P((int port, const char *,
struct servent *, char *, size_t, struct servent **));
int getservent_r __P((struct servent *, char *, size_t, struct servent **));
#else
struct servent *getservbyname_r __P((const char *name, const char *,
struct servent *, char *, int));
struct servent *getservbyport_r __P((int port, const char *,
struct servent *, char *, int));
struct servent *getservent_r __P((struct servent *, char *, int));
#endif
void setservent_r __P((int));
void endservent_r __P((void));
#ifdef __GLIBC__
int getnetgrent_r __P((char **, char **, char **, char *, size_t));
#endif
#endif
#endif
__END_DECLS
/* This is nec'y to make this include file properly replace the sun version. */
#ifdef sun
#ifdef __GNU_LIBRARY__
#include <rpc/netdb.h>
#else
struct rpcent {
char *r_name; /*%< name of server for this rpc program */
char **r_aliases; /*%< alias list */
int r_number; /*%< rpc program number */
};
struct rpcent *getrpcbyname(), *getrpcbynumber(), *getrpcent();
#endif /* __GNU_LIBRARY__ */
#endif /* sun */
#endif /* !_NETDB_H_ */
/*! \file */

View File

@ -1,26 +0,0 @@
#ifndef netgroup_h
#define netgroup_h
#ifndef __GLIBC__
/*
* The standard is crazy. These values "belong" to getnetgrent() and
* shouldn't be altered by the caller.
*/
int getnetgrent __P((/* const */ char **, /* const */ char **,
/* const */ char **));
int getnetgrent_r __P((char **, char **, char **, char *, int));
void endnetgrent __P((void));
#ifdef __osf__
int innetgr __P((char *, char *, char *, char *));
void setnetgrent __P((char *));
#else
void setnetgrent __P((const char *));
int innetgr __P((const char *, const char *, const char *, const char *));
#endif
#endif
#endif
/*! \file */

View File

@ -1,69 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999 by Internet Software Consortium, Inc.
*
* 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 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: res_update.h,v 1.2.18.1 2005/04/27 05:00:49 sra Exp $
*/
#ifndef __RES_UPDATE_H
#define __RES_UPDATE_H
/*! \file */
#include <sys/types.h>
#include <arpa/nameser.h>
#include <isc/list.h>
#include <resolv.h>
/*%
* This RR-like structure is particular to UPDATE.
*/
struct ns_updrec {
LINK(struct ns_updrec) r_link, r_glink;
ns_sect r_section; /*%< ZONE/PREREQUISITE/UPDATE */
char * r_dname; /*%< owner of the RR */
ns_class r_class; /*%< class number */
ns_type r_type; /*%< type number */
u_int32_t r_ttl; /*%< time to live */
u_char * r_data; /*%< rdata fields as text string */
u_int r_size; /*%< size of r_data field */
int r_opcode; /*%< type of operation */
/* following fields for private use by the resolver/server routines */
struct databuf *r_dp; /*%< databuf to process */
struct databuf *r_deldp; /*%< databuf's deleted/overwritten */
u_int r_zone; /*%< zone number on server */
};
typedef struct ns_updrec ns_updrec;
typedef LIST(ns_updrec) ns_updque;
#define res_mkupdate __res_mkupdate
#define res_update __res_update
#define res_mkupdrec __res_mkupdrec
#define res_freeupdrec __res_freeupdrec
#define res_nmkupdate __res_nmkupdate
#define res_nupdate __res_nupdate
int res_mkupdate __P((ns_updrec *, u_char *, int));
int res_update __P((ns_updrec *));
ns_updrec * res_mkupdrec __P((int, const char *, u_int, u_int, u_long));
void res_freeupdrec __P((ns_updrec *));
int res_nmkupdate __P((res_state, ns_updrec *, u_char *, int));
int res_nupdate __P((res_state, ns_updrec *, ns_tsig_key *));
#endif /*__RES_UPDATE_H*/
/*! \file */

View File

@ -1,509 +0,0 @@
/*
* Copyright (c) 1983, 1987, 1989
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Portions 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 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.
*/
/*%
* @(#)resolv.h 8.1 (Berkeley) 6/2/93
* $Id: resolv.h,v 1.19.18.4 2008/04/03 23:15:15 marka Exp $
*/
#ifndef _RESOLV_H_
#define _RESOLV_H_
#include <sys/param.h>
#if (!defined(BSD)) || (BSD < 199306)
# include <sys/bitypes.h>
#else
# include <sys/types.h>
#endif
#include <sys/cdefs.h>
#include <sys/socket.h>
#include <stdio.h>
#include <arpa/nameser.h>
/*%
* Revision information. This is the release date in YYYYMMDD format.
* It can change every day so the right thing to do with it is use it
* in preprocessor commands such as "#if (__RES > 19931104)". Do not
* compare for equality; rather, use it to determine whether your resolver
* is new enough to contain a certain feature.
*/
#define __RES 20030124
/*%
* This used to be defined in res_query.c, now it's in herror.c.
* [XXX no it's not. It's in irs/irs_data.c]
* It was
* never extern'd by any *.h file before it was placed here. For thread
* aware programs, the last h_errno value set is stored in res->h_errno.
*
* XXX: There doesn't seem to be a good reason for exposing RES_SET_H_ERRNO
* (and __h_errno_set) to the public via <resolv.h>.
* XXX: __h_errno_set is really part of IRS, not part of the resolver.
* If somebody wants to build and use a resolver that doesn't use IRS,
* what do they do? Perhaps something like
* #ifdef WANT_IRS
* # define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x)
* #else
* # define RES_SET_H_ERRNO(r,x) (h_errno = (r)->res_h_errno = (x))
* #endif
*/
#define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x)
struct __res_state; /*%< forward */
__BEGIN_DECLS
void __h_errno_set(struct __res_state *res, int err);
__END_DECLS
/*%
* Resolver configuration file.
* Normally not present, but may contain the address of the
* initial name server(s) to query and the domain search list.
*/
#ifndef _PATH_RESCONF
#define _PATH_RESCONF "/etc/resolv.conf"
#endif
typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
res_sendhookact;
#ifndef __PMT
#if defined(__STDC__) || defined(__cplusplus)
#define __PMT(args) args
#else
#define __PMT(args) ()
#endif
#endif
typedef res_sendhookact (*res_send_qhook)__PMT((struct sockaddr * const *,
const u_char **, int *,
u_char *, int, int *));
typedef res_sendhookact (*res_send_rhook)__PMT((const struct sockaddr *,
const u_char *, int, u_char *,
int, int *));
struct res_sym {
int number; /*%< Identifying number, like T_MX */
const char * name; /*%< Its symbolic name, like "MX" */
const char * humanname; /*%< Its fun name, like "mail exchanger" */
};
/*%
* Global defines and variables for resolver stub.
*/
#define MAXNS 3 /*%< max # name servers we'll track */
#define MAXDFLSRCH 3 /*%< # default domain levels to try */
#define MAXDNSRCH 6 /*%< max # domains in search path */
#define LOCALDOMAINPARTS 2 /*%< min levels in name that is "local" */
#define RES_TIMEOUT 5 /*%< min. seconds between retries */
#define MAXRESOLVSORT 10 /*%< number of net to sort on */
#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_MAXTIME 65535 /*%< Infinity, in milliseconds. */
struct __res_state_ext;
struct __res_state {
int retrans; /*%< retransmission time interval */
int retry; /*%< number of times to retransmit */
#ifdef sun
u_int options; /*%< option flags - see below. */
#else
u_long options; /*%< option flags - see below. */
#endif
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 */
char defdname[256]; /*%< default domain (deprecated) */
#ifdef sun
u_int pfcode; /*%< RES_PRF_ flags - see below. */
#else
u_long pfcode; /*%< RES_PRF_ flags - see below. */
#endif
unsigned ndots:4; /*%< threshold for initial abs. query */
unsigned nsort:4; /*%< number of elements in sort_list[] */
char unused[3];
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 */
u_int _pad; /*%< make _u 64 bit aligned */
union {
/* On an 32-bit arch this means 512b total. */
char pad[72 - 4*sizeof (int) - 2*sizeof (void *)];
struct {
u_int16_t nscount;
u_int16_t nstimes[MAXNS]; /*%< ms. */
int nssocks[MAXNS];
struct __res_state_ext *ext; /*%< extention for IPv6 */
} _ext;
} _u;
};
typedef struct __res_state *res_state;
union res_sockaddr_union {
struct sockaddr_in sin;
#ifdef IN6ADDR_ANY_INIT
struct sockaddr_in6 sin6;
#endif
#ifdef ISC_ALIGN64
int64_t __align64; /*%< 64bit alignment */
#else
int32_t __align32; /*%< 32bit alignment */
#endif
char __space[128]; /*%< max size */
};
/*%
* Resolver flags (used to be discrete per-module statics ints).
*/
#define RES_F_VC 0x00000001 /*%< socket is TCP */
#define RES_F_CONN 0x00000002 /*%< socket is connected */
#define RES_F_EDNS0ERR 0x00000004 /*%< EDNS0 caused errors */
#define RES_F__UNUSED 0x00000008 /*%< (unused) */
#define RES_F_LASTMASK 0x000000F0 /*%< ordinal server of last res_nsend */
#define RES_F_LASTSHIFT 4 /*%< bit position of LASTMASK "flag" */
#define RES_GETLAST(res) (((res)._flags & RES_F_LASTMASK) >> RES_F_LASTSHIFT)
/* res_findzonecut2() options */
#define RES_EXHAUSTIVE 0x00000001 /*%< always do all queries */
#define RES_IPV4ONLY 0x00000002 /*%< IPv4 only */
#define RES_IPV6ONLY 0x00000004 /*%< IPv6 only */
/*%
* Resolver options (keep these in synch with res_debug.c, please)
*/
#define RES_INIT 0x00000001 /*%< address initialized */
#define RES_DEBUG 0x00000002 /*%< print debug messages */
#define RES_AAONLY 0x00000004 /*%< authoritative answers only (!IMPL)*/
#define RES_USEVC 0x00000008 /*%< use virtual circuit */
#define RES_PRIMARY 0x00000010 /*%< query primary server only (!IMPL) */
#define RES_IGNTC 0x00000020 /*%< ignore trucation errors */
#define RES_RECURSE 0x00000040 /*%< recursion desired */
#define RES_DEFNAMES 0x00000080 /*%< use default domain name */
#define RES_STAYOPEN 0x00000100 /*%< Keep TCP socket open */
#define RES_DNSRCH 0x00000200 /*%< search up local domain tree */
#define RES_INSECURE1 0x00000400 /*%< type 1 security disabled */
#define RES_INSECURE2 0x00000800 /*%< type 2 security disabled */
#define RES_NOALIASES 0x00001000 /*%< shuts off HOSTALIASES feature */
#define RES_USE_INET6 0x00002000 /*%< use/map IPv6 in gethostbyname() */
#define RES_ROTATE 0x00004000 /*%< rotate ns list after each query */
#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_NSID 0x00040000 /*%< request name server ID */
#define RES_NOTLDQUERY 0x00100000 /*%< don't unqualified name as a tld */
#define RES_USE_DNSSEC 0x00200000 /*%< use DNSSEC using OK bit in OPT */
/* #define RES_DEBUG2 0x00400000 */ /* nslookup internal */
/* KAME extensions: use higher bit to avoid conflict with ISC use */
#define RES_USE_DNAME 0x10000000 /*%< use DNAME */
#define RES_USE_EDNS0 0x40000000 /*%< use EDNS0 if configured */
#define RES_NO_NIBBLE2 0x80000000 /*%< disable alternate nibble lookup */
#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | \
RES_DNSRCH | RES_NO_NIBBLE2)
/*%
* Resolver "pfcode" values. Used by dig.
*/
#define RES_PRF_STATS 0x00000001
#define RES_PRF_UPDATE 0x00000002
#define RES_PRF_CLASS 0x00000004
#define RES_PRF_CMD 0x00000008
#define RES_PRF_QUES 0x00000010
#define RES_PRF_ANS 0x00000020
#define RES_PRF_AUTH 0x00000040
#define RES_PRF_ADD 0x00000080
#define RES_PRF_HEAD1 0x00000100
#define RES_PRF_HEAD2 0x00000200
#define RES_PRF_TTLID 0x00000400
#define RES_PRF_HEADX 0x00000800
#define RES_PRF_QUERY 0x00001000
#define RES_PRF_REPLY 0x00002000
#define RES_PRF_INIT 0x00004000
#define RES_PRF_TRUNC 0x00008000
/* 0x00010000 */
/* Things involving an internal (static) resolver context. */
#ifdef _REENTRANT
__BEGIN_DECLS
extern struct __res_state *__res_state(void);
__END_DECLS
#define _res (*__res_state())
#else
#ifdef __linux
__BEGIN_DECLS
extern struct __res_state * __res_state(void);
__END_DECLS
#endif
#ifndef __BIND_NOSTATIC
extern struct __res_state _res;
#endif
#endif
#ifndef __BIND_NOSTATIC
#define fp_nquery __fp_nquery
#define fp_query __fp_query
#define hostalias __hostalias
#define p_query __p_query
#define res_close __res_close
#define res_init __res_init
#define res_isourserver __res_isourserver
#define res_mkquery __res_mkquery
#define res_query __res_query
#define res_querydomain __res_querydomain
#define res_search __res_search
#define res_send __res_send
#define res_sendsigned __res_sendsigned
__BEGIN_DECLS
void fp_nquery __P((const u_char *, int, FILE *));
void fp_query __P((const u_char *, FILE *));
const char * hostalias __P((const char *));
void p_query __P((const u_char *));
void res_close __P((void));
int res_init __P((void));
int res_isourserver __P((const struct sockaddr_in *));
int res_mkquery __P((int, const char *, int, int, const u_char *,
int, const u_char *, u_char *, int));
int res_query __P((const char *, int, int, u_char *, int));
int res_querydomain __P((const char *, const char *, int, int,
u_char *, int));
int res_search __P((const char *, int, int, u_char *, int));
int res_send __P((const u_char *, int, u_char *, int));
int res_sendsigned __P((const u_char *, int, ns_tsig_key *,
u_char *, int));
__END_DECLS
#endif
#if !defined(SHARED_LIBBIND) || defined(LIB)
/*
* If libbind is a shared object (well, DLL anyway)
* these externs break the linker when resolv.h is
* included by a lib client (like named)
* Make them go away if a client is including this
*
*/
extern const struct res_sym __p_key_syms[];
extern const struct res_sym __p_cert_syms[];
extern const struct res_sym __p_class_syms[];
extern const struct res_sym __p_type_syms[];
extern const struct res_sym __p_rcode_syms[];
#endif /* SHARED_LIBBIND */
#define b64_ntop __b64_ntop
#define b64_pton __b64_pton
#define dn_comp __dn_comp
#define dn_count_labels __dn_count_labels
#define dn_expand __dn_expand
#define dn_skipname __dn_skipname
#define fp_resstat __fp_resstat
#define loc_aton __loc_aton
#define loc_ntoa __loc_ntoa
#define p_cdname __p_cdname
#define p_cdnname __p_cdnname
#define p_class __p_class
#define p_fqname __p_fqname
#define p_fqnname __p_fqnname
#define p_option __p_option
#define p_secstodate __p_secstodate
#define p_section __p_section
#define p_time __p_time
#define p_type __p_type
#define p_rcode __p_rcode
#define p_sockun __p_sockun
#define putlong __putlong
#define putshort __putshort
#define res_dnok __res_dnok
#define res_findzonecut __res_findzonecut
#define res_findzonecut2 __res_findzonecut2
#define res_hnok __res_hnok
#define res_hostalias __res_hostalias
#define res_mailok __res_mailok
#define res_nameinquery __res_nameinquery
#define res_nclose __res_nclose
#define res_ninit __res_ninit
#define res_nmkquery __res_nmkquery
#define res_pquery __res_pquery
#define res_nquery __res_nquery
#define res_nquerydomain __res_nquerydomain
#define res_nsearch __res_nsearch
#define res_nsend __res_nsend
#define res_nsendsigned __res_nsendsigned
#define res_nisourserver __res_nisourserver
#define res_ownok __res_ownok
#define res_queriesmatch __res_queriesmatch
#define res_randomid __res_randomid
#define sym_ntop __sym_ntop
#define sym_ntos __sym_ntos
#define sym_ston __sym_ston
#define res_nopt __res_nopt
#define res_nopt_rdata __res_nopt_rdata
#define res_ndestroy __res_ndestroy
#define res_nametoclass __res_nametoclass
#define res_nametotype __res_nametotype
#define res_setservers __res_setservers
#define res_getservers __res_getservers
#define res_buildprotolist __res_buildprotolist
#define res_destroyprotolist __res_destroyprotolist
#define res_destroyservicelist __res_destroyservicelist
#define res_get_nibblesuffix __res_get_nibblesuffix
#define res_get_nibblesuffix2 __res_get_nibblesuffix2
#define res_ourserver_p __res_ourserver_p
#define res_protocolname __res_protocolname
#define res_protocolnumber __res_protocolnumber
#define res_send_setqhook __res_send_setqhook
#define res_send_setrhook __res_send_setrhook
#define res_servicename __res_servicename
#define res_servicenumber __res_servicenumber
__BEGIN_DECLS
int res_hnok __P((const char *));
int res_ownok __P((const char *));
int res_mailok __P((const char *));
int res_dnok __P((const char *));
int sym_ston __P((const struct res_sym *, const char *, int *));
const char * sym_ntos __P((const struct res_sym *, int, int *));
const char * sym_ntop __P((const struct res_sym *, int, int *));
int b64_ntop __P((u_char const *, size_t, char *, size_t));
int b64_pton __P((char const *, u_char *, size_t));
int loc_aton __P((const char *, u_char *));
const char * loc_ntoa __P((const u_char *, char *));
int dn_skipname __P((const u_char *, const u_char *));
void putlong __P((u_int32_t, u_char *));
void putshort __P((u_int16_t, u_char *));
#ifndef __ultrix__
u_int16_t _getshort __P((const u_char *));
u_int32_t _getlong __P((const u_char *));
#endif
const char * p_class __P((int));
const char * p_time __P((u_int32_t));
const char * p_type __P((int));
const char * p_rcode __P((int));
const char * p_sockun __P((union res_sockaddr_union, char *, size_t));
const u_char * p_cdnname __P((const u_char *, const u_char *, int, FILE *));
const u_char * p_cdname __P((const u_char *, const u_char *, FILE *));
const u_char * p_fqnname __P((const u_char *, const u_char *,
int, char *, int));
const u_char * p_fqname __P((const u_char *, const u_char *, FILE *));
const char * p_option __P((u_long));
char * p_secstodate __P((u_long));
int dn_count_labels __P((const char *));
int dn_comp __P((const char *, u_char *, int,
u_char **, u_char **));
int dn_expand __P((const u_char *, const u_char *, const u_char *,
char *, int));
u_int res_randomid __P((void));
int res_nameinquery __P((const char *, int, int, const u_char *,
const u_char *));
int res_queriesmatch __P((const u_char *, const u_char *,
const u_char *, const u_char *));
const char * p_section __P((int, int));
/* Things involving a resolver context. */
int res_ninit __P((res_state));
int res_nisourserver __P((const res_state,
const struct sockaddr_in *));
void fp_resstat __P((const res_state, FILE *));
void res_pquery __P((const res_state, const u_char *, int, FILE *));
const char * res_hostalias __P((const res_state, const char *,
char *, size_t));
int res_nquery __P((res_state, const char *, int, int,
u_char *, int));
int res_nsearch __P((res_state, const char *, int, int, u_char *,
int));
int res_nquerydomain __P((res_state, const char *, const char *,
int, int, u_char *, int));
int res_nmkquery __P((res_state, int, const char *, int, int,
const u_char *, int, const u_char *,
u_char *, int));
int res_nsend __P((res_state, const u_char *, int, u_char *, int));
int res_nsendsigned __P((res_state, const u_char *, int,
ns_tsig_key *, u_char *, int));
int res_findzonecut __P((res_state, const char *, ns_class, int,
char *, size_t, struct in_addr *, int));
int res_findzonecut2 __P((res_state, const char *, ns_class, int,
char *, size_t,
union res_sockaddr_union *, int));
void res_nclose __P((res_state));
int res_nopt __P((res_state, int, u_char *, int, int));
int res_nopt_rdata __P((res_state, int, u_char *, int, u_char *,
u_short, u_short, u_char *));
void res_send_setqhook __P((res_send_qhook));
void res_send_setrhook __P((res_send_rhook));
int __res_vinit __P((res_state, int));
void res_destroyservicelist __P((void));
const char * res_servicename __P((u_int16_t, const char *));
const char * res_protocolname __P((int));
void res_destroyprotolist __P((void));
void res_buildprotolist __P((void));
const char * res_get_nibblesuffix __P((res_state));
const char * res_get_nibblesuffix2 __P((res_state));
void res_ndestroy __P((res_state));
u_int16_t res_nametoclass __P((const char *, int *));
u_int16_t res_nametotype __P((const char *, int *));
void res_setservers __P((res_state,
const union res_sockaddr_union *, int));
int res_getservers __P((res_state,
union res_sockaddr_union *, int));
__END_DECLS
#endif /* !_RESOLV_H_ */
/*! \file */

View File

@ -1,47 +0,0 @@
#ifndef _RESOLV_MT_H
#define _RESOLV_MT_H
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
/* Access functions for the libresolv private interface */
int __res_enable_mt(void);
int __res_disable_mt(void);
/* Per-thread context */
typedef struct {
int no_hosts_fallback_private;
int retry_save;
int retry_private;
char inet_nsap_ntoa_tmpbuf[255*3];
char sym_ntos_unname[20];
char sym_ntop_unname[20];
char p_option_nbuf[40];
char p_time_nbuf[40];
char precsize_ntoa_retbuf[sizeof "90000000.00"];
char loc_ntoa_tmpbuf[sizeof
"1000 60 60.000 N 1000 60 60.000 W -12345678.00m 90000000.00m 90000000.00m 90000000.00m"];
char p_secstodate_output[15];
} mtctxres_t;
/* Thread-specific data (TSD) */
mtctxres_t *___mtctxres(void);
#define mtctxres (___mtctxres())
/* Various static data that should be TSD */
#define sym_ntos_unname (mtctxres->sym_ntos_unname)
#define sym_ntop_unname (mtctxres->sym_ntop_unname)
#define inet_nsap_ntoa_tmpbuf (mtctxres->inet_nsap_ntoa_tmpbuf)
#define p_option_nbuf (mtctxres->p_option_nbuf)
#define p_time_nbuf (mtctxres->p_time_nbuf)
#define precsize_ntoa_retbuf (mtctxres->precsize_ntoa_retbuf)
#define loc_ntoa_tmpbuf (mtctxres->loc_ntoa_tmpbuf)
#define p_secstodate_output (mtctxres->p_secstodate_output)
#endif /* _RESOLV_MT_H */

View File

@ -1,35 +0,0 @@
# Copyright (C) 2004, 2008 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2001 Internet Software Consortium.
#
# Permission to use, copy, modify, and/or 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 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: Makefile.in,v 1.5.18.2 2008/03/20 23:46:01 tbox Exp $
srcdir= @srcdir@
VPATH = @srcdir@
OBJS= inet_addr.@O@ inet_cidr_ntop.@O@ inet_cidr_pton.@O@ inet_data.@O@ \
inet_lnaof.@O@ inet_makeaddr.@O@ inet_net_ntop.@O@ inet_net_pton.@O@ \
inet_neta.@O@ inet_netof.@O@ inet_network.@O@ inet_ntoa.@O@ \
inet_ntop.@O@ inet_pton.@O@ nsap_addr.@O@
SRCS= inet_addr.c inet_cidr_ntop.c inet_cidr_pton.c inet_data.c \
inet_lnaof.c inet_makeaddr.c inet_net_ntop.c inet_net_pton.c \
inet_neta.c inet_netof.c inet_network.c inet_ntoa.c \
inet_ntop.c inet_pton.c nsap_addr.c
TARGETS= ${OBJS}
CINCLUDES= -I.. -I../include -I${srcdir}/../include
@BIND9_MAKE_RULES@

View File

@ -1,208 +0,0 @@
/*
* Copyright (c) 1983, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
* 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, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
* CORPORATION 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.
*/
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Portions 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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
static const char rcsid[] = "$Id: inet_addr.c,v 1.4.18.1 2005/04/27 05:00:52 sra Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
#include <sys/types.h>
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <ctype.h>
#include "port_after.h"
/*%
* Ascii internet address interpretation routine.
* The value returned is in network order.
*/
u_long
inet_addr(const char *cp) {
struct in_addr val;
if (inet_aton(cp, &val))
return (val.s_addr);
return (INADDR_NONE);
}
/*%
* Check whether "cp" is a valid ascii representation
* of an Internet address and convert to a binary address.
* Returns 1 if the address is valid, 0 if not.
* This replaces inet_addr, the return value from which
* cannot distinguish between failure and a local broadcast address.
*/
int
inet_aton(const char *cp, struct in_addr *addr) {
u_long val;
int base, n;
char c;
u_int8_t parts[4];
u_int8_t *pp = parts;
int digit;
c = *cp;
for (;;) {
/*
* Collect number up to ``.''.
* Values are specified as for C:
* 0x=hex, 0=octal, isdigit=decimal.
*/
if (!isdigit((unsigned char)c))
return (0);
val = 0; base = 10; digit = 0;
if (c == '0') {
c = *++cp;
if (c == 'x' || c == 'X')
base = 16, c = *++cp;
else {
base = 8;
digit = 1 ;
}
}
for (;;) {
if (isascii(c) && isdigit((unsigned char)c)) {
if (base == 8 && (c == '8' || c == '9'))
return (0);
val = (val * base) + (c - '0');
c = *++cp;
digit = 1;
} else if (base == 16 && isascii(c) &&
isxdigit((unsigned char)c)) {
val = (val << 4) |
(c + 10 - (islower((unsigned char)c) ? 'a' : 'A'));
c = *++cp;
digit = 1;
} else
break;
}
if (c == '.') {
/*
* Internet format:
* a.b.c.d
* a.b.c (with c treated as 16 bits)
* a.b (with b treated as 24 bits)
*/
if (pp >= parts + 3 || val > 0xffU)
return (0);
*pp++ = val;
c = *++cp;
} else
break;
}
/*
* Check for trailing characters.
*/
if (c != '\0' && (!isascii(c) || !isspace((unsigned char)c)))
return (0);
/*
* Did we get a valid digit?
*/
if (!digit)
return (0);
/*
* Concoct the address according to
* the number of parts specified.
*/
n = pp - parts + 1;
switch (n) {
case 1: /*%< a -- 32 bits */
break;
case 2: /*%< a.b -- 8.24 bits */
if (val > 0xffffffU)
return (0);
val |= parts[0] << 24;
break;
case 3: /*%< a.b.c -- 8.8.16 bits */
if (val > 0xffffU)
return (0);
val |= (parts[0] << 24) | (parts[1] << 16);
break;
case 4: /*%< a.b.c.d -- 8.8.8.8 bits */
if (val > 0xffU)
return (0);
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
break;
}
if (addr != NULL)
addr->s_addr = htonl(val);
return (1);
}
/*! \file */

View File

@ -1,263 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1998,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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_cidr_ntop.c,v 1.4.18.3 2006/10/11 02:32:47 marka Exp $";
#endif
#include "port_before.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "port_after.h"
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintf/**/x)
#else
# define SPRINTF(x) ((size_t)sprintf x)
#endif
static char *
inet_cidr_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size);
static char *
inet_cidr_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size);
/*%
* char *
* inet_cidr_ntop(af, src, bits, dst, size)
* convert network address from network to presentation format.
* "src"'s size is determined from its "af".
* return:
* pointer to dst, or NULL if an error occurred (check errno).
* note:
* 192.5.5.1/28 has a nonzero host part, which means it isn't a network
* as called for by inet_net_ntop() but it can be a host address with
* an included netmask.
* author:
* Paul Vixie (ISC), October 1998
*/
char *
inet_cidr_ntop(int af, const void *src, int bits, char *dst, size_t size) {
switch (af) {
case AF_INET:
return (inet_cidr_ntop_ipv4(src, bits, dst, size));
case AF_INET6:
return (inet_cidr_ntop_ipv6(src, bits, dst, size));
default:
errno = EAFNOSUPPORT;
return (NULL);
}
}
static int
decoct(const u_char *src, int bytes, char *dst, size_t size) {
char *odst = dst;
char *t;
int b;
for (b = 1; b <= bytes; b++) {
if (size < sizeof "255.")
return (0);
t = dst;
dst += SPRINTF((dst, "%u", *src++));
if (b != bytes) {
*dst++ = '.';
*dst = '\0';
}
size -= (size_t)(dst - t);
}
return (dst - odst);
}
/*%
* static char *
* inet_cidr_ntop_ipv4(src, bits, dst, size)
* convert IPv4 network address from network to presentation format.
* "src"'s size is determined from its "af".
* return:
* pointer to dst, or NULL if an error occurred (check errno).
* note:
* network byte order assumed. this means 192.5.5.240/28 has
* 0b11110000 in its fourth octet.
* author:
* Paul Vixie (ISC), October 1998
*/
static char *
inet_cidr_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size) {
char *odst = dst;
size_t len = 4;
size_t b;
size_t bytes;
if ((bits < -1) || (bits > 32)) {
errno = EINVAL;
return (NULL);
}
/* Find number of significant bytes in address. */
if (bits == -1)
len = 4;
else
for (len = 1, b = 1 ; b < 4U; b++)
if (*(src + b))
len = b + 1;
/* Format whole octets plus nonzero trailing octets. */
bytes = (((bits <= 0) ? 1 : bits) + 7) / 8;
if (len > bytes)
bytes = len;
b = decoct(src, bytes, dst, size);
if (b == 0U)
goto emsgsize;
dst += b;
size -= b;
if (bits != -1) {
/* Format CIDR /width. */
if (size < sizeof "/32")
goto emsgsize;
dst += SPRINTF((dst, "/%u", bits));
}
return (odst);
emsgsize:
errno = EMSGSIZE;
return (NULL);
}
static char *
inet_cidr_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) {
/*
* Note that int32_t and int16_t need only be "at least" large enough
* to contain a value of the specified size. On some systems, like
* Crays, there is no such thing as an integer variable with 16 bits.
* Keep this in mind if you think this function should have been coded
* to use pointer overlays. All the world's not a VAX.
*/
char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255/128"];
char *tp;
struct { int base, len; } best, cur;
u_int words[NS_IN6ADDRSZ / NS_INT16SZ];
int i;
if ((bits < -1) || (bits > 128)) {
errno = EINVAL;
return (NULL);
}
/*
* Preprocess:
* Copy the input (bytewise) array into a wordwise array.
* Find the longest run of 0x00's in src[] for :: shorthanding.
*/
memset(words, '\0', sizeof words);
for (i = 0; i < NS_IN6ADDRSZ; i++)
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
best.base = -1;
best.len = 0;
cur.base = -1;
cur.len = 0;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
if (words[i] == 0) {
if (cur.base == -1)
cur.base = i, cur.len = 1;
else
cur.len++;
} else {
if (cur.base != -1) {
if (best.base == -1 || cur.len > best.len)
best = cur;
cur.base = -1;
}
}
}
if (cur.base != -1) {
if (best.base == -1 || cur.len > best.len)
best = cur;
}
if (best.base != -1 && best.len < 2)
best.base = -1;
/*
* Format the result.
*/
tp = tmp;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
/* Are we inside the best run of 0x00's? */
if (best.base != -1 && i >= best.base &&
i < (best.base + best.len)) {
if (i == best.base)
*tp++ = ':';
continue;
}
/* Are we following an initial run of 0x00s or any real hex? */
if (i != 0)
*tp++ = ':';
/* Is this address an encapsulated IPv4? */
if (i == 6 && best.base == 0 && (best.len == 6 ||
(best.len == 7 && words[7] != 0x0001) ||
(best.len == 5 && words[5] == 0xffff))) {
int n;
if (src[15] || bits == -1 || bits > 120)
n = 4;
else if (src[14] || bits > 112)
n = 3;
else
n = 2;
n = decoct(src+12, n, tp, sizeof tmp - (tp - tmp));
if (n == 0) {
errno = EMSGSIZE;
return (NULL);
}
tp += strlen(tp);
break;
}
tp += SPRINTF((tp, "%x", words[i]));
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) ==
(NS_IN6ADDRSZ / NS_INT16SZ))
*tp++ = ':';
*tp = '\0';
if (bits != -1)
tp += SPRINTF((tp, "/%u", bits));
/*
* Check for overflow, copy, and we're done.
*/
if ((size_t)(tp - tmp) > size) {
errno = EMSGSIZE;
return (NULL);
}
strcpy(dst, tmp);
return (dst);
}
/*! \file */

View File

@ -1,277 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1998,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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_cidr_pton.c,v 1.5.18.1 2005/04/27 05:00:53 sra Exp $";
#endif
#include "port_before.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include <isc/assertions.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "port_after.h"
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintf/**/x)
#else
# define SPRINTF(x) ((size_t)sprintf x)
#endif
static int inet_cidr_pton_ipv4 __P((const char *src, u_char *dst,
int *bits, int ipv6));
static int inet_cidr_pton_ipv6 __P((const char *src, u_char *dst,
int *bits));
static int getbits(const char *, int ipv6);
/*%
* int
* inet_cidr_pton(af, src, dst, *bits)
* convert network address from presentation to network format.
* accepts inet_pton()'s input for this "af" plus trailing "/CIDR".
* "dst" is assumed large enough for its "af". "bits" is set to the
* /CIDR prefix length, which can have defaults (like /32 for IPv4).
* return:
* -1 if an error occurred (inspect errno; ENOENT means bad format).
* 0 if successful conversion occurred.
* note:
* 192.5.5.1/28 has a nonzero host part, which means it isn't a network
* as called for by inet_net_pton() but it can be a host address with
* an included netmask.
* author:
* Paul Vixie (ISC), October 1998
*/
int
inet_cidr_pton(int af, const char *src, void *dst, int *bits) {
switch (af) {
case AF_INET:
return (inet_cidr_pton_ipv4(src, dst, bits, 0));
case AF_INET6:
return (inet_cidr_pton_ipv6(src, dst, bits));
default:
errno = EAFNOSUPPORT;
return (-1);
}
}
static const char digits[] = "0123456789";
static int
inet_cidr_pton_ipv4(const char *src, u_char *dst, int *pbits, int ipv6) {
const u_char *odst = dst;
int n, ch, tmp, bits;
size_t size = 4;
/* Get the mantissa. */
while (ch = *src++, (isascii(ch) && isdigit(ch))) {
tmp = 0;
do {
n = strchr(digits, ch) - digits;
INSIST(n >= 0 && n <= 9);
tmp *= 10;
tmp += n;
if (tmp > 255)
goto enoent;
} while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch));
if (size-- == 0U)
goto emsgsize;
*dst++ = (u_char) tmp;
if (ch == '\0' || ch == '/')
break;
if (ch != '.')
goto enoent;
}
/* Get the prefix length if any. */
bits = -1;
if (ch == '/' && dst > odst) {
bits = getbits(src, ipv6);
if (bits == -2)
goto enoent;
} else if (ch != '\0')
goto enoent;
/* Prefix length can default to /32 only if all four octets spec'd. */
if (bits == -1) {
if (dst - odst == 4)
bits = ipv6 ? 128 : 32;
else
goto enoent;
}
/* If nothing was written to the destination, we found no address. */
if (dst == odst)
goto enoent;
/* If prefix length overspecifies mantissa, life is bad. */
if (((bits - (ipv6 ? 96 : 0)) / 8) > (dst - odst))
goto enoent;
/* Extend address to four octets. */
while (size-- > 0U)
*dst++ = 0;
*pbits = bits;
return (0);
enoent:
errno = ENOENT;
return (-1);
emsgsize:
errno = EMSGSIZE;
return (-1);
}
static int
inet_cidr_pton_ipv6(const char *src, u_char *dst, int *pbits) {
static const char xdigits_l[] = "0123456789abcdef",
xdigits_u[] = "0123456789ABCDEF";
u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
const char *xdigits, *curtok;
int ch, saw_xdigit;
u_int val;
int bits;
memset((tp = tmp), '\0', NS_IN6ADDRSZ);
endp = tp + NS_IN6ADDRSZ;
colonp = NULL;
/* Leading :: requires some special handling. */
if (*src == ':')
if (*++src != ':')
return (0);
curtok = src;
saw_xdigit = 0;
val = 0;
bits = -1;
while ((ch = *src++) != '\0') {
const char *pch;
if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
pch = strchr((xdigits = xdigits_u), ch);
if (pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
if (val > 0xffff)
return (0);
saw_xdigit = 1;
continue;
}
if (ch == ':') {
curtok = src;
if (!saw_xdigit) {
if (colonp)
return (0);
colonp = tp;
continue;
} else if (*src == '\0') {
return (0);
}
if (tp + NS_INT16SZ > endp)
return (0);
*tp++ = (u_char) (val >> 8) & 0xff;
*tp++ = (u_char) val & 0xff;
saw_xdigit = 0;
val = 0;
continue;
}
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
inet_cidr_pton_ipv4(curtok, tp, &bits, 1) == 0) {
tp += NS_INADDRSZ;
saw_xdigit = 0;
break; /*%< '\\0' was seen by inet_pton4(). */
}
if (ch == '/') {
bits = getbits(src, 1);
if (bits == -2)
goto enoent;
break;
}
goto enoent;
}
if (saw_xdigit) {
if (tp + NS_INT16SZ > endp)
goto emsgsize;
*tp++ = (u_char) (val >> 8) & 0xff;
*tp++ = (u_char) val & 0xff;
}
if (colonp != NULL) {
/*
* Since some memmove()'s erroneously fail to handle
* overlapping regions, we'll do the shift by hand.
*/
const int n = tp - colonp;
int i;
if (tp == endp)
goto enoent;
for (i = 1; i <= n; i++) {
endp[- i] = colonp[n - i];
colonp[n - i] = 0;
}
tp = endp;
}
memcpy(dst, tmp, NS_IN6ADDRSZ);
*pbits = bits;
return (0);
enoent:
errno = ENOENT;
return (-1);
emsgsize:
errno = EMSGSIZE;
return (-1);
}
static int
getbits(const char *src, int ipv6) {
int bits = 0;
char *cp, ch;
if (*src == '\0') /*%< syntax */
return (-2);
do {
ch = *src++;
cp = strchr(digits, ch);
if (cp == NULL) /*%< syntax */
return (-2);
bits *= 10;
bits += cp - digits;
if (bits == 0 && *src != '\0') /*%< no leading zeros */
return (-2);
if (bits > (ipv6 ? 128 : 32)) /*%< range error */
return (-2);
} while (*src != '\0');
return (bits);
}
/*! \file */

View File

@ -1,46 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char rcsid[] = "$Id: inet_data.c,v 1.3.18.1 2005/04/27 05:00:53 sra Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <ctype.h>
#include <netdb.h>
#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "port_after.h"
const struct in6_addr isc_in6addr_any = IN6ADDR_ANY_INIT;
const struct in6_addr isc_in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
/*! \file */

View File

@ -1,65 +0,0 @@
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)inet_lnaof.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "port_after.h"
/*%
* Return the local network address portion of an
* internet address; handles class a/b/c network
* number formats.
*/
u_long
inet_lnaof(in)
struct in_addr in;
{
register u_long i = ntohl(in.s_addr);
if (IN_CLASSA(i))
return ((i)&IN_CLASSA_HOST);
else if (IN_CLASSB(i))
return ((i)&IN_CLASSB_HOST);
else
return ((i)&IN_CLASSC_HOST);
}
/*! \file */

View File

@ -1,68 +0,0 @@
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)inet_makeaddr.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "port_after.h"
/*%
* Formulate an Internet address from network + host. Used in
* building addresses stored in the ifnet structure.
*/
struct in_addr
inet_makeaddr(net, host)
u_long net, host;
{
struct in_addr a;
if (net < 128U)
a.s_addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST);
else if (net < 65536U)
a.s_addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST);
else if (net < 16777216L)
a.s_addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST);
else
a.s_addr = net | host;
a.s_addr = htonl(a.s_addr);
return (a);
}
/*! \file */

View File

@ -1,279 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.3.18.2 2006/06/20 02:51:32 marka Exp $";
#endif
#include "port_before.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "port_after.h"
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintf/**/x)
#else
# define SPRINTF(x) ((size_t)sprintf x)
#endif
static char * inet_net_ntop_ipv4 __P((const u_char *src, int bits,
char *dst, size_t size));
static char * inet_net_ntop_ipv6 __P((const u_char *src, int bits,
char *dst, size_t size));
/*%
* char *
* inet_net_ntop(af, src, bits, dst, size)
* convert network number from network to presentation format.
* generates CIDR style result always.
* return:
* pointer to dst, or NULL if an error occurred (check errno).
* author:
* Paul Vixie (ISC), July 1996
*/
char *
inet_net_ntop(af, src, bits, dst, size)
int af;
const void *src;
int bits;
char *dst;
size_t size;
{
switch (af) {
case AF_INET:
return (inet_net_ntop_ipv4(src, bits, dst, size));
case AF_INET6:
return (inet_net_ntop_ipv6(src, bits, dst, size));
default:
errno = EAFNOSUPPORT;
return (NULL);
}
}
/*%
* static char *
* inet_net_ntop_ipv4(src, bits, dst, size)
* convert IPv4 network number from network to presentation format.
* generates CIDR style result always.
* return:
* pointer to dst, or NULL if an error occurred (check errno).
* note:
* network byte order assumed. this means 192.5.5.240/28 has
* 0b11110000 in its fourth octet.
* author:
* Paul Vixie (ISC), July 1996
*/
static char *
inet_net_ntop_ipv4(src, bits, dst, size)
const u_char *src;
int bits;
char *dst;
size_t size;
{
char *odst = dst;
char *t;
u_int m;
int b;
if (bits < 0 || bits > 32) {
errno = EINVAL;
return (NULL);
}
if (bits == 0) {
if (size < sizeof "0")
goto emsgsize;
*dst++ = '0';
size--;
*dst = '\0';
}
/* Format whole octets. */
for (b = bits / 8; b > 0; b--) {
if (size <= sizeof "255.")
goto emsgsize;
t = dst;
dst += SPRINTF((dst, "%u", *src++));
if (b > 1) {
*dst++ = '.';
*dst = '\0';
}
size -= (size_t)(dst - t);
}
/* Format partial octet. */
b = bits % 8;
if (b > 0) {
if (size <= sizeof ".255")
goto emsgsize;
t = dst;
if (dst != odst)
*dst++ = '.';
m = ((1 << b) - 1) << (8 - b);
dst += SPRINTF((dst, "%u", *src & m));
size -= (size_t)(dst - t);
}
/* Format CIDR /width. */
if (size <= sizeof "/32")
goto emsgsize;
dst += SPRINTF((dst, "/%u", bits));
return (odst);
emsgsize:
errno = EMSGSIZE;
return (NULL);
}
/*%
* static char *
* inet_net_ntop_ipv6(src, bits, fakebits, dst, size)
* convert IPv6 network number from network to presentation format.
* generates CIDR style result always. Picks the shortest representation
* unless the IP is really IPv4.
* always prints specified number of bits (bits).
* return:
* pointer to dst, or NULL if an error occurred (check errno).
* note:
* network byte order assumed. this means 192.5.5.240/28 has
* 0x11110000 in its fourth octet.
* author:
* Vadim Kogan (UCB), June 2001
* Original version (IPv4) by Paul Vixie (ISC), July 1996
*/
static char *
inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) {
u_int m;
int b;
int p;
int zero_s, zero_l, tmp_zero_s, tmp_zero_l;
int i;
int is_ipv4 = 0;
unsigned char inbuf[16];
char outbuf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
char *cp;
int words;
u_char *s;
if (bits < 0 || bits > 128) {
errno = EINVAL;
return (NULL);
}
cp = outbuf;
if (bits == 0) {
*cp++ = ':';
*cp++ = ':';
*cp = '\0';
} else {
/* Copy src to private buffer. Zero host part. */
p = (bits + 7) / 8;
memcpy(inbuf, src, p);
memset(inbuf + p, 0, 16 - p);
b = bits % 8;
if (b != 0) {
m = ~0 << (8 - b);
inbuf[p-1] &= m;
}
s = inbuf;
/* how many words need to be displayed in output */
words = (bits + 15) / 16;
if (words == 1)
words = 2;
/* Find the longest substring of zero's */
zero_s = zero_l = tmp_zero_s = tmp_zero_l = 0;
for (i = 0; i < (words * 2); i += 2) {
if ((s[i] | s[i+1]) == 0) {
if (tmp_zero_l == 0)
tmp_zero_s = i / 2;
tmp_zero_l++;
} else {
if (tmp_zero_l && zero_l < tmp_zero_l) {
zero_s = tmp_zero_s;
zero_l = tmp_zero_l;
tmp_zero_l = 0;
}
}
}
if (tmp_zero_l && zero_l < tmp_zero_l) {
zero_s = tmp_zero_s;
zero_l = tmp_zero_l;
}
if (zero_l != words && zero_s == 0 && ((zero_l == 6) ||
((zero_l == 5 && s[10] == 0xff && s[11] == 0xff) ||
((zero_l == 7 && s[14] != 0 && s[15] != 1)))))
is_ipv4 = 1;
/* Format whole words. */
for (p = 0; p < words; p++) {
if (zero_l != 0 && p >= zero_s && p < zero_s + zero_l) {
/* Time to skip some zeros */
if (p == zero_s)
*cp++ = ':';
if (p == words - 1)
*cp++ = ':';
s++;
s++;
continue;
}
if (is_ipv4 && p > 5 ) {
*cp++ = (p == 6) ? ':' : '.';
cp += SPRINTF((cp, "%u", *s++));
/* we can potentially drop the last octet */
if (p != 7 || bits > 120) {
*cp++ = '.';
cp += SPRINTF((cp, "%u", *s++));
}
} else {
if (cp != outbuf)
*cp++ = ':';
cp += SPRINTF((cp, "%x", *s * 256 + s[1]));
s += 2;
}
}
}
/* Format CIDR /width. */
sprintf(cp, "/%u", bits);
if (strlen(outbuf) + 1 > size)
goto emsgsize;
strcpy(dst, outbuf);
return (dst);
emsgsize:
errno = EMSGSIZE;
return (NULL);
}
/*! \file */

View File

@ -1,407 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_net_pton.c,v 1.7.18.2 2008/08/26 04:42:43 marka Exp $";
#endif
#include "port_before.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include <isc/assertions.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "port_after.h"
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintf/**/x)
#else
# define SPRINTF(x) ((size_t)sprintf x)
#endif
/*%
* static int
* inet_net_pton_ipv4(src, dst, size)
* convert IPv4 network number from presentation to network format.
* accepts hex octets, hex strings, decimal octets, and /CIDR.
* "size" is in bytes and describes "dst".
* return:
* number of bits, either imputed classfully or specified with /CIDR,
* or -1 if some failure occurred (check errno). ENOENT means it was
* not an IPv4 network specification.
* note:
* network byte order assumed. this means 192.5.5.240/28 has
* 0b11110000 in its fourth octet.
* author:
* Paul Vixie (ISC), June 1996
*/
static int
inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) {
static const char xdigits[] = "0123456789abcdef";
static const char digits[] = "0123456789";
int n, ch, tmp = 0, dirty, bits;
const u_char *odst = dst;
ch = *src++;
if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
&& isascii((unsigned char)(src[1]))
&& isxdigit((unsigned char)(src[1]))) {
/* Hexadecimal: Eat nybble string. */
if (size <= 0U)
goto emsgsize;
dirty = 0;
src++; /*%< skip x or X. */
while ((ch = *src++) != '\0' && isascii(ch) && isxdigit(ch)) {
if (isupper(ch))
ch = tolower(ch);
n = strchr(xdigits, ch) - xdigits;
INSIST(n >= 0 && n <= 15);
if (dirty == 0)
tmp = n;
else
tmp = (tmp << 4) | n;
if (++dirty == 2) {
if (size-- <= 0U)
goto emsgsize;
*dst++ = (u_char) tmp;
dirty = 0;
}
}
if (dirty) { /*%< Odd trailing nybble? */
if (size-- <= 0U)
goto emsgsize;
*dst++ = (u_char) (tmp << 4);
}
} else if (isascii(ch) && isdigit(ch)) {
/* Decimal: eat dotted digit string. */
for (;;) {
tmp = 0;
do {
n = strchr(digits, ch) - digits;
INSIST(n >= 0 && n <= 9);
tmp *= 10;
tmp += n;
if (tmp > 255)
goto enoent;
} while ((ch = *src++) != '\0' &&
isascii(ch) && isdigit(ch));
if (size-- <= 0U)
goto emsgsize;
*dst++ = (u_char) tmp;
if (ch == '\0' || ch == '/')
break;
if (ch != '.')
goto enoent;
ch = *src++;
if (!isascii(ch) || !isdigit(ch))
goto enoent;
}
} else
goto enoent;
bits = -1;
if (ch == '/' && isascii((unsigned char)(src[0])) &&
isdigit((unsigned char)(src[0])) && dst > odst) {
/* CIDR width specifier. Nothing can follow it. */
ch = *src++; /*%< Skip over the /. */
bits = 0;
do {
n = strchr(digits, ch) - digits;
INSIST(n >= 0 && n <= 9);
bits *= 10;
bits += n;
if (bits > 32)
goto enoent;
} while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch));
if (ch != '\0')
goto enoent;
}
/* Firey death and destruction unless we prefetched EOS. */
if (ch != '\0')
goto enoent;
/* If nothing was written to the destination, we found no address. */
if (dst == odst)
goto enoent;
/* If no CIDR spec was given, infer width from net class. */
if (bits == -1) {
if (*odst >= 240) /*%< Class E */
bits = 32;
else if (*odst >= 224) /*%< Class D */
bits = 8;
else if (*odst >= 192) /*%< Class C */
bits = 24;
else if (*odst >= 128) /*%< Class B */
bits = 16;
else /*%< Class A */
bits = 8;
/* If imputed mask is narrower than specified octets, widen. */
if (bits < ((dst - odst) * 8))
bits = (dst - odst) * 8;
/*
* If there are no additional bits specified for a class D
* address adjust bits to 4.
*/
if (bits == 8 && *odst == 224)
bits = 4;
}
/* Extend network to cover the actual mask. */
while (bits > ((dst - odst) * 8)) {
if (size-- <= 0U)
goto emsgsize;
*dst++ = '\0';
}
return (bits);
enoent:
errno = ENOENT;
return (-1);
emsgsize:
errno = EMSGSIZE;
return (-1);
}
static int
getbits(const char *src, int *bitsp) {
static const char digits[] = "0123456789";
int n;
int val;
char ch;
val = 0;
n = 0;
while ((ch = *src++) != '\0') {
const char *pch;
pch = strchr(digits, ch);
if (pch != NULL) {
if (n++ != 0 && val == 0) /*%< no leading zeros */
return (0);
val *= 10;
val += (pch - digits);
if (val > 128) /*%< range */
return (0);
continue;
}
return (0);
}
if (n == 0)
return (0);
*bitsp = val;
return (1);
}
static int
getv4(const char *src, u_char *dst, int *bitsp) {
static const char digits[] = "0123456789";
u_char *odst = dst;
int n;
u_int val;
char ch;
val = 0;
n = 0;
while ((ch = *src++) != '\0') {
const char *pch;
pch = strchr(digits, ch);
if (pch != NULL) {
if (n++ != 0 && val == 0) /*%< no leading zeros */
return (0);
val *= 10;
val += (pch - digits);
if (val > 255) /*%< range */
return (0);
continue;
}
if (ch == '.' || ch == '/') {
if (dst - odst > 3) /*%< too many octets? */
return (0);
*dst++ = val;
if (ch == '/')
return (getbits(src, bitsp));
val = 0;
n = 0;
continue;
}
return (0);
}
if (n == 0)
return (0);
if (dst - odst > 3) /*%< too many octets? */
return (0);
*dst++ = val;
return (1);
}
static int
inet_net_pton_ipv6(const char *src, u_char *dst, size_t size) {
static const char xdigits_l[] = "0123456789abcdef",
xdigits_u[] = "0123456789ABCDEF";
u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
const char *xdigits, *curtok;
int ch, saw_xdigit;
u_int val;
int digits;
int bits;
size_t bytes;
int words;
int ipv4;
memset((tp = tmp), '\0', NS_IN6ADDRSZ);
endp = tp + NS_IN6ADDRSZ;
colonp = NULL;
/* Leading :: requires some special handling. */
if (*src == ':')
if (*++src != ':')
goto enoent;
curtok = src;
saw_xdigit = 0;
val = 0;
digits = 0;
bits = -1;
ipv4 = 0;
while ((ch = *src++) != '\0') {
const char *pch;
if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
pch = strchr((xdigits = xdigits_u), ch);
if (pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
if (++digits > 4)
goto enoent;
saw_xdigit = 1;
continue;
}
if (ch == ':') {
curtok = src;
if (!saw_xdigit) {
if (colonp)
goto enoent;
colonp = tp;
continue;
} else if (*src == '\0')
goto enoent;
if (tp + NS_INT16SZ > endp)
return (0);
*tp++ = (u_char) (val >> 8) & 0xff;
*tp++ = (u_char) val & 0xff;
saw_xdigit = 0;
digits = 0;
val = 0;
continue;
}
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
getv4(curtok, tp, &bits) > 0) {
tp += NS_INADDRSZ;
saw_xdigit = 0;
ipv4 = 1;
break; /*%< '\\0' was seen by inet_pton4(). */
}
if (ch == '/' && getbits(src, &bits) > 0)
break;
goto enoent;
}
if (saw_xdigit) {
if (tp + NS_INT16SZ > endp)
goto enoent;
*tp++ = (u_char) (val >> 8) & 0xff;
*tp++ = (u_char) val & 0xff;
}
if (bits == -1)
bits = 128;
words = (bits + 15) / 16;
if (words < 2)
words = 2;
if (ipv4)
words = 8;
endp = tmp + 2 * words;
if (colonp != NULL) {
/*
* Since some memmove()'s erroneously fail to handle
* overlapping regions, we'll do the shift by hand.
*/
const int n = tp - colonp;
int i;
if (tp == endp)
goto enoent;
for (i = 1; i <= n; i++) {
endp[- i] = colonp[n - i];
colonp[n - i] = 0;
}
tp = endp;
}
if (tp != endp)
goto enoent;
bytes = (bits + 7) / 8;
if (bytes > size)
goto emsgsize;
memcpy(dst, tmp, bytes);
return (bits);
enoent:
errno = ENOENT;
return (-1);
emsgsize:
errno = EMSGSIZE;
return (-1);
}
/*%
* int
* inet_net_pton(af, src, dst, size)
* convert network number from presentation to network format.
* accepts hex octets, hex strings, decimal octets, and /CIDR.
* "size" is in bytes and describes "dst".
* return:
* number of bits, either imputed classfully or specified with /CIDR,
* or -1 if some failure occurred (check errno). ENOENT means it was
* not a valid network specification.
* author:
* Paul Vixie (ISC), June 1996
*/
int
inet_net_pton(int af, const char *src, void *dst, size_t size) {
switch (af) {
case AF_INET:
return (inet_net_pton_ipv4(src, dst, size));
case AF_INET6:
return (inet_net_pton_ipv6(src, dst, size));
default:
errno = EAFNOSUPPORT;
return (-1);
}
}
/*! \file */

View File

@ -1,89 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_neta.c,v 1.2.18.1 2005/04/27 05:00:53 sra Exp $";
#endif
#include "port_before.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include "port_after.h"
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintf/**/x)
#else
# define SPRINTF(x) ((size_t)sprintf x)
#endif
/*%
* char *
* inet_neta(src, dst, size)
* format a u_long network number into presentation format.
* return:
* pointer to dst, or NULL if an error occurred (check errno).
* note:
* format of ``src'' is as for inet_network().
* author:
* Paul Vixie (ISC), July 1996
*/
char *
inet_neta(src, dst, size)
u_long src;
char *dst;
size_t size;
{
char *odst = dst;
char *tp;
while (src & 0xffffffff) {
u_char b = (src & 0xff000000) >> 24;
src <<= 8;
if (b) {
if (size < sizeof "255.")
goto emsgsize;
tp = dst;
dst += SPRINTF((dst, "%u", b));
if (src != 0L) {
*dst++ = '.';
*dst = '\0';
}
size -= (size_t)(dst - tp);
}
}
if (dst == odst) {
if (size < sizeof "0.0.0.0")
goto emsgsize;
strcpy(dst, "0.0.0.0");
}
return (odst);
emsgsize:
errno = EMSGSIZE;
return (NULL);
}
/*! \file */

View File

@ -1,64 +0,0 @@
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)inet_netof.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "port_after.h"
/*%
* Return the network number from an internet
* address; handles class a/b/c network #'s.
*/
u_long
inet_netof(in)
struct in_addr in;
{
register u_long i = ntohl(in.s_addr);
if (IN_CLASSA(i))
return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT);
else if (IN_CLASSB(i))
return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT);
else
return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT);
}
/*! \file */

View File

@ -1,106 +0,0 @@
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <ctype.h>
#include "port_after.h"
/*%
* Internet network address interpretation routine.
* The library routines call this routine to interpret
* network numbers.
*/
u_long
inet_network(cp)
register const char *cp;
{
register u_long val, base, n, i;
register char c;
u_long parts[4], *pp = parts;
int digit;
again:
val = 0; base = 10; digit = 0;
if (*cp == '0')
digit = 1, base = 8, cp++;
if (*cp == 'x' || *cp == 'X')
base = 16, cp++;
while ((c = *cp) != 0) {
if (isdigit((unsigned char)c)) {
if (base == 8U && (c == '8' || c == '9'))
return (INADDR_NONE);
val = (val * base) + (c - '0');
cp++;
digit = 1;
continue;
}
if (base == 16U && isxdigit((unsigned char)c)) {
val = (val << 4) +
(c + 10 - (islower((unsigned char)c) ? 'a' : 'A'));
cp++;
digit = 1;
continue;
}
break;
}
if (!digit)
return (INADDR_NONE);
if (pp >= parts + 4 || val > 0xffU)
return (INADDR_NONE);
if (*cp == '.') {
*pp++ = val, cp++;
goto again;
}
if (*cp && !isspace(*cp&0xff))
return (INADDR_NONE);
*pp++ = val;
n = pp - parts;
if (n > 4U)
return (INADDR_NONE);
for (val = 0, i = 0; i < n; i++) {
val <<= 8;
val |= parts[i] & 0xff;
}
return (val);
}
/*! \file */

View File

@ -1,64 +0,0 @@
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)inet_ntoa.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: inet_ntoa.c,v 1.1.352.1 2005/04/27 05:00:54 sra Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include "port_after.h"
/*%
* Convert network-format internet address
* to base 256 d.d.d.d representation.
*/
/*const*/ char *
inet_ntoa(struct in_addr in) {
static char ret[18];
strcpy(ret, "[inet_ntoa error]");
(void) inet_ntop(AF_INET, &in, ret, sizeof ret);
return (ret);
}
/*! \file */

View File

@ -1,207 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_ntop.c,v 1.3.18.2 2005/11/03 23:02:22 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include "port_after.h"
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintf/**/x)
#else
# define SPRINTF(x) ((size_t)sprintf x)
#endif
/*%
* WARNING: Don't even consider trying to compile this on a system where
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
static const char *inet_ntop4 __P((const u_char *src, char *dst, size_t size));
static const char *inet_ntop6 __P((const u_char *src, char *dst, size_t size));
/* char *
* inet_ntop(af, src, dst, size)
* convert a network format address to presentation format.
* return:
* pointer to presentation format address (`dst'), or NULL (see errno).
* author:
* Paul Vixie, 1996.
*/
const char *
inet_ntop(af, src, dst, size)
int af;
const void *src;
char *dst;
size_t size;
{
switch (af) {
case AF_INET:
return (inet_ntop4(src, dst, size));
case AF_INET6:
return (inet_ntop6(src, dst, size));
default:
errno = EAFNOSUPPORT;
return (NULL);
}
/* NOTREACHED */
}
/* const char *
* inet_ntop4(src, dst, size)
* format an IPv4 address
* return:
* `dst' (as a const)
* notes:
* (1) uses no statics
* (2) takes a u_char* not an in_addr as input
* author:
* Paul Vixie, 1996.
*/
static const char *
inet_ntop4(src, dst, size)
const u_char *src;
char *dst;
size_t size;
{
static const char fmt[] = "%u.%u.%u.%u";
char tmp[sizeof "255.255.255.255"];
if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) >= size) {
errno = ENOSPC;
return (NULL);
}
strcpy(dst, tmp);
return (dst);
}
/* const char *
* inet_ntop6(src, dst, size)
* convert IPv6 binary address into presentation (printable) format
* author:
* Paul Vixie, 1996.
*/
static const char *
inet_ntop6(src, dst, size)
const u_char *src;
char *dst;
size_t size;
{
/*
* Note that int32_t and int16_t need only be "at least" large enough
* to contain a value of the specified size. On some systems, like
* Crays, there is no such thing as an integer variable with 16 bits.
* Keep this in mind if you think this function should have been coded
* to use pointer overlays. All the world's not a VAX.
*/
char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
struct { int base, len; } best, cur;
u_int words[NS_IN6ADDRSZ / NS_INT16SZ];
int i;
/*
* Preprocess:
* Copy the input (bytewise) array into a wordwise array.
* Find the longest run of 0x00's in src[] for :: shorthanding.
*/
memset(words, '\0', sizeof words);
for (i = 0; i < NS_IN6ADDRSZ; i++)
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
best.base = -1;
best.len = 0;
cur.base = -1;
cur.len = 0;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
if (words[i] == 0) {
if (cur.base == -1)
cur.base = i, cur.len = 1;
else
cur.len++;
} else {
if (cur.base != -1) {
if (best.base == -1 || cur.len > best.len)
best = cur;
cur.base = -1;
}
}
}
if (cur.base != -1) {
if (best.base == -1 || cur.len > best.len)
best = cur;
}
if (best.base != -1 && best.len < 2)
best.base = -1;
/*
* Format the result.
*/
tp = tmp;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
/* Are we inside the best run of 0x00's? */
if (best.base != -1 && i >= best.base &&
i < (best.base + best.len)) {
if (i == best.base)
*tp++ = ':';
continue;
}
/* Are we following an initial run of 0x00s or any real hex? */
if (i != 0)
*tp++ = ':';
/* Is this address an encapsulated IPv4? */
if (i == 6 && best.base == 0 && (best.len == 6 ||
(best.len == 7 && words[7] != 0x0001) ||
(best.len == 5 && words[5] == 0xffff))) {
if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
return (NULL);
tp += strlen(tp);
break;
}
tp += SPRINTF((tp, "%x", words[i]));
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) ==
(NS_IN6ADDRSZ / NS_INT16SZ))
*tp++ = ':';
*tp++ = '\0';
/*
* Check for overflow, copy, and we're done.
*/
if ((size_t)(tp - tmp) > size) {
errno = ENOSPC;
return (NULL);
}
strcpy(dst, tmp);
return (dst);
}
/*! \file */

View File

@ -1,223 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_pton.c,v 1.3.18.2 2005/07/28 07:38:07 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <string.h>
#include <errno.h>
#include "port_after.h"
/*%
* WARNING: Don't even consider trying to compile this on a system where
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
static int inet_pton4 __P((const char *src, u_char *dst));
static int inet_pton6 __P((const char *src, u_char *dst));
/* int
* inet_pton(af, src, dst)
* convert from presentation format (which usually means ASCII printable)
* to network format (which is usually some kind of binary format).
* return:
* 1 if the address was valid for the specified address family
* 0 if the address wasn't valid (`dst' is untouched in this case)
* -1 if some other error occurred (`dst' is untouched in this case, too)
* author:
* Paul Vixie, 1996.
*/
int
inet_pton(af, src, dst)
int af;
const char *src;
void *dst;
{
switch (af) {
case AF_INET:
return (inet_pton4(src, dst));
case AF_INET6:
return (inet_pton6(src, dst));
default:
errno = EAFNOSUPPORT;
return (-1);
}
/* NOTREACHED */
}
/* int
* inet_pton4(src, dst)
* like inet_aton() but without all the hexadecimal and shorthand.
* return:
* 1 if `src' is a valid dotted quad, else 0.
* notice:
* does not touch `dst' unless it's returning 1.
* author:
* Paul Vixie, 1996.
*/
static int
inet_pton4(src, dst)
const char *src;
u_char *dst;
{
static const char digits[] = "0123456789";
int saw_digit, octets, ch;
u_char tmp[NS_INADDRSZ], *tp;
saw_digit = 0;
octets = 0;
*(tp = tmp) = 0;
while ((ch = *src++) != '\0') {
const char *pch;
if ((pch = strchr(digits, ch)) != NULL) {
u_int new = *tp * 10 + (pch - digits);
if (saw_digit && *tp == 0)
return (0);
if (new > 255)
return (0);
*tp = new;
if (!saw_digit) {
if (++octets > 4)
return (0);
saw_digit = 1;
}
} else if (ch == '.' && saw_digit) {
if (octets == 4)
return (0);
*++tp = 0;
saw_digit = 0;
} else
return (0);
}
if (octets < 4)
return (0);
memcpy(dst, tmp, NS_INADDRSZ);
return (1);
}
/* int
* inet_pton6(src, dst)
* convert presentation level address to network order binary form.
* return:
* 1 if `src' is a valid [RFC1884 2.2] address, else 0.
* notice:
* (1) does not touch `dst' unless it's returning 1.
* (2) :: in a full address is silently ignored.
* credit:
* inspired by Mark Andrews.
* author:
* Paul Vixie, 1996.
*/
static int
inet_pton6(src, dst)
const char *src;
u_char *dst;
{
static const char xdigits_l[] = "0123456789abcdef",
xdigits_u[] = "0123456789ABCDEF";
u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
const char *xdigits, *curtok;
int ch, seen_xdigits;
u_int val;
memset((tp = tmp), '\0', NS_IN6ADDRSZ);
endp = tp + NS_IN6ADDRSZ;
colonp = NULL;
/* Leading :: requires some special handling. */
if (*src == ':')
if (*++src != ':')
return (0);
curtok = src;
seen_xdigits = 0;
val = 0;
while ((ch = *src++) != '\0') {
const char *pch;
if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
pch = strchr((xdigits = xdigits_u), ch);
if (pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
if (++seen_xdigits > 4)
return (0);
continue;
}
if (ch == ':') {
curtok = src;
if (!seen_xdigits) {
if (colonp)
return (0);
colonp = tp;
continue;
} else if (*src == '\0') {
return (0);
}
if (tp + NS_INT16SZ > endp)
return (0);
*tp++ = (u_char) (val >> 8) & 0xff;
*tp++ = (u_char) val & 0xff;
seen_xdigits = 0;
val = 0;
continue;
}
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
inet_pton4(curtok, tp) > 0) {
tp += NS_INADDRSZ;
seen_xdigits = 0;
break; /*%< '\\0' was seen by inet_pton4(). */
}
return (0);
}
if (seen_xdigits) {
if (tp + NS_INT16SZ > endp)
return (0);
*tp++ = (u_char) (val >> 8) & 0xff;
*tp++ = (u_char) val & 0xff;
}
if (colonp != NULL) {
/*
* Since some memmove()'s erroneously fail to handle
* overlapping regions, we'll do the shift by hand.
*/
const int n = tp - colonp;
int i;
if (tp == endp)
return (0);
for (i = 1; i <= n; i++) {
endp[- i] = colonp[n - i];
colonp[n - i] = 0;
}
tp = endp;
}
if (tp != endp)
return (0);
memcpy(dst, tmp, NS_IN6ADDRSZ);
return (1);
}
/*! \file */

View File

@ -1,111 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: nsap_addr.c,v 1.3.18.2 2005/07/28 07:38:08 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <ctype.h>
#include <resolv.h>
#include <resolv_mt.h>
#include "port_after.h"
static char
xtob(int c) {
return (c - (((c >= '0') && (c <= '9')) ? '0' : '7'));
}
u_int
inet_nsap_addr(const char *ascii, u_char *binary, int maxlen) {
u_char c, nib;
u_int len = 0;
if (ascii[0] != '0' || (ascii[1] != 'x' && ascii[1] != 'X'))
return (0);
ascii += 2;
while ((c = *ascii++) != '\0' && len < (u_int)maxlen) {
if (c == '.' || c == '+' || c == '/')
continue;
if (!isascii(c))
return (0);
if (islower(c))
c = toupper(c);
if (isxdigit(c)) {
nib = xtob(c);
c = *ascii++;
if (c != '\0') {
c = toupper(c);
if (isxdigit(c)) {
*binary++ = (nib << 4) | xtob(c);
len++;
} else
return (0);
}
else
return (0);
}
else
return (0);
}
return (len);
}
char *
inet_nsap_ntoa(int binlen, const u_char *binary, char *ascii) {
int nib;
int i;
char *tmpbuf = inet_nsap_ntoa_tmpbuf;
char *start;
if (ascii)
start = ascii;
else {
ascii = tmpbuf;
start = tmpbuf;
}
*ascii++ = '0';
*ascii++ = 'x';
if (binlen > 255)
binlen = 255;
for (i = 0; i < binlen; i++) {
nib = *binary >> 4;
*ascii++ = nib + (nib < 10 ? '0' : '7');
nib = *binary++ & 0x0f;
*ascii++ = nib + (nib < 10 ? '0' : '7');
if (((i % 2) == 0 && (i + 1) < binlen))
*ascii++ = '.';
}
*ascii = '\0';
return (start);
}
/*! \file */

View File

@ -1,70 +0,0 @@
# Copyright (C) 2004, 2008 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2001 Internet Software Consortium.
#
# Permission to use, copy, modify, and/or 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 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: Makefile.in,v 1.8.18.4 2008/03/20 23:46:01 tbox Exp $
srcdir= @srcdir@
VPATH = @srcdir@
WANT_IRS_THREADS_OBJS= gethostent_r.@O@ getnetent_r.@O@ getnetgrent_r.@O@ \
getprotoent_r.@O@ getservent_r.@O@
WANT_IRS_NISGR_OBJS= nis_gr.@O@
WANT_IRS_GR_OBJS= dns_gr.@O@ irp_gr.@O@ lcl_gr.@O@ gen_gr.@O@ getgrent.@O@ \
@WANT_IRS_NISGR_OBJS@ @WANT_IRS_THREADSGR_OBJS@
WANT_IRS_THREADSPW_OBJS=getpwent_r.@O@
WANT_IRS_NISPW_OBJS= nis_pw.@O@
WANT_IRS_DBPW_OBJS=irp_pw.@O@ lcl_pw.@O@
WANT_IRS_PW_OBJS= dns_pw.@O@ gen_pw.@O@ getpwent.@O@ \
@WANT_IRS_DBPW_OBJS@ @WANT_IRS_NISPW_OBJS@ @WANT_IRS_THREADSPW_OBJS@
WANT_IRS_NIS_OBJS= \
nis_ho.@O@ nis_ng.@O@ nis_nw.@O@ nis_pr.@O@ nis_sv.@O@
OBJS= @WANT_IRS_GR_OBJS@ @WANT_IRS_NIS_OBJS@ @WANT_IRS_THREADS_OBJS@ \
@WANT_IRS_PW_OBJS@ \
dns.@O@ dns_ho.@O@ dns_nw.@O@ dns_pr.@O@ \
dns_sv.@O@ gai_strerror.@O@ gen.@O@ gen_ho.@O@ \
gen_ng.@O@ gen_nw.@O@ gen_pr.@O@ gen_sv.@O@ \
getaddrinfo.@O@ gethostent.@O@ \
getnameinfo.@O@ getnetent.@O@ \
getnetgrent.@O@ getprotoent.@O@ getservent.@O@ \
hesiod.@O@ irp.@O@ irp_ho.@O@ irp_ng.@O@ irp_nw.@O@ \
irp_pr.@O@ irp_sv.@O@ irpmarshall.@O@ irs_data.@O@ \
lcl.@O@ lcl_ho.@O@ lcl_ng.@O@ lcl_nw.@O@ lcl_pr.@O@ \
lcl_sv.@O@ nis.@O@ nul_ng.@O@ util.@O@
SRCS= dns.c dns_gr.c dns_ho.c dns_nw.c dns_pr.c dns_pw.c \
dns_sv.c gai_strerror.c gen.c gen_gr.c gen_ho.c \
gen_ng.c gen_nw.c gen_pr.c gen_pw.c gen_sv.c \
getaddrinfo.c getgrent.c gethostent.c \
getnameinfo.c getnetent.c getnetent_r.c \
getnetgrent.c getprotoent.c getpwent.c getservent.c \
hesiod.c irp.c irp_gr.c irp_ho.c irp_ng.c irp_nw.c \
irp_pr.c irp_pw.c irp_sv.c irpmarshall.c irs_data.c \
lcl.c lcl_gr.c lcl_ho.c lcl_ng.c lcl_nw.c lcl_pr.c \
lcl_pw.c lcl_sv.c nis.c nis_gr.c nis_ho.c nis_ng.c \
nis_nw.c nis_pr.c nis_pw.c nis_sv.c nul_ng.c \
util.c getgrent_r.c gethostent_r.c getnetgrent_r.c getprotoent_r.c \
getpwent_r.c getservent_r.c
WANT_IRS_THREADSGR_OBJS=getgrent_r.@O@
TARGETS= ${OBJS}
CINCLUDES= -I.. -I../include -I${srcdir}/../include
@BIND9_MAKE_RULES@

View File

@ -1,154 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: dns.c,v 1.3.18.2 2006/03/10 00:20:08 marka Exp $";
#endif
/*! \file
* \brief
* dns.c --- this is the top-level accessor function for the dns
*/
#include "port_before.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <resolv.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "hesiod.h"
#include "dns_p.h"
/* forward */
static void dns_close(struct irs_acc *);
static struct __res_state * dns_res_get(struct irs_acc *);
static void dns_res_set(struct irs_acc *, struct __res_state *,
void (*)(void *));
/* public */
struct irs_acc *
irs_dns_acc(const char *options) {
struct irs_acc *acc;
struct dns_p *dns;
UNUSED(options);
if (!(acc = memget(sizeof *acc))) {
errno = ENOMEM;
return (NULL);
}
memset(acc, 0x5e, sizeof *acc);
if (!(dns = memget(sizeof *dns))) {
errno = ENOMEM;
memput(acc, sizeof *acc);
return (NULL);
}
memset(dns, 0x5e, sizeof *dns);
dns->res = NULL;
dns->free_res = NULL;
if (hesiod_init(&dns->hes_ctx) < 0) {
/*
* We allow the dns accessor class to initialize
* despite hesiod failing to initialize correctly,
* since dns host queries don't depend on hesiod.
*/
dns->hes_ctx = NULL;
}
acc->private = dns;
#ifdef WANT_IRS_GR
acc->gr_map = irs_dns_gr;
#else
acc->gr_map = NULL;
#endif
#ifdef WANT_IRS_PW
acc->pw_map = irs_dns_pw;
#else
acc->pw_map = NULL;
#endif
acc->sv_map = irs_dns_sv;
acc->pr_map = irs_dns_pr;
acc->ho_map = irs_dns_ho;
acc->nw_map = irs_dns_nw;
acc->ng_map = irs_nul_ng;
acc->res_get = dns_res_get;
acc->res_set = dns_res_set;
acc->close = dns_close;
return (acc);
}
/* methods */
static struct __res_state *
dns_res_get(struct irs_acc *this) {
struct dns_p *dns = (struct dns_p *)this->private;
if (dns->res == NULL) {
struct __res_state *res;
res = (struct __res_state *)malloc(sizeof *res);
if (res == NULL)
return (NULL);
memset(res, 0, sizeof *res);
dns_res_set(this, res, free);
}
if ((dns->res->options & RES_INIT) == 0U &&
res_ninit(dns->res) < 0)
return (NULL);
return (dns->res);
}
static void
dns_res_set(struct irs_acc *this, struct __res_state *res,
void (*free_res)(void *)) {
struct dns_p *dns = (struct dns_p *)this->private;
if (dns->res && dns->free_res) {
res_nclose(dns->res);
(*dns->free_res)(dns->res);
}
dns->res = res;
dns->free_res = free_res;
}
static void
dns_close(struct irs_acc *this) {
struct dns_p *dns;
dns = (struct dns_p *)this->private;
if (dns->res && dns->free_res)
(*dns->free_res)(dns->res);
if (dns->hes_ctx)
hesiod_end(dns->hes_ctx);
memput(dns, sizeof *dns);
memput(this, sizeof *this);
}

View File

@ -1,294 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: dns_gr.c,v 1.3.18.1 2005/04/27 05:00:54 sra Exp $";
#endif
/*! \file
* \brief
* dns_gr.c --- this file contains the functions for accessing
* group information from Hesiod.
*/
#include "port_before.h"
#ifndef WANT_IRS_GR
static int __bind_irs_gr_unneeded;
#else
#include <sys/param.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "hesiod.h"
#include "dns_p.h"
/* Types. */
struct pvt {
/*
* This is our private accessor data. It has a shared hesiod context.
*/
struct dns_p * dns;
/*
* Need space to store the entries read from the group file.
* The members list also needs space per member, and the
* strings making up the user names must be allocated
* somewhere. Rather than doing lots of small allocations,
* we keep one buffer and resize it as needed.
*/
struct group group;
size_t nmemb; /*%< Malloc'd max index of gr_mem[]. */
char * membuf;
size_t membufsize;
};
/* Forward. */
static struct group * gr_next(struct irs_gr *);
static struct group * gr_byname(struct irs_gr *, const char *);
static struct group * gr_bygid(struct irs_gr *, gid_t);
static void gr_rewind(struct irs_gr *);
static void gr_close(struct irs_gr *);
static int gr_list(struct irs_gr *, const char *,
gid_t, gid_t *, int *);
static void gr_minimize(struct irs_gr *);
static struct __res_state * gr_res_get(struct irs_gr *);
static void gr_res_set(struct irs_gr *,
struct __res_state *,
void (*)(void *));
static struct group * get_hes_group(struct irs_gr *this,
const char *name,
const char *type);
/* Public. */
struct irs_gr *
irs_dns_gr(struct irs_acc *this) {
struct dns_p *dns = (struct dns_p *)this->private;
struct irs_gr *gr;
struct pvt *pvt;
if (!dns || !dns->hes_ctx) {
errno = ENODEV;
return (NULL);
}
if (!(pvt = memget(sizeof *pvt))) {
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
pvt->dns = dns;
if (!(gr = memget(sizeof *gr))) {
memput(pvt, sizeof *pvt);
errno = ENOMEM;
return (NULL);
}
memset(gr, 0x5e, sizeof *gr);
gr->private = pvt;
gr->next = gr_next;
gr->byname = gr_byname;
gr->bygid = gr_bygid;
gr->rewind = gr_rewind;
gr->close = gr_close;
gr->list = gr_list;
gr->minimize = gr_minimize;
gr->res_get = gr_res_get;
gr->res_set = gr_res_set;
return (gr);
}
/* methods */
static void
gr_close(struct irs_gr *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (pvt->group.gr_mem)
free(pvt->group.gr_mem);
if (pvt->membuf)
free(pvt->membuf);
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static struct group *
gr_next(struct irs_gr *this) {
UNUSED(this);
return (NULL);
}
static struct group *
gr_byname(struct irs_gr *this, const char *name) {
return (get_hes_group(this, name, "group"));
}
static struct group *
gr_bygid(struct irs_gr *this, gid_t gid) {
char name[32];
sprintf(name, "%ld", (long)gid);
return (get_hes_group(this, name, "gid"));
}
static void
gr_rewind(struct irs_gr *this) {
UNUSED(this);
/* NOOP */
}
static int
gr_list(struct irs_gr *this, const char *name,
gid_t basegid, gid_t *groups, int *ngroups)
{
UNUSED(this);
UNUSED(name);
UNUSED(basegid);
UNUSED(groups);
*ngroups = 0;
/* There's some way to do this in Hesiod. */
return (-1);
}
static void
gr_minimize(struct irs_gr *this) {
UNUSED(this);
/* NOOP */
}
/* Private. */
static struct group *
get_hes_group(struct irs_gr *this, const char *name, const char *type) {
struct pvt *pvt = (struct pvt *)this->private;
char **hes_list, *cp, **new;
size_t num_members = 0;
u_long t;
hes_list = hesiod_resolve(pvt->dns->hes_ctx, name, type);
if (!hes_list)
return (NULL);
/*
* Copy the returned hesiod string into storage space.
*/
if (pvt->membuf)
free(pvt->membuf);
pvt->membuf = strdup(*hes_list);
hesiod_free_list(pvt->dns->hes_ctx, hes_list);
cp = pvt->membuf;
pvt->group.gr_name = cp;
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
pvt->group.gr_passwd = cp;
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
errno = 0;
t = strtoul(cp, NULL, 10);
if (errno == ERANGE)
goto cleanup;
pvt->group.gr_gid = (gid_t) t;
if (!(cp = strchr(cp, ':')))
goto cleanup;
cp++;
/*
* Parse the members out.
*/
while (*cp) {
if (num_members+1 >= pvt->nmemb || pvt->group.gr_mem == NULL) {
pvt->nmemb += 10;
new = realloc(pvt->group.gr_mem,
pvt->nmemb * sizeof(char *));
if (new == NULL)
goto cleanup;
pvt->group.gr_mem = new;
}
pvt->group.gr_mem[num_members++] = cp;
if (!(cp = strchr(cp, ',')))
break;
*cp++ = '\0';
}
if (!pvt->group.gr_mem) {
pvt->group.gr_mem = malloc(sizeof(char*));
if (!pvt->group.gr_mem)
goto cleanup;
}
pvt->group.gr_mem[num_members] = NULL;
return (&pvt->group);
cleanup:
if (pvt->group.gr_mem) {
free(pvt->group.gr_mem);
pvt->group.gr_mem = NULL;
}
if (pvt->membuf) {
free(pvt->membuf);
pvt->membuf = NULL;
}
return (NULL);
}
static struct __res_state *
gr_res_get(struct irs_gr *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
return (__hesiod_res_get(dns->hes_ctx));
}
static void
gr_res_set(struct irs_gr *this, struct __res_state * res,
void (*free_res)(void *)) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
__hesiod_res_set(dns->hes_ctx, res, free_res);
}
#endif /* WANT_IRS_GR */

File diff suppressed because it is too large Load Diff

View File

@ -1,591 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: dns_nw.c,v 1.9.18.3 2005/04/27 05:00:55 sra Exp $";
#endif /* LIBC_SCCS and not lint */
/* Imports. */
#include "port_before.h"
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.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
# define SPRINTF(x) strlen(sprintf/**/x)
#else
# define SPRINTF(x) sprintf x
#endif
/* Definitions. */
#define MAXALIASES 35
#define MAXPACKET (64*1024)
struct pvt {
struct nwent net;
char * ali[MAXALIASES];
char buf[BUFSIZ+1];
struct __res_state * res;
void (*free_res)(void *);
};
typedef union {
long al;
char ac;
} align;
enum by_what { by_addr, by_name };
/* Forwards. */
static void nw_close(struct irs_nw *);
static struct nwent * nw_byname(struct irs_nw *, const char *, int);
static struct nwent * nw_byaddr(struct irs_nw *, void *, int, int);
static struct nwent * nw_next(struct irs_nw *);
static void nw_rewind(struct irs_nw *);
static void nw_minimize(struct irs_nw *);
static struct __res_state * nw_res_get(struct irs_nw *this);
static void nw_res_set(struct irs_nw *this,
struct __res_state *res,
void (*free_res)(void *));
static struct nwent * get1101byaddr(struct irs_nw *, u_char *, int);
static struct nwent * get1101byname(struct irs_nw *, const char *);
static struct nwent * get1101answer(struct irs_nw *,
u_char *ansbuf, int anslen,
enum by_what by_what,
int af, const char *name,
const u_char *addr, int addrlen);
static struct nwent * get1101mask(struct irs_nw *this, struct nwent *);
static int make1101inaddr(const u_char *, int, char *, int);
static void normalize_name(char *name);
static int init(struct irs_nw *this);
/* Exports. */
struct irs_nw *
irs_dns_nw(struct irs_acc *this) {
struct irs_nw *nw;
struct pvt *pvt;
UNUSED(this);
if (!(pvt = memget(sizeof *pvt))) {
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
if (!(nw = memget(sizeof *nw))) {
memput(pvt, sizeof *pvt);
errno = ENOMEM;
return (NULL);
}
memset(nw, 0x5e, sizeof *nw);
nw->private = pvt;
nw->close = nw_close;
nw->byname = nw_byname;
nw->byaddr = nw_byaddr;
nw->next = nw_next;
nw->rewind = nw_rewind;
nw->minimize = nw_minimize;
nw->res_get = nw_res_get;
nw->res_set = nw_res_set;
return (nw);
}
/* Methods. */
static void
nw_close(struct irs_nw *this) {
struct pvt *pvt = (struct pvt *)this->private;
nw_minimize(this);
if (pvt->res && pvt->free_res)
(*pvt->free_res)(pvt->res);
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static struct nwent *
nw_byname(struct irs_nw *this, const char *name, int af) {
struct pvt *pvt = (struct pvt *)this->private;
if (init(this) == -1)
return (NULL);
switch (af) {
case AF_INET:
return (get1101byname(this, name));
default:
(void)NULL;
}
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
errno = EAFNOSUPPORT;
return (NULL);
}
static struct nwent *
nw_byaddr(struct irs_nw *this, void *net, int len, int af) {
struct pvt *pvt = (struct pvt *)this->private;
if (init(this) == -1)
return (NULL);
switch (af) {
case AF_INET:
return (get1101byaddr(this, net, len));
default:
(void)NULL;
}
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
errno = EAFNOSUPPORT;
return (NULL);
}
static struct nwent *
nw_next(struct irs_nw *this) {
UNUSED(this);
return (NULL);
}
static void
nw_rewind(struct irs_nw *this) {
UNUSED(this);
/* NOOP */
}
static void
nw_minimize(struct irs_nw *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (pvt->res)
res_nclose(pvt->res);
}
static struct __res_state *
nw_res_get(struct irs_nw *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (!pvt->res) {
struct __res_state *res;
res = (struct __res_state *)malloc(sizeof *res);
if (!res) {
errno = ENOMEM;
return (NULL);
}
memset(res, 0, sizeof *res);
nw_res_set(this, res, free);
}
return (pvt->res);
}
static void
nw_res_set(struct irs_nw *this, struct __res_state *res,
void (*free_res)(void *)) {
struct pvt *pvt = (struct pvt *)this->private;
if (pvt->res && pvt->free_res) {
res_nclose(pvt->res);
(*pvt->free_res)(pvt->res);
}
pvt->res = res;
pvt->free_res = free_res;
}
/* Private. */
static struct nwent *
get1101byname(struct irs_nw *this, const char *name) {
struct pvt *pvt = (struct pvt *)this->private;
u_char *ansbuf;
int anslen;
struct nwent *result;
ansbuf = memget(MAXPACKET);
if (ansbuf == NULL) {
errno = ENOMEM;
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
return (NULL);
}
anslen = res_nsearch(pvt->res, name, C_IN, T_PTR, ansbuf, MAXPACKET);
if (anslen < 0) {
memput(ansbuf, MAXPACKET);
return (NULL);
}
result = get1101mask(this, get1101answer(this, ansbuf, anslen, by_name,
AF_INET, name, NULL, 0));
memput(ansbuf, MAXPACKET);
return (result);
}
static struct nwent *
get1101byaddr(struct irs_nw *this, u_char *net, int len) {
struct pvt *pvt = (struct pvt *)this->private;
char qbuf[sizeof "255.255.255.255.in-addr.arpa"];
struct nwent *result;
u_char *ansbuf;
int anslen;
if (len < 1 || len > 32) {
errno = EINVAL;
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
return (NULL);
}
if (make1101inaddr(net, len, qbuf, sizeof qbuf) < 0)
return (NULL);
ansbuf = memget(MAXPACKET);
if (ansbuf == NULL) {
errno = ENOMEM;
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
return (NULL);
}
anslen = res_nquery(pvt->res, qbuf, C_IN, T_PTR, ansbuf, MAXPACKET);
if (anslen < 0) {
memput(ansbuf, MAXPACKET);
return (NULL);
}
result = get1101mask(this, get1101answer(this, ansbuf, anslen, by_addr,
AF_INET, NULL, net, len));
memput(ansbuf, MAXPACKET);
return (result);
}
static struct nwent *
get1101answer(struct irs_nw *this,
u_char *ansbuf, int anslen, enum by_what by_what,
int af, const char *name, const u_char *addr, int addrlen)
{
struct pvt *pvt = (struct pvt *)this->private;
int type, class, ancount, qdcount, haveanswer;
char *bp, *ep, **ap;
u_char *cp, *eom;
HEADER *hp;
/* Initialize, and parse header. */
eom = ansbuf + anslen;
if (ansbuf + HFIXEDSZ > eom) {
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
return (NULL);
}
hp = (HEADER *)ansbuf;
cp = ansbuf + HFIXEDSZ;
qdcount = ntohs(hp->qdcount);
while (qdcount-- > 0) {
int n = dn_skipname(cp, eom);
cp += n + QFIXEDSZ;
if (n < 0 || cp > eom) {
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
return (NULL);
}
}
ancount = ntohs(hp->ancount);
if (!ancount) {
if (hp->aa)
RES_SET_H_ERRNO(pvt->res, HOST_NOT_FOUND);
else
RES_SET_H_ERRNO(pvt->res, TRY_AGAIN);
return (NULL);
}
/* Prepare a return structure. */
bp = pvt->buf;
ep = pvt->buf + sizeof(pvt->buf);
pvt->net.n_name = NULL;
pvt->net.n_aliases = pvt->ali;
pvt->net.n_addrtype = af;
pvt->net.n_addr = NULL;
pvt->net.n_length = addrlen;
/* Save input key if given. */
switch (by_what) {
case by_name:
if (name != NULL) {
int n = strlen(name) + 1;
if (n > (ep - bp)) {
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
return (NULL);
}
pvt->net.n_name = strcpy(bp, name); /* (checked) */
bp += n;
}
break;
case by_addr:
if (addr != NULL && addrlen != 0) {
int n = addrlen / 8 + ((addrlen % 8) != 0);
if (INADDRSZ > (ep - bp)) {
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
return (NULL);
}
memset(bp, 0, INADDRSZ);
memcpy(bp, addr, n);
pvt->net.n_addr = bp;
bp += INADDRSZ;
}
break;
default:
abort();
}
/* Parse the answer, collect aliases. */
ap = pvt->ali;
haveanswer = 0;
while (--ancount >= 0 && cp < eom) {
int n = dn_expand(ansbuf, eom, cp, bp, ep - bp);
cp += n; /*%< Owner */
if (n < 0 || !maybe_dnok(pvt->res, bp) ||
cp + 3 * INT16SZ + INT32SZ > eom) {
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
return (NULL);
}
GETSHORT(type, cp); /*%< Type */
GETSHORT(class, cp); /*%< Class */
cp += INT32SZ; /*%< TTL */
GETSHORT(n, cp); /*%< RDLENGTH */
if (class == C_IN && type == T_PTR) {
int nn;
nn = dn_expand(ansbuf, eom, cp, bp, ep - bp);
if (nn < 0 || !maybe_hnok(pvt->res, bp) || nn != n) {
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
return (NULL);
}
normalize_name(bp);
switch (by_what) {
case by_addr: {
if (pvt->net.n_name == NULL)
pvt->net.n_name = bp;
else if (ns_samename(pvt->net.n_name, bp) == 1)
break;
else
*ap++ = bp;
nn = strlen(bp) + 1;
bp += nn;
haveanswer++;
break;
}
case by_name: {
u_int b1, b2, b3, b4;
if (pvt->net.n_addr != NULL ||
sscanf(bp, "%u.%u.%u.%u.in-addr.arpa",
&b1, &b2, &b3, &b4) != 4)
break;
if ((ep - bp) < INADDRSZ) {
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
return (NULL);
}
pvt->net.n_addr = bp;
*bp++ = b4;
*bp++ = b3;
*bp++ = b2;
*bp++ = b1;
pvt->net.n_length = INADDRSZ * 8;
haveanswer++;
}
}
}
cp += n; /*%< RDATA */
}
if (!haveanswer) {
RES_SET_H_ERRNO(pvt->res, TRY_AGAIN);
return (NULL);
}
*ap = NULL;
return (&pvt->net);
}
static struct nwent *
get1101mask(struct irs_nw *this, struct nwent *nwent) {
struct pvt *pvt = (struct pvt *)this->private;
char qbuf[sizeof "255.255.255.255.in-addr.arpa"], owner[MAXDNAME];
int anslen, type, class, ancount, qdcount;
u_char *ansbuf, *cp, *eom;
HEADER *hp;
if (!nwent)
return (NULL);
if (make1101inaddr(nwent->n_addr, nwent->n_length, qbuf, sizeof qbuf)
< 0) {
/* "First, do no harm." */
return (nwent);
}
ansbuf = memget(MAXPACKET);
if (ansbuf == NULL) {
errno = ENOMEM;
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
return (NULL);
}
/* Query for the A RR that would hold this network's mask. */
anslen = res_nquery(pvt->res, qbuf, C_IN, T_A, ansbuf, MAXPACKET);
if (anslen < HFIXEDSZ) {
memput(ansbuf, MAXPACKET);
return (nwent);
}
/* Initialize, and parse header. */
hp = (HEADER *)ansbuf;
cp = ansbuf + HFIXEDSZ;
eom = ansbuf + anslen;
qdcount = ntohs(hp->qdcount);
while (qdcount-- > 0) {
int n = dn_skipname(cp, eom);
cp += n + QFIXEDSZ;
if (n < 0 || cp > eom) {
memput(ansbuf, MAXPACKET);
return (nwent);
}
}
ancount = ntohs(hp->ancount);
/* Parse the answer, collect aliases. */
while (--ancount >= 0 && cp < eom) {
int n = dn_expand(ansbuf, eom, cp, owner, sizeof owner);
if (n < 0 || !maybe_dnok(pvt->res, owner))
break;
cp += n; /*%< Owner */
if (cp + 3 * INT16SZ + INT32SZ > eom)
break;
GETSHORT(type, cp); /*%< Type */
GETSHORT(class, cp); /*%< Class */
cp += INT32SZ; /*%< TTL */
GETSHORT(n, cp); /*%< RDLENGTH */
if (cp + n > eom)
break;
if (n == INADDRSZ && class == C_IN && type == T_A &&
ns_samename(qbuf, owner) == 1) {
/* This A RR indicates the actual netmask. */
int nn, mm;
nwent->n_length = 0;
for (nn = 0; nn < INADDRSZ; nn++)
for (mm = 7; mm >= 0; mm--)
if (cp[nn] & (1 << mm))
nwent->n_length++;
else
break;
}
cp += n; /*%< RDATA */
}
memput(ansbuf, MAXPACKET);
return (nwent);
}
static int
make1101inaddr(const u_char *net, int bits, char *name, int size) {
int n, m;
char *ep;
ep = name + size;
/* Zero fill any whole bytes left out of the prefix. */
for (n = (32 - bits) / 8; n > 0; n--) {
if (ep - name < (int)(sizeof "0."))
goto emsgsize;
m = SPRINTF((name, "0."));
name += m;
}
/* Format the partial byte, if any, within the prefix. */
if ((n = bits % 8) != 0) {
if (ep - name < (int)(sizeof "255."))
goto emsgsize;
m = SPRINTF((name, "%u.",
net[bits / 8] & ~((1 << (8 - n)) - 1)));
name += m;
}
/* Format the whole bytes within the prefix. */
for (n = bits / 8; n > 0; n--) {
if (ep - name < (int)(sizeof "255."))
goto emsgsize;
m = SPRINTF((name, "%u.", net[n - 1]));
name += m;
}
/* Add the static text. */
if (ep - name < (int)(sizeof "in-addr.arpa"))
goto emsgsize;
(void) SPRINTF((name, "in-addr.arpa"));
return (0);
emsgsize:
errno = EMSGSIZE;
return (-1);
}
static void
normalize_name(char *name) {
char *t;
/* Make lower case. */
for (t = name; *t; t++)
if (isascii((unsigned char)*t) && isupper((unsigned char)*t))
*t = tolower((*t)&0xff);
/* Remove trailing dots. */
while (t > name && t[-1] == '.')
*--t = '\0';
}
static int
init(struct irs_nw *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (!pvt->res && !nw_res_get(this))
return (-1);
if (((pvt->res->options & RES_INIT) == 0U) &&
res_ninit(pvt->res) == -1)
return (-1);
return (0);
}
/*! \file */

View File

@ -1,52 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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: dns_p.h,v 1.3.18.1 2005/04/27 05:00:55 sra Exp $
*/
#ifndef _DNS_P_H_INCLUDED
#define _DNS_P_H_INCLUDED
#define maybe_ok(res, nm, ok) (((res)->options & RES_NOCHECKNAME) != 0U || \
(ok)(nm) != 0)
#define maybe_hnok(res, hn) maybe_ok((res), (hn), res_hnok)
#define maybe_dnok(res, dn) maybe_ok((res), (dn), res_dnok)
/*%
* Object state.
*/
struct dns_p {
void *hes_ctx;
struct __res_state *res;
void (*free_res) __P((void *));
};
/*
* Methods.
*/
extern struct irs_gr * irs_dns_gr __P((struct irs_acc *));
extern struct irs_pw * irs_dns_pw __P((struct irs_acc *));
extern struct irs_sv * irs_dns_sv __P((struct irs_acc *));
extern struct irs_pr * irs_dns_pr __P((struct irs_acc *));
extern struct irs_ho * irs_dns_ho __P((struct irs_acc *));
extern struct irs_nw * irs_dns_nw __P((struct irs_acc *));
#endif /*_DNS_P_H_INCLUDED*/
/*! \file */

View File

@ -1,268 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: dns_pr.c,v 1.4.18.1 2005/04/27 05:00:55 sra Exp $";
#endif
/* Imports */
#include "port_before.h"
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <ctype.h>
#include <stdlib.h>
#include <errno.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "hesiod.h"
#include "dns_p.h"
/* Types. */
struct pvt {
struct dns_p * dns;
struct protoent proto;
char * prbuf;
};
/* Forward. */
static void pr_close(struct irs_pr *);
static struct protoent * pr_byname(struct irs_pr *, const char *);
static struct protoent * pr_bynumber(struct irs_pr *, int);
static struct protoent * pr_next(struct irs_pr *);
static void pr_rewind(struct irs_pr *);
static void pr_minimize(struct irs_pr *);
static struct __res_state * pr_res_get(struct irs_pr *);
static void pr_res_set(struct irs_pr *,
struct __res_state *,
void (*)(void *));
static struct protoent * parse_hes_list(struct irs_pr *, char **);
/* Public. */
struct irs_pr *
irs_dns_pr(struct irs_acc *this) {
struct dns_p *dns = (struct dns_p *)this->private;
struct pvt *pvt;
struct irs_pr *pr;
if (!dns->hes_ctx) {
errno = ENODEV;
return (NULL);
}
if (!(pvt = memget(sizeof *pvt))) {
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
if (!(pr = memget(sizeof *pr))) {
memput(pvt, sizeof *pvt);
errno = ENOMEM;
return (NULL);
}
memset(pr, 0x5e, sizeof *pr);
pvt->dns = dns;
pr->private = pvt;
pr->byname = pr_byname;
pr->bynumber = pr_bynumber;
pr->next = pr_next;
pr->rewind = pr_rewind;
pr->close = pr_close;
pr->minimize = pr_minimize;
pr->res_get = pr_res_get;
pr->res_set = pr_res_set;
return (pr);
}
/* Methods. */
static void
pr_close(struct irs_pr *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (pvt->proto.p_aliases)
free(pvt->proto.p_aliases);
if (pvt->prbuf)
free(pvt->prbuf);
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static struct protoent *
pr_byname(struct irs_pr *this, const char *name) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
struct protoent *proto;
char **hes_list;
if (!(hes_list = hesiod_resolve(dns->hes_ctx, name, "protocol")))
return (NULL);
proto = parse_hes_list(this, hes_list);
hesiod_free_list(dns->hes_ctx, hes_list);
return (proto);
}
static struct protoent *
pr_bynumber(struct irs_pr *this, int num) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
struct protoent *proto;
char numstr[16];
char **hes_list;
sprintf(numstr, "%d", num);
if (!(hes_list = hesiod_resolve(dns->hes_ctx, numstr, "protonum")))
return (NULL);
proto = parse_hes_list(this, hes_list);
hesiod_free_list(dns->hes_ctx, hes_list);
return (proto);
}
static struct protoent *
pr_next(struct irs_pr *this) {
UNUSED(this);
errno = ENODEV;
return (NULL);
}
static void
pr_rewind(struct irs_pr *this) {
UNUSED(this);
/* NOOP */
}
static void
pr_minimize(struct irs_pr *this) {
UNUSED(this);
/* NOOP */
}
static struct __res_state *
pr_res_get(struct irs_pr *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
return (__hesiod_res_get(dns->hes_ctx));
}
static void
pr_res_set(struct irs_pr *this, struct __res_state * res,
void (*free_res)(void *)) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
__hesiod_res_set(dns->hes_ctx, res, free_res);
}
/* Private. */
static struct protoent *
parse_hes_list(struct irs_pr *this, char **hes_list) {
struct pvt *pvt = (struct pvt *)this->private;
char *p, *cp, **cpp, **new;
int num = 0;
int max = 0;
for (cpp = hes_list; *cpp; cpp++) {
cp = *cpp;
/* Strip away comments, if any. */
if ((p = strchr(cp, '#')))
*p = 0;
/* Skip blank lines. */
p = cp;
while (*p && !isspace((unsigned char)*p))
p++;
if (!*p)
continue;
/* OK, we've got a live one. Let's parse it for real. */
if (pvt->prbuf)
free(pvt->prbuf);
pvt->prbuf = strdup(cp);
p = pvt->prbuf;
pvt->proto.p_name = p;
while (*p && !isspace((unsigned char)*p))
p++;
if (!*p)
continue;
*p++ = '\0';
pvt->proto.p_proto = atoi(p);
while (*p && !isspace((unsigned char)*p))
p++;
if (*p)
*p++ = '\0';
while (*p) {
if ((num + 1) >= max || !pvt->proto.p_aliases) {
max += 10;
new = realloc(pvt->proto.p_aliases,
max * sizeof(char *));
if (!new) {
errno = ENOMEM;
goto cleanup;
}
pvt->proto.p_aliases = new;
}
pvt->proto.p_aliases[num++] = p;
while (*p && !isspace((unsigned char)*p))
p++;
if (*p)
*p++ = '\0';
}
if (!pvt->proto.p_aliases)
pvt->proto.p_aliases = malloc(sizeof(char *));
if (!pvt->proto.p_aliases)
goto cleanup;
pvt->proto.p_aliases[num] = NULL;
return (&pvt->proto);
}
cleanup:
if (pvt->proto.p_aliases) {
free(pvt->proto.p_aliases);
pvt->proto.p_aliases = NULL;
}
if (pvt->prbuf) {
free(pvt->prbuf);
pvt->prbuf = NULL;
}
return (NULL);
}
/*! \file */

View File

@ -1,232 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: dns_pw.c,v 1.2.18.1 2005/04/27 05:00:55 sra Exp $";
#endif
#include "port_before.h"
#ifndef WANT_IRS_PW
static int __bind_irs_pw_unneeded;
#else
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "hesiod.h"
#include "dns_p.h"
/* Types. */
struct pvt {
struct dns_p * dns;
struct passwd passwd;
char * pwbuf;
};
/* Forward. */
static void pw_close(struct irs_pw *);
static struct passwd * pw_byname(struct irs_pw *, const char *);
static struct passwd * pw_byuid(struct irs_pw *, uid_t);
static struct passwd * pw_next(struct irs_pw *);
static void pw_rewind(struct irs_pw *);
static void pw_minimize(struct irs_pw *);
static struct __res_state * pw_res_get(struct irs_pw *);
static void pw_res_set(struct irs_pw *,
struct __res_state *,
void (*)(void *));
static struct passwd * getpwcommon(struct irs_pw *, const char *,
const char *);
/* Public. */
struct irs_pw *
irs_dns_pw(struct irs_acc *this) {
struct dns_p *dns = (struct dns_p *)this->private;
struct irs_pw *pw;
struct pvt *pvt;
if (!dns || !dns->hes_ctx) {
errno = ENODEV;
return (NULL);
}
if (!(pvt = memget(sizeof *pvt))) {
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
pvt->dns = dns;
if (!(pw = memget(sizeof *pw))) {
memput(pvt, sizeof *pvt);
errno = ENOMEM;
return (NULL);
}
memset(pw, 0x5e, sizeof *pw);
pw->private = pvt;
pw->close = pw_close;
pw->byname = pw_byname;
pw->byuid = pw_byuid;
pw->next = pw_next;
pw->rewind = pw_rewind;
pw->minimize = pw_minimize;
pw->res_get = pw_res_get;
pw->res_set = pw_res_set;
return (pw);
}
/* Methods. */
static void
pw_close(struct irs_pw *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (pvt->pwbuf)
free(pvt->pwbuf);
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static struct passwd *
pw_byname(struct irs_pw *this, const char *nam) {
return (getpwcommon(this, nam, "passwd"));
}
static struct passwd *
pw_byuid(struct irs_pw *this, uid_t uid) {
char uidstr[16];
sprintf(uidstr, "%lu", (u_long)uid);
return (getpwcommon(this, uidstr, "uid"));
}
static struct passwd *
pw_next(struct irs_pw *this) {
UNUSED(this);
errno = ENODEV;
return (NULL);
}
static void
pw_rewind(struct irs_pw *this) {
UNUSED(this);
/* NOOP */
}
static void
pw_minimize(struct irs_pw *this) {
UNUSED(this);
/* NOOP */
}
static struct __res_state *
pw_res_get(struct irs_pw *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
return (__hesiod_res_get(dns->hes_ctx));
}
static void
pw_res_set(struct irs_pw *this, struct __res_state * res,
void (*free_res)(void *)) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
__hesiod_res_set(dns->hes_ctx, res, free_res);
}
/* Private. */
static struct passwd *
getpwcommon(struct irs_pw *this, const char *arg, const char *type) {
struct pvt *pvt = (struct pvt *)this->private;
char **hes_list, *cp;
if (!(hes_list = hesiod_resolve(pvt->dns->hes_ctx, arg, type)))
return (NULL);
if (!*hes_list) {
hesiod_free_list(pvt->dns->hes_ctx, hes_list);
errno = ENOENT;
return (NULL);
}
memset(&pvt->passwd, 0, sizeof pvt->passwd);
if (pvt->pwbuf)
free(pvt->pwbuf);
pvt->pwbuf = strdup(*hes_list);
hesiod_free_list(pvt->dns->hes_ctx, hes_list);
cp = pvt->pwbuf;
pvt->passwd.pw_name = cp;
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
pvt->passwd.pw_passwd = cp;
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
pvt->passwd.pw_uid = atoi(cp);
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
pvt->passwd.pw_gid = atoi(cp);
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
pvt->passwd.pw_gecos = cp;
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
pvt->passwd.pw_dir = cp;
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
pvt->passwd.pw_shell = cp;
return (&pvt->passwd);
cleanup:
free(pvt->pwbuf);
pvt->pwbuf = NULL;
return (NULL);
}
#endif /* WANT_IRS_PW */
/*! \file */

View File

@ -1,300 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: dns_sv.c,v 1.4.18.1 2005/04/27 05:00:55 sra Exp $";
#endif
/* Imports */
#include "port_before.h"
#include <sys/types.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <ctype.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "hesiod.h"
#include "dns_p.h"
/* Definitions */
struct pvt {
struct dns_p * dns;
struct servent serv;
char * svbuf;
struct __res_state * res;
void (*free_res)(void *);
};
/* Forward. */
static void sv_close(struct irs_sv *);
static struct servent * sv_byname(struct irs_sv *,
const char *, const char *);
static struct servent * sv_byport(struct irs_sv *, int, const char *);
static struct servent * sv_next(struct irs_sv *);
static void sv_rewind(struct irs_sv *);
static void sv_minimize(struct irs_sv *);
#ifdef SV_RES_SETGET
static struct __res_state * sv_res_get(struct irs_sv *);
static void sv_res_set(struct irs_sv *,
struct __res_state *,
void (*)(void *));
#endif
static struct servent * parse_hes_list(struct irs_sv *,
char **, const char *);
/* Public */
struct irs_sv *
irs_dns_sv(struct irs_acc *this) {
struct dns_p *dns = (struct dns_p *)this->private;
struct irs_sv *sv;
struct pvt *pvt;
if (!dns || !dns->hes_ctx) {
errno = ENODEV;
return (NULL);
}
if (!(pvt = memget(sizeof *pvt))) {
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
pvt->dns = dns;
if (!(sv = memget(sizeof *sv))) {
memput(pvt, sizeof *pvt);
errno = ENOMEM;
return (NULL);
}
memset(sv, 0x5e, sizeof *sv);
sv->private = pvt;
sv->byname = sv_byname;
sv->byport = sv_byport;
sv->next = sv_next;
sv->rewind = sv_rewind;
sv->close = sv_close;
sv->minimize = sv_minimize;
#ifdef SV_RES_SETGET
sv->res_get = sv_res_get;
sv->res_set = sv_res_set;
#else
sv->res_get = NULL; /*%< sv_res_get; */
sv->res_set = NULL; /*%< sv_res_set; */
#endif
return (sv);
}
/* Methods */
static void
sv_close(struct irs_sv *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (pvt->serv.s_aliases)
free(pvt->serv.s_aliases);
if (pvt->svbuf)
free(pvt->svbuf);
if (pvt->res && pvt->free_res)
(*pvt->free_res)(pvt->res);
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static struct servent *
sv_byname(struct irs_sv *this, const char *name, const char *proto) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
struct servent *s;
char **hes_list;
if (!(hes_list = hesiod_resolve(dns->hes_ctx, name, "service")))
return (NULL);
s = parse_hes_list(this, hes_list, proto);
hesiod_free_list(dns->hes_ctx, hes_list);
return (s);
}
static struct servent *
sv_byport(struct irs_sv *this, int port, const char *proto) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
struct servent *s;
char portstr[16];
char **hes_list;
sprintf(portstr, "%d", ntohs(port));
if (!(hes_list = hesiod_resolve(dns->hes_ctx, portstr, "port")))
return (NULL);
s = parse_hes_list(this, hes_list, proto);
hesiod_free_list(dns->hes_ctx, hes_list);
return (s);
}
static struct servent *
sv_next(struct irs_sv *this) {
UNUSED(this);
errno = ENODEV;
return (NULL);
}
static void
sv_rewind(struct irs_sv *this) {
UNUSED(this);
/* NOOP */
}
/* Private */
static struct servent *
parse_hes_list(struct irs_sv *this, char **hes_list, const char *proto) {
struct pvt *pvt = (struct pvt *)this->private;
char *p, *cp, **cpp, **new;
int proto_len;
int num = 0;
int max = 0;
for (cpp = hes_list; *cpp; cpp++) {
cp = *cpp;
/* Strip away comments, if any. */
if ((p = strchr(cp, '#')))
*p = 0;
/* Check to make sure the protocol matches. */
p = cp;
while (*p && !isspace((unsigned char)*p))
p++;
if (!*p)
continue;
if (proto) {
proto_len = strlen(proto);
if (strncasecmp(++p, proto, proto_len) != 0)
continue;
if (p[proto_len] && !isspace(p[proto_len]&0xff))
continue;
}
/* OK, we've got a live one. Let's parse it for real. */
if (pvt->svbuf)
free(pvt->svbuf);
pvt->svbuf = strdup(cp);
p = pvt->svbuf;
pvt->serv.s_name = p;
while (*p && !isspace(*p&0xff))
p++;
if (!*p)
continue;
*p++ = '\0';
pvt->serv.s_proto = p;
while (*p && !isspace(*p&0xff))
p++;
if (!*p)
continue;
*p++ = '\0';
pvt->serv.s_port = htons((u_short) atoi(p));
while (*p && !isspace(*p&0xff))
p++;
if (*p)
*p++ = '\0';
while (*p) {
if ((num + 1) >= max || !pvt->serv.s_aliases) {
max += 10;
new = realloc(pvt->serv.s_aliases,
max * sizeof(char *));
if (!new) {
errno = ENOMEM;
goto cleanup;
}
pvt->serv.s_aliases = new;
}
pvt->serv.s_aliases[num++] = p;
while (*p && !isspace(*p&0xff))
p++;
if (*p)
*p++ = '\0';
}
if (!pvt->serv.s_aliases)
pvt->serv.s_aliases = malloc(sizeof(char *));
if (!pvt->serv.s_aliases)
goto cleanup;
pvt->serv.s_aliases[num] = NULL;
return (&pvt->serv);
}
cleanup:
if (pvt->serv.s_aliases) {
free(pvt->serv.s_aliases);
pvt->serv.s_aliases = NULL;
}
if (pvt->svbuf) {
free(pvt->svbuf);
pvt->svbuf = NULL;
}
return (NULL);
}
static void
sv_minimize(struct irs_sv *this) {
UNUSED(this);
/* NOOP */
}
#ifdef SV_RES_SETGET
static struct __res_state *
sv_res_get(struct irs_sv *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
return (__hesiod_res_get(dns->hes_ctx));
}
static void
sv_res_set(struct irs_sv *this, struct __res_state * res,
void (*free_res)(void *)) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
__hesiod_res_set(dns->hes_ctx, res, free_res);
}
#endif
/*! \file */

View File

@ -1,105 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2001 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 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.
*/
#include <port_before.h>
#include <netdb.h>
#include <port_after.h>
#ifdef DO_PTHREADS
#include <pthread.h>
#include <stdlib.h>
#endif
static const char *gai_errlist[] = {
"no error",
"address family not supported for name",/*%< EAI_ADDRFAMILY */
"temporary failure", /*%< EAI_AGAIN */
"invalid flags", /*%< EAI_BADFLAGS */
"permanent failure", /*%< EAI_FAIL */
"address family not supported", /*%< EAI_FAMILY */
"memory failure", /*%< EAI_MEMORY */
"no address", /*%< EAI_NODATA */
"unknown name or service", /*%< EAI_NONAME */
"service not supported for socktype", /*%< EAI_SERVICE */
"socktype not supported", /*%< EAI_SOCKTYPE */
"system failure", /*%< EAI_SYSTEM */
"bad hints", /*%< EAI_BADHINTS */
"bad protocol", /*%< EAI_PROTOCOL */
"unknown error" /*%< Must be last. */
};
static const int gai_nerr = (sizeof(gai_errlist)/sizeof(*gai_errlist));
#define EAI_BUFSIZE 128
const char *
gai_strerror(int ecode) {
#ifndef DO_PTHREADS
static char buf[EAI_BUFSIZE];
#else /* DO_PTHREADS */
#ifndef LIBBIND_MUTEX_INITIALIZER
#define LIBBIND_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#endif
static pthread_mutex_t lock = LIBBIND_MUTEX_INITIALIZER;
static pthread_key_t key;
static int once = 0;
char *buf;
#endif
if (ecode >= 0 && ecode < (gai_nerr - 1))
return (gai_errlist[ecode]);
#ifdef DO_PTHREADS
if (!once) {
if (pthread_mutex_lock(&lock) != 0)
goto unknown;
if (!once) {
if (pthread_key_create(&key, free) != 0) {
(void)pthread_mutex_unlock(&lock);
goto unknown;
}
once = 1;
}
if (pthread_mutex_unlock(&lock) != 0)
goto unknown;
}
buf = pthread_getspecific(key);
if (buf == NULL) {
buf = malloc(EAI_BUFSIZE);
if (buf == NULL)
goto unknown;
if (pthread_setspecific(key, buf) != 0) {
free(buf);
goto unknown;
}
}
#endif
/*
* XXX This really should be snprintf(buf, EAI_BUFSIZE, ...).
* It is safe until message catalogs are used.
*/
sprintf(buf, "%s: %d", gai_errlist[gai_nerr - 1], ecode);
return (buf);
#ifdef DO_PTHREADS
unknown:
return ("unknown error");
#endif
}
/*! \file */

View File

@ -1,433 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: gen.c,v 1.5.18.2 2005/04/27 05:00:56 sra Exp $";
#endif
/*! \file
* \brief
* this is the top level dispatcher
*
* The dispatcher is implemented as an accessor class; it is an
* accessor class that calls other accessor classes, as controlled by a
* configuration file.
*
* A big difference between this accessor class and others is that the
* map class initializers are NULL, and the map classes are already
* filled in with method functions that will do the right thing.
*/
/* Imports */
#include "port_before.h"
#include <isc/assertions.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "gen_p.h"
/* Definitions */
struct nameval {
const char * name;
int val;
};
static const struct nameval acc_names[irs_nacc+1] = {
{ "local", irs_lcl },
{ "dns", irs_dns },
{ "nis", irs_nis },
{ "irp", irs_irp },
{ NULL, irs_nacc }
};
typedef struct irs_acc *(*accinit) __P((const char *options));
static const accinit accs[irs_nacc+1] = {
irs_lcl_acc,
irs_dns_acc,
#ifdef WANT_IRS_NIS
irs_nis_acc,
#else
NULL,
#endif
irs_irp_acc,
NULL
};
static const struct nameval map_names[irs_nmap+1] = {
{ "group", irs_gr },
{ "passwd", irs_pw },
{ "services", irs_sv },
{ "protocols", irs_pr },
{ "hosts", irs_ho },
{ "networks", irs_nw },
{ "netgroup", irs_ng },
{ NULL, irs_nmap }
};
static const struct nameval option_names[] = {
{ "merge", IRS_MERGE },
{ "continue", IRS_CONTINUE },
{ NULL, 0 }
};
/* Forward */
static void gen_close(struct irs_acc *);
static struct __res_state * gen_res_get(struct irs_acc *);
static void gen_res_set(struct irs_acc *, struct __res_state *,
void (*)(void *));
static int find_name(const char *, const struct nameval nv[]);
static void init_map_rules(struct gen_p *, const char *conf_file);
static struct irs_rule *release_rule(struct irs_rule *);
static int add_rule(struct gen_p *,
enum irs_map_id, enum irs_acc_id,
const char *);
/* Public */
struct irs_acc *
irs_gen_acc(const char *options, const char *conf_file) {
struct irs_acc *acc;
struct gen_p *irs;
if (!(acc = memget(sizeof *acc))) {
errno = ENOMEM;
return (NULL);
}
memset(acc, 0x5e, sizeof *acc);
if (!(irs = memget(sizeof *irs))) {
errno = ENOMEM;
memput(acc, sizeof *acc);
return (NULL);
}
memset(irs, 0x5e, sizeof *irs);
irs->options = strdup(options);
irs->res = NULL;
irs->free_res = NULL;
memset(irs->accessors, 0, sizeof irs->accessors);
memset(irs->map_rules, 0, sizeof irs->map_rules);
init_map_rules(irs, conf_file);
acc->private = irs;
#ifdef WANT_IRS_GR
acc->gr_map = irs_gen_gr;
#else
acc->gr_map = NULL;
#endif
#ifdef WANT_IRS_PW
acc->pw_map = irs_gen_pw;
#else
acc->pw_map = NULL;
#endif
acc->sv_map = irs_gen_sv;
acc->pr_map = irs_gen_pr;
acc->ho_map = irs_gen_ho;
acc->nw_map = irs_gen_nw;
acc->ng_map = irs_gen_ng;
acc->res_get = gen_res_get;
acc->res_set = gen_res_set;
acc->close = gen_close;
return (acc);
}
/* Methods */
static struct __res_state *
gen_res_get(struct irs_acc *this) {
struct gen_p *irs = (struct gen_p *)this->private;
if (irs->res == NULL) {
struct __res_state *res;
res = (struct __res_state *)malloc(sizeof *res);
if (res == NULL)
return (NULL);
memset(res, 0, sizeof *res);
gen_res_set(this, res, free);
}
if (((irs->res->options & RES_INIT) == 0U) && res_ninit(irs->res) < 0)
return (NULL);
return (irs->res);
}
static void
gen_res_set(struct irs_acc *this, struct __res_state *res,
void (*free_res)(void *)) {
struct gen_p *irs = (struct gen_p *)this->private;
#if 0
struct irs_rule *rule;
struct irs_ho *ho;
struct irs_nw *nw;
#endif
if (irs->res && irs->free_res) {
res_nclose(irs->res);
(*irs->free_res)(irs->res);
}
irs->res = res;
irs->free_res = free_res;
#if 0
for (rule = irs->map_rules[irs_ho]; rule; rule = rule->next) {
ho = rule->inst->ho;
(*ho->res_set)(ho, res, NULL);
}
for (rule = irs->map_rules[irs_nw]; rule; rule = rule->next) {
nw = rule->inst->nw;
(*nw->res_set)(nw, res, NULL);
}
#endif
}
static void
gen_close(struct irs_acc *this) {
struct gen_p *irs = (struct gen_p *)this->private;
int n;
/* Search rules. */
for (n = 0; n < irs_nmap; n++)
while (irs->map_rules[n] != NULL)
irs->map_rules[n] = release_rule(irs->map_rules[n]);
/* Access methods. */
for (n = 0; n < irs_nacc; n++) {
/* Map objects. */
if (irs->accessors[n].gr != NULL)
(*irs->accessors[n].gr->close)(irs->accessors[n].gr);
if (irs->accessors[n].pw != NULL)
(*irs->accessors[n].pw->close)(irs->accessors[n].pw);
if (irs->accessors[n].sv != NULL)
(*irs->accessors[n].sv->close)(irs->accessors[n].sv);
if (irs->accessors[n].pr != NULL)
(*irs->accessors[n].pr->close)(irs->accessors[n].pr);
if (irs->accessors[n].ho != NULL)
(*irs->accessors[n].ho->close)(irs->accessors[n].ho);
if (irs->accessors[n].nw != NULL)
(*irs->accessors[n].nw->close)(irs->accessors[n].nw);
if (irs->accessors[n].ng != NULL)
(*irs->accessors[n].ng->close)(irs->accessors[n].ng);
/* Enclosing accessor. */
if (irs->accessors[n].acc != NULL)
(*irs->accessors[n].acc->close)(irs->accessors[n].acc);
}
/* The options string was strdup'd. */
free((void*)irs->options);
if (irs->res && irs->free_res)
(*irs->free_res)(irs->res);
/* The private data container. */
memput(irs, sizeof *irs);
/* The object. */
memput(this, sizeof *this);
}
/* Private */
static int
find_name(const char *name, const struct nameval names[]) {
int n;
for (n = 0; names[n].name != NULL; n++)
if (strcmp(name, names[n].name) == 0)
return (names[n].val);
return (-1);
}
static struct irs_rule *
release_rule(struct irs_rule *rule) {
struct irs_rule *next = rule->next;
memput(rule, sizeof *rule);
return (next);
}
static int
add_rule(struct gen_p *irs,
enum irs_map_id map, enum irs_acc_id acc,
const char *options)
{
struct irs_rule **rules, *last, *tmp, *new;
struct irs_inst *inst;
const char *cp;
int n;
#ifndef WANT_IRS_GR
if (map == irs_gr)
return (-1);
#endif
#ifndef WANT_IRS_PW
if (map == irs_pw)
return (-1);
#endif
#ifndef WANT_IRS_NIS
if (acc == irs_nis)
return (-1);
#endif
new = memget(sizeof *new);
if (new == NULL)
return (-1);
memset(new, 0x5e, sizeof *new);
new->next = NULL;
new->inst = &irs->accessors[acc];
new->flags = 0;
cp = options;
while (cp && *cp) {
char option[50], *next;
next = strchr(cp, ',');
if (next)
n = next++ - cp;
else
n = strlen(cp);
if ((size_t)n > sizeof option - 1)
n = sizeof option - 1;
strncpy(option, cp, n);
option[n] = '\0';
n = find_name(option, option_names);
if (n >= 0)
new->flags |= n;
cp = next;
}
rules = &irs->map_rules[map];
for (last = NULL, tmp = *rules;
tmp != NULL;
last = tmp, tmp = tmp->next)
(void)NULL;
if (last == NULL)
*rules = new;
else
last->next = new;
/* Try to instantiate map accessors for this if necessary & approp. */
inst = &irs->accessors[acc];
if (inst->acc == NULL && accs[acc] != NULL)
inst->acc = (*accs[acc])(irs->options);
if (inst->acc != NULL) {
if (inst->gr == NULL && inst->acc->gr_map != NULL)
inst->gr = (*inst->acc->gr_map)(inst->acc);
if (inst->pw == NULL && inst->acc->pw_map != NULL)
inst->pw = (*inst->acc->pw_map)(inst->acc);
if (inst->sv == NULL && inst->acc->sv_map != NULL)
inst->sv = (*inst->acc->sv_map)(inst->acc);
if (inst->pr == NULL && inst->acc->pr_map != NULL)
inst->pr = (*inst->acc->pr_map)(inst->acc);
if (inst->ho == NULL && inst->acc->ho_map != NULL)
inst->ho = (*inst->acc->ho_map)(inst->acc);
if (inst->nw == NULL && inst->acc->nw_map != NULL)
inst->nw = (*inst->acc->nw_map)(inst->acc);
if (inst->ng == NULL && inst->acc->ng_map != NULL)
inst->ng = (*inst->acc->ng_map)(inst->acc);
}
return (0);
}
static void
default_map_rules(struct gen_p *irs) {
/* Install time honoured and proved BSD style rules as default. */
add_rule(irs, irs_gr, irs_lcl, "");
add_rule(irs, irs_pw, irs_lcl, "");
add_rule(irs, irs_sv, irs_lcl, "");
add_rule(irs, irs_pr, irs_lcl, "");
add_rule(irs, irs_ho, irs_dns, "continue");
add_rule(irs, irs_ho, irs_lcl, "");
add_rule(irs, irs_nw, irs_dns, "continue");
add_rule(irs, irs_nw, irs_lcl, "");
add_rule(irs, irs_ng, irs_lcl, "");
}
static void
init_map_rules(struct gen_p *irs, const char *conf_file) {
char line[1024], pattern[40], mapname[20], accname[20], options[100];
FILE *conf;
if (conf_file == NULL)
conf_file = _PATH_IRS_CONF ;
/* A conf file of "" means compiled in defaults. Irpd wants this */
if (conf_file[0] == '\0' || (conf = fopen(conf_file, "r")) == NULL) {
default_map_rules(irs);
return;
}
(void) sprintf(pattern, "%%%lus %%%lus %%%lus\n",
(unsigned long)sizeof mapname,
(unsigned long)sizeof accname,
(unsigned long)sizeof options);
while (fgets(line, sizeof line, conf)) {
enum irs_map_id map;
enum irs_acc_id acc;
char *tmp;
int n;
for (tmp = line;
isascii((unsigned char)*tmp) &&
isspace((unsigned char)*tmp);
tmp++)
(void)NULL;
if (*tmp == '#' || *tmp == '\n' || *tmp == '\0')
continue;
n = sscanf(tmp, pattern, mapname, accname, options);
if (n < 2)
continue;
if (n < 3)
options[0] = '\0';
n = find_name(mapname, map_names);
INSIST(n < irs_nmap);
if (n < 0)
continue;
map = (enum irs_map_id) n;
n = find_name(accname, acc_names);
INSIST(n < irs_nacc);
if (n < 0)
continue;
acc = (enum irs_acc_id) n;
add_rule(irs, map, acc, options);
}
fclose(conf);
}

View File

@ -1,493 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: gen_gr.c,v 1.6.18.2 2005/04/27 05:00:56 sra Exp $";
#endif
/* Imports */
#include "port_before.h"
#ifndef WANT_IRS_GR
static int __bind_irs_gr_unneeded;
#else
#include <sys/types.h>
#include <isc/assertions.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "gen_p.h"
/* Definitions */
struct pvt {
struct irs_rule * rules;
struct irs_rule * rule;
struct irs_gr * gr;
/*
* Need space to store the entries read from the group file.
* The members list also needs space per member, and the
* strings making up the user names must be allocated
* somewhere. Rather than doing lots of small allocations,
* we keep one buffer and resize it as needed.
*/
struct group group;
size_t nmemb; /*%< Malloc'd max index of gr_mem[]. */
char * membuf;
size_t membufsize;
struct __res_state * res;
void (*free_res)(void *);
};
/* Forward */
static void gr_close(struct irs_gr *);
static struct group * gr_next(struct irs_gr *);
static struct group * gr_byname(struct irs_gr *, const char *);
static struct group * gr_bygid(struct irs_gr *, gid_t);
static void gr_rewind(struct irs_gr *);
static int gr_list(struct irs_gr *, const char *,
gid_t, gid_t *, int *);
static void gr_minimize(struct irs_gr *);
static struct __res_state * gr_res_get(struct irs_gr *);
static void gr_res_set(struct irs_gr *,
struct __res_state *,
void (*)(void *));
static int grmerge(struct irs_gr *gr, const struct group *src,
int preserve);
static int countvec(char **vec);
static int isnew(char **old, char *new);
static int countnew(char **old, char **new);
static size_t sizenew(char **old, char **new);
static int newgid(int, gid_t *, gid_t);
/* Macros */
#define FREE_IF(x) do { if ((x) != NULL) { free(x); (x) = NULL; } } while (0)
/* Public */
struct irs_gr *
irs_gen_gr(struct irs_acc *this) {
struct gen_p *accpvt = (struct gen_p *)this->private;
struct irs_gr *gr;
struct pvt *pvt;
if (!(gr = memget(sizeof *gr))) {
errno = ENOMEM;
return (NULL);
}
memset(gr, 0x5e, sizeof *gr);
if (!(pvt = memget(sizeof *pvt))) {
memput(gr, sizeof *gr);
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
pvt->rules = accpvt->map_rules[irs_gr];
pvt->rule = pvt->rules;
gr->private = pvt;
gr->close = gr_close;
gr->next = gr_next;
gr->byname = gr_byname;
gr->bygid = gr_bygid;
gr->rewind = gr_rewind;
gr->list = gr_list;
gr->minimize = gr_minimize;
gr->res_get = gr_res_get;
gr->res_set = gr_res_set;
return (gr);
}
/* Methods. */
static void
gr_close(struct irs_gr *this) {
struct pvt *pvt = (struct pvt *)this->private;
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static struct group *
gr_next(struct irs_gr *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct group *rval;
struct irs_gr *gr;
while (pvt->rule) {
gr = pvt->rule->inst->gr;
rval = (*gr->next)(gr);
if (rval)
return (rval);
if (!(pvt->rule->flags & IRS_CONTINUE))
break;
pvt->rule = pvt->rule->next;
if (pvt->rule) {
gr = pvt->rule->inst->gr;
(*gr->rewind)(gr);
}
}
return (NULL);
}
static struct group *
gr_byname(struct irs_gr *this, const char *name) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct group *tval;
struct irs_gr *gr;
int dirty;
dirty = 0;
for (rule = pvt->rules; rule; rule = rule->next) {
gr = rule->inst->gr;
tval = (*gr->byname)(gr, name);
if (tval) {
if (!grmerge(this, tval, dirty++))
return (NULL);
if (!(rule->flags & IRS_MERGE))
break;
} else {
if (!(rule->flags & IRS_CONTINUE))
break;
}
}
if (dirty)
return (&pvt->group);
return (NULL);
}
static struct group *
gr_bygid(struct irs_gr *this, gid_t gid) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct group *tval;
struct irs_gr *gr;
int dirty;
dirty = 0;
for (rule = pvt->rules; rule; rule = rule->next) {
gr = rule->inst->gr;
tval = (*gr->bygid)(gr, gid);
if (tval) {
if (!grmerge(this, tval, dirty++))
return (NULL);
if (!(rule->flags & IRS_MERGE))
break;
} else {
if (!(rule->flags & IRS_CONTINUE))
break;
}
}
if (dirty)
return (&pvt->group);
return (NULL);
}
static void
gr_rewind(struct irs_gr *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_gr *gr;
pvt->rule = pvt->rules;
if (pvt->rule) {
gr = pvt->rule->inst->gr;
(*gr->rewind)(gr);
}
}
static int
gr_list(struct irs_gr *this, const char *name,
gid_t basegid, gid_t *groups, int *ngroups)
{
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct irs_gr *gr;
int t_ngroups, maxgroups;
gid_t *t_groups;
int n, t, rval = 0;
maxgroups = *ngroups;
*ngroups = 0;
t_groups = (gid_t *)malloc(maxgroups * sizeof(gid_t));
if (!t_groups) {
errno = ENOMEM;
return (-1);
}
for (rule = pvt->rules; rule; rule = rule->next) {
t_ngroups = maxgroups;
gr = rule->inst->gr;
t = (*gr->list)(gr, name, basegid, t_groups, &t_ngroups);
for (n = 0; n < t_ngroups; n++) {
if (newgid(*ngroups, groups, t_groups[n])) {
if (*ngroups == maxgroups) {
rval = -1;
goto done;
}
groups[(*ngroups)++] = t_groups[n];
}
}
if (t == 0) {
if (!(rule->flags & IRS_MERGE))
break;
} else {
if (!(rule->flags & IRS_CONTINUE))
break;
}
}
done:
free(t_groups);
return (rval);
}
static void
gr_minimize(struct irs_gr *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_gr *gr = rule->inst->gr;
(*gr->minimize)(gr);
}
}
static struct __res_state *
gr_res_get(struct irs_gr *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (!pvt->res) {
struct __res_state *res;
res = (struct __res_state *)malloc(sizeof *res);
if (!res) {
errno = ENOMEM;
return (NULL);
}
memset(res, 0, sizeof *res);
gr_res_set(this, res, free);
}
return (pvt->res);
}
static void
gr_res_set(struct irs_gr *this, struct __res_state *res,
void (*free_res)(void *)) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
if (pvt->res && pvt->free_res) {
res_nclose(pvt->res);
(*pvt->free_res)(pvt->res);
}
pvt->res = res;
pvt->free_res = free_res;
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_gr *gr = rule->inst->gr;
if (gr->res_set)
(*gr->res_set)(gr, pvt->res, NULL);
}
}
/* Private. */
static int
grmerge(struct irs_gr *this, const struct group *src, int preserve) {
struct pvt *pvt = (struct pvt *)this->private;
char *cp, **m, **p, *oldmembuf, *ep;
int n, ndst, nnew;
size_t used;
if (!preserve) {
pvt->group.gr_gid = src->gr_gid;
if (pvt->nmemb < 1) {
m = malloc(sizeof *m);
if (m == NULL) {
/* No harm done, no work done. */
return (0);
}
pvt->group.gr_mem = m;
pvt->nmemb = 1;
}
pvt->group.gr_mem[0] = NULL;
}
ndst = countvec(pvt->group.gr_mem);
nnew = countnew(pvt->group.gr_mem, src->gr_mem);
/*
* Make sure destination member array is large enough.
* p points to new portion.
*/
n = ndst + nnew + 1;
if ((size_t)n > pvt->nmemb) {
m = realloc(pvt->group.gr_mem, n * sizeof *m);
if (m == NULL) {
/* No harm done, no work done. */
return (0);
}
pvt->group.gr_mem = m;
pvt->nmemb = n;
}
p = pvt->group.gr_mem + ndst;
/*
* Enlarge destination membuf; cp points at new portion.
*/
n = sizenew(pvt->group.gr_mem, src->gr_mem);
INSIST((nnew == 0) == (n == 0));
if (!preserve) {
n += strlen(src->gr_name) + 1;
n += strlen(src->gr_passwd) + 1;
}
if (n == 0) {
/* No work to do. */
return (1);
}
used = preserve ? pvt->membufsize : 0;
cp = malloc(used + n);
if (cp == NULL) {
/* No harm done, no work done. */
return (0);
}
ep = cp + used + n;
if (used != 0)
memcpy(cp, pvt->membuf, used);
oldmembuf = pvt->membuf;
pvt->membuf = cp;
pvt->membufsize = used + n;
cp += used;
/*
* Adjust group.gr_mem.
*/
if (pvt->membuf != oldmembuf)
for (m = pvt->group.gr_mem; *m; m++)
*m = pvt->membuf + (*m - oldmembuf);
/*
* Add new elements.
*/
for (m = src->gr_mem; *m; m++)
if (isnew(pvt->group.gr_mem, *m)) {
*p++ = cp;
*p = NULL;
n = strlen(*m) + 1;
if (n > ep - cp) {
FREE_IF(oldmembuf);
return (0);
}
strcpy(cp, *m); /* (checked) */
cp += n;
}
if (preserve) {
pvt->group.gr_name = pvt->membuf +
(pvt->group.gr_name - oldmembuf);
pvt->group.gr_passwd = pvt->membuf +
(pvt->group.gr_passwd - oldmembuf);
} else {
pvt->group.gr_name = cp;
n = strlen(src->gr_name) + 1;
if (n > ep - cp) {
FREE_IF(oldmembuf);
return (0);
}
strcpy(cp, src->gr_name); /* (checked) */
cp += n;
pvt->group.gr_passwd = cp;
n = strlen(src->gr_passwd) + 1;
if (n > ep - cp) {
FREE_IF(oldmembuf);
return (0);
}
strcpy(cp, src->gr_passwd); /* (checked) */
cp += n;
}
FREE_IF(oldmembuf);
INSIST(cp >= pvt->membuf && cp <= &pvt->membuf[pvt->membufsize]);
return (1);
}
static int
countvec(char **vec) {
int n = 0;
while (*vec++)
n++;
return (n);
}
static int
isnew(char **old, char *new) {
for (; *old; old++)
if (strcmp(*old, new) == 0)
return (0);
return (1);
}
static int
countnew(char **old, char **new) {
int n = 0;
for (; *new; new++)
n += isnew(old, *new);
return (n);
}
static size_t
sizenew(char **old, char **new) {
size_t n = 0;
for (; *new; new++)
if (isnew(old, *new))
n += strlen(*new) + 1;
return (n);
}
static int
newgid(int ngroups, gid_t *groups, gid_t group) {
ngroups--, groups++;
for (; ngroups-- > 0; groups++)
if (*groups == group)
return (0);
return (1);
}
#endif /* WANT_IRS_GR */
/*! \file */

View File

@ -1,391 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: gen_ho.c,v 1.3.18.2 2006/03/10 00:20:08 marka Exp $";
#endif /* LIBC_SCCS and not lint */
/* Imports */
#include "port_before.h"
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <errno.h>
#include <stdlib.h>
#include <netdb.h>
#include <resolv.h>
#include <stdio.h>
#include <string.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "gen_p.h"
/* Definitions */
struct pvt {
struct irs_rule * rules;
struct irs_rule * rule;
struct irs_ho * ho;
struct __res_state * res;
void (*free_res)(void *);
};
/* Forwards */
static void ho_close(struct irs_ho *this);
static struct hostent * ho_byname(struct irs_ho *this, const char *name);
static struct hostent * ho_byname2(struct irs_ho *this, const char *name,
int af);
static struct hostent * ho_byaddr(struct irs_ho *this, const void *addr,
int len, int af);
static struct hostent * ho_next(struct irs_ho *this);
static void ho_rewind(struct irs_ho *this);
static void ho_minimize(struct irs_ho *this);
static struct __res_state * ho_res_get(struct irs_ho *this);
static void ho_res_set(struct irs_ho *this,
struct __res_state *res,
void (*free_res)(void *));
static struct addrinfo * ho_addrinfo(struct irs_ho *this, const char *name,
const struct addrinfo *pai);
static int init(struct irs_ho *this);
/* Exports */
struct irs_ho *
irs_gen_ho(struct irs_acc *this) {
struct gen_p *accpvt = (struct gen_p *)this->private;
struct irs_ho *ho;
struct pvt *pvt;
if (!(pvt = memget(sizeof *pvt))) {
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
if (!(ho = memget(sizeof *ho))) {
memput(pvt, sizeof *pvt);
errno = ENOMEM;
return (NULL);
}
memset(ho, 0x5e, sizeof *ho);
pvt->rules = accpvt->map_rules[irs_ho];
pvt->rule = pvt->rules;
ho->private = pvt;
ho->close = ho_close;
ho->byname = ho_byname;
ho->byname2 = ho_byname2;
ho->byaddr = ho_byaddr;
ho->next = ho_next;
ho->rewind = ho_rewind;
ho->minimize = ho_minimize;
ho->res_get = ho_res_get;
ho->res_set = ho_res_set;
ho->addrinfo = ho_addrinfo;
return (ho);
}
/* Methods. */
static void
ho_close(struct irs_ho *this) {
struct pvt *pvt = (struct pvt *)this->private;
ho_minimize(this);
if (pvt->res && pvt->free_res)
(*pvt->free_res)(pvt->res);
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static struct hostent *
ho_byname(struct irs_ho *this, const char *name) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct hostent *rval;
struct irs_ho *ho;
int therrno = NETDB_INTERNAL;
int softerror = 0;
if (init(this) == -1)
return (NULL);
for (rule = pvt->rules; rule; rule = rule->next) {
ho = rule->inst->ho;
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
errno = 0;
rval = (*ho->byname)(ho, name);
if (rval != NULL)
return (rval);
if (softerror == 0 &&
pvt->res->res_h_errno != HOST_NOT_FOUND &&
pvt->res->res_h_errno != NETDB_INTERNAL) {
softerror = 1;
therrno = pvt->res->res_h_errno;
}
if (rule->flags & IRS_CONTINUE)
continue;
/*
* The value TRY_AGAIN can mean that the service
* is not available, or just that this particular name
* cannot be resolved now. We use the errno ECONNREFUSED
* to distinguish. If a lookup sets that errno when
* H_ERRNO is TRY_AGAIN, we continue to try other lookup
* functions, otherwise we return the TRY_AGAIN error.
*/
if (pvt->res->res_h_errno != TRY_AGAIN || errno != ECONNREFUSED)
break;
}
if (softerror != 0 && pvt->res->res_h_errno == HOST_NOT_FOUND)
RES_SET_H_ERRNO(pvt->res, therrno);
return (NULL);
}
static struct hostent *
ho_byname2(struct irs_ho *this, const char *name, int af) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct hostent *rval;
struct irs_ho *ho;
int therrno = NETDB_INTERNAL;
int softerror = 0;
if (init(this) == -1)
return (NULL);
for (rule = pvt->rules; rule; rule = rule->next) {
ho = rule->inst->ho;
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
errno = 0;
rval = (*ho->byname2)(ho, name, af);
if (rval != NULL)
return (rval);
if (softerror == 0 &&
pvt->res->res_h_errno != HOST_NOT_FOUND &&
pvt->res->res_h_errno != NETDB_INTERNAL) {
softerror = 1;
therrno = pvt->res->res_h_errno;
}
if (rule->flags & IRS_CONTINUE)
continue;
/*
* See the comments in ho_byname() explaining
* the interpretation of TRY_AGAIN and ECONNREFUSED.
*/
if (pvt->res->res_h_errno != TRY_AGAIN || errno != ECONNREFUSED)
break;
}
if (softerror != 0 && pvt->res->res_h_errno == HOST_NOT_FOUND)
RES_SET_H_ERRNO(pvt->res, therrno);
return (NULL);
}
static struct hostent *
ho_byaddr(struct irs_ho *this, const void *addr, int len, int af) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct hostent *rval;
struct irs_ho *ho;
int therrno = NETDB_INTERNAL;
int softerror = 0;
if (init(this) == -1)
return (NULL);
for (rule = pvt->rules; rule; rule = rule->next) {
ho = rule->inst->ho;
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
errno = 0;
rval = (*ho->byaddr)(ho, addr, len, af);
if (rval != NULL)
return (rval);
if (softerror == 0 &&
pvt->res->res_h_errno != HOST_NOT_FOUND &&
pvt->res->res_h_errno != NETDB_INTERNAL) {
softerror = 1;
therrno = pvt->res->res_h_errno;
}
if (rule->flags & IRS_CONTINUE)
continue;
/*
* See the comments in ho_byname() explaining
* the interpretation of TRY_AGAIN and ECONNREFUSED.
*/
if (pvt->res->res_h_errno != TRY_AGAIN || errno != ECONNREFUSED)
break;
}
if (softerror != 0 && pvt->res->res_h_errno == HOST_NOT_FOUND)
RES_SET_H_ERRNO(pvt->res, therrno);
return (NULL);
}
static struct hostent *
ho_next(struct irs_ho *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct hostent *rval;
struct irs_ho *ho;
while (pvt->rule) {
ho = pvt->rule->inst->ho;
rval = (*ho->next)(ho);
if (rval)
return (rval);
if (!(pvt->rule->flags & IRS_CONTINUE))
break;
pvt->rule = pvt->rule->next;
if (pvt->rule) {
ho = pvt->rule->inst->ho;
(*ho->rewind)(ho);
}
}
return (NULL);
}
static void
ho_rewind(struct irs_ho *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_ho *ho;
pvt->rule = pvt->rules;
if (pvt->rule) {
ho = pvt->rule->inst->ho;
(*ho->rewind)(ho);
}
}
static void
ho_minimize(struct irs_ho *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
if (pvt->res)
res_nclose(pvt->res);
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_ho *ho = rule->inst->ho;
(*ho->minimize)(ho);
}
}
static struct __res_state *
ho_res_get(struct irs_ho *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (!pvt->res) {
struct __res_state *res;
res = (struct __res_state *)malloc(sizeof *res);
if (!res) {
errno = ENOMEM;
return (NULL);
}
memset(res, 0, sizeof *res);
ho_res_set(this, res, free);
}
return (pvt->res);
}
static void
ho_res_set(struct irs_ho *this, struct __res_state *res,
void (*free_res)(void *)) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
if (pvt->res && pvt->free_res) {
res_nclose(pvt->res);
(*pvt->free_res)(pvt->res);
}
pvt->res = res;
pvt->free_res = free_res;
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_ho *ho = rule->inst->ho;
(*ho->res_set)(ho, pvt->res, NULL);
}
}
static struct addrinfo *
ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
{
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct addrinfo *rval = NULL;
struct irs_ho *ho;
int therrno = NETDB_INTERNAL;
int softerror = 0;
if (init(this) == -1)
return (NULL);
for (rule = pvt->rules; rule; rule = rule->next) {
ho = rule->inst->ho;
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
errno = 0;
if (ho->addrinfo == NULL) /*%< for safety */
continue;
rval = (*ho->addrinfo)(ho, name, pai);
if (rval != NULL)
return (rval);
if (softerror == 0 &&
pvt->res->res_h_errno != HOST_NOT_FOUND &&
pvt->res->res_h_errno != NETDB_INTERNAL) {
softerror = 1;
therrno = pvt->res->res_h_errno;
}
if (rule->flags & IRS_CONTINUE)
continue;
/*
* See the comments in ho_byname() explaining
* the interpretation of TRY_AGAIN and ECONNREFUSED.
*/
if (pvt->res->res_h_errno != TRY_AGAIN ||
errno != ECONNREFUSED)
break;
}
if (softerror != 0 && pvt->res->res_h_errno == HOST_NOT_FOUND)
RES_SET_H_ERRNO(pvt->res, therrno);
return (NULL);
}
static int
init(struct irs_ho *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (!pvt->res && !ho_res_get(this))
return (-1);
if (((pvt->res->options & RES_INIT) == 0U) &&
(res_ninit(pvt->res) == -1))
return (-1);
return (0);
}
/*! \file */

View File

@ -1,174 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: gen_ng.c,v 1.2.18.1 2005/04/27 05:00:56 sra Exp $";
#endif
/* Imports */
#include "port_before.h"
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "gen_p.h"
/* Types */
struct pvt {
struct irs_rule * rules;
struct irs_rule * rule;
char * curgroup;
};
/* Forward */
static void ng_close(struct irs_ng *);
static int ng_next(struct irs_ng *, const char **,
const char **, const char **);
static int ng_test(struct irs_ng *, const char *,
const char *, const char *,
const char *);
static void ng_rewind(struct irs_ng *, const char *);
static void ng_minimize(struct irs_ng *);
/* Public */
struct irs_ng *
irs_gen_ng(struct irs_acc *this) {
struct gen_p *accpvt = (struct gen_p *)this->private;
struct irs_ng *ng;
struct pvt *pvt;
if (!(ng = memget(sizeof *ng))) {
errno = ENOMEM;
return (NULL);
}
memset(ng, 0x5e, sizeof *ng);
if (!(pvt = memget(sizeof *pvt))) {
memput(ng, sizeof *ng);
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
pvt->rules = accpvt->map_rules[irs_ng];
pvt->rule = pvt->rules;
ng->private = pvt;
ng->close = ng_close;
ng->next = ng_next;
ng->test = ng_test;
ng->rewind = ng_rewind;
ng->minimize = ng_minimize;
return (ng);
}
/* Methods */
static void
ng_close(struct irs_ng *this) {
struct pvt *pvt = (struct pvt *)this->private;
ng_minimize(this);
if (pvt->curgroup)
free(pvt->curgroup);
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static int
ng_next(struct irs_ng *this, const char **host, const char **user,
const char **domain)
{
struct pvt *pvt = (struct pvt *)this->private;
struct irs_ng *ng;
while (pvt->rule) {
ng = pvt->rule->inst->ng;
if ((*ng->next)(ng, host, user, domain) == 1)
return (1);
if (!(pvt->rule->flags & IRS_CONTINUE))
break;
pvt->rule = pvt->rule->next;
if (pvt->rule) {
ng = pvt->rule->inst->ng;
(*ng->rewind)(ng, pvt->curgroup);
}
}
return (0);
}
static int
ng_test(struct irs_ng *this, const char *name,
const char *user, const char *host, const char *domain)
{
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct irs_ng *ng;
int rval;
rval = 0;
for (rule = pvt->rules; rule; rule = rule->next) {
ng = rule->inst->ng;
rval = (*ng->test)(ng, name, user, host, domain);
if (rval || !(rule->flags & IRS_CONTINUE))
break;
}
return (rval);
}
static void
ng_rewind(struct irs_ng *this, const char *group) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_ng *ng;
pvt->rule = pvt->rules;
if (pvt->rule) {
if (pvt->curgroup)
free(pvt->curgroup);
pvt->curgroup = strdup(group);
ng = pvt->rule->inst->ng;
(*ng->rewind)(ng, pvt->curgroup);
}
}
static void
ng_minimize(struct irs_ng *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_ng *ng = rule->inst->ng;
(*ng->minimize)(ng);
}
}
/*! \file */

View File

@ -1,264 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: gen_nw.c,v 1.3.18.1 2005/04/27 05:00:56 sra Exp $";
#endif
/* Imports */
#include "port_before.h"
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <errno.h>
#include <resolv.h>
#include <stdlib.h>
#include <string.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "gen_p.h"
/* Types */
struct pvt {
struct irs_rule * rules;
struct irs_rule * rule;
struct __res_state * res;
void (*free_res)(void *);
};
/* Forward */
static void nw_close(struct irs_nw*);
static struct nwent * nw_next(struct irs_nw *);
static struct nwent * nw_byname(struct irs_nw *, const char *, int);
static struct nwent * nw_byaddr(struct irs_nw *, void *, int, int);
static void nw_rewind(struct irs_nw *);
static void nw_minimize(struct irs_nw *);
static struct __res_state * nw_res_get(struct irs_nw *this);
static void nw_res_set(struct irs_nw *this,
struct __res_state *res,
void (*free_res)(void *));
static int init(struct irs_nw *this);
/* Public */
struct irs_nw *
irs_gen_nw(struct irs_acc *this) {
struct gen_p *accpvt = (struct gen_p *)this->private;
struct irs_nw *nw;
struct pvt *pvt;
if (!(pvt = memget(sizeof *pvt))) {
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
if (!(nw = memget(sizeof *nw))) {
memput(pvt, sizeof *pvt);
errno = ENOMEM;
return (NULL);
}
memset(nw, 0x5e, sizeof *nw);
pvt->rules = accpvt->map_rules[irs_nw];
pvt->rule = pvt->rules;
nw->private = pvt;
nw->close = nw_close;
nw->next = nw_next;
nw->byname = nw_byname;
nw->byaddr = nw_byaddr;
nw->rewind = nw_rewind;
nw->minimize = nw_minimize;
nw->res_get = nw_res_get;
nw->res_set = nw_res_set;
return (nw);
}
/* Methods */
static void
nw_close(struct irs_nw *this) {
struct pvt *pvt = (struct pvt *)this->private;
nw_minimize(this);
if (pvt->res && pvt->free_res)
(*pvt->free_res)(pvt->res);
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static struct nwent *
nw_next(struct irs_nw *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct nwent *rval;
struct irs_nw *nw;
if (init(this) == -1)
return(NULL);
while (pvt->rule) {
nw = pvt->rule->inst->nw;
rval = (*nw->next)(nw);
if (rval)
return (rval);
if (!(pvt->rules->flags & IRS_CONTINUE))
break;
pvt->rule = pvt->rule->next;
if (pvt->rule) {
nw = pvt->rule->inst->nw;
(*nw->rewind)(nw);
}
}
return (NULL);
}
static struct nwent *
nw_byname(struct irs_nw *this, const char *name, int type) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct nwent *rval;
struct irs_nw *nw;
if (init(this) == -1)
return(NULL);
for (rule = pvt->rules; rule; rule = rule->next) {
nw = rule->inst->nw;
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
rval = (*nw->byname)(nw, name, type);
if (rval != NULL)
return (rval);
if (pvt->res->res_h_errno != TRY_AGAIN &&
!(rule->flags & IRS_CONTINUE))
break;
}
return (NULL);
}
static struct nwent *
nw_byaddr(struct irs_nw *this, void *net, int length, int type) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct nwent *rval;
struct irs_nw *nw;
if (init(this) == -1)
return(NULL);
for (rule = pvt->rules; rule; rule = rule->next) {
nw = rule->inst->nw;
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
rval = (*nw->byaddr)(nw, net, length, type);
if (rval != NULL)
return (rval);
if (pvt->res->res_h_errno != TRY_AGAIN &&
!(rule->flags & IRS_CONTINUE))
break;
}
return (NULL);
}
static void
nw_rewind(struct irs_nw *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_nw *nw;
pvt->rule = pvt->rules;
if (pvt->rule) {
nw = pvt->rule->inst->nw;
(*nw->rewind)(nw);
}
}
static void
nw_minimize(struct irs_nw *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
if (pvt->res)
res_nclose(pvt->res);
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_nw *nw = rule->inst->nw;
(*nw->minimize)(nw);
}
}
static struct __res_state *
nw_res_get(struct irs_nw *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (!pvt->res) {
struct __res_state *res;
res = (struct __res_state *)malloc(sizeof *res);
if (!res) {
errno = ENOMEM;
return (NULL);
}
memset(res, 0, sizeof *res);
nw_res_set(this, res, free);
}
return (pvt->res);
}
static void
nw_res_set(struct irs_nw *this, struct __res_state *res,
void (*free_res)(void *)) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
if (pvt->res && pvt->free_res) {
res_nclose(pvt->res);
(*pvt->free_res)(pvt->res);
}
pvt->res = res;
pvt->free_res = free_res;
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_nw *nw = rule->inst->nw;
(*nw->res_set)(nw, pvt->res, NULL);
}
}
static int
init(struct irs_nw *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (!pvt->res && !nw_res_get(this))
return (-1);
if (((pvt->res->options & RES_INIT) == 0U) &&
res_ninit(pvt->res) == -1)
return (-1);
return (0);
}
/*! \file */

View File

@ -1,113 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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: gen_p.h,v 1.2.18.1 2005/04/27 05:00:56 sra Exp $
*/
/*! \file
* Notes:
* We hope to create a complete set of thread-safe entry points someday,
* which will mean a set of getXbyY() functions that take as an argument
* a pointer to the map class, which will have a pointer to the private
* data, which will be used preferentially to the static variables that
* are necessary to support the "classic" interface. This "classic"
* interface will then be reimplemented as stubs on top of the thread
* safe modules, and will keep the map class pointers as their only
* static data. HOWEVER, we are not there yet. So while we will call
* the just-barely-converted map class methods with map class pointers,
* right now they probably all still use statics. We're not fooling
* anybody, and we're not trying to (yet).
*/
#ifndef _GEN_P_H_INCLUDED
#define _GEN_P_H_INCLUDED
/*%
* These are the access methods.
*/
enum irs_acc_id {
irs_lcl, /*%< Local. */
irs_dns, /*%< DNS or Hesiod. */
irs_nis, /*%< Sun NIS ("YP"). */
irs_irp, /*%< IR protocol. */
irs_nacc
};
/*%
* These are the map types.
*/
enum irs_map_id {
irs_gr, /*%< "group" */
irs_pw, /*%< "passwd" */
irs_sv, /*%< "services" */
irs_pr, /*%< "protocols" */
irs_ho, /*%< "hosts" */
irs_nw, /*%< "networks" */
irs_ng, /*%< "netgroup" */
irs_nmap
};
/*%
* This is an accessor instance.
*/
struct irs_inst {
struct irs_acc *acc;
struct irs_gr * gr;
struct irs_pw * pw;
struct irs_sv * sv;
struct irs_pr * pr;
struct irs_ho * ho;
struct irs_nw * nw;
struct irs_ng * ng;
};
/*%
* This is a search rule for some map type.
*/
struct irs_rule {
struct irs_rule * next;
struct irs_inst * inst;
int flags;
};
#define IRS_MERGE 0x0001 /*%< Don't stop if acc. has data? */
#define IRS_CONTINUE 0x0002 /*%< Don't stop if acc. has no data? */
/*
* This is the private data for a search access class.
*/
struct gen_p {
char * options;
struct irs_rule * map_rules[(int)irs_nmap];
struct irs_inst accessors[(int)irs_nacc];
struct __res_state * res;
void (*free_res) __P((void *));
};
/*
* Externs.
*/
extern struct irs_acc * irs_gen_acc __P((const char *, const char *conf_file));
extern struct irs_gr * irs_gen_gr __P((struct irs_acc *));
extern struct irs_pw * irs_gen_pw __P((struct irs_acc *));
extern struct irs_sv * irs_gen_sv __P((struct irs_acc *));
extern struct irs_pr * irs_gen_pr __P((struct irs_acc *));
extern struct irs_ho * irs_gen_ho __P((struct irs_acc *));
extern struct irs_nw * irs_gen_nw __P((struct irs_acc *));
extern struct irs_ng * irs_gen_ng __P((struct irs_acc *));
#endif /*_IRS_P_H_INCLUDED*/

View File

@ -1,228 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: gen_pr.c,v 1.2.18.1 2005/04/27 05:00:56 sra Exp $";
#endif
/* Imports */
#include "port_before.h"
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <errno.h>
#include <resolv.h>
#include <stdlib.h>
#include <string.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "gen_p.h"
/* Types */
struct pvt {
struct irs_rule * rules;
struct irs_rule * rule;
struct __res_state * res;
void (*free_res)(void *);
};
/* Forward */
static void pr_close(struct irs_pr*);
static struct protoent * pr_next(struct irs_pr *);
static struct protoent * pr_byname(struct irs_pr *, const char *);
static struct protoent * pr_bynumber(struct irs_pr *, int);
static void pr_rewind(struct irs_pr *);
static void pr_minimize(struct irs_pr *);
static struct __res_state * pr_res_get(struct irs_pr *);
static void pr_res_set(struct irs_pr *,
struct __res_state *,
void (*)(void *));
/* Public */
struct irs_pr *
irs_gen_pr(struct irs_acc *this) {
struct gen_p *accpvt = (struct gen_p *)this->private;
struct irs_pr *pr;
struct pvt *pvt;
if (!(pr = memget(sizeof *pr))) {
errno = ENOMEM;
return (NULL);
}
memset(pr, 0x5e, sizeof *pr);
if (!(pvt = memget(sizeof *pvt))) {
memput(pr, sizeof *pr);
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
pvt->rules = accpvt->map_rules[irs_pr];
pvt->rule = pvt->rules;
pr->private = pvt;
pr->close = pr_close;
pr->next = pr_next;
pr->byname = pr_byname;
pr->bynumber = pr_bynumber;
pr->rewind = pr_rewind;
pr->minimize = pr_minimize;
pr->res_get = pr_res_get;
pr->res_set = pr_res_set;
return (pr);
}
/* Methods */
static void
pr_close(struct irs_pr *this) {
struct pvt *pvt = (struct pvt *)this->private;
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static struct protoent *
pr_next(struct irs_pr *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct protoent *rval;
struct irs_pr *pr;
while (pvt->rule) {
pr = pvt->rule->inst->pr;
rval = (*pr->next)(pr);
if (rval)
return (rval);
if (!(pvt->rules->flags & IRS_CONTINUE))
break;
pvt->rule = pvt->rule->next;
if (pvt->rule) {
pr = pvt->rule->inst->pr;
(*pr->rewind)(pr);
}
}
return (NULL);
}
static struct protoent *
pr_byname(struct irs_pr *this, const char *name) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct protoent *rval;
struct irs_pr *pr;
rval = NULL;
for (rule = pvt->rules; rule; rule = rule->next) {
pr = rule->inst->pr;
rval = (*pr->byname)(pr, name);
if (rval || !(rule->flags & IRS_CONTINUE))
break;
}
return (rval);
}
static struct protoent *
pr_bynumber(struct irs_pr *this, int proto) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct protoent *rval;
struct irs_pr *pr;
rval = NULL;
for (rule = pvt->rules; rule; rule = rule->next) {
pr = rule->inst->pr;
rval = (*pr->bynumber)(pr, proto);
if (rval || !(rule->flags & IRS_CONTINUE))
break;
}
return (rval);
}
static void
pr_rewind(struct irs_pr *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_pr *pr;
pvt->rule = pvt->rules;
if (pvt->rule) {
pr = pvt->rule->inst->pr;
(*pr->rewind)(pr);
}
}
static void
pr_minimize(struct irs_pr *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_pr *pr = rule->inst->pr;
(*pr->minimize)(pr);
}
}
static struct __res_state *
pr_res_get(struct irs_pr *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (!pvt->res) {
struct __res_state *res;
res = (struct __res_state *)malloc(sizeof *res);
if (!res) {
errno = ENOMEM;
return (NULL);
}
memset(res, 0, sizeof *res);
pr_res_set(this, res, free);
}
return (pvt->res);
}
static void
pr_res_set(struct irs_pr *this, struct __res_state *res,
void (*free_res)(void *)) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
if (pvt->res && pvt->free_res) {
res_nclose(pvt->res);
(*pvt->free_res)(pvt->res);
}
pvt->res = res;
pvt->free_res = free_res;
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_pr *pr = rule->inst->pr;
if (pr->res_set)
(*pr->res_set)(pr, pvt->res, NULL);
}
}
/*! \file */

View File

@ -1,234 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: gen_pw.c,v 1.2.18.1 2005/04/27 05:00:57 sra Exp $";
#endif
/* Imports */
#include "port_before.h"
#ifndef WANT_IRS_PW
static int __bind_irs_pw_unneeded;
#else
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <errno.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "gen_p.h"
/* Types */
struct pvt {
struct irs_rule * rules;
struct irs_rule * rule;
struct __res_state * res;
void (*free_res)(void *);
};
/* Forward */
static void pw_close(struct irs_pw *);
static struct passwd * pw_next(struct irs_pw *);
static struct passwd * pw_byname(struct irs_pw *, const char *);
static struct passwd * pw_byuid(struct irs_pw *, uid_t);
static void pw_rewind(struct irs_pw *);
static void pw_minimize(struct irs_pw *);
static struct __res_state * pw_res_get(struct irs_pw *);
static void pw_res_set(struct irs_pw *,
struct __res_state *,
void (*)(void *));
/* Public */
struct irs_pw *
irs_gen_pw(struct irs_acc *this) {
struct gen_p *accpvt = (struct gen_p *)this->private;
struct irs_pw *pw;
struct pvt *pvt;
if (!(pw = memget(sizeof *pw))) {
errno = ENOMEM;
return (NULL);
}
memset(pw, 0x5e, sizeof *pw);
if (!(pvt = memget(sizeof *pvt))) {
memput(pw, sizeof *pvt);
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
pvt->rules = accpvt->map_rules[irs_pw];
pvt->rule = pvt->rules;
pw->private = pvt;
pw->close = pw_close;
pw->next = pw_next;
pw->byname = pw_byname;
pw->byuid = pw_byuid;
pw->rewind = pw_rewind;
pw->minimize = pw_minimize;
pw->res_get = pw_res_get;
pw->res_set = pw_res_set;
return (pw);
}
/* Methods */
static void
pw_close(struct irs_pw *this) {
struct pvt *pvt = (struct pvt *)this->private;
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static struct passwd *
pw_next(struct irs_pw *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct passwd *rval;
struct irs_pw *pw;
while (pvt->rule) {
pw = pvt->rule->inst->pw;
rval = (*pw->next)(pw);
if (rval)
return (rval);
if (!(pvt->rule->flags & IRS_CONTINUE))
break;
pvt->rule = pvt->rule->next;
if (pvt->rule) {
pw = pvt->rule->inst->pw;
(*pw->rewind)(pw);
}
}
return (NULL);
}
static void
pw_rewind(struct irs_pw *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_pw *pw;
pvt->rule = pvt->rules;
if (pvt->rule) {
pw = pvt->rule->inst->pw;
(*pw->rewind)(pw);
}
}
static struct passwd *
pw_byname(struct irs_pw *this, const char *name) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct passwd *rval;
struct irs_pw *pw;
rval = NULL;
for (rule = pvt->rules; rule; rule = rule->next) {
pw = rule->inst->pw;
rval = (*pw->byname)(pw, name);
if (rval || !(rule->flags & IRS_CONTINUE))
break;
}
return (rval);
}
static struct passwd *
pw_byuid(struct irs_pw *this, uid_t uid) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct passwd *rval;
struct irs_pw *pw;
rval = NULL;
for (rule = pvt->rules; rule; rule = rule->next) {
pw = rule->inst->pw;
rval = (*pw->byuid)(pw, uid);
if (rval || !(rule->flags & IRS_CONTINUE))
break;
}
return (rval);
}
static void
pw_minimize(struct irs_pw *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_pw *pw = rule->inst->pw;
(*pw->minimize)(pw);
}
}
static struct __res_state *
pw_res_get(struct irs_pw *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (!pvt->res) {
struct __res_state *res;
res = (struct __res_state *)malloc(sizeof *res);
if (!res) {
errno = ENOMEM;
return (NULL);
}
memset(res, 0, sizeof *res);
pw_res_set(this, res, free);
}
return (pvt->res);
}
static void
pw_res_set(struct irs_pw *this, struct __res_state *res,
void (*free_res)(void *)) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
if (pvt->res && pvt->free_res) {
res_nclose(pvt->res);
(*pvt->free_res)(pvt->res);
}
pvt->res = res;
pvt->free_res = free_res;
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_pw *pw = rule->inst->pw;
if (pw->res_set)
(*pw->res_set)(pw, pvt->res, NULL);
}
}
#endif /* WANT_IRS_PW */
/*! \file */

View File

@ -1,229 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: gen_sv.c,v 1.2.18.1 2005/04/27 05:00:57 sra Exp $";
#endif
/* Imports */
#include "port_before.h"
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "gen_p.h"
/* Types */
struct pvt {
struct irs_rule * rules;
struct irs_rule * rule;
struct __res_state * res;
void (*free_res)(void *);
};
/* Forward */
static void sv_close(struct irs_sv*);
static struct servent * sv_next(struct irs_sv *);
static struct servent * sv_byname(struct irs_sv *, const char *,
const char *);
static struct servent * sv_byport(struct irs_sv *, int, const char *);
static void sv_rewind(struct irs_sv *);
static void sv_minimize(struct irs_sv *);
static struct __res_state * sv_res_get(struct irs_sv *);
static void sv_res_set(struct irs_sv *,
struct __res_state *,
void (*)(void *));
/* Public */
struct irs_sv *
irs_gen_sv(struct irs_acc *this) {
struct gen_p *accpvt = (struct gen_p *)this->private;
struct irs_sv *sv;
struct pvt *pvt;
if (!(sv = memget(sizeof *sv))) {
errno = ENOMEM;
return (NULL);
}
memset(sv, 0x5e, sizeof *sv);
if (!(pvt = memget(sizeof *pvt))) {
memput(sv, sizeof *sv);
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
pvt->rules = accpvt->map_rules[irs_sv];
pvt->rule = pvt->rules;
sv->private = pvt;
sv->close = sv_close;
sv->next = sv_next;
sv->byname = sv_byname;
sv->byport = sv_byport;
sv->rewind = sv_rewind;
sv->minimize = sv_minimize;
sv->res_get = sv_res_get;
sv->res_set = sv_res_set;
return (sv);
}
/* Methods */
static void
sv_close(struct irs_sv *this) {
struct pvt *pvt = (struct pvt *)this->private;
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static struct servent *
sv_next(struct irs_sv *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct servent *rval;
struct irs_sv *sv;
while (pvt->rule) {
sv = pvt->rule->inst->sv;
rval = (*sv->next)(sv);
if (rval)
return (rval);
if (!(pvt->rule->flags & IRS_CONTINUE))
break;
pvt->rule = pvt->rule->next;
if (pvt->rule) {
sv = pvt->rule->inst->sv;
(*sv->rewind)(sv);
}
}
return (NULL);
}
static struct servent *
sv_byname(struct irs_sv *this, const char *name, const char *proto) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct servent *rval;
struct irs_sv *sv;
rval = NULL;
for (rule = pvt->rules; rule; rule = rule->next) {
sv = rule->inst->sv;
rval = (*sv->byname)(sv, name, proto);
if (rval || !(rule->flags & IRS_CONTINUE))
break;
}
return (rval);
}
static struct servent *
sv_byport(struct irs_sv *this, int port, const char *proto) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct servent *rval;
struct irs_sv *sv;
rval = NULL;
for (rule = pvt->rules; rule; rule = rule->next) {
sv = rule->inst->sv;
rval = (*sv->byport)(sv, port, proto);
if (rval || !(rule->flags & IRS_CONTINUE))
break;
}
return (rval);
}
static void
sv_rewind(struct irs_sv *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_sv *sv;
pvt->rule = pvt->rules;
if (pvt->rule) {
sv = pvt->rule->inst->sv;
(*sv->rewind)(sv);
}
}
static void
sv_minimize(struct irs_sv *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_sv *sv = rule->inst->sv;
(*sv->minimize)(sv);
}
}
static struct __res_state *
sv_res_get(struct irs_sv *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (!pvt->res) {
struct __res_state *res;
res = (struct __res_state *)malloc(sizeof *res);
if (!res) {
errno = ENOMEM;
return (NULL);
}
memset(res, 0, sizeof *res);
sv_res_set(this, res, free);
}
return (pvt->res);
}
static void
sv_res_set(struct irs_sv *this, struct __res_state *res,
void (*free_res)(void *)) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
if (pvt->res && pvt->free_res) {
res_nclose(pvt->res);
(*pvt->free_res)(pvt->res);
}
pvt->res = res;
pvt->free_res = free_res;
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_sv *sv = rule->inst->sv;
if (sv->res_set)
(*sv->res_set)(sv, pvt->res, NULL);
}
}
/*! \file */

File diff suppressed because it is too large Load Diff

View File

@ -1,224 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: getgrent.c,v 1.4.18.1 2005/04/27 05:00:57 sra Exp $";
#endif
/* Imports */
#include "port_before.h"
#if !defined(WANT_IRS_GR) || defined(__BIND_NOSTATIC)
static int __bind_irs_gr_unneeded;
#else
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <errno.h>
#include <grp.h>
#include <resolv.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <irs.h>
#include "port_after.h"
#include "irs_data.h"
/* Forward */
static struct net_data *init(void);
void endgrent(void);
/* Public */
struct group *
getgrent() {
struct net_data *net_data = init();
return (getgrent_p(net_data));
}
struct group *
getgrnam(const char *name) {
struct net_data *net_data = init();
return (getgrnam_p(name, net_data));
}
struct group *
getgrgid(gid_t gid) {
struct net_data *net_data = init();
return (getgrgid_p(gid, net_data));
}
int
setgroupent(int stayopen) {
struct net_data *net_data = init();
return (setgroupent_p(stayopen, net_data));
}
#ifdef SETGRENT_VOID
void
setgrent(void) {
struct net_data *net_data = init();
setgrent_p(net_data);
}
#else
int
setgrent(void) {
struct net_data *net_data = init();
return (setgrent_p(net_data));
}
#endif /* SETGRENT_VOID */
void
endgrent() {
struct net_data *net_data = init();
endgrent_p(net_data);
}
int
getgrouplist(GETGROUPLIST_ARGS) {
struct net_data *net_data = init();
return (getgrouplist_p(name, basegid, groups, ngroups, net_data));
}
/* Shared private. */
struct group *
getgrent_p(struct net_data *net_data) {
struct irs_gr *gr;
if (!net_data || !(gr = net_data->gr))
return (NULL);
net_data->gr_last = (*gr->next)(gr);
return (net_data->gr_last);
}
struct group *
getgrnam_p(const char *name, struct net_data *net_data) {
struct irs_gr *gr;
if (!net_data || !(gr = net_data->gr))
return (NULL);
if (net_data->gr_stayopen && net_data->gr_last &&
!strcmp(net_data->gr_last->gr_name, name))
return (net_data->gr_last);
net_data->gr_last = (*gr->byname)(gr, name);
if (!net_data->gr_stayopen)
endgrent();
return (net_data->gr_last);
}
struct group *
getgrgid_p(gid_t gid, struct net_data *net_data) {
struct irs_gr *gr;
if (!net_data || !(gr = net_data->gr))
return (NULL);
if (net_data->gr_stayopen && net_data->gr_last &&
(gid_t)net_data->gr_last->gr_gid == gid)
return (net_data->gr_last);
net_data->gr_last = (*gr->bygid)(gr, gid);
if (!net_data->gr_stayopen)
endgrent();
return (net_data->gr_last);
}
int
setgroupent_p(int stayopen, struct net_data *net_data) {
struct irs_gr *gr;
if (!net_data || !(gr = net_data->gr))
return (0);
(*gr->rewind)(gr);
net_data->gr_stayopen = (stayopen != 0);
if (stayopen == 0)
net_data_minimize(net_data);
return (1);
}
#ifdef SETGRENT_VOID
void
setgrent_p(struct net_data *net_data) {
(void)setgroupent_p(0, net_data);
}
#else
int
setgrent_p(struct net_data *net_data) {
return (setgroupent_p(0, net_data));
}
#endif /* SETGRENT_VOID */
void
endgrent_p(struct net_data *net_data) {
struct irs_gr *gr;
if ((net_data != NULL) && ((gr = net_data->gr) != NULL))
(*gr->minimize)(gr);
}
int
getgrouplist_p(const char *name, gid_t basegid, gid_t *groups, int *ngroups,
struct net_data *net_data) {
struct irs_gr *gr;
if (!net_data || !(gr = net_data->gr)) {
*ngroups = 0;
return (-1);
}
return ((*gr->list)(gr, name, basegid, groups, ngroups));
}
/* Private */
static struct net_data *
init() {
struct net_data *net_data;
if (!(net_data = net_data_init(NULL)))
goto error;
if (!net_data->gr) {
net_data->gr = (*net_data->irs->gr_map)(net_data->irs);
if (!net_data->gr || !net_data->res) {
error:
errno = EIO;
return (NULL);
}
(*net_data->gr->res_set)(net_data->gr, net_data->res,
NULL);
}
return (net_data);
}
#endif /* WANT_IRS_GR */
/*! \file */

View File

@ -1,230 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1998-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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: getgrent_r.c,v 1.6.18.1 2005/04/27 05:00:57 sra Exp $";
#endif /* LIBC_SCCS and not lint */
#include <port_before.h>
#if !defined(_REENTRANT) || !defined(DO_PTHREADS) || !defined(WANT_IRS_PW)
static int getgrent_r_not_required = 0;
#else
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#if (defined(POSIX_GETGRNAM_R) || defined(POSIX_GETGRGID_R)) && \
defined(_POSIX_PTHREAD_SEMANTICS)
/* turn off solaris remapping in <grp.h> */
#define _UNIX95
#undef _POSIX_PTHREAD_SEMANTICS
#include <grp.h>
#define _POSIX_PTHREAD_SEMANTICS 1
#else
#include <grp.h>
#endif
#include <sys/param.h>
#include <port_after.h>
#ifdef GROUP_R_RETURN
static int
copy_group(struct group *, struct group *, char *buf, int buflen);
/* POSIX 1003.1c */
#ifdef POSIX_GETGRNAM_R
int
__posix_getgrnam_r(const char *name, struct group *gptr,
char *buf, int buflen, struct group **result) {
#else
int
getgrnam_r(const char *name, struct group *gptr,
char *buf, size_t buflen, struct group **result) {
#endif
struct group *ge = getgrnam(name);
int res;
if (ge == NULL) {
*result = NULL;
return (0);
}
res = copy_group(ge, gptr, buf, buflen);
*result = res ? NULL : gptr;
return (res);
}
#ifdef POSIX_GETGRNAM_R
struct group *
getgrnam_r(const char *name, struct group *gptr,
char *buf, int buflen) {
struct group *ge = getgrnam(name);
int res;
if (ge == NULL)
return (NULL);
res = copy_group(ge, gptr, buf, buflen);
return (res ? NULL : gptr);
}
#endif /* POSIX_GETGRNAM_R */
/* POSIX 1003.1c */
#ifdef POSIX_GETGRGID_R
int
__posix_getgrgid_r(gid_t gid, struct group *gptr,
char *buf, int buflen, struct group **result) {
#else /* POSIX_GETGRGID_R */
int
getgrgid_r(gid_t gid, struct group *gptr,
char *buf, size_t buflen, struct group **result) {
#endif /* POSIX_GETGRGID_R */
struct group *ge = getgrgid(gid);
int res;
if (ge == NULL) {
*result = NULL;
return (0);
}
res = copy_group(ge, gptr, buf, buflen);
*result = res ? NULL : gptr;
return (res);
}
#ifdef POSIX_GETGRGID_R
struct group *
getgrgid_r(gid_t gid, struct group *gptr,
char *buf, int buflen) {
struct group *ge = getgrgid(gid);
int res;
if (ge == NULL)
return (NULL);
res = copy_group(ge, gptr, buf, buflen);
return (res ? NULL : gptr);
}
#endif
/*%
* These assume a single context is in operation per thread.
* If this is not the case we will need to call irs directly
* rather than through the base functions.
*/
GROUP_R_RETURN
getgrent_r(struct group *gptr, GROUP_R_ARGS) {
struct group *ge = getgrent();
int res;
if (ge == NULL) {
return (GROUP_R_BAD);
}
res = copy_group(ge, gptr, buf, buflen);
return (res ? GROUP_R_BAD : GROUP_R_OK);
}
GROUP_R_SET_RETURN
setgrent_r(GROUP_R_ENT_ARGS) {
setgrent();
#ifdef GROUP_R_SET_RESULT
return (GROUP_R_SET_RESULT);
#endif
}
GROUP_R_END_RETURN
endgrent_r(GROUP_R_ENT_ARGS) {
endgrent();
GROUP_R_END_RESULT(GROUP_R_OK);
}
#if 0
/* XXX irs does not have a fgetgrent() */
GROUP_R_RETURN
fgetgrent_r(FILE *f, struct group *gptr, GROUP_R_ARGS) {
struct group *ge = fgetgrent(f);
int res;
if (ge == NULL)
return (GROUP_R_BAD);
res = copy_group(ge, gptr, buf, buflen);
return (res ? GROUP_R_BAD : GROUP_R_OK);
}
#endif
/* Private */
static int
copy_group(struct group *ge, struct group *gptr, char *buf, int buflen) {
char *cp;
int i, n;
int numptr, len;
/* Find out the amount of space required to store the answer. */
numptr = 1; /*%< NULL ptr */
len = (char *)ALIGN(buf) - buf;
for (i = 0; ge->gr_mem[i]; i++, numptr++) {
len += strlen(ge->gr_mem[i]) + 1;
}
len += strlen(ge->gr_name) + 1;
len += strlen(ge->gr_passwd) + 1;
len += numptr * sizeof(char*);
if (len > buflen) {
errno = ERANGE;
return (ERANGE);
}
/* copy group id */
gptr->gr_gid = ge->gr_gid;
cp = (char *)ALIGN(buf) + numptr * sizeof(char *);
/* copy official name */
n = strlen(ge->gr_name) + 1;
strcpy(cp, ge->gr_name);
gptr->gr_name = cp;
cp += n;
/* copy member list */
gptr->gr_mem = (char **)ALIGN(buf);
for (i = 0 ; ge->gr_mem[i]; i++) {
n = strlen(ge->gr_mem[i]) + 1;
strcpy(cp, ge->gr_mem[i]);
gptr->gr_mem[i] = cp;
cp += n;
}
gptr->gr_mem[i] = NULL;
/* copy password */
n = strlen(ge->gr_passwd) + 1;
strcpy(cp, ge->gr_passwd);
gptr->gr_passwd = cp;
cp += n;
return (0);
}
#else /* GROUP_R_RETURN */
static int getgrent_r_unknown_system = 0;
#endif /* GROUP_R_RETURN */
#endif /* !def(_REENTRANT) || !def(DO_PTHREADS) || !def(WANT_IRS_PW) */
/*! \file */

File diff suppressed because it is too large Load Diff

View File

@ -1,275 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1998-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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: gethostent_r.c,v 1.5.18.4 2005/09/03 12:45:14 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <port_before.h>
#if !defined(_REENTRANT) || !defined(DO_PTHREADS)
static int gethostent_r_not_required = 0;
#else
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/param.h>
#include <port_after.h>
#ifdef HOST_R_RETURN
static HOST_R_RETURN
copy_hostent(struct hostent *, struct hostent *, HOST_R_COPY_ARGS);
HOST_R_RETURN
gethostbyname_r(const char *name, struct hostent *hptr, HOST_R_ARGS) {
struct hostent *he = gethostbyname(name);
#ifdef HOST_R_SETANSWER
int n = 0;
#endif
#ifdef HOST_R_ERRNO
HOST_R_ERRNO;
#endif
#ifdef HOST_R_SETANSWER
if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) != 0)
*answerp = NULL;
else
*answerp = hptr;
return (n);
#else
if (he == NULL)
return (HOST_R_BAD);
return (copy_hostent(he, hptr, HOST_R_COPY));
#endif
}
HOST_R_RETURN
gethostbyaddr_r(const char *addr, int len, int type,
struct hostent *hptr, HOST_R_ARGS) {
struct hostent *he = gethostbyaddr(addr, len, type);
#ifdef HOST_R_SETANSWER
int n = 0;
#endif
#ifdef HOST_R_ERRNO
HOST_R_ERRNO;
#endif
#ifdef HOST_R_SETANSWER
if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) != 0)
*answerp = NULL;
else
*answerp = hptr;
return (n);
#else
if (he == NULL)
return (HOST_R_BAD);
return (copy_hostent(he, hptr, HOST_R_COPY));
#endif
}
/*%
* These assume a single context is in operation per thread.
* If this is not the case we will need to call irs directly
* rather than through the base functions.
*/
HOST_R_RETURN
gethostent_r(struct hostent *hptr, HOST_R_ARGS) {
struct hostent *he = gethostent();
#ifdef HOST_R_SETANSWER
int n = 0;
#endif
#ifdef HOST_R_ERRNO
HOST_R_ERRNO;
#endif
#ifdef HOST_R_SETANSWER
if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) != 0)
*answerp = NULL;
else
*answerp = hptr;
return (n);
#else
if (he == NULL)
return (HOST_R_BAD);
return (copy_hostent(he, hptr, HOST_R_COPY));
#endif
}
HOST_R_SET_RETURN
#ifdef HOST_R_ENT_ARGS
sethostent_r(int stay_open, HOST_R_ENT_ARGS)
#else
sethostent_r(int stay_open)
#endif
{
#ifdef HOST_R_ENT_ARGS
UNUSED(hdptr);
#endif
sethostent(stay_open);
#ifdef HOST_R_SET_RESULT
return (HOST_R_SET_RESULT);
#endif
}
HOST_R_END_RETURN
#ifdef HOST_R_ENT_ARGS
endhostent_r(HOST_R_ENT_ARGS)
#else
endhostent_r(void)
#endif
{
#ifdef HOST_R_ENT_ARGS
UNUSED(hdptr);
#endif
endhostent();
HOST_R_END_RESULT(HOST_R_OK);
}
/* Private */
#ifndef HOSTENT_DATA
static HOST_R_RETURN
copy_hostent(struct hostent *he, struct hostent *hptr, HOST_R_COPY_ARGS) {
char *cp;
char **ptr;
int i, n;
int nptr, len;
/* Find out the amount of space required to store the answer. */
nptr = 2; /*%< NULL ptrs */
len = (char *)ALIGN(buf) - buf;
for (i = 0; he->h_addr_list[i]; i++, nptr++) {
len += he->h_length;
}
for (i = 0; he->h_aliases[i]; i++, nptr++) {
len += strlen(he->h_aliases[i]) + 1;
}
len += strlen(he->h_name) + 1;
len += nptr * sizeof(char*);
if (len > buflen) {
errno = ERANGE;
return (HOST_R_BAD);
}
/* copy address size and type */
hptr->h_addrtype = he->h_addrtype;
n = hptr->h_length = he->h_length;
ptr = (char **)ALIGN(buf);
cp = (char *)ALIGN(buf) + nptr * sizeof(char *);
/* copy address list */
hptr->h_addr_list = ptr;
for (i = 0; he->h_addr_list[i]; i++ , ptr++) {
memcpy(cp, he->h_addr_list[i], n);
hptr->h_addr_list[i] = cp;
cp += n;
}
hptr->h_addr_list[i] = NULL;
ptr++;
/* copy official name */
n = strlen(he->h_name) + 1;
strcpy(cp, he->h_name);
hptr->h_name = cp;
cp += n;
/* copy aliases */
hptr->h_aliases = ptr;
for (i = 0 ; he->h_aliases[i]; i++) {
n = strlen(he->h_aliases[i]) + 1;
strcpy(cp, he->h_aliases[i]);
hptr->h_aliases[i] = cp;
cp += n;
}
hptr->h_aliases[i] = NULL;
return (HOST_R_OK);
}
#else /* !HOSTENT_DATA */
static int
copy_hostent(struct hostent *he, struct hostent *hptr, HOST_R_COPY_ARGS) {
char *cp, *eob;
int i, n;
/* copy address size and type */
hptr->h_addrtype = he->h_addrtype;
n = hptr->h_length = he->h_length;
/* copy up to first 35 addresses */
i = 0;
cp = hdptr->hostbuf;
eob = hdptr->hostbuf + sizeof(hdptr->hostbuf);
hptr->h_addr_list = hdptr->h_addr_ptrs;
while (he->h_addr_list[i] && i < (_MAXADDRS)) {
if (n < (eob - cp)) {
memcpy(cp, he->h_addr_list[i], n);
hptr->h_addr_list[i] = cp;
cp += n;
} else {
break;
}
i++;
}
hptr->h_addr_list[i] = NULL;
/* copy official name */
if ((n = strlen(he->h_name) + 1) < (eob - cp)) {
strcpy(cp, he->h_name);
hptr->h_name = cp;
cp += n;
} else {
return (-1);
}
/* copy aliases */
i = 0;
hptr->h_aliases = hdptr->host_aliases;
while (he->h_aliases[i] && i < (_MAXALIASES-1)) {
if ((n = strlen(he->h_aliases[i]) + 1) < (eob - cp)) {
strcpy(cp, he->h_aliases[i]);
hptr->h_aliases[i] = cp;
cp += n;
} else {
break;
}
i++;
}
hptr->h_aliases[i] = NULL;
return (HOST_R_OK);
}
#endif /* !HOSTENT_DATA */
#else /* HOST_R_RETURN */
static int gethostent_r_unknown_system = 0;
#endif /* HOST_R_RETURN */
#endif /* !defined(_REENTRANT) || !defined(DO_PTHREADS) */
/*! \file */

View File

@ -1,334 +0,0 @@
/*
* Issues to be discussed:
* - Thread safe-ness must be checked
*/
#if ( defined(__linux__) || defined(__linux) || defined(LINUX) )
#ifndef IF_NAMESIZE
# ifdef IFNAMSIZ
# define IF_NAMESIZE IFNAMSIZ
# else
# define IF_NAMESIZE 16
# endif
#endif
#endif
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by WIDE Project and
* its contributors.
* 4. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <port_before.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <netdb.h>
#include <resolv.h>
#include <string.h>
#include <stddef.h>
#include <port_after.h>
/*%
* Note that a_off will be dynamically adjusted so that to be consistent
* with the definition of sockaddr_in{,6}.
* The value presented below is just a guess.
*/
static struct afd {
int a_af;
int a_addrlen;
size_t a_socklen;
int a_off;
} afdl [] = {
/* first entry is linked last... */
{PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
offsetof(struct sockaddr_in, sin_addr)},
{PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
offsetof(struct sockaddr_in6, sin6_addr)},
{0, 0, 0, 0},
};
struct sockinet {
#ifdef HAVE_SA_LEN
u_char si_len;
#endif
u_char si_family;
u_short si_port;
};
static int ip6_parsenumeric __P((const struct sockaddr *, const char *, char *,
size_t, int));
#ifdef HAVE_SIN6_SCOPE_ID
static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t, int));
#endif
int
getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
const struct sockaddr *sa;
size_t salen;
char *host;
size_t hostlen;
char *serv;
size_t servlen;
int flags;
{
struct afd *afd;
struct servent *sp;
struct hostent *hp;
u_short port;
#ifdef HAVE_SA_LEN
size_t len;
#endif
int family, i;
const char *addr;
char *p;
char numserv[512];
char numaddr[512];
const struct sockaddr_in6 *sin6;
if (sa == NULL)
return EAI_FAIL;
#ifdef HAVE_SA_LEN
len = sa->sa_len;
if (len != salen) return EAI_FAIL;
#endif
family = sa->sa_family;
for (i = 0; afdl[i].a_af; i++)
if (afdl[i].a_af == family) {
afd = &afdl[i];
goto found;
}
return EAI_FAMILY;
found:
if (salen != afd->a_socklen) return EAI_FAIL;
port = ((const struct sockinet *)sa)->si_port; /*%< network byte order */
addr = (const char *)sa + afd->a_off;
if (serv == NULL || servlen == 0U) {
/*
* rfc2553bis says that serv == NULL or servlen == 0 means that
* the caller does not want the result.
*/
} else if (flags & NI_NUMERICSERV) {
sprintf(numserv, "%d", ntohs(port));
if (strlen(numserv) > servlen)
return EAI_MEMORY;
strcpy(serv, numserv);
} else {
sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp");
if (sp) {
if (strlen(sp->s_name) + 1 > servlen)
return EAI_MEMORY;
strcpy(serv, sp->s_name);
} else
return EAI_NONAME;
}
switch (sa->sa_family) {
case AF_INET:
if (ntohl(*(const u_int32_t *)addr) >> IN_CLASSA_NSHIFT == 0)
flags |= NI_NUMERICHOST;
break;
case AF_INET6:
sin6 = (const struct sockaddr_in6 *)sa;
switch (sin6->sin6_addr.s6_addr[0]) {
case 0x00:
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
;
else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
;
else
flags |= NI_NUMERICHOST;
break;
default:
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))
flags |= NI_NUMERICHOST;
else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
flags |= NI_NUMERICHOST;
break;
}
break;
}
if (host == NULL || hostlen == 0U) {
/*
* rfc2553bis says that host == NULL or hostlen == 0 means that
* the caller does not want the result.
*/
} else if (flags & NI_NUMERICHOST) {
goto numeric;
} else {
hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
if (hp) {
if (flags & NI_NOFQDN) {
p = strchr(hp->h_name, '.');
if (p) *p = '\0';
}
if (strlen(hp->h_name) + 1 > hostlen)
return EAI_MEMORY;
strcpy(host, hp->h_name);
} else {
if (flags & NI_NAMEREQD)
return EAI_NONAME;
numeric:
switch(afd->a_af) {
case AF_INET6:
{
int error;
if ((error = ip6_parsenumeric(sa, addr, host,
hostlen,
flags)) != 0)
return(error);
break;
}
default:
if (inet_ntop(afd->a_af, addr, numaddr,
sizeof(numaddr)) == NULL)
return EAI_NONAME;
if (strlen(numaddr) + 1 > hostlen)
return EAI_MEMORY;
strcpy(host, numaddr);
}
}
}
return(0);
}
static int
ip6_parsenumeric(const struct sockaddr *sa, const char *addr, char *host,
size_t hostlen, int flags)
{
size_t numaddrlen;
char numaddr[512];
#ifndef HAVE_SIN6_SCOPE_ID
UNUSED(sa);
UNUSED(flags);
#endif
if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr))
== NULL)
return EAI_SYSTEM;
numaddrlen = strlen(numaddr);
if (numaddrlen + 1 > hostlen) /*%< don't forget terminator */
return EAI_MEMORY;
strcpy(host, numaddr);
#ifdef HAVE_SIN6_SCOPE_ID
if (((const struct sockaddr_in6 *)sa)->sin6_scope_id) {
char scopebuf[MAXHOSTNAMELEN]; /*%< XXX */
int scopelen;
/* ip6_sa2str never fails */
scopelen = ip6_sa2str((const struct sockaddr_in6 *)sa,
scopebuf, sizeof(scopebuf), flags);
if (scopelen + 1 + numaddrlen + 1 > hostlen)
return EAI_MEMORY;
/* construct <numeric-addr><delim><scopeid> */
memcpy(host + numaddrlen + 1, scopebuf,
scopelen);
host[numaddrlen] = SCOPE_DELIMITER;
host[numaddrlen + 1 + scopelen] = '\0';
}
#endif
return 0;
}
#ifdef HAVE_SIN6_SCOPE_ID
/* ARGSUSED */
static int
ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf,
size_t bufsiz, int flags)
{
#ifdef USE_IFNAMELINKID
unsigned int ifindex = (unsigned int)sa6->sin6_scope_id;
const struct in6_addr *a6 = &sa6->sin6_addr;
#endif
char tmp[64];
#ifdef NI_NUMERICSCOPE
if (flags & NI_NUMERICSCOPE) {
sprintf(tmp, "%u", sa6->sin6_scope_id);
if (bufsiz != 0U) {
strncpy(buf, tmp, bufsiz - 1);
buf[bufsiz - 1] = '\0';
}
return(strlen(tmp));
}
#endif
#ifdef USE_IFNAMELINKID
/*
* For a link-local address, convert the index to an interface
* name, assuming a one-to-one mapping between links and interfaces.
* Note, however, that this assumption is stronger than the
* specification of the scoped address architecture; the
* specficication says that more than one interfaces can belong to
* a single link.
*/
/* if_indextoname() does not take buffer size. not a good api... */
if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) &&
bufsiz >= IF_NAMESIZE) {
char *p = if_indextoname(ifindex, buf);
if (p) {
return(strlen(p));
}
}
#endif
/* last resort */
sprintf(tmp, "%u", sa6->sin6_scope_id);
if (bufsiz != 0U) {
strncpy(buf, tmp, bufsiz - 1);
buf[bufsiz - 1] = '\0';
}
return(strlen(tmp));
}
#endif
/*! \file */

View File

@ -1,345 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: getnetent.c,v 1.6.18.1 2005/04/27 05:00:58 sra Exp $";
#endif
/* Imports */
#include "port_before.h"
#if !defined(__BIND_NOSTATIC)
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <netdb.h>
#include <resolv.h>
#include <stdlib.h>
#include <string.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "irs_data.h"
/* Definitions */
struct pvt {
struct netent netent;
char * aliases[1];
char name[MAXDNAME + 1];
};
/* Forward */
static struct net_data *init(void);
static struct netent *nw_to_net(struct nwent *, struct net_data *);
static void freepvt(struct net_data *);
static struct netent *fakeaddr(const char *, int af, struct net_data *);
/* Portability */
#ifndef INADDR_NONE
# define INADDR_NONE 0xffffffff
#endif
/* Public */
struct netent *
getnetent() {
struct net_data *net_data = init();
return (getnetent_p(net_data));
}
struct netent *
getnetbyname(const char *name) {
struct net_data *net_data = init();
return (getnetbyname_p(name, net_data));
}
struct netent *
getnetbyaddr(unsigned long net, int type) {
struct net_data *net_data = init();
return (getnetbyaddr_p(net, type, net_data));
}
void
setnetent(int stayopen) {
struct net_data *net_data = init();
setnetent_p(stayopen, net_data);
}
void
endnetent() {
struct net_data *net_data = init();
endnetent_p(net_data);
}
/* Shared private. */
struct netent *
getnetent_p(struct net_data *net_data) {
struct irs_nw *nw;
if (!net_data || !(nw = net_data->nw))
return (NULL);
net_data->nww_last = (*nw->next)(nw);
net_data->nw_last = nw_to_net(net_data->nww_last, net_data);
return (net_data->nw_last);
}
struct netent *
getnetbyname_p(const char *name, struct net_data *net_data) {
struct irs_nw *nw;
struct netent *np;
char **nap;
if (!net_data || !(nw = net_data->nw))
return (NULL);
if (net_data->nw_stayopen && net_data->nw_last) {
if (!strcmp(net_data->nw_last->n_name, name))
return (net_data->nw_last);
for (nap = net_data->nw_last->n_aliases; nap && *nap; nap++)
if (!strcmp(name, *nap))
return (net_data->nw_last);
}
if ((np = fakeaddr(name, AF_INET, net_data)) != NULL)
return (np);
net_data->nww_last = (*nw->byname)(nw, name, AF_INET);
net_data->nw_last = nw_to_net(net_data->nww_last, net_data);
if (!net_data->nw_stayopen)
endnetent();
return (net_data->nw_last);
}
struct netent *
getnetbyaddr_p(unsigned long net, int type, struct net_data *net_data) {
struct irs_nw *nw;
u_char addr[4];
int bits;
if (!net_data || !(nw = net_data->nw))
return (NULL);
if (net_data->nw_stayopen && net_data->nw_last)
if (type == net_data->nw_last->n_addrtype &&
net == net_data->nw_last->n_net)
return (net_data->nw_last);
/* cannonize net(host order) */
if (net < 256UL) {
net <<= 24;
bits = 8;
} else if (net < 65536UL) {
net <<= 16;
bits = 16;
} else if (net < 16777216UL) {
net <<= 8;
bits = 24;
} else
bits = 32;
/* convert to net order */
addr[0] = (0xFF000000 & net) >> 24;
addr[1] = (0x00FF0000 & net) >> 16;
addr[2] = (0x0000FF00 & net) >> 8;
addr[3] = (0x000000FF & net);
/* reduce bits to as close to natural number as possible */
if ((bits == 32) && (addr[0] < 224) && (addr[3] == 0)) {
if ((addr[0] < 192) && (addr[2] == 0)) {
if ((addr[0] < 128) && (addr[1] == 0))
bits = 8;
else
bits = 16;
} else {
bits = 24;
}
}
net_data->nww_last = (*nw->byaddr)(nw, addr, bits, AF_INET);
net_data->nw_last = nw_to_net(net_data->nww_last, net_data);
if (!net_data->nw_stayopen)
endnetent();
return (net_data->nw_last);
}
void
setnetent_p(int stayopen, struct net_data *net_data) {
struct irs_nw *nw;
if (!net_data || !(nw = net_data->nw))
return;
freepvt(net_data);
(*nw->rewind)(nw);
net_data->nw_stayopen = (stayopen != 0);
if (stayopen == 0)
net_data_minimize(net_data);
}
void
endnetent_p(struct net_data *net_data) {
struct irs_nw *nw;
if ((net_data != NULL) && ((nw = net_data->nw) != NULL))
(*nw->minimize)(nw);
}
/* Private */
static struct net_data *
init() {
struct net_data *net_data;
if (!(net_data = net_data_init(NULL)))
goto error;
if (!net_data->nw) {
net_data->nw = (*net_data->irs->nw_map)(net_data->irs);
if (!net_data->nw || !net_data->res) {
error:
errno = EIO;
return (NULL);
}
(*net_data->nw->res_set)(net_data->nw, net_data->res, NULL);
}
return (net_data);
}
static void
freepvt(struct net_data *net_data) {
if (net_data->nw_data) {
free(net_data->nw_data);
net_data->nw_data = NULL;
}
}
static struct netent *
fakeaddr(const char *name, int af, struct net_data *net_data) {
struct pvt *pvt;
const char *cp;
u_long tmp;
if (af != AF_INET) {
/* XXX should support IPv6 some day */
errno = EAFNOSUPPORT;
RES_SET_H_ERRNO(net_data->res, NETDB_INTERNAL);
return (NULL);
}
if (!isascii((unsigned char)(name[0])) ||
!isdigit((unsigned char)(name[0])))
return (NULL);
for (cp = name; *cp; ++cp)
if (!isascii(*cp) || (!isdigit((unsigned char)*cp) && *cp != '.'))
return (NULL);
if (*--cp == '.')
return (NULL);
/* All-numeric, no dot at the end. */
tmp = inet_network(name);
if (tmp == INADDR_NONE) {
RES_SET_H_ERRNO(net_data->res, HOST_NOT_FOUND);
return (NULL);
}
/* Valid network number specified.
* Fake up a netent as if we'd actually
* done a lookup.
*/
freepvt(net_data);
net_data->nw_data = malloc(sizeof (struct pvt));
if (!net_data->nw_data) {
errno = ENOMEM;
RES_SET_H_ERRNO(net_data->res, NETDB_INTERNAL);
return (NULL);
}
pvt = net_data->nw_data;
strncpy(pvt->name, name, MAXDNAME);
pvt->name[MAXDNAME] = '\0';
pvt->netent.n_name = pvt->name;
pvt->netent.n_addrtype = AF_INET;
pvt->netent.n_aliases = pvt->aliases;
pvt->aliases[0] = NULL;
pvt->netent.n_net = tmp;
return (&pvt->netent);
}
static struct netent *
nw_to_net(struct nwent *nwent, struct net_data *net_data) {
struct pvt *pvt;
u_long addr = 0;
int i;
int msbyte;
if (!nwent || nwent->n_addrtype != AF_INET)
return (NULL);
freepvt(net_data);
net_data->nw_data = malloc(sizeof (struct pvt));
if (!net_data->nw_data) {
errno = ENOMEM;
RES_SET_H_ERRNO(net_data->res, NETDB_INTERNAL);
return (NULL);
}
pvt = net_data->nw_data;
pvt->netent.n_name = nwent->n_name;
pvt->netent.n_aliases = nwent->n_aliases;
pvt->netent.n_addrtype = nwent->n_addrtype;
/*%
* What this code does: Converts net addresses from network to host form.
*
* msbyte: the index of the most significant byte in the n_addr array.
*
* Shift bytes in significant order into addr. When all signicant
* bytes are in, zero out bits in the LSB that are not part of the network.
*/
msbyte = nwent->n_length / 8 +
((nwent->n_length % 8) != 0 ? 1 : 0) - 1;
for (i = 0; i <= msbyte; i++)
addr = (addr << 8) | ((unsigned char *)nwent->n_addr)[i];
i = (32 - nwent->n_length) % 8;
if (i != 0)
addr &= ~((1 << (i + 1)) - 1);
pvt->netent.n_net = addr;
return (&pvt->netent);
}
#endif /*__BIND_NOSTATIC*/
/*! \file */

View File

@ -1,234 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1998-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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: getnetent_r.c,v 1.4.18.2 2005/09/03 12:45:14 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <port_before.h>
#if !defined(_REENTRANT) || !defined(DO_PTHREADS)
static int getnetent_r_not_required = 0;
#else
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/param.h>
#include <port_after.h>
#ifdef NET_R_RETURN
static NET_R_RETURN
copy_netent(struct netent *, struct netent *, NET_R_COPY_ARGS);
NET_R_RETURN
getnetbyname_r(const char *name, struct netent *nptr, NET_R_ARGS) {
struct netent *ne = getnetbyname(name);
#ifdef NET_R_SETANSWER
int n = 0;
if (ne == NULL || (n = copy_netent(ne, nptr, NET_R_COPY)) != 0)
*answerp = NULL;
else
*answerp = ne;
if (ne == NULL)
*h_errnop = h_errno;
return (n);
#else
if (ne == NULL)
return (NET_R_BAD);
return (copy_netent(ne, nptr, NET_R_COPY));
#endif
}
#ifndef GETNETBYADDR_ADDR_T
#define GETNETBYADDR_ADDR_T long
#endif
NET_R_RETURN
getnetbyaddr_r(GETNETBYADDR_ADDR_T addr, int type, struct netent *nptr, NET_R_ARGS) {
struct netent *ne = getnetbyaddr(addr, type);
#ifdef NET_R_SETANSWER
int n = 0;
if (ne == NULL || (n = copy_netent(ne, nptr, NET_R_COPY)) != 0)
*answerp = NULL;
else
*answerp = ne;
if (ne == NULL)
*h_errnop = h_errno;
return (n);
#else
if (ne == NULL)
return (NET_R_BAD);
return (copy_netent(ne, nptr, NET_R_COPY));
#endif
}
/*%
* These assume a single context is in operation per thread.
* If this is not the case we will need to call irs directly
* rather than through the base functions.
*/
NET_R_RETURN
getnetent_r(struct netent *nptr, NET_R_ARGS) {
struct netent *ne = getnetent();
#ifdef NET_R_SETANSWER
int n = 0;
if (ne == NULL || (n = copy_netent(ne, nptr, NET_R_COPY)) != 0)
*answerp = NULL;
else
*answerp = ne;
if (ne == NULL)
*h_errnop = h_errno;
return (n);
#else
if (ne == NULL)
return (NET_R_BAD);
return (copy_netent(ne, nptr, NET_R_COPY));
#endif
}
NET_R_SET_RETURN
#ifdef NET_R_ENT_ARGS
setnetent_r(int stay_open, NET_R_ENT_ARGS)
#else
setnetent_r(int stay_open)
#endif
{
#ifdef NET_R_ENT_ARGS
UNUSED(ndptr);
#endif
setnetent(stay_open);
#ifdef NET_R_SET_RESULT
return (NET_R_SET_RESULT);
#endif
}
NET_R_END_RETURN
#ifdef NET_R_ENT_ARGS
endnetent_r(NET_R_ENT_ARGS)
#else
endnetent_r()
#endif
{
#ifdef NET_R_ENT_ARGS
UNUSED(ndptr);
#endif
endnetent();
NET_R_END_RESULT(NET_R_OK);
}
/* Private */
#ifndef NETENT_DATA
static NET_R_RETURN
copy_netent(struct netent *ne, struct netent *nptr, NET_R_COPY_ARGS) {
char *cp;
int i, n;
int numptr, len;
/* Find out the amount of space required to store the answer. */
numptr = 1; /*%< NULL ptr */
len = (char *)ALIGN(buf) - buf;
for (i = 0; ne->n_aliases[i]; i++, numptr++) {
len += strlen(ne->n_aliases[i]) + 1;
}
len += strlen(ne->n_name) + 1;
len += numptr * sizeof(char*);
if (len > (int)buflen) {
errno = ERANGE;
return (NET_R_BAD);
}
/* copy net value and type */
nptr->n_addrtype = ne->n_addrtype;
nptr->n_net = ne->n_net;
cp = (char *)ALIGN(buf) + numptr * sizeof(char *);
/* copy official name */
n = strlen(ne->n_name) + 1;
strcpy(cp, ne->n_name);
nptr->n_name = cp;
cp += n;
/* copy aliases */
nptr->n_aliases = (char **)ALIGN(buf);
for (i = 0 ; ne->n_aliases[i]; i++) {
n = strlen(ne->n_aliases[i]) + 1;
strcpy(cp, ne->n_aliases[i]);
nptr->n_aliases[i] = cp;
cp += n;
}
nptr->n_aliases[i] = NULL;
return (NET_R_OK);
}
#else /* !NETENT_DATA */
static int
copy_netent(struct netent *ne, struct netent *nptr, NET_R_COPY_ARGS) {
char *cp, *eob;
int i, n;
/* copy net value and type */
nptr->n_addrtype = ne->n_addrtype;
nptr->n_net = ne->n_net;
/* copy official name */
cp = ndptr->line;
eob = ndptr->line + sizeof(ndptr->line);
if ((n = strlen(ne->n_name) + 1) < (eob - cp)) {
strcpy(cp, ne->n_name);
nptr->n_name = cp;
cp += n;
} else {
return (-1);
}
/* copy aliases */
i = 0;
nptr->n_aliases = ndptr->net_aliases;
while (ne->n_aliases[i] && i < (_MAXALIASES-1)) {
if ((n = strlen(ne->n_aliases[i]) + 1) < (eob - cp)) {
strcpy(cp, ne->n_aliases[i]);
nptr->n_aliases[i] = cp;
cp += n;
} else {
break;
}
i++;
}
nptr->n_aliases[i] = NULL;
return (NET_R_OK);
}
#endif /* !NETENT_DATA */
#else /* NET_R_RETURN */
static int getnetent_r_unknown_system = 0;
#endif /* NET_R_RETURN */
#endif /* !defined(_REENTRANT) || !defined(DO_PTHREADS) */
/*! \file */

View File

@ -1,160 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* 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 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: getnetgrent.c,v 1.3.18.2 2008/02/27 00:08:30 marka Exp $";
#endif /* LIBC_SCCS and not lint */
/* Imports */
#include "port_before.h"
#if !defined(__BIND_NOSTATIC)
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <errno.h>
#include <resolv.h>
#include <stdio.h>
#include <irs.h>
#include "port_after.h"
#include "irs_data.h"
/* Forward */
static struct net_data *init(void);
/* Public */
#ifndef SETNETGRENT_ARGS
#define SETNETGRENT_ARGS const char *netgroup
#endif
void
setnetgrent(SETNETGRENT_ARGS) {
struct net_data *net_data = init();
setnetgrent_p(netgroup, net_data);
}
void
endnetgrent(void) {
struct net_data *net_data = init();
endnetgrent_p(net_data);
}
#ifndef INNETGR_ARGS
#define INNETGR_ARGS const char *netgroup, const char *host, \
const char *user, const char *domain
#endif
int
innetgr(INNETGR_ARGS) {
struct net_data *net_data = init();
return (innetgr_p(netgroup, host, user, domain, net_data));
}
int
getnetgrent(NGR_R_CONST char **host, NGR_R_CONST char **user,
NGR_R_CONST char **domain)
{
struct net_data *net_data = init();
const char *ch, *cu, *cd;
int ret;
ret = getnetgrent_p(&ch, &cu, &cd, net_data);
if (ret != 1)
return (ret);
DE_CONST(ch, *host);
DE_CONST(cu, *user);
DE_CONST(cd, *domain);
return (ret);
}
/* Shared private. */
void
setnetgrent_p(const char *netgroup, struct net_data *net_data) {
struct irs_ng *ng;
if ((net_data != NULL) && ((ng = net_data->ng) != NULL))
(*ng->rewind)(ng, netgroup);
}
void
endnetgrent_p(struct net_data *net_data) {
struct irs_ng *ng;
if (!net_data)
return;
if ((ng = net_data->ng) != NULL)
(*ng->close)(ng);
net_data->ng = NULL;
}
int
innetgr_p(const char *netgroup, const char *host,
const char *user, const char *domain,
struct net_data *net_data) {
struct irs_ng *ng;
if (!net_data || !(ng = net_data->ng))
return (0);
return ((*ng->test)(ng, netgroup, host, user, domain));
}
int
getnetgrent_p(const char **host, const char **user, const char **domain,
struct net_data *net_data ) {
struct irs_ng *ng;
if (!net_data || !(ng = net_data->ng))
return (0);
return ((*ng->next)(ng, host, user, domain));
}
/* Private */
static struct net_data *
init(void) {
struct net_data *net_data;
if (!(net_data = net_data_init(NULL)))
goto error;
if (!net_data->ng) {
net_data->ng = (*net_data->irs->ng_map)(net_data->irs);
if (!net_data->ng) {
error:
errno = EIO;
return (NULL);
}
}
return (net_data);
}
#endif /*__BIND_NOSTATIC*/
/*! \file */

Some files were not shown because too many files have changed in this diff Show More