mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
make this go on the Alpha.
This commit is contained in:
2
acconfig.h
Normal file
2
acconfig.h
Normal file
@@ -0,0 +1,2 @@
|
||||
/* define if you need inet_ntop() */
|
||||
#undef NEED_INET_NTOP
|
@@ -15,6 +15,9 @@
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* define if you need inet_ntop() */
|
||||
#undef NEED_INET_NTOP
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
|
66
configure
vendored
66
configure
vendored
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
|
||||
# From configure.in Revision: 1.8
|
||||
# From configure.in Revision: 1.9
|
||||
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated automatically using autoconf version 2.12
|
||||
@@ -1367,8 +1367,65 @@ fi
|
||||
|
||||
fi
|
||||
|
||||
|
||||
echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6
|
||||
echo "configure:1373: checking for inet_ntop" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_func_inet_ntop'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1378 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char inet_ntop(); below. */
|
||||
#include <assert.h>
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
builtin and then its argument prototype would still apply. */
|
||||
char inet_ntop();
|
||||
|
||||
int main() {
|
||||
|
||||
/* The GNU C library defines this for functions which it implements
|
||||
to always fail with ENOSYS. Some functions are actually named
|
||||
something starting with __ and the normal name is an alias. */
|
||||
#if defined (__stub_inet_ntop) || defined (__stub___inet_ntop)
|
||||
choke me
|
||||
#else
|
||||
inet_ntop();
|
||||
#endif
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1401: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_inet_ntop=yes"
|
||||
else
|
||||
echo "configure: failed program was:" >&5
|
||||
cat conftest.$ac_ext >&5
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_inet_ntop=no"
|
||||
fi
|
||||
rm -f conftest*
|
||||
fi
|
||||
|
||||
if eval "test \"`echo '$ac_cv_func_'inet_ntop`\" = yes"; then
|
||||
echo "$ac_t""yes" 1>&6
|
||||
:
|
||||
else
|
||||
echo "$ac_t""no" 1>&6
|
||||
ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_ntop.o"
|
||||
|
||||
cat >> confdefs.h <<\EOF
|
||||
#define NEED_INET_NTOP 1
|
||||
EOF
|
||||
|
||||
|
||||
fi
|
||||
|
||||
|
||||
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
|
||||
echo "configure:1372: checking whether ${MAKE-make} sets \${MAKE}" >&5
|
||||
echo "configure:1429: checking whether ${MAKE-make} sets \${MAKE}" >&5
|
||||
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
@@ -1397,7 +1454,7 @@ fi
|
||||
# Extract the first word of "ranlib", so it can be a program name with args.
|
||||
set dummy ranlib; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1401: checking for $ac_word" >&5
|
||||
echo "configure:1458: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1434,7 +1491,7 @@ fi
|
||||
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
|
||||
# ./install, which can be erroneously created by make from ./install.sh.
|
||||
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
|
||||
echo "configure:1438: checking for a BSD compatible install" >&5
|
||||
echo "configure:1495: checking for a BSD compatible install" >&5
|
||||
if test -z "$INSTALL"; then
|
||||
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
@@ -1673,6 +1730,7 @@ s%@host_vendor@%$host_vendor%g
|
||||
s%@host_os@%$host_os%g
|
||||
s%@CC@%$CC%g
|
||||
s%@CPP@%$CPP%g
|
||||
s%@ISC_EXTRA_OBJS@%$ISC_EXTRA_OBJS%g
|
||||
s%@SET_MAKE@%$SET_MAKE%g
|
||||
s%@RANLIB@%$RANLIB%g
|
||||
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
AC_REVISION($Revision: 1.9 $)
|
||||
AC_REVISION($Revision: 1.10 $)
|
||||
|
||||
AC_INIT(lib/dns/name.c)
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
@@ -23,6 +23,13 @@ AC_CHECK_LIB(xnet, socket,,
|
||||
AC_CHECK_LIB(socket, socket)
|
||||
AC_CHECK_LIB(nsl, inet_ntoa)
|
||||
)
|
||||
|
||||
AC_CHECK_FUNC(inet_ntop, ,
|
||||
[ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_ntop.o"
|
||||
AC_SUBST(ISC_EXTRA_OBJS)
|
||||
AC_DEFINE(NEED_INET_NTOP)]
|
||||
)
|
||||
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_INSTALL
|
||||
|
@@ -15,10 +15,11 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/error.h>
|
||||
|
@@ -15,16 +15,20 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: a_1.c,v 1.6 1999/01/22 00:36:58 marka Exp $ */
|
||||
/* $Id: a_1.c,v 1.7 1999/01/22 04:35:10 explorer Exp $ */
|
||||
|
||||
#ifndef RDATA_IN_1_A_1_H
|
||||
#define RDATA_IN_1_A_1_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/inet.h>
|
||||
|
||||
static dns_result_t
|
||||
fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type,
|
||||
@@ -63,8 +67,8 @@ totext_in_a(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
|
||||
origin = origin; /* unused */
|
||||
|
||||
isc_buffer_available(target, ®ion);
|
||||
if (inet_ntop(AF_INET, rdata->data,
|
||||
region.base, region.length) == NULL)
|
||||
if (isc_inet_ntop(AF_INET, rdata->data,
|
||||
region.base, region.length) == NULL)
|
||||
return (DNS_R_NOSPACE);
|
||||
|
||||
isc_buffer_add(target, strlen(region.base));
|
||||
|
@@ -15,16 +15,20 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: a_1.h,v 1.6 1999/01/22 00:36:58 marka Exp $ */
|
||||
/* $Id: a_1.h,v 1.7 1999/01/22 04:35:10 explorer Exp $ */
|
||||
|
||||
#ifndef RDATA_IN_1_A_1_H
|
||||
#define RDATA_IN_1_A_1_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/inet.h>
|
||||
|
||||
static dns_result_t
|
||||
fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type,
|
||||
@@ -63,8 +67,8 @@ totext_in_a(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
|
||||
origin = origin; /* unused */
|
||||
|
||||
isc_buffer_available(target, ®ion);
|
||||
if (inet_ntop(AF_INET, rdata->data,
|
||||
region.base, region.length) == NULL)
|
||||
if (isc_inet_ntop(AF_INET, rdata->data,
|
||||
region.base, region.length) == NULL)
|
||||
return (DNS_R_NOSPACE);
|
||||
|
||||
isc_buffer_add(target, strlen(region.base));
|
||||
|
@@ -15,21 +15,22 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: wks_11.c,v 1.2 1999/01/22 00:36:59 marka Exp $ */
|
||||
/* $Id: wks_11.c,v 1.3 1999/01/22 04:35:10 explorer Exp $ */
|
||||
|
||||
#ifndef RDATA_IN_1_WKS_11_H
|
||||
#define RDATA_IN_1_WKS_11_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <limits.h>
|
||||
#include <netdb.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <isc/inet.h>
|
||||
|
||||
static dns_result_t
|
||||
fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type,
|
||||
@@ -124,7 +125,7 @@ totext_in_wks(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
|
||||
origin = origin;
|
||||
dns_rdata_toregion(rdata, &sr);
|
||||
isc_buffer_available(target, &tr);
|
||||
if (inet_ntop(AF_INET, sr.base, tr.base, tr.length) == NULL)
|
||||
if (isc_inet_ntop(AF_INET, sr.base, tr.base, tr.length) == NULL)
|
||||
return (DNS_R_NOSPACE);
|
||||
isc_buffer_add(target, strlen(tr.base));
|
||||
isc_region_consume(&sr, 4);
|
||||
|
@@ -15,21 +15,22 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: wks_11.h,v 1.2 1999/01/22 00:36:59 marka Exp $ */
|
||||
/* $Id: wks_11.h,v 1.3 1999/01/22 04:35:10 explorer Exp $ */
|
||||
|
||||
#ifndef RDATA_IN_1_WKS_11_H
|
||||
#define RDATA_IN_1_WKS_11_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <limits.h>
|
||||
#include <netdb.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <isc/inet.h>
|
||||
|
||||
static dns_result_t
|
||||
fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type,
|
||||
@@ -124,7 +125,7 @@ totext_in_wks(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
|
||||
origin = origin;
|
||||
dns_rdata_toregion(rdata, &sr);
|
||||
isc_buffer_available(target, &tr);
|
||||
if (inet_ntop(AF_INET, sr.base, tr.base, tr.length) == NULL)
|
||||
if (isc_inet_ntop(AF_INET, sr.base, tr.base, tr.length) == NULL)
|
||||
return (DNS_R_NOSPACE);
|
||||
isc_buffer_add(target, strlen(tr.base));
|
||||
isc_region_consume(&sr, 4);
|
||||
|
@@ -15,10 +15,11 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/error.h>
|
||||
|
@@ -14,7 +14,8 @@ CWARNINGS =
|
||||
OBJS = assertions.o buffer.o error.o heap.o lex.o mem.o result.o \
|
||||
rwlock.o symtab.o task.o timer.o version.o \
|
||||
unix/time.o unix/socket.o \
|
||||
pthreads/condition.o
|
||||
pthreads/condition.o \
|
||||
@ISC_EXTRA_OBJS@
|
||||
|
||||
SUBDIRS = include unix pthreads
|
||||
TARGETS = timestamp
|
||||
|
36
lib/isc/include/isc/inet.h
Normal file
36
lib/isc/include/isc/inet.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 1999 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef ISC_INET_H
|
||||
#define ISC_INET_H 1
|
||||
|
||||
/*
|
||||
* Provide missing functionality that functions internal to the isc/dns
|
||||
* library will need.
|
||||
*
|
||||
* This file will need to be generated if it will be installed, since it
|
||||
* depends on <config.h> being included. This won't work outside our
|
||||
* controlled tree.
|
||||
*/
|
||||
|
||||
#ifdef NEED_INET_NTOP
|
||||
char *isc_inet_ntop(int af, const void *src, char *dst, size_t size);
|
||||
#else
|
||||
#define isc_inet_ntop inet_ntop
|
||||
#endif
|
||||
|
||||
#endif /* ISC_INET_H */
|
187
lib/isc/inet_ntop.c
Normal file
187
lib/isc/inet_ntop.c
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* Copyright (c) 1996-1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char rcsid[] = "$Id: inet_ntop.c,v 1.1 1999/01/22 04:35:11 explorer Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.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>
|
||||
|
||||
#define NS_INT16SZ 2
|
||||
#define NS_IN6ADDRSZ 16
|
||||
|
||||
/*
|
||||
* 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 *isc_inet_ntop4(const u_char *src, char *dst, size_t size);
|
||||
static const char *isc_inet_ntop6(const u_char *src, char *dst, size_t size);
|
||||
|
||||
/* char *
|
||||
* isc_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 *
|
||||
isc_inet_ntop(int af, const void *src, char *dst, size_t size)
|
||||
{
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
return (isc_inet_ntop4(src, dst, size));
|
||||
case AF_INET6:
|
||||
return (isc_inet_ntop6(src, dst, size));
|
||||
default:
|
||||
errno = EAFNOSUPPORT;
|
||||
return (NULL);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/* const char *
|
||||
* isc_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 *
|
||||
isc_inet_ntop4(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 *
|
||||
* isc_inet_ntop6(src, dst, size)
|
||||
* convert IPv6 binary address into presentation (printable) format
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static const char *
|
||||
isc_inet_ntop6(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;
|
||||
cur.base = -1;
|
||||
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 == 5 && words[5] == 0xffff))) {
|
||||
if (!isc_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);
|
||||
}
|
Reference in New Issue
Block a user