mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
Merge branch '192-make-ipv6-mandatory' into 'master'
Remove all kind of legacy compatibility layers (including IPv6, networking and functions defined by C99 or POSIX.1) Closes #192 See merge request isc-projects/bind9!668
This commit is contained in:
commit
b6e64eb23b
105 changed files with 426 additions and 7291 deletions
4
CHANGES
4
CHANGES
|
|
@ -1,3 +1,7 @@
|
|||
5023. [cleanup] Remove wrappers that try to fix broken or incomplete
|
||||
implementations of IPv6, pthreads and other core
|
||||
functionality required and used by BIND. [GL #192]
|
||||
|
||||
5022. [doc] Update ms-self, ms-subdomain, krb5-self, and
|
||||
krb5-subdomain documentation. [GL !708]
|
||||
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ Minimally, BIND requires a UNIX or Linux system with an ANSI C compiler,
|
|||
basic POSIX support, and a 64-bit integer type. Successful builds have been
|
||||
observed on many versions of Linux and UNIX, including RedHat, Fedora,
|
||||
Debian, Ubuntu, SuSE, Slackware, FreeBSD, NetBSD, OpenBSD, Mac OS X,
|
||||
Solaris, HP-UX, AIX, SCO OpenServer, and OpenWRT.
|
||||
Solaris, HP-UX, and OpenWRT.
|
||||
|
||||
BIND requires a cryptography provider library such as OpenSSL or a
|
||||
hardware service module supporting PKCS#11. On Linux, BIND requires
|
||||
|
|
@ -271,10 +271,6 @@ specifying `--enable-fixed-rrset` or `--disable-fixed-rrset` on the
|
|||
configure command line. By default, fixed rrset-order is disabled to
|
||||
reduce memory footprint.
|
||||
|
||||
If your operating system has integrated support for IPv6, it will be used
|
||||
automatically. If you have installed KAME IPv6 separately, use
|
||||
`--with-kame[=PATH]` to specify its location.
|
||||
|
||||
`make install` will install `named` and the various BIND 9 libraries. By
|
||||
default, installation is into /usr/local, but this can be changed with the
|
||||
`--prefix` option when running `configure`.
|
||||
|
|
|
|||
47
acconfig.h
47
acconfig.h
|
|
@ -17,9 +17,6 @@
|
|||
***/
|
||||
@TOP@
|
||||
|
||||
/** define on DEC OSF to enable 4.4BSD style sa_len support */
|
||||
#undef _SOCKADDR_LEN
|
||||
|
||||
/** define if your system needs pthread_init() before using pthreads */
|
||||
#undef NEED_PTHREAD_INIT
|
||||
|
||||
|
|
@ -53,62 +50,18 @@
|
|||
/** define if tzset() is available */
|
||||
#undef HAVE_TZSET
|
||||
|
||||
/** define if struct addrinfo exists */
|
||||
#undef HAVE_ADDRINFO
|
||||
|
||||
/** define if getaddrinfo() exists */
|
||||
#undef HAVE_GETADDRINFO
|
||||
|
||||
/** define if gai_strerror() exists */
|
||||
#undef HAVE_GAISTRERROR
|
||||
|
||||
/**
|
||||
* define if pthread_setconcurrency() should be called to tell the
|
||||
* OS how many threads we might want to run.
|
||||
*/
|
||||
#undef CALL_PTHREAD_SETCONCURRENCY
|
||||
|
||||
/** define if IPv6 is not disabled */
|
||||
#undef WANT_IPV6
|
||||
|
||||
/** define if flockfile() is available */
|
||||
#undef HAVE_FLOCKFILE
|
||||
|
||||
/** define if getc_unlocked() is available */
|
||||
#undef HAVE_GETCUNLOCKED
|
||||
|
||||
/** 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
|
||||
|
||||
/** Shut up warnings about missing sigwait prototype on BSD/OS 4.0* */
|
||||
#undef SHUTUP_SIGWAIT
|
||||
#ifdef SHUTUP_SIGWAIT
|
||||
int sigwait(const unsigned int *set, int *sig);
|
||||
#endif
|
||||
|
||||
/** Shut up warnings from gcc -Wcast-qual on BSD/OS 4.1. */
|
||||
#undef SHUTUP_STDARG_CAST
|
||||
#if defined(SHUTUP_STDARG_CAST) && defined(__GNUC__)
|
||||
#include <stdarg.h> /** Grr. Must be included *every time*. */
|
||||
/**
|
||||
* The silly continuation line is to keep configure from
|
||||
* commenting out the #undef.
|
||||
*/
|
||||
|
||||
#undef \
|
||||
va_start
|
||||
#define va_start(ap, last) \
|
||||
do { \
|
||||
union { const void *konst; long *var; } _u; \
|
||||
_u.konst = &(last); \
|
||||
ap = (va_list)(_u.var + __va_words(__typeof(last))); \
|
||||
} while (0)
|
||||
#endif /** SHUTUP_STDARG_CAST && __GNUC__ */
|
||||
|
||||
/** define if the system has a random number generating device */
|
||||
#undef PATH_RANDOMDEV
|
||||
|
||||
|
|
|
|||
|
|
@ -62,14 +62,6 @@
|
|||
#define CHECK_LOCAL 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ADDRINFO
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
#ifdef HAVE_GAISTRERROR
|
||||
#define USE_GETADDRINFO
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define CHECK(r) \
|
||||
do { \
|
||||
result = (r); \
|
||||
|
|
@ -177,7 +169,6 @@ static bool
|
|||
checkns(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner,
|
||||
dns_rdataset_t *a, dns_rdataset_t *aaaa)
|
||||
{
|
||||
#ifdef USE_GETADDRINFO
|
||||
dns_rdataset_t *rdataset;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
struct addrinfo hints, *ai, *cur;
|
||||
|
|
@ -373,14 +364,10 @@ checkns(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner,
|
|||
}
|
||||
freeaddrinfo(ai);
|
||||
return (answer);
|
||||
#else
|
||||
return (true);
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool
|
||||
checkmx(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner) {
|
||||
#ifdef USE_GETADDRINFO
|
||||
struct addrinfo hints, *ai, *cur;
|
||||
char namebuf[DNS_NAME_FORMATSIZE + 1];
|
||||
char ownerbuf[DNS_NAME_FORMATSIZE];
|
||||
|
|
@ -459,14 +446,10 @@ checkmx(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner) {
|
|||
}
|
||||
return (true);
|
||||
}
|
||||
#else
|
||||
return (true);
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool
|
||||
checksrv(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner) {
|
||||
#ifdef USE_GETADDRINFO
|
||||
struct addrinfo hints, *ai, *cur;
|
||||
char namebuf[DNS_NAME_FORMATSIZE + 1];
|
||||
char ownerbuf[DNS_NAME_FORMATSIZE];
|
||||
|
|
@ -544,9 +527,6 @@ checksrv(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner) {
|
|||
}
|
||||
return (true);
|
||||
}
|
||||
#else
|
||||
return (true);
|
||||
#endif
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
|
|
@ -791,4 +771,3 @@ DestroySockets(void) {
|
|||
WSACleanup();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/stdlib.h>
|
||||
|
||||
#include <dns/byaddr.h>
|
||||
#include <dns/fixedname.h>
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
#include "dnssectool.h"
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024 /* AIX, WIN32, and others don't define this. */
|
||||
#define PATH_MAX 1024 /* WIN32, and others don't define this. */
|
||||
#endif
|
||||
|
||||
const char *program = "dnssec-cds";
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
#include "dnssectool.h"
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024 /* AIX, WIN32, and others don't define this. */
|
||||
#define PATH_MAX 1024 /* WIN32, and others don't define this. */
|
||||
#endif
|
||||
|
||||
const char *program = "dnssec-dsfromkey";
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
#include "dnssectool.h"
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024 /* AIX, WIN32, and others don't define this. */
|
||||
#define PATH_MAX 1024 /* WIN32, and others don't define this. */
|
||||
#endif
|
||||
|
||||
const char *program = "dnssec-importkey";
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@
|
|||
#include <isc/serial.h>
|
||||
#include <isc/safe.h>
|
||||
#include <isc/stdio.h>
|
||||
#include <isc/stdlib.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/time.h>
|
||||
|
|
@ -89,7 +88,7 @@
|
|||
#include "dnssectool.h"
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024 /* AIX, WIN32, and others don't define this. */
|
||||
#define PATH_MAX 1024 /* WIN32, and others don't define this. */
|
||||
#endif
|
||||
|
||||
const char *program = "dnssec-signzone";
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
#include <isc/rwlock.h>
|
||||
#include <isc/serial.h>
|
||||
#include <isc/stdio.h>
|
||||
#include <isc/stdlib.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/time.h>
|
||||
#include <isc/util.h>
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ key_collision(dst_key_t *dstkey, dns_name_t *name, const char *dir,
|
|||
uint16_t id, oldid;
|
||||
uint32_t rid, roldid;
|
||||
dns_secalg_t alg;
|
||||
char filename[ISC_DIR_NAMEMAX];
|
||||
char filename[NAME_MAX];
|
||||
isc_buffer_t fileb;
|
||||
isc_stdtime_t now;
|
||||
|
||||
|
|
|
|||
|
|
@ -110,8 +110,8 @@ LIBDNS_EXTERNAL_DATA extern unsigned int dns_zone_mkey_day;
|
|||
LIBDNS_EXTERNAL_DATA extern unsigned int dns_zone_mkey_month;
|
||||
|
||||
static bool want_stats = false;
|
||||
static char program_name[ISC_DIR_NAMEMAX] = "named";
|
||||
static char absolute_conffile[ISC_DIR_PATHMAX];
|
||||
static char program_name[NAME_MAX] = "named";
|
||||
static char absolute_conffile[PATH_MAX];
|
||||
static char saved_command_line[512];
|
||||
static char version[512];
|
||||
static unsigned int maxsocks = 0;
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@
|
|||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <grp.h>
|
||||
#include <fcntl.h>
|
||||
#include <grp.h> /* Required for initgroups() on IRIX. */
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -40,7 +40,6 @@
|
|||
#include <isc/print.h>
|
||||
#include <isc/resource.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/strerror.h>
|
||||
#include <isc/string.h>
|
||||
|
||||
#include <named/globals.h>
|
||||
|
|
@ -130,7 +129,7 @@ linux_setcaps(cap_t caps) {
|
|||
return;
|
||||
}
|
||||
if (cap_set_proc(caps) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlyfatal("cap_set_proc() failed: %s:"
|
||||
" please ensure that the capset kernel"
|
||||
" module is loaded. see insmod(8)",
|
||||
|
|
@ -146,13 +145,13 @@ linux_setcaps(cap_t caps) {
|
|||
if (err != -1 && curval) { \
|
||||
err = cap_set_flag(caps, CAP_EFFECTIVE, 1, &capval, CAP_SET); \
|
||||
if (err == -1) { \
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf)); \
|
||||
strerror_r(errno, strbuf, sizeof(strbuf)); \
|
||||
named_main_earlyfatal("cap_set_proc failed: %s", strbuf); \
|
||||
} \
|
||||
\
|
||||
err = cap_set_flag(caps, CAP_PERMITTED, 1, &capval, CAP_SET); \
|
||||
if (err == -1) { \
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf)); \
|
||||
strerror_r(errno, strbuf, sizeof(strbuf)); \
|
||||
named_main_earlyfatal("cap_set_proc failed: %s", strbuf); \
|
||||
} \
|
||||
} \
|
||||
|
|
@ -161,12 +160,12 @@ linux_setcaps(cap_t caps) {
|
|||
do { \
|
||||
caps = cap_init(); \
|
||||
if (caps == NULL) { \
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf)); \
|
||||
strerror_r(errno, strbuf, sizeof(strbuf)); \
|
||||
named_main_earlyfatal("cap_init failed: %s", strbuf); \
|
||||
} \
|
||||
curcaps = cap_get_proc(); \
|
||||
if (curcaps == NULL) { \
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf)); \
|
||||
strerror_r(errno, strbuf, sizeof(strbuf)); \
|
||||
named_main_earlyfatal("cap_get_proc failed: %s", strbuf); \
|
||||
} \
|
||||
} while (0)
|
||||
|
|
@ -286,7 +285,7 @@ linux_keepcaps(void) {
|
|||
|
||||
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0) {
|
||||
if (errno != EINVAL) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlyfatal("prctl() failed: %s", strbuf);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -331,13 +330,13 @@ named_os_daemonize(void) {
|
|||
char strbuf[ISC_STRERRORSIZE];
|
||||
|
||||
if (pipe(dfd) == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlyfatal("pipe(): %s", strbuf);
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
if (pid == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlyfatal("fork(): %s", strbuf);
|
||||
}
|
||||
if (pid != 0) {
|
||||
|
|
@ -367,7 +366,7 @@ named_os_daemonize(void) {
|
|||
#endif
|
||||
|
||||
if (setsid() == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlyfatal("setsid(): %s", strbuf);
|
||||
}
|
||||
|
||||
|
|
@ -450,14 +449,14 @@ named_os_chroot(const char *root) {
|
|||
if (root != NULL) {
|
||||
#ifdef HAVE_CHROOT
|
||||
if (chroot(root) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlyfatal("chroot(): %s", strbuf);
|
||||
}
|
||||
#else
|
||||
named_main_earlyfatal("chroot(): disabled");
|
||||
#endif
|
||||
if (chdir("/") < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlyfatal("chdir(/): %s", strbuf);
|
||||
}
|
||||
#ifdef HAVE_LIBSCF
|
||||
|
|
@ -484,7 +483,7 @@ named_os_inituserinfo(const char *username) {
|
|||
|
||||
if (getuid() == 0) {
|
||||
if (initgroups(runas_pw->pw_name, runas_pw->pw_gid) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlyfatal("initgroups(): %s", strbuf);
|
||||
}
|
||||
}
|
||||
|
|
@ -514,12 +513,12 @@ named_os_changeuser(void) {
|
|||
#endif
|
||||
|
||||
if (setgid(runas_pw->pw_gid) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlyfatal("setgid(): %s", strbuf);
|
||||
}
|
||||
|
||||
if (setuid(runas_pw->pw_uid) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlyfatal("setuid(): %s", strbuf);
|
||||
}
|
||||
|
||||
|
|
@ -529,7 +528,7 @@ named_os_changeuser(void) {
|
|||
* call has disabled it.
|
||||
*/
|
||||
if (prctl(PR_SET_DUMPABLE,1,0,0,0) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlywarning("prctl(PR_SET_DUMPABLE) failed: %s",
|
||||
strbuf);
|
||||
}
|
||||
|
|
@ -648,7 +647,7 @@ mkdirpath(char *filename, void (*report)(const char *, ...)) {
|
|||
|
||||
if (stat(filename, &sb) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
(*report)("couldn't stat '%s': %s", filename,
|
||||
strbuf);
|
||||
goto error;
|
||||
|
|
@ -668,7 +667,7 @@ mkdirpath(char *filename, void (*report)(const char *, ...)) {
|
|||
mode |= S_IRGRP | S_IXGRP; /* g=rx */
|
||||
mode |= S_IROTH | S_IXOTH; /* o=rx */
|
||||
if (mkdir(filename, mode) == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
(*report)("couldn't mkdir '%s': %s", filename,
|
||||
strbuf);
|
||||
goto error;
|
||||
|
|
@ -676,7 +675,7 @@ mkdirpath(char *filename, void (*report)(const char *, ...)) {
|
|||
if (runas_pw != NULL &&
|
||||
chown(filename, runas_pw->pw_uid,
|
||||
runas_pw->pw_gid) == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
(*report)("couldn't chown '%s': %s", filename,
|
||||
strbuf);
|
||||
}
|
||||
|
|
@ -703,7 +702,7 @@ setperms(uid_t uid, gid_t gid) {
|
|||
#endif
|
||||
#if defined(HAVE_SETEGID)
|
||||
if (getegid() != gid && setegid(gid) == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlywarning("unable to set effective "
|
||||
"gid to %ld: %s",
|
||||
(long)gid, strbuf);
|
||||
|
|
@ -711,7 +710,7 @@ setperms(uid_t uid, gid_t gid) {
|
|||
#elif defined(HAVE_SETRESGID)
|
||||
if (getresgid(&tmpg, &oldgid, &tmpg) == -1 || oldgid != gid) {
|
||||
if (setresgid(-1, gid, -1) == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlywarning("unable to set effective "
|
||||
"gid to %d: %s", gid, strbuf);
|
||||
}
|
||||
|
|
@ -720,7 +719,7 @@ setperms(uid_t uid, gid_t gid) {
|
|||
|
||||
#if defined(HAVE_SETEUID)
|
||||
if (geteuid() != uid && seteuid(uid) == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlywarning("unable to set effective "
|
||||
"uid to %ld: %s",
|
||||
(long)uid, strbuf);
|
||||
|
|
@ -728,7 +727,7 @@ setperms(uid_t uid, gid_t gid) {
|
|||
#elif defined(HAVE_SETRESUID)
|
||||
if (getresuid(&tmpu, &olduid, &tmpu) == -1 || olduid != uid) {
|
||||
if (setresuid(-1, uid, -1) == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlywarning("unable to set effective "
|
||||
"uid to %d: %s", uid, strbuf);
|
||||
}
|
||||
|
|
@ -747,7 +746,7 @@ named_os_openfile(const char *filename, mode_t mode, bool switch_user) {
|
|||
*/
|
||||
f = strdup(filename);
|
||||
if (f == NULL) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlywarning("couldn't strdup() '%s': %s",
|
||||
filename, strbuf);
|
||||
return (NULL);
|
||||
|
|
@ -799,7 +798,7 @@ named_os_openfile(const char *filename, mode_t mode, bool switch_user) {
|
|||
}
|
||||
|
||||
if (fd < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlywarning("could not open file '%s': %s",
|
||||
filename, strbuf);
|
||||
return (NULL);
|
||||
|
|
@ -807,7 +806,7 @@ named_os_openfile(const char *filename, mode_t mode, bool switch_user) {
|
|||
|
||||
fp = fdopen(fd, "w");
|
||||
if (fp == NULL) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlywarning("could not fdopen() file '%s': %s",
|
||||
filename, strbuf);
|
||||
}
|
||||
|
|
@ -835,7 +834,7 @@ named_os_writepidfile(const char *filename, bool first_time) {
|
|||
|
||||
pidfile = strdup(filename);
|
||||
if (pidfile == NULL) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
(*report)("couldn't strdup() '%s': %s", filename, strbuf);
|
||||
return;
|
||||
}
|
||||
|
|
@ -882,7 +881,7 @@ named_os_issingleton(const char *filename) {
|
|||
*/
|
||||
lockfile = strdup(filename);
|
||||
if (lockfile == NULL) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlyfatal("couldn't allocate memory for '%s': %s",
|
||||
filename, strbuf);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#include <isc/print.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/strerror.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/ntpaths.h>
|
||||
#include <isc/util.h>
|
||||
|
|
@ -231,7 +230,7 @@ named_os_openfile(const char *filename, int mode, bool switch_user) {
|
|||
UNUSED(switch_user);
|
||||
fd = safe_open(filename, mode, false);
|
||||
if (fd < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_s(strbuf, sizeof(strbuf), errno);
|
||||
named_main_earlywarning("could not open file '%s': %s",
|
||||
filename, strbuf);
|
||||
return (NULL);
|
||||
|
|
@ -239,7 +238,7 @@ named_os_openfile(const char *filename, int mode, bool switch_user) {
|
|||
|
||||
fp = fdopen(fd, "w");
|
||||
if (fp == NULL) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_s(strbuf, sizeof(strbuf), errno);
|
||||
named_main_earlywarning("could not fdopen() file '%s': %s",
|
||||
filename, strbuf);
|
||||
close(fd);
|
||||
|
|
@ -268,7 +267,7 @@ named_os_writepidfile(const char *filename, bool first_time) {
|
|||
|
||||
pidfile = strdup(filename);
|
||||
if (pidfile == NULL) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_s(strbuf, sizeof(strbuf), errno);
|
||||
(*report)("couldn't strdup() '%s': %s", filename, strbuf);
|
||||
return;
|
||||
}
|
||||
|
|
@ -312,7 +311,7 @@ named_os_issingleton(const char *filename) {
|
|||
|
||||
lockfile = strdup(filename);
|
||||
if (lockfile == NULL) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_s(strbuf, sizeof(strbuf), errno);
|
||||
named_main_earlyfatal("couldn't allocate memory for '%s': %s",
|
||||
filename, strbuf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,20 +99,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ADDRINFO
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
#ifdef HAVE_GAISTRERROR
|
||||
#define USE_GETADDRINFO
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef USE_GETADDRINFO
|
||||
#ifndef ISC_PLATFORM_NONSTDHERRNO
|
||||
extern int h_errno;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define MAXCMD (128 * 1024)
|
||||
#define MAXWIRE (64 * 1024)
|
||||
#define PACKETSIZE ((64 * 1024) - 1)
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@
|
|||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <isc/print.h>
|
||||
#include <isc/serial.h>
|
||||
#include <isc/stdlib.h>
|
||||
|
||||
int
|
||||
main() {
|
||||
|
|
|
|||
|
|
@ -138,11 +138,7 @@ else
|
|||
TESTSOCK6=false
|
||||
fi
|
||||
|
||||
if grep "^#define WANT_IPV6 1" $TOP/config.h > /dev/null 2>&1 ; then
|
||||
TESTSOCK6="$TESTSOCK6"
|
||||
else
|
||||
TESTSOCK6=false
|
||||
fi
|
||||
TESTSOCK6="$TESTSOCK6"
|
||||
|
||||
# Windows process management leave empty
|
||||
PSSUSPEND=
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ PARALLELDIRS="allow_query catz rpzrecurse serve-stale"
|
|||
SUBDIRS="$SEQUENTIALDIRS $PARALLELDIRS"
|
||||
|
||||
# missing: chain integrity
|
||||
# extra: dname ednscompliance forward
|
||||
# extra: dname ednscompliance forward
|
||||
|
||||
#Things that are different on Windows
|
||||
KILL="/bin/kill -f"
|
||||
|
|
@ -117,7 +117,7 @@ DOS2UNIX=dos2unix
|
|||
TP=
|
||||
|
||||
# Configure is launched from native environment, but tests are run in Cygwin -
|
||||
# so any detection is unreliable.
|
||||
# so any detection is unreliable.
|
||||
SHELL="/bin/bash -o igncr"
|
||||
CURL=/usr/bin/curl
|
||||
XMLLINT=/usr/bin/xmllint
|
||||
|
|
@ -135,11 +135,7 @@ else
|
|||
TESTSOCK6=false
|
||||
fi
|
||||
|
||||
if grep "^#define WANT_IPV6 1" $TOP/config.h > /dev/null 2>&1 ; then
|
||||
TESTSOCK6="$TESTSOCK6"
|
||||
else
|
||||
TESTSOCK6=false
|
||||
fi
|
||||
TESTSOCK6="$TESTSOCK6"
|
||||
|
||||
#
|
||||
# PsSuspend is part of PSTools and can be downloaded from
|
||||
|
|
|
|||
|
|
@ -38,15 +38,7 @@ EOF
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# If running on hp-ux, don't even try to run config.guess.
|
||||
# It will try to create a temporary file in the current directory,
|
||||
# which fails when running as root with the current directory
|
||||
# on a NFS mounted disk.
|
||||
|
||||
case `uname -a` in
|
||||
*HP-UX*) sys=hpux ;;
|
||||
*) sys=`sh $config_guess` ;;
|
||||
esac
|
||||
sys=`sh $config_guess`
|
||||
|
||||
use_ip=
|
||||
case "$sys" in
|
||||
|
|
|
|||
74
config.h.in
74
config.h.in
|
|
@ -17,9 +17,6 @@
|
|||
*** it does not get installed.
|
||||
***/
|
||||
|
||||
/** define on DEC OSF to enable 4.4BSD style sa_len support */
|
||||
#undef _SOCKADDR_LEN
|
||||
|
||||
/** define if your system needs pthread_init() before using pthreads */
|
||||
#undef NEED_PTHREAD_INIT
|
||||
|
||||
|
|
@ -53,62 +50,18 @@
|
|||
/** define if tzset() is available */
|
||||
#undef HAVE_TZSET
|
||||
|
||||
/** define if struct addrinfo exists */
|
||||
#undef HAVE_ADDRINFO
|
||||
|
||||
/** define if getaddrinfo() exists */
|
||||
#undef HAVE_GETADDRINFO
|
||||
|
||||
/** define if gai_strerror() exists */
|
||||
#undef HAVE_GAISTRERROR
|
||||
|
||||
/**
|
||||
* define if pthread_setconcurrency() should be called to tell the
|
||||
* OS how many threads we might want to run.
|
||||
*/
|
||||
#undef CALL_PTHREAD_SETCONCURRENCY
|
||||
|
||||
/** define if IPv6 is not disabled */
|
||||
#undef WANT_IPV6
|
||||
|
||||
/** define if flockfile() is available */
|
||||
#undef HAVE_FLOCKFILE
|
||||
|
||||
/** define if getc_unlocked() is available */
|
||||
#undef HAVE_GETCUNLOCKED
|
||||
|
||||
/** 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
|
||||
|
||||
/** Shut up warnings about missing sigwait prototype on BSD/OS 4.0* */
|
||||
#undef SHUTUP_SIGWAIT
|
||||
#ifdef SHUTUP_SIGWAIT
|
||||
int sigwait(const unsigned int *set, int *sig);
|
||||
#endif
|
||||
|
||||
/** Shut up warnings from gcc -Wcast-qual on BSD/OS 4.1. */
|
||||
#undef SHUTUP_STDARG_CAST
|
||||
#if defined(SHUTUP_STDARG_CAST) && defined(__GNUC__)
|
||||
#include <stdarg.h> /** Grr. Must be included *every time*. */
|
||||
/**
|
||||
* The silly continuation line is to keep configure from
|
||||
* commenting out the #undef.
|
||||
*/
|
||||
|
||||
#undef \
|
||||
va_start
|
||||
#define va_start(ap, last) \
|
||||
do { \
|
||||
union { const void *konst; long *var; } _u; \
|
||||
_u.konst = &(last); \
|
||||
ap = (va_list)(_u.var + __va_words(__typeof(last))); \
|
||||
} while (0)
|
||||
#endif /** SHUTUP_STDARG_CAST && __GNUC__ */
|
||||
|
||||
/** define if the system has a random number generating device */
|
||||
#undef PATH_RANDOMDEV
|
||||
|
||||
|
|
@ -139,10 +92,6 @@ int sigwait(const unsigned int *set, int *sig);
|
|||
/* define if ATF unit tests are to be built. */
|
||||
#undef ATF_TEST
|
||||
|
||||
/* Define if recvmsg() does not meet all of the BSD socket API specifications.
|
||||
*/
|
||||
#undef BROKEN_RECVMSG
|
||||
|
||||
/* Define if you cannot bind() before connect() for TCP sockets. */
|
||||
#undef BROKEN_TCP_BIND_BEFORE_CONNECT
|
||||
|
||||
|
|
@ -461,9 +410,6 @@ int sigwait(const unsigned int *set, int *sig);
|
|||
/* Define to 1 if you have the <sys/devpoll.h> header file. */
|
||||
#undef HAVE_SYS_DEVPOLL_H
|
||||
|
||||
/* Define to 1 if you have the <sys/dyntune.h> header file. */
|
||||
#undef HAVE_SYS_DYNTUNE_H
|
||||
|
||||
/* Define to 1 if you have the <sys/mman.h> header file. */
|
||||
#undef HAVE_SYS_MMAN_H
|
||||
|
||||
|
|
@ -506,9 +452,6 @@ int sigwait(const unsigned int *set, int *sig);
|
|||
/* Define if Thread-Local Storage is available */
|
||||
#undef HAVE_TLS
|
||||
|
||||
/* Define if running under Compaq TruCluster */
|
||||
#undef HAVE_TRUCLUSTER
|
||||
|
||||
/* Define to 1 if the system has the type `uintptr_t'. */
|
||||
#undef HAVE_UINTPTR_T
|
||||
|
||||
|
|
@ -530,18 +473,6 @@ int sigwait(const unsigned int *set, int *sig);
|
|||
/* Use HMAC-SHA256 for Client Cookie generation */
|
||||
#undef HMAC_SHA256_CC
|
||||
|
||||
/* return type of gai_strerror */
|
||||
#undef IRS_GAISTRERROR_RETURN_T
|
||||
|
||||
/* Define to the buffer length type used by getnameinfo(3). */
|
||||
#undef IRS_GETNAMEINFO_BUFLEN_T
|
||||
|
||||
/* Define to the flags type used by getnameinfo(3). */
|
||||
#undef IRS_GETNAMEINFO_FLAGS_T
|
||||
|
||||
/* Define to the sockaddr length type used by getnameinfo(3). */
|
||||
#undef IRS_GETNAMEINFO_SOCKLEN_T
|
||||
|
||||
/* Define if you want to use inline buffers */
|
||||
#undef ISC_BUFFER_USEINLINE
|
||||
|
||||
|
|
@ -639,8 +570,11 @@ int sigwait(const unsigned int *set, int *sig);
|
|||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#undef const
|
||||
|
||||
/* Define to empty if your compiler does not support "static inline". */
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
#undef inline
|
||||
#endif
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
|
|
|||
|
|
@ -141,8 +141,6 @@ char *getpassphrase(const char *);
|
|||
*/
|
||||
#define ISC_DLZ_DLOPEN 1
|
||||
|
||||
#define WANT_IPV6
|
||||
|
||||
#define S_IFMT _S_IFMT /* file type mask */
|
||||
#define S_IFDIR _S_IFDIR /* directory */
|
||||
#define S_IFCHR _S_IFCHR /* character special */
|
||||
|
|
@ -291,27 +289,6 @@ typedef __int64 off_t;
|
|||
*/
|
||||
@HAVE_LIBXML2@
|
||||
|
||||
/** define if struct addrinfo exists */
|
||||
#define HAVE_ADDRINFO
|
||||
|
||||
/** define if getaddrinfo() exists */
|
||||
#define HAVE_GETADDRINFO
|
||||
|
||||
/** define if gai_strerror() exists */
|
||||
#define HAVE_GAISTRERROR
|
||||
|
||||
/* return type of gai_strerror */
|
||||
#define IRS_GAISTRERROR_RETURN_T char *
|
||||
|
||||
/* Define to the buffer length type used by getnameinfo(3). */
|
||||
#define IRS_GETNAMEINFO_BUFLEN_T DWORD
|
||||
|
||||
/* Define to the flags type used by getnameinfo(3). */
|
||||
#define IRS_GETNAMEINFO_FLAGS_T int
|
||||
|
||||
/* Define to the sockaddr length type used by getnameinfo(3). */
|
||||
#define IRS_GETNAMEINFO_SOCKLEN_T socklen_t
|
||||
|
||||
/* Define to enable "rrset-order fixed" syntax. */
|
||||
@DNS_RDATASET_FIXED@
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@ case $host in
|
|||
use_threads=false ;;
|
||||
*-solaris*)
|
||||
use_threads=true ;;
|
||||
*-ibm-aix*)
|
||||
use_threads=true ;;
|
||||
*-hp-hpux10*)
|
||||
use_threads=false ;;
|
||||
*-hp-hpux11*)
|
||||
|
|
@ -50,13 +48,8 @@ case $host in
|
|||
use_threads=false ;;
|
||||
*-freebsd*)
|
||||
use_threads=true ;;
|
||||
[*-bsdi[234]*])
|
||||
# Thread signals do not work reliably on some versions of BSD/OS.
|
||||
use_threads=false ;;
|
||||
*-bsdi5*)
|
||||
use_threads=true ;;
|
||||
*-linux*)
|
||||
use_threads=true ;;
|
||||
use_threads=true ;;
|
||||
*-darwin[[123456789]].*)
|
||||
use_threads=false ;;
|
||||
*-darwin*.*)
|
||||
|
|
@ -86,7 +79,7 @@ if $use_threads
|
|||
then
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
if $use_threads
|
||||
|
|
@ -99,7 +92,7 @@ then
|
|||
# We don't want to set -lpthread as that break
|
||||
# the ability to choose threads library at final
|
||||
# link time and is not valid for all architectures.
|
||||
|
||||
|
||||
PTHREAD=
|
||||
if test "X$GCC" = "Xyes"; then
|
||||
saved_cc="$CC"
|
||||
|
|
|
|||
863
configure.in
863
configure.in
File diff suppressed because it is too large
Load diff
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
/*
|
||||
* Copyright (C) 1999-2001, 2016 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
|
@ -84,7 +84,7 @@ typedef struct config_data {
|
|||
typedef struct dir_entry dir_entry_t;
|
||||
|
||||
struct dir_entry {
|
||||
char dirpath[ISC_DIR_PATHMAX];
|
||||
char dirpath[PATH_MAX];
|
||||
ISC_LINK(dir_entry_t) link;
|
||||
};
|
||||
|
||||
|
|
@ -361,7 +361,7 @@ process_dir(isc_dir_t *dir, void *passback, config_data_t *cd,
|
|||
dlist_t *dir_list, unsigned int basedirlen)
|
||||
{
|
||||
|
||||
char tmp[ISC_DIR_PATHMAX + ISC_DIR_NAMEMAX];
|
||||
char tmp[PATH_MAX + NAME_MAX];
|
||||
int astPos;
|
||||
struct stat sb;
|
||||
isc_result_t result = ISC_R_FAILURE;
|
||||
|
|
@ -369,7 +369,7 @@ process_dir(isc_dir_t *dir, void *passback, config_data_t *cd,
|
|||
char *type;
|
||||
char *ttlStr;
|
||||
char *data;
|
||||
char host[ISC_DIR_NAMEMAX];
|
||||
char host[NAME_MAX];
|
||||
char *tmpString;
|
||||
char *tmpPtr;
|
||||
int ttl;
|
||||
|
|
@ -408,7 +408,7 @@ process_dir(isc_dir_t *dir, void *passback, config_data_t *cd,
|
|||
{
|
||||
if ((strlen(host) +
|
||||
strlen(tmpPtr + 1) + 2)
|
||||
> ISC_DIR_NAMEMAX)
|
||||
> NAME_MAX)
|
||||
continue;
|
||||
strcat(host, tmpPtr + 1);
|
||||
strcat(host, ".");
|
||||
|
|
@ -416,7 +416,7 @@ process_dir(isc_dir_t *dir, void *passback, config_data_t *cd,
|
|||
}
|
||||
if ((strlen(host) +
|
||||
strlen(tmpString) + 1)
|
||||
<= ISC_DIR_NAMEMAX)
|
||||
<= NAME_MAX)
|
||||
strcat(host, tmpString);
|
||||
}
|
||||
|
||||
|
|
@ -443,7 +443,7 @@ process_dir(isc_dir_t *dir, void *passback, config_data_t *cd,
|
|||
strncpy(host,
|
||||
(char *) &dir->entry.name[6],
|
||||
sizeof(host) - 1);
|
||||
host[255] = '\0';
|
||||
host[NAME_MAX-1] = '\0';
|
||||
}
|
||||
foundHost = true;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,8 @@
|
|||
/* config.h.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the `getaddrinfo' function. */
|
||||
#undef HAVE_GETADDRINFO
|
||||
|
||||
/* Define to 1 if you have the `gethostbyname2' function. */
|
||||
#undef HAVE_GETHOSTBYNAME2
|
||||
|
||||
/* Define to 1 if you have the `getnameinfo' function. */
|
||||
#undef HAVE_GETNAMEINFO
|
||||
|
||||
/* Define to 1 if you have the `nsl' library (-lnsl). */
|
||||
#undef HAVE_LIBNSL
|
||||
|
||||
|
|
@ -30,6 +24,9 @@
|
|||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
|
|
|
|||
213
contrib/queryperf/configure
vendored
213
contrib/queryperf/configure
vendored
|
|
@ -1,11 +1,9 @@
|
|||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.68.
|
||||
# Generated by GNU Autoconf 2.69.
|
||||
#
|
||||
#
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
|
||||
# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
|
||||
# Foundation, Inc.
|
||||
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
|
||||
#
|
||||
#
|
||||
# This configure script is free software; the Free Software Foundation
|
||||
|
|
@ -134,6 +132,31 @@ export LANGUAGE
|
|||
# CDPATH.
|
||||
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
|
||||
|
||||
# Use a proper internal environment variable to ensure we don't fall
|
||||
# into an infinite loop, continuously re-executing ourselves.
|
||||
if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
|
||||
_as_can_reexec=no; export _as_can_reexec;
|
||||
# We cannot yet assume a decent shell, so we have to provide a
|
||||
# neutralization value for shells without unset; and this also
|
||||
# works around shells that cannot unset nonexistent variables.
|
||||
# Preserve -v and -x to the replacement shell.
|
||||
BASH_ENV=/dev/null
|
||||
ENV=/dev/null
|
||||
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
|
||||
case $- in # ((((
|
||||
*v*x* | *x*v* ) as_opts=-vx ;;
|
||||
*v* ) as_opts=-v ;;
|
||||
*x* ) as_opts=-x ;;
|
||||
* ) as_opts= ;;
|
||||
esac
|
||||
exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
|
||||
# Admittedly, this is quite paranoid, since all the known shells bail
|
||||
# out after a failed `exec'.
|
||||
$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
|
||||
as_fn_exit 255
|
||||
fi
|
||||
# We don't want this to propagate to other subprocesses.
|
||||
{ _as_can_reexec=; unset _as_can_reexec;}
|
||||
if test "x$CONFIG_SHELL" = x; then
|
||||
as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
|
||||
emulate sh
|
||||
|
|
@ -167,7 +190,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
|
|||
else
|
||||
exitcode=1; echo positional parameters were not saved.
|
||||
fi
|
||||
test x\$exitcode = x0 || exit 1"
|
||||
test x\$exitcode = x0 || exit 1
|
||||
test -x / || exit 1"
|
||||
as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
|
||||
as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
|
||||
eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
|
||||
|
|
@ -211,21 +235,25 @@ IFS=$as_save_IFS
|
|||
|
||||
|
||||
if test "x$CONFIG_SHELL" != x; then :
|
||||
# We cannot yet assume a decent shell, so we have to provide a
|
||||
# neutralization value for shells without unset; and this also
|
||||
# works around shells that cannot unset nonexistent variables.
|
||||
# Preserve -v and -x to the replacement shell.
|
||||
BASH_ENV=/dev/null
|
||||
ENV=/dev/null
|
||||
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
|
||||
export CONFIG_SHELL
|
||||
case $- in # ((((
|
||||
*v*x* | *x*v* ) as_opts=-vx ;;
|
||||
*v* ) as_opts=-v ;;
|
||||
*x* ) as_opts=-x ;;
|
||||
* ) as_opts= ;;
|
||||
esac
|
||||
exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
|
||||
export CONFIG_SHELL
|
||||
# We cannot yet assume a decent shell, so we have to provide a
|
||||
# neutralization value for shells without unset; and this also
|
||||
# works around shells that cannot unset nonexistent variables.
|
||||
# Preserve -v and -x to the replacement shell.
|
||||
BASH_ENV=/dev/null
|
||||
ENV=/dev/null
|
||||
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
|
||||
case $- in # ((((
|
||||
*v*x* | *x*v* ) as_opts=-vx ;;
|
||||
*v* ) as_opts=-v ;;
|
||||
*x* ) as_opts=-x ;;
|
||||
* ) as_opts= ;;
|
||||
esac
|
||||
exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
|
||||
# Admittedly, this is quite paranoid, since all the known shells bail
|
||||
# out after a failed `exec'.
|
||||
$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
|
||||
exit 255
|
||||
fi
|
||||
|
||||
if test x$as_have_required = xno; then :
|
||||
|
|
@ -327,6 +355,14 @@ $as_echo X"$as_dir" |
|
|||
|
||||
|
||||
} # as_fn_mkdir_p
|
||||
|
||||
# as_fn_executable_p FILE
|
||||
# -----------------------
|
||||
# Test if FILE is an executable regular file.
|
||||
as_fn_executable_p ()
|
||||
{
|
||||
test -f "$1" && test -x "$1"
|
||||
} # as_fn_executable_p
|
||||
# as_fn_append VAR VALUE
|
||||
# ----------------------
|
||||
# Append the text in VALUE to the end of the definition contained in VAR. Take
|
||||
|
|
@ -448,6 +484,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
|
|||
chmod +x "$as_me.lineno" ||
|
||||
{ $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
|
||||
|
||||
# If we had to re-execute with $CONFIG_SHELL, we're ensured to have
|
||||
# already done that, so ensure we don't try to do so again and fall
|
||||
# in an infinite loop. This has already happened in practice.
|
||||
_as_can_reexec=no; export _as_can_reexec
|
||||
# Don't try to exec as it changes $[0], causing all sort of problems
|
||||
# (the dirname of $[0] is not the place where we might find the
|
||||
# original and so on. Autoconf is especially sensitive to this).
|
||||
|
|
@ -482,16 +522,16 @@ if (echo >conf$$.file) 2>/dev/null; then
|
|||
# ... but there are two gotchas:
|
||||
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
|
||||
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
|
||||
# In both cases, we have to default to `cp -p'.
|
||||
# In both cases, we have to default to `cp -pR'.
|
||||
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
|
||||
as_ln_s='cp -p'
|
||||
as_ln_s='cp -pR'
|
||||
elif ln conf$$.file conf$$ 2>/dev/null; then
|
||||
as_ln_s=ln
|
||||
else
|
||||
as_ln_s='cp -p'
|
||||
as_ln_s='cp -pR'
|
||||
fi
|
||||
else
|
||||
as_ln_s='cp -p'
|
||||
as_ln_s='cp -pR'
|
||||
fi
|
||||
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
|
||||
rmdir conf$$.dir 2>/dev/null
|
||||
|
|
@ -503,28 +543,8 @@ else
|
|||
as_mkdir_p=false
|
||||
fi
|
||||
|
||||
if test -x / >/dev/null 2>&1; then
|
||||
as_test_x='test -x'
|
||||
else
|
||||
if ls -dL / >/dev/null 2>&1; then
|
||||
as_ls_L_option=L
|
||||
else
|
||||
as_ls_L_option=
|
||||
fi
|
||||
as_test_x='
|
||||
eval sh -c '\''
|
||||
if test -d "$1"; then
|
||||
test -d "$1/.";
|
||||
else
|
||||
case $1 in #(
|
||||
-*)set "./$1";;
|
||||
esac;
|
||||
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
|
||||
???[sx]*):;;*)false;;esac;fi
|
||||
'\'' sh
|
||||
'
|
||||
fi
|
||||
as_executable_p=$as_test_x
|
||||
as_test_x='test -x'
|
||||
as_executable_p=as_fn_executable_p
|
||||
|
||||
# Sed expression to map a string onto a valid CPP name.
|
||||
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
|
||||
|
|
@ -1076,8 +1096,6 @@ target=$target_alias
|
|||
if test "x$host_alias" != x; then
|
||||
if test "x$build_alias" = x; then
|
||||
cross_compiling=maybe
|
||||
$as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
|
||||
If a cross compiler is detected then cross compile mode will be used" >&2
|
||||
elif test "x$build_alias" != "x$host_alias"; then
|
||||
cross_compiling=yes
|
||||
fi
|
||||
|
|
@ -1302,9 +1320,9 @@ test -n "$ac_init_help" && exit $ac_status
|
|||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
configure
|
||||
generated by GNU Autoconf 2.68
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
This configure script is free software; the Free Software Foundation
|
||||
gives unlimited permission to copy, distribute and modify it.
|
||||
_ACEOF
|
||||
|
|
@ -1380,7 +1398,7 @@ $as_echo "$ac_try_echo"; } >&5
|
|||
test ! -s conftest.err
|
||||
} && test -s conftest$ac_exeext && {
|
||||
test "$cross_compiling" = yes ||
|
||||
$as_test_x conftest$ac_exeext
|
||||
test -x conftest$ac_exeext
|
||||
}; then :
|
||||
ac_retval=0
|
||||
else
|
||||
|
|
@ -1470,7 +1488,7 @@ This file contains any messages produced by compilers while
|
|||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by $as_me, which was
|
||||
generated by GNU Autoconf 2.68. Invocation command line was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
|
||||
|
|
@ -1842,7 +1860,7 @@ do
|
|||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
||||
ac_cv_prog_CC="${ac_tool_prefix}gcc"
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
|
|
@ -1882,7 +1900,7 @@ do
|
|||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
||||
ac_cv_prog_ac_ct_CC="gcc"
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
|
|
@ -1935,7 +1953,7 @@ do
|
|||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
||||
ac_cv_prog_CC="${ac_tool_prefix}cc"
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
|
|
@ -1976,7 +1994,7 @@ do
|
|||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
||||
if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
|
||||
ac_prog_rejected=yes
|
||||
continue
|
||||
|
|
@ -2034,7 +2052,7 @@ do
|
|||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
||||
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
|
|
@ -2078,7 +2096,7 @@ do
|
|||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
||||
ac_cv_prog_ac_ct_CC="$ac_prog"
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
|
|
@ -2524,8 +2542,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|||
/* end confdefs.h. */
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
struct stat;
|
||||
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
|
||||
struct buf { int x; };
|
||||
FILE * (*rcsopen) (struct buf *, struct stat *, int);
|
||||
|
|
@ -2887,34 +2904,6 @@ _ACEOF
|
|||
fi
|
||||
done
|
||||
|
||||
ac_fn_c_check_func "$LINENO" "getaddrinfo" "ac_cv_func_getaddrinfo"
|
||||
if test "x$ac_cv_func_getaddrinfo" = xyes; then :
|
||||
|
||||
$as_echo "#define HAVE_GETADDRINFO 1" >>confdefs.h
|
||||
|
||||
else
|
||||
case " $LIBOBJS " in
|
||||
*" getaddrinfo.$ac_objext "* ) ;;
|
||||
*) LIBOBJS="$LIBOBJS getaddrinfo.$ac_objext"
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
ac_fn_c_check_func "$LINENO" "getnameinfo" "ac_cv_func_getnameinfo"
|
||||
if test "x$ac_cv_func_getnameinfo" = xyes; then :
|
||||
|
||||
$as_echo "#define HAVE_GETNAMEINFO 1" >>confdefs.h
|
||||
|
||||
else
|
||||
case " $LIBOBJS " in
|
||||
*" getnameinfo.$ac_objext "* ) ;;
|
||||
*) LIBOBJS="$LIBOBJS getnameinfo.$ac_objext"
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socklen_t" >&5
|
||||
$as_echo_n "checking for socklen_t... " >&6; }
|
||||
|
|
@ -3394,16 +3383,16 @@ if (echo >conf$$.file) 2>/dev/null; then
|
|||
# ... but there are two gotchas:
|
||||
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
|
||||
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
|
||||
# In both cases, we have to default to `cp -p'.
|
||||
# In both cases, we have to default to `cp -pR'.
|
||||
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
|
||||
as_ln_s='cp -p'
|
||||
as_ln_s='cp -pR'
|
||||
elif ln conf$$.file conf$$ 2>/dev/null; then
|
||||
as_ln_s=ln
|
||||
else
|
||||
as_ln_s='cp -p'
|
||||
as_ln_s='cp -pR'
|
||||
fi
|
||||
else
|
||||
as_ln_s='cp -p'
|
||||
as_ln_s='cp -pR'
|
||||
fi
|
||||
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
|
||||
rmdir conf$$.dir 2>/dev/null
|
||||
|
|
@ -3463,28 +3452,16 @@ else
|
|||
as_mkdir_p=false
|
||||
fi
|
||||
|
||||
if test -x / >/dev/null 2>&1; then
|
||||
as_test_x='test -x'
|
||||
else
|
||||
if ls -dL / >/dev/null 2>&1; then
|
||||
as_ls_L_option=L
|
||||
else
|
||||
as_ls_L_option=
|
||||
fi
|
||||
as_test_x='
|
||||
eval sh -c '\''
|
||||
if test -d "$1"; then
|
||||
test -d "$1/.";
|
||||
else
|
||||
case $1 in #(
|
||||
-*)set "./$1";;
|
||||
esac;
|
||||
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
|
||||
???[sx]*):;;*)false;;esac;fi
|
||||
'\'' sh
|
||||
'
|
||||
fi
|
||||
as_executable_p=$as_test_x
|
||||
|
||||
# as_fn_executable_p FILE
|
||||
# -----------------------
|
||||
# Test if FILE is an executable regular file.
|
||||
as_fn_executable_p ()
|
||||
{
|
||||
test -f "$1" && test -x "$1"
|
||||
} # as_fn_executable_p
|
||||
as_test_x='test -x'
|
||||
as_executable_p=as_fn_executable_p
|
||||
|
||||
# Sed expression to map a string onto a valid CPP name.
|
||||
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
|
||||
|
|
@ -3506,7 +3483,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
|||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by $as_me, which was
|
||||
generated by GNU Autoconf 2.68. Invocation command line was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
CONFIG_HEADERS = $CONFIG_HEADERS
|
||||
|
|
@ -3568,10 +3545,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
|||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
config.status
|
||||
configured by $0, generated by GNU Autoconf 2.68,
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
This config.status script is free software; the Free Software Foundation
|
||||
gives unlimited permission to copy, distribute and modify it."
|
||||
|
||||
|
|
@ -3659,7 +3636,7 @@ fi
|
|||
_ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
if \$ac_cs_recheck; then
|
||||
set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
|
||||
set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
|
||||
shift
|
||||
\$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
|
||||
CONFIG_SHELL='$SHELL'
|
||||
|
|
|
|||
|
|
@ -58,12 +58,6 @@ AC_SEARCH_LIBS(res_9_mkquery, resolv bind)
|
|||
AC_CHECK_LIB(socket, socket)
|
||||
AC_CHECK_LIB(nsl, inet_ntoa)
|
||||
AC_CHECK_FUNCS(gethostbyname2)
|
||||
AC_CHECK_FUNC(getaddrinfo,
|
||||
AC_DEFINE(HAVE_GETADDRINFO, 1, [Define to 1 if you have the `getaddrinfo' function.]),
|
||||
[AC_LIBOBJ(getaddrinfo)])
|
||||
AC_CHECK_FUNC(getnameinfo,
|
||||
AC_DEFINE(HAVE_GETNAMEINFO, 1, [Define to 1 if you have the `getnameinfo' function.]),
|
||||
[AC_LIBOBJ(getnameinfo)])
|
||||
|
||||
AC_TYPE_SOCKLEN_T
|
||||
AC_SA_LEN
|
||||
|
|
|
|||
|
|
@ -1,100 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 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. 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.
|
||||
*/
|
||||
|
||||
#ifndef HAVE_GETADDRINFO
|
||||
|
||||
/*
|
||||
* 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 /* get address to use bind() */
|
||||
#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
|
||||
#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
|
||||
/* valid flags for addrinfo */
|
||||
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
|
||||
|
||||
#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
|
||||
#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
|
||||
#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
|
||||
#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
|
||||
/* special recommended flags for getipnodebyname */
|
||||
#define AI_DEFAULT (AI_V4MAPPED_CFG | 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
|
||||
|
||||
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 */
|
||||
size_t ai_addrlen; /* length of ai_addr */
|
||||
char *ai_canonname; /* canonical name for hostname */
|
||||
struct sockaddr *ai_addr; /* binary address */
|
||||
struct addrinfo *ai_next; /* next structure in linked list */
|
||||
};
|
||||
|
||||
struct sockaddr_storage {
|
||||
u_char __ss_len;
|
||||
u_char __ss_family;
|
||||
u_char fill[126];
|
||||
};
|
||||
|
||||
extern void freehostent(struct hostent *);
|
||||
extern char *gai_strerror(int);
|
||||
#endif
|
||||
|
|
@ -1,632 +0,0 @@
|
|||
/*
|
||||
* 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. 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 <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "addrinfo.h"
|
||||
|
||||
#define SUCCESS 0
|
||||
#define ANY 0
|
||||
#define YES 1
|
||||
#define NO 0
|
||||
|
||||
static const char in_addrany[] = { 0, 0, 0, 0 };
|
||||
static const char in6_addrany[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
static const char in_loopback[] = { 127, 0, 0, 1 };
|
||||
static const char in6_loopback[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
|
||||
};
|
||||
|
||||
struct sockinet {
|
||||
u_char si_len;
|
||||
u_char si_family;
|
||||
u_short si_port;
|
||||
};
|
||||
|
||||
static struct afd {
|
||||
int a_af;
|
||||
int a_addrlen;
|
||||
int a_socklen;
|
||||
int a_off;
|
||||
const char *a_addrany;
|
||||
const char *a_loopback;
|
||||
} afdl [] = {
|
||||
#ifdef INET6
|
||||
#define N_INET6 0
|
||||
{PF_INET6, sizeof(struct in6_addr),
|
||||
sizeof(struct sockaddr_in6),
|
||||
offsetof(struct sockaddr_in6, sin6_addr),
|
||||
in6_addrany, in6_loopback},
|
||||
#define N_INET 1
|
||||
#else
|
||||
#define N_INET 0
|
||||
#endif
|
||||
{PF_INET, sizeof(struct in_addr),
|
||||
sizeof(struct sockaddr_in),
|
||||
offsetof(struct sockaddr_in, sin_addr),
|
||||
in_addrany, in_loopback},
|
||||
{0, 0, 0, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
#ifdef INET6
|
||||
#define PTON_MAX 16
|
||||
#else
|
||||
#define PTON_MAX 4
|
||||
#endif
|
||||
|
||||
|
||||
static int get_name(const char *, struct afd *,
|
||||
struct addrinfo **, char *, struct addrinfo *,
|
||||
int);
|
||||
static int get_addr(const char *, int, struct addrinfo **,
|
||||
struct addrinfo *, int);
|
||||
static int get_addr0(const char *, int, struct addrinfo **,
|
||||
struct addrinfo *, int);
|
||||
static int str_isnumber(const char *);
|
||||
|
||||
static char *ai_errlist[] = {
|
||||
"Success",
|
||||
"Address family for hostname not supported", /* EAI_ADDRFAMILY */
|
||||
"Temporary failure in name resolution", /* EAI_AGAIN */
|
||||
"Invalid value for ai_flags", /* EAI_BADFLAGS */
|
||||
"Non-recoverable failure in name resolution", /* EAI_FAIL */
|
||||
"ai_family not supported", /* EAI_FAMILY */
|
||||
"Memory allocation failure", /* EAI_MEMORY */
|
||||
"No address associated with hostname", /* EAI_NODATA */
|
||||
"hostname nor servname provided, or not known",/* EAI_NONAME */
|
||||
"servname not supported for ai_socktype", /* EAI_SERVICE */
|
||||
"ai_socktype not supported", /* EAI_SOCKTYPE */
|
||||
"System error returned in errno", /* EAI_SYSTEM */
|
||||
"Invalid value for hints", /* EAI_BADHINTS */
|
||||
"Resolved protocol is unknown", /* EAI_PROTOCOL */
|
||||
"Unknown error", /* EAI_MAX */
|
||||
};
|
||||
|
||||
#define GET_CANONNAME(ai, str) \
|
||||
if (pai->ai_flags & AI_CANONNAME) {\
|
||||
if (((ai)->ai_canonname = (char *)malloc(strlen(str) + 1)) != NULL) {\
|
||||
strcpy((ai)->ai_canonname, (str));\
|
||||
} else {\
|
||||
error = EAI_MEMORY;\
|
||||
goto free;\
|
||||
}\
|
||||
}
|
||||
|
||||
#ifdef HAVE_SA_LEN
|
||||
#define SET_AILEN(ai,l) (ai)->ai_addr->sa_len = (ai)->ai_addrlen = (l)
|
||||
#else
|
||||
#define SET_AILEN(ai,l) (ai)->ai_addrlen = (l)
|
||||
#endif
|
||||
|
||||
#define GET_AI(ai, afd, addr, port) {\
|
||||
char *p;\
|
||||
if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\
|
||||
((afd)->a_socklen)))\
|
||||
== NULL) {\
|
||||
error = EAI_MEMORY;\
|
||||
goto free;\
|
||||
}\
|
||||
memcpy(ai, pai, sizeof(struct addrinfo));\
|
||||
(ai)->ai_addr = (struct sockaddr *)((ai) + 1);\
|
||||
memset((ai)->ai_addr, 0, (afd)->a_socklen);\
|
||||
SET_AILEN((ai), (afd)->a_socklen);\
|
||||
(ai)->ai_addr->sa_family = (ai)->ai_family = (afd)->a_af;\
|
||||
((struct sockinet *)(ai)->ai_addr)->si_port = port;\
|
||||
p = (char *)((ai)->ai_addr);\
|
||||
memcpy(p + (afd)->a_off, (addr), (afd)->a_addrlen);\
|
||||
}
|
||||
|
||||
#define ERR(err) { error = (err); goto bad; }
|
||||
|
||||
char *
|
||||
gai_strerror(ecode)
|
||||
int ecode;
|
||||
{
|
||||
if (ecode < 0 || ecode > EAI_MAX)
|
||||
ecode = EAI_MAX;
|
||||
return ai_errlist[ecode];
|
||||
}
|
||||
|
||||
void
|
||||
freeaddrinfo(ai)
|
||||
struct addrinfo *ai;
|
||||
{
|
||||
struct addrinfo *next;
|
||||
|
||||
do {
|
||||
next = ai->ai_next;
|
||||
if (ai->ai_canonname)
|
||||
free(ai->ai_canonname);
|
||||
/* no need to free(ai->ai_addr) */
|
||||
free(ai);
|
||||
} while ((ai = next) != NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
str_isnumber(p)
|
||||
const char *p;
|
||||
{
|
||||
char *q = (char *)p;
|
||||
while (*q) {
|
||||
if (! isdigit(*q))
|
||||
return NO;
|
||||
q++;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
int
|
||||
getaddrinfo(hostname, servname, hints, res)
|
||||
const char *hostname, *servname;
|
||||
const struct addrinfo *hints;
|
||||
struct addrinfo **res;
|
||||
{
|
||||
struct addrinfo sentinel;
|
||||
struct addrinfo *top = NULL;
|
||||
struct addrinfo *cur;
|
||||
int i, error = 0;
|
||||
char pton[PTON_MAX];
|
||||
struct addrinfo ai;
|
||||
struct addrinfo *pai;
|
||||
u_short port;
|
||||
|
||||
/* initialize file static vars */
|
||||
sentinel.ai_next = NULL;
|
||||
cur = &sentinel;
|
||||
pai = &ai;
|
||||
pai->ai_flags = 0;
|
||||
pai->ai_family = PF_UNSPEC;
|
||||
pai->ai_socktype = ANY;
|
||||
pai->ai_protocol = ANY;
|
||||
pai->ai_addrlen = 0;
|
||||
pai->ai_canonname = NULL;
|
||||
pai->ai_addr = NULL;
|
||||
pai->ai_next = NULL;
|
||||
port = ANY;
|
||||
|
||||
if (hostname == NULL && servname == NULL)
|
||||
return EAI_NONAME;
|
||||
if (hints) {
|
||||
/* error check for hints */
|
||||
if (hints->ai_addrlen || hints->ai_canonname ||
|
||||
hints->ai_addr || hints->ai_next)
|
||||
ERR(EAI_BADHINTS); /* xxx */
|
||||
if (hints->ai_flags & ~AI_MASK)
|
||||
ERR(EAI_BADFLAGS);
|
||||
switch (hints->ai_family) {
|
||||
case PF_UNSPEC:
|
||||
case PF_INET:
|
||||
#ifdef INET6
|
||||
case PF_INET6:
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
ERR(EAI_FAMILY);
|
||||
}
|
||||
memcpy(pai, hints, sizeof(*pai));
|
||||
switch (pai->ai_socktype) {
|
||||
case ANY:
|
||||
switch (pai->ai_protocol) {
|
||||
case ANY:
|
||||
break;
|
||||
case IPPROTO_UDP:
|
||||
pai->ai_socktype = SOCK_DGRAM;
|
||||
break;
|
||||
case IPPROTO_TCP:
|
||||
pai->ai_socktype = SOCK_STREAM;
|
||||
break;
|
||||
default:
|
||||
pai->ai_socktype = SOCK_RAW;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SOCK_RAW:
|
||||
break;
|
||||
case SOCK_DGRAM:
|
||||
if (pai->ai_protocol != IPPROTO_UDP &&
|
||||
pai->ai_protocol != ANY)
|
||||
ERR(EAI_BADHINTS); /*xxx*/
|
||||
pai->ai_protocol = IPPROTO_UDP;
|
||||
break;
|
||||
case SOCK_STREAM:
|
||||
if (pai->ai_protocol != IPPROTO_TCP &&
|
||||
pai->ai_protocol != ANY)
|
||||
ERR(EAI_BADHINTS); /*xxx*/
|
||||
pai->ai_protocol = IPPROTO_TCP;
|
||||
break;
|
||||
default:
|
||||
ERR(EAI_SOCKTYPE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* service port
|
||||
*/
|
||||
if (servname) {
|
||||
if (str_isnumber(servname)) {
|
||||
if (pai->ai_socktype == ANY) {
|
||||
/* caller accept *ANY* socktype */
|
||||
pai->ai_socktype = SOCK_DGRAM;
|
||||
pai->ai_protocol = IPPROTO_UDP;
|
||||
}
|
||||
port = htons(atoi(servname));
|
||||
} else {
|
||||
struct servent *sp;
|
||||
char *proto;
|
||||
|
||||
proto = NULL;
|
||||
switch (pai->ai_socktype) {
|
||||
case ANY:
|
||||
proto = NULL;
|
||||
break;
|
||||
case SOCK_DGRAM:
|
||||
proto = "udp";
|
||||
break;
|
||||
case SOCK_STREAM:
|
||||
proto = "tcp";
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "panic!\n");
|
||||
break;
|
||||
}
|
||||
if ((sp = getservbyname(servname, proto)) == NULL)
|
||||
ERR(EAI_SERVICE);
|
||||
port = sp->s_port;
|
||||
if (pai->ai_socktype == ANY) {
|
||||
if (strcmp(sp->s_proto, "udp") == 0) {
|
||||
pai->ai_socktype = SOCK_DGRAM;
|
||||
pai->ai_protocol = IPPROTO_UDP;
|
||||
} else if (strcmp(sp->s_proto, "tcp") == 0) {
|
||||
pai->ai_socktype = SOCK_STREAM;
|
||||
pai->ai_protocol = IPPROTO_TCP;
|
||||
} else
|
||||
ERR(EAI_PROTOCOL); /*xxx*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* hostname == NULL.
|
||||
* passive socket -> anyaddr (0.0.0.0 or ::)
|
||||
* non-passive socket -> localhost (127.0.0.1 or ::1)
|
||||
*/
|
||||
if (hostname == NULL) {
|
||||
struct afd *afd;
|
||||
int s;
|
||||
|
||||
for (afd = &afdl[0]; afd->a_af; afd++) {
|
||||
if (!(pai->ai_family == PF_UNSPEC
|
||||
|| pai->ai_family == afd->a_af)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* filter out AFs that are not supported by the kernel
|
||||
* XXX errno?
|
||||
*/
|
||||
s = socket(afd->a_af, SOCK_DGRAM, 0);
|
||||
if (s < 0)
|
||||
continue;
|
||||
close(s);
|
||||
|
||||
if (pai->ai_flags & AI_PASSIVE) {
|
||||
GET_AI(cur->ai_next, afd, afd->a_addrany, port);
|
||||
/* xxx meaningless?
|
||||
* GET_CANONNAME(cur->ai_next, "anyaddr");
|
||||
*/
|
||||
} else {
|
||||
GET_AI(cur->ai_next, afd, afd->a_loopback,
|
||||
port);
|
||||
/* xxx meaningless?
|
||||
* GET_CANONNAME(cur->ai_next, "localhost");
|
||||
*/
|
||||
}
|
||||
cur = cur->ai_next;
|
||||
}
|
||||
top = sentinel.ai_next;
|
||||
if (top)
|
||||
goto good;
|
||||
else
|
||||
ERR(EAI_FAMILY);
|
||||
}
|
||||
|
||||
/* hostname as numeric name */
|
||||
for (i = 0; afdl[i].a_af; i++) {
|
||||
if (inet_pton(afdl[i].a_af, hostname, pton) == 1) {
|
||||
u_long v4a;
|
||||
u_char pfx;
|
||||
|
||||
switch (afdl[i].a_af) {
|
||||
case AF_INET:
|
||||
v4a = ntohl(((struct in_addr *)pton)->s_addr);
|
||||
if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
|
||||
pai->ai_flags &= ~AI_CANONNAME;
|
||||
v4a >>= IN_CLASSA_NSHIFT;
|
||||
if (v4a == 0 || v4a == IN_LOOPBACKNET)
|
||||
pai->ai_flags &= ~AI_CANONNAME;
|
||||
break;
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
pfx = ((struct in6_addr *)pton)->s6_addr[0];
|
||||
if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
|
||||
pai->ai_flags &= ~AI_CANONNAME;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (pai->ai_family == afdl[i].a_af ||
|
||||
pai->ai_family == PF_UNSPEC) {
|
||||
if (! (pai->ai_flags & AI_CANONNAME)) {
|
||||
GET_AI(top, &afdl[i], pton, port);
|
||||
goto good;
|
||||
}
|
||||
/*
|
||||
* if AI_CANONNAME and if reverse lookup
|
||||
* fail, return ai anyway to pacify
|
||||
* calling application.
|
||||
*
|
||||
* XXX getaddrinfo() is a name->address
|
||||
* translation function, and it looks strange
|
||||
* that we do addr->name translation here.
|
||||
*/
|
||||
get_name(pton, &afdl[i], &top, pton, pai, port);
|
||||
goto good;
|
||||
} else
|
||||
ERR(EAI_FAMILY); /*xxx*/
|
||||
}
|
||||
}
|
||||
|
||||
if (pai->ai_flags & AI_NUMERICHOST)
|
||||
ERR(EAI_NONAME);
|
||||
|
||||
/* hostname as alphabetical name */
|
||||
error = get_addr(hostname, pai->ai_family, &top, pai, port);
|
||||
if (error == 0) {
|
||||
if (top) {
|
||||
good:
|
||||
*res = top;
|
||||
return SUCCESS;
|
||||
} else
|
||||
error = EAI_FAIL;
|
||||
}
|
||||
free:
|
||||
if (top)
|
||||
freeaddrinfo(top);
|
||||
bad:
|
||||
*res = NULL;
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
get_name(addr, afd, res, numaddr, pai, port0)
|
||||
const char *addr;
|
||||
struct afd *afd;
|
||||
struct addrinfo **res;
|
||||
char *numaddr;
|
||||
struct addrinfo *pai;
|
||||
int port0;
|
||||
{
|
||||
u_short port = port0 & 0xffff;
|
||||
struct hostent *hp;
|
||||
struct addrinfo *cur;
|
||||
int error = 0;
|
||||
hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
|
||||
if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
|
||||
GET_AI(cur, afd, hp->h_addr_list[0], port);
|
||||
GET_CANONNAME(cur, hp->h_name);
|
||||
} else
|
||||
GET_AI(cur, afd, numaddr, port);
|
||||
|
||||
*res = cur;
|
||||
return SUCCESS;
|
||||
free:
|
||||
if (cur)
|
||||
freeaddrinfo(cur);
|
||||
|
||||
/* bad: */
|
||||
*res = NULL;
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
get_addr(hostname, af, res0, pai, port0)
|
||||
const char *hostname;
|
||||
int af;
|
||||
struct addrinfo **res0;
|
||||
struct addrinfo *pai;
|
||||
int port0;
|
||||
{
|
||||
int i, error, ekeep;
|
||||
struct addrinfo *cur;
|
||||
struct addrinfo **res;
|
||||
int retry;
|
||||
int s;
|
||||
|
||||
res = res0;
|
||||
ekeep = 0;
|
||||
error = 0;
|
||||
for (i = 0; afdl[i].a_af; i++) {
|
||||
retry = 0;
|
||||
if (af == AF_UNSPEC) {
|
||||
/*
|
||||
* filter out AFs that are not supported by the kernel
|
||||
* XXX errno?
|
||||
*/
|
||||
s = socket(afdl[i].a_af, SOCK_DGRAM, 0);
|
||||
if (s < 0)
|
||||
continue;
|
||||
close(s);
|
||||
} else {
|
||||
if (af != afdl[i].a_af)
|
||||
continue;
|
||||
}
|
||||
/* It is WRONG, we need getipnodebyname(). */
|
||||
again:
|
||||
error = get_addr0(hostname, afdl[i].a_af, res, pai, port0);
|
||||
switch (error) {
|
||||
case EAI_AGAIN:
|
||||
if (++retry < 3)
|
||||
goto again;
|
||||
/* FALL THROUGH*/
|
||||
default:
|
||||
if (ekeep == 0)
|
||||
ekeep = error;
|
||||
break;
|
||||
}
|
||||
if (*res) {
|
||||
/* make chain of addrs */
|
||||
for (cur = *res;
|
||||
cur && cur->ai_next;
|
||||
cur = cur->ai_next)
|
||||
;
|
||||
if (!cur)
|
||||
return EAI_FAIL;
|
||||
res = &cur->ai_next;
|
||||
}
|
||||
}
|
||||
|
||||
/* if we got something, it's okay */
|
||||
if (*res0)
|
||||
return 0;
|
||||
|
||||
return error ? error : ekeep;
|
||||
}
|
||||
|
||||
static int
|
||||
get_addr0(hostname, af, res, pai, port0)
|
||||
const char *hostname;
|
||||
int af;
|
||||
struct addrinfo **res;
|
||||
struct addrinfo *pai;
|
||||
int port0;
|
||||
{
|
||||
u_short port = port0 & 0xffff;
|
||||
struct addrinfo sentinel;
|
||||
struct hostent *hp;
|
||||
struct addrinfo *top, *cur;
|
||||
struct afd *afd;
|
||||
int i, error = 0, h_error;
|
||||
char *ap;
|
||||
|
||||
top = NULL;
|
||||
sentinel.ai_next = NULL;
|
||||
cur = &sentinel;
|
||||
|
||||
#ifdef HAVE_GETHOSTBYNAME2
|
||||
if (af == AF_UNSPEC) {
|
||||
error = EAI_FAIL;
|
||||
goto bad;
|
||||
}
|
||||
hp = gethostbyname2(hostname, af);
|
||||
#else
|
||||
if (af != AF_UNSPEC && af != AF_INET) {
|
||||
error = EAI_FAIL;
|
||||
goto bad;
|
||||
}
|
||||
hp = gethostbyname(hostname);
|
||||
#endif
|
||||
h_error = h_errno;
|
||||
|
||||
if (hp == NULL) {
|
||||
switch (h_error) {
|
||||
case HOST_NOT_FOUND:
|
||||
case NO_DATA:
|
||||
error = EAI_NODATA;
|
||||
break;
|
||||
case TRY_AGAIN:
|
||||
error = EAI_AGAIN;
|
||||
break;
|
||||
case NO_RECOVERY:
|
||||
case NETDB_INTERNAL:
|
||||
default:
|
||||
error = EAI_FAIL;
|
||||
break;
|
||||
}
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if ((hp->h_name == NULL) || (hp->h_name[0] == 0) ||
|
||||
(hp->h_addr_list[0] == NULL))
|
||||
ERR(EAI_FAIL);
|
||||
|
||||
for (i = 0; (ap = hp->h_addr_list[i]) != NULL; i++) {
|
||||
switch (af) {
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
afd = &afdl[N_INET6];
|
||||
break;
|
||||
#endif
|
||||
#ifndef INET6
|
||||
default: /* AF_UNSPEC */
|
||||
#endif
|
||||
case AF_INET:
|
||||
afd = &afdl[N_INET];
|
||||
break;
|
||||
#ifdef INET6
|
||||
default: /* AF_UNSPEC */
|
||||
if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) {
|
||||
ap += sizeof(struct in6_addr) -
|
||||
sizeof(struct in_addr);
|
||||
afd = &afdl[N_INET];
|
||||
} else
|
||||
afd = &afdl[N_INET6];
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
GET_AI(cur->ai_next, afd, ap, port);
|
||||
if (cur == &sentinel) {
|
||||
top = cur->ai_next;
|
||||
GET_CANONNAME(top, hp->h_name);
|
||||
}
|
||||
cur = cur->ai_next;
|
||||
}
|
||||
*res = top;
|
||||
return SUCCESS;
|
||||
free:
|
||||
if (top)
|
||||
freeaddrinfo(top);
|
||||
bad:
|
||||
*res = NULL;
|
||||
return error;
|
||||
}
|
||||
|
|
@ -1,226 +0,0 @@
|
|||
/*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Issues to be discussed:
|
||||
* - Thread safe-ness must be checked
|
||||
* - Return values. There seems to be no standard for return value (RFC2553)
|
||||
* but INRIA implementation returns EAI_xxx defined for getaddrinfo().
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "addrinfo.h"
|
||||
|
||||
#define SUCCESS 0
|
||||
#define ANY 0
|
||||
#define YES 1
|
||||
#define NO 0
|
||||
|
||||
static struct afd {
|
||||
int a_af;
|
||||
int a_addrlen;
|
||||
int a_socklen;
|
||||
int a_off;
|
||||
} afdl [] = {
|
||||
#ifdef INET6
|
||||
{PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
|
||||
offsetof(struct sockaddr_in6, sin6_addr)},
|
||||
#endif
|
||||
{PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
|
||||
offsetof(struct sockaddr_in, sin_addr)},
|
||||
{0, 0, 0},
|
||||
};
|
||||
|
||||
struct sockinet {
|
||||
u_char si_len;
|
||||
u_char si_family;
|
||||
u_short si_port;
|
||||
};
|
||||
|
||||
#define ENI_NOSOCKET 0
|
||||
#define ENI_NOSERVNAME 1
|
||||
#define ENI_NOHOSTNAME 2
|
||||
#define ENI_MEMORY 3
|
||||
#define ENI_SYSTEM 4
|
||||
#define ENI_FAMILY 5
|
||||
#define ENI_SALEN 6
|
||||
|
||||
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;
|
||||
int family, len, i;
|
||||
char *addr, *p;
|
||||
u_long v4a;
|
||||
int h_error;
|
||||
char numserv[512];
|
||||
char numaddr[512];
|
||||
|
||||
if (sa == NULL)
|
||||
return ENI_NOSOCKET;
|
||||
|
||||
#ifdef HAVE_SA_LEN
|
||||
len = sa->sa_len;
|
||||
if (len != salen) return ENI_SALEN;
|
||||
#else
|
||||
len = salen;
|
||||
#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 ENI_FAMILY;
|
||||
|
||||
found:
|
||||
if (len != afd->a_socklen) return ENI_SALEN;
|
||||
|
||||
port = ((struct sockinet *)sa)->si_port; /* network byte order */
|
||||
addr = (char *)sa + afd->a_off;
|
||||
|
||||
if (serv == NULL || servlen == 0) {
|
||||
/* what we should do? */
|
||||
} else if (flags & NI_NUMERICSERV) {
|
||||
snprintf(numserv, sizeof(numserv), "%d", ntohs(port));
|
||||
if (strlen(numserv) > servlen)
|
||||
return ENI_MEMORY;
|
||||
strcpy(serv, numserv);
|
||||
} else {
|
||||
sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp");
|
||||
if (sp) {
|
||||
if (strlen(sp->s_name) > servlen)
|
||||
return ENI_MEMORY;
|
||||
strcpy(serv, sp->s_name);
|
||||
} else
|
||||
return ENI_NOSERVNAME;
|
||||
}
|
||||
|
||||
switch (sa->sa_family) {
|
||||
case AF_INET:
|
||||
v4a = ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
|
||||
if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
|
||||
flags |= NI_NUMERICHOST;
|
||||
v4a >>= IN_CLASSA_NSHIFT;
|
||||
if (v4a == 0 || v4a == IN_LOOPBACKNET)
|
||||
flags |= NI_NUMERICHOST;
|
||||
break;
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
{
|
||||
struct sockaddr_in6 *sin6;
|
||||
sin6 = (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;
|
||||
#endif
|
||||
}
|
||||
if (host == NULL || hostlen == 0) {
|
||||
/* what should we do? */
|
||||
} else if (flags & NI_NUMERICHOST) {
|
||||
/* NUMERICHOST and NAMEREQD conflicts with each other */
|
||||
if (flags & NI_NAMEREQD)
|
||||
return ENI_NOHOSTNAME;
|
||||
if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
|
||||
== NULL)
|
||||
return ENI_SYSTEM;
|
||||
if (strlen(numaddr) > hostlen)
|
||||
return ENI_MEMORY;
|
||||
strcpy(host, numaddr);
|
||||
} else {
|
||||
#ifdef USE_GETIPNODEBY
|
||||
hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
|
||||
#else
|
||||
hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
|
||||
h_error = h_errno;
|
||||
#endif
|
||||
|
||||
if (hp) {
|
||||
if (flags & NI_NOFQDN) {
|
||||
p = strchr(hp->h_name, '.');
|
||||
if (p) *p = '\0';
|
||||
}
|
||||
if (strlen(hp->h_name) > hostlen) {
|
||||
#ifdef USE_GETIPNODEBY
|
||||
freehostent(hp);
|
||||
#endif
|
||||
return ENI_MEMORY;
|
||||
}
|
||||
strcpy(host, hp->h_name);
|
||||
#ifdef USE_GETIPNODEBY
|
||||
freehostent(hp);
|
||||
#endif
|
||||
} else {
|
||||
if (flags & NI_NAMEREQD)
|
||||
return ENI_NOHOSTNAME;
|
||||
if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
|
||||
== NULL)
|
||||
return ENI_NOHOSTNAME;
|
||||
if (strlen(numaddr) > hostlen)
|
||||
return ENI_MEMORY;
|
||||
strcpy(host, numaddr);
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
|
@ -41,9 +41,6 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#ifndef HAVE_GETADDRINFO
|
||||
#include "missing/addrinfo.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -1387,7 +1384,7 @@ parse_query(char *input, char *qname, unsigned int qnlen, int *qtype) {
|
|||
|
||||
/*
|
||||
* dispatch_query:
|
||||
* Send the query packet for the entry
|
||||
* Send the query packet for the entry
|
||||
*
|
||||
* Return -1 on failure
|
||||
* Return a non-negative integer otherwise
|
||||
|
|
@ -1422,7 +1419,7 @@ dispatch_query(unsigned short int id, char *dom, int qt, u_char **pktp,
|
|||
*p++ = 0; /* root name */
|
||||
*p++ = 0;
|
||||
*p++ = 41; /* OPT */
|
||||
*p++ = 16;
|
||||
*p++ = 16;
|
||||
*p++ = 0; /* UDP payload size (4K) */
|
||||
*p++ = 0; /* extended rcode */
|
||||
*p++ = 0; /* version */
|
||||
|
|
@ -1934,7 +1931,7 @@ print_statistics(int intermediate, unsigned int sent, unsigned int timed_out,
|
|||
unsigned int roverflows, unsigned int *rarray)
|
||||
{
|
||||
unsigned int num_queries_completed;
|
||||
double per_lost, per_completed, per_lost2, per_completed2;
|
||||
double per_lost, per_completed, per_lost2, per_completed2;
|
||||
double run_time, queries_per_sec, queries_per_sec2;
|
||||
double queries_per_sec_total;
|
||||
double rtt_average, rtt_stddev;
|
||||
|
|
@ -2074,7 +2071,7 @@ print_statistics(int intermediate, unsigned int sent, unsigned int timed_out,
|
|||
}
|
||||
if (target_qps > 0) {
|
||||
printf(" Total QPS/target: %.6lf/%d qps\n",
|
||||
queries_per_sec_total, target_qps);
|
||||
queries_per_sec_total, target_qps);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
|
|
|||
|
|
@ -269,6 +269,13 @@
|
|||
BIND 8 when processing an IXFR stream. 'no-change' deltas
|
||||
will now trigger a fallback to AXFR as the recovery mechanism.
|
||||
</para>
|
||||
<para>
|
||||
BIND 9 will no longer build on platforms that doesn't have
|
||||
proper IPv6 support. BIND 9 now also requires non-broken
|
||||
POSIX-compatible pthread support. Such platforms are
|
||||
usually long after their end-of-life date and they are
|
||||
neither developed nor supported by their respective vendors.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ The sources are checked out, and the web reports are generated,
|
|||
on bb, as driven by the following cron jobs:
|
||||
|
||||
# Check out the current bind 9 version and make the source tarball.
|
||||
# Argument to maketar.sh should be v9_0 for 9.0 release branch,
|
||||
# Argument to maketar.sh should be v9_0 for 9.0 release branch,
|
||||
# HEAD for mainline.
|
||||
35 2-22 * * * PLATFORM=BSD-3.1 && . $HOME/b9t/hosts/$PLATFORM/env && \
|
||||
nice sh $HOME/b9t/bin/maketar.sh HEAD \
|
||||
|
|
@ -57,7 +57,6 @@ The current test schedule is as follows:
|
|||
:00 Most tests begin
|
||||
:45 Status report generator runs (was :30)
|
||||
|
||||
aix: I can't seem to access that machine; it appears to be down.
|
||||
bb: Build starts at top of hour, 0300 to 2200
|
||||
durango: Build starts at top of hour, 0300 to 2200
|
||||
trantor: Build starts at top of hour, 0300 to 2100, odd-numbered hours
|
||||
|
|
|
|||
|
|
@ -17,11 +17,6 @@ socket API to be usable. The systems which do not follow this will
|
|||
currently not get any warnings or errors, but ipv6 will simply not
|
||||
function on them.
|
||||
|
||||
These systems currently include, but are not limited to:
|
||||
|
||||
AIX 3.4 (with ipv6 patches)
|
||||
|
||||
|
||||
RUN-TIME ISSUES
|
||||
---------------
|
||||
|
||||
|
|
@ -108,4 +103,3 @@ RELEVANT RFCs
|
|||
3493: Basic Socket Interface Extensions for IPv6
|
||||
|
||||
3542: Advanced Sockets Application Program Interface (API) for IPv6
|
||||
|
||||
|
|
|
|||
|
|
@ -28,20 +28,6 @@
|
|||
|
||||
#include <bind9/getaddresses.h>
|
||||
|
||||
#ifdef HAVE_ADDRINFO
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
#ifdef HAVE_GAISTRERROR
|
||||
#define USE_GETADDRINFO
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef USE_GETADDRINFO
|
||||
#ifndef ISC_PLATFORM_NONSTDHERRNO
|
||||
extern int h_errno;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
isc_result_t
|
||||
bind9_getaddresses(const char *hostname, in_port_t port,
|
||||
isc_sockaddr_t *addrs, int addrsize, int *addrcount)
|
||||
|
|
@ -51,12 +37,8 @@ bind9_getaddresses(const char *hostname, in_port_t port,
|
|||
bool have_ipv4, have_ipv6;
|
||||
int i;
|
||||
|
||||
#ifdef USE_GETADDRINFO
|
||||
struct addrinfo *ai = NULL, *tmpai, hints;
|
||||
int result;
|
||||
#else
|
||||
struct hostent *he;
|
||||
#endif
|
||||
|
||||
REQUIRE(hostname != NULL);
|
||||
REQUIRE(addrs != NULL);
|
||||
|
|
@ -98,7 +80,6 @@ bind9_getaddresses(const char *hostname, in_port_t port,
|
|||
return (ISC_R_FAMILYNOSUPPORT);
|
||||
|
||||
if (d != NULL) {
|
||||
#ifdef ISC_PLATFORM_HAVESCOPEID
|
||||
isc_result_t iresult;
|
||||
|
||||
iresult = isc_netscope_pton(AF_INET6, d + 1,
|
||||
|
|
@ -106,15 +87,6 @@ bind9_getaddresses(const char *hostname, in_port_t port,
|
|||
|
||||
if (iresult != ISC_R_SUCCESS)
|
||||
return (iresult);
|
||||
#else
|
||||
/*
|
||||
* The extended format is specified while the
|
||||
* system does not provide the ability to use
|
||||
* it. Throw an explicit error instead of
|
||||
* ignoring the specified value.
|
||||
*/
|
||||
return (ISC_R_BADADDRESSFORM);
|
||||
#endif
|
||||
}
|
||||
|
||||
isc_netaddr_fromin6(&na, &in6);
|
||||
|
|
@ -127,7 +99,6 @@ bind9_getaddresses(const char *hostname, in_port_t port,
|
|||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
}
|
||||
#ifdef USE_GETADDRINFO
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
if (!have_ipv6)
|
||||
hints.ai_family = PF_INET;
|
||||
|
|
@ -185,41 +156,6 @@ bind9_getaddresses(const char *hostname, in_port_t port,
|
|||
}
|
||||
freeaddrinfo(ai);
|
||||
*addrcount = i;
|
||||
#else
|
||||
he = gethostbyname(hostname);
|
||||
if (he == NULL) {
|
||||
switch (h_errno) {
|
||||
case HOST_NOT_FOUND:
|
||||
#ifdef NO_DATA
|
||||
case NO_DATA:
|
||||
#endif
|
||||
#if defined(NO_ADDRESS) && (!defined(NO_DATA) || (NO_DATA != NO_ADDRESS))
|
||||
case NO_ADDRESS:
|
||||
#endif
|
||||
return (ISC_R_NOTFOUND);
|
||||
default:
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
}
|
||||
if (he->h_addrtype != AF_INET && he->h_addrtype != AF_INET6)
|
||||
return (ISC_R_NOTFOUND);
|
||||
for (i = 0; i < addrsize; i++) {
|
||||
if (he->h_addrtype == AF_INET) {
|
||||
struct in_addr *inp;
|
||||
inp = (struct in_addr *)(he->h_addr_list[i]);
|
||||
if (inp == NULL)
|
||||
break;
|
||||
isc_sockaddr_fromin(&addrs[i], inp, port);
|
||||
} else {
|
||||
struct in6_addr *in6p;
|
||||
in6p = (struct in6_addr *)(he->h_addr_list[i]);
|
||||
if (in6p == NULL)
|
||||
break;
|
||||
isc_sockaddr_fromin6(&addrs[i], in6p, port);
|
||||
}
|
||||
}
|
||||
*addrcount = i;
|
||||
#endif
|
||||
if (*addrcount == 0)
|
||||
return (ISC_R_NOTFOUND);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
#ifdef USE_DNSRPS
|
||||
|
||||
#include <isc/mem.h>
|
||||
#include <isc/stdlib.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -784,7 +784,7 @@ dns_dnssec_findzonekeys(dns_db_t *db, dns_dbversion_t *ver,
|
|||
isc_result_t result2;
|
||||
isc_buffer_t buf;
|
||||
|
||||
isc_buffer_init(&buf, filename, ISC_DIR_NAMEMAX);
|
||||
isc_buffer_init(&buf, filename, NAME_MAX);
|
||||
result2 = dst_key_getfilename(dst_key_name(pubkey),
|
||||
dst_key_id(pubkey),
|
||||
dst_key_alg(pubkey),
|
||||
|
|
@ -1676,7 +1676,7 @@ dns_dnssec_keylistfromrdataset(const dns_name_t *origin,
|
|||
isc_result_t result2;
|
||||
isc_buffer_t buf;
|
||||
|
||||
isc_buffer_init(&buf, filename, ISC_DIR_NAMEMAX);
|
||||
isc_buffer_init(&buf, filename, NAME_MAX);
|
||||
result2 = dst_key_getfilename(dst_key_name(pubkey),
|
||||
dst_key_id(pubkey),
|
||||
dst_key_alg(pubkey),
|
||||
|
|
|
|||
|
|
@ -484,7 +484,7 @@ dst_key_fromfile(dns_name_t *name, dns_keytag_t id,
|
|||
isc_mem_t *mctx, dst_key_t **keyp)
|
||||
{
|
||||
isc_result_t result;
|
||||
char filename[ISC_DIR_NAMEMAX];
|
||||
char filename[NAME_MAX];
|
||||
isc_buffer_t buf;
|
||||
dst_key_t *key;
|
||||
|
||||
|
|
@ -498,7 +498,7 @@ dst_key_fromfile(dns_name_t *name, dns_keytag_t id,
|
|||
|
||||
key = NULL;
|
||||
|
||||
isc_buffer_init(&buf, filename, ISC_DIR_NAMEMAX);
|
||||
isc_buffer_init(&buf, filename, NAME_MAX);
|
||||
result = dst_key_getfilename(name, id, alg, type, NULL, mctx, &buf);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
|
|
@ -1605,7 +1605,7 @@ write_public_key(const dst_key_t *key, int type, const char *directory) {
|
|||
FILE *fp;
|
||||
isc_buffer_t keyb, textb, fileb, classb;
|
||||
isc_region_t r;
|
||||
char filename[ISC_DIR_NAMEMAX];
|
||||
char filename[NAME_MAX];
|
||||
unsigned char key_array[DST_KEY_MAXSIZE];
|
||||
char text_array[DST_KEY_MAXTEXTSIZE];
|
||||
char class_array[10];
|
||||
|
|
|
|||
|
|
@ -624,7 +624,7 @@ dst__privstruct_writefile(const dst_key_t *key, const dst_private_t *priv,
|
|||
{
|
||||
FILE *fp;
|
||||
isc_result_t result;
|
||||
char filename[ISC_DIR_NAMEMAX];
|
||||
char filename[NAME_MAX];
|
||||
char buffer[MAXFIELDSIZE * 2];
|
||||
isc_fsaccess_t access;
|
||||
isc_stdtime_t when;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include <ctype.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isc/buffer.h>
|
||||
#include <isc/parseint.h>
|
||||
|
|
@ -22,7 +23,6 @@
|
|||
#include <isc/region.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/stdio.h>
|
||||
#include <isc/stdlib.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/types.h>
|
||||
#include <isc/util.h>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
#include <isc/parseint.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/stdlib.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/callbacks.h>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
#include <isc/netaddr.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/rwlock.h>
|
||||
#include <isc/stdlib.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/util.h>
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@
|
|||
#include <isc/result.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
#include <isc/strerror.h>
|
||||
|
||||
#include <dns/fixedname.h>
|
||||
#include <dns/name.h>
|
||||
|
|
@ -82,7 +81,7 @@ ux_socket_connect(const char *path) {
|
|||
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd == -1) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
ssu_e_log(3, "ssu_external: unable to create socket - %s",
|
||||
strbuf);
|
||||
return (-1);
|
||||
|
|
@ -90,7 +89,7 @@ ux_socket_connect(const char *path) {
|
|||
|
||||
if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
ssu_e_log(3, "ssu_external: unable to connect to "
|
||||
"socket '%s' - %s",
|
||||
path, strbuf);
|
||||
|
|
@ -224,7 +223,7 @@ dns_ssu_external_match(const dns_name_t *identity,
|
|||
isc_mem_free(mctx, data);
|
||||
if (ret != (ssize_t) req_len) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
ssu_e_log(3, "ssu_external: unable to send request - %s",
|
||||
strbuf);
|
||||
close(fd);
|
||||
|
|
@ -235,7 +234,7 @@ dns_ssu_external_match(const dns_name_t *identity,
|
|||
ret = read(fd, &reply, sizeof(uint32_t));
|
||||
if (ret != (ssize_t) sizeof(uint32_t)) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
ssu_e_log(3, "ssu_external: unable to receive reply - %s",
|
||||
strbuf);
|
||||
close(fd);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
#include <isc/serial.h>
|
||||
#include <isc/stats.h>
|
||||
#include <isc/stdtime.h>
|
||||
#include <isc/strerror.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/taskpool.h>
|
||||
#include <isc/thread.h>
|
||||
|
|
@ -4593,7 +4592,7 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
|
|||
"removing journal file");
|
||||
if (remove(zone->journal) < 0 && errno != ENOENT) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(dns_lctx,
|
||||
DNS_LOGCATEGORY_GENERAL,
|
||||
DNS_LOGMODULE_ZONE,
|
||||
|
|
@ -15112,7 +15111,7 @@ zone_replacedb(dns_zone_t *zone, dns_db_t *db, bool dump) {
|
|||
zone->journal);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
dns_zone_log(zone, ISC_LOG_ERROR,
|
||||
"ixfr-from-differences: failed: "
|
||||
"%s", strbuf);
|
||||
|
|
@ -15134,7 +15133,7 @@ zone_replacedb(dns_zone_t *zone, dns_db_t *db, bool dump) {
|
|||
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_FORCEXFER) &&
|
||||
remove(zone->masterfile) < 0 && errno != ENOENT) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(dns_lctx,
|
||||
DNS_LOGCATEGORY_GENERAL,
|
||||
DNS_LOGMODULE_ZONE,
|
||||
|
|
@ -15165,7 +15164,7 @@ zone_replacedb(dns_zone_t *zone, dns_db_t *db, bool dump) {
|
|||
"removing journal file");
|
||||
if (remove(zone->journal) < 0 && errno != ENOENT) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(dns_lctx,
|
||||
DNS_LOGCATEGORY_GENERAL,
|
||||
DNS_LOGMODULE_ZONE,
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ static const char *gai_messages[] = {
|
|||
* Returns an error message corresponding to an error code returned by
|
||||
* getaddrinfo() and getnameinfo()
|
||||
*/
|
||||
IRS_GAISTRERROR_RETURN_T
|
||||
const char *
|
||||
gai_strerror(int ecode) {
|
||||
union {
|
||||
const char *const_ptr;
|
||||
|
|
|
|||
|
|
@ -138,10 +138,10 @@ static struct afd {
|
|||
} while (0)
|
||||
|
||||
int
|
||||
getnameinfo(const struct sockaddr *sa, IRS_GETNAMEINFO_SOCKLEN_T salen,
|
||||
char *host, IRS_GETNAMEINFO_BUFLEN_T hostlen,
|
||||
char *serv, IRS_GETNAMEINFO_BUFLEN_T servlen,
|
||||
IRS_GETNAMEINFO_FLAGS_T flags)
|
||||
getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
||||
char *host, socklen_t hostlen,
|
||||
char *serv, socklen_t servlen,
|
||||
int flags)
|
||||
{
|
||||
struct afd *afd = NULL;
|
||||
struct servent *sp;
|
||||
|
|
|
|||
|
|
@ -17,24 +17,6 @@
|
|||
#include <stddef.h> /* Required on FreeBSD (and others?) for size_t. */
|
||||
#include <netdb.h> /* Contractual provision. */
|
||||
|
||||
/*
|
||||
* Define if <netdb.h> does not declare struct addrinfo.
|
||||
*/
|
||||
@ISC_IRS_NEEDADDRINFO@
|
||||
|
||||
#ifdef ISC_IRS_NEEDADDRINFO
|
||||
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 */
|
||||
size_t ai_addrlen; /* Length of ai_addr */
|
||||
char *ai_canonname; /* Canonical name for hostname */
|
||||
struct sockaddr *ai_addr; /* Binary address */
|
||||
struct addrinfo *ai_next; /* Next structure in linked list */
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Undefine all #defines we are interested in as <netdb.h> may or may not have
|
||||
* defined them.
|
||||
|
|
@ -187,17 +169,17 @@ getaddrinfo(const char *hostname, const char *servname,
|
|||
const struct addrinfo *hints, struct addrinfo **res);
|
||||
|
||||
int
|
||||
getnameinfo(const struct sockaddr *sa, IRS_GETNAMEINFO_SOCKLEN_T salen,
|
||||
char *host, IRS_GETNAMEINFO_BUFLEN_T hostlen,
|
||||
char *serv, IRS_GETNAMEINFO_BUFLEN_T servlen,
|
||||
IRS_GETNAMEINFO_FLAGS_T flags);
|
||||
getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
||||
char *host, socklen_t hostlen,
|
||||
char *serv, socklen_t servlen,
|
||||
int flags);
|
||||
|
||||
void freeaddrinfo (struct addrinfo *ai);
|
||||
|
||||
IRS_GAISTRERROR_RETURN_T
|
||||
const char *
|
||||
gai_strerror(int ecode);
|
||||
|
||||
#endif
|
||||
#endif /* IRS_NAMESPACE */
|
||||
|
||||
/*
|
||||
* Tell Emacs to use C mode on this file.
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@ CDEFINES =
|
|||
CWARNINGS =
|
||||
|
||||
# Alphabetically
|
||||
UNIXOBJS = @ISC_ISCIPV6_O@ unix/pk11_api.@O@ \
|
||||
UNIXOBJS = unix/pk11_api.@O@ \
|
||||
unix/app.@O@ unix/dir.@O@ unix/errno.@O@ \
|
||||
unix/errno2result.@O@ unix/file.@O@ unix/fsaccess.@O@ \
|
||||
unix/interfaceiter.@O@ unix/keyboard.@O@ unix/meminfo.@O@ \
|
||||
unix/net.@O@ unix/os.@O@ unix/resource.@O@ unix/socket.@O@ \
|
||||
unix/stdio.@O@ unix/stdtime.@O@ unix/strerror.@O@ \
|
||||
unix/stdio.@O@ unix/stdtime.@O@ \
|
||||
unix/syslog.@O@ unix/time.@O@
|
||||
|
||||
NLSOBJS = nls/msgcat.@O@
|
||||
|
|
@ -44,7 +44,7 @@ WIN32OBJS = win32/condition.@O@ win32/dir.@O@ win32/errno.@O@ \
|
|||
win32/stdtime.@O@ win32/thread.@O@ win32/time.@O@
|
||||
|
||||
# Alphabetically
|
||||
OBJS = @ISC_EXTRA_OBJS@ pk11.@O@ pk11_result.@O@ \
|
||||
OBJS = pk11.@O@ pk11_result.@O@ \
|
||||
aes.@O@ assertions.@O@ backtrace.@O@ base32.@O@ base64.@O@ \
|
||||
bind9.@O@ buffer.@O@ bufferlist.@O@ \
|
||||
commandline.@O@ counter.@O@ crc64.@O@ error.@O@ entropy.@O@ \
|
||||
|
|
@ -57,13 +57,13 @@ OBJS = @ISC_EXTRA_OBJS@ pk11.@O@ pk11_result.@O@ \
|
|||
ratelimiter.@O@ refcount.@O@ region.@O@ regex.@O@ result.@O@ \
|
||||
rwlock.@O@ \
|
||||
serial.@O@ sha1.@O@ sha2.@O@ sockaddr.@O@ stats.@O@ \
|
||||
string.@O@ strtoul.@O@ symtab.@O@ task.@O@ taskpool.@O@ \
|
||||
string.@O@ symtab.@O@ task.@O@ taskpool.@O@ \
|
||||
tm.@O@ timer.@O@ version.@O@ \
|
||||
${UNIXOBJS} ${NLSOBJS} ${THREADOBJS}
|
||||
SYMTBLOBJS = backtrace-emptytbl.@O@
|
||||
|
||||
# Alphabetically
|
||||
SRCS = @ISC_EXTRA_SRCS@ pk11.c pk11_result.c \
|
||||
SRCS = pk11.c pk11_result.c \
|
||||
aes.c assertions.c backtrace.c base32.c base64.c bind9.c \
|
||||
buffer.c bufferlist.c commandline.c counter.c crc64.c \
|
||||
entropy.c error.c event.c hash.c ht.c heap.c hex.c hmacmd5.c \
|
||||
|
|
@ -74,7 +74,7 @@ SRCS = @ISC_EXTRA_SRCS@ pk11.c pk11_result.c \
|
|||
parseint.c portset.c quota.c radix.c random.c \
|
||||
ratelimiter.c refcount.c region.c regex.c result.c rwlock.c \
|
||||
serial.c sha1.c sha2.c sockaddr.c stats.c string.c \
|
||||
strtoul.c symtab.c task.c taskpool.c timer.c \
|
||||
symtab.c task.c taskpool.c timer.c \
|
||||
tm.c version.c
|
||||
|
||||
LIBS = @OPENSSL_LIBS@ @LIBS@
|
||||
|
|
|
|||
|
|
@ -51,67 +51,7 @@
|
|||
#include <isc/platform.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
#ifdef ISC_PLATFORM_USEOSFASM
|
||||
#include <c_asm.h>
|
||||
|
||||
#pragma intrinsic(asm)
|
||||
|
||||
/*
|
||||
* This routine atomically increments the value stored in 'p' by 'val', and
|
||||
* returns the previous value. Memory access ordering around this function
|
||||
* can be critical, so we add explicit memory block instructions at the
|
||||
* beginning and the end of it (same for other functions).
|
||||
*/
|
||||
static inline int32_t
|
||||
isc_atomic_xadd(int32_t *p, int32_t val) {
|
||||
return (asm("mb;"
|
||||
"1:"
|
||||
"ldl_l %t0, 0(%a0);" /* load old value */
|
||||
"mov %t0, %v0;" /* copy the old value */
|
||||
"addl %t0, %a1, %t0;" /* calculate new value */
|
||||
"stl_c %t0, 0(%a0);" /* attempt to store */
|
||||
"beq %t0, 1b;" /* spin if failed */
|
||||
"mb;",
|
||||
p, val));
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine atomically stores the value 'val' in 'p'.
|
||||
*/
|
||||
static inline void
|
||||
isc_atomic_store(int32_t *p, int32_t val) {
|
||||
(void)asm("mb;"
|
||||
"1:"
|
||||
"ldl_l %t0, 0(%a0);" /* load old value */
|
||||
"mov %a1, %t0;" /* value to store */
|
||||
"stl_c %t0, 0(%a0);" /* attempt to store */
|
||||
"beq %t0, 1b;" /* spin if failed */
|
||||
"mb;",
|
||||
p, val);
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine atomically replaces the value in 'p' with 'val', if the
|
||||
* original value is equal to 'cmpval'. The original value is returned in any
|
||||
* case.
|
||||
*/
|
||||
static inline int32_t
|
||||
isc_atomic_cmpxchg(int32_t *p, int32_t cmpval, int32_t val) {
|
||||
|
||||
return(asm("mb;"
|
||||
"1:"
|
||||
"ldl_l %t0, 0(%a0);" /* load old value */
|
||||
"mov %t0, %v0;" /* copy the old value */
|
||||
"cmpeq %t0, %a1, %t0;" /* compare */
|
||||
"beq %t0, 2f;" /* exit if not equal */
|
||||
"mov %a2, %t0;" /* value to store */
|
||||
"stl_c %t0, 0(%a0);" /* attempt to store */
|
||||
"beq %t0, 1b;" /* if it failed, spin */
|
||||
"2:"
|
||||
"mb;",
|
||||
p, cmpval, val));
|
||||
}
|
||||
#elif defined (ISC_PLATFORM_USEGCCASM)
|
||||
#if defined (ISC_PLATFORM_USEGCCASM)
|
||||
static inline int32_t
|
||||
isc_atomic_xadd(int32_t *p, int32_t val) {
|
||||
int32_t temp, prev;
|
||||
|
|
|
|||
|
|
@ -1,134 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
#ifndef ISC_IPV6_H
|
||||
#define ISC_IPV6_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/ipv6.h
|
||||
* \brief IPv6 definitions for systems which do not support IPv6.
|
||||
*
|
||||
* \li MP:
|
||||
* No impact.
|
||||
*
|
||||
* \li Reliability:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Resources:
|
||||
* N/A.
|
||||
*
|
||||
* \li Security:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Standards:
|
||||
* RFC2553.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports.
|
||||
***/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <isc/platform.h>
|
||||
|
||||
/***
|
||||
*** Types.
|
||||
***/
|
||||
|
||||
struct in6_addr {
|
||||
union {
|
||||
uint8_t _S6_u8[16];
|
||||
uint16_t _S6_u16[8];
|
||||
uint32_t _S6_u32[4];
|
||||
} _S6_un;
|
||||
};
|
||||
#define s6_addr _S6_un._S6_u8
|
||||
#define s6_addr8 _S6_un._S6_u8
|
||||
#define s6_addr16 _S6_un._S6_u16
|
||||
#define s6_addr32 _S6_un._S6_u32
|
||||
|
||||
#define IN6ADDR_ANY_INIT {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }}}
|
||||
#define IN6ADDR_LOOPBACK_INIT {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }}}
|
||||
|
||||
LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_any;
|
||||
LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_loopback;
|
||||
|
||||
struct sockaddr_in6 {
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
uint8_t sin6_len;
|
||||
uint8_t sin6_family;
|
||||
#else
|
||||
uint16_t sin6_family;
|
||||
#endif
|
||||
uint16_t sin6_port;
|
||||
uint32_t sin6_flowinfo;
|
||||
struct in6_addr sin6_addr;
|
||||
uint32_t sin6_scope_id;
|
||||
};
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
#define SIN6_LEN 1
|
||||
#endif
|
||||
|
||||
/*%
|
||||
* Unspecified
|
||||
*/
|
||||
#define IN6_IS_ADDR_UNSPECIFIED(a) \
|
||||
(((a)->s6_addr32[0] == 0) && \
|
||||
((a)->s6_addr32[1] == 0) && \
|
||||
((a)->s6_addr32[2] == 0) && \
|
||||
((a)->s6_addr32[3] == 0))
|
||||
|
||||
/*%
|
||||
* Loopback
|
||||
*/
|
||||
#define IN6_IS_ADDR_LOOPBACK(a) \
|
||||
(((a)->s6_addr32[0] == 0) && \
|
||||
((a)->s6_addr32[1] == 0) && \
|
||||
((a)->s6_addr32[2] == 0) && \
|
||||
((a)->s6_addr32[3] == htonl(1)))
|
||||
|
||||
/*%
|
||||
* IPv4 compatible
|
||||
*/
|
||||
#define IN6_IS_ADDR_V4COMPAT(a) \
|
||||
(((a)->s6_addr32[0] == 0) && \
|
||||
((a)->s6_addr32[1] == 0) && \
|
||||
((a)->s6_addr32[2] == 0) && \
|
||||
((a)->s6_addr32[3] != 0) && \
|
||||
((a)->s6_addr32[3] != htonl(1)))
|
||||
|
||||
/*%
|
||||
* Mapped
|
||||
*/
|
||||
#define IN6_IS_ADDR_V4MAPPED(a) \
|
||||
(((a)->s6_addr32[0] == 0) && \
|
||||
((a)->s6_addr32[1] == 0) && \
|
||||
((a)->s6_addr32[2] == htonl(0x0000ffff)))
|
||||
|
||||
/*%
|
||||
* Multicast
|
||||
*/
|
||||
#define IN6_IS_ADDR_MULTICAST(a) \
|
||||
((a)->s6_addr8[0] == 0xffU)
|
||||
|
||||
/*%
|
||||
* Unicast link / site local.
|
||||
*/
|
||||
#define IN6_IS_ADDR_LINKLOCAL(a) \
|
||||
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
|
||||
#define IN6_IS_ADDR_SITELOCAL(a) \
|
||||
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
|
||||
|
||||
#endif /* ISC_IPV6_H */
|
||||
|
|
@ -27,76 +27,14 @@
|
|||
#endif
|
||||
|
||||
/***
|
||||
*** Network.
|
||||
*** Default strerror_r buffer size
|
||||
***/
|
||||
|
||||
/*! \brief
|
||||
* Define if this system needs the <netinet/in6.h> header file included
|
||||
* for full IPv6 support (pretty much only UnixWare).
|
||||
*/
|
||||
@ISC_PLATFORM_NEEDNETINETIN6H@
|
||||
#define ISC_STRERRORSIZE 128
|
||||
|
||||
/*! \brief
|
||||
* Define if this system needs the <netinet6/in6.h> header file included
|
||||
* to support in6_pkinfo (pretty much only BSD/OS).
|
||||
*/
|
||||
@ISC_PLATFORM_NEEDNETINET6IN6H@
|
||||
|
||||
/*! \brief
|
||||
* If sockaddrs on this system have an sa_len field, ISC_PLATFORM_HAVESALEN
|
||||
* will be defined.
|
||||
*/
|
||||
@ISC_PLATFORM_HAVESALEN@
|
||||
|
||||
/*! \brief
|
||||
* If this system has the IPv6 structure definitions, ISC_PLATFORM_HAVEIPV6
|
||||
* will be defined.
|
||||
*/
|
||||
@ISC_PLATFORM_HAVEIPV6@
|
||||
|
||||
/*! \brief
|
||||
* If this system is missing in6addr_any, ISC_PLATFORM_NEEDIN6ADDRANY will
|
||||
* be defined.
|
||||
*/
|
||||
@ISC_PLATFORM_NEEDIN6ADDRANY@
|
||||
|
||||
/*! \brief
|
||||
* If this system is missing in6addr_loopback, ISC_PLATFORM_NEEDIN6ADDRLOOPBACK
|
||||
* will be defined.
|
||||
*/
|
||||
@ISC_PLATFORM_NEEDIN6ADDRLOOPBACK@
|
||||
|
||||
/*! \brief
|
||||
* If this system has in6_pktinfo, ISC_PLATFORM_HAVEIN6PKTINFO will be
|
||||
* defined.
|
||||
*/
|
||||
@ISC_PLATFORM_HAVEIN6PKTINFO@
|
||||
|
||||
/*! \brief
|
||||
* If this system has in_addr6, rather than in6_addr, ISC_PLATFORM_HAVEINADDR6
|
||||
* will be defined.
|
||||
*/
|
||||
@ISC_PLATFORM_HAVEINADDR6@
|
||||
|
||||
/*! \brief
|
||||
* If this system has sin6_scope_id, ISC_PLATFORM_HAVESCOPEID will be defined.
|
||||
*/
|
||||
@ISC_PLATFORM_HAVESCOPEID@
|
||||
|
||||
/*! \brief
|
||||
* If this system needs inet_ntop(), ISC_PLATFORM_NEEDNTOP will be defined.
|
||||
*/
|
||||
@ISC_PLATFORM_NEEDNTOP@
|
||||
|
||||
/*! \brief
|
||||
* If this system needs inet_pton(), ISC_PLATFORM_NEEDPTON will be defined.
|
||||
*/
|
||||
@ISC_PLATFORM_NEEDPTON@
|
||||
|
||||
/*! \brief
|
||||
* If this system needs in_port_t, ISC_PLATFORM_NEEDPORTT will be defined.
|
||||
*/
|
||||
@ISC_PLATFORM_NEEDPORTT@
|
||||
/***
|
||||
*** Network.
|
||||
***/
|
||||
|
||||
/*! \brief
|
||||
* Define if the system has struct lifconf which is a extended struct ifconf
|
||||
|
|
@ -115,27 +53,11 @@
|
|||
*/
|
||||
@ISC_PLATFORM_HAVEIF_LADDRREQ@
|
||||
|
||||
/*! \brief
|
||||
* Define either ISC_PLATFORM_BSD44MSGHDR or ISC_PLATFORM_BSD43MSGHDR.
|
||||
*/
|
||||
@ISC_PLATFORM_MSGHDRFLAVOR@
|
||||
|
||||
/*! \brief
|
||||
* Define if the system supports if_nametoindex.
|
||||
*/
|
||||
@ISC_PLATFORM_HAVEIFNAMETOINDEX@
|
||||
|
||||
/*! \brief
|
||||
* Define on some UnixWare systems to fix erroneous definitions of various
|
||||
* IN6_IS_ADDR_* macros.
|
||||
*/
|
||||
@ISC_PLATFORM_FIXIN6ISADDR@
|
||||
|
||||
/*! \brief
|
||||
* Define if the system has struct sockaddr_storage.
|
||||
*/
|
||||
@ISC_PLATFORM_HAVESOCKADDRSTORAGE@
|
||||
|
||||
/*! \brief
|
||||
* Define if the system has TCP_FASTOPEN socket option.
|
||||
*/
|
||||
|
|
@ -175,21 +97,6 @@
|
|||
*/
|
||||
@ISC_PLATFORM_NEEDSTRLCAT@
|
||||
|
||||
/*
|
||||
* Define if this system needs strtoul.
|
||||
*/
|
||||
@ISC_PLATFORM_NEEDSTRTOUL@
|
||||
|
||||
/*
|
||||
* Define if this system needs memmove.
|
||||
*/
|
||||
@ISC_PLATFORM_NEEDMEMMOVE@
|
||||
|
||||
/*
|
||||
* Define if this system needs strcasestr.
|
||||
*/
|
||||
@ISC_PLATFORM_NEEDSTRCASESTR@
|
||||
|
||||
/***
|
||||
*** Miscellaneous.
|
||||
***/
|
||||
|
|
@ -222,22 +129,6 @@
|
|||
*/
|
||||
@ISC_PLATFORM_HAVESTATNSEC@
|
||||
|
||||
/*
|
||||
* Type used for resource limits.
|
||||
*/
|
||||
@ISC_PLATFORM_RLIMITTYPE@
|
||||
|
||||
/*
|
||||
* Define if your compiler supports "long long int".
|
||||
*/
|
||||
@ISC_PLATFORM_HAVELONGLONG@
|
||||
|
||||
/*
|
||||
* Define if PTHREAD_ONCE_INIT should be surrounded by braces to
|
||||
* prevent compiler warnings (such as with gcc on Solaris 2.8).
|
||||
*/
|
||||
@ISC_PLATFORM_BRACEPTHREADONCEINIT@
|
||||
|
||||
/*
|
||||
* Used to control how extern data is linked; needed for Win32 platforms.
|
||||
*/
|
||||
|
|
@ -289,11 +180,6 @@
|
|||
*/
|
||||
@ISC_PLATFORM_USEGCCASM@
|
||||
|
||||
/*
|
||||
* Define if Tru64 style ASM syntax must be used.
|
||||
*/
|
||||
@ISC_PLATFORM_USEOSFASM@
|
||||
|
||||
/*
|
||||
* Define if the standard __asm function must be used.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1196,8 +1196,8 @@ isc_socket_permunix(const isc_sockaddr_t *sockaddr, uint32_t perm,
|
|||
/*%<
|
||||
* Set ownership and file permissions on the UNIX domain socket.
|
||||
*
|
||||
* Note: On Solaris and SunOS this secures the directory containing
|
||||
* the socket as Solaris and SunOS do not honour the filesystem
|
||||
* Note: On Solaris this secures the directory containing
|
||||
* the socket as Solaris do not honour the filesystem
|
||||
* permissions on the socket.
|
||||
*
|
||||
* Requires:
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ISC_STDLIB_H
|
||||
#define ISC_STDLIB_H 1
|
||||
|
||||
/*! \file isc/stdlib.h */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/platform.h>
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDSTRTOUL
|
||||
#define strtoul isc_strtoul
|
||||
#endif
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
unsigned long isc_strtoul(const char *, char **, int);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif
|
||||
|
|
@ -1,196 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/net.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/util.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 *inet_ntop4(const unsigned char *src, char *dst,
|
||||
size_t size);
|
||||
|
||||
#ifdef AF_INET6
|
||||
static const char *inet_ntop6(const unsigned char *src, char *dst,
|
||||
size_t size);
|
||||
#endif
|
||||
|
||||
/*! char *
|
||||
* isc_net_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_net_ntop(int af, const void *src, char *dst, size_t size)
|
||||
{
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
return (inet_ntop4(src, dst, size));
|
||||
#ifdef AF_INET6
|
||||
case AF_INET6:
|
||||
return (inet_ntop6(src, dst, size));
|
||||
#endif
|
||||
default:
|
||||
errno = EAFNOSUPPORT;
|
||||
return (NULL);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/*! const char *
|
||||
* inet_ntop4(src, dst, size)
|
||||
* format an IPv4 address
|
||||
* \return
|
||||
* `dst' (as a const)
|
||||
* \note
|
||||
* (1) uses no statics
|
||||
* \note
|
||||
* (2) takes a unsigned char* not an in_addr as input
|
||||
* \author
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static const char *
|
||||
inet_ntop4(const unsigned char *src, char *dst, size_t size)
|
||||
{
|
||||
static const char *fmt = "%u.%u.%u.%u";
|
||||
char tmp[sizeof("255.255.255.255")];
|
||||
int n;
|
||||
|
||||
|
||||
n = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]);
|
||||
if (n < 0 || (size_t)n >= size) {
|
||||
errno = ENOSPC;
|
||||
return (NULL);
|
||||
}
|
||||
strlcpy(dst, tmp, size);
|
||||
|
||||
return (dst);
|
||||
}
|
||||
|
||||
/*! const char *
|
||||
* isc_inet_ntop6(src, dst, size)
|
||||
* convert IPv6 binary address into presentation (printable) format
|
||||
* \author
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
#ifdef AF_INET6
|
||||
static const char *
|
||||
inet_ntop6(const unsigned 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;
|
||||
unsigned 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; /* silence compiler */
|
||||
cur.base = -1;
|
||||
cur.len = 0; /* silence compiler */
|
||||
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;
|
||||
}
|
||||
INSIST((size_t)(tp - tmp) < sizeof(tmp));
|
||||
tp += snprintf(tp, sizeof(tmp) - (tp - tmp), "%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);
|
||||
}
|
||||
strlcpy(dst, tmp, size);
|
||||
return (dst);
|
||||
}
|
||||
#endif /* AF_INET6 */
|
||||
|
|
@ -1,204 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/net.h>
|
||||
|
||||
/*% INT16 Size */
|
||||
#define NS_INT16SZ 2
|
||||
/*% IPv4 Address Size */
|
||||
#define NS_INADDRSZ 4
|
||||
/*% IPv6 Address Size */
|
||||
#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 int inet_pton4(const char *src, unsigned char *dst);
|
||||
static int inet_pton6(const char *src, unsigned char *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
|
||||
isc_net_pton(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 */
|
||||
}
|
||||
|
||||
/*!\fn static int inet_pton4(const char *src, unsigned char *dst)
|
||||
* \brief
|
||||
* like inet_aton() but without all the hexadecimal and shorthand.
|
||||
* \return
|
||||
* 1 if `src' is a valid dotted quad, else 0.
|
||||
* \note
|
||||
* does not touch `dst' unless it's returning 1.
|
||||
* \author
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static int
|
||||
inet_pton4(const char *src, unsigned char *dst) {
|
||||
static const char digits[] = "0123456789";
|
||||
int saw_digit, octets, ch;
|
||||
unsigned 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) {
|
||||
unsigned int byte = *tp * 10;
|
||||
|
||||
byte += (int)(pch - digits);
|
||||
if (saw_digit && *tp == 0)
|
||||
return (0);
|
||||
if (byte > 255)
|
||||
return (0);
|
||||
*tp = byte;
|
||||
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);
|
||||
memmove(dst, tmp, NS_INADDRSZ);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*%
|
||||
* convert presentation level address to network order binary form.
|
||||
* \return
|
||||
* 1 if `src' is a valid [RFC1884 2.2] address, else 0.
|
||||
* \note
|
||||
* (1) does not touch `dst' unless it's returning 1.
|
||||
* \note
|
||||
* (2) :: in a full address is silently ignored.
|
||||
* \author
|
||||
* inspired by Mark Andrews.
|
||||
* \author
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static int
|
||||
inet_pton6(const char *src, unsigned char *dst) {
|
||||
static const char xdigits_l[] = "0123456789abcdef",
|
||||
xdigits_u[] = "0123456789ABCDEF";
|
||||
unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
|
||||
const char *xdigits, *curtok;
|
||||
int ch, seen_xdigits;
|
||||
unsigned 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;
|
||||
}
|
||||
if (tp + NS_INT16SZ > endp)
|
||||
return (0);
|
||||
*tp++ = (unsigned char) (val >> 8) & 0xff;
|
||||
*tp++ = (unsigned 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++ = (unsigned char) (val >> 8) & 0xff;
|
||||
*tp++ = (unsigned 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 = (int)(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);
|
||||
memmove(dst, tmp, NS_IN6ADDRSZ);
|
||||
return (1);
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@
|
|||
#define LOG_BUFFER_SIZE (8 * 1024)
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024 /* AIX and others don't define this. */
|
||||
#define PATH_MAX 1024 /* WIN32 and others don't define this. */
|
||||
#endif
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -336,11 +336,7 @@ isc_netaddr_fromsockaddr(isc_netaddr_t *t, const isc_sockaddr_t *s) {
|
|||
break;
|
||||
case AF_INET6:
|
||||
memmove(&t->type.in6, &s->type.sin6.sin6_addr, 16);
|
||||
#ifdef ISC_PLATFORM_HAVESCOPEID
|
||||
t->zone = s->type.sin6.sin6_scope_id;
|
||||
#else
|
||||
t->zone = 0;
|
||||
#endif
|
||||
break;
|
||||
#ifdef ISC_PLATFORM_HAVESYSUNH
|
||||
case AF_UNIX:
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@
|
|||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isc/parseint.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/stdlib.h>
|
||||
|
||||
isc_result_t
|
||||
isc_parse_uint32(uint32_t *uip, const char *string, int base) {
|
||||
|
|
|
|||
|
|
@ -38,63 +38,7 @@
|
|||
* case.
|
||||
*/
|
||||
|
||||
#if defined(_AIX)
|
||||
|
||||
#include <sys/atomic_op.h>
|
||||
|
||||
#define isc_atomic_store(p, v) _clear_lock(p, v)
|
||||
|
||||
#ifdef __GNUC__
|
||||
static inline int32_t
|
||||
#else
|
||||
static int32_t
|
||||
#endif
|
||||
isc_atomic_xadd(int32_t *p, int32_t val) {
|
||||
int ret;
|
||||
|
||||
#ifdef __GNUC__
|
||||
asm("ics");
|
||||
#else
|
||||
__isync();
|
||||
#endif
|
||||
|
||||
ret = fetch_and_add((atomic_p)p, (int)val);
|
||||
|
||||
#ifdef __GNUC__
|
||||
asm("ics");
|
||||
#else
|
||||
__isync();
|
||||
#endif
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
static inline int
|
||||
#else
|
||||
static int
|
||||
#endif
|
||||
isc_atomic_cmpxchg(atomic_p p, int old, int replacement) {
|
||||
int orig = old;
|
||||
|
||||
#ifdef __GNUC__
|
||||
asm("ics");
|
||||
#else
|
||||
__isync();
|
||||
#endif
|
||||
if (compare_and_swap(p, &orig, replacement))
|
||||
orig = old;
|
||||
|
||||
#ifdef __GNUC__
|
||||
asm("ics");
|
||||
#else
|
||||
__isync();
|
||||
#endif
|
||||
|
||||
return (orig);
|
||||
}
|
||||
|
||||
#elif defined(ISC_PLATFORM_USEGCCASM) || defined(ISC_PLATFORM_USEMACASM)
|
||||
#if defined(ISC_PLATFORM_USEGCCASM) || defined(ISC_PLATFORM_USEMACASM)
|
||||
static inline int32_t
|
||||
isc_atomic_xadd(int32_t *p, int32_t val) {
|
||||
int32_t orig;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include <isc/condition.h>
|
||||
#include <isc/msgs.h>
|
||||
#include <isc/strerror.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/time.h>
|
||||
#include <isc/util.h>
|
||||
|
|
@ -64,7 +63,7 @@ isc_condition_waituntil(isc_condition_t *c, isc_mutex_t *m, isc_time_t *t) {
|
|||
return (ISC_R_TIMEDOUT);
|
||||
} while (presult == EINTR);
|
||||
|
||||
isc__strerror(presult, strbuf, sizeof(strbuf));
|
||||
strerror_r(presult, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"pthread_cond_timedwait() %s %s",
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
|
||||
|
|
|
|||
|
|
@ -22,17 +22,7 @@
|
|||
|
||||
typedef pthread_once_t isc_once_t;
|
||||
|
||||
#ifdef ISC_PLATFORM_BRACEPTHREADONCEINIT
|
||||
/*!
|
||||
* This accomodates systems that define PTHRAD_ONCE_INIT improperly.
|
||||
*/
|
||||
#define ISC_ONCE_INIT { PTHREAD_ONCE_INIT }
|
||||
#else
|
||||
/*!
|
||||
* This is the usual case.
|
||||
*/
|
||||
#define ISC_ONCE_INIT PTHREAD_ONCE_INIT
|
||||
#endif
|
||||
|
||||
/* XXX We could do fancier error handling... */
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
|
|
@ -23,7 +24,6 @@
|
|||
#include <isc/mutex.h>
|
||||
#include <isc/util.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/strerror.h>
|
||||
#include <isc/once.h>
|
||||
|
||||
#if ISC_MUTEX_PROFILE
|
||||
|
|
@ -292,7 +292,7 @@ isc__mutex_init(isc_mutex_t *mp, const char *file, unsigned int line) {
|
|||
if (err == ENOMEM)
|
||||
return (ISC_R_NOMEMORY);
|
||||
if (err != 0) {
|
||||
isc__strerror(err, strbuf, sizeof(strbuf));
|
||||
strerror_r(err, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(file, line, "isc_mutex_init() failed: %s",
|
||||
strbuf);
|
||||
result = ISC_R_UNEXPECTED;
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ isc_sockaddr_compare(const isc_sockaddr_t *a, const isc_sockaddr_t *b,
|
|||
memcmp(&a->type.sin6.sin6_addr, &b->type.sin6.sin6_addr,
|
||||
sizeof(a->type.sin6.sin6_addr)) != 0)
|
||||
return (false);
|
||||
#ifdef ISC_PLATFORM_HAVESCOPEID
|
||||
/*
|
||||
* If ISC_SOCKADDR_CMPSCOPEZERO is set then don't return
|
||||
* false if one of the scopes in zero.
|
||||
|
|
@ -82,7 +81,6 @@ isc_sockaddr_compare(const isc_sockaddr_t *a, const isc_sockaddr_t *b,
|
|||
(a->type.sin6.sin6_scope_id != 0 &&
|
||||
b->type.sin6.sin6_scope_id != 0)))
|
||||
return (false);
|
||||
#endif
|
||||
if ((flags & ISC_SOCKADDR_CMPPORT) != 0 &&
|
||||
a->type.sin6.sin6_port != b->type.sin6.sin6_port)
|
||||
return (false);
|
||||
|
|
@ -244,9 +242,6 @@ isc_sockaddr_any(isc_sockaddr_t *sockaddr)
|
|||
{
|
||||
memset(sockaddr, 0, sizeof(*sockaddr));
|
||||
sockaddr->type.sin.sin_family = AF_INET;
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
sockaddr->type.sin.sin_len = sizeof(sockaddr->type.sin);
|
||||
#endif
|
||||
sockaddr->type.sin.sin_addr.s_addr = INADDR_ANY;
|
||||
sockaddr->type.sin.sin_port = 0;
|
||||
sockaddr->length = sizeof(sockaddr->type.sin);
|
||||
|
|
@ -258,9 +253,6 @@ isc_sockaddr_any6(isc_sockaddr_t *sockaddr)
|
|||
{
|
||||
memset(sockaddr, 0, sizeof(*sockaddr));
|
||||
sockaddr->type.sin6.sin6_family = AF_INET6;
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6);
|
||||
#endif
|
||||
sockaddr->type.sin6.sin6_addr = in6addr_any;
|
||||
sockaddr->type.sin6.sin6_port = 0;
|
||||
sockaddr->length = sizeof(sockaddr->type.sin6);
|
||||
|
|
@ -273,9 +265,6 @@ isc_sockaddr_fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina,
|
|||
{
|
||||
memset(sockaddr, 0, sizeof(*sockaddr));
|
||||
sockaddr->type.sin.sin_family = AF_INET;
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
sockaddr->type.sin.sin_len = sizeof(sockaddr->type.sin);
|
||||
#endif
|
||||
sockaddr->type.sin.sin_addr = *ina;
|
||||
sockaddr->type.sin.sin_port = htons(port);
|
||||
sockaddr->length = sizeof(sockaddr->type.sin);
|
||||
|
|
@ -302,9 +291,6 @@ isc_sockaddr_fromin6(isc_sockaddr_t *sockaddr, const struct in6_addr *ina6,
|
|||
{
|
||||
memset(sockaddr, 0, sizeof(*sockaddr));
|
||||
sockaddr->type.sin6.sin6_family = AF_INET6;
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6);
|
||||
#endif
|
||||
sockaddr->type.sin6.sin6_addr = *ina6;
|
||||
sockaddr->type.sin6.sin6_port = htons(port);
|
||||
sockaddr->length = sizeof(sockaddr->type.sin6);
|
||||
|
|
@ -317,9 +303,6 @@ isc_sockaddr_v6fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina,
|
|||
{
|
||||
memset(sockaddr, 0, sizeof(*sockaddr));
|
||||
sockaddr->type.sin6.sin6_family = AF_INET6;
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6);
|
||||
#endif
|
||||
sockaddr->type.sin6.sin6_addr.s6_addr[10] = 0xff;
|
||||
sockaddr->type.sin6.sin6_addr.s6_addr[11] = 0xff;
|
||||
memmove(&sockaddr->type.sin6.sin6_addr.s6_addr[12], ina, 4);
|
||||
|
|
@ -365,21 +348,13 @@ isc_sockaddr_fromnetaddr(isc_sockaddr_t *sockaddr, const isc_netaddr_t *na,
|
|||
switch (na->family) {
|
||||
case AF_INET:
|
||||
sockaddr->length = sizeof(sockaddr->type.sin);
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
sockaddr->type.sin.sin_len = sizeof(sockaddr->type.sin);
|
||||
#endif
|
||||
sockaddr->type.sin.sin_addr = na->type.in;
|
||||
sockaddr->type.sin.sin_port = htons(port);
|
||||
break;
|
||||
case AF_INET6:
|
||||
sockaddr->length = sizeof(sockaddr->type.sin6);
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6);
|
||||
#endif
|
||||
memmove(&sockaddr->type.sin6.sin6_addr, &na->type.in6, 16);
|
||||
#ifdef ISC_PLATFORM_HAVESCOPEID
|
||||
sockaddr->type.sin6.sin6_scope_id = isc_netaddr_getzone(na);
|
||||
#endif
|
||||
sockaddr->type.sin6.sin6_port = htons(port);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -492,10 +467,6 @@ isc_sockaddr_frompath(isc_sockaddr_t *sockaddr, const char *path) {
|
|||
memset(sockaddr, 0, sizeof(*sockaddr));
|
||||
sockaddr->length = sizeof(sockaddr->type.sunix);
|
||||
sockaddr->type.sunix.sun_family = AF_UNIX;
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
sockaddr->type.sunix.sun_len =
|
||||
(unsigned char)sizeof(sockaddr->type.sunix);
|
||||
#endif
|
||||
strlcpy(sockaddr->type.sunix.sun_path, path,
|
||||
sizeof(sockaddr->type.sunix.sun_path));
|
||||
return (ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -1,117 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)strtoul.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <isc/stdlib.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
/*!
|
||||
* Convert a string to an unsigned long integer.
|
||||
*
|
||||
* Ignores `locale' stuff. Assumes that the upper and lower case
|
||||
* alphabets and digits are each contiguous.
|
||||
*/
|
||||
unsigned long
|
||||
isc_strtoul(const char *nptr, char **endptr, int base) {
|
||||
const char *s = nptr;
|
||||
unsigned long acc;
|
||||
unsigned char c;
|
||||
unsigned long cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* See strtol for comments as to the logic used.
|
||||
*/
|
||||
do {
|
||||
c = *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 = (unsigned long)ULONG_MAX / (unsigned long)base;
|
||||
cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
|
||||
for (acc = 0, any = 0;; c = *s++) {
|
||||
if (!isascii(c))
|
||||
break;
|
||||
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);
|
||||
}
|
||||
|
|
@ -11,7 +11,6 @@ tp: file_test
|
|||
tp: hash_test
|
||||
tp: heap_test
|
||||
tp: ht_test
|
||||
tp: inet_ntop_test
|
||||
tp: lex_test
|
||||
tp: mem_test
|
||||
tp: netaddr_test
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ atf_test_program{name='file_test'}
|
|||
atf_test_program{name='hash_test'}
|
||||
atf_test_program{name='heap_test'}
|
||||
atf_test_program{name='ht_test'}
|
||||
atf_test_program{name='inet_ntop_test'}
|
||||
atf_test_program{name='lex_test'}
|
||||
atf_test_program{name='mem_test'}
|
||||
atf_test_program{name='netaddr_test'}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ CMOCKA_LIBS = @CMOCKA_LIBS@
|
|||
OBJS = isctest.@O@
|
||||
SRCS = isctest.c aes_test.c atomic_test.c buffer_test.c \
|
||||
counter_test.c errno_test.c file_test.c hash_test.c \
|
||||
heap_test.c ht_test.c inet_ntop_test.c lex_test.c \
|
||||
heap_test.c ht_test.c lex_test.c \
|
||||
mem_test.c netaddr_test.c parse_test.c pool_test.c \
|
||||
queue_test.c radix_test.c random_test.c \
|
||||
regex_test.c result_test.c safe_test.c sockaddr_test.c \
|
||||
|
|
@ -44,7 +44,7 @@ SUBDIRS =
|
|||
TARGETS = aes_test@EXEEXT@ atomic_test@EXEEXT@ buffer_test@EXEEXT@ \
|
||||
counter_test@EXEEXT@ errno_test@EXEEXT@ file_test@EXEEXT@ \
|
||||
hash_test@EXEEXT@ heap_test@EXEEXT@ ht_test@EXEEXT@ \
|
||||
inet_ntop_test@EXEEXT@ lex_test@EXEEXT@ mem_test@EXEEXT@ \
|
||||
lex_test@EXEEXT@ mem_test@EXEEXT@ \
|
||||
netaddr_test@EXEEXT@ parse_test@EXEEXT@ pool_test@EXEEXT@ \
|
||||
queue_test@EXEEXT@ radix_test@EXEEXT@ \
|
||||
random_test@EXEEXT@ regex_test@EXEEXT@ result_test@EXEEXT@ \
|
||||
|
|
@ -90,11 +90,6 @@ ht_test@EXEEXT@: ht_test.@O@ ${ISCDEPLIBS}
|
|||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||
ht_test.@O@ ${ISCLIBS} ${LIBS}
|
||||
|
||||
inet_ntop_test.c.@O@: ${top_srcdir}/lib/isc/ntop_test.c
|
||||
inet_ntop_test@EXEEXT@: inet_ntop_test.@O@ ${ISCDEPLIBS}
|
||||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||
inet_ntop_test.@O@ ${ISCLIBS} ${LIBS}
|
||||
|
||||
lex_test@EXEEXT@: lex_test.@O@ ${ISCDEPLIBS}
|
||||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||
lex_test.@O@ ${ISCLIBS} ${LIBS}
|
||||
|
|
|
|||
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
/*
|
||||
* Force the prototype for isc_net_ntop to be declared.
|
||||
*/
|
||||
#include <isc/platform.h>
|
||||
#undef ISC_PLATFORM_NEEDNTOP
|
||||
#define ISC_PLATFORM_NEEDNTOP
|
||||
#include "../inet_ntop.c"
|
||||
|
||||
ATF_TC(isc_net_ntop);
|
||||
ATF_TC_HEAD(isc_net_ntop, tc) {
|
||||
atf_tc_set_md_var(tc, "descr", "isc_net_ntop implementation");
|
||||
}
|
||||
ATF_TC_BODY(isc_net_ntop, tc) {
|
||||
char buf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
|
||||
int r;
|
||||
size_t i;
|
||||
unsigned char abuf[16];
|
||||
struct {
|
||||
int family;
|
||||
const char * address;
|
||||
} testdata[] = {
|
||||
{ AF_INET, "0.0.0.0" },
|
||||
{ AF_INET, "0.1.0.0" },
|
||||
{ AF_INET, "0.0.2.0" },
|
||||
{ AF_INET, "0.0.0.3" },
|
||||
{ AF_INET, "255.255.255.255" },
|
||||
{ AF_INET6, "::" },
|
||||
{ AF_INET6, "::1.2.3.4" },
|
||||
{ AF_INET6, "::ffff:1.2.3.4" },
|
||||
{ AF_INET6, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" }
|
||||
};
|
||||
|
||||
for (i = 0; i < sizeof(testdata)/sizeof(testdata[0]); i++) {
|
||||
r = inet_pton(testdata[i].family, testdata[i].address, abuf);
|
||||
ATF_REQUIRE_EQ_MSG(r, 1, "%s", testdata[i].address);
|
||||
isc_net_ntop(testdata[i].family, abuf, buf, sizeof(buf));
|
||||
ATF_CHECK_STREQ(buf, testdata[i].address);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
ATF_TP_ADD_TCS(tp) {
|
||||
ATF_TP_ADD_TC(tp, isc_net_ntop);
|
||||
return (atf_no_error());
|
||||
}
|
||||
|
|
@ -412,7 +412,6 @@ ATF_TC_HEAD(udp_dscp_v6, tc) {
|
|||
atf_tc_set_md_var(tc, "descr", "udp dscp ipv6");
|
||||
}
|
||||
ATF_TC_BODY(udp_dscp_v6, tc) {
|
||||
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6)
|
||||
isc_result_t result;
|
||||
isc_sockaddr_t addr1, addr2;
|
||||
struct in6_addr in6;
|
||||
|
|
@ -508,10 +507,6 @@ ATF_TC_BODY(udp_dscp_v6, tc) {
|
|||
isc_socket_detach(&s2);
|
||||
|
||||
isc_test_end();
|
||||
#else
|
||||
UNUSED(tc);
|
||||
atf_tc_skip("IPv6 not available");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Test TCP sendto/recv (IPv4) */
|
||||
|
|
@ -618,7 +613,6 @@ ATF_TC_HEAD(tcp_dscp_v6, tc) {
|
|||
atf_tc_set_md_var(tc, "descr", "tcp dscp ipv6");
|
||||
}
|
||||
ATF_TC_BODY(tcp_dscp_v6, tc) {
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
isc_result_t result;
|
||||
isc_sockaddr_t addr1;
|
||||
struct in6_addr in6;
|
||||
|
|
@ -717,10 +711,6 @@ ATF_TC_BODY(tcp_dscp_v6, tc) {
|
|||
isc_socket_detach(&s3);
|
||||
|
||||
isc_test_end();
|
||||
#else
|
||||
UNUSED(tc);
|
||||
atf_tc_skip("IPv6 not available");
|
||||
#endif
|
||||
}
|
||||
|
||||
ATF_TC(net_probedscp);
|
||||
|
|
|
|||
|
|
@ -161,7 +161,6 @@ schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) {
|
|||
isc__timermgr_t *manager;
|
||||
isc_time_t due;
|
||||
int cmp;
|
||||
bool timedwait;
|
||||
|
||||
/*!
|
||||
* Note: the caller must ensure locking.
|
||||
|
|
@ -171,13 +170,6 @@ schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) {
|
|||
|
||||
manager = timer->manager;
|
||||
|
||||
/*!
|
||||
* If the manager was timed wait, we may need to signal the
|
||||
* manager to force a wakeup.
|
||||
*/
|
||||
timedwait = (manager->nscheduled > 0 &&
|
||||
isc_time_seconds(&manager->due) != 0);
|
||||
|
||||
/*
|
||||
* Compute the new due time.
|
||||
*/
|
||||
|
|
@ -240,31 +232,6 @@ schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) {
|
|||
* run thread, or explicitly setting the value in the manager.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is a temporary (probably) hack to fix a bug on tru64 5.1
|
||||
* and 5.1a. Sometimes, pthread_cond_timedwait() doesn't actually
|
||||
* return when the time expires, so here, we check to see if
|
||||
* we're 15 seconds or more behind, and if we are, we signal
|
||||
* the dispatcher. This isn't such a bad idea as a general purpose
|
||||
* watchdog, so perhaps we should just leave it in here.
|
||||
*/
|
||||
if (signal_ok && timedwait) {
|
||||
isc_interval_t fifteen;
|
||||
isc_time_t then;
|
||||
|
||||
isc_interval_set(&fifteen, 15, 0);
|
||||
result = isc_time_add(&manager->due, &fifteen, &then);
|
||||
|
||||
if (result == ISC_R_SUCCESS &&
|
||||
isc_time_compare(&then, now) < 0) {
|
||||
SIGNAL(&manager->wakeup);
|
||||
signal_ok = false;
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_TIMER, ISC_LOG_WARNING,
|
||||
"*** POKED TIMER ***");
|
||||
}
|
||||
}
|
||||
|
||||
if (timer->index == 1 && signal_ok) {
|
||||
XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TIMER,
|
||||
ISC_MSG_SIGNALSCHED,
|
||||
|
|
|
|||
|
|
@ -21,24 +21,23 @@ CDEFINES =
|
|||
CWARNINGS =
|
||||
|
||||
# Alphabetically
|
||||
OBJS = @ISC_IPV6_O@ pk11_api.@O@ \
|
||||
OBJS = pk11_api.@O@ \
|
||||
app.@O@ dir.@O@ errno.@O@ errno2result.@O@ \
|
||||
file.@O@ fsaccess.@O@ interfaceiter.@O@ \
|
||||
keyboard.@O@ meminfo.@O@ \
|
||||
net.@O@ os.@O@ resource.@O@ socket.@O@ stdio.@O@ stdtime.@O@ \
|
||||
strerror.@O@ syslog.@O@ time.@O@
|
||||
syslog.@O@ time.@O@
|
||||
|
||||
# Alphabetically
|
||||
SRCS = @ISC_IPV6_C@ pk11_api.c \
|
||||
SRCS = pk11_api.c \
|
||||
app.c dir.c errno.c errno2result.c \
|
||||
file.c fsaccess.c interfaceiter.c keyboard.c meminfo.c \
|
||||
net.c os.c resource.c socket.c stdio.c stdtime.c \
|
||||
strerror.c syslog.c time.c
|
||||
syslog.c time.c
|
||||
|
||||
SUBDIRS = include
|
||||
TARGETS = ${OBJS}
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
interfaceiter.@O@: interfaceiter.c ifiter_ioctl.c ifiter_sysctl.c ifiter_getifaddrs.c
|
||||
|
||||
interfaceiter.@O@: interfaceiter.c ifiter_getifaddrs.c
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include <sys/epoll.h>
|
||||
#endif
|
||||
|
||||
#include <isc/platform.h>
|
||||
#include <isc/app.h>
|
||||
#include <isc/condition.h>
|
||||
#include <isc/mem.h>
|
||||
|
|
@ -35,7 +36,6 @@
|
|||
#include <isc/mutex.h>
|
||||
#include <isc/event.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/strerror.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/time.h>
|
||||
|
|
@ -181,7 +181,7 @@ handle_signal(int sig, void (*handler)(int)) {
|
|||
|
||||
if (sigfillset(&sa.sa_mask) != 0 ||
|
||||
sigaction(sig, &sa, NULL) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_APP,
|
||||
ISC_MSG_SIGNALSETUP,
|
||||
|
|
@ -213,7 +213,7 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
|
|||
*/
|
||||
presult = pthread_init();
|
||||
if (presult != 0) {
|
||||
isc__strerror(presult, strbuf, sizeof(strbuf));
|
||||
strerror_r(presult, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_app_start() pthread_init: %s", strbuf);
|
||||
return (ISC_R_UNEXPECTED);
|
||||
|
|
@ -302,7 +302,7 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
|
|||
sigaddset(&sset, SIGHUP) != 0 ||
|
||||
sigaddset(&sset, SIGINT) != 0 ||
|
||||
sigaddset(&sset, SIGTERM) != 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_app_start() sigsetops: %s", strbuf);
|
||||
result = ISC_R_UNEXPECTED;
|
||||
|
|
@ -310,7 +310,7 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
|
|||
}
|
||||
presult = pthread_sigmask(SIG_BLOCK, &sset, NULL);
|
||||
if (presult != 0) {
|
||||
isc__strerror(presult, strbuf, sizeof(strbuf));
|
||||
strerror_r(presult, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_app_start() pthread_sigmask: %s",
|
||||
strbuf);
|
||||
|
|
@ -450,7 +450,7 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
|
|||
sigaddset(&sset, SIGHUP) != 0 ||
|
||||
sigaddset(&sset, SIGINT) != 0 ||
|
||||
sigaddset(&sset, SIGTERM) != 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_app_run() sigsetops: %s",
|
||||
strbuf);
|
||||
|
|
@ -502,7 +502,7 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
|
|||
return (ISC_R_SUCCESS);
|
||||
|
||||
if (sigemptyset(&sset) != 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_app_run() sigsetops: %s",
|
||||
strbuf);
|
||||
|
|
@ -510,7 +510,7 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
|
|||
}
|
||||
#ifdef HAVE_GPERFTOOLS_PROFILER
|
||||
if (sigaddset(&sset, SIGALRM) != 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_app_run() sigsetops: %s",
|
||||
strbuf);
|
||||
|
|
@ -583,7 +583,7 @@ isc__app_ctxshutdown(isc_appctx_t *ctx0) {
|
|||
|
||||
result = pthread_kill(main_thread, SIGTERM);
|
||||
if (result != 0) {
|
||||
isc__strerror(result,
|
||||
strerror_r(result,
|
||||
strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_app_shutdown() "
|
||||
|
|
@ -596,7 +596,7 @@ isc__app_ctxshutdown(isc_appctx_t *ctx0) {
|
|||
if (isc_bind9) {
|
||||
/* BIND9 internal, single context */
|
||||
if (kill(getpid(), SIGTERM) < 0) {
|
||||
isc__strerror(errno,
|
||||
strerror_r(errno,
|
||||
strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_app_shutdown() "
|
||||
|
|
@ -656,7 +656,7 @@ isc__app_ctxsuspend(isc_appctx_t *ctx0) {
|
|||
|
||||
result = pthread_kill(main_thread, SIGHUP);
|
||||
if (result != 0) {
|
||||
isc__strerror(result,
|
||||
strerror_r(result,
|
||||
strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_app_reload() "
|
||||
|
|
@ -669,7 +669,7 @@ isc__app_ctxsuspend(isc_appctx_t *ctx0) {
|
|||
if (isc_bind9) {
|
||||
/* BIND9 internal, single context */
|
||||
if (kill(getpid(), SIGHUP) < 0) {
|
||||
isc__strerror(errno,
|
||||
strerror_r(errno,
|
||||
strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_app_reload() "
|
||||
|
|
|
|||
|
|
@ -15,9 +15,10 @@
|
|||
#include <config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/platform.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/strerror.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include "errno2result.h"
|
||||
|
|
@ -109,7 +110,7 @@ isc___errno2result(int posixerrno, bool dolog,
|
|||
return (ISC_R_CONNREFUSED);
|
||||
default:
|
||||
if (dolog) {
|
||||
isc__strerror(posixerrno, strbuf, sizeof(strbuf));
|
||||
strerror_r(posixerrno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(file, line, "unable to convert errno "
|
||||
"to isc_result: %d: %s",
|
||||
posixerrno, strbuf);
|
||||
|
|
|
|||
|
|
@ -198,9 +198,7 @@ isc_file_settime(const char *file, isc_time_t *when) {
|
|||
|
||||
/*
|
||||
* isc_time_nanoseconds guarantees a value that divided by 1000 will
|
||||
* fit into the minimum possible size tv_usec field. Unfortunately,
|
||||
* we don't know what that type is so can't cast directly ... but
|
||||
* we can at least cast to signed so the IRIX compiler shuts up.
|
||||
* fit into the minimum possible size tv_usec field.
|
||||
*/
|
||||
times[0].tv_usec = times[1].tv_usec =
|
||||
(int32_t)(isc_time_nanoseconds(when) / 1000);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
|||
#endif
|
||||
|
||||
if (getifaddrs(&iter->ifaddrs) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERGETIFADDRS,
|
||||
|
|
|
|||
|
|
@ -1,931 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <isc/print.h>
|
||||
|
||||
/*! \file
|
||||
* \brief
|
||||
* Obtain the list of network interfaces using the SIOCGLIFCONF ioctl.
|
||||
* See netintro(4).
|
||||
*/
|
||||
|
||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||
#ifdef ISC_PLATFORM_HAVEIF_LADDRCONF
|
||||
#define lifc_len iflc_len
|
||||
#define lifc_buf iflc_buf
|
||||
#define lifc_req iflc_req
|
||||
#define LIFCONF if_laddrconf
|
||||
#else
|
||||
#define ISC_HAVE_LIFC_FAMILY 1
|
||||
#define ISC_HAVE_LIFC_FLAGS 1
|
||||
#define LIFCONF lifconf
|
||||
#endif
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVEIF_LADDRREQ
|
||||
#define lifr_addr iflr_addr
|
||||
#define lifr_name iflr_name
|
||||
#define lifr_dstaddr iflr_dstaddr
|
||||
#define lifr_flags iflr_flags
|
||||
#define ss_family sa_family
|
||||
#define LIFREQ if_laddrreq
|
||||
#else
|
||||
#define LIFREQ lifreq
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define IFITER_MAGIC ISC_MAGIC('I', 'F', 'I', 'T')
|
||||
#define VALID_IFITER(t) ISC_MAGIC_VALID(t, IFITER_MAGIC)
|
||||
|
||||
struct isc_interfaceiter {
|
||||
unsigned int magic; /* Magic number. */
|
||||
isc_mem_t *mctx;
|
||||
int mode;
|
||||
int socket;
|
||||
struct ifconf ifc;
|
||||
void *buf; /* Buffer for sysctl data. */
|
||||
unsigned int bufsize; /* Bytes allocated. */
|
||||
unsigned int pos; /* Current offset in
|
||||
SIOCGIFCONF data */
|
||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||
int socket6;
|
||||
struct LIFCONF lifc;
|
||||
void *buf6; /* Buffer for sysctl data. */
|
||||
unsigned int bufsize6; /* Bytes allocated. */
|
||||
unsigned int pos6; /* Current offset in
|
||||
SIOCGLIFCONF data */
|
||||
isc_result_t result6; /* Last result code. */
|
||||
bool first6;
|
||||
#endif
|
||||
#ifdef HAVE_TRUCLUSTER
|
||||
int clua_context; /* Cluster alias context */
|
||||
bool clua_done;
|
||||
struct sockaddr clua_sa;
|
||||
#endif
|
||||
#ifdef __linux
|
||||
FILE * proc;
|
||||
char entry[ISC_IF_INET6_SZ];
|
||||
isc_result_t valid;
|
||||
#endif
|
||||
isc_interface_t current; /* Current interface data. */
|
||||
isc_result_t result; /* Last result code. */
|
||||
};
|
||||
|
||||
#ifdef HAVE_TRUCLUSTER
|
||||
#include <clua/clua.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*%
|
||||
* Size of buffer for SIOCGLIFCONF, in bytes. We assume no sane system
|
||||
* will have more than a megabyte of interface configuration data.
|
||||
*/
|
||||
#define IFCONF_BUFSIZE_INITIAL 4096
|
||||
#define IFCONF_BUFSIZE_MAX 1048576
|
||||
|
||||
#ifdef __linux
|
||||
#ifndef IF_NAMESIZE
|
||||
# ifdef IFNAMSIZ
|
||||
# define IF_NAMESIZE IFNAMSIZ
|
||||
# else
|
||||
# define IF_NAMESIZE 16
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static isc_result_t
|
||||
getbuf4(isc_interfaceiter_t *iter) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
|
||||
iter->bufsize = IFCONF_BUFSIZE_INITIAL;
|
||||
|
||||
for (;;) {
|
||||
iter->buf = isc_mem_get(iter->mctx, iter->bufsize);
|
||||
if (iter->buf == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
|
||||
memset(&iter->ifc.ifc_len, 0, sizeof(iter->ifc.ifc_len));
|
||||
iter->ifc.ifc_len = iter->bufsize;
|
||||
iter->ifc.ifc_buf = iter->buf;
|
||||
/*
|
||||
* Ignore the HP/UX warning about "integer overflow during
|
||||
* conversion". It comes from its own macro definition,
|
||||
* and is really hard to shut up.
|
||||
*/
|
||||
if (ioctl(iter->socket, SIOCGIFCONF, (char *)&iter->ifc)
|
||||
== -1) {
|
||||
if (errno != EINVAL) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERIOCTL,
|
||||
ISC_MSG_GETIFCONFIG,
|
||||
"get interface "
|
||||
"configuration: %s"),
|
||||
strbuf);
|
||||
goto unexpected;
|
||||
}
|
||||
/*
|
||||
* EINVAL. Retry with a bigger buffer.
|
||||
*/
|
||||
} else {
|
||||
/*
|
||||
* The ioctl succeeded.
|
||||
* Some OS's just return what will fit rather
|
||||
* than set EINVAL if the buffer is too small
|
||||
* to fit all the interfaces in. If
|
||||
* ifc.lifc_len is too near to the end of the
|
||||
* buffer we will grow it just in case and
|
||||
* retry.
|
||||
*/
|
||||
if (iter->ifc.ifc_len + 2 * sizeof(struct ifreq)
|
||||
< iter->bufsize)
|
||||
break;
|
||||
}
|
||||
if (iter->bufsize >= IFCONF_BUFSIZE_MAX) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERIOCTL,
|
||||
ISC_MSG_BUFFERMAX,
|
||||
"get interface "
|
||||
"configuration: "
|
||||
"maximum buffer "
|
||||
"size exceeded"));
|
||||
goto unexpected;
|
||||
}
|
||||
isc_mem_put(iter->mctx, iter->buf, iter->bufsize);
|
||||
|
||||
iter->bufsize *= 2;
|
||||
}
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
unexpected:
|
||||
isc_mem_put(iter->mctx, iter->buf, iter->bufsize);
|
||||
iter->buf = NULL;
|
||||
return (ISC_R_UNEXPECTED);
|
||||
}
|
||||
|
||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||
static isc_result_t
|
||||
getbuf6(isc_interfaceiter_t *iter) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc_result_t result;
|
||||
|
||||
iter->bufsize6 = IFCONF_BUFSIZE_INITIAL;
|
||||
|
||||
for (;;) {
|
||||
iter->buf6 = isc_mem_get(iter->mctx, iter->bufsize6);
|
||||
if (iter->buf6 == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
|
||||
memset(&iter->lifc, 0, sizeof(iter->lifc));
|
||||
#ifdef ISC_HAVE_LIFC_FAMILY
|
||||
iter->lifc.lifc_family = AF_INET6;
|
||||
#endif
|
||||
#ifdef ISC_HAVE_LIFC_FLAGS
|
||||
iter->lifc.lifc_flags = 0;
|
||||
#endif
|
||||
iter->lifc.lifc_len = iter->bufsize6;
|
||||
iter->lifc.lifc_buf = iter->buf6;
|
||||
/*
|
||||
* Ignore the HP/UX warning about "integer overflow during
|
||||
* conversion". It comes from its own macro definition,
|
||||
* and is really hard to shut up.
|
||||
*/
|
||||
if (ioctl(iter->socket6, SIOCGLIFCONF, (char *)&iter->lifc)
|
||||
== -1) {
|
||||
#ifdef __hpux
|
||||
/*
|
||||
* IPv6 interface scanning is not available on all
|
||||
* kernels w/ IPv6 sockets.
|
||||
*/
|
||||
if (errno == ENOENT) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_INTERFACE,
|
||||
ISC_LOG_DEBUG(1),
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERIOCTL,
|
||||
ISC_MSG_GETIFCONFIG,
|
||||
"get interface "
|
||||
"configuration: %s"),
|
||||
strbuf);
|
||||
result = ISC_R_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
#endif
|
||||
if (errno != EINVAL) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERIOCTL,
|
||||
ISC_MSG_GETIFCONFIG,
|
||||
"get interface "
|
||||
"configuration: %s"),
|
||||
strbuf);
|
||||
result = ISC_R_UNEXPECTED;
|
||||
goto cleanup;
|
||||
}
|
||||
/*
|
||||
* EINVAL. Retry with a bigger buffer.
|
||||
*/
|
||||
} else {
|
||||
/*
|
||||
* The ioctl succeeded.
|
||||
* Some OS's just return what will fit rather
|
||||
* than set EINVAL if the buffer is too small
|
||||
* to fit all the interfaces in. If
|
||||
* ifc.ifc_len is too near to the end of the
|
||||
* buffer we will grow it just in case and
|
||||
* retry.
|
||||
*/
|
||||
if (iter->lifc.lifc_len + 2 * sizeof(struct LIFREQ)
|
||||
< iter->bufsize6)
|
||||
break;
|
||||
}
|
||||
if (iter->bufsize6 >= IFCONF_BUFSIZE_MAX) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERIOCTL,
|
||||
ISC_MSG_BUFFERMAX,
|
||||
"get interface "
|
||||
"configuration: "
|
||||
"maximum buffer "
|
||||
"size exceeded"));
|
||||
result = ISC_R_UNEXPECTED;
|
||||
goto cleanup;
|
||||
}
|
||||
isc_mem_put(iter->mctx, iter->buf6, iter->bufsize6);
|
||||
|
||||
iter->bufsize6 *= 2;
|
||||
}
|
||||
|
||||
if (iter->lifc.lifc_len != 0)
|
||||
iter->mode = 6;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
isc_mem_put(iter->mctx, iter->buf6, iter->bufsize6);
|
||||
iter->buf6 = NULL;
|
||||
return (result);
|
||||
}
|
||||
#endif
|
||||
|
||||
isc_result_t
|
||||
isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
||||
isc_interfaceiter_t *iter;
|
||||
isc_result_t result;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
|
||||
REQUIRE(mctx != NULL);
|
||||
REQUIRE(iterp != NULL);
|
||||
REQUIRE(*iterp == NULL);
|
||||
|
||||
iter = isc_mem_get(mctx, sizeof(*iter));
|
||||
if (iter == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
|
||||
iter->mctx = mctx;
|
||||
iter->mode = 4;
|
||||
iter->buf = NULL;
|
||||
iter->pos = (unsigned int) -1;
|
||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||
iter->buf6 = NULL;
|
||||
iter->pos6 = (unsigned int) -1;
|
||||
iter->result6 = ISC_R_NOMORE;
|
||||
iter->socket6 = -1;
|
||||
iter->first6 = false;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get the interface configuration, allocating more memory if
|
||||
* necessary.
|
||||
*/
|
||||
|
||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||
result = isc_net_probeipv6();
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
/*
|
||||
* Create an unbound datagram socket to do the SIOCGLIFCONF
|
||||
* ioctl on. HP/UX requires an AF_INET6 socket for
|
||||
* SIOCGLIFCONF to get IPv6 addresses.
|
||||
*/
|
||||
if ((iter->socket6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERIOCTL,
|
||||
ISC_MSG_MAKESCANSOCKET,
|
||||
"making interface "
|
||||
"scan socket: %s"),
|
||||
strbuf);
|
||||
result = ISC_R_UNEXPECTED;
|
||||
goto socket6_failure;
|
||||
}
|
||||
result = iter->result6 = getbuf6(iter);
|
||||
if (result != ISC_R_NOTIMPLEMENTED && result != ISC_R_SUCCESS)
|
||||
goto ioctl6_failure;
|
||||
}
|
||||
#endif
|
||||
if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERIOCTL,
|
||||
ISC_MSG_MAKESCANSOCKET,
|
||||
"making interface "
|
||||
"scan socket: %s"),
|
||||
strbuf);
|
||||
result = ISC_R_UNEXPECTED;
|
||||
goto socket_failure;
|
||||
}
|
||||
result = getbuf4(iter);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto ioctl_failure;
|
||||
|
||||
/*
|
||||
* A newly created iterator has an undefined position
|
||||
* until isc_interfaceiter_first() is called.
|
||||
*/
|
||||
#ifdef HAVE_TRUCLUSTER
|
||||
iter->clua_context = -1;
|
||||
iter->clua_done = true;
|
||||
#endif
|
||||
#ifdef __linux
|
||||
iter->proc = fopen("/proc/net/if_inet6", "r");
|
||||
iter->valid = ISC_R_FAILURE;
|
||||
#endif
|
||||
iter->result = ISC_R_FAILURE;
|
||||
|
||||
iter->magic = IFITER_MAGIC;
|
||||
*iterp = iter;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
ioctl_failure:
|
||||
if (iter->buf != NULL)
|
||||
isc_mem_put(mctx, iter->buf, iter->bufsize);
|
||||
(void) close(iter->socket);
|
||||
|
||||
socket_failure:
|
||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||
if (iter->buf6 != NULL)
|
||||
isc_mem_put(mctx, iter->buf6, iter->bufsize6);
|
||||
ioctl6_failure:
|
||||
if (iter->socket6 != -1)
|
||||
(void) close(iter->socket6);
|
||||
socket6_failure:
|
||||
#endif
|
||||
|
||||
isc_mem_put(mctx, iter, sizeof(*iter));
|
||||
return (result);
|
||||
}
|
||||
|
||||
#ifdef HAVE_TRUCLUSTER
|
||||
static void
|
||||
get_inaddr(isc_netaddr_t *dst, struct in_addr *src) {
|
||||
dst->family = AF_INET;
|
||||
memmove(&dst->type.in, src, sizeof(struct in_addr));
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
internal_current_clusteralias(isc_interfaceiter_t *iter) {
|
||||
struct clua_info ci;
|
||||
if (clua_getaliasinfo(&iter->clua_sa, &ci) != CLUA_SUCCESS)
|
||||
return (ISC_R_IGNORE);
|
||||
memset(&iter->current, 0, sizeof(iter->current));
|
||||
iter->current.af = iter->clua_sa.sa_family;
|
||||
memset(iter->current.name, 0, sizeof(iter->current.name));
|
||||
snprintf(iter->current.name, sizeof(iter->current.name),
|
||||
"clua%d", ci.aliasid);
|
||||
iter->current.flags = INTERFACE_F_UP;
|
||||
get_inaddr(&iter->current.address, &ci.addr);
|
||||
get_inaddr(&iter->current.netmask, &ci.netmask);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get information about the current interface to iter->current.
|
||||
* If successful, return ISC_R_SUCCESS.
|
||||
* If the interface has an unsupported address family, or if
|
||||
* some operation on it fails, return ISC_R_IGNORE to make
|
||||
* the higher-level iterator code ignore it.
|
||||
*/
|
||||
|
||||
static isc_result_t
|
||||
internal_current4(isc_interfaceiter_t *iter) {
|
||||
struct ifreq *ifrp;
|
||||
struct ifreq ifreq;
|
||||
int family;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
#if !defined(ISC_PLATFORM_HAVEIF_LADDRREQ) && defined(SIOCGLIFADDR)
|
||||
struct lifreq lifreq;
|
||||
#else
|
||||
char sabuf[256];
|
||||
#endif
|
||||
int i, bits, prefixlen;
|
||||
|
||||
REQUIRE(VALID_IFITER(iter));
|
||||
|
||||
if (iter->ifc.ifc_len == 0 ||
|
||||
iter->pos == (unsigned int)iter->ifc.ifc_len) {
|
||||
#ifdef __linux
|
||||
return (linux_if_inet6_current(iter));
|
||||
#else
|
||||
return (ISC_R_NOMORE);
|
||||
#endif
|
||||
}
|
||||
|
||||
INSIST( iter->pos < (unsigned int) iter->ifc.ifc_len);
|
||||
|
||||
ifrp = (struct ifreq *)((char *) iter->ifc.ifc_req + iter->pos);
|
||||
|
||||
memset(&ifreq, 0, sizeof(ifreq));
|
||||
memmove(&ifreq, ifrp, sizeof(ifreq));
|
||||
|
||||
family = ifreq.ifr_addr.sa_family;
|
||||
#if defined(ISC_PLATFORM_HAVEIPV6)
|
||||
if (family != AF_INET && family != AF_INET6)
|
||||
#else
|
||||
if (family != AF_INET)
|
||||
#endif
|
||||
return (ISC_R_IGNORE);
|
||||
|
||||
memset(&iter->current, 0, sizeof(iter->current));
|
||||
iter->current.af = family;
|
||||
|
||||
INSIST(sizeof(ifreq.ifr_name) <= sizeof(iter->current.name));
|
||||
memset(iter->current.name, 0, sizeof(iter->current.name));
|
||||
memmove(iter->current.name, ifreq.ifr_name, sizeof(ifreq.ifr_name));
|
||||
|
||||
get_addr(family, &iter->current.address,
|
||||
(struct sockaddr *)&ifrp->ifr_addr, ifreq.ifr_name);
|
||||
|
||||
/*
|
||||
* If the interface does not have a address ignore it.
|
||||
*/
|
||||
switch (family) {
|
||||
case AF_INET:
|
||||
if (iter->current.address.type.in.s_addr == htonl(INADDR_ANY))
|
||||
return (ISC_R_IGNORE);
|
||||
break;
|
||||
case AF_INET6:
|
||||
if (memcmp(&iter->current.address.type.in6, &in6addr_any,
|
||||
sizeof(in6addr_any)) == 0)
|
||||
return (ISC_R_IGNORE);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get interface flags.
|
||||
*/
|
||||
|
||||
iter->current.flags = 0;
|
||||
|
||||
/*
|
||||
* Ignore the HP/UX warning about "integer overflow during
|
||||
* conversion. It comes from its own macro definition,
|
||||
* and is really hard to shut up.
|
||||
*/
|
||||
if (ioctl(iter->socket, SIOCGIFFLAGS, (char *) &ifreq) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"%s: getting interface flags: %s",
|
||||
ifreq.ifr_name, strbuf);
|
||||
return (ISC_R_IGNORE);
|
||||
}
|
||||
|
||||
if ((ifreq.ifr_flags & IFF_UP) != 0)
|
||||
iter->current.flags |= INTERFACE_F_UP;
|
||||
|
||||
#ifdef IFF_POINTOPOINT
|
||||
if ((ifreq.ifr_flags & IFF_POINTOPOINT) != 0)
|
||||
iter->current.flags |= INTERFACE_F_POINTTOPOINT;
|
||||
#endif
|
||||
|
||||
if ((ifreq.ifr_flags & IFF_LOOPBACK) != 0)
|
||||
iter->current.flags |= INTERFACE_F_LOOPBACK;
|
||||
|
||||
if (family == AF_INET)
|
||||
goto inet;
|
||||
|
||||
#if !defined(ISC_PLATFORM_HAVEIF_LADDRREQ) && defined(SIOCGLIFADDR)
|
||||
memset(&lifreq, 0, sizeof(lifreq));
|
||||
memmove(lifreq.lifr_name, iter->current.name, sizeof(lifreq.lifr_name));
|
||||
memmove(&lifreq.lifr_addr, &iter->current.address.type.in6,
|
||||
sizeof(iter->current.address.type.in6));
|
||||
|
||||
if (ioctl(iter->socket, SIOCGLIFADDR, &lifreq) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"%s: getting interface address: %s",
|
||||
ifreq.ifr_name, strbuf);
|
||||
return (ISC_R_IGNORE);
|
||||
}
|
||||
prefixlen = lifreq.lifr_addrlen;
|
||||
#else
|
||||
isc_netaddr_format(&iter->current.address, sabuf, sizeof(sabuf));
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_INTERFACE,
|
||||
ISC_LOG_INFO,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERIOCTL,
|
||||
ISC_MSG_GETIFCONFIG,
|
||||
"prefix length for %s is unknown "
|
||||
"(assume 128)"), sabuf);
|
||||
prefixlen = 128;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Netmask already zeroed.
|
||||
*/
|
||||
iter->current.netmask.family = family;
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (prefixlen > 8) {
|
||||
bits = 0;
|
||||
prefixlen -= 8;
|
||||
} else {
|
||||
bits = 8 - prefixlen;
|
||||
prefixlen = 0;
|
||||
}
|
||||
iter->current.netmask.type.in6.s6_addr[i] =
|
||||
(~0U << bits) & 0xff;
|
||||
}
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
inet:
|
||||
if (family != AF_INET)
|
||||
return (ISC_R_IGNORE);
|
||||
#ifdef IFF_POINTOPOINT
|
||||
/*
|
||||
* If the interface is point-to-point, get the destination address.
|
||||
*/
|
||||
if ((iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0) {
|
||||
/*
|
||||
* Ignore the HP/UX warning about "integer overflow during
|
||||
* conversion. It comes from its own macro definition,
|
||||
* and is really hard to shut up.
|
||||
*/
|
||||
if (ioctl(iter->socket, SIOCGIFDSTADDR, (char *)&ifreq)
|
||||
< 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERIOCTL,
|
||||
ISC_MSG_GETDESTADDR,
|
||||
"%s: getting "
|
||||
"destination address: %s"),
|
||||
ifreq.ifr_name, strbuf);
|
||||
return (ISC_R_IGNORE);
|
||||
}
|
||||
get_addr(family, &iter->current.dstaddress,
|
||||
(struct sockaddr *)&ifreq.ifr_dstaddr, ifreq.ifr_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get the network mask.
|
||||
*/
|
||||
memset(&ifreq, 0, sizeof(ifreq));
|
||||
memmove(&ifreq, ifrp, sizeof(ifreq));
|
||||
/*
|
||||
* Ignore the HP/UX warning about "integer overflow during
|
||||
* conversion. It comes from its own macro definition,
|
||||
* and is really hard to shut up.
|
||||
*/
|
||||
if (ioctl(iter->socket, SIOCGIFNETMASK, (char *)&ifreq) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERIOCTL,
|
||||
ISC_MSG_GETNETMASK,
|
||||
"%s: getting netmask: %s"),
|
||||
ifreq.ifr_name, strbuf);
|
||||
return (ISC_R_IGNORE);
|
||||
}
|
||||
get_addr(family, &iter->current.netmask,
|
||||
(struct sockaddr *)&ifreq.ifr_addr, ifreq.ifr_name);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||
static isc_result_t
|
||||
internal_current6(isc_interfaceiter_t *iter) {
|
||||
struct LIFREQ *ifrp;
|
||||
struct LIFREQ lifreq;
|
||||
int family;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
int fd;
|
||||
|
||||
REQUIRE(VALID_IFITER(iter));
|
||||
if (iter->result6 != ISC_R_SUCCESS)
|
||||
return (iter->result6);
|
||||
REQUIRE(iter->pos6 < (unsigned int) iter->lifc.lifc_len);
|
||||
|
||||
ifrp = (struct LIFREQ *)((char *) iter->lifc.lifc_req + iter->pos6);
|
||||
|
||||
memset(&lifreq, 0, sizeof(lifreq));
|
||||
memmove(&lifreq, ifrp, sizeof(lifreq));
|
||||
|
||||
family = lifreq.lifr_addr.ss_family;
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
if (family != AF_INET && family != AF_INET6)
|
||||
#else
|
||||
if (family != AF_INET)
|
||||
#endif
|
||||
return (ISC_R_IGNORE);
|
||||
|
||||
memset(&iter->current, 0, sizeof(iter->current));
|
||||
iter->current.af = family;
|
||||
|
||||
INSIST(sizeof(lifreq.lifr_name) <= sizeof(iter->current.name));
|
||||
memset(iter->current.name, 0, sizeof(iter->current.name));
|
||||
memmove(iter->current.name, lifreq.lifr_name, sizeof(lifreq.lifr_name));
|
||||
|
||||
get_addr(family, &iter->current.address,
|
||||
(struct sockaddr *)&lifreq.lifr_addr, lifreq.lifr_name);
|
||||
|
||||
/*
|
||||
* If the interface does not have a address ignore it.
|
||||
*/
|
||||
switch (family) {
|
||||
case AF_INET:
|
||||
if (iter->current.address.type.in.s_addr == htonl(INADDR_ANY))
|
||||
return (ISC_R_IGNORE);
|
||||
break;
|
||||
case AF_INET6:
|
||||
if (memcmp(&iter->current.address.type.in6, &in6addr_any,
|
||||
sizeof(in6addr_any)) == 0)
|
||||
return (ISC_R_IGNORE);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get interface flags.
|
||||
*/
|
||||
|
||||
iter->current.flags = 0;
|
||||
|
||||
if (family == AF_INET6)
|
||||
fd = iter->socket6;
|
||||
else
|
||||
fd = iter->socket;
|
||||
|
||||
/*
|
||||
* Ignore the HP/UX warning about "integer overflow during
|
||||
* conversion. It comes from its own macro definition,
|
||||
* and is really hard to shut up.
|
||||
*/
|
||||
if (ioctl(fd, SIOCGLIFFLAGS, (char *) &lifreq) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"%s: getting interface flags: %s",
|
||||
lifreq.lifr_name, strbuf);
|
||||
return (ISC_R_IGNORE);
|
||||
}
|
||||
|
||||
if ((lifreq.lifr_flags & IFF_UP) != 0)
|
||||
iter->current.flags |= INTERFACE_F_UP;
|
||||
|
||||
#ifdef IFF_POINTOPOINT
|
||||
if ((lifreq.lifr_flags & IFF_POINTOPOINT) != 0)
|
||||
iter->current.flags |= INTERFACE_F_POINTTOPOINT;
|
||||
#endif
|
||||
|
||||
if ((lifreq.lifr_flags & IFF_LOOPBACK) != 0)
|
||||
iter->current.flags |= INTERFACE_F_LOOPBACK;
|
||||
|
||||
#ifdef IFF_POINTOPOINT
|
||||
/*
|
||||
* If the interface is point-to-point, get the destination address.
|
||||
*/
|
||||
if ((iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0) {
|
||||
/*
|
||||
* Ignore the HP/UX warning about "integer overflow during
|
||||
* conversion. It comes from its own macro definition,
|
||||
* and is really hard to shut up.
|
||||
*/
|
||||
if (ioctl(fd, SIOCGLIFDSTADDR, (char *)&lifreq)
|
||||
< 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERIOCTL,
|
||||
ISC_MSG_GETDESTADDR,
|
||||
"%s: getting "
|
||||
"destination address: %s"),
|
||||
lifreq.lifr_name, strbuf);
|
||||
return (ISC_R_IGNORE);
|
||||
}
|
||||
get_addr(family, &iter->current.dstaddress,
|
||||
(struct sockaddr *)&lifreq.lifr_dstaddr,
|
||||
lifreq.lifr_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get the network mask. Netmask already zeroed.
|
||||
*/
|
||||
memset(&lifreq, 0, sizeof(lifreq));
|
||||
memmove(&lifreq, ifrp, sizeof(lifreq));
|
||||
|
||||
#ifdef lifr_addrlen
|
||||
/*
|
||||
* Special case: if the system provides lifr_addrlen member, the
|
||||
* netmask of an IPv6 address can be derived from the length, since
|
||||
* an IPv6 address always has a contiguous mask.
|
||||
*/
|
||||
if (family == AF_INET6) {
|
||||
int i, bits;
|
||||
|
||||
iter->current.netmask.family = family;
|
||||
for (i = 0; i < lifreq.lifr_addrlen; i += 8) {
|
||||
bits = lifreq.lifr_addrlen - i;
|
||||
bits = (bits < 8) ? (8 - bits) : 0;
|
||||
iter->current.netmask.type.in6.s6_addr[i / 8] =
|
||||
(~0U << bits) & 0xff;
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Ignore the HP/UX warning about "integer overflow during
|
||||
* conversion. It comes from its own macro definition,
|
||||
* and is really hard to shut up.
|
||||
*/
|
||||
if (ioctl(fd, SIOCGLIFNETMASK, (char *)&lifreq) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERIOCTL,
|
||||
ISC_MSG_GETNETMASK,
|
||||
"%s: getting netmask: %s"),
|
||||
lifreq.lifr_name, strbuf);
|
||||
return (ISC_R_IGNORE);
|
||||
}
|
||||
get_addr(family, &iter->current.netmask,
|
||||
(struct sockaddr *)&lifreq.lifr_addr, lifreq.lifr_name);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
|
||||
static isc_result_t
|
||||
internal_current(isc_interfaceiter_t *iter) {
|
||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||
if (iter->mode == 6) {
|
||||
iter->result6 = internal_current6(iter);
|
||||
if (iter->result6 != ISC_R_NOMORE)
|
||||
return (iter->result6);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_TRUCLUSTER
|
||||
if (!iter->clua_done)
|
||||
return(internal_current_clusteralias(iter));
|
||||
#endif
|
||||
return (internal_current4(iter));
|
||||
}
|
||||
|
||||
/*
|
||||
* Step the iterator to the next interface. Unlike
|
||||
* isc_interfaceiter_next(), this may leave the iterator
|
||||
* positioned on an interface that will ultimately
|
||||
* be ignored. Return ISC_R_NOMORE if there are no more
|
||||
* interfaces, otherwise ISC_R_SUCCESS.
|
||||
*/
|
||||
static isc_result_t
|
||||
internal_next4(isc_interfaceiter_t *iter) {
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
struct ifreq *ifrp;
|
||||
#endif
|
||||
|
||||
if (iter->pos < (unsigned int) iter->ifc.ifc_len) {
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
ifrp = (struct ifreq *)((char *) iter->ifc.ifc_req + iter->pos);
|
||||
|
||||
if (ifrp->ifr_addr.sa_len > sizeof(struct sockaddr))
|
||||
iter->pos += sizeof(ifrp->ifr_name) +
|
||||
ifrp->ifr_addr.sa_len;
|
||||
else
|
||||
#endif
|
||||
iter->pos += sizeof(struct ifreq);
|
||||
|
||||
} else {
|
||||
INSIST(iter->pos == (unsigned int) iter->ifc.ifc_len);
|
||||
#ifdef __linux
|
||||
return (linux_if_inet6_next(iter));
|
||||
#else
|
||||
return (ISC_R_NOMORE);
|
||||
#endif
|
||||
}
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||
static isc_result_t
|
||||
internal_next6(isc_interfaceiter_t *iter) {
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
struct LIFREQ *ifrp;
|
||||
#endif
|
||||
|
||||
if (iter->result6 != ISC_R_SUCCESS && iter->result6 != ISC_R_IGNORE)
|
||||
return (iter->result6);
|
||||
|
||||
REQUIRE(iter->pos6 < (unsigned int) iter->lifc.lifc_len);
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
ifrp = (struct LIFREQ *)((char *) iter->lifc.lifc_req + iter->pos6);
|
||||
|
||||
if (ifrp->lifr_addr.sa_len > sizeof(struct sockaddr))
|
||||
iter->pos6 += sizeof(ifrp->lifr_name) + ifrp->lifr_addr.sa_len;
|
||||
else
|
||||
#endif
|
||||
iter->pos6 += sizeof(struct LIFREQ);
|
||||
|
||||
if (iter->pos6 >= (unsigned int) iter->lifc.lifc_len)
|
||||
return (ISC_R_NOMORE);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
|
||||
static isc_result_t
|
||||
internal_next(isc_interfaceiter_t *iter) {
|
||||
#ifdef HAVE_TRUCLUSTER
|
||||
int clua_result;
|
||||
#endif
|
||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||
if (iter->mode == 6) {
|
||||
iter->result6 = internal_next6(iter);
|
||||
if (iter->result6 != ISC_R_NOMORE)
|
||||
return (iter->result6);
|
||||
if (iter->first6) {
|
||||
iter->first6 = false;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_TRUCLUSTER
|
||||
if (!iter->clua_done) {
|
||||
clua_result = clua_getaliasaddress(&iter->clua_sa,
|
||||
&iter->clua_context);
|
||||
if (clua_result != CLUA_SUCCESS)
|
||||
iter->clua_done = true;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
return (internal_next4(iter));
|
||||
}
|
||||
|
||||
static void
|
||||
internal_destroy(isc_interfaceiter_t *iter) {
|
||||
(void) close(iter->socket);
|
||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||
if (iter->socket6 != -1)
|
||||
(void) close(iter->socket6);
|
||||
if (iter->buf6 != NULL) {
|
||||
isc_mem_put(iter->mctx, iter->buf6, iter->bufsize6);
|
||||
}
|
||||
#endif
|
||||
#ifdef __linux
|
||||
if (iter->proc != NULL)
|
||||
fclose(iter->proc);
|
||||
#endif
|
||||
}
|
||||
|
||||
static
|
||||
void internal_first(isc_interfaceiter_t *iter) {
|
||||
#ifdef HAVE_TRUCLUSTER
|
||||
int clua_result;
|
||||
#endif
|
||||
iter->pos = 0;
|
||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||
iter->pos6 = 0;
|
||||
if (iter->result6 == ISC_R_NOMORE)
|
||||
iter->result6 = ISC_R_SUCCESS;
|
||||
iter->first6 = true;
|
||||
#endif
|
||||
#ifdef HAVE_TRUCLUSTER
|
||||
iter->clua_context = 0;
|
||||
clua_result = clua_getaliasaddress(&iter->clua_sa,
|
||||
&iter->clua_context);
|
||||
iter->clua_done = (clua_result != CLUA_SUCCESS);
|
||||
#endif
|
||||
#ifdef __linux
|
||||
linux_if_inet6_first(iter);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -1,301 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/*! \file
|
||||
* \brief
|
||||
* Obtain the list of network interfaces using sysctl.
|
||||
* See TCP/IP Illustrated Volume 2, sections 19.8, 19.14,
|
||||
* and 19.16.
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <net/route.h>
|
||||
#include <net/if_dl.h>
|
||||
|
||||
#include <isc/print.h>
|
||||
|
||||
/* XXX what about Alpha? */
|
||||
#ifdef sgi
|
||||
#define ROUNDUP(a) ((a) > 0 ? \
|
||||
(1 + (((a) - 1) | (sizeof(__uint64_t) - 1))) : \
|
||||
sizeof(__uint64_t))
|
||||
#else
|
||||
#define ROUNDUP(a) ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) \
|
||||
: sizeof(long))
|
||||
#endif
|
||||
|
||||
#define IFITER_MAGIC ISC_MAGIC('I', 'F', 'I', 'S')
|
||||
#define VALID_IFITER(t) ISC_MAGIC_VALID(t, IFITER_MAGIC)
|
||||
|
||||
struct isc_interfaceiter {
|
||||
unsigned int magic; /* Magic number. */
|
||||
isc_mem_t *mctx;
|
||||
void *buf; /* Buffer for sysctl data. */
|
||||
unsigned int bufsize; /* Bytes allocated. */
|
||||
unsigned int bufused; /* Bytes used. */
|
||||
unsigned int pos; /* Current offset in
|
||||
sysctl data. */
|
||||
isc_interface_t current; /* Current interface data. */
|
||||
isc_result_t result; /* Last result code. */
|
||||
};
|
||||
|
||||
static int mib[6] = {
|
||||
CTL_NET,
|
||||
PF_ROUTE,
|
||||
0,
|
||||
0, /* Any address family. */
|
||||
NET_RT_IFLIST,
|
||||
0 /* Flags. */
|
||||
};
|
||||
|
||||
isc_result_t
|
||||
isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
||||
isc_interfaceiter_t *iter;
|
||||
isc_result_t result;
|
||||
size_t bufsize;
|
||||
size_t bufused;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
|
||||
REQUIRE(mctx != NULL);
|
||||
REQUIRE(iterp != NULL);
|
||||
REQUIRE(*iterp == NULL);
|
||||
|
||||
iter = isc_mem_get(mctx, sizeof(*iter));
|
||||
if (iter == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
|
||||
iter->mctx = mctx;
|
||||
iter->buf = 0;
|
||||
|
||||
/*
|
||||
* Determine the amount of memory needed.
|
||||
*/
|
||||
bufsize = 0;
|
||||
if (sysctl(mib, 6, NULL, &bufsize, NULL, (size_t) 0) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERSYSCTL,
|
||||
ISC_MSG_GETIFLISTSIZE,
|
||||
"getting interface "
|
||||
"list size: sysctl: %s"),
|
||||
strbuf);
|
||||
result = ISC_R_UNEXPECTED;
|
||||
goto failure;
|
||||
}
|
||||
iter->bufsize = bufsize;
|
||||
|
||||
iter->buf = isc_mem_get(iter->mctx, iter->bufsize);
|
||||
if (iter->buf == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto failure;
|
||||
}
|
||||
|
||||
bufused = bufsize;
|
||||
if (sysctl(mib, 6, iter->buf, &bufused, NULL, (size_t) 0) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERSYSCTL,
|
||||
ISC_MSG_GETIFLIST,
|
||||
"getting interface list: "
|
||||
"sysctl: %s"),
|
||||
strbuf);
|
||||
result = ISC_R_UNEXPECTED;
|
||||
goto failure;
|
||||
}
|
||||
iter->bufused = bufused;
|
||||
INSIST(iter->bufused <= iter->bufsize);
|
||||
|
||||
/*
|
||||
* A newly created iterator has an undefined position
|
||||
* until isc_interfaceiter_first() is called.
|
||||
*/
|
||||
iter->pos = (unsigned int) -1;
|
||||
iter->result = ISC_R_FAILURE;
|
||||
|
||||
iter->magic = IFITER_MAGIC;
|
||||
*iterp = iter;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
failure:
|
||||
if (iter->buf != NULL)
|
||||
isc_mem_put(mctx, iter->buf, iter->bufsize);
|
||||
isc_mem_put(mctx, iter, sizeof(*iter));
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get information about the current interface to iter->current.
|
||||
* If successful, return ISC_R_SUCCESS.
|
||||
* If the interface has an unsupported address family,
|
||||
* return ISC_R_IGNORE. In case of other failure,
|
||||
* return ISC_R_UNEXPECTED.
|
||||
*/
|
||||
|
||||
static isc_result_t
|
||||
internal_current(isc_interfaceiter_t *iter) {
|
||||
struct ifa_msghdr *ifam, *ifam_end;
|
||||
|
||||
REQUIRE(VALID_IFITER(iter));
|
||||
REQUIRE (iter->pos < (unsigned int) iter->bufused);
|
||||
|
||||
ifam = (struct ifa_msghdr *) ((char *) iter->buf + iter->pos);
|
||||
ifam_end = (struct ifa_msghdr *) ((char *) iter->buf + iter->bufused);
|
||||
|
||||
if (ifam->ifam_type == RTM_IFINFO) {
|
||||
struct if_msghdr *ifm = (struct if_msghdr *) ifam;
|
||||
struct sockaddr_dl *sdl = (struct sockaddr_dl *) (ifm + 1);
|
||||
unsigned int namelen;
|
||||
|
||||
memset(&iter->current, 0, sizeof(iter->current));
|
||||
|
||||
namelen = sdl->sdl_nlen;
|
||||
if (namelen > sizeof(iter->current.name) - 1)
|
||||
namelen = sizeof(iter->current.name) - 1;
|
||||
|
||||
memset(iter->current.name, 0, sizeof(iter->current.name));
|
||||
memmove(iter->current.name, sdl->sdl_data, namelen);
|
||||
|
||||
iter->current.flags = 0;
|
||||
|
||||
if ((ifam->ifam_flags & IFF_UP) != 0)
|
||||
iter->current.flags |= INTERFACE_F_UP;
|
||||
|
||||
if ((ifam->ifam_flags & IFF_POINTOPOINT) != 0)
|
||||
iter->current.flags |= INTERFACE_F_POINTTOPOINT;
|
||||
|
||||
if ((ifam->ifam_flags & IFF_LOOPBACK) != 0)
|
||||
iter->current.flags |= INTERFACE_F_LOOPBACK;
|
||||
|
||||
/*
|
||||
* This is not an interface address.
|
||||
* Force another iteration.
|
||||
*/
|
||||
return (ISC_R_IGNORE);
|
||||
} else if (ifam->ifam_type == RTM_NEWADDR) {
|
||||
int i;
|
||||
int family;
|
||||
struct sockaddr *mask_sa = NULL;
|
||||
struct sockaddr *addr_sa = NULL;
|
||||
struct sockaddr *dst_sa = NULL;
|
||||
|
||||
struct sockaddr *sa = (struct sockaddr *)(ifam + 1);
|
||||
family = sa->sa_family;
|
||||
|
||||
for (i = 0; i < RTAX_MAX; i++)
|
||||
{
|
||||
if ((ifam->ifam_addrs & (1 << i)) == 0)
|
||||
continue;
|
||||
|
||||
INSIST(sa < (struct sockaddr *) ifam_end);
|
||||
|
||||
switch (i) {
|
||||
case RTAX_NETMASK: /* Netmask */
|
||||
mask_sa = sa;
|
||||
break;
|
||||
case RTAX_IFA: /* Interface address */
|
||||
addr_sa = sa;
|
||||
break;
|
||||
case RTAX_BRD: /* Broadcast or destination address */
|
||||
dst_sa = sa;
|
||||
break;
|
||||
}
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
sa = (struct sockaddr *)((char*)(sa)
|
||||
+ ROUNDUP(sa->sa_len));
|
||||
#else
|
||||
#ifdef sgi
|
||||
/*
|
||||
* Do as the contributed SGI code does.
|
||||
*/
|
||||
sa = (struct sockaddr *)((char*)(sa)
|
||||
+ ROUNDUP(_FAKE_SA_LEN_DST(sa)));
|
||||
#else
|
||||
/* XXX untested. */
|
||||
sa = (struct sockaddr *)((char*)(sa)
|
||||
+ ROUNDUP(sizeof(struct sockaddr)));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if (addr_sa == NULL)
|
||||
return (ISC_R_IGNORE);
|
||||
|
||||
family = addr_sa->sa_family;
|
||||
if (family != AF_INET && family != AF_INET6)
|
||||
return (ISC_R_IGNORE);
|
||||
|
||||
iter->current.af = family;
|
||||
|
||||
get_addr(family, &iter->current.address, addr_sa,
|
||||
iter->current.name);
|
||||
|
||||
if (mask_sa != NULL)
|
||||
get_addr(family, &iter->current.netmask, mask_sa,
|
||||
iter->current.name);
|
||||
|
||||
if (dst_sa != NULL &&
|
||||
(iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0)
|
||||
get_addr(family, &iter->current.dstaddress, dst_sa,
|
||||
iter->current.name);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
} else {
|
||||
printf("%s",
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_IFITERSYSCTL,
|
||||
ISC_MSG_UNEXPECTEDTYPE,
|
||||
"warning: unexpected interface list "
|
||||
"message type\n"));
|
||||
return (ISC_R_IGNORE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Step the iterator to the next interface. Unlike
|
||||
* isc_interfaceiter_next(), this may leave the iterator
|
||||
* positioned on an interface that will ultimately
|
||||
* be ignored. Return ISC_R_NOMORE if there are no more
|
||||
* interfaces, otherwise ISC_R_SUCCESS.
|
||||
*/
|
||||
static isc_result_t
|
||||
internal_next(isc_interfaceiter_t *iter) {
|
||||
struct ifa_msghdr *ifam;
|
||||
REQUIRE (iter->pos < (unsigned int) iter->bufused);
|
||||
|
||||
ifam = (struct ifa_msghdr *) ((char *) iter->buf + iter->pos);
|
||||
|
||||
iter->pos += ifam->ifam_msglen;
|
||||
|
||||
if (iter->pos >= iter->bufused)
|
||||
return (ISC_R_NOMORE);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
internal_destroy(isc_interfaceiter_t *iter) {
|
||||
UNUSED(iter); /* Unused. */
|
||||
/*
|
||||
* Do nothing.
|
||||
*/
|
||||
}
|
||||
|
||||
static
|
||||
void internal_first(isc_interfaceiter_t *iter) {
|
||||
iter->pos = 0;
|
||||
}
|
||||
|
|
@ -20,29 +20,24 @@
|
|||
#include <isc/lang.h>
|
||||
#include <isc/result.h>
|
||||
|
||||
#define ISC_DIR_NAMEMAX 256
|
||||
#define ISC_DIR_PATHMAX 1024
|
||||
#ifndef NAME_MAX
|
||||
#define NAME_MAX 256
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024
|
||||
#endif
|
||||
|
||||
/*% Directory Entry */
|
||||
typedef struct isc_direntry {
|
||||
/*!
|
||||
* Ideally, this should be NAME_MAX, but AIX does not define it by
|
||||
* default and dynamically allocating the space based on pathconf()
|
||||
* complicates things undesirably, as does adding special conditionals
|
||||
* just for AIX. So a comfortably sized buffer is chosen instead.
|
||||
*/
|
||||
char name[ISC_DIR_NAMEMAX];
|
||||
char name[NAME_MAX];
|
||||
unsigned int length;
|
||||
} isc_direntry_t;
|
||||
|
||||
/*% Directory */
|
||||
typedef struct isc_dir {
|
||||
unsigned int magic;
|
||||
/*!
|
||||
* As with isc_direntry_t->name, making this "right" for all systems
|
||||
* is slightly problematic because AIX does not define PATH_MAX.
|
||||
*/
|
||||
char dirname[ISC_DIR_PATHMAX];
|
||||
char dirname[PATH_MAX];
|
||||
isc_direntry_t entry;
|
||||
DIR * handle;
|
||||
} isc_dir_t;
|
||||
|
|
|
|||
|
|
@ -76,40 +76,10 @@
|
|||
|
||||
#include <netinet/in.h> /* Contractual promise. */
|
||||
#include <arpa/inet.h> /* Contractual promise. */
|
||||
#ifdef ISC_PLATFORM_NEEDNETINETIN6H
|
||||
#include <netinet/in6.h> /* Required on UnixWare. */
|
||||
#endif
|
||||
#ifdef ISC_PLATFORM_NEEDNETINET6IN6H
|
||||
#include <netinet6/in6.h> /* Required on BSD/OS for in6_pktinfo. */
|
||||
#endif
|
||||
|
||||
#ifndef ISC_PLATFORM_HAVEIPV6
|
||||
#include <isc/ipv6.h> /* Contractual promise. */
|
||||
#endif
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVEINADDR6
|
||||
#define in6_addr in_addr6 /*%< Required for pre RFC2133 implementations. */
|
||||
#endif
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
#ifndef IN6ADDR_ANY_INIT
|
||||
#ifdef s6_addr
|
||||
/*%
|
||||
* Required for some pre RFC2133 implementations.
|
||||
* IN6ADDR_ANY_INIT and IN6ADDR_LOOPBACK_INIT were added in
|
||||
* draft-ietf-ipngwg-bsd-api-04.txt or draft-ietf-ipngwg-bsd-api-05.txt.
|
||||
* If 's6_addr' is defined then assume that there is a union and three
|
||||
* levels otherwise assume two levels required.
|
||||
*/
|
||||
#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
|
||||
#else
|
||||
#define IN6ADDR_ANY_INIT { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef IN6ADDR_LOOPBACK_INIT
|
||||
#ifdef s6_addr
|
||||
/*% IPv6 address loopback init */
|
||||
|
|
@ -167,7 +137,6 @@
|
|||
#define IN6_IS_ADDR_LOOPBACK(x) \
|
||||
(memcmp((x)->s6_addr, in6addr_loopback.s6_addr, 16) == 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef AF_INET6
|
||||
/*% IPv6 */
|
||||
|
|
@ -189,82 +158,6 @@
|
|||
#define INADDR_LOOPBACK 0x7f000001UL
|
||||
#endif
|
||||
|
||||
#ifndef ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
/*% IPv6 packet info */
|
||||
struct in6_pktinfo {
|
||||
struct in6_addr ipi6_addr; /*%< src/dst IPv6 address */
|
||||
unsigned int ipi6_ifindex; /*%< send/recv interface index */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ISC_PLATFORM_HAVESOCKADDRSTORAGE
|
||||
#define _SS_MAXSIZE 128
|
||||
#define _SS_ALIGNSIZE (sizeof (uint64_t))
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
#define _SS_PAD1SIZE (_SS_ALIGNSIZE - (2 * sizeof(uint8_t)))
|
||||
#define _SS_PAD2SIZE (_SS_MAXSIZE - (_SS_ALIGNSIZE + _SS_PAD1SIZE \
|
||||
+ 2 * sizeof(uint8_t)))
|
||||
#else
|
||||
#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(uint16_t))
|
||||
#define _SS_PAD2SIZE (_SS_MAXSIZE - (_SS_ALIGNSIZE + _SS_PAD1SIZE \
|
||||
+ sizeof(uint16_t)))
|
||||
#endif
|
||||
|
||||
struct sockaddr_storage {
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
uint8_t ss_len;
|
||||
uint8_t ss_family;
|
||||
#else
|
||||
uint16_t ss_family;
|
||||
#endif
|
||||
char __ss_pad1[_SS_PAD1SIZE];
|
||||
uint64_t __ss_align; /* field to force desired structure */
|
||||
char __ss_pad2[_SS_PAD2SIZE];
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRANY)
|
||||
extern const struct in6_addr isc_net_in6addrany;
|
||||
/*%
|
||||
* Cope with a missing in6addr_any and in6addr_loopback.
|
||||
*/
|
||||
#define in6addr_any isc_net_in6addrany
|
||||
#endif
|
||||
|
||||
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRLOOPBACK)
|
||||
extern const struct in6_addr isc_net_in6addrloop;
|
||||
#define in6addr_loopback isc_net_in6addrloop
|
||||
#endif
|
||||
|
||||
#ifdef ISC_PLATFORM_FIXIN6ISADDR
|
||||
#undef IN6_IS_ADDR_GEOGRAPHIC
|
||||
/*!
|
||||
* \brief
|
||||
* Fix UnixWare 7.1.1's broken IN6_IS_ADDR_* definitions.
|
||||
*/
|
||||
#define IN6_IS_ADDR_GEOGRAPHIC(a) (((a)->S6_un.S6_l[0] & 0xE0) == 0x80)
|
||||
#undef IN6_IS_ADDR_IPX
|
||||
#define IN6_IS_ADDR_IPX(a) (((a)->S6_un.S6_l[0] & 0xFE) == 0x04)
|
||||
#undef IN6_IS_ADDR_LINKLOCAL
|
||||
#define IN6_IS_ADDR_LINKLOCAL(a) (((a)->S6_un.S6_l[0] & 0xC0FF) == 0x80FE)
|
||||
#undef IN6_IS_ADDR_MULTICAST
|
||||
#define IN6_IS_ADDR_MULTICAST(a) (((a)->S6_un.S6_l[0] & 0xFF) == 0xFF)
|
||||
#undef IN6_IS_ADDR_NSAP
|
||||
#define IN6_IS_ADDR_NSAP(a) (((a)->S6_un.S6_l[0] & 0xFE) == 0x02)
|
||||
#undef IN6_IS_ADDR_PROVIDER
|
||||
#define IN6_IS_ADDR_PROVIDER(a) (((a)->S6_un.S6_l[0] & 0xE0) == 0x40)
|
||||
#undef IN6_IS_ADDR_SITELOCAL
|
||||
#define IN6_IS_ADDR_SITELOCAL(a) (((a)->S6_un.S6_l[0] & 0xC0FF) == 0xC0FE)
|
||||
#endif /* ISC_PLATFORM_FIXIN6ISADDR */
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDPORTT
|
||||
/*%
|
||||
* Ensure type in_port_t is defined.
|
||||
*/
|
||||
typedef uint16_t in_port_t;
|
||||
#endif
|
||||
|
||||
#ifndef MSG_TRUNC
|
||||
/*%
|
||||
* If this system does not have MSG_TRUNC (as returned from recvmsg())
|
||||
|
|
@ -393,20 +286,6 @@ isc_net_getudpportrange(int af, in_port_t *low, in_port_t *high);
|
|||
* the range.
|
||||
*/
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDNTOP
|
||||
const char *
|
||||
isc_net_ntop(int af, const void *src, char *dst, size_t size);
|
||||
#undef inet_ntop
|
||||
#define inet_ntop isc_net_ntop
|
||||
#endif
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDPTON
|
||||
int
|
||||
isc_net_pton(int af, const char *src, void *dst);
|
||||
#undef inet_pton
|
||||
#define inet_pton isc_net_pton
|
||||
#endif
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_NET_H */
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ISC_STRERROR_H
|
||||
#define ISC_STRERROR_H
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*% String Error Size */
|
||||
#define ISC_STRERRORSIZE 128
|
||||
|
||||
/*%
|
||||
* Provide a thread safe wrapper to strerror().
|
||||
*
|
||||
* Requires:
|
||||
* 'buf' to be non NULL.
|
||||
*/
|
||||
void
|
||||
isc__strerror(int num, char *buf, size_t bufsize);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_STRERROR_H */
|
||||
|
|
@ -34,7 +34,6 @@
|
|||
#include <isc/net.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/strerror.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/types.h>
|
||||
#include <isc/util.h>
|
||||
|
|
@ -62,8 +61,7 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src,
|
|||
{
|
||||
struct sockaddr_in6 *sa6;
|
||||
|
||||
#if !defined(ISC_PLATFORM_HAVEIFNAMETOINDEX) || \
|
||||
!defined(ISC_PLATFORM_HAVESCOPEID)
|
||||
#if !defined(ISC_PLATFORM_HAVEIFNAMETOINDEX)
|
||||
UNUSED(ifname);
|
||||
#endif
|
||||
|
||||
|
|
@ -81,7 +79,6 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src,
|
|||
sa6 = (struct sockaddr_in6 *)src;
|
||||
memmove(&dst->type.in6, &sa6->sin6_addr,
|
||||
sizeof(struct in6_addr));
|
||||
#ifdef ISC_PLATFORM_HAVESCOPEID
|
||||
if (sa6->sin6_scope_id != 0)
|
||||
isc_netaddr_setzone(dst, sa6->sin6_scope_id);
|
||||
else {
|
||||
|
|
@ -127,7 +124,6 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src,
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
INSIST(0);
|
||||
|
|
@ -147,13 +143,7 @@ static isc_result_t linux_if_inet6_current(isc_interfaceiter_t *);
|
|||
static void linux_if_inet6_first(isc_interfaceiter_t *iter);
|
||||
#endif
|
||||
|
||||
#if HAVE_GETIFADDRS
|
||||
#include "ifiter_getifaddrs.c"
|
||||
#elif HAVE_IFLIST_SYSCTL
|
||||
#include "ifiter_sysctl.c"
|
||||
#else
|
||||
#include "ifiter_ioctl.c"
|
||||
#endif
|
||||
|
||||
#ifdef __linux
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <isc/ipv6.h>
|
||||
|
||||
const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
|
||||
const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
|
||||
|
|
@ -32,7 +32,6 @@
|
|||
#include <isc/net.h>
|
||||
#include <isc/netdb.h>
|
||||
#include <isc/once.h>
|
||||
#include <isc/strerror.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
|
|
@ -93,23 +92,8 @@
|
|||
|
||||
#endif /* HAVE_SYSCTLBYNAME */
|
||||
|
||||
#if defined(ISC_PLATFORM_HAVEIPV6)
|
||||
# if defined(ISC_PLATFORM_NEEDIN6ADDRANY)
|
||||
const struct in6_addr isc_net_in6addrany = IN6ADDR_ANY_INIT;
|
||||
# endif
|
||||
|
||||
# if defined(ISC_PLATFORM_NEEDIN6ADDRLOOPBACK)
|
||||
const struct in6_addr isc_net_in6addrloop = IN6ADDR_LOOPBACK_INIT;
|
||||
# endif
|
||||
|
||||
# if defined(WANT_IPV6)
|
||||
static isc_once_t once_ipv6only = ISC_ONCE_INIT;
|
||||
|
||||
# if defined(ISC_PLATFORM_HAVEIN6PKTINFO)
|
||||
static isc_once_t once_ipv6pktinfo = ISC_ONCE_INIT;
|
||||
# endif
|
||||
# endif /* WANT_IPV6 */
|
||||
#endif /* ISC_PLATFORM_HAVEIPV6 */
|
||||
|
||||
#ifndef ISC_CMSG_IP_TOS
|
||||
#ifdef __APPLE__
|
||||
|
|
@ -152,7 +136,7 @@ try_proto(int domain) {
|
|||
#endif
|
||||
return (ISC_R_NOTFOUND);
|
||||
default:
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"socket() %s: %s",
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
|
|
@ -164,9 +148,6 @@ try_proto(int domain) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
#ifdef WANT_IPV6
|
||||
#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
if (domain == PF_INET6) {
|
||||
struct sockaddr_in6 sin6;
|
||||
unsigned int len;
|
||||
|
|
@ -204,9 +185,6 @@ try_proto(int domain) {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
(void)close(s);
|
||||
|
||||
|
|
@ -216,13 +194,7 @@ try_proto(int domain) {
|
|||
static void
|
||||
initialize_action(void) {
|
||||
ipv4_result = try_proto(PF_INET);
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
#ifdef WANT_IPV6
|
||||
#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
ipv6_result = try_proto(PF_INET6);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ISC_PLATFORM_HAVESYSUNH
|
||||
unix_result = try_proto(PF_UNIX);
|
||||
#endif
|
||||
|
|
@ -251,8 +223,6 @@ isc_net_probeunix(void) {
|
|||
return (unix_result);
|
||||
}
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
#ifdef WANT_IPV6
|
||||
static void
|
||||
try_ipv6only(void) {
|
||||
#ifdef IPV6_V6ONLY
|
||||
|
|
@ -274,7 +244,7 @@ try_ipv6only(void) {
|
|||
/* check for TCP sockets */
|
||||
s = socket(PF_INET6, SOCK_STREAM, 0);
|
||||
if (s == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"socket() %s: %s",
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
|
|
@ -297,7 +267,7 @@ try_ipv6only(void) {
|
|||
/* check for UDP sockets */
|
||||
s = socket(PF_INET6, SOCK_DGRAM, 0);
|
||||
if (s == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"socket() %s: %s",
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
|
|
@ -328,10 +298,7 @@ initialize_ipv6only(void) {
|
|||
RUNTIME_CHECK(isc_once_do(&once_ipv6only,
|
||||
try_ipv6only) == ISC_R_SUCCESS);
|
||||
}
|
||||
#endif /* WANT_IPV6 */
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
#ifdef WANT_IPV6
|
||||
static void
|
||||
try_ipv6pktinfo(void) {
|
||||
int s, on;
|
||||
|
|
@ -348,7 +315,7 @@ try_ipv6pktinfo(void) {
|
|||
/* we only use this for UDP sockets */
|
||||
s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (s == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"socket() %s: %s",
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
|
|
@ -383,38 +350,20 @@ initialize_ipv6pktinfo(void) {
|
|||
RUNTIME_CHECK(isc_once_do(&once_ipv6pktinfo,
|
||||
try_ipv6pktinfo) == ISC_R_SUCCESS);
|
||||
}
|
||||
#endif /* WANT_IPV6 */
|
||||
#endif /* ISC_PLATFORM_HAVEIN6PKTINFO */
|
||||
#endif /* ISC_PLATFORM_HAVEIPV6 */
|
||||
|
||||
isc_result_t
|
||||
isc_net_probe_ipv6only(void) {
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
#ifdef WANT_IPV6
|
||||
initialize_ipv6only();
|
||||
#else
|
||||
ipv6only_result = ISC_R_NOTFOUND;
|
||||
#endif
|
||||
#endif
|
||||
return (ipv6only_result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_net_probe_ipv6pktinfo(void) {
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
#ifdef WANT_IPV6
|
||||
initialize_ipv6pktinfo();
|
||||
#else
|
||||
ipv6pktinfo_result = ISC_R_NOTFOUND;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
return (ipv6pktinfo_result);
|
||||
}
|
||||
|
||||
#if ISC_CMSG_IP_TOS || \
|
||||
defined(ISC_NET_BSD44MSGHDR) && defined(IPV6_TCLASS) && defined(WANT_IPV6)
|
||||
#if ISC_CMSG_IP_TOS || defined(IPV6_TCLASS)
|
||||
|
||||
static inline ISC_SOCKADDR_LEN_T
|
||||
cmsg_len(ISC_SOCKADDR_LEN_T len) {
|
||||
|
|
@ -460,7 +409,6 @@ cmsg_space(ISC_SOCKADDR_LEN_T len) {
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef ISC_NET_BSD44MSGHDR
|
||||
/*
|
||||
* Make a fd non-blocking.
|
||||
*/
|
||||
|
|
@ -480,7 +428,7 @@ make_nonblock(int fd) {
|
|||
#endif
|
||||
|
||||
if (ret == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
#ifdef USE_FIONBIO_IOCTL
|
||||
"ioctl(%d, FIONBIO, &on): %s", fd,
|
||||
|
|
@ -512,7 +460,7 @@ cmsgsend(int s, int level, int type, struct addrinfo *res) {
|
|||
isc_result_t result;
|
||||
|
||||
if (bind(s, res->ai_addr, res->ai_addrlen) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_SOCKET, ISC_LOG_DEBUG(10),
|
||||
"bind: %s", strbuf);
|
||||
|
|
@ -520,7 +468,7 @@ cmsgsend(int s, int level, int type, struct addrinfo *res) {
|
|||
}
|
||||
|
||||
if (getsockname(s, (struct sockaddr *)&ss, &len) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_SOCKET, ISC_LOG_DEBUG(10),
|
||||
"getsockname: %s", strbuf);
|
||||
|
|
@ -583,7 +531,7 @@ cmsgsend(int s, int level, int type, struct addrinfo *res) {
|
|||
default:
|
||||
debug = ISC_LOG_NOTICE;
|
||||
}
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
if (debug != ISC_LOG_NOTICE) {
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_SOCKET, ISC_LOG_DEBUG(10),
|
||||
|
|
@ -623,7 +571,6 @@ cmsgsend(int s, int level, int type, struct addrinfo *res) {
|
|||
return (true);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static void
|
||||
try_dscp_v4(void) {
|
||||
|
|
@ -656,7 +603,7 @@ try_dscp_v4(void) {
|
|||
s = socket(res0->ai_family, res0->ai_socktype, res0->ai_protocol);
|
||||
|
||||
if (s == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_SOCKET, ISC_LOG_DEBUG(10),
|
||||
"socket: %s", strbuf);
|
||||
|
|
@ -673,15 +620,11 @@ try_dscp_v4(void) {
|
|||
dscp_result |= ISC_NET_DSCPRECVV4;
|
||||
#endif /* IP_RECVTOS */
|
||||
|
||||
#ifdef ISC_NET_BSD44MSGHDR
|
||||
|
||||
#if ISC_CMSG_IP_TOS
|
||||
if (cmsgsend(s, IPPROTO_IP, IP_TOS, res0))
|
||||
dscp_result |= ISC_NET_DSCPPKTV4;
|
||||
#endif /* ISC_CMSG_IP_TOS */
|
||||
|
||||
#endif /* ISC_NET_BSD44MSGHDR */
|
||||
|
||||
freeaddrinfo(res0);
|
||||
close(s);
|
||||
|
||||
|
|
@ -690,8 +633,6 @@ try_dscp_v4(void) {
|
|||
|
||||
static void
|
||||
try_dscp_v6(void) {
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
#ifdef WANT_IPV6
|
||||
#ifdef IPV6_TCLASS
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
struct addrinfo hints, *res0;
|
||||
|
|
@ -720,7 +661,7 @@ try_dscp_v6(void) {
|
|||
|
||||
s = socket(res0->ai_family, res0->ai_socktype, res0->ai_protocol);
|
||||
if (s == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_SOCKET, ISC_LOG_DEBUG(10),
|
||||
"socket: %s", strbuf);
|
||||
|
|
@ -736,17 +677,13 @@ try_dscp_v6(void) {
|
|||
dscp_result |= ISC_NET_DSCPRECVV6;
|
||||
#endif /* IPV6_RECVTCLASS */
|
||||
|
||||
#ifdef ISC_NET_BSD44MSGHDR
|
||||
if (cmsgsend(s, IPPROTO_IPV6, IPV6_TCLASS, res0))
|
||||
dscp_result |= ISC_NET_DSCPPKTV6;
|
||||
#endif /* ISC_NET_BSD44MSGHDR */
|
||||
|
||||
freeaddrinfo(res0);
|
||||
close(s);
|
||||
|
||||
#endif /* IPV6_TCLASS */
|
||||
#endif /* WANT_IPV6 */
|
||||
#endif /* ISC_PLATFORM_HAVEIPV6 */
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef __hpux
|
||||
static inline long
|
||||
sysconf_ncpus(void) {
|
||||
#if defined(_SC_NPROCESSORS_ONLN)
|
||||
|
|
@ -30,25 +29,8 @@ sysconf_ncpus(void) {
|
|||
return (0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_SYSCONF */
|
||||
|
||||
|
||||
#ifdef __hpux
|
||||
|
||||
#include <sys/pstat.h>
|
||||
|
||||
static inline int
|
||||
hpux_ncpus(void) {
|
||||
struct pst_dynamic psd;
|
||||
if (pstat_getdynamic(&psd, sizeof(psd), 1, 0) != -1)
|
||||
return (psd.psd_proc_cnt);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
#endif /* __hpux */
|
||||
|
||||
#if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTLBYNAME)
|
||||
#include <sys/types.h> /* for FreeBSD */
|
||||
#include <sys/param.h> /* for NetBSD */
|
||||
|
|
@ -71,9 +53,7 @@ unsigned int
|
|||
isc_os_ncpus(void) {
|
||||
long ncpus = 0;
|
||||
|
||||
#ifdef __hpux
|
||||
ncpus = hpux_ncpus();
|
||||
#elif defined(HAVE_SYSCONF)
|
||||
#if defined(HAVE_SYSCONF)
|
||||
ncpus = sysconf_ncpus();
|
||||
#endif
|
||||
#if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTLBYNAME)
|
||||
|
|
|
|||
|
|
@ -28,10 +28,6 @@
|
|||
#include <linux/fs.h> /* To get the large NR_OPEN. */
|
||||
#endif
|
||||
|
||||
#if defined(__hpux) && defined(HAVE_SYS_DYNTUNE_H)
|
||||
#include <sys/dyntune.h>
|
||||
#endif
|
||||
|
||||
#include "errno2result.h"
|
||||
|
||||
static isc_result_t
|
||||
|
|
@ -100,7 +96,7 @@ resource2rlim(isc_resource_t resource, int *rlim_resource) {
|
|||
isc_result_t
|
||||
isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value) {
|
||||
struct rlimit rl;
|
||||
ISC_PLATFORM_RLIMITTYPE rlim_value;
|
||||
rlim_t rlim_value;
|
||||
int unixresult;
|
||||
int unixresource;
|
||||
isc_result_t result;
|
||||
|
|
@ -118,17 +114,17 @@ isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value) {
|
|||
* integer so that it could contain the maximum range of
|
||||
* reasonable values. Unfortunately, this exceeds the typical
|
||||
* range on Unix systems. Ensure the range of
|
||||
* ISC_PLATFORM_RLIMITTYPE is not overflowed.
|
||||
* rlim_t is not overflowed.
|
||||
*/
|
||||
isc_resourcevalue_t rlim_max;
|
||||
bool rlim_t_is_signed =
|
||||
(((double)(ISC_PLATFORM_RLIMITTYPE)-1) < 0);
|
||||
(((double)(rlim_t)-1) < 0);
|
||||
|
||||
if (rlim_t_is_signed)
|
||||
rlim_max = ~((ISC_PLATFORM_RLIMITTYPE)1 <<
|
||||
(sizeof(ISC_PLATFORM_RLIMITTYPE) * 8 - 1));
|
||||
rlim_max = ~((rlim_t)1 <<
|
||||
(sizeof(rlim_t) * 8 - 1));
|
||||
else
|
||||
rlim_max = (ISC_PLATFORM_RLIMITTYPE)-1;
|
||||
rlim_max = (rlim_t)-1;
|
||||
|
||||
if (value > rlim_max)
|
||||
value = rlim_max;
|
||||
|
|
@ -170,16 +166,6 @@ isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value) {
|
|||
if (unixresult == 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
#elif defined(__hpux) && defined(HAVE_SYS_DYNTUNE_H)
|
||||
if (resource == isc_resource_openfiles && rlim_value == RLIM_INFINITY) {
|
||||
uint64_t maxfiles;
|
||||
if (gettune("maxfiles_lim", &maxfiles) == 0) {
|
||||
rl.rlim_cur = rl.rlim_max = maxfiles;
|
||||
unixresult = setrlimit(unixresource, &rl);
|
||||
if (unixresult == 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (resource == isc_resource_openfiles && rlim_value == RLIM_INFINITY) {
|
||||
if (getrlimit(unixresource, &rl) == 0) {
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@
|
|||
#include <isc/resource.h>
|
||||
#include <isc/socket.h>
|
||||
#include <isc/stats.h>
|
||||
#include <isc/strerror.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/thread.h>
|
||||
|
|
@ -259,11 +258,9 @@ typedef isc_event_t intev_t;
|
|||
* to collect the destination address and interface so the client can
|
||||
* set them on outgoing packets.
|
||||
*/
|
||||
#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
#ifndef USE_CMSG
|
||||
#define USE_CMSG 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*%
|
||||
* NetBSD and FreeBSD can timestamp packets. XXXMLG Should we have
|
||||
|
|
@ -295,7 +292,7 @@ typedef isc_event_t intev_t;
|
|||
* multiplied by 2, everything should fit. Those sizes are not
|
||||
* large enough to cause any concern.
|
||||
*/
|
||||
#if defined(USE_CMSG) && defined(ISC_PLATFORM_HAVEIN6PKTINFO)
|
||||
#if defined(USE_CMSG)
|
||||
#define CMSG_SP_IN6PKT 40
|
||||
#else
|
||||
#define CMSG_SP_IN6PKT 0
|
||||
|
|
@ -823,39 +820,6 @@ socket_log(isc__socket_t *sock, const isc_sockaddr_t *address,
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(_AIX) && defined(ISC_NET_BSD44MSGHDR) && \
|
||||
defined(USE_CMSG) && defined(IPV6_RECVPKTINFO)
|
||||
/*
|
||||
* AIX has a kernel bug where IPV6_RECVPKTINFO gets cleared by
|
||||
* setting IPV6_V6ONLY.
|
||||
*/
|
||||
static void
|
||||
FIX_IPV6_RECVPKTINFO(isc__socket_t *sock)
|
||||
{
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
int on = 1;
|
||||
|
||||
if (sock->pf != AF_INET6 || sock->type != isc_sockettype_udp)
|
||||
return;
|
||||
|
||||
if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_RECVPKTINFO,
|
||||
(void *)&on, sizeof(on)) < 0) {
|
||||
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, IPV6_RECVPKTINFO) "
|
||||
"%s: %s", sock->fd,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_GENERAL,
|
||||
ISC_MSG_FAILED,
|
||||
"failed"),
|
||||
strbuf);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define FIX_IPV6_RECVPKTINFO(sock) (void)0
|
||||
#endif
|
||||
|
||||
/*%
|
||||
* Increment socket-related statistics counters.
|
||||
*/
|
||||
|
|
@ -994,7 +958,7 @@ unwatch_fd(isc__socketmgr_t *manager, int fd, int msg) {
|
|||
ret = epoll_ctl(manager->epoll_fd, op, fd, &event);
|
||||
if (ret == -1 && errno != ENOENT) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"epoll_ctl(DEL), %d: %s", fd, strbuf);
|
||||
result = ISC_R_UNEXPECTED;
|
||||
|
|
@ -1142,7 +1106,7 @@ select_poke(isc__socketmgr_t *mgr, int fd, int msg) {
|
|||
} while (cc < 0 && SOFT_ERROR(errno));
|
||||
|
||||
if (cc < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
FATAL_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET,
|
||||
ISC_MSG_WRITEFAILED,
|
||||
|
|
@ -1170,7 +1134,7 @@ select_readmsg(isc__socketmgr_t *mgr, int *fd, int *msg) {
|
|||
if (SOFT_ERROR(errno))
|
||||
return;
|
||||
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
FATAL_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET,
|
||||
ISC_MSG_READFAILED,
|
||||
|
|
@ -1206,7 +1170,7 @@ make_nonblock(int fd) {
|
|||
#endif
|
||||
|
||||
if (ret == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
#ifdef USE_FIONBIO_IOCTL
|
||||
"ioctl(%d, FIONBIO, &on): %s", fd,
|
||||
|
|
@ -1279,16 +1243,12 @@ cmsg_space(ISC_SOCKADDR_LEN_T len) {
|
|||
*/
|
||||
static void
|
||||
process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
|
||||
#ifdef ISC_NET_BSD44MSGHDR
|
||||
#ifdef USE_CMSG
|
||||
struct cmsghdr *cmsgp;
|
||||
#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
struct in6_pktinfo *pktinfop;
|
||||
#endif
|
||||
#ifdef SO_TIMESTAMP
|
||||
void *timevalp;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -1301,8 +1261,6 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
|
|||
UNUSED(msg);
|
||||
UNUSED(dev);
|
||||
|
||||
#ifdef ISC_NET_BSD44MSGHDR
|
||||
|
||||
#ifdef MSG_TRUNC
|
||||
if ((msg->msg_flags & MSG_TRUNC) == MSG_TRUNC)
|
||||
dev->attributes |= ISC_SOCKEVENTATTR_TRUNC;
|
||||
|
|
@ -1322,9 +1280,7 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
|
|||
#ifdef SO_TIMESTAMP
|
||||
timevalp = NULL;
|
||||
#endif
|
||||
#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
pktinfop = NULL;
|
||||
#endif
|
||||
|
||||
cmsgp = CMSG_FIRSTHDR(msg);
|
||||
while (cmsgp != NULL) {
|
||||
|
|
@ -1332,7 +1288,6 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
|
|||
isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_PROCESSCMSG,
|
||||
"processing cmsg %p", cmsgp);
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
if (cmsgp->cmsg_level == IPPROTO_IPV6
|
||||
&& cmsgp->cmsg_type == IPV6_PKTINFO) {
|
||||
|
||||
|
|
@ -1349,7 +1304,6 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
|
|||
dev->attributes |= ISC_SOCKEVENTATTR_MULTICAST;
|
||||
goto next;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SO_TIMESTAMP
|
||||
if (cmsgp->cmsg_level == SOL_SOCKET
|
||||
|
|
@ -1391,8 +1345,6 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
|
|||
cmsgp = CMSG_NXTHDR(msg, cmsgp);
|
||||
}
|
||||
#endif /* USE_CMSG */
|
||||
|
||||
#endif /* ISC_NET_BSD44MSGHDR */
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1416,9 +1368,7 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev,
|
|||
isc_region_t used;
|
||||
size_t write_count;
|
||||
size_t skip_count;
|
||||
#ifdef ISC_NET_BSD44MSGHDR
|
||||
struct cmsghdr *cmsgp;
|
||||
#endif
|
||||
|
||||
memset(msg, 0, sizeof(*msg));
|
||||
|
||||
|
|
@ -1480,14 +1430,11 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev,
|
|||
config:
|
||||
msg->msg_iov = iov;
|
||||
msg->msg_iovlen = iovcount;
|
||||
|
||||
#ifdef ISC_NET_BSD44MSGHDR
|
||||
msg->msg_control = NULL;
|
||||
msg->msg_controllen = 0;
|
||||
msg->msg_flags = 0;
|
||||
#if defined(USE_CMSG)
|
||||
|
||||
#if defined(ISC_PLATFORM_HAVEIN6PKTINFO)
|
||||
if ((sock->type == isc_sockettype_udp) &&
|
||||
((dev->attributes & ISC_SOCKEVENTATTR_PKTINFO) != 0))
|
||||
{
|
||||
|
|
@ -1509,7 +1456,6 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev,
|
|||
pktinfop = (struct in6_pktinfo *)CMSG_DATA(cmsgp);
|
||||
memmove(pktinfop, &dev->pktinfo, sizeof(struct in6_pktinfo));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(IPV6_USE_MIN_MTU)
|
||||
if ((sock->type == isc_sockettype_udp) &&
|
||||
|
|
@ -1562,7 +1508,7 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev,
|
|||
(void *)&dscp, sizeof(int)) < 0)
|
||||
{
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, IP_TOS, %.02x)"
|
||||
" %s: %s",
|
||||
|
|
@ -1592,7 +1538,7 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev,
|
|||
if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_TCLASS,
|
||||
(void *)&dscp, sizeof(int)) < 0) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, IPV6_TCLASS, "
|
||||
"%.02x) %s: %s",
|
||||
|
|
@ -1615,10 +1561,6 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev,
|
|||
}
|
||||
#endif
|
||||
#endif /* USE_CMSG */
|
||||
#else /* ISC_NET_BSD44MSGHDR */
|
||||
msg->msg_accrights = NULL;
|
||||
msg->msg_accrightslen = 0;
|
||||
#endif /* ISC_NET_BSD44MSGHDR */
|
||||
|
||||
if (write_countp != NULL)
|
||||
*write_countp = write_count;
|
||||
|
|
@ -1649,26 +1591,8 @@ build_msghdr_recv(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
|
|||
|
||||
if (sock->type == isc_sockettype_udp) {
|
||||
memset(&dev->address, 0, sizeof(dev->address));
|
||||
#ifdef BROKEN_RECVMSG
|
||||
if (sock->pf == AF_INET) {
|
||||
msg->msg_name = (void *)&dev->address.type.sin;
|
||||
msg->msg_namelen = sizeof(dev->address.type.sin6);
|
||||
} else if (sock->pf == AF_INET6) {
|
||||
msg->msg_name = (void *)&dev->address.type.sin6;
|
||||
msg->msg_namelen = sizeof(dev->address.type.sin6);
|
||||
#ifdef ISC_PLATFORM_HAVESYSUNH
|
||||
} else if (sock->pf == AF_UNIX) {
|
||||
msg->msg_name = (void *)&dev->address.type.sunix;
|
||||
msg->msg_namelen = sizeof(dev->address.type.sunix);
|
||||
#endif
|
||||
} else {
|
||||
msg->msg_name = (void *)&dev->address.type.sa;
|
||||
msg->msg_namelen = sizeof(dev->address.type);
|
||||
}
|
||||
#else
|
||||
msg->msg_name = (void *)&dev->address.type.sa;
|
||||
msg->msg_namelen = sizeof(dev->address.type);
|
||||
#endif
|
||||
} else { /* TCP */
|
||||
msg->msg_name = NULL;
|
||||
msg->msg_namelen = 0;
|
||||
|
|
@ -1733,7 +1657,6 @@ build_msghdr_recv(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
|
|||
msg->msg_iov = iov;
|
||||
msg->msg_iovlen = iovcount;
|
||||
|
||||
#ifdef ISC_NET_BSD44MSGHDR
|
||||
#if defined(USE_CMSG)
|
||||
msg->msg_control = cmsgbuf;
|
||||
msg->msg_controllen = RECVCMSGBUFLEN;
|
||||
|
|
@ -1742,10 +1665,6 @@ build_msghdr_recv(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
|
|||
msg->msg_controllen = 0;
|
||||
#endif /* USE_CMSG */
|
||||
msg->msg_flags = 0;
|
||||
#else /* ISC_NET_BSD44MSGHDR */
|
||||
msg->msg_accrights = NULL;
|
||||
msg->msg_accrightslen = 0;
|
||||
#endif /* ISC_NET_BSD44MSGHDR */
|
||||
|
||||
if (read_countp != NULL)
|
||||
*read_countp = read_count;
|
||||
|
|
@ -1817,10 +1736,8 @@ dump_msg(struct msghdr *msg) {
|
|||
printf("\t\t%u\tbase %p, len %ld\n", i,
|
||||
msg->msg_iov[i].iov_base,
|
||||
(long) msg->msg_iov[i].iov_len);
|
||||
#ifdef ISC_NET_BSD44MSGHDR
|
||||
printf("\tcontrol %p, controllen %ld\n", msg->msg_control,
|
||||
(long) msg->msg_controllen);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1859,7 +1776,7 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) {
|
|||
return (DOIO_SOFT);
|
||||
|
||||
if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL)) {
|
||||
isc__strerror(recv_errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(recv_errno, strbuf, sizeof(strbuf));
|
||||
socket_log(sock, NULL, IOEVENT,
|
||||
isc_msgcat, ISC_MSGSET_SOCKET,
|
||||
ISC_MSG_DOIORECV,
|
||||
|
|
@ -1889,19 +1806,10 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) {
|
|||
SOFT_OR_HARD(ENETUNREACH, ISC_R_NETUNREACH);
|
||||
SOFT_OR_HARD(EHOSTUNREACH, ISC_R_HOSTUNREACH);
|
||||
SOFT_OR_HARD(EHOSTDOWN, ISC_R_HOSTDOWN);
|
||||
/* HPUX 11.11 can return EADDRNOTAVAIL. */
|
||||
SOFT_OR_HARD(EADDRNOTAVAIL, ISC_R_ADDRNOTAVAIL);
|
||||
SOFT_OR_HARD(ENOBUFS, ISC_R_NORESOURCES);
|
||||
/* Should never get this one but it was seen. */
|
||||
#ifdef ENOPROTOOPT
|
||||
SOFT_OR_HARD(ENOPROTOOPT, ISC_R_HOSTUNREACH);
|
||||
#endif
|
||||
/*
|
||||
* HPUX returns EPROTO and EINVAL on receiving some ICMP/ICMPv6
|
||||
* errors.
|
||||
*/
|
||||
#ifdef EPROTO
|
||||
SOFT_OR_HARD(EPROTO, ISC_R_HOSTUNREACH);
|
||||
#endif
|
||||
SOFT_OR_HARD(EINVAL, ISC_R_HOSTUNREACH);
|
||||
|
||||
|
|
@ -2106,7 +2014,7 @@ doio_send(isc__socket_t *sock, isc_socketevent_t *dev) {
|
|||
* a status.
|
||||
*/
|
||||
isc_sockaddr_format(&dev->address, addrbuf, sizeof(addrbuf));
|
||||
isc__strerror(send_errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(send_errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__, "internal_send: %s: %s",
|
||||
addrbuf, strbuf);
|
||||
dev->result = isc__errno2result(send_errno);
|
||||
|
|
@ -2367,7 +2275,6 @@ set_rcvbuf(void) {
|
|||
ISC_SOCKADDR_LEN_T len;
|
||||
|
||||
fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
#if defined(ISC_PLATFORM_HAVEIPV6)
|
||||
if (fd == -1) {
|
||||
switch (errno) {
|
||||
case EPROTONOSUPPORT:
|
||||
|
|
@ -2382,7 +2289,6 @@ set_rcvbuf(void) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (fd == -1)
|
||||
return;
|
||||
|
||||
|
|
@ -2606,7 +2512,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
|
|||
switch (errno) {
|
||||
case EMFILE:
|
||||
case ENFILE:
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_iwrite(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR,
|
||||
isc_msgcat, ISC_MSGSET_SOCKET,
|
||||
|
|
@ -2631,7 +2537,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
|
|||
return (ISC_R_FAMILYNOSUPPORT);
|
||||
|
||||
default:
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"%s() %s: %s", err,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
|
|
@ -2661,7 +2567,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
|
|||
if (sock->type != isc_sockettype_unix && bsdcompat &&
|
||||
setsockopt(sock->fd, SOL_SOCKET, SO_BSDCOMPAT,
|
||||
(void *)&on, sizeof(on)) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, SO_BSDCOMPAT) %s: %s",
|
||||
sock->fd,
|
||||
|
|
@ -2675,7 +2581,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
|
|||
#ifdef SO_NOSIGPIPE
|
||||
if (setsockopt(sock->fd, SOL_SOCKET, SO_NOSIGPIPE,
|
||||
(void *)&on, sizeof(on)) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, SO_NOSIGPIPE) %s: %s",
|
||||
sock->fd,
|
||||
|
|
@ -2702,7 +2608,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
|
|||
if (setsockopt(sock->fd, SOL_SOCKET, SO_TIMESTAMP,
|
||||
(void *)&on, sizeof(on)) < 0
|
||||
&& errno != ENOPROTOOPT) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, SO_TIMESTAMP) %s: %s",
|
||||
sock->fd,
|
||||
|
|
@ -2715,14 +2621,12 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
|
|||
}
|
||||
#endif /* SO_TIMESTAMP */
|
||||
|
||||
#if defined(ISC_PLATFORM_HAVEIPV6)
|
||||
#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
#ifdef IPV6_RECVPKTINFO
|
||||
/* RFC 3542 */
|
||||
if ((sock->pf == AF_INET6)
|
||||
&& (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_RECVPKTINFO,
|
||||
(void *)&on, sizeof(on)) < 0)) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, IPV6_RECVPKTINFO) "
|
||||
"%s: %s", sock->fd,
|
||||
|
|
@ -2737,7 +2641,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
|
|||
if ((sock->pf == AF_INET6)
|
||||
&& (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_PKTINFO,
|
||||
(void *)&on, sizeof(on)) < 0)) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, IPV6_PKTINFO) %s: %s",
|
||||
sock->fd,
|
||||
|
|
@ -2748,7 +2652,6 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
|
|||
strbuf);
|
||||
}
|
||||
#endif /* IPV6_RECVPKTINFO */
|
||||
#endif /* ISC_PLATFORM_HAVEIN6PKTINFO */
|
||||
#if defined(IPV6_MTU_DISCOVER) && defined(IPV6_PMTUDISC_DONT)
|
||||
/*
|
||||
* Turn off Path MTU discovery on IPv6/UDP sockets.
|
||||
|
|
@ -2760,7 +2663,6 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
|
|||
sizeof(action));
|
||||
}
|
||||
#endif
|
||||
#endif /* ISC_PLATFORM_HAVEIPV6 */
|
||||
#endif /* defined(USE_CMSG) */
|
||||
|
||||
#if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
|
||||
|
|
@ -2805,7 +2707,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
|
|||
set_rcvbuf) == ISC_R_SUCCESS);
|
||||
if (setsockopt(sock->fd, SOL_SOCKET, SO_RCVBUF,
|
||||
(void *)&rcvbuf, sizeof(rcvbuf)) == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, SO_RCVBUF, %d) %s: %s",
|
||||
sock->fd, rcvbuf,
|
||||
|
|
@ -2822,7 +2724,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
|
|||
if ((sock->pf == AF_INET6)
|
||||
&& (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_RECVTCLASS,
|
||||
(void *)&on, sizeof(on)) < 0)) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, IPV6_RECVTCLASS) "
|
||||
"%s: %s", sock->fd,
|
||||
|
|
@ -2835,7 +2737,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
|
|||
if ((sock->pf == AF_INET)
|
||||
&& (setsockopt(sock->fd, IPPROTO_IP, IP_RECVTOS,
|
||||
(void *)&on, sizeof(on)) < 0)) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, IP_RECVTOS) "
|
||||
"%s: %s", sock->fd,
|
||||
|
|
@ -3533,7 +3435,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"internal_accept: %s() %s: %s", err,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
|
|
@ -4225,7 +4127,7 @@ watcher(void *uap) {
|
|||
#endif /* USE_KQUEUE */
|
||||
|
||||
if (cc < 0 && !SOFT_ERROR(errno)) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
FATAL_ERROR(__FILE__, __LINE__,
|
||||
"%s %s: %s", fnname,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
|
|
@ -4320,7 +4222,7 @@ setup_watcher(isc_mem_t *mctx, isc__socketmgr_t *manager) {
|
|||
manager->kqueue_fd = kqueue();
|
||||
if (manager->kqueue_fd == -1) {
|
||||
result = isc__errno2result(errno);
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"kqueue %s: %s",
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
|
||||
|
|
@ -4347,7 +4249,7 @@ setup_watcher(isc_mem_t *mctx, isc__socketmgr_t *manager) {
|
|||
manager->epoll_fd = epoll_create(manager->nevents);
|
||||
if (manager->epoll_fd == -1) {
|
||||
result = isc__errno2result(errno);
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"epoll_create %s: %s",
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
|
||||
|
|
@ -4390,7 +4292,7 @@ setup_watcher(isc_mem_t *mctx, isc__socketmgr_t *manager) {
|
|||
manager->devpoll_fd = open("/dev/poll", O_RDWR);
|
||||
if (manager->devpoll_fd == -1) {
|
||||
result = isc__errno2result(errno);
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"open(/dev/poll) %s: %s",
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
|
||||
|
|
@ -4593,7 +4495,7 @@ isc__socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
|
|||
* select/poll loop when something internal needs to be done.
|
||||
*/
|
||||
if (pipe(manager->pipe_fds) != 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"pipe() %s: %s",
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
|
||||
|
|
@ -5222,7 +5124,7 @@ isc__socket_cleanunix(const isc_sockaddr_t *sockaddr, bool active) {
|
|||
|
||||
if (active) {
|
||||
if (stat(sockaddr->type.sunix.sun_path, &sb) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR,
|
||||
"isc_socket_cleanunix: stat(%s): %s",
|
||||
|
|
@ -5237,7 +5139,7 @@ isc__socket_cleanunix(const isc_sockaddr_t *sockaddr, bool active) {
|
|||
return;
|
||||
}
|
||||
if (unlink(sockaddr->type.sunix.sun_path) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR,
|
||||
"isc_socket_cleanunix: unlink(%s): %s",
|
||||
|
|
@ -5248,7 +5150,7 @@ isc__socket_cleanunix(const isc_sockaddr_t *sockaddr, bool active) {
|
|||
|
||||
s = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (s < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_SOCKET, ISC_LOG_WARNING,
|
||||
"isc_socket_cleanunix: socket(%s): %s",
|
||||
|
|
@ -5261,7 +5163,7 @@ isc__socket_cleanunix(const isc_sockaddr_t *sockaddr, bool active) {
|
|||
case ENOENT: /* We exited cleanly last time */
|
||||
break;
|
||||
default:
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_SOCKET, ISC_LOG_WARNING,
|
||||
"isc_socket_cleanunix: stat(%s): %s",
|
||||
|
|
@ -5285,7 +5187,7 @@ isc__socket_cleanunix(const isc_sockaddr_t *sockaddr, bool active) {
|
|||
case ECONNREFUSED:
|
||||
case ECONNRESET:
|
||||
if (unlink(sockaddr->type.sunix.sun_path) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_SOCKET,
|
||||
ISC_LOG_WARNING,
|
||||
|
|
@ -5296,7 +5198,7 @@ isc__socket_cleanunix(const isc_sockaddr_t *sockaddr, bool active) {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_SOCKET, ISC_LOG_WARNING,
|
||||
"isc_socket_cleanunix: connect(%s): %s",
|
||||
|
|
@ -5342,7 +5244,7 @@ isc__socket_permunix(const isc_sockaddr_t *sockaddr, uint32_t perm,
|
|||
#endif
|
||||
|
||||
if (chmod(path, perm) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR,
|
||||
"isc_socket_permunix: chmod(%s, %d): %s",
|
||||
|
|
@ -5350,7 +5252,7 @@ isc__socket_permunix(const isc_sockaddr_t *sockaddr, uint32_t perm,
|
|||
result = ISC_R_FAILURE;
|
||||
}
|
||||
if (chown(path, owner, group) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR,
|
||||
"isc_socket_permunix: chown(%s, %d, %d): %s",
|
||||
|
|
@ -5423,7 +5325,7 @@ isc__socket_bind(isc_socket_t *sock0, const isc_sockaddr_t *sockaddr,
|
|||
case EINVAL:
|
||||
return (ISC_R_BOUND);
|
||||
default:
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__, "bind: %s",
|
||||
strbuf);
|
||||
return (ISC_R_UNEXPECTED);
|
||||
|
|
@ -5463,7 +5365,7 @@ isc__socket_filter(isc_socket_t *sock0, const char *filter) {
|
|||
strlcpy(afa.af_name, filter, sizeof(afa.af_name));
|
||||
if (setsockopt(sock->fd, SOL_SOCKET, SO_ACCEPTFILTER,
|
||||
&afa, sizeof(afa)) == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
socket_log(sock, NULL, CREATION, isc_msgcat, ISC_MSGSET_SOCKET,
|
||||
ISC_MSG_FILTER, "setsockopt(SO_ACCEPTFILTER): %s",
|
||||
strbuf);
|
||||
|
|
@ -5526,7 +5428,7 @@ set_tcp_fastopen(isc__socket_t *sock, unsigned int backlog) {
|
|||
#endif
|
||||
if (setsockopt(sock->fd, IPPROTO_TCP, TCP_FASTOPEN,
|
||||
(void *)&backlog, sizeof(backlog)) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, TCP_FASTOPEN) failed with %s",
|
||||
sock->fd, strbuf);
|
||||
|
|
@ -5567,7 +5469,7 @@ isc__socket_listen(isc_socket_t *sock0, unsigned int backlog) {
|
|||
|
||||
if (listen(sock->fd, (int)backlog) < 0) {
|
||||
UNLOCK(&sock->lock);
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__, "listen: %s", strbuf);
|
||||
|
||||
|
|
@ -5719,10 +5621,14 @@ isc__socket_connect(isc_socket_t *sock0, const isc_sockaddr_t *addr,
|
|||
cc = connect(sock->fd, &addr->type.sa, addr->length);
|
||||
if (cc < 0) {
|
||||
/*
|
||||
* HP-UX "fails" to connect a UDP socket and sets errno to
|
||||
* EINPROGRESS if it's non-blocking. We'd rather regard this as
|
||||
* a success and let the user detect it if it's really an error
|
||||
* at the time of sending a packet on the socket.
|
||||
* The socket is nonblocking and the connection cannot be
|
||||
* completed immediately. It is possible to select(2) or
|
||||
* poll(2) for completion by selecting the socket for writing.
|
||||
* After select(2) indicates writability, use getsockopt(2) to
|
||||
* read the SO_ERROR option at level SOL_SOCKET to determine
|
||||
* whether connect() completed successfully (SO_ERROR is zero)
|
||||
* or unsuccessfully (SO_ERROR is one of the usual error codes
|
||||
* listed here, explaining the reason for the failure).
|
||||
*/
|
||||
if (sock->type == isc_sockettype_udp && errno == EINPROGRESS) {
|
||||
cc = 0;
|
||||
|
|
@ -5751,7 +5657,7 @@ isc__socket_connect(isc_socket_t *sock0, const isc_sockaddr_t *addr,
|
|||
|
||||
sock->connected = 0;
|
||||
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
isc_sockaddr_format(addr, addrbuf, sizeof(addrbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__, "connect(%s) %d/%s",
|
||||
addrbuf, errno, strbuf);
|
||||
|
|
@ -5913,7 +5819,7 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
|
|||
result = ISC_R_UNEXPECTED;
|
||||
isc_sockaddr_format(&sock->peer_address, peerbuf,
|
||||
sizeof(peerbuf));
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"internal_connect: connect(%s) %s",
|
||||
peerbuf, strbuf);
|
||||
|
|
@ -5978,7 +5884,7 @@ isc__socket_getsockname(isc_socket_t *sock0, isc_sockaddr_t *addressp) {
|
|||
|
||||
len = sizeof(addressp->type);
|
||||
if (getsockname(sock->fd, &addressp->type.sa, (void *)&len) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__, "getsockname: %s",
|
||||
strbuf);
|
||||
result = ISC_R_UNEXPECTED;
|
||||
|
|
@ -6157,7 +6063,7 @@ isc__socket_ipv6only(isc_socket_t *sock0, bool yes) {
|
|||
if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||
(void *)&onoff, sizeof(int)) < 0) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, IPV6_V6ONLY) "
|
||||
"%s: %s", sock->fd,
|
||||
|
|
@ -6168,7 +6074,6 @@ isc__socket_ipv6only(isc_socket_t *sock0, bool yes) {
|
|||
strbuf);
|
||||
}
|
||||
}
|
||||
FIX_IPV6_RECVPKTINFO(sock); /* AIX */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -6185,7 +6090,7 @@ setdscp(isc__socket_t *sock, isc_dscp_t dscp) {
|
|||
if (setsockopt(sock->fd, IPPROTO_IP, IP_TOS,
|
||||
(void *)&value, sizeof(value)) < 0) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, IP_TOS, %.02x) "
|
||||
"%s: %s", sock->fd, value >> 2,
|
||||
|
|
@ -6202,7 +6107,7 @@ setdscp(isc__socket_t *sock, isc_dscp_t dscp) {
|
|||
if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_TCLASS,
|
||||
(void *)&value, sizeof(value)) < 0) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, IPV6_TCLASS, %.02x) "
|
||||
"%s: %s", sock->fd, dscp >> 2,
|
||||
|
|
|
|||
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/once.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/strerror.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#ifdef HAVE_STRERROR
|
||||
/*%
|
||||
* We need to do this this way for profiled locks.
|
||||
*/
|
||||
static isc_mutex_t isc_strerror_lock;
|
||||
static void init_lock(void) {
|
||||
RUNTIME_CHECK(isc_mutex_init(&isc_strerror_lock) == ISC_R_SUCCESS);
|
||||
}
|
||||
#else
|
||||
extern const char * const sys_errlist[];
|
||||
extern const int sys_nerr;
|
||||
#endif
|
||||
|
||||
void
|
||||
isc__strerror(int num, char *buf, size_t size) {
|
||||
#ifdef HAVE_STRERROR
|
||||
char *msg;
|
||||
unsigned int unum = (unsigned int)num;
|
||||
static isc_once_t once = ISC_ONCE_INIT;
|
||||
|
||||
REQUIRE(buf != NULL);
|
||||
|
||||
RUNTIME_CHECK(isc_once_do(&once, init_lock) == ISC_R_SUCCESS);
|
||||
|
||||
LOCK(&isc_strerror_lock);
|
||||
msg = strerror(num);
|
||||
if (msg != NULL)
|
||||
snprintf(buf, size, "%s", msg);
|
||||
else
|
||||
snprintf(buf, size, "Unknown error: %u", unum);
|
||||
UNLOCK(&isc_strerror_lock);
|
||||
#else
|
||||
unsigned int unum = (unsigned int)num;
|
||||
|
||||
REQUIRE(buf != NULL);
|
||||
|
||||
if (num >= 0 && num < sys_nerr)
|
||||
snprintf(buf, size, "%s", sys_errlist[num]);
|
||||
else
|
||||
snprintf(buf, size, "Unknown error: %u", unum);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -27,7 +27,6 @@
|
|||
#include <isc/log.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/strerror.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/time.h>
|
||||
#include <isc/tm.h>
|
||||
|
|
@ -149,7 +148,7 @@ isc_time_now(isc_time_t *t) {
|
|||
REQUIRE(t != NULL);
|
||||
|
||||
if (gettimeofday(&tv, NULL) == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strbuf);
|
||||
return (ISC_R_UNEXPECTED);
|
||||
}
|
||||
|
|
@ -193,7 +192,7 @@ isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i) {
|
|||
INSIST(i->nanoseconds < NS_PER_S);
|
||||
|
||||
if (gettimeofday(&tv, NULL) == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strbuf);
|
||||
return (ISC_R_UNEXPECTED);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ isc__errno2resultx(int posixerrno, bool dolog,
|
|||
return (ISC_R_NORESOURCES);
|
||||
default:
|
||||
if (dolog) {
|
||||
isc__strerror(posixerrno, strbuf, sizeof(strbuf));
|
||||
strerror_r(posixerrno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(file, line,
|
||||
"unable to convert errno "
|
||||
"to isc_result: %d: %s",
|
||||
|
|
|
|||
|
|
@ -19,18 +19,23 @@
|
|||
#include <isc/lang.h>
|
||||
#include <isc/result.h>
|
||||
|
||||
#define ISC_DIR_NAMEMAX _MAX_FNAME
|
||||
#define ISC_DIR_PATHMAX _MAX_PATH
|
||||
#ifndef NAME_MAX
|
||||
#define NAME_MAX _MAX_FNAME
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX _MAX_PATH
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
char name[ISC_DIR_NAMEMAX];
|
||||
char name[NAME_MAX];
|
||||
unsigned int length;
|
||||
WIN32_FIND_DATA find_data;
|
||||
} isc_direntry_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned int magic;
|
||||
char dirname[ISC_DIR_PATHMAX];
|
||||
char dirname[PATH_MAX];
|
||||
isc_direntry_t entry;
|
||||
bool entry_filled;
|
||||
HANDLE search_handle;
|
||||
|
|
|
|||
|
|
@ -100,13 +100,6 @@
|
|||
#define INADDR_LOOPBACK 0x7f000001UL
|
||||
#endif
|
||||
|
||||
#ifndef ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
struct in6_pktinfo {
|
||||
struct in6_addr ipi6_addr; /* src/dst IPv6 address */
|
||||
unsigned int ipi6_ifindex; /* send/recv interface index */
|
||||
};
|
||||
#endif
|
||||
|
||||
#if _MSC_VER < 1300
|
||||
#define in6addr_any isc_in6addr_any
|
||||
#define in6addr_loopback isc_in6addr_loopback
|
||||
|
|
@ -115,9 +108,7 @@ struct in6_pktinfo {
|
|||
/*
|
||||
* Ensure type in_port_t is defined.
|
||||
*/
|
||||
#ifdef ISC_PLATFORM_NEEDPORTT
|
||||
typedef uint16_t in_port_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If this system does not have MSG_TRUNC (as returned from recvmsg())
|
||||
|
|
@ -399,19 +390,6 @@ isc_net_getudpportrange(int af, in_port_t *low, in_port_t *high);
|
|||
* the range.
|
||||
*/
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDNTOP
|
||||
const char *
|
||||
isc_net_ntop(int af, const void *src, char *dst, size_t size);
|
||||
#undef inet_ntop
|
||||
#define inet_ntop isc_net_ntop
|
||||
#endif
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDPTON
|
||||
int
|
||||
isc_net_pton(int af, const char *src, void *dst);
|
||||
#define inet_pton isc_net_pton
|
||||
#endif
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_NET_H */
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@
|
|||
#if defined(_WIN32) || defined(_WIN64)
|
||||
/* We are on Windows */
|
||||
# define strtok_r strtok_s
|
||||
# define strerror_r(errnum, buf, buflen) strerror_s(buf, buflen, errnum)
|
||||
|
||||
#define ISC_STRERRORSIZE 128
|
||||
|
||||
#ifndef strtoull
|
||||
#define strtoull _strtoui64
|
||||
|
|
@ -42,16 +45,7 @@
|
|||
#define PATH_MAX _MAX_PATH
|
||||
#endif
|
||||
|
||||
#define ISC_PLATFORM_HAVEIPV6
|
||||
#if _MSC_VER > 1200
|
||||
#define ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
#endif
|
||||
#define ISC_PLATFORM_HAVESCOPEID
|
||||
#define ISC_PLATFORM_NEEDPORTT
|
||||
#undef MSG_TRUNC
|
||||
#define ISC_PLATFORM_NEEDNTOP
|
||||
#define ISC_PLATFORM_NEEDPTON
|
||||
#define ISC_PLATFORM_HAVESOCKADDRSTORAGE
|
||||
|
||||
#define ISC_PLATFORM_NEEDSTRSEP
|
||||
#define ISC_PLATFORM_NEEDSTRLCPY
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ISC_STRERROR_H
|
||||
#define ISC_STRERROR_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
#define ISC_STRERRORSIZE 128
|
||||
|
||||
/*
|
||||
* Provide a thread safe wrapper to strerrror().
|
||||
*
|
||||
* Requires:
|
||||
* 'buf' to be non NULL.
|
||||
*/
|
||||
void
|
||||
isc__strerror(int num, char *buf, size_t bufsize);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_STRERROR_H */
|
||||
|
|
@ -141,7 +141,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
|||
error = WSAGetLastError();
|
||||
if (error == WSAEAFNOSUPPORT)
|
||||
goto inet6_only;
|
||||
isc__strerror(error, strbuf, sizeof(strbuf));
|
||||
strerror_r(error, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"making interface scan socket: %s",
|
||||
strbuf);
|
||||
|
|
@ -169,7 +169,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
|||
error = WSAGetLastError();
|
||||
if (error != WSAEFAULT && error != WSAENOBUFS) {
|
||||
errno = error;
|
||||
isc__strerror(error, strbuf, sizeof(strbuf));
|
||||
strerror_r(error, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"get interface configuration: %s",
|
||||
strbuf);
|
||||
|
|
@ -222,7 +222,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
|||
error = WSAGetLastError();
|
||||
if (error == WSAEAFNOSUPPORT)
|
||||
goto inet_only;
|
||||
isc__strerror(error, strbuf, sizeof(strbuf));
|
||||
strerror_r(error, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"making interface scan socket: %s",
|
||||
strbuf);
|
||||
|
|
@ -251,7 +251,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
|||
error = WSAGetLastError();
|
||||
if (error != WSAEFAULT && error != WSAENOBUFS) {
|
||||
errno = error;
|
||||
isc__strerror(error, strbuf, sizeof(strbuf));
|
||||
strerror_r(error, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"sio address list query: %s",
|
||||
strbuf);
|
||||
|
|
|
|||
|
|
@ -14,8 +14,5 @@
|
|||
#include <isc/net.h>
|
||||
#include <isc/platform.h>
|
||||
|
||||
LIBISC_EXTERNAL_DATA const struct in6_addr isc_in6addr_any =
|
||||
IN6ADDR_ANY_INIT;
|
||||
|
||||
LIBISC_EXTERNAL_DATA const struct in6_addr isc_in6addr_loopback =
|
||||
IN6ADDR_LOOPBACK_INIT;
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ isc__socketmgr_destroy
|
|||
isc__socketmgr_getmaxsockets
|
||||
isc__socketmgr_setreserved
|
||||
isc__socketmgr_setstats
|
||||
isc__strerror
|
||||
isc__task_getname
|
||||
isc__task_gettag
|
||||
isc__task_unsendrange
|
||||
|
|
|
|||
|
|
@ -40,10 +40,6 @@
|
|||
#define ISC_NET_PORTRANGEHIGH 65535
|
||||
#endif /* ISC_NET_PORTRANGEHIGH */
|
||||
|
||||
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRANY)
|
||||
const struct in6_addr isc_net_in6addrany = IN6ADDR_ANY_INIT;
|
||||
#endif
|
||||
|
||||
static isc_once_t once = ISC_ONCE_INIT;
|
||||
static isc_once_t once_ipv6only = ISC_ONCE_INIT;
|
||||
static isc_once_t once_ipv6pktinfo = ISC_ONCE_INIT;
|
||||
|
|
@ -69,7 +65,7 @@ try_proto(int domain) {
|
|||
case WSAEINVAL:
|
||||
return (ISC_R_NOTFOUND);
|
||||
default:
|
||||
isc__strerror(errval, strbuf, sizeof(strbuf));
|
||||
strerror_r(errval, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"socket() %s: %s",
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
|
|
@ -90,13 +86,7 @@ static void
|
|||
initialize_action(void) {
|
||||
InitSockets();
|
||||
ipv4_result = try_proto(PF_INET);
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
#ifdef WANT_IPV6
|
||||
#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
ipv6_result = try_proto(PF_INET6);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -121,8 +111,6 @@ isc_net_probeunix(void) {
|
|||
return (ISC_R_NOTFOUND);
|
||||
}
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
#ifdef WANT_IPV6
|
||||
static void
|
||||
try_ipv6only(void) {
|
||||
#ifdef IPV6_V6ONLY
|
||||
|
|
@ -145,7 +133,7 @@ try_ipv6only(void) {
|
|||
/* check for TCP sockets */
|
||||
s = socket(PF_INET6, SOCK_STREAM, 0);
|
||||
if (s == INVALID_SOCKET) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"socket() %s: %s",
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
|
|
@ -169,7 +157,7 @@ try_ipv6only(void) {
|
|||
/* check for UDP sockets */
|
||||
s = socket(PF_INET6, SOCK_DGRAM, 0);
|
||||
if (s == INVALID_SOCKET) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"socket() %s: %s",
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
|
|
@ -225,7 +213,7 @@ try_ipv6pktinfo(void) {
|
|||
/* we only use this for UDP sockets */
|
||||
s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (s == INVALID_SOCKET) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"socket() %s: %s",
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
|
|
@ -262,31 +250,17 @@ initialize_ipv6pktinfo(void) {
|
|||
try_ipv6pktinfo) == ISC_R_SUCCESS);
|
||||
}
|
||||
#endif /* __notyet__ */
|
||||
#endif /* WANT_IPV6 */
|
||||
#endif /* ISC_PLATFORM_HAVEIPV6 */
|
||||
|
||||
isc_result_t
|
||||
isc_net_probe_ipv6only(void) {
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
#ifdef WANT_IPV6
|
||||
initialize_ipv6only();
|
||||
#else
|
||||
ipv6only_result = ISC_R_NOTFOUND;
|
||||
#endif
|
||||
#endif
|
||||
return (ipv6only_result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_net_probe_ipv6pktinfo(void) {
|
||||
#ifdef __notyet__
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
#ifdef WANT_IPV6
|
||||
initialize_ipv6pktinfo();
|
||||
#else
|
||||
ipv6pktinfo_result = ISC_R_NOTFOUND;
|
||||
#endif
|
||||
#endif
|
||||
#endif /* __notyet__ */
|
||||
return (ipv6pktinfo_result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,11 +188,9 @@ enum {
|
|||
* to collect the destination address and interface so the client can
|
||||
* set them on outgoing packets.
|
||||
*/
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
#ifndef USE_CMSG
|
||||
#define USE_CMSG 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We really don't want to try and use these control messages. Win32
|
||||
|
|
@ -463,7 +461,7 @@ signal_iocompletionport_exit(isc_socketmgr_t *manager) {
|
|||
if (!PostQueuedCompletionStatus(manager->hIoCompletionPort,
|
||||
0, 0, 0)) {
|
||||
errval = GetLastError();
|
||||
isc__strerror(errval, strbuf, sizeof(strbuf));
|
||||
strerror_r(errval, strbuf, sizeof(strbuf));
|
||||
FATAL_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET,
|
||||
ISC_MSG_FAILED,
|
||||
|
|
@ -493,7 +491,7 @@ iocompletionport_createthreads(int total_threads, isc_socketmgr_t *manager) {
|
|||
&manager->dwIOCPThreadIds[i]);
|
||||
if (manager->hIOCPThreads[i] == NULL) {
|
||||
errval = GetLastError();
|
||||
isc__strerror(errval, strbuf, sizeof(strbuf));
|
||||
strerror_r(errval, strbuf, sizeof(strbuf));
|
||||
FATAL_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET,
|
||||
ISC_MSG_FAILED,
|
||||
|
|
@ -519,7 +517,7 @@ iocompletionport_init(isc_socketmgr_t *manager) {
|
|||
hHeapHandle = HeapCreate(0, 10 * sizeof(IoCompletionInfo), 0);
|
||||
if (hHeapHandle == NULL) {
|
||||
errval = GetLastError();
|
||||
isc__strerror(errval, strbuf, sizeof(strbuf));
|
||||
strerror_r(errval, strbuf, sizeof(strbuf));
|
||||
FATAL_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET,
|
||||
ISC_MSG_FAILED,
|
||||
|
|
@ -536,7 +534,7 @@ iocompletionport_init(isc_socketmgr_t *manager) {
|
|||
0, manager->maxIOCPThreads);
|
||||
if (manager->hIoCompletionPort == NULL) {
|
||||
errval = GetLastError();
|
||||
isc__strerror(errval, strbuf, sizeof(strbuf));
|
||||
strerror_r(errval, strbuf, sizeof(strbuf));
|
||||
FATAL_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET,
|
||||
ISC_MSG_FAILED,
|
||||
|
|
@ -567,7 +565,7 @@ iocompletionport_update(isc_socket_t *sock) {
|
|||
|
||||
if (hiocp == NULL) {
|
||||
DWORD errval = GetLastError();
|
||||
isc__strerror(errval, strbuf, sizeof(strbuf));
|
||||
strerror_r(errval, strbuf, sizeof(strbuf));
|
||||
isc_log_iwrite(isc_lctx,
|
||||
ISC_LOGCATEGORY_GENERAL,
|
||||
ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR,
|
||||
|
|
@ -633,7 +631,7 @@ initialise(void) {
|
|||
err = WSAStartup(wVersionRequested, &wsaData);
|
||||
if (err != 0) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc__strerror(err, strbuf, sizeof(strbuf));
|
||||
strerror_r(err, strbuf, sizeof(strbuf));
|
||||
FATAL_ERROR(__FILE__, __LINE__, "WSAStartup() %s: %s",
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
|
||||
ISC_MSG_FAILED, "failed"),
|
||||
|
|
@ -900,7 +898,7 @@ make_nonblock(SOCKET fd) {
|
|||
ret = ioctlsocket(fd, FIONBIO, &flags);
|
||||
|
||||
if (ret == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"ioctlsocket(%d, FIOBIO, %d): %s",
|
||||
fd, flags, strbuf);
|
||||
|
|
@ -1218,7 +1216,7 @@ map_socket_error(isc_socket_t *sock, int windows_errno, int *isc_errno,
|
|||
break;
|
||||
}
|
||||
if (doreturn == DOIO_HARD) {
|
||||
isc__strerror(windows_errno, errorstring, bufsize);
|
||||
strerror_r(windows_errno, errorstring, bufsize);
|
||||
}
|
||||
return (doreturn);
|
||||
}
|
||||
|
|
@ -1412,7 +1410,7 @@ startio_send(isc_socket_t *sock, isc_socketevent_t *dev, int *nbytes,
|
|||
* If we got this far then something is wrong
|
||||
*/
|
||||
if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL)) {
|
||||
isc__strerror(*send_errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(*send_errno, strbuf, sizeof(strbuf));
|
||||
socket_log(__LINE__, sock, NULL, IOEVENT,
|
||||
isc_msgcat, ISC_MSGSET_SOCKET,
|
||||
ISC_MSG_INTERNALSEND,
|
||||
|
|
@ -1721,7 +1719,7 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
|
|||
return (ISC_R_FAMILYNOSUPPORT);
|
||||
|
||||
default:
|
||||
isc__strerror(socket_errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(socket_errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"socket() %s: %s",
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
|
|
@ -1754,13 +1752,12 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
|
|||
if (type == isc_sockettype_udp) {
|
||||
|
||||
#if defined(USE_CMSG)
|
||||
#if defined(ISC_PLATFORM_HAVEIPV6)
|
||||
#ifdef IPV6_RECVPKTINFO
|
||||
/* 2292bis */
|
||||
if ((pf == AF_INET6)
|
||||
&& (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_RECVPKTINFO,
|
||||
(char *)&on, sizeof(on)) < 0)) {
|
||||
isc__strerror(WSAGetLastError(), strbuf, sizeof(strbuf));
|
||||
strerror_r(WSAGetLastError(), strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, IPV6_RECVPKTINFO) "
|
||||
"%s: %s", sock->fd,
|
||||
|
|
@ -1775,7 +1772,7 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
|
|||
if ((pf == AF_INET6)
|
||||
&& (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_PKTINFO,
|
||||
(char *)&on, sizeof(on)) < 0)) {
|
||||
isc__strerror(WSAGetLastError(), strbuf, sizeof(strbuf));
|
||||
strerror_r(WSAGetLastError(), strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, IPV6_PKTINFO) %s: %s",
|
||||
sock->fd,
|
||||
|
|
@ -1786,7 +1783,6 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
|
|||
strbuf);
|
||||
}
|
||||
#endif /* IPV6_RECVPKTINFO */
|
||||
#endif /* ISC_PLATFORM_HAVEIPV6 */
|
||||
#endif /* defined(USE_CMSG) */
|
||||
|
||||
#if defined(SO_RCVBUF)
|
||||
|
|
@ -2198,7 +2194,7 @@ internal_connect(isc_socket_t *sock, IoCompletionInfo *lpo, int connect_errno) {
|
|||
#undef ERROR_MATCH
|
||||
default:
|
||||
result = ISC_R_UNEXPECTED;
|
||||
isc__strerror(connect_errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(connect_errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"internal_connect: connect() %s",
|
||||
strbuf);
|
||||
|
|
@ -2490,7 +2486,7 @@ SocketIoThread(LPVOID ThreadContext) {
|
|||
if (!SetThreadPriority(GetCurrentThread(),
|
||||
THREAD_PRIORITY_ABOVE_NORMAL)) {
|
||||
errval = GetLastError();
|
||||
isc__strerror(errval, strbuf, sizeof(strbuf));
|
||||
strerror_r(errval, strbuf, sizeof(strbuf));
|
||||
FATAL_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET,
|
||||
ISC_MSG_FAILED,
|
||||
|
|
@ -3285,7 +3281,7 @@ isc__socket_bind(isc_socket_t *sock, const isc_sockaddr_t *sockaddr,
|
|||
case WSAEINVAL:
|
||||
return (ISC_R_BOUND);
|
||||
default:
|
||||
isc__strerror(bind_errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(bind_errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__, "bind: %s",
|
||||
strbuf);
|
||||
return (ISC_R_UNEXPECTED);
|
||||
|
|
@ -3348,7 +3344,7 @@ isc__socket_listen(isc_socket_t *sock, unsigned int backlog) {
|
|||
|
||||
if (listen(sock->fd, (int)backlog) < 0) {
|
||||
UNLOCK(&sock->lock);
|
||||
isc__strerror(WSAGetLastError(), strbuf, sizeof(strbuf));
|
||||
strerror_r(WSAGetLastError(), strbuf, sizeof(strbuf));
|
||||
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__, "listen: %s", strbuf);
|
||||
|
||||
|
|
@ -3358,7 +3354,7 @@ isc__socket_listen(isc_socket_t *sock, unsigned int backlog) {
|
|||
#if defined(ISC_PLATFORM_HAVETFO) && defined(TCP_FASTOPEN)
|
||||
if (setsockopt(sock->fd, IPPROTO_TCP, TCP_FASTOPEN,
|
||||
&on, sizeof(on)) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, TCP_FASTOPEN) failed with %s",
|
||||
sock->fd, strbuf);
|
||||
|
|
@ -3550,7 +3546,7 @@ isc__socket_connect(isc_socket_t *sock, const isc_sockaddr_t *addr,
|
|||
case WSAEINVAL:
|
||||
return (ISC_R_BOUND);
|
||||
default:
|
||||
isc__strerror(bind_errno, strbuf,
|
||||
strerror_r(bind_errno, strbuf,
|
||||
sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"bind: %s", strbuf);
|
||||
|
|
@ -3686,7 +3682,7 @@ isc__socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) {
|
|||
|
||||
len = sizeof(addressp->type);
|
||||
if (getsockname(sock->fd, &addressp->type.sa, (void *)&len) < 0) {
|
||||
isc__strerror(WSAGetLastError(), strbuf, sizeof(strbuf));
|
||||
strerror_r(WSAGetLastError(), strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__, "getsockname: %s",
|
||||
strbuf);
|
||||
result = ISC_R_UNEXPECTED;
|
||||
|
|
|
|||
|
|
@ -1,452 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <winsock2.h>
|
||||
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/once.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/strerror.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
/*
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
char *
|
||||
FormatError(int error);
|
||||
|
||||
char *
|
||||
GetWSAErrorMessage(int errval);
|
||||
|
||||
char *
|
||||
NTstrerror(int err, BOOL *bfreebuf);
|
||||
|
||||
/*
|
||||
* We need to do this this way for profiled locks.
|
||||
*/
|
||||
|
||||
static isc_mutex_t isc_strerror_lock;
|
||||
static void init_lock(void) {
|
||||
RUNTIME_CHECK(isc_mutex_init(&isc_strerror_lock) == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine needs to free up any buffer allocated by FormatMessage
|
||||
* if that routine gets used.
|
||||
*/
|
||||
|
||||
void
|
||||
isc__strerror(int num, char *buf, size_t size) {
|
||||
char *msg;
|
||||
BOOL freebuf;
|
||||
unsigned int unum = num;
|
||||
static isc_once_t once = ISC_ONCE_INIT;
|
||||
|
||||
REQUIRE(buf != NULL);
|
||||
|
||||
RUNTIME_CHECK(isc_once_do(&once, init_lock) == ISC_R_SUCCESS);
|
||||
|
||||
LOCK(&isc_strerror_lock);
|
||||
freebuf = FALSE;
|
||||
msg = NTstrerror(num, &freebuf);
|
||||
if (msg != NULL)
|
||||
snprintf(buf, size, "%s", msg);
|
||||
else
|
||||
snprintf(buf, size, "Unknown error: %u", unum);
|
||||
if(freebuf && msg != NULL) {
|
||||
LocalFree(msg);
|
||||
}
|
||||
UNLOCK(&isc_strerror_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* Note this will cause a memory leak unless the memory allocated here
|
||||
* is freed by calling LocalFree. isc__strerror does this before unlocking.
|
||||
* This only gets called if there is a system type of error and will likely
|
||||
* be an unusual event.
|
||||
*/
|
||||
char *
|
||||
FormatError(int error) {
|
||||
LPVOID lpMsgBuf = NULL;
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
error,
|
||||
/* Default language */
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
return (lpMsgBuf);
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine checks the error value and calls the WSA Windows Sockets
|
||||
* Error message function GetWSAErrorMessage below if it's within that range
|
||||
* since those messages are not available in the system error messages.
|
||||
*/
|
||||
char *
|
||||
NTstrerror(int err, BOOL *bfreebuf) {
|
||||
char *retmsg = NULL;
|
||||
|
||||
/* Copy the error value first in case of other errors */
|
||||
DWORD errval = err;
|
||||
|
||||
*bfreebuf = FALSE;
|
||||
|
||||
/* Get the Winsock2 error messages */
|
||||
if (errval >= WSABASEERR && errval <= (WSABASEERR + 1015)) {
|
||||
retmsg = GetWSAErrorMessage(errval);
|
||||
if (retmsg != NULL)
|
||||
return (retmsg);
|
||||
}
|
||||
/*
|
||||
* If it's not one of the standard Unix error codes,
|
||||
* try a system error message
|
||||
*/
|
||||
if (errval > (DWORD) _sys_nerr) {
|
||||
*bfreebuf = TRUE;
|
||||
return (FormatError(errval));
|
||||
} else {
|
||||
return (strerror(errval));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a replacement for perror
|
||||
*/
|
||||
void __cdecl
|
||||
NTperror(char *errmsg) {
|
||||
/* Copy the error value first in case of other errors */
|
||||
int errval = errno;
|
||||
BOOL bfreebuf = FALSE;
|
||||
char *msg;
|
||||
|
||||
msg = NTstrerror(errval, &bfreebuf);
|
||||
fprintf(stderr, "%s: %s\n", errmsg, msg);
|
||||
if(bfreebuf == TRUE) {
|
||||
LocalFree(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the error string related to Winsock2 errors.
|
||||
* This function is necessary since FormatMessage knows nothing about them
|
||||
* and there is no function to get them.
|
||||
*/
|
||||
char *
|
||||
GetWSAErrorMessage(int errval) {
|
||||
char *msg;
|
||||
|
||||
switch (errval) {
|
||||
|
||||
case WSAEINTR:
|
||||
msg = "Interrupted system call";
|
||||
break;
|
||||
|
||||
case WSAEBADF:
|
||||
msg = "Bad file number";
|
||||
break;
|
||||
|
||||
case WSAEACCES:
|
||||
msg = "Permission denied";
|
||||
break;
|
||||
|
||||
case WSAEFAULT:
|
||||
msg = "Bad address";
|
||||
break;
|
||||
|
||||
case WSAEINVAL:
|
||||
msg = "Invalid argument";
|
||||
break;
|
||||
|
||||
case WSAEMFILE:
|
||||
msg = "Too many open sockets";
|
||||
break;
|
||||
|
||||
case WSAEWOULDBLOCK:
|
||||
msg = "Operation would block";
|
||||
break;
|
||||
|
||||
case WSAEINPROGRESS:
|
||||
msg = "Operation now in progress";
|
||||
break;
|
||||
|
||||
case WSAEALREADY:
|
||||
msg = "Operation already in progress";
|
||||
break;
|
||||
|
||||
case WSAENOTSOCK:
|
||||
msg = "Socket operation on non-socket";
|
||||
break;
|
||||
|
||||
case WSAEDESTADDRREQ:
|
||||
msg = "Destination address required";
|
||||
break;
|
||||
|
||||
case WSAEMSGSIZE:
|
||||
msg = "Message too long";
|
||||
break;
|
||||
|
||||
case WSAEPROTOTYPE:
|
||||
msg = "Protocol wrong type for socket";
|
||||
break;
|
||||
|
||||
case WSAENOPROTOOPT:
|
||||
msg = "Bad protocol option";
|
||||
break;
|
||||
|
||||
case WSAEPROTONOSUPPORT:
|
||||
msg = "Protocol not supported";
|
||||
break;
|
||||
|
||||
case WSAESOCKTNOSUPPORT:
|
||||
msg = "Socket type not supported";
|
||||
break;
|
||||
|
||||
case WSAEOPNOTSUPP:
|
||||
msg = "Operation not supported on socket";
|
||||
break;
|
||||
|
||||
case WSAEPFNOSUPPORT:
|
||||
msg = "Protocol family not supported";
|
||||
break;
|
||||
|
||||
case WSAEAFNOSUPPORT:
|
||||
msg = "Address family not supported";
|
||||
break;
|
||||
|
||||
case WSAEADDRINUSE:
|
||||
msg = "Address already in use";
|
||||
break;
|
||||
|
||||
case WSAEADDRNOTAVAIL:
|
||||
msg = "Can't assign requested address";
|
||||
break;
|
||||
|
||||
case WSAENETDOWN:
|
||||
msg = "Network is down";
|
||||
break;
|
||||
|
||||
case WSAENETUNREACH:
|
||||
msg = "Network is unreachable";
|
||||
break;
|
||||
|
||||
case WSAENETRESET:
|
||||
msg = "Net connection reset";
|
||||
break;
|
||||
|
||||
case WSAECONNABORTED:
|
||||
msg = "Software caused connection abort";
|
||||
break;
|
||||
|
||||
case WSAECONNRESET:
|
||||
msg = "Connection reset by peer";
|
||||
break;
|
||||
|
||||
case WSAENOBUFS:
|
||||
msg = "No buffer space available";
|
||||
break;
|
||||
|
||||
case WSAEISCONN:
|
||||
msg = "Socket is already connected";
|
||||
break;
|
||||
|
||||
case WSAENOTCONN:
|
||||
msg = "Socket is not connected";
|
||||
break;
|
||||
|
||||
case WSAESHUTDOWN:
|
||||
msg = "Can't send after socket shutdown";
|
||||
break;
|
||||
|
||||
case WSAETOOMANYREFS:
|
||||
msg = "Too many references: can't splice";
|
||||
break;
|
||||
|
||||
case WSAETIMEDOUT:
|
||||
msg = "Connection timed out";
|
||||
break;
|
||||
|
||||
case WSAECONNREFUSED:
|
||||
msg = "Connection refused";
|
||||
break;
|
||||
|
||||
case WSAELOOP:
|
||||
msg = "Too many levels of symbolic links";
|
||||
break;
|
||||
|
||||
case WSAENAMETOOLONG:
|
||||
msg = "File name too long";
|
||||
break;
|
||||
|
||||
case WSAEHOSTDOWN:
|
||||
msg = "Host is down";
|
||||
break;
|
||||
|
||||
case WSAEHOSTUNREACH:
|
||||
msg = "No route to host";
|
||||
break;
|
||||
|
||||
case WSAENOTEMPTY:
|
||||
msg = "Directory not empty";
|
||||
break;
|
||||
|
||||
case WSAEPROCLIM:
|
||||
msg = "Too many processes";
|
||||
break;
|
||||
|
||||
case WSAEUSERS:
|
||||
msg = "Too many users";
|
||||
break;
|
||||
|
||||
case WSAEDQUOT:
|
||||
msg = "Disc quota exceeded";
|
||||
break;
|
||||
|
||||
case WSAESTALE:
|
||||
msg = "Stale NFS file handle";
|
||||
break;
|
||||
|
||||
case WSAEREMOTE:
|
||||
msg = "Too many levels of remote in path";
|
||||
break;
|
||||
|
||||
case WSASYSNOTREADY:
|
||||
msg = "Network system is unavailable";
|
||||
break;
|
||||
|
||||
case WSAVERNOTSUPPORTED:
|
||||
msg = "Winsock version out of range";
|
||||
break;
|
||||
|
||||
case WSANOTINITIALISED:
|
||||
msg = "WSAStartup not yet called";
|
||||
break;
|
||||
|
||||
case WSAEDISCON:
|
||||
msg = "Graceful shutdown in progress";
|
||||
break;
|
||||
/*
|
||||
case WSAHOST_NOT_FOUND:
|
||||
msg = "Host not found";
|
||||
break;
|
||||
|
||||
case WSANO_DATA:
|
||||
msg = "No host data of that type was found";
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
msg = NULL;
|
||||
break;
|
||||
}
|
||||
return (msg);
|
||||
}
|
||||
|
||||
/*
|
||||
* These error messages are more informative about CryptAPI Errors than the
|
||||
* standard error messages
|
||||
*/
|
||||
|
||||
char *
|
||||
GetCryptErrorMessage(int errval) {
|
||||
char *msg;
|
||||
|
||||
switch (errval) {
|
||||
|
||||
case NTE_BAD_FLAGS:
|
||||
msg = "The dwFlags parameter has an illegal value.";
|
||||
break;
|
||||
case NTE_BAD_KEYSET:
|
||||
msg = "The Registry entry for the key container "
|
||||
"could not be opened and may not exist.";
|
||||
break;
|
||||
case NTE_BAD_KEYSET_PARAM:
|
||||
msg = "The pszContainer or pszProvider parameter "
|
||||
"is set to an illegal value.";
|
||||
break;
|
||||
case NTE_BAD_PROV_TYPE:
|
||||
msg = "The value of the dwProvType parameter is out "
|
||||
"of range. All provider types must be from "
|
||||
"1 to 999, inclusive.";
|
||||
break;
|
||||
case NTE_BAD_SIGNATURE:
|
||||
msg = "The provider DLL signature did not verify "
|
||||
"correctly. Either the DLL or the digital "
|
||||
"signature has been tampered with.";
|
||||
break;
|
||||
case NTE_EXISTS:
|
||||
msg = "The dwFlags parameter is CRYPT_NEWKEYSET, but the key"
|
||||
" container already exists.";
|
||||
break;
|
||||
case NTE_KEYSET_ENTRY_BAD:
|
||||
msg = "The Registry entry for the pszContainer key container "
|
||||
"was found (in the HKEY_CURRENT_USER window), but is "
|
||||
"corrupt. See the section System Administration for "
|
||||
" etails about CryptoAPI's Registry usage.";
|
||||
break;
|
||||
case NTE_KEYSET_NOT_DEF:
|
||||
msg = "No Registry entry exists in the HKEY_CURRENT_USER "
|
||||
"window for the key container specified by "
|
||||
"pszContainer.";
|
||||
break;
|
||||
case NTE_NO_MEMORY:
|
||||
msg = "The CSP ran out of memory during the operation.";
|
||||
break;
|
||||
case NTE_PROV_DLL_NOT_FOUND:
|
||||
msg = "The provider DLL file does not exist or is not on the "
|
||||
"current path.";
|
||||
break;
|
||||
case NTE_PROV_TYPE_ENTRY_BAD:
|
||||
msg = "The Registry entry for the provider type specified by "
|
||||
"dwProvType is corrupt. This error may relate to "
|
||||
"either the user default CSP list or the machine "
|
||||
"default CSP list. See the section System "
|
||||
"Administration for details about CryptoAPI's "
|
||||
"Registry usage.";
|
||||
break;
|
||||
case NTE_PROV_TYPE_NO_MATCH:
|
||||
msg = "The provider type specified by dwProvType does not "
|
||||
"match the provider type found in the Registry. Note "
|
||||
"that this error can only occur when pszProvider "
|
||||
"specifies an actual CSP name.";
|
||||
break;
|
||||
case NTE_PROV_TYPE_NOT_DEF:
|
||||
msg = "No Registry entry exists for the provider type "
|
||||
"specified by dwProvType.";
|
||||
break;
|
||||
case NTE_PROVIDER_DLL_FAIL:
|
||||
msg = "The provider DLL file could not be loaded, and "
|
||||
"may not exist. If it exists, then the file is "
|
||||
"not a valid DLL.";
|
||||
break;
|
||||
case NTE_SIGNATURE_FILE_BAD:
|
||||
msg = "An error occurred while loading the DLL file image, "
|
||||
"prior to verifying its signature.";
|
||||
break;
|
||||
|
||||
default:
|
||||
msg = NULL;
|
||||
break;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue