diff --git a/src/kits/network/old/Jamfile b/src/kits/network/old/Jamfile deleted file mode 100644 index 57409fe3ab..0000000000 --- a/src/kits/network/old/Jamfile +++ /dev/null @@ -1,8 +0,0 @@ -SubDir HAIKU_TOP src kits network ; - -Package haiku-networkingkit-cvs : - README.html install.sh -; - -SubInclude HAIKU_TOP src kits network compat ; -SubInclude HAIKU_TOP src kits network libnetwork ; diff --git a/src/kits/network/old/README.html b/src/kits/network/old/README.html deleted file mode 100644 index 9f35fa75fd..0000000000 --- a/src/kits/network/old/README.html +++ /dev/null @@ -1,62 +0,0 @@ - -Haiku Networking Kit Package - -

Haiku Networking Kit Package

- -

About

-This package was created to allow BeOS users to have the latest version of the Haiku Networking Kit, without having to compile it themselves. This also lets BeOS users take advantage of bug fixes and new features without having to wait for the next beta release of the Networking Kit. -

-However, because this package is made from the latest sources, experimental and unstable features may be present. Such features may cause some programs to behave abnormally. -

-USE AT YOUR OWN RISK. - -

Included Files

-Currently, this package is intended to contain the Haiku Networking Kit and all of the Haiku network drivers. This may change in the future. -

-Files:
- - -boot/home/config/lib/libnet.so
-boot/home/config/lib/libnetapi.so
-boot/home/config/lib/libsocket.so
-boot/home/config/lib/libbind.so
-boot/home/config/add-ons/kernel/drivers/bin/net_stack_driver
-boot/home/config/add-ons/kernel/drivers/bin/net_server_driver
-boot/home/config/add-ons/kernel/drivers/bin/sis900
-boot/home/config/add-ons/kernel/drivers/bin/rtl8139
-boot/home/config/add-ons/kernel/drivers/bin/rtl8169
-boot/home/config/add-ons/kernel/drivers/bin/via-rhine
-boot/home/config/add-ons/kernel/drivers/bin/wb840
-boot/home/config/add-ons/kernel/drivers/bin/ipro1000
-boot/home/config/add-ons/kernel/drivers/dev/net/net_stack_driver (link)
-boot/home/config/add-ons/kernel/drivers/dev/net/net_server_driver (link)
-boot/home/config/add-ons/kernel/drivers/dev/net/sis900 (link)
-boot/home/config/add-ons/kernel/drivers/dev/net/rtl8139 (link)
-boot/home/config/add-ons/kernel/drivers/dev/net/rtl8169 (link)
-boot/home/config/add-ons/kernel/drivers/dev/net/via-rhine (link)
-boot/home/config/add-ons/kernel/drivers/dev/net/wb840 (link)
-boot/home/config/add-ons/kernel/drivers/dev/net/ipro1000 (link)
-boot/home/config/add-ons/kernel/obos_network/core
-boot/home/config/add-ons/kernel/obos_network/interfaces/ether_drivers
-boot/home/config/add-ons/kernel/obos_network/interfaces/loopback
-boot/home/config/add-ons/kernel/obos_network/interfaces/ppp
-boot/home/config/add-ons/kernel/obos_network/ppp/ipcp
-boot/home/config/add-ons/kernel/obos_network/ppp/modem
-boot/home/config/add-ons/kernel/obos_network/ppp/pap
-boot/home/config/add-ons/kernel/obos_network/ppp/pppoe
-boot/home/config/add-ons/kernel/obos_network/protocols/icmp
-boot/home/config/add-ons/kernel/obos_network/protocols/ipv4
-boot/home/config/add-ons/kernel/obos_network/protocols/raw
-boot/home/config/add-ons/kernel/obos_network/protocols/route
-boot/home/config/add-ons/kernel/obos_network/protocols/tcp
-boot/home/config/add-ons/kernel/obos_network/protocols/udp
- -

Installing

-To install this package, simply double-click on the install.sh script. The install process WILL NOT change any of the system files. Because the files are copied to under the home folder, they will be loaded instead of the BeOS system files. - -

Bugs

-As always, if you find a bug with the Networking Kit, please e-mail me at phoudoin <@t> users | sourceforge | net. Please include the date of the package in your e-mail so I know which version of the files you are seeing bugs with. - - - - diff --git a/src/kits/network/old/compat/Jamfile b/src/kits/network/old/compat/Jamfile deleted file mode 100644 index 6255a437b2..0000000000 --- a/src/kits/network/old/compat/Jamfile +++ /dev/null @@ -1,6 +0,0 @@ -SubDir HAIKU_TOP src kits network compat ; - -SubInclude HAIKU_TOP src kits network compat libbind ; -SubInclude HAIKU_TOP src kits network compat libnet ; -SubInclude HAIKU_TOP src kits network compat libnetapi ; -SubInclude HAIKU_TOP src kits network compat libsocket ; diff --git a/src/kits/network/old/compat/libbind/DEVNOTES b/src/kits/network/old/compat/libbind/DEVNOTES deleted file mode 100644 index 1d30df8c92..0000000000 --- a/src/kits/network/old/compat/libbind/DEVNOTES +++ /dev/null @@ -1,9 +0,0 @@ -See libnetwork/dns/DEVNOTES for general notes. This file contains information about the legacy libbind.so. - -This folder and the headers folder contained within override the respective libnetwork/dns folder. Additionally, the legacy headers override the default posix headers. - -The src folder is imported for sources. Currently, it is empty. - -You may import files from Haiku's libroot.so if funtionality is missing. - -libbind.so links against libnet.so because it needs gethostname() on non-Haiku targets. diff --git a/src/kits/network/old/compat/libbind/Jamfile b/src/kits/network/old/compat/libbind/Jamfile deleted file mode 100644 index 6791bf5bd1..0000000000 --- a/src/kits/network/old/compat/libbind/Jamfile +++ /dev/null @@ -1,216 +0,0 @@ -SubDir HAIKU_TOP src kits network compat libbind ; - -SetSubDirSupportedPlatformsBeOSCompatible ; - -LIBNETWORK_DNS_DIR = $(HAIKU_TOP) src kits network libnetwork dns ; - -UseHeaders [ FDirName $(SUBDIR) headers ] : true ; -UsePrivateHeaders net ; -UseHeaders [ FDirName $(HAIKU_TOP) headers legacy network ] : true ; -SubDirSysHdrs $(SUBDIR) ; -UseHeaders [ FDirName $(LIBNETWORK_DNS_DIR) headers ] : true ; -SubDirSysHdrs $(LIBNETWORK_DNS_DIR) ; - -if $(TARGET_PLATFORM) != haiku { - UseHeaders [ FDirName $(HAIKU_TOP) headers posix ] : true ; - # We need the public network headers also when not compiling for Haiku. - # Unfortunately we get more than we want, namely all POSIX headers. - UseHeaders [ FStandardOSHeaders ] : true ; - # Needed for and maybe other stuff. - - # Remove _NO_INLINE_ASM from the defines. Otherwise we get - # references to tls_get/set() etc. that don't exist under BeOS. - TARGET_DEFINES = [ FFilter $(TARGET_DEFINES) : _NO_INLINE_ASM ] ; -} - -# our libroot contains functions that are missing in BeOS (e.g.: strlcat) -SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src system libroot posix string ] ; - -# private sources for this port -SEARCH_SOURCE += [ FDirName $(SUBDIR) src ] ; -SEARCH_SOURCE += [ FDirName $(LIBNETWORK_DNS_DIR) src ] ; - -# BIND sources -SEARCH_SOURCE += [ FDirName $(LIBNETWORK_DNS_DIR) dst ] ; -SEARCH_SOURCE += [ FDirName $(LIBNETWORK_DNS_DIR) inet ] ; -SEARCH_SOURCE += [ FDirName $(LIBNETWORK_DNS_DIR) irs ] ; -SEARCH_SOURCE += [ FDirName $(LIBNETWORK_DNS_DIR) isc ] ; -SEARCH_SOURCE += [ FDirName $(LIBNETWORK_DNS_DIR) nameser ] ; -SEARCH_SOURCE += [ FDirName $(LIBNETWORK_DNS_DIR) resolv ] ; - -{ - # Default libs include BeOS R5 libnet.so, something we don't want here! - LINKFLAGS on libbind.so = [ on libbind.so return $(LINKFLAGS) ] -nodefaultlibs ; - - # we want to have the xxx_r functions, too - local defines = _REENTRANT=1 NO_SOCKADDR_UN=1 ISC_SOCKLEN_T=int ; - defines = [ FDefines $(defines) ] ; - SubDirCcFlags $(defines) ; - SubDirC++Flags $(defines) ; -} - - -MergeObject dst.o : - dst_api.c - hmac_link.c - md5_dgst.c - support.c -; - -MergeObject inet.o : - inet_addr.c - inet_cidr_ntop.c - inet_cidr_pton.c - inet_data.c - inet_lnaof.c - inet_makeaddr.c - inet_net_ntop.c - inet_net_pton.c - inet_neta.c - inet_netof.c - inet_network.c - inet_ntoa.c - inet_ntop.c - inet_pton.c - nsap_addr.c -; - -MergeObject irs.o : - dns.c - dns_ho.c - dns_nw.c - dns_pr.c - dns_sv.c - gai_strerror.c - gen.c - gen_ho.c - gen_ng.c - gen_nw.c - gen_pr.c - gen_sv.c - getaddrinfo.c - gethostent.c - gethostent_r.c - getnameinfo.c - getnetent.c - getnetent_r.c - getnetgrent.c - getnetgrent_r.c - getprotoent.c - getprotoent_r.c - getservent.c - getservent_r.c - hesiod.c - irp.c - irp_ho.c - irp_ng.c - irp_nw.c - irp_pr.c - irp_sv.c - irpmarshall.c - irs_data.c - lcl.c - lcl_ho.c - lcl_ng.c - lcl_nw.c - lcl_pr.c - lcl_sv.c - nis.c - nul_ng.c - util.c -; - -MergeObject isc.o : - assertions.c - base64.c - bitncmp.c - ctl_clnt.c - ctl_p.c - ctl_srvr.c - ev_connects.c - ev_files.c - ev_streams.c - ev_timers.c - ev_waits.c - eventlib.c - heap.c - hex.c - logging.c - memcluster.c - movefile.c - tree.c -; - -MergeObject nameser.o : - ns_date.c - ns_name.c - ns_netint.c - ns_parse.c - ns_print.c - ns_samedomain.c - ns_sign.c - ns_ttl.c - ns_verify.c -; - -MergeObject resolv.o : - herror.c - res_comp.c - res_data.c - res_debug.c - res_findzonecut.c - res_init.c - res_mkquery.c - res_mkupdate.c - res_query.c - res_send.c - res_sendsigned.c - res_update.c -; - -SharedLibrary libbind.so : - # functions from our libroot - # TODO: these can be removed for the Haiku build - strlcat.c - - # private functions - arc4random.c - ethers.c - gettimeofday.c - linkaddr.c - res_resultcodes.c - strsep.c - - # UGLY HACK - TLSInit.cpp -; - -LinkAgainst libbind.so : - dst.o - inet.o - irs.o - isc.o # (not used) - nameser.o - resolv.o - - libsocket.so - libnet.so # for gethostname() - be - root -; - -# Installation -- in the test directory for the time being -HaikuInstallRelSymLink install-networking - : [ FDirName $(HAIKU_TEST_DIR) kits net lib ] - : libbind.so - : installed-networking-test ; - -HaikuInstallRelSymLink install-userland-networking - : [ FDirName $(HAIKU_TEST_DIR) kits net userland lib ] - : libbind.so - : installed-userland-networking ; - -Package haiku-networkingkit-cvs : - libbind.so : -# boot home config lib ; - boot home Desktop haiku-networkingkit lib ; diff --git a/src/kits/network/old/compat/libbind/config.h b/src/kits/network/old/compat/libbind/config.h deleted file mode 100644 index f171bab3e6..0000000000 --- a/src/kits/network/old/compat/libbind/config.h +++ /dev/null @@ -1,54 +0,0 @@ -/* config.h. Generated by configure. */ -/* #undef _SOCKADDR_LEN */ -#define HAVE_FCNTL_H 1 -/* #undef HAVE_PATHS_H */ -/* #undef HAVE_SYS_TIMERS_H */ -/* #undef SYS_CDEFS_H */ -/* #undef _POSIX_PTHREAD_SEMANTICS */ -/* #undef POSIX_GETPWUID_R */ -/* #undef POSIX_GETPWNAM_R */ -/* #undef POSIX_GETGRGID_R */ -/* #undef POSIX_GETGRNAM_R */ - -#define NEED_SETGROUPENT 1 -#define NEED_GETGROUPLIST 1 - -/* define if prototype for getgrnam_r() is required */ -#define NEED_GETGRNAM_R 1 -#define NEED_GETGRGID_R 1 -#define NEED_GETGRENT_R 1 -#define NEED_SETGRENT_R 1 -#define NEED_ENDGRENT_R 1 - -#define NEED_INNETGR_R 1 -/* #undef NEED_SETNETGRENT_R */ -#define NEED_ENDNETGRENT_R 1 - -#define NEED_GETPWNAM_R 1 -#define NEED_GETPWUID_R 1 -#define NEED_SETPWENT_R 1 -#define NEED_SETPASSENT_R 1 -#define NEED_SETPWENT_R 1 -#define NEED_GETPWENT_R 1 -#define NEED_ENDPWENT_R 1 - -#define NEED_SETPASSENT 1 - -/* #undef HAS_PW_CLASS */ - -/* Shut up warnings about sputaux in stdio.h on BSD/OS pre-4.1 */ -/* #undef SHUTUP_SPUTAUX */ -#ifdef SHUTUP_SPUTAUX -struct __sFILE; -extern __inline int __sputaux(int _c, struct __sFILE *_p); -#endif -/* #undef BROKEN_IN6ADDR_INIT_MACROS */ -/* #undef HAVE_STRLCAT */ -/* Shut up warnings about missing braces */ -/* #undef SHUTUP_MUTEX_INITIALIZER */ -#ifdef SHUTUP_MUTEX_INITIALIZER -#define LIBBIND_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER } -#else -#define LIBBIND_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER -#endif - diff --git a/src/kits/network/old/compat/libbind/headers/fd_setsize.h b/src/kits/network/old/compat/libbind/headers/fd_setsize.h deleted file mode 100644 index 235b1ad1c2..0000000000 --- a/src/kits/network/old/compat/libbind/headers/fd_setsize.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _FD_SETSIZE_H -#define _FD_SETSIZE_H - -/* - * If you need a bigger FD_SETSIZE, this is NOT the place to set it. - * This file is a fallback for BIND ports which don't specify their own. - */ - -#endif /* _FD_SETSIZE_H */ diff --git a/src/kits/network/old/compat/libbind/headers/irp.h b/src/kits/network/old/compat/libbind/headers/irp.h deleted file mode 100644 index ffed347f72..0000000000 --- a/src/kits/network/old/compat/libbind/headers/irp.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * $Id$ - */ - -#ifndef _IRP_H_INCLUDED -#define _IRP_H_INCLUDED - -#define IRPD_TIMEOUT 30 /* seconds */ -#define IRPD_MAXSESS 50 /* number of simultaneous sessions. */ -#define IRPD_PORT 6660 /* 10 times the number of the beast. */ -#define IRPD_PATH "/var/run/irpd" /* af_unix socket path */ - -/* If sets the environment variable IRPDSERVER to an IP address - (e.g. "192.5.5.1"), then that's the host the client expects irpd to be - running on. */ -#define IRPD_HOST_ENV "IRPDSERVER" - -/* Protocol response codes. */ -#define IRPD_WELCOME_CODE 200 -#define IRPD_NOT_WELCOME_CODE 500 - -#define IRPD_GETHOST_ERROR 510 -#define IRPD_GETHOST_NONE 210 -#define IRPD_GETHOST_OK 211 -#define IRPD_GETHOST_SETOK 212 - -#define IRPD_GETNET_ERROR 520 -#define IRPD_GETNET_NONE 220 -#define IRPD_GETNET_OK 221 -#define IRPD_GETNET_SETOK 222 - -#define IRPD_GETUSER_ERROR 530 -#define IRPD_GETUSER_NONE 230 -#define IRPD_GETUSER_OK 231 -#define IRPD_GETUSER_SETOK 232 - -#define IRPD_GETGROUP_ERROR 540 -#define IRPD_GETGROUP_NONE 240 -#define IRPD_GETGROUP_OK 241 -#define IRPD_GETGROUP_SETOK 242 - -#define IRPD_GETSERVICE_ERROR 550 -#define IRPD_GETSERVICE_NONE 250 -#define IRPD_GETSERVICE_OK 251 -#define IRPD_GETSERVICE_SETOK 252 - -#define IRPD_GETPROTO_ERROR 560 -#define IRPD_GETPROTO_NONE 260 -#define IRPD_GETPROTO_OK 261 -#define IRPD_GETPROTO_SETOK 262 - -#define IRPD_GETNETGR_ERROR 570 -#define IRPD_GETNETGR_NONE 270 -#define IRPD_GETNETGR_OK 271 -#define IRPD_GETNETGR_NOMORE 272 -#define IRPD_GETNETGR_MATCHES 273 -#define IRPD_GETNETGR_NOMATCH 274 -#define IRPD_GETNETGR_SETOK 275 -#define IRPD_GETNETGR_SETERR 276 - -#define irs_irp_read_body __irs_irp_read_body -#define irs_irp_read_response __irs_irp_read_response -#define irs_irp_disconnect __irs_irp_disconnect -#define irs_irp_connect __irs_irp_connect -#define irs_irp_connection_setup __irs_irp_connection_setup -#define irs_irp_send_command __irs_irp_send_command - -struct irp_p; - -char *irs_irp_read_body(struct irp_p *, size_t *); -int irs_irp_read_response(struct irp_p *, char *, size_t); -void irs_irp_disconnect(struct irp_p *); -int irs_irp_connect(struct irp_p *); -int irs_irp_is_connected(struct irp_p *); -int irs_irp_connection_setup(struct irp_p *, int *); -#ifdef __GNUC__ -int irs_irp_send_command(struct irp_p *, const char *, ...) - __attribute__((__format__(__printf__, 2, 3))); -#else -int irs_irp_send_command(struct irp_p *, const char *, ...); -#endif -int irs_irp_get_full_response(struct irp_p *, int *, char *, size_t, - char **, size_t *); -int irs_irp_read_line(struct irp_p *, char *, int); - -#endif diff --git a/src/kits/network/old/compat/libbind/headers/irs.h b/src/kits/network/old/compat/libbind/headers/irs.h deleted file mode 100644 index 86b49bd3f7..0000000000 --- a/src/kits/network/old/compat/libbind/headers/irs.h +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * $Id$ - */ - -#ifndef _IRS_H_INCLUDED -#define _IRS_H_INCLUDED - -#include - -#include - -#include -#include -#include -#include - -/* - * This is the group map class. - */ -struct irs_gr { - void * private; - void (*close) __P((struct irs_gr *)); - struct group * (*next) __P((struct irs_gr *)); - struct group * (*byname) __P((struct irs_gr *, const char *)); - struct group * (*bygid) __P((struct irs_gr *, gid_t)); - int (*list) __P((struct irs_gr *, const char *, - gid_t, gid_t *, int *)); - void (*rewind) __P((struct irs_gr *)); - void (*minimize) __P((struct irs_gr *)); - struct __res_state * (*res_get) __P((struct irs_gr *)); - void (*res_set) __P((struct irs_gr *, res_state, - void (*)(void *))); -}; - -/* - * This is the password map class. - */ -struct irs_pw { - void * private; - void (*close) __P((struct irs_pw *)); - struct passwd * (*next) __P((struct irs_pw *)); - struct passwd * (*byname) __P((struct irs_pw *, const char *)); - struct passwd * (*byuid) __P((struct irs_pw *, uid_t)); - void (*rewind) __P((struct irs_pw *)); - void (*minimize) __P((struct irs_pw *)); - struct __res_state * (*res_get) __P((struct irs_pw *)); - void (*res_set) __P((struct irs_pw *, res_state, - void (*)(void *))); -}; - -/* - * This is the service map class. - */ -struct irs_sv { - void * private; - void (*close) __P((struct irs_sv *)); - struct servent *(*byname) __P((struct irs_sv *, - const char *, const char *)); - struct servent *(*byport) __P((struct irs_sv *, int, const char *)); - struct servent *(*next) __P((struct irs_sv *)); - void (*rewind) __P((struct irs_sv *)); - void (*minimize) __P((struct irs_sv *)); - struct __res_state * (*res_get) __P((struct irs_sv *)); - void (*res_set) __P((struct irs_sv *, res_state, - void (*)(void *))); -}; - -/* - * This is the protocols map class. - */ -struct irs_pr { - void * private; - void (*close) __P((struct irs_pr *)); - struct protoent *(*byname) __P((struct irs_pr *, const char *)); - struct protoent *(*bynumber) __P((struct irs_pr *, int)); - struct protoent *(*next) __P((struct irs_pr *)); - void (*rewind) __P((struct irs_pr *)); - void (*minimize) __P((struct irs_pr *)); - struct __res_state * (*res_get) __P((struct irs_pr *)); - void (*res_set) __P((struct irs_pr *, res_state, - void (*)(void *))); -}; - -/* - * This is the hosts map class. - */ -struct irs_ho { - void * private; - void (*close) __P((struct irs_ho *)); - struct hostent *(*byname) __P((struct irs_ho *, const char *)); - struct hostent *(*byname2) __P((struct irs_ho *, const char *, int)); - struct hostent *(*byaddr) __P((struct irs_ho *, - const void *, int, int)); - struct hostent *(*next) __P((struct irs_ho *)); - void (*rewind) __P((struct irs_ho *)); - void (*minimize) __P((struct irs_ho *)); - struct __res_state * (*res_get) __P((struct irs_ho *)); - void (*res_set) __P((struct irs_ho *, res_state, - void (*)(void *))); - struct addrinfo *(*addrinfo) __P((struct irs_ho *, const char *, - const struct addrinfo *)); -}; - -/* - * This is the networks map class. - */ -struct irs_nw { - void * private; - void (*close) __P((struct irs_nw *)); - struct nwent * (*byname) __P((struct irs_nw *, const char *, int)); - struct nwent * (*byaddr) __P((struct irs_nw *, void *, int, int)); - struct nwent * (*next) __P((struct irs_nw *)); - void (*rewind) __P((struct irs_nw *)); - void (*minimize) __P((struct irs_nw *)); - struct __res_state * (*res_get) __P((struct irs_nw *)); - void (*res_set) __P((struct irs_nw *, res_state, - void (*)(void *))); -}; - -/* - * This is the netgroups map class. - */ -struct irs_ng { - void * private; - void (*close) __P((struct irs_ng *)); - int (*next) __P((struct irs_ng *, const char **, - const char **, const char **)); - int (*test) __P((struct irs_ng *, const char *, - const char *, const char *, - const char *)); - void (*rewind) __P((struct irs_ng *, const char *)); - void (*minimize) __P((struct irs_ng *)); -}; - -/* - * This is the generic map class, which copies the front of all others. - */ -struct irs_map { - void * private; - void (*close) __P((void *)); -}; - -/* - * This is the accessor class. It contains pointers to all of the - * initializers for the map classes for a particular accessor. - */ -struct irs_acc { - void * private; - void (*close) __P((struct irs_acc *)); - struct irs_gr * (*gr_map) __P((struct irs_acc *)); - struct irs_pw * (*pw_map) __P((struct irs_acc *)); - struct irs_sv * (*sv_map) __P((struct irs_acc *)); - struct irs_pr * (*pr_map) __P((struct irs_acc *)); - struct irs_ho * (*ho_map) __P((struct irs_acc *)); - struct irs_nw * (*nw_map) __P((struct irs_acc *)); - struct irs_ng * (*ng_map) __P((struct irs_acc *)); - struct __res_state * (*res_get) __P((struct irs_acc *)); - void (*res_set) __P((struct irs_acc *, res_state, - void (*)(void *))); -}; - -/* - * This is because the official definition of "struct netent" has no - * concept of CIDR even though it allows variant address families (on - * output but not input). The compatibility stubs convert the structs - * below into "struct netent"'s. - */ -struct nwent { - char *n_name; /* official name of net */ - char **n_aliases; /* alias list */ - int n_addrtype; /* net address type */ - void *n_addr; /* network address */ - int n_length; /* address length, in bits */ -}; - -/* - * Hide external function names from POSIX. - */ -#define irs_gen_acc __irs_gen_acc -#define irs_lcl_acc __irs_lcl_acc -#define irs_dns_acc __irs_dns_acc -#define irs_nis_acc __irs_nis_acc -#define irs_irp_acc __irs_irp_acc -#define irs_destroy __irs_destroy -#define irs_dns_gr __irs_dns_gr -#define irs_dns_ho __irs_dns_ho -#define irs_dns_nw __irs_dns_nw -#define irs_dns_pr __irs_dns_pr -#define irs_dns_pw __irs_dns_pw -#define irs_dns_sv __irs_dns_sv -#define irs_gen_gr __irs_gen_gr -#define irs_gen_ho __irs_gen_ho -#define irs_gen_ng __irs_gen_ng -#define irs_gen_nw __irs_gen_nw -#define irs_gen_pr __irs_gen_pr -#define irs_gen_pw __irs_gen_pw -#define irs_gen_sv __irs_gen_sv -#define irs_irp_get_full_response __irs_irp_get_full_response -#define irs_irp_gr __irs_irp_gr -#define irs_irp_ho __irs_irp_ho -#define irs_irp_is_connected __irs_irp_is_connected -#define irs_irp_ng __irs_irp_ng -#define irs_irp_nw __irs_irp_nw -#define irs_irp_pr __irs_irp_pr -#define irs_irp_pw __irs_irp_pw -#define irs_irp_read_line __irs_irp_read_line -#define irs_irp_sv __irs_irp_sv -#define irs_lcl_gr __irs_lcl_gr -#define irs_lcl_ho __irs_lcl_ho -#define irs_lcl_ng __irs_lcl_ng -#define irs_lcl_nw __irs_lcl_nw -#define irs_lcl_pr __irs_lcl_pr -#define irs_lcl_pw __irs_lcl_pw -#define irs_lcl_sv __irs_lcl_sv -#define irs_nis_gr __irs_nis_gr -#define irs_nis_ho __irs_nis_ho -#define irs_nis_ng __irs_nis_ng -#define irs_nis_nw __irs_nis_nw -#define irs_nis_pr __irs_nis_pr -#define irs_nis_pw __irs_nis_pw -#define irs_nis_sv __irs_nis_sv -#define net_data_create __net_data_create -#define net_data_destroy __net_data_destroy -#define net_data_minimize __net_data_minimize - -/* - * Externs. - */ -extern struct irs_acc * irs_gen_acc __P((const char *, const char *)); -extern struct irs_acc * irs_lcl_acc __P((const char *)); -extern struct irs_acc * irs_dns_acc __P((const char *)); -extern struct irs_acc * irs_nis_acc __P((const char *)); -extern struct irs_acc * irs_irp_acc __P((const char *)); - -extern void irs_destroy __P((void)); - -/* - * These forward declarations are for the semi-private functions in - * the get*.c files. Each of these funcs implements the real get* - * functionality and the standard versions are just wrappers that - * call these. Apart from the wrappers, only irpd is expected to - * call these directly, hence these decls are put here and not in - * the /usr/include replacements. - */ - -struct net_data; /* forward */ - -/* - * net_data_create gets a singleton net_data object. net_data_init - * creates as many net_data objects as times it is called. Clients using - * the default interface will use net_data_create by default. Servers will - * probably want net_data_init (one call per client) - */ -struct net_data *net_data_create __P((const char *)); -struct net_data *net_data_init __P((const char *)); -void net_data_destroy __P((void *)); - -extern struct group *getgrent_p __P((struct net_data *)); -extern struct group *getgrnam_p __P((const char *, struct net_data *)); -extern struct group *getgrgid_p __P((gid_t, struct net_data *)); -extern int setgroupent_p __P((int, struct net_data *)); -extern void endgrent_p __P((struct net_data *)); -extern int getgrouplist_p __P((const char *, gid_t, gid_t *, int *, - struct net_data *)); - -#ifdef SETGRENT_VOID -extern void setgrent_p __P((struct net_data *)); -#else -extern int setgrent_p __P((struct net_data *)); -#endif - -extern struct hostent *gethostbyname_p __P((const char *, - struct net_data *)); -extern struct hostent *gethostbyname2_p __P((const char *, int, - struct net_data *)); -extern struct hostent *gethostbyaddr_p __P((const char *, int, int, - struct net_data *)); -extern struct hostent *gethostent_p __P((struct net_data *)); -extern void sethostent_p __P((int, struct net_data *)); -extern void endhostent_p __P((struct net_data *)); -extern struct hostent *getipnodebyname_p __P((const char *, int, int, int *, - struct net_data *)); -extern struct hostent *getipnodebyaddr_p __P((const void *, size_t, - int, int *, struct net_data *)); - -extern struct netent *getnetent_p __P((struct net_data *)); -extern struct netent *getnetbyname_p __P((const char *, struct net_data *)); -extern struct netent *getnetbyaddr_p __P((unsigned long, int, - struct net_data *)); -extern void setnetent_p __P((int, struct net_data *)); -extern void endnetent_p __P((struct net_data *)); - -extern void setnetgrent_p __P((const char *, struct net_data *)); -extern void endnetgrent_p __P((struct net_data *)); -extern int innetgr_p __P((const char *, const char *, const char *, - const char *, struct net_data *)); -extern int getnetgrent_p __P((const char **, const char **, - const char **, struct net_data *)); - -extern struct protoent *getprotoent_p __P((struct net_data *)); -extern struct protoent *getprotobyname_p __P((const char *, - struct net_data *)); -extern struct protoent *getprotobynumber_p __P((int, struct net_data *)); -extern void setprotoent_p __P((int, struct net_data *)); -extern void endprotoent_p __P((struct net_data *)); - - -extern struct passwd *getpwent_p __P((struct net_data *)); -extern struct passwd *getpwnam_p __P((const char *, struct net_data *)); -extern struct passwd *getpwuid_p __P((uid_t, struct net_data *)); -extern int setpassent_p __P((int, struct net_data *)); -extern void endpwent_p __P((struct net_data *)); - -#ifdef SETPWENT_VOID -extern void setpwent_p __P((struct net_data *)); -#else -extern int setpwent_p __P((struct net_data *)); -#endif - -extern struct servent *getservent_p __P((struct net_data *)); -extern struct servent *getservbyname_p __P((const char *, const char *, - struct net_data *)); -extern struct servent *getservbyport_p __P((int, const char *, - struct net_data *)); -extern void setservent_p __P((int, struct net_data *)); -extern void endservent_p __P((struct net_data *)); - -#endif /*_IRS_H_INCLUDED*/ diff --git a/src/kits/network/old/compat/libbind/headers/isc/assertions.h b/src/kits/network/old/compat/libbind/headers/isc/assertions.h deleted file mode 100644 index 3066558d0e..0000000000 --- a/src/kits/network/old/compat/libbind/headers/isc/assertions.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1997-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * $Id$ - */ - -#ifndef ASSERTIONS_H -#define ASSERTIONS_H 1 - -typedef enum { - assert_require, assert_ensure, assert_insist, assert_invariant -} assertion_type; - -typedef void (*assertion_failure_callback)(const char *, int, assertion_type, - const char *, int); - -extern assertion_failure_callback __assertion_failed; -void set_assertion_failure_callback(assertion_failure_callback f); -const char *assertion_type_to_text(assertion_type type); - -#ifdef CHECK_ALL -#define CHECK_REQUIRE 1 -#define CHECK_ENSURE 1 -#define CHECK_INSIST 1 -#define CHECK_INVARIANT 1 -#endif - -#ifdef CHECK_NONE -#define CHECK_REQUIRE 0 -#define CHECK_ENSURE 0 -#define CHECK_INSIST 0 -#define CHECK_INVARIANT 0 -#endif - -#ifndef CHECK_REQUIRE -#define CHECK_REQUIRE 1 -#endif - -#ifndef CHECK_ENSURE -#define CHECK_ENSURE 1 -#endif - -#ifndef CHECK_INSIST -#define CHECK_INSIST 1 -#endif - -#ifndef CHECK_INVARIANT -#define CHECK_INVARIANT 1 -#endif - -#if CHECK_REQUIRE != 0 -#define REQUIRE(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_require, \ - #cond, 0), 0))) -#define REQUIRE_ERR(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_require, \ - #cond, 1), 0))) -#else -#define REQUIRE(cond) ((void) (cond)) -#define REQUIRE_ERR(cond) ((void) (cond)) -#endif /* CHECK_REQUIRE */ - -#if CHECK_ENSURE != 0 -#define ENSURE(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \ - #cond, 0), 0))) -#define ENSURE_ERR(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \ - #cond, 1), 0))) -#else -#define ENSURE(cond) ((void) (cond)) -#define ENSURE_ERR(cond) ((void) (cond)) -#endif /* CHECK_ENSURE */ - -#if CHECK_INSIST != 0 -#define INSIST(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \ - #cond, 0), 0))) -#define INSIST_ERR(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \ - #cond, 1), 0))) -#else -#define INSIST(cond) ((void) (cond)) -#define INSIST_ERR(cond) ((void) (cond)) -#endif /* CHECK_INSIST */ - -#if CHECK_INVARIANT != 0 -#define INVARIANT(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \ - #cond, 0), 0))) -#define INVARIANT_ERR(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \ - #cond, 1), 0))) -#else -#define INVARIANT(cond) ((void) (cond)) -#define INVARIANT_ERR(cond) ((void) (cond)) -#endif /* CHECK_INVARIANT */ - -#endif /* ASSERTIONS_H */ diff --git a/src/kits/network/old/compat/libbind/headers/isc/ctl.h b/src/kits/network/old/compat/libbind/headers/isc/ctl.h deleted file mode 100644 index 4ee6b9a213..0000000000 --- a/src/kits/network/old/compat/libbind/headers/isc/ctl.h +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef ISC_CTL_H -#define ISC_CTL_H - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1998,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * $Id$ - */ - -#include -#include - -#include - -/* Macros. */ - -#define CTL_MORE 0x0001 /* More will be / should be sent. */ -#define CTL_EXIT 0x0002 /* Close connection after this. */ -#define CTL_DATA 0x0004 /* Go into / this is DATA mode. */ - -/* Types. */ - -struct ctl_cctx; -struct ctl_sctx; -struct ctl_sess; -struct ctl_verb; - -enum ctl_severity { ctl_debug, ctl_warning, ctl_error }; - -typedef void (*ctl_logfunc)(enum ctl_severity, const char *, ...); - -typedef void (*ctl_verbfunc)(struct ctl_sctx *, struct ctl_sess *, - const struct ctl_verb *, const char *, - u_int, const void *, void *); - -typedef void (*ctl_srvrdone)(struct ctl_sctx *, struct ctl_sess *, void *); - -typedef void (*ctl_clntdone)(struct ctl_cctx *, void *, const char *, u_int); - -struct ctl_verb { - const char * name; - ctl_verbfunc func; - const char * help; -}; - -/* General symbols. */ - -#define ctl_logger __ctl_logger - -#ifdef __GNUC__ -void ctl_logger(enum ctl_severity, const char *, ...) - __attribute__((__format__(__printf__, 2, 3))); -#else -void ctl_logger(enum ctl_severity, const char *, ...); -#endif - -/* Client symbols. */ - -#define ctl_client __ctl_client -#define ctl_endclient __ctl_endclient -#define ctl_command __ctl_command - -struct ctl_cctx * ctl_client(evContext, const struct sockaddr *, size_t, - const struct sockaddr *, size_t, - ctl_clntdone, void *, - u_int, ctl_logfunc); -void ctl_endclient(struct ctl_cctx *); -int ctl_command(struct ctl_cctx *, const char *, size_t, - ctl_clntdone, void *); - -/* Server symbols. */ - -#define ctl_server __ctl_server -#define ctl_endserver __ctl_endserver -#define ctl_response __ctl_response -#define ctl_sendhelp __ctl_sendhelp -#define ctl_getcsctx __ctl_getcsctx -#define ctl_setcsctx __ctl_setcsctx - -struct ctl_sctx * ctl_server(evContext, const struct sockaddr *, size_t, - const struct ctl_verb *, - u_int, u_int, - u_int, int, int, - ctl_logfunc, void *); -void ctl_endserver(struct ctl_sctx *); -void ctl_response(struct ctl_sess *, u_int, - const char *, u_int, const void *, - ctl_srvrdone, void *, - const char *, size_t); -void ctl_sendhelp(struct ctl_sess *, u_int); -void * ctl_getcsctx(struct ctl_sess *); -void * ctl_setcsctx(struct ctl_sess *, void *); - -#endif /*ISC_CTL_H*/ diff --git a/src/kits/network/old/compat/libbind/headers/isc/dst.h b/src/kits/network/old/compat/libbind/headers/isc/dst.h deleted file mode 100644 index fe9229725a..0000000000 --- a/src/kits/network/old/compat/libbind/headers/isc/dst.h +++ /dev/null @@ -1,180 +0,0 @@ -#ifndef DST_H -#define DST_H - -#ifndef HAS_DST_KEY -typedef struct dst_key { - char *dk_key_name; /* name of the key */ - int dk_key_size; /* this is the size of the key in bits */ - int dk_proto; /* what protocols this key can be used for */ - int dk_alg; /* algorithm number from key record */ - u_int32_t dk_flags; /* and the flags of the public key */ - u_int16_t dk_id; /* identifier of the key */ -} DST_KEY; -#endif /* HAS_DST_KEY */ - -/* - * do not taint namespace - */ -#define dst_bsafe_init __dst_bsafe_init -#define dst_buffer_to_key __dst_buffer_to_key -#define dst_check_algorithm __dst_check_algorithm -#define dst_compare_keys __dst_compare_keys -#define dst_cylink_init __dst_cylink_init -#define dst_dnskey_to_key __dst_dnskey_to_key -#define dst_eay_dss_init __dst_eay_dss_init -#define dst_free_key __dst_free_key -#define dst_generate_key __dst_generate_key -#define dst_hmac_md5_init __dst_hmac_md5_init -#define dst_init __dst_init -#define dst_key_to_buffer __dst_key_to_buffer -#define dst_key_to_dnskey __dst_key_to_dnskey -#define dst_read_key __dst_read_key -#define dst_rsaref_init __dst_rsaref_init -#define dst_s_build_filename __dst_s_build_filename -#define dst_s_calculate_bits __dst_s_calculate_bits -#define dst_s_conv_bignum_b64_to_u8 __dst_s_conv_bignum_b64_to_u8 -#define dst_s_conv_bignum_u8_to_b64 __dst_s_conv_bignum_u8_to_b64 -#define dst_s_dns_key_id __dst_s_dns_key_id -#define dst_s_dump __dst_s_dump -#define dst_s_filename_length __dst_s_filename_length -#define dst_s_fopen __dst_s_fopen -#define dst_s_get_int16 __dst_s_get_int16 -#define dst_s_get_int32 __dst_s_get_int32 -#define dst_s_id_calc __dst_s_id_calc -#define dst_s_put_int16 __dst_s_put_int16 -#define dst_s_put_int32 __dst_s_put_int32 -#define dst_s_quick_random __dst_s_quick_random -#define dst_s_quick_random_set __dst_s_quick_random_set -#define dst_s_random __dst_s_random -#define dst_s_semi_random __dst_s_semi_random -#define dst_s_verify_str __dst_s_verify_str -#define dst_sig_size __dst_sig_size -#define dst_sign_data __dst_sign_data -#define dst_verify_data __dst_verify_data -#define dst_write_key __dst_write_key - -/* - * DST Crypto API defintions - */ -void dst_init(void); -int dst_check_algorithm(const int); - -int dst_sign_data(const int, /* specifies INIT/UPDATE/FINAL/ALL */ - DST_KEY *, /* the key to use */ - void **, /* pointer to state structure */ - const u_char *, /* data to be signed */ - const int, /* length of input data */ - u_char *, /* buffer to write signature to */ - const int); /* size of output buffer */ - -int dst_verify_data(const int, /* specifies INIT/UPDATE/FINAL/ALL */ - DST_KEY *, /* the key to use */ - void **, /* pointer to state structure */ - const u_char *, /* data to be verified */ - const int, /* length of input data */ - const u_char *, /* buffer containing signature */ - const int); /* length of signature */ - - -DST_KEY *dst_read_key(const char *, /* name of key */ - const u_int16_t, /* key tag identifier */ - const int, /* key algorithm */ - const int); /* Private/PublicKey wanted*/ - -int dst_write_key(const DST_KEY *, /* key to write out */ - const int); /* Public/Private */ - -DST_KEY *dst_dnskey_to_key(const char *, /* KEY record name */ - const u_char *, /* KEY RDATA */ - const int); /* size of input buffer*/ - - -int dst_key_to_dnskey(const DST_KEY *, /* key to translate */ - u_char *, /* output buffer */ - const int); /* size of out_storage*/ - - -DST_KEY *dst_buffer_to_key(const char *, /* name of the key */ - const int, /* algorithm */ - const int, /* dns flags */ - const int, /* dns protocol */ - const u_char *, /* key in dns wire fmt */ - const int); /* size of key */ - - -int dst_key_to_buffer(DST_KEY *, u_char *, int); - -DST_KEY *dst_generate_key(const char *, /* name of new key */ - const int, /* key algorithm to generate */ - const int, /* size of new key */ - const int, /* alg dependent parameter*/ - const int, /* key DNS flags */ - const int); /* key DNS protocol */ - -DST_KEY *dst_free_key(DST_KEY *); -int dst_compare_keys(const DST_KEY *, const DST_KEY *); - -int dst_sig_size(DST_KEY *); - - -/* support for dns key tags/ids */ -u_int16_t dst_s_dns_key_id(const u_char *, const int); -u_int16_t dst_s_id_calc(const u_char *, const int); - -/* Used by callers as well as by the library. */ -#define RAW_KEY_SIZE 8192 /* large enough to store any key */ - -/* DST_API control flags */ -/* These are used used in functions dst_sign_data and dst_verify_data */ -#define SIG_MODE_INIT 1 /* initialize digest */ -#define SIG_MODE_UPDATE 2 /* add data to digest */ -#define SIG_MODE_FINAL 4 /* generate/verify signature */ -#define SIG_MODE_ALL (SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL) - -/* Flags for dst_read_private_key() */ -#define DST_FORCE_READ 0x1000000 -#define DST_CAN_SIGN 0x010F -#define DST_NO_AUTHEN 0x8000 -#define DST_EXTEND_FLAG 0x1000 -#define DST_STANDARD 0 -#define DST_PRIVATE 0x2000000 -#define DST_PUBLIC 0x4000000 -#define DST_RAND_SEMI 1 -#define DST_RAND_STD 2 -#define DST_RAND_KEY 3 -#define DST_RAND_DSS 4 - - -/* DST algorithm codes */ -#define KEY_RSA 1 -#define KEY_DH 2 -#define KEY_DSA 3 -#define KEY_PRIVATE 254 -#define KEY_EXPAND 255 -#define KEY_HMAC_MD5 157 -#define KEY_HMAC_SHA1 158 -#define UNKNOWN_KEYALG 0 -#define DST_MAX_ALGS KEY_HMAC_SHA1 - -/* DST constants to locations in KEY record changes in new KEY record */ -#define DST_FLAGS_SIZE 2 -#define DST_KEY_PROT 2 -#define DST_KEY_ALG 3 -#define DST_EXT_FLAG 4 -#define DST_KEY_START 4 - -#ifndef SIGN_F_NOKEY -#define SIGN_F_NOKEY 0xC000 -#endif - -/* error codes from dst routines */ -#define SIGN_INIT_FAILURE (-23) -#define SIGN_UPDATE_FAILURE (-24) -#define SIGN_FINAL_FAILURE (-25) -#define VERIFY_INIT_FAILURE (-26) -#define VERIFY_UPDATE_FAILURE (-27) -#define VERIFY_FINAL_FAILURE (-28) -#define MISSING_KEY_OR_SIGNATURE (-30) -#define UNSUPPORTED_KEYALG (-31) - -#endif /* DST_H */ diff --git a/src/kits/network/old/compat/libbind/headers/isc/eventlib.h b/src/kits/network/old/compat/libbind/headers/isc/eventlib.h deleted file mode 100644 index ea1844ab2c..0000000000 --- a/src/kits/network/old/compat/libbind/headers/isc/eventlib.h +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1995-1999 by Internet Software Consortium - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* eventlib.h - exported interfaces for eventlib - * vix 09sep95 [initial] - * - * $Id$ - */ - -#ifndef _EVENTLIB_H -#define _EVENTLIB_H - -#include -#include -#include -#include - -#ifndef __P -# define __EVENTLIB_P_DEFINED -# ifdef __STDC__ -# define __P(x) x -# else -# define __P(x) () -# endif -#endif - -/* In the absence of branded types... */ -typedef struct { void *opaque; } evConnID; -typedef struct { void *opaque; } evFileID; -typedef struct { void *opaque; } evStreamID; -typedef struct { void *opaque; } evTimerID; -typedef struct { void *opaque; } evWaitID; -typedef struct { void *opaque; } evContext; -typedef struct { void *opaque; } evEvent; - -#define evInitID(id) ((id)->opaque = NULL) -#define evTestID(id) ((id).opaque != NULL) - -typedef void (*evConnFunc)__P((evContext, void *, int, const void *, int, - const void *, int)); -typedef void (*evFileFunc)__P((evContext, void *, int, int)); -typedef void (*evStreamFunc)__P((evContext, void *, int, int)); -typedef void (*evTimerFunc)__P((evContext, void *, - struct timespec, struct timespec)); -typedef void (*evWaitFunc)__P((evContext, void *, const void *)); - -typedef struct { unsigned char mask[256/8]; } evByteMask; -#define EV_BYTEMASK_BYTE(b) ((b) / 8) -#define EV_BYTEMASK_MASK(b) (1 << ((b) % 8)) -#define EV_BYTEMASK_SET(bm, b) \ - ((bm).mask[EV_BYTEMASK_BYTE(b)] |= EV_BYTEMASK_MASK(b)) -#define EV_BYTEMASK_CLR(bm, b) \ - ((bm).mask[EV_BYTEMASK_BYTE(b)] &= ~EV_BYTEMASK_MASK(b)) -#define EV_BYTEMASK_TST(bm, b) \ - ((bm).mask[EV_BYTEMASK_BYTE(b)] & EV_BYTEMASK_MASK(b)) - -#define EV_POLL 1 -#define EV_WAIT 2 -#define EV_NULL 4 - -#define EV_READ 1 -#define EV_WRITE 2 -#define EV_EXCEPT 4 - -/* eventlib.c */ -#define evCreate __evCreate -#define evSetDebug __evSetDebug -#define evDestroy __evDestroy -#define evGetNext __evGetNext -#define evDispatch __evDispatch -#define evDrop __evDrop -#define evMainLoop __evMainLoop -#define evHighestFD __evHighestFD -#define evGetOption __evGetOption -#define evSetOption __evSetOption - -int evCreate __P((evContext *)); -void evSetDebug __P((evContext, int, FILE *)); -int evDestroy __P((evContext)); -int evGetNext __P((evContext, evEvent *, int)); -int evDispatch __P((evContext, evEvent)); -void evDrop __P((evContext, evEvent)); -int evMainLoop __P((evContext)); -int evHighestFD __P((evContext)); -int evGetOption __P((evContext *, const char *, int *)); -int evSetOption __P((evContext *, const char *, int)); - -/* ev_connects.c */ -#define evListen __evListen -#define evConnect __evConnect -#define evCancelConn __evCancelConn -#define evHold __evHold -#define evUnhold __evUnhold -#define evTryAccept __evTryAccept - -int evListen __P((evContext, int, int, evConnFunc, void *, evConnID *)); -int evConnect __P((evContext, int, const void *, int, - evConnFunc, void *, evConnID *)); -int evCancelConn __P((evContext, evConnID)); -int evHold __P((evContext, evConnID)); -int evUnhold __P((evContext, evConnID)); -int evTryAccept __P((evContext, evConnID, int *)); - -/* ev_files.c */ -#define evSelectFD __evSelectFD -#define evDeselectFD __evDeselectFD - -int evSelectFD __P((evContext, int, int, evFileFunc, void *, evFileID *)); -int evDeselectFD __P((evContext, evFileID)); - -/* ev_streams.c */ -#define evConsIovec __evConsIovec -#define evWrite __evWrite -#define evRead __evRead -#define evTimeRW __evTimeRW -#define evUntimeRW __evUntimeRW -#define evCancelRW __evCancelRW - -struct iovec evConsIovec __P((void *, size_t)); -int evWrite __P((evContext, int, const struct iovec *, int, - evStreamFunc func, void *, evStreamID *)); -int evRead __P((evContext, int, const struct iovec *, int, - evStreamFunc func, void *, evStreamID *)); -int evTimeRW __P((evContext, evStreamID, evTimerID timer)); -int evUntimeRW __P((evContext, evStreamID)); -int evCancelRW __P((evContext, evStreamID)); - -/* ev_timers.c */ -#define evConsTime __evConsTime -#define evAddTime __evAddTime -#define evSubTime __evSubTime -#define evCmpTime __evCmpTime -#define evTimeSpec __evTimeSpec -#define evTimeVal __evTimeVal - -#define evNowTime __evNowTime -#define evUTCTime __evUTCTime -#define evLastEventTime __evLastEventTime -#define evSetTimer __evSetTimer -#define evClearTimer __evClearTimer -#define evConfigTimer __evConfigTimer -#define evResetTimer __evResetTimer -#define evSetIdleTimer __evSetIdleTimer -#define evClearIdleTimer __evClearIdleTimer -#define evResetIdleTimer __evResetIdleTimer -#define evTouchIdleTimer __evTouchIdleTimer - -struct timespec evConsTime __P((time_t sec, long nsec)); -struct timespec evAddTime __P((struct timespec, struct timespec)); -struct timespec evSubTime __P((struct timespec, struct timespec)); -struct timespec evNowTime __P((void)); -struct timespec evUTCTime __P((void)); -struct timespec evLastEventTime __P((evContext)); -struct timespec evTimeSpec __P((struct timeval)); -struct timeval evTimeVal __P((struct timespec)); -int evCmpTime __P((struct timespec, struct timespec)); -int evSetTimer __P((evContext, evTimerFunc, void *, struct timespec, - struct timespec, evTimerID *)); -int evClearTimer __P((evContext, evTimerID)); -int evConfigTimer __P((evContext, evTimerID, const char *param, - int value)); -int evResetTimer __P((evContext, evTimerID, evTimerFunc, void *, - struct timespec, struct timespec)); -int evSetIdleTimer __P((evContext, evTimerFunc, void *, struct timespec, - evTimerID *)); -int evClearIdleTimer __P((evContext, evTimerID)); -int evResetIdleTimer __P((evContext, evTimerID, evTimerFunc, void *, - struct timespec)); -int evTouchIdleTimer __P((evContext, evTimerID)); - -/* ev_waits.c */ -#define evWaitFor __evWaitFor -#define evDo __evDo -#define evUnwait __evUnwait -#define evDefer __evDefer - -int evWaitFor __P((evContext, const void *, evWaitFunc, void *, evWaitID *)); -int evDo __P((evContext, const void *)); -int evUnwait __P((evContext, evWaitID)); -int evDefer __P((evContext, evWaitFunc, void *)); - -#ifdef __EVENTLIB_P_DEFINED -# undef __P -#endif - -#endif /*_EVENTLIB_H*/ diff --git a/src/kits/network/old/compat/libbind/headers/isc/heap.h b/src/kits/network/old/compat/libbind/headers/isc/heap.h deleted file mode 100644 index 691c821d1e..0000000000 --- a/src/kits/network/old/compat/libbind/headers/isc/heap.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1997,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -typedef int (*heap_higher_priority_func)(void *, void *); -typedef void (*heap_index_func)(void *, int); -typedef void (*heap_for_each_func)(void *, void *); - -typedef struct heap_context { - int array_size; - int array_size_increment; - int heap_size; - void **heap; - heap_higher_priority_func higher_priority; - heap_index_func index; -} *heap_context; - -#define heap_new __heap_new -#define heap_free __heap_free -#define heap_insert __heap_insert -#define heap_delete __heap_delete -#define heap_increased __heap_increased -#define heap_decreased __heap_decreased -#define heap_element __heap_element -#define heap_for_each __heap_for_each - -heap_context heap_new(heap_higher_priority_func, heap_index_func, int); -int heap_free(heap_context); -int heap_insert(heap_context, void *); -int heap_delete(heap_context, int); -int heap_increased(heap_context, int); -int heap_decreased(heap_context, int); -void * heap_element(heap_context, int); -int heap_for_each(heap_context, heap_for_each_func, void *); diff --git a/src/kits/network/old/compat/libbind/headers/isc/irpmarshall.h b/src/kits/network/old/compat/libbind/headers/isc/irpmarshall.h deleted file mode 100644 index 74f0a0a8a8..0000000000 --- a/src/kits/network/old/compat/libbind/headers/isc/irpmarshall.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * $Id$ - */ - -#ifndef _IRPMARSHALL_H_INCLUDED -#define _IRPMARSHALL_H_INCLUDED - -/* Hide function names */ -#define irp_marshall_gr __irp_marshall_gr -#define irp_marshall_ho __irp_marshall_ho -#define irp_marshall_ne __irp_marshall_ne -#define irp_marshall_ng __irp_marshall_ng -#define irp_marshall_nw __irp_marshall_nw -#define irp_marshall_pr __irp_marshall_pr -#define irp_marshall_pw __irp_marshall_pw -#define irp_marshall_sv __irp_marshall_sv -#define irp_unmarshall_gr __irp_unmarshall_gr -#define irp_unmarshall_ho __irp_unmarshall_ho -#define irp_unmarshall_ne __irp_unmarshall_ne -#define irp_unmarshall_ng __irp_unmarshall_ng -#define irp_unmarshall_nw __irp_unmarshall_nw -#define irp_unmarshall_pr __irp_unmarshall_pr -#define irp_unmarshall_pw __irp_unmarshall_pw -#define irp_unmarshall_sv __irp_unmarshall_sv - -#define MAXPADDRSIZE (sizeof "255.255.255.255" + 1) -#define ADDR_T_STR(x) (x == AF_INET ? "AF_INET" :\ - (x == AF_INET6 ? "AF_INET6" : "UNKNOWN")) - -/* See comment below on usage */ -int irp_marshall_pw(const struct passwd *, char **, size_t *); -int irp_unmarshall_pw(struct passwd *, char *); -int irp_marshall_gr(const struct group *, char **, size_t *); -int irp_unmarshall_gr(struct group *, char *); -int irp_marshall_sv(const struct servent *, char **, size_t *); -int irp_unmarshall_sv(struct servent *, char *); -int irp_marshall_pr(struct protoent *, char **, size_t *); -int irp_unmarshall_pr(struct protoent *, char *); -int irp_marshall_ho(struct hostent *, char **, size_t *); -int irp_unmarshall_ho(struct hostent *, char *); -int irp_marshall_ng(const char *, const char *, const char *, - char **, size_t *); -int irp_unmarshall_ng(const char **, const char **, const char **, char *); -int irp_marshall_nw(struct nwent *, char **, size_t *); -int irp_unmarshall_nw(struct nwent *, char *); -int irp_marshall_ne(struct netent *, char **, size_t *); -int irp_unmarshall_ne(struct netent *, char *); - -/* - * Functions to marshall and unmarshall various system data structures. We - * use a printable ascii format that is as close to various system config - * files as reasonable (e.g. /etc/passwd format). - * - * We are not forgiving with unmarhsalling misformatted buffers. In - * particular whitespace in fields is not ignored. So a formatted password - * entry "brister :1364:100:...." will yield a username of "brister " - * - * We potentially do a lot of mallocs to fill fields that are of type - * (char **) like a hostent h_addr field. Building (for example) the - * h_addr field and its associated addresses all in one buffer is - * certainly possible, but not done here. - * - * The following description is true for all the marshalling functions: - * - */ - -/* int irp_marshall_XX(struct yyyy *XX, char **buffer, size_t *len); - * - * The argument XX (of type struct passwd for example) is marshalled in the - * buffer pointed at by *BUFFER, which is of length *LEN. Returns 0 - * on success and -1 on failure. Failure will occur if *LEN is - * smaller than needed. - * - * If BUFFER is NULL, then *LEN is set to the size of the buffer - * needed to marshall the data and no marshalling is actually done. - * - * If *BUFFER is NULL, then a buffer large enough will be allocated - * with memget() and the size allocated will be stored in *LEN. An extra 2 - * bytes will be allocated for the client to append CRLF if wanted. The - * value of *LEN will include these two bytes. - * - * All the marshalling functions produce a buffer with the fields - * separated by colons (except for the hostent marshalling, which uses '@' - * to separate fields). Fields that have multiple subfields (like the - * gr_mem field in struct group) have their subparts separated by - * commas. - */ - -/* - * int irp_unmarshall_XX(struct YYYYY *XX, char *buffer); - * - * The unmashalling functions break apart the buffer and store the - * values in the struct pointed to by XX. All pointer values inside - * XX are allocated with malloc. All arrays of pointers have a NULL - * as the last element. - */ - -#endif diff --git a/src/kits/network/old/compat/libbind/headers/isc/list.h b/src/kits/network/old/compat/libbind/headers/isc/list.h deleted file mode 100644 index ad574ac2b5..0000000000 --- a/src/kits/network/old/compat/libbind/headers/isc/list.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1997,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef LIST_H -#define LIST_H 1 -#include - -#define LIST(type) struct { type *head, *tail; } -#define INIT_LIST(list) \ - do { (list).head = NULL; (list).tail = NULL; } while (0) - -#define LINK(type) struct { type *prev, *next; } -#define INIT_LINK_TYPE(elt, link, type) \ - do { \ - (elt)->link.prev = (type *)(-1); \ - (elt)->link.next = (type *)(-1); \ - } while (0) -#define INIT_LINK(elt, link) \ - INIT_LINK_TYPE(elt, link, void) -#define LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1)) - -#define HEAD(list) ((list).head) -#define TAIL(list) ((list).tail) -#define EMPTY(list) ((list).head == NULL) - -#define PREPEND(list, elt, link) \ - do { \ - INSIST(!LINKED(elt, link));\ - if ((list).head != NULL) \ - (list).head->link.prev = (elt); \ - else \ - (list).tail = (elt); \ - (elt)->link.prev = NULL; \ - (elt)->link.next = (list).head; \ - (list).head = (elt); \ - } while (0) - -#define APPEND(list, elt, link) \ - do { \ - INSIST(!LINKED(elt, link));\ - if ((list).tail != NULL) \ - (list).tail->link.next = (elt); \ - else \ - (list).head = (elt); \ - (elt)->link.prev = (list).tail; \ - (elt)->link.next = NULL; \ - (list).tail = (elt); \ - } while (0) - -#define UNLINK_TYPE(list, elt, link, type) \ - do { \ - INSIST(LINKED(elt, link));\ - if ((elt)->link.next != NULL) \ - (elt)->link.next->link.prev = (elt)->link.prev; \ - else \ - (list).tail = (elt)->link.prev; \ - if ((elt)->link.prev != NULL) \ - (elt)->link.prev->link.next = (elt)->link.next; \ - else \ - (list).head = (elt)->link.next; \ - INIT_LINK_TYPE(elt, link, type); \ - } while (0) -#define UNLINK(list, elt, link) \ - UNLINK_TYPE(list, elt, link, void) - -#define PREV(elt, link) ((elt)->link.prev) -#define NEXT(elt, link) ((elt)->link.next) - -#define INSERT_BEFORE(list, before, elt, link) \ - do { \ - INSIST(!LINKED(elt, link));\ - if ((before)->link.prev == NULL) \ - PREPEND(list, elt, link); \ - else { \ - (elt)->link.prev = (before)->link.prev; \ - (before)->link.prev = (elt); \ - (elt)->link.prev->link.next = (elt); \ - (elt)->link.next = (before); \ - } \ - } while (0) - -#define INSERT_AFTER(list, after, elt, link) \ - do { \ - INSIST(!LINKED(elt, link));\ - if ((after)->link.next == NULL) \ - APPEND(list, elt, link); \ - else { \ - (elt)->link.next = (after)->link.next; \ - (after)->link.next = (elt); \ - (elt)->link.next->link.prev = (elt); \ - (elt)->link.prev = (after); \ - } \ - } while (0) - -#define ENQUEUE(list, elt, link) APPEND(list, elt, link) -#define DEQUEUE(list, elt, link) UNLINK(list, elt, link) - -#endif /* LIST_H */ diff --git a/src/kits/network/old/compat/libbind/headers/isc/logging.h b/src/kits/network/old/compat/libbind/headers/isc/logging.h deleted file mode 100644 index 574fd8a257..0000000000 --- a/src/kits/network/old/compat/libbind/headers/isc/logging.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef LOGGING_H -#define LOGGING_H - -#include -#include -#include -#include - -#define log_critical (-5) -#define log_error (-4) -#define log_warning (-3) -#define log_notice (-2) -#define log_info (-1) -#define log_debug(level) (level) - -typedef enum { log_syslog, log_file, log_null } log_channel_type; - -#define LOG_MAX_VERSIONS 99 - -#define LOG_CLOSE_STREAM 0x0001 -#define LOG_TIMESTAMP 0x0002 -#define LOG_TRUNCATE 0x0004 -#define LOG_USE_CONTEXT_LEVEL 0x0008 -#define LOG_PRINT_LEVEL 0x0010 -#define LOG_REQUIRE_DEBUG 0x0020 -#define LOG_CHANNEL_BROKEN 0x0040 -#define LOG_PRINT_CATEGORY 0x0080 -#define LOG_CHANNEL_OFF 0x0100 - -typedef struct log_context *log_context; -typedef struct log_channel *log_channel; - -#define LOG_OPTION_DEBUG 0x01 -#define LOG_OPTION_LEVEL 0x02 - -#define log_open_stream __log_open_stream -#define log_close_stream __log_close_stream -#define log_get_stream __log_get_stream -#define log_get_filename __log_get_filename -#define log_check_channel __log_check_channel -#define log_check __log_check -#define log_vwrite __log_vwrite -#define log_write __log_write -#define log_new_context __log_new_context -#define log_free_context __log_free_context -#define log_add_channel __log_add_channel -#define log_remove_channel __log_remove_channel -#define log_option __log_option -#define log_category_is_active __log_category_is_active -#define log_new_syslog_channel __log_new_syslog_channel -#define log_new_file_channel __log_new_file_channel -#define log_set_file_owner __log_set_file_owner -#define log_new_null_channel __log_new_null_channel -#define log_inc_references __log_inc_references -#define log_dec_references __log_dec_references -#define log_get_channel_type __log_get_channel_type -#define log_free_channel __log_free_channel -#define log_close_debug_channels __log_close_debug_channels - -FILE * log_open_stream(log_channel); -int log_close_stream(log_channel); -FILE * log_get_stream(log_channel); -char * log_get_filename(log_channel); -int log_check_channel(log_context, int, log_channel); -int log_check(log_context, int, int); -#ifdef __GNUC__ -void log_vwrite(log_context, int, int, const char *, - va_list args) - __attribute__((__format__(__printf__, 4, 0))); -void log_write(log_context, int, int, const char *, ...) - __attribute__((__format__(__printf__, 4, 5))); -#else -void log_vwrite(log_context, int, int, const char *, - va_list args); -void log_write(log_context, int, int, const char *, ...); -#endif -int log_new_context(int, char **, log_context *); -void log_free_context(log_context); -int log_add_channel(log_context, int, log_channel); -int log_remove_channel(log_context, int, log_channel); -int log_option(log_context, int, int); -int log_category_is_active(log_context, int); -log_channel log_new_syslog_channel(unsigned int, int, int); -log_channel log_new_file_channel(unsigned int, int, const char *, - FILE *, unsigned int, - unsigned long); -int log_set_file_owner(log_channel, uid_t, gid_t); -log_channel log_new_null_channel(void); -int log_inc_references(log_channel); -int log_dec_references(log_channel); -log_channel_type log_get_channel_type(log_channel); -int log_free_channel(log_channel); -void log_close_debug_channels(log_context); - -#endif /* !LOGGING_H */ diff --git a/src/kits/network/old/compat/libbind/headers/isc/memcluster.h b/src/kits/network/old/compat/libbind/headers/isc/memcluster.h deleted file mode 100644 index 11e1fa381d..0000000000 --- a/src/kits/network/old/compat/libbind/headers/isc/memcluster.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1997,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef MEMCLUSTER_H -#define MEMCLUSTER_H - -#include - -#define meminit __meminit -#ifdef MEMCLUSTER_DEBUG -#define memget(s) __memget_debug(s, __FILE__, __LINE__) -#define memput(p, s) __memput_debug(p, s, __FILE__, __LINE__) -#else /*MEMCLUSTER_DEBUG*/ -#ifdef MEMCLUSTER_RECORD -#define memget(s) __memget_record(s, __FILE__, __LINE__) -#define memput(p, s) __memput_record(p, s, __FILE__, __LINE__) -#else /*MEMCLUSTER_RECORD*/ -#define memget __memget -#define memput __memput -#endif /*MEMCLUSTER_RECORD*/ -#endif /*MEMCLUSTER_DEBUG*/ -#define memstats __memstats -#define memactive __memactive - -int meminit(size_t, size_t); -void * __memget(size_t); -void __memput(void *, size_t); -void * __memget_debug(size_t, const char *, int); -void __memput_debug(void *, size_t, const char *, int); -void * __memget_record(size_t, const char *, int); -void __memput_record(void *, size_t, const char *, int); -void memstats(FILE *); -int memactive(void); - -#endif /* MEMCLUSTER_H */ diff --git a/src/kits/network/old/compat/libbind/headers/isc/misc.h b/src/kits/network/old/compat/libbind/headers/isc/misc.h deleted file mode 100644 index f3b181890c..0000000000 --- a/src/kits/network/old/compat/libbind/headers/isc/misc.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1995-1999 by Internet Software Consortium - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * $Id$ - */ - -#ifndef _ISC_MISC_H -#define _ISC_MISC_H - -#include - -#define bitncmp __bitncmp -/*#define isc_movefile __isc_movefile */ - -extern int bitncmp(const void *, const void *, int); -extern int isc_movefile(const char *, const char *); - -extern int isc_gethexstring(unsigned char *, size_t, int, FILE *, - int *); -extern void isc_puthexstring(FILE *, const unsigned char *, size_t, - size_t, size_t, const char *); -extern void isc_tohex(const unsigned char *, size_t, char *); - -#endif /*_ISC_MISC_H*/ diff --git a/src/kits/network/old/compat/libbind/headers/isc/tree.h b/src/kits/network/old/compat/libbind/headers/isc/tree.h deleted file mode 100644 index 9bdc7e037e..0000000000 --- a/src/kits/network/old/compat/libbind/headers/isc/tree.h +++ /dev/null @@ -1,58 +0,0 @@ -/* tree.h - declare structures used by tree library - * - * vix 22jan93 [revisited; uses RCS, ANSI, POSIX; has bug fixes] - * vix 27jun86 [broken out of tree.c] - * - * $Id$ - */ - - -#ifndef _TREE_H_INCLUDED -#define _TREE_H_INCLUDED - - -#ifndef __P -# if defined(__STDC__) || defined(__GNUC__) -# define __P(x) x -# else -# define __P(x) () -# endif -#endif - -/* - * tree_t is our package-specific anonymous pointer. - */ -#if defined(__STDC__) || defined(__GNUC__) -typedef void *tree_t; -#else -typedef char *tree_t; -#endif - -/* - * Do not taint namespace - */ -#define tree_add __tree_add -#define tree_delete __tree_delete -#define tree_init __tree_init -#define tree_mung __tree_mung -#define tree_srch __tree_srch -#define tree_trav __tree_trav - - -typedef struct tree_s { - tree_t data; - struct tree_s *left, *right; - short bal; - } - tree; - - -void tree_init __P((tree **)); -tree_t tree_srch __P((tree **, int (*)(), tree_t)); -tree_t tree_add __P((tree **, int (*)(), tree_t, void (*)())); -int tree_delete __P((tree **, int (*)(), tree_t, void (*)())); -int tree_trav __P((tree **, int (*)())); -void tree_mung __P((tree **, void (*)())); - - -#endif /* _TREE_H_INCLUDED */ diff --git a/src/kits/network/old/compat/libbind/headers/res_update.h b/src/kits/network/old/compat/libbind/headers/res_update.h deleted file mode 100644 index beb6c63fb9..0000000000 --- a/src/kits/network/old/compat/libbind/headers/res_update.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1999 by Internet Software Consortium, Inc. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * $Id$ - */ - -#ifndef __RES_UPDATE_H -#define __RES_UPDATE_H - -#include -#include -#include -#include - -/* - * This RR-like structure is particular to UPDATE. - */ -struct ns_updrec { - LINK(struct ns_updrec) r_link, r_glink; - ns_sect r_section; /* ZONE/PREREQUISITE/UPDATE */ - char * r_dname; /* owner of the RR */ - ns_class r_class; /* class number */ - ns_type r_type; /* type number */ - u_int32_t r_ttl; /* time to live */ - u_char * r_data; /* rdata fields as text string */ - u_int r_size; /* size of r_data field */ - int r_opcode; /* type of operation */ - /* following fields for private use by the resolver/server routines */ - struct databuf *r_dp; /* databuf to process */ - struct databuf *r_deldp; /* databuf's deleted/overwritten */ - u_int r_zone; /* zone number on server */ -}; -typedef struct ns_updrec ns_updrec; -typedef LIST(ns_updrec) ns_updque; - -#define res_mkupdate __res_mkupdate -#define res_update __res_update -#define res_mkupdrec __res_mkupdrec -#define res_freeupdrec __res_freeupdrec -#define res_nmkupdate __res_nmkupdate -#define res_nupdate __res_nupdate - -int res_mkupdate __P((ns_updrec *, u_char *, int)); -int res_update __P((ns_updrec *)); -ns_updrec * res_mkupdrec __P((int, const char *, u_int, u_int, u_long)); -void res_freeupdrec __P((ns_updrec *)); -int res_nmkupdate __P((res_state, ns_updrec *, u_char *, int)); -int res_nupdate __P((res_state, ns_updrec *, ns_tsig_key *)); - -#endif /*__RES_UPDATE_H*/ diff --git a/src/kits/network/old/compat/libbind/headers/sys/un.h b/src/kits/network/old/compat/libbind/headers/sys/un.h deleted file mode 100644 index bdbf5a6063..0000000000 --- a/src/kits/network/old/compat/libbind/headers/sys/un.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _SYS_UN_H -#define _SYS_UN_H - - -/* TODO: implement */ - - -#endif /* _SYS_UN_H */ diff --git a/src/kits/network/old/compat/libbind/headers/utmp.h b/src/kits/network/old/compat/libbind/headers/utmp.h deleted file mode 100644 index 8c115d14a6..0000000000 --- a/src/kits/network/old/compat/libbind/headers/utmp.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef UTMP_H -#define UTMP_H - - -/* TODO: implement */ - - -#endif /* UTMP_H */ diff --git a/src/kits/network/old/compat/libbind/port_after.h b/src/kits/network/old/compat/libbind/port_after.h deleted file mode 100644 index 09270697ec..0000000000 --- a/src/kits/network/old/compat/libbind/port_after.h +++ /dev/null @@ -1,422 +0,0 @@ -#ifndef port_after_h -#define port_after_h - -#include -#include -#include -#include -#if (!defined(BSD)) || (BSD < 199306) -#include -#endif - -// CHANGED: Haiku does not have these error codes -#define ETOOMANYREFS B_ERROR - -// CHANGED: Haiku fd_set has 'bits' instead of 'fds_bits' -#define fds_bits bits - -// CHANGED: Haiku does have pselect, turn on when not compiling for Haiku -#ifndef __HAIKU__ -#define NEED_PSELECT -#endif - -// CHANGED: we don't want the daemon -#undef NEED_DAEMON - -// CHANGED -#define HAVE_SOCKADDR_STORAGE 1 - -#define HAVE_SA_LEN 1 -#undef HAVE_MINIMUM_IFREQ -#define NEED_STRSEP 1 -#undef NEED_STRERROR -#undef HAS_INET6_STRUCTS -#define HAVE_SIN6_SCOPE_ID 1 -#undef NEED_IN6ADDR_ANY - -#undef NEED_GETTIMEOFDAY -#undef HAVE_STRNDUP -#undef USE_FIONBIO_IOCTL -#undef USE_SYSERROR_LIST -#undef INNETGR_ARGS -#undef SETNETGRENT_ARGS -#undef USE_IFNAMELINKID - -/* XXX sunos and cygwin needs O_NDELAY */ -#define PORT_NONBLOCK O_NONBLOCK - -/* - * We need to know the IPv6 address family number even on IPv4-only systems. - * Note that this is NOT a protocol constant, and that if the system has its - * own AF_INET6, different from ours below, all of BIND's libraries and - * executables will need to be recompiled after the system - * has had this type added. The type number below is correct on most BSD- - * derived systems for which AF_INET6 is defined. - */ -#ifndef AF_INET6 -#define AF_INET6 24 -#endif - -#ifndef PF_INET6 -#define PF_INET6 AF_INET6 -#endif - -#ifdef HAS_IN_ADDR6 -/* Map to pre-RFC structure. */ -#define in6_addr in_addr6 -#endif - -#ifndef HAS_INET6_STRUCTS -/* Replace with structure from later rev of O/S if known. */ -struct in6_addr { - u_int8_t s6_addr[16]; -}; - -#define IN6ADDR_ANY_INIT \ - {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }} - -#define IN6ADDR_LOOPBACK_INIT \ - {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }} - -/* Replace with structure from later rev of O/S if known. */ -struct sockaddr_in6 { -#ifdef HAVE_SA_LEN - u_int8_t sin6_len; /* length of this struct */ - u_int8_t sin6_family; /* AF_INET6 */ -#else - u_int16_t sin6_family; /* AF_INET6 */ -#endif - u_int16_t sin6_port; /* transport layer port # */ - u_int32_t sin6_flowinfo; /* IPv6 flow information */ - struct in6_addr sin6_addr; /* IPv6 address */ - u_int32_t sin6_scope_id; /* set of interfaces for a scope */ -}; -#endif /* HAS_INET6_STRUCTS */ - -#ifdef BROKEN_IN6ADDR_INIT_MACROS -#undef IN6ADDR_ANY_INIT -#undef IN6ADDR_LOOPBACK_INIT -#endif - -#ifdef _AIX -#ifndef IN6ADDR_ANY_INIT -#define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}} -#endif -#ifndef IN6ADDR_LOOPBACK_INIT -#if BYTE_ORDER == BIG_ENDIAN -#define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}} -#else -#define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}} -#endif -#endif -#endif - -#ifndef IN6ADDR_ANY_INIT -#ifdef s6_addr -#define IN6ADDR_ANY_INIT \ - {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} -#else -#define IN6ADDR_ANY_INIT \ - {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }} -#endif - -#endif -#ifndef IN6ADDR_LOOPBACK_INIT -#ifdef s6_addr -#define IN6ADDR_LOOPBACK_INIT \ - {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} -#else -#define IN6ADDR_LOOPBACK_INIT \ - {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }} -#endif -#endif - -#ifndef HAVE_SOCKADDR_STORAGE -#define __SS_MAXSIZE 128 -#define __SS_ALLIGSIZE (sizeof (long)) - -struct sockaddr_storage { -#ifdef HAVE_SA_LEN - u_int8_t ss_len; /* address length */ - u_int8_t ss_family; /* address family */ - char __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)]; - long __ss_align; - char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE]; -#else - u_int16_t ss_family; /* address family */ - char __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)]; - long __ss_align; - char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE]; -#endif -}; -#endif - - -#if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY) -#define in6addr_any isc_in6addr_any -extern const struct in6_addr in6addr_any; -#endif - -/* - * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and - * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1. - */ -#ifdef __GLIBC__ -#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2) -#undef IN6_ARE_ADDR_EQUAL -#undef IN6_IS_ADDR_UNSPECIFIED -#undef IN6_IS_ADDR_V4COMPAT -#undef IN6_IS_ADDR_V4MAPPED -#endif -#endif - -#ifndef IN6_ARE_ADDR_EQUAL -#define IN6_ARE_ADDR_EQUAL(a,b) \ - (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0) -#endif - -#ifndef IN6_IS_ADDR_UNSPECIFIED -#define IN6_IS_ADDR_UNSPECIFIED(a) \ - IN6_ARE_ADDR_EQUAL(a, &in6addr_any) -#endif - -#ifndef IN6_IS_ADDR_LOOPBACK -extern const struct in6_addr isc_in6addr_loopback; -#define IN6_IS_ADDR_LOOPBACK(a) \ - IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback) -#endif - -#ifndef IN6_IS_ADDR_V4MAPPED -#define IN6_IS_ADDR_V4MAPPED(a) \ - ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \ - (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \ - (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \ - (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \ - (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \ - (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff) -#endif - -#ifndef IN6_IS_ADDR_SITELOCAL -#define IN6_IS_ADDR_SITELOCAL(a) \ - (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) -#endif - -#ifndef IN6_IS_ADDR_LINKLOCAL -#define IN6_IS_ADDR_LINKLOCAL(a) \ - (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) -#endif - -#ifndef IN6_IS_ADDR_MULTICAST -#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) -#endif - -#ifndef __IPV6_ADDR_MC_SCOPE -#define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) -#endif - -#ifndef __IPV6_ADDR_SCOPE_SITELOCAL -#define __IPV6_ADDR_SCOPE_SITELOCAL 0x05 -#endif -#ifndef __IPV6_ADDR_SCOPE_ORGLOCAL -#define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08 -#endif - -#ifndef IN6_IS_ADDR_MC_SITELOCAL -#define IN6_IS_ADDR_MC_SITELOCAL(a) \ - (IN6_IS_ADDR_MULTICAST(a) && \ - (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL)) -#endif - -#ifndef IN6_IS_ADDR_MC_ORGLOCAL -#define IN6_IS_ADDR_MC_ORGLOCAL(a) \ - (IN6_IS_ADDR_MULTICAST(a) && \ - (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL)) -#endif - -#ifndef INADDR_NONE -#define INADDR_NONE 0xffffffff -#endif - -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 256 -#endif - -#ifndef INET6_ADDRSTRLEN -/* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */ -#define INET6_ADDRSTRLEN 46 -#endif - -#ifndef MIN -#define MIN(x,y) (((x) <= (y)) ? (x) : (y)) -#endif - -#ifndef MAX -#define MAX(x,y) (((x) >= (y)) ? (x) : (y)) -#endif - -#ifdef NEED_DAEMON -int daemon(int nochdir, int noclose); -#endif - -#ifdef NEED_STRSEP -char * strsep(char **stringp, const char *delim); -#endif - -#ifndef ALIGN -#define ALIGN(p) (((unsigned int)(p) + (sizeof(int) - 1)) & ~(sizeof(int) - 1)) -#endif - -#ifdef NEED_SETGROUPENT -int setgroupent(int stayopen); -#endif - -#ifdef NEED_GETGROUPLIST -int getgrouplist(GETGROUPLIST_ARGS); -#endif - -#ifdef POSIX_GETGRNAM_R -int -__posix_getgrnam_r(const char *, struct group *, char *, int, struct group **); -#endif - -#ifdef NEED_GETGRNAM_R -int -getgrnam_r(const char *, struct group *, char *, size_t, struct group **); -#endif - -#ifdef POSIX_GETGRGID_R -int -__posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ; -#endif - -#ifdef NEED_GETGRGID_R -int -getgrgid_r(gid_t, struct group *, char *, size_t, struct group **); -#endif - -#ifdef NEED_GETGRENT_R -GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS); -#endif - -#ifdef NEED_SETGRENT_R -GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS); -#endif - -#ifdef NEED_ENDGRENT_R -GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS); -#endif - -#ifdef NEED_INNETGR_R -NGR_R_RETURN -innetgr_r(const char *, const char *, const char *, const char *); -#endif - -#ifdef NEED_SETNETGRENT_R -#ifdef NGR_R_ENT_ARGS -NGR_R_SET_RETURN setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS); -#else -NGR_R_SET_RETURN setnetgrent_r(const char *netgroup); -#endif -#endif - -#ifdef NEED_ENDNETGRENT_R -#ifdef NGR_R_ENT_ARGS -NGR_R_END_RETURN endnetgrent_r(NGR_R_ENT_ARGS); -#else -NGR_R_END_RETURN endnetgrent_r(void); -#endif -#endif - -#ifdef POSIX_GETPWNAM_R -int -__posix_getpwnam_r(const char *login, struct passwd *pwptr, - char *buf, size_t buflen, struct passwd **result); -#endif - -#ifdef NEED_GETPWNAM_R -int -getpwnam_r(const char *login, struct passwd *pwptr, - char *buf, size_t buflen, struct passwd **result); -#endif - -#ifdef POSIX_GETPWUID_R -int -__posix_getpwuid_r(uid_t uid, struct passwd *pwptr, - char *buf, int buflen, struct passwd **result); -#endif - -#ifdef NEED_GETPWUID_R -int -getpwuid_r(uid_t uid, struct passwd *pwptr, - char *buf, size_t buflen, struct passwd **result); -#endif - -#ifdef NEED_SETPWENT_R -#ifdef PASS_R_ENT_ARGS -PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS); -#else -PASS_R_SET_RETURN setpwent_r(void); -#endif - -#endif - -#ifdef NEED_SETPASSENT_R -#ifdef PASS_R_ENT_ARGS -PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS); -#else -PASS_R_SET_RETURN setpassent_r(int stayopen); -#endif -#endif - -#ifdef NEED_GETPWENT_R -PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS); -#endif - -#ifdef NEED_ENDPWENT_R -void endpwent_r(void); -#endif - -#ifdef NEED_SETPASSENT -int setpassent(int stayopen); -#endif - -#define gettimeofday isc__gettimeofday -#ifdef NEED_GETTIMEOFDAY -int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp); -#else -int isc__gettimeofday(struct timeval *tp, struct timezone *tzp); -#endif - -int getnetgrent(char **machinep, char **userp, char **domainp); - -int getnetgrent_r(char **machinep, char **userp, char **domainp, NGR_R_ARGS); - -#ifdef SETNETGRENT_ARGS -void setnetgrent(SETNETGRENT_ARGS); -#else -void setnetgrent(const char *netgroup); -#endif - -void endnetgrent(void); - -#ifdef INNETGR_ARGS -int innetgr(INNETGR_ARGS); -#else -int innetgr(const char *netgroup, const char *machine, - const char *user, const char *domain); -#endif - -#ifdef NGR_R_ENT_ARGS -NGR_R_SET_RETURN -setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS); -#else -NGR_R_SET_RETURN -setnetgrent_r(const char *netgroup); -#endif -#endif diff --git a/src/kits/network/old/compat/libbind/port_before.h b/src/kits/network/old/compat/libbind/port_before.h deleted file mode 100644 index 25a4758980..0000000000 --- a/src/kits/network/old/compat/libbind/port_before.h +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef port_before_h -#define port_before_h -#include - -struct group; /* silence warning */ -struct passwd; /* silence warning */ -struct timeval; /* silence warning */ -struct timezone; /* silence warning */ - -#ifdef HAVE_SYS_TIMERS_H -#include -#endif -#include - - -#undef WANT_IRS_GR -#undef WANT_IRS_NIS -#undef WANT_IRS_PW - -#undef BSD_COMP - -// CHANGED: pthread emulation -#define DO_PTHREADS 1 - -#define GETGROUPLIST_ARGS const char *name, gid_t basegid, gid_t *groups, int *ngroups -#define GETNETBYADDR_ADDR_T long -#define SETPWENT_VOID 1 -#define SETGRENT_VOID 1 - -#define NET_R_ARGS char *buf, int buflen -#define NET_R_BAD NULL -#define NET_R_COPY buf, buflen -#define NET_R_COPY_ARGS NET_R_ARGS -#define NET_R_END_RESULT(x) /*empty*/ -#define NET_R_END_RETURN void -#undef NET_R_ENT_ARGS /*empty*/ -#define NET_R_OK nptr -#define NET_R_RETURN struct netent * -#undef NET_R_SET_RESULT /*empty*/ -#undef NET_R_SETANSWER -#define NET_R_SET_RETURN void -#undef NETENT_DATA - -#define GROUP_R_RETURN struct group * -#define GROUP_R_SET_RETURN void -#undef GROUP_R_SET_RESULT /*empty*/ -#define GROUP_R_END_RETURN void -#define GROUP_R_END_RESULT(x) /*empty*/ -#define GROUP_R_ARGS char *buf, int buflen -#define GROUP_R_ENT_ARGS void -#define GROUP_R_OK gptr -#define GROUP_R_BAD NULL - -#define HOST_R_ARGS char *buf, int buflen, int *h_errnop -#define HOST_R_BAD NULL -#define HOST_R_COPY buf, buflen -#define HOST_R_COPY_ARGS char *buf, int buflen -#define HOST_R_END_RESULT(x) /*empty*/ -#define HOST_R_END_RETURN void -#undef HOST_R_ENT_ARGS /*empty*/ -#define HOST_R_ERRNO *h_errnop = h_errno -#define HOST_R_OK hptr -#define HOST_R_RETURN struct hostent * -#undef HOST_R_SETANSWER -#undef HOST_R_SET_RESULT -#define HOST_R_SET_RETURN void -#undef HOSTENT_DATA - -#define NGR_R_ARGS char *buf, int buflen -#define NGR_R_BAD (0) -#define NGR_R_COPY buf, buflen -#define NGR_R_COPY_ARGS NGR_R_ARGS -#define NGR_R_END_RESULT(x) /*empty*/ -#define NGR_R_END_RETURN void -#undef NGR_R_ENT_ARGS /*empty*/ -#define NGR_R_OK 1 -#define NGR_R_RETURN int -#undef NGR_R_SET_RESULT /*empty*/ -#define NGR_R_SET_RETURN void - - -#define PROTO_R_ARGS char *buf, int buflen -#define PROTO_R_BAD NULL -#define PROTO_R_COPY buf, buflen -#define PROTO_R_COPY_ARGS PROTO_R_ARGS -#define PROTO_R_END_RESULT(x) /*empty*/ -#define PROTO_R_END_RETURN void -#undef PROTO_R_ENT_ARGS /*empty*/ -#define PROTO_R_OK pptr -#undef PROTO_R_SETANSWER -#define PROTO_R_RETURN struct protoent * -#undef PROTO_R_SET_RESULT -#define PROTO_R_SET_RETURN void - -#define PASS_R_ARGS char *buf, int buflen -#define PASS_R_BAD NULL -#define PASS_R_COPY buf, buflen -#define PASS_R_COPY_ARGS PASS_R_ARGS -#define PASS_R_END_RESULT(x) /*empty*/ -#define PASS_R_END_RETURN void -#undef PASS_R_ENT_ARGS -#define PASS_R_OK pwptr -#define PASS_R_RETURN struct passwd * -#undef PASS_R_SET_RESULT /*empty*/ -#define PASS_R_SET_RETURN void - -#define SERV_R_ARGS char *buf, int buflen -#define SERV_R_BAD NULL -#define SERV_R_COPY buf, buflen -#define SERV_R_COPY_ARGS SERV_R_ARGS -#define SERV_R_END_RESULT(x) /*empty*/ -#define SERV_R_END_RETURN void -#undef SERV_R_ENT_ARGS /*empty*/ -#define SERV_R_OK sptr -#undef SERV_R_SETANSWER -#define SERV_R_RETURN struct servent * -#undef SERV_R_SET_RESULT -#define SERV_R_SET_RETURN void - - -#define DE_CONST(konst, var) \ - do { \ - union { const void *k; void *v; } _u; \ - _u.k = konst; \ - var = _u.v; \ - } while (0) - -#define UNUSED(x) (x) = (x) - -#undef NEED_SOLARIS_BITTYPES -#define ISC_SOCKLEN_T int - -#ifdef __GNUC__ -#define ISC_FORMAT_PRINTF(fmt, args) \ - __attribute__((__format__(__printf__, fmt, args))) -#else -#define ISC_FORMAT_PRINTF(fmt, args) -#endif - -#endif diff --git a/src/kits/network/old/compat/libnet/Jamfile b/src/kits/network/old/compat/libnet/Jamfile deleted file mode 100644 index 7d6ef1c251..0000000000 --- a/src/kits/network/old/compat/libnet/Jamfile +++ /dev/null @@ -1,124 +0,0 @@ -SubDir HAIKU_TOP src kits network compat libnet ; - -SetSubDirSupportedPlatformsBeOSCompatible ; - -UseHeaders [ FDirName $(SUBDIR) headers ] : true ; -UsePrivateHeaders net ; -UseHeaders [ FDirName $(HAIKU_TOP) headers legacy network ] : true ; - -if $(TARGET_PLATFORM) != haiku { - UseHeaders [ FDirName $(HAIKU_TOP) headers posix ] : true ; - # We need the public network headers also when not compiling for Haiku. - # Unfortunately we get more than we want, namely all POSIX headers. - - # Default libs include BeOS R5 libnet.so, something we don't want here! - LINKFLAGS on libnet.so = [ on libnet.so return $(LINKFLAGS) ] - -nodefaultlibs -lroot ; -} - -{ - # actually we are always BUILDING_R5_LIBNET, as this means we get unprefixed - # versions of inet_* functions in libnet.so, which is how it should be in any case - # BONE versions of the inet_* functions are prefixed with __ in and - # implemented in libbind.so as are ours. - local defines ; - if $(TARGET_PLATFORM) = r5 { - defines += BUILDING_R5_LIBNET ; - } else if $(TARGET_PLATFORM) = bone { - defines += BONE_VERSION ; - defines += BUILDING_R5_LIBNET ; - } else if $(TARGET_PLATFORM) = haiku { - defines += BUILDING_R5_LIBNET ; - } - defines = [ FDefines $(defines) ] ; - SubDirCcFlags $(defines) ; - SubDirC++Flags $(defines) ; -} - -#Depends libnet.so : install_network_etc_files ; - -if $(TARGET_PLATFORM) = r5 { - PLATFORM_SOURCES = - select.c - poll.c - ; - PLATFORM_LIBS = ; -} else { - # under Haiku and BONE we don't need the above - # because they are in libsocket.so or libroot.so - PLATFORM_SOURCES = ; - PLATFORM_LIBS = libsocket.so ; -} - -SharedLibrary libnet.so : - $(PLATFORM_SOURCES) - netdebug.c - netconfig.c - socket.c - compat.c - arc4random.c - base64.c - ethers.c - freeaddrinfo.c - inet_addr.c - inet_ntoa.c - inet_neta.c - inet_netof.c - inet_lnaof.c - inet_network.c - inet_pton.c - inet_ntop.c - getaddrinfo.c - gethostnamadr.c - getnameinfo.c - getnetbyaddr.c - getnetbyname.c - getnetnamadr.c - getprotoname.c - getnetent.c - getproto.c - getprotoent.c - getservent.c - getservbyname.c - getservbyport.c - linkaddr.c - res_comp.c - res_data.c - res_debug.c - res_init.c - res_mkquery.c - res_query.c - res_random.c - res_send.c - sethostent.c - - : $(PLATFORM_LIBS) -; - -# HaikuInstall install_network_etc_files : [ FDirName $(HAIKU_ETC_DIR) ] : -# resolv.conf -# services -# protocols -# networks -# ; - -# Installation -- in the test directory for the time being -HaikuInstallRelSymLink install-networking - : [ FDirName $(HAIKU_TEST_DIR) kits net lib ] - : libnet.so - : installed-networking-test ; - -HaikuInstallRelSymLink install-userland-networking - : [ FDirName $(HAIKU_TEST_DIR) kits net userland lib ] - : libnet.so - : installed-userland-networking ; - -Package haiku-networkingkit-cvs : - libnet.so : -# boot home config lib ; - boot home Desktop haiku-networkingkit lib ; - -Package haiku-networkingkit-cvs : - resolv.conf services protocols networks : -# boot beos etc ; - boot home Desktop haiku-networkingkit etc ; diff --git a/src/kits/network/old/compat/libnet/arc4random.c b/src/kits/network/old/compat/libnet/arc4random.c deleted file mode 100644 index 9b3514a5ab..0000000000 --- a/src/kits/network/old/compat/libnet/arc4random.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Arc4 random number generator for OpenBSD. - * Copyright 1996 David Mazieres . - * - * Modification and redistribution in source and binary forms is - * permitted provided that due credit is given to the author and the - * OpenBSD project by leaving this copyright notice intact. - */ - -/* - * This code is derived from section 17.1 of Applied Cryptography, - * second edition, which describes a stream cipher allegedly - * compatible with RSA Labs "RC4" cipher (the actual description of - * which is a trade secret). The same algorithm is used as a stream - * cipher called "arcfour" in Tatu Ylonen's ssh package. - * - * Here the stream cipher has been modified always to include the time - * when initializing the state. That makes it impossible to - * regenerate the same random sequence twice, so this can't be used - * for encryption, but will generate good random numbers. - * - * RC4 is a registered trademark of RSA Laboratories. - */ - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __GNUC__ -#define inline __inline -#else /* !__GNUC__ */ -#define inline -#endif /* !__GNUC__ */ - -struct arc4_stream { - uint8 i; - uint8 j; - uint8 s[256]; -}; - -int rs_initialized; -static struct arc4_stream rs; - - -static inline void arc4_init(struct arc4_stream *as) -{ - int n; - - for (n = 0; n < 256; n++) - as->s[n] = n; - as->i = 0; - as->j = 0; -} - - -static inline void arc4_addrandom(struct arc4_stream *as, - u_char *dat, int datlen) -{ - int n; - uint8 si; - - as->i--; - for (n = 0; n < 256; n++) { - as->i = (as->i + 1); - si = as->s[as->i]; - as->j = (as->j + si + dat[n % datlen]); - as->s[as->i] = as->s[as->j]; - as->s[as->j] = si; - } - as->j = as->i; -} - - -static void arc4_stir(struct arc4_stream *as) -{ - int fd; - struct { - struct timeval tv; - u_int rnd[(128 - sizeof(struct timeval)) / sizeof(u_int)]; - } rdat; - - gettimeofday(&rdat.tv, NULL); - fd = open("/dev/arandom", O_RDONLY); - if (fd != -1) { - read(fd, rdat.rnd, sizeof(rdat.rnd)); - close(fd); - } - /* fd < 0 or failed sysctl ? Ah, what the heck. We'll just take - * whatever was on the stack... */ - - arc4_addrandom(as, (void *) &rdat, sizeof(rdat)); -} - - -static inline uint8 arc4_getbyte(struct arc4_stream *as) -{ - uint8 si, sj; - - as->i = (as->i + 1); - si = as->s[as->i]; - as->j = (as->j + si); - sj = as->s[as->j]; - as->s[as->i] = sj; - as->s[as->j] = si; - return (as->s[(si + sj) & 0xff]); -} - - -static inline uint32 arc4_getword(struct arc4_stream *as) -{ - uint32 val; - val = arc4_getbyte(as) << 24; - val |= arc4_getbyte(as) << 16; - val |= arc4_getbyte(as) << 8; - val |= arc4_getbyte(as); - return val; -} - - -void arc4random_stir(void) -{ - if (!rs_initialized) { - arc4_init(&rs); - rs_initialized = 1; - } - arc4_stir(&rs); -} - -void arc4random_addrandom(u_char *dat, int datlen) -{ - if (!rs_initialized) - arc4random_stir(); - arc4_addrandom(&rs, dat, datlen); -} - - -uint32 arc4random() -{ - if (!rs_initialized) - arc4random_stir(); - return arc4_getword(&rs); -} diff --git a/src/kits/network/old/compat/libnet/base64.c b/src/kits/network/old/compat/libnet/base64.c deleted file mode 100644 index cf15af3c00..0000000000 --- a/src/kits/network/old/compat/libnet/base64.c +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Copyright (c) 1996 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -/* - * Portions Copyright (c) 1995 by International Business Machines, Inc. - * - * International Business Machines, Inc. (hereinafter called IBM) grants - * permission under its copyrights to use, copy, modify, and distribute this - * Software with or without fee, provided that the above copyright notice and - * all paragraphs of this notice appear in all copies, and that the name of IBM - * not be used in connection with the marketing of any product incorporating - * the Software or modifications thereof, without specific, written prior - * permission. - * - * To the extent it has a right to do so, IBM grants an immunity from suit - * under its patents, if any, for the use, sale or manufacture of products to - * the extent that such products are used for performing Domain Name System - * dynamic updates in TCP/IP networks by means of the Software. No immunity is - * granted for any product per se or for any other function of any product. - * - * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, - * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN - * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#define Assert(Cond) if (!(Cond)) abort() - -static const char Base64[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static const char Pad64 = '='; - -/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt) - The following encoding technique is taken from RFC 1521 by Borenstein - and Freed. It is reproduced here in a slightly edited form for - convenience. - - A 65-character subset of US-ASCII is used, enabling 6 bits to be - represented per printable character. (The extra 65th character, "=", - is used to signify a special processing function.) - - The encoding process represents 24-bit groups of input bits as output - strings of 4 encoded characters. Proceeding from left to right, a - 24-bit input group is formed by concatenating 3 8-bit input groups. - These 24 bits are then treated as 4 concatenated 6-bit groups, each - of which is translated into a single digit in the base64 alphabet. - - Each 6-bit group is used as an index into an array of 64 printable - characters. The character referenced by the index is placed in the - output string. - - Table 1: The Base64 Alphabet - - Value Encoding Value Encoding Value Encoding Value Encoding - 0 A 17 R 34 i 51 z - 1 B 18 S 35 j 52 0 - 2 C 19 T 36 k 53 1 - 3 D 20 U 37 l 54 2 - 4 E 21 V 38 m 55 3 - 5 F 22 W 39 n 56 4 - 6 G 23 X 40 o 57 5 - 7 H 24 Y 41 p 58 6 - 8 I 25 Z 42 q 59 7 - 9 J 26 a 43 r 60 8 - 10 K 27 b 44 s 61 9 - 11 L 28 c 45 t 62 + - 12 M 29 d 46 u 63 / - 13 N 30 e 47 v - 14 O 31 f 48 w (pad) = - 15 P 32 g 49 x - 16 Q 33 h 50 y - - Special processing is performed if fewer than 24 bits are available - at the end of the data being encoded. A full encoding quantum is - always completed at the end of a quantity. When fewer than 24 input - bits are available in an input group, zero bits are added (on the - right) to form an integral number of 6-bit groups. Padding at the - end of the data is performed using the '=' character. - - Since all base64 input is an integral number of octets, only the - ------------------------------------------------- - following cases can arise: - - (1) the final quantum of encoding input is an integral - multiple of 24 bits; here, the final unit of encoded - output will be an integral multiple of 4 characters - with no "=" padding, - (2) the final quantum of encoding input is exactly 8 bits; - here, the final unit of encoded output will be two - characters followed by two "=" padding characters, or - (3) the final quantum of encoding input is exactly 16 bits; - here, the final unit of encoded output will be three - characters followed by one "=" padding character. - */ - -int -b64_ntop(src, srclength, target, targsize) - u_char const *src; - size_t srclength; - char *target; - size_t targsize; -{ - size_t datalength = 0; - u_char input[3]; - u_char output[4]; - int i; - - while (2 < srclength) { - input[0] = *src++; - input[1] = *src++; - input[2] = *src++; - srclength -= 3; - - output[0] = input[0] >> 2; - output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); - output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); - output[3] = input[2] & 0x3f; - Assert(output[0] < 64); - Assert(output[1] < 64); - Assert(output[2] < 64); - Assert(output[3] < 64); - - if (datalength + 4 > targsize) - return (-1); - target[datalength++] = Base64[output[0]]; - target[datalength++] = Base64[output[1]]; - target[datalength++] = Base64[output[2]]; - target[datalength++] = Base64[output[3]]; - } - - /* Now we worry about padding. */ - if (0 != srclength) { - /* Get what's left. */ - input[0] = input[1] = input[2] = '\0'; - for (i = 0; i < srclength; i++) - input[i] = *src++; - - output[0] = input[0] >> 2; - output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); - output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); - Assert(output[0] < 64); - Assert(output[1] < 64); - Assert(output[2] < 64); - - if (datalength + 4 > targsize) - return (-1); - target[datalength++] = Base64[output[0]]; - target[datalength++] = Base64[output[1]]; - if (srclength == 1) - target[datalength++] = Pad64; - else - target[datalength++] = Base64[output[2]]; - target[datalength++] = Pad64; - } - if (datalength >= targsize) - return (-1); - target[datalength] = '\0'; /* Returned value doesn't count \0. */ - return (datalength); -} - -/* skips all whitespace anywhere. - converts characters, four at a time, starting at (or after) - src from base - 64 numbers into three 8 bit bytes in the target area. - it returns the number of data bytes stored at the target, or -1 on error. - */ - -int -b64_pton(src, target, targsize) - char const *src; - u_char *target; - size_t targsize; -{ - int tarindex, state, ch; - char *pos; - - state = 0; - tarindex = 0; - - while ((ch = *src++) != '\0') { - if (isspace(ch)) /* Skip whitespace anywhere. */ - continue; - - if (ch == Pad64) - break; - - pos = strchr(Base64, ch); - if (pos == 0) /* A non-base64 character. */ - return (-1); - - switch (state) { - case 0: - if (target) { - if (tarindex >= targsize) - return (-1); - target[tarindex] = (pos - Base64) << 2; - } - state = 1; - break; - case 1: - if (target) { - if (tarindex + 1 >= targsize) - return (-1); - target[tarindex] |= (pos - Base64) >> 4; - target[tarindex+1] = ((pos - Base64) & 0x0f) - << 4 ; - } - tarindex++; - state = 2; - break; - case 2: - if (target) { - if (tarindex + 1 >= targsize) - return (-1); - target[tarindex] |= (pos - Base64) >> 2; - target[tarindex+1] = ((pos - Base64) & 0x03) - << 6; - } - tarindex++; - state = 3; - break; - case 3: - if (target) { - if (tarindex >= targsize) - return (-1); - target[tarindex] |= (pos - Base64); - } - tarindex++; - state = 0; - break; - } - } - - /* - * We are done decoding Base-64 chars. Let's see if we ended - * on a byte boundary, and/or with erroneous trailing characters. - */ - - if (ch == Pad64) { /* We got a pad char. */ - ch = *src++; /* Skip it, get next. */ - switch (state) { - case 0: /* Invalid = in first position */ - case 1: /* Invalid = in second position */ - return (-1); - - case 2: /* Valid, means one byte of info */ - /* Skip any number of spaces. */ - for (; ch != '\0'; ch = *src++) - if (!isspace(ch)) - break; - /* Make sure there is another trailing = sign. */ - if (ch != Pad64) - return (-1); - ch = *src++; /* Skip the = */ - /* Fall through to "single trailing =" case. */ - /* FALLTHROUGH */ - - case 3: /* Valid, means two bytes of info */ - /* - * We know this char is an =. Is there anything but - * whitespace after it? - */ - for (; ch != '\0'; ch = *src++) - if (!isspace(ch)) - return (-1); - - /* - * Now make sure for cases 2 and 3 that the "extra" - * bits that slopped past the last full byte were - * zeros. If we don't check them, they become a - * subliminal channel. - */ - if (target && target[tarindex] != 0) - return (-1); - } - } else { - /* - * We ended by seeing the end of the string. Make sure we - * have no partial bytes lying around. - */ - if (state != 0) - return (-1); - } - - return (tarindex); -} diff --git a/src/kits/network/old/compat/libnet/compat.c b/src/kits/network/old/compat/libnet/compat.c deleted file mode 100644 index 2911f467a9..0000000000 --- a/src/kits/network/old/compat/libnet/compat.c +++ /dev/null @@ -1,185 +0,0 @@ -/* compat.c */ - -/* These routines are included in libnet simply because R5 expects them - * to be there. They should mostly be no-ops... - * Some of them are hacks! We must fix this!!! - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -static int32 h_errno_tls = -1; - -void _init(void); -void _fini(void); -void initialize_before(void); -void terminate_after(void); -int _netstat(int fd, char **output, int verbose); -void _b_pre_accept(void); -void _b_post_accept(void); - -const char * hstrerror(int error); - -int _socket_interrupt(void); - -char _socket_signals[5]; - -_EXPORT void _b_pre_accept(void) -{ -} - -_EXPORT void _b_post_accept(void) -{ -} - -_EXPORT void initialize_before(void) -{ - h_errno_tls = tls_allocate(); -} - -_EXPORT void terminate_after(void) -{ -} - - -_EXPORT int -_netstat(int fd, char **output, int verbose) -{ - return ENOSYS; -} - - -_EXPORT int closesocket(int sock) -{ - return close(sock); -} - - -_EXPORT const char * hstrerror(int error) -{ - printf("hstrerror() not yet supported."); - return "hstrerror() not supported yet"; -} - - -_EXPORT void herror(const char *error) -{ - printf("herror() not yet supported."); -} - -_EXPORT int * _h_errnop() -{ - return (int *) tls_address(h_errno_tls); -} - - -_EXPORT int _socket_interrupt(void) -{ - printf("_socket_interrupt\n"); - return 0; -} - -/* XXX: HACK HACK HACK! FIXME! */ -/* This is a terrible hack :( - * TODO: We should really get these settings values by parsing - * $HOME/config/settings/network file, which will make both R5 and BONE compatible. - */ - -_EXPORT char * find_net_setting(net_settings * ncw, const char * heading, - const char * name, char * value, unsigned nbytes) -{ -// printf("find_net_setting\n"); - - if (strcmp(heading, "GLOBAL") != 0) - return NULL; - - if (strcmp(name, "HOSTNAME") == 0) - strncpy(value, "hostname", nbytes); - else if (strcmp(name, "USERNAME") == 0) - strncpy(value, "baron\0", nbytes); - else if (strcmp(name, "PASSWORD") == 0) - strncpy(value, "password", nbytes); - else if (strcmp(name, "FTP_ENABLED") == 0) - strncpy(value, "1", nbytes); - else if (strcmp(name, "TELNETD_ENABLED") == 0) - strncpy(value, "1", nbytes); - else - return NULL; - - return value; -} - - -_EXPORT status_t set_net_setting(net_settings * ncw, const char * heading, - const char * name, const char * value) -{ - printf("set_net_setting\n"); - return B_UNSUPPORTED; -} - - -_EXPORT int gethostname(char * name, size_t length) -{ -// printf("gethostname\n"); - if (find_net_setting(NULL, "GLOBAL", "HOSTNAME", name, length) == NULL) - return B_ERROR; - - return strlen(name); -} - - -_EXPORT int getusername(char * name, size_t length) -{ -// printf("getusername\n"); - if (find_net_setting(NULL, "GLOBAL", "USERNAME", name, length) == NULL) - return B_ERROR; - - return strlen(name); -} - - -_EXPORT int getpassword(char * pwd, size_t length) -{ -// printf("getpassword\n"); - if (find_net_setting(NULL, "GLOBAL", "PASSWORD", pwd, length) == NULL) - return B_ERROR; - - return strlen(pwd); -} - -// TODO: This is not a good solution. The complete compat.c should not be -// included in a libnet.so for Haiku, but if left out, _h_errnop is missing -// when linking. -#ifndef __HAIKU__ - -struct utsname { - char sysname[32]; - char nodename[32]; - char release[32]; - char version[32]; - char machine[32]; -}; -int uname(struct utsname *name); -_EXPORT int uname(struct utsname *name) -{ - if (!name) - return B_ERROR; - - strcpy(name->sysname, "BeOS"); - strcpy(name->nodename, "trantor"); - strcpy(name->release, "5.0"); - strcpy(name->version, "1000009"); - strcpy(name->machine, "BePC"); - return B_OK; -} - -#endif // !defined(__HAIKU__) diff --git a/src/kits/network/old/compat/libnet/ethers.c b/src/kits/network/old/compat/libnet/ethers.c deleted file mode 100644 index 23c340c1cc..0000000000 --- a/src/kits/network/old/compat/libnet/ethers.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (c) 1998 Todd C. Miller - * 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE AUTHOR 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. - */ - -/* - * ethers(3) a la Sun. - * Originally Written by Roland McGrath 10/14/93. - * Substantially modified by Todd C. Miller - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef YP -#include -#endif - -#include "netdb.h" /* for MAXHOSTNAMELEN */ -#ifndef _PATH_ETHERS -#define _PATH_ETHERS "/etc/ethers" -#endif - -static char * _ether_aton (char *, struct ether_addr *); - -char *ether_ntoa(struct ether_addr *e) -{ - static char a[] = "xx:xx:xx:xx:xx:xx"; - - if (e->ether_addr_octet[0] > 0xFF || e->ether_addr_octet[1] > 0xFF || - e->ether_addr_octet[2] > 0xFF || e->ether_addr_octet[3] > 0xFF || - e->ether_addr_octet[4] > 0xFF || e->ether_addr_octet[5] > 0xFF) { - errno = EINVAL; - return (NULL); - } - - (void)sprintf(a, "%02x:%02x:%02x:%02x:%02x:%02x", - e->ether_addr_octet[0], e->ether_addr_octet[1], - e->ether_addr_octet[2], e->ether_addr_octet[3], - e->ether_addr_octet[4], e->ether_addr_octet[5]); - - return (a); -} - - -static char *_ether_aton(char *s, struct ether_addr *e) -{ - int i; - long l; - char *pp; - - while (isspace(*s)) - s++; - - /* expect 6 hex octets separated by ':' or space/NUL if last octet */ - for (i = 0; i < 6; i++) { - l = strtol(s, &pp, 16); - if (pp == s || l > 0xFF || l < 0) - return (NULL); - if (!(*pp == ':' || (i == 5 && (isspace(*pp) || *pp == '\0')))) - return (NULL); - e->ether_addr_octet[i] = (u_char)l; - s = pp + 1; - } - - /* return character after the octets ala strtol(3) */ - return (pp); -} - - -struct ether_addr *ether_aton(char *s) -{ - static struct ether_addr n; - - return (_ether_aton(s, &n) ? &n : NULL); -} - - -int ether_ntohost(char *hostname, struct ether_addr *e) -{ - FILE *f; - char buf[BUFSIZ+1], *p; - size_t len; - struct ether_addr try; - char lbuf[80]; -#ifdef YP - char trybuf[sizeof("xx:xx:xx:xx:xx:xx")]; - int trylen; -#endif - - if (e->ether_addr_octet[0] > 0xFF || e->ether_addr_octet[1] > 0xFF || - e->ether_addr_octet[2] > 0xFF || e->ether_addr_octet[3] > 0xFF || - e->ether_addr_octet[4] > 0xFF || e->ether_addr_octet[5] > 0xFF) { - errno = EINVAL; - return (-1); - } - -#ifdef YP - sprintf(trybuf, "%x:%x:%x:%x:%x:%x", - e->ether_addr_octet[0], e->ether_addr_octet[1], - e->ether_addr_octet[2], e->ether_addr_octet[3], - e->ether_addr_octet[4], e->ether_addr_octet[5]); - trylen = strlen(trybuf); -#endif - - f = fopen(_PATH_ETHERS, "r"); - if (f == NULL) - return (-1); - while (fgets(lbuf, 80, f) != NULL) { - len = strlen(lbuf); - p = lbuf; - if (p[len-1] == '\n') - len--; - if (len > sizeof(buf) - 2) - continue; - (void)memcpy(buf, p, len); - buf[len] = '\n'; /* code assumes newlines later on */ - buf[len+1] = '\0'; -#ifdef YP - /* A + in the file means try YP now. */ - if (!strncmp(buf, "+\n", sizeof(buf))) { - char *ypbuf, *ypdom; - int ypbuflen; - - if (yp_get_default_domain(&ypdom)) - continue; - if (yp_match(ypdom, "ethers.byaddr", trybuf, - trylen, &ypbuf, &ypbuflen)) - continue; - if (ether_line(ypbuf, &try, hostname) == 0) { - free(ypbuf); - (void)fclose(f); - return (0); - } - free(ypbuf); - continue; - } -#endif - if (ether_line(buf, &try, hostname) == 0 && - memcmp((void *)&try, (void *)e, sizeof(try)) == 0) { - (void)fclose(f); - return (0); - } - } - (void)fclose(f); - errno = ENOENT; - return (-1); -} - -int -ether_hostton(hostname, e) - char *hostname; - struct ether_addr *e; -{ - FILE *f; - char buf[BUFSIZ+1], *p; - char try[MAXHOSTNAMELEN]; - size_t len; - char lbuf[80]; -#ifdef YP - int hostlen = strlen(hostname); -#endif - - f = fopen(_PATH_ETHERS, "r"); - if (f==NULL) - return (-1); - - while (fgets(lbuf, 80, f) != NULL) { - len = strlen(lbuf); - p = lbuf; - if (p[len-1] == '\n') - len--; - if (len > sizeof(buf) - 2) - continue; - memcpy(buf, p, len); - buf[len] = '\n'; /* code assumes newlines later on */ - buf[len+1] = '\0'; -#ifdef YP - /* A + in the file means try YP now. */ - if (!strncmp(buf, "+\n", sizeof(buf))) { - char *ypbuf, *ypdom; - int ypbuflen; - - if (yp_get_default_domain(&ypdom)) - continue; - if (yp_match(ypdom, "ethers.byname", hostname, hostlen, - &ypbuf, &ypbuflen)) - continue; - if (ether_line(ypbuf, e, try) == 0) { - free(ypbuf); - (void)fclose(f); - return (0); - } - free(ypbuf); - continue; - } -#endif - if (ether_line(buf, e, try) == 0 && strcmp(hostname, try) == 0) { - (void)fclose(f); - return (0); - } - } - (void)fclose(f); - errno = ENOENT; - return (-1); -} - -int ether_line(char *line, struct ether_addr *e, char *hostname) -{ - char *p; - size_t n; - - /* Parse "xx:xx:xx:xx:xx:xx" */ - if ((p = _ether_aton(line, e)) == NULL || (*p != ' ' && *p != '\t')) - goto bad; - - /* Now get the hostname */ - while (isspace(*p)) - p++; - if (*p == '\0') - goto bad; - n = strcspn(p, " \t\n"); - if (n >= MAXHOSTNAMELEN) - goto bad; - strncpy(hostname, p, n + 1); - return (0); - -bad: - errno = EINVAL; - return (-1); -} diff --git a/src/kits/network/old/compat/libnet/freeaddrinfo.c b/src/kits/network/old/compat/libnet/freeaddrinfo.c deleted file mode 100644 index 7ca9198797..0000000000 --- a/src/kits/network/old/compat/libnet/freeaddrinfo.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1996, 1997, 1998, 1999, Craig Metz, All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Craig Metz and - * by other contributors. - * 4. Neither the name of the author nor the names of contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -void -freeaddrinfo(ai) - struct addrinfo *ai; -{ - struct addrinfo *p; - - do { - p = ai; - ai = ai->ai_next; - if (p->ai_canonname) - free(p->ai_canonname); - free((void *)p); - } while (ai); -} diff --git a/src/kits/network/old/compat/libnet/getaddrinfo.c b/src/kits/network/old/compat/libnet/getaddrinfo.c deleted file mode 100644 index 047e29ad75..0000000000 --- a/src/kits/network/old/compat/libnet/getaddrinfo.c +++ /dev/null @@ -1,1821 +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 are nonstandard return values defined and used - * in the source code. This is because RFC2553 is silent about which error - * code must be returned for which situation. - * - IPv4 classful (shortened) form. RFC2553 is silent about it. XNET 5.2 - * says to use inet_aton() to convert IPv4 numeric to binary (alows - * classful form as a result). - * current code - disallow classful form for IPv4 (due to use of inet_pton). - * - freeaddrinfo(NULL). RFC2553 is silent about it. XNET 5.2 says it is - * invalid. - * current code - SEGV on freeaddrinfo(NULL) - * Note: - * - We use getipnodebyname() just for thread-safeness. There's no intent - * to let it do PF_UNSPEC (actually we never pass PF_UNSPEC to - * getipnodebyname(). - * - The code filters out AFs that are not supported by the kernel, - * when globbing NULL hostname (to loopback, or wildcard). Is it the right - * thing to do? What is the relationship with post-RFC2553 AI_ADDRCONFIG - * in ai_flags? - * - (post-2553) semantics of AI_ADDRCONFIG itself is too vague. - * (1) what should we do against numeric hostname (2) what should we do - * against NULL hostname (3) what is AI_ADDRCONFIG itself. AF not ready? - * non-loopback address configured? global address configured? - * - To avoid search order issue, we have a big amount of code duplicate - * from gethnamaddr.c and some other places. The issues that there's no - * lower layer function to lookup "IPv4 or IPv6" record. Calling - * gethostbyname2 from getaddrinfo will end up in wrong search order, as - * follows: - * - The code makes use of following calls when asked to resolver with - * ai_family = PF_UNSPEC: - * getipnodebyname(host, AF_INET6); - * getipnodebyname(host, AF_INET); - * This will result in the following queries if the node is configure to - * prefer /etc/hosts than DNS: - * lookup /etc/hosts for IPv6 address - * lookup DNS for IPv6 address - * lookup /etc/hosts for IPv4 address - * lookup DNS for IPv4 address - * which may not meet people's requirement. - * The right thing to happen is to have underlying layer which does - * PF_UNSPEC lookup (lookup both) and return chain of addrinfos. - * This would result in a bit of code duplicate with _dns_ghbyname() and - * friends. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* XXX - hmm, we need to look at adding syslog support -#include - */ -#include - -#ifdef YP -#include -#include -#include -#include "ypinternal.h" -#endif - -#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 -}; - -static const struct afd { - int a_af; - int a_addrlen; - int a_socklen; - int a_off; - const char *a_addrany; - const char *a_loopback; - int a_scoped; -} afdl [] = { -#ifdef INET6 - {PF_INET6, sizeof(struct in6_addr), - sizeof(struct sockaddr_in6), - offsetof(struct sockaddr_in6, sin6_addr), - in6_addrany, in6_loopback, 1}, -#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, 0, NULL, NULL, 0}, -}; - -struct explore { - int e_af; - int e_socktype; - int e_protocol; - const char *e_protostr; - int e_wild; -#define WILD_AF(ex) ((ex)->e_wild & 0x01) -#define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02) -#define WILD_PROTOCOL(ex) ((ex)->e_wild & 0x04) -}; - -static const struct explore explore[] = { -#if 0 - { PF_LOCAL, 0, ANY, ANY, NULL, 0x01 }, -#endif -#ifdef INET6 - { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, - { PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, - { PF_INET6, SOCK_RAW, ANY, NULL, 0x05 }, -#endif - { PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, - { PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, - { PF_INET, SOCK_RAW, ANY, NULL, 0x05 }, - { PF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, - { PF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, - { PF_UNSPEC, SOCK_RAW, ANY, NULL, 0x05 }, - { -1, 0, 0, NULL, 0 }, -}; - -#ifdef INET6 -#define PTON_MAX 16 -#else -#define PTON_MAX 4 -#endif - -#if PACKETSZ > 1024 -#define MAXPACKET PACKETSZ -#else -#define MAXPACKET 1024 -#endif - -typedef union { - HEADER hdr; - u_char buf[MAXPACKET]; -} querybuf; - -struct res_target { - struct res_target *next; - const char *name; /* domain name */ - int qclass, qtype; /* class and type of query */ - u_char *answer; /* buffer to put answer */ - int anslen; /* size of answer buffer */ - int n; /* result length */ -}; - -static int str_isnumber (const char *); -static int explore_fqdn (const struct addrinfo *, const char *, - const char *, struct addrinfo **); -static int explore_null (const struct addrinfo *, - const char *, struct addrinfo **); -static int explore_numeric (const struct addrinfo *, const char *, - const char *, struct addrinfo **); -static int explore_numeric_scope (const struct addrinfo *, const char *, - const char *, struct addrinfo **); -static int get_canonname (const struct addrinfo *, - struct addrinfo *, const char *); -static struct addrinfo *get_ai (const struct addrinfo *, - const struct afd *, const char *); -static int get_portmatch (const struct addrinfo *, const char *); -static int get_port (struct addrinfo *, const char *, int); -static const struct afd *find_afd (int); -#if 0 -static int addrconfig (const struct addrinfo *); -#endif -#ifdef INET6 -static int ip6_str2scopeid (char *, struct sockaddr_in6 *); -#endif - -static void _sethtent (void); -static void _endhtent (void); -static struct addrinfo * _gethtent (const char *, const struct addrinfo *); -static struct addrinfo *_files_getaddrinfo (const char *, - const struct addrinfo *); - -#ifdef YP -static struct addrinfo *_yphostent (char *, const struct addrinfo *); -static struct addrinfo *_yp_getaddrinfo ((const char *, - const struct addrinfo *); -#endif - -static struct addrinfo *getanswer (const querybuf *, int, const char *, int, - const struct addrinfo *); -static int res_queryN (const char *, struct res_target *); -static int res_searchN (const char *, struct res_target *); -static int res_querydomainN (const char *, const char *, - struct res_target *); -static struct addrinfo *_dns_getaddrinfo (const char *, - const struct addrinfo *); - - -/* XXX macros that make external reference is BAD. */ - -#define GET_AI(ai, afd, addr) \ -do { \ - /* external reference: pai, error, and label free */ \ - (ai) = get_ai(pai, (afd), (addr)); \ - if ((ai) == NULL) { \ - error = EAI_MEMORY; \ - goto free; \ - } \ -} while (/*CONSTCOND*/0) - -#define GET_PORT(ai, serv) \ -do { \ - /* external reference: error and label free */ \ - error = get_port((ai), (serv), 0); \ - if (error != 0) \ - goto free; \ -} while (/*CONSTCOND*/0) - -#define GET_CANONNAME(ai, str) \ -do { \ - /* external reference: pai, error and label free */ \ - error = get_canonname(pai, (ai), (str)); \ - if (error != 0) \ - goto free; \ -} while (/*CONSTCOND*/0) - -#define ERR(err) \ -do { \ - /* external reference: error, and label bad */ \ - error = (err); \ - goto bad; \ - /*NOTREACHED*/ \ -} while (/*CONSTCOND*/0) - -#define MATCH_FAMILY(x, y, w) \ - ((x) == (y) || (/*CONSTCOND*/(w) && ((x) == PF_UNSPEC || (y) == PF_UNSPEC))) -#define MATCH(x, y, w) \ - ((x) == (y) || (/*CONSTCOND*/(w) && ((x) == ANY || (y) == ANY))) - -static int -str_isnumber(p) - const char *p; -{ - char *ep; - - if (*p == '\0') - return NO; - ep = NULL; - (void)strtoul(p, &ep, 10); - if (ep && *ep == '\0') - return YES; - else - return NO; -} - -int -getaddrinfo(hostname, servname, hints, res) - const char *hostname, *servname; - const struct addrinfo *hints; - struct addrinfo **res; -{ - struct addrinfo sentinel; - struct addrinfo *cur; - int error = 0; - struct addrinfo ai; - struct addrinfo ai0; - struct addrinfo *pai; - const struct explore *ex; - - memset(&sentinel, 0, sizeof(sentinel)); - 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; - - 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)); - - /* - * if both socktype/protocol are specified, check if they - * are meaningful combination. - */ - if (pai->ai_socktype != ANY && pai->ai_protocol != ANY) { - for (ex = explore; ex->e_af >= 0; ex++) { - if (pai->ai_family != ex->e_af) - continue; - if (ex->e_socktype == ANY) - continue; - if (ex->e_protocol == ANY) - continue; - if (pai->ai_socktype == ex->e_socktype - && pai->ai_protocol != ex->e_protocol) { - ERR(EAI_BADHINTS); - } - } - } - } - - /* - * check for special cases. (1) numeric servname is disallowed if - * socktype/protocol are left unspecified. (2) servname is disallowed - * for raw and other inet{,6} sockets. - */ - if (MATCH_FAMILY(pai->ai_family, PF_INET, 1) -#ifdef PF_INET6 - || MATCH_FAMILY(pai->ai_family, PF_INET6, 1) -#endif - ) { - ai0 = *pai; /* backup *pai */ - - if (pai->ai_family == PF_UNSPEC) { -#ifdef PF_INET6 - pai->ai_family = PF_INET6; -#else - pai->ai_family = PF_INET; -#endif - } - error = get_portmatch(pai, servname); - if (error) - ERR(error); - - *pai = ai0; - } - - ai0 = *pai; - - /* NULL hostname, or numeric hostname */ - for (ex = explore; ex->e_af >= 0; ex++) { - *pai = ai0; - - /* PF_UNSPEC entries are prepared for DNS queries only */ - if (ex->e_af == PF_UNSPEC) - continue; - - if (!MATCH_FAMILY(pai->ai_family, ex->e_af, WILD_AF(ex))) - continue; - if (!MATCH(pai->ai_socktype, ex->e_socktype, WILD_SOCKTYPE(ex))) - continue; - if (!MATCH(pai->ai_protocol, ex->e_protocol, WILD_PROTOCOL(ex))) - continue; - - if (pai->ai_family == PF_UNSPEC) - pai->ai_family = ex->e_af; - if (pai->ai_socktype == ANY && ex->e_socktype != ANY) - pai->ai_socktype = ex->e_socktype; - if (pai->ai_protocol == ANY && ex->e_protocol != ANY) - pai->ai_protocol = ex->e_protocol; - - if (hostname == NULL) - error = explore_null(pai, servname, &cur->ai_next); - else - error = explore_numeric_scope(pai, hostname, servname, &cur->ai_next); - - if (error) - goto free; - - while (cur && cur->ai_next) - cur = cur->ai_next; - } - - /* - * XXX - * If numreic representation of AF1 can be interpreted as FQDN - * representation of AF2, we need to think again about the code below. - */ - if (sentinel.ai_next) - goto good; - - if (pai->ai_flags & AI_NUMERICHOST) - ERR(EAI_NODATA); - if (hostname == NULL) - ERR(EAI_NODATA); - - /* - * hostname as alphabetical name. - * we would like to prefer AF_INET6 than AF_INET, so we'll make a - * outer loop by AFs. - */ - for (ex = explore; ex->e_af >= 0; ex++) { - *pai = ai0; - - /* require exact match for family field */ - if (pai->ai_family != ex->e_af) - continue; - - if (!MATCH(pai->ai_socktype, ex->e_socktype, - WILD_SOCKTYPE(ex))) { - continue; - } - if (!MATCH(pai->ai_protocol, ex->e_protocol, - WILD_PROTOCOL(ex))) { - continue; - } - - if (pai->ai_socktype == ANY && ex->e_socktype != ANY) - pai->ai_socktype = ex->e_socktype; - if (pai->ai_protocol == ANY && ex->e_protocol != ANY) - pai->ai_protocol = ex->e_protocol; - - error = explore_fqdn(pai, hostname, servname, - &cur->ai_next); - - while (cur && cur->ai_next) - cur = cur->ai_next; - } - - /* XXX */ - if (sentinel.ai_next) - error = 0; - - if (error) - goto free; - if (error == 0) { - if (sentinel.ai_next) { - good: - *res = sentinel.ai_next; - return SUCCESS; - } else - error = EAI_FAIL; - } - free: - bad: - if (sentinel.ai_next) - freeaddrinfo(sentinel.ai_next); - *res = NULL; - return error; -} - -/* - * FQDN hostname, DNS lookup - */ -static int -explore_fqdn(pai, hostname, servname, res) - const struct addrinfo *pai; - const char *hostname; - const char *servname; - struct addrinfo **res; -{ - struct addrinfo *result; - struct addrinfo *cur; - int error = 0; - char lookups[MAXDNSLUS]; - int i; - - result = NULL; - -#if 0 - /* - * If AI_ADDRCONFIG is specified, check if we are expected to - * return the address family or not. - * XXX does not handle PF_UNSPEC case, should filter final result - */ - if ((pai->ai_flags & AI_ADDRCONFIG) != 0 && !addrconfig(pai)) - return 0; -#endif - - /* - * if the servname does not match socktype/protocol, ignore it. - */ - if (get_portmatch(pai, servname) != 0) - return 0; - - if ((_res.options & RES_INIT) == 0 && res_init() == -1) - strncpy(lookups, "f", sizeof lookups); - else { - memcpy(lookups, _res.lookups, sizeof lookups); - if (lookups[0] == '\0') - strncpy(lookups, "bf", sizeof lookups); - } - - for (i = 0; i < MAXDNSLUS && result == NULL && lookups[i]; i++) { - switch (lookups[i]) { -#ifdef YP - case 'y': - result = _yp_getaddrinfo(hostname, pai); - break; -#endif - case 'b': - result = _dns_getaddrinfo(hostname, pai); - break; - case 'f': - result = _files_getaddrinfo(hostname, pai); - break; - } - } - if (result) { - for (cur = result; cur; cur = cur->ai_next) { - GET_PORT(cur, servname); - /* canonname should be filled already */ - } - *res = result; - return 0; - } else { - /* translate error code */ - switch (h_errno) { - case NETDB_SUCCESS: - error = EAI_FAIL; /*XXX strange */ - break; - case HOST_NOT_FOUND: - error = EAI_NODATA; - break; - case TRY_AGAIN: - error = EAI_AGAIN; - break; - case NO_RECOVERY: - error = EAI_FAIL; - break; - case NO_DATA: -#if NO_ADDRESS != NO_DATA - case NO_ADDRESS: -#endif - error = EAI_NODATA; - break; - default: /* unknown ones */ - error = EAI_FAIL; - break; - } - } - -free: - if (result) - freeaddrinfo(result); - return error; -} - -/* - * hostname == NULL. - * passive socket -> anyaddr (0.0.0.0 or ::) - * non-passive socket -> localhost (127.0.0.1 or ::1) - */ -static int -explore_null(pai, servname, res) - const struct addrinfo *pai; - const char *servname; - struct addrinfo **res; -{ - int s; - const struct afd *afd; - struct addrinfo *cur; - struct addrinfo sentinel; - int error; - - *res = NULL; - sentinel.ai_next = NULL; - cur = &sentinel; - - /* - * filter out AFs that are not supported by the kernel - * XXX errno? - */ - s = socket(pai->ai_family, SOCK_DGRAM, 0); - if (s < 0) { - if (errno != EMFILE) - return 0; - } else - close(s); - - /* - * if the servname does not match socktype/protocol, ignore it. - */ - if (get_portmatch(pai, servname) != 0) - return 0; - - afd = find_afd(pai->ai_family); - if (afd == NULL) - return 0; - - if (pai->ai_flags & AI_PASSIVE) { - GET_AI(cur->ai_next, afd, afd->a_addrany); - /* xxx meaningless? - * GET_CANONNAME(cur->ai_next, "anyaddr"); - */ - GET_PORT(cur->ai_next, servname); - } else { - GET_AI(cur->ai_next, afd, afd->a_loopback); - /* xxx meaningless? - * GET_CANONNAME(cur->ai_next, "localhost"); - */ - GET_PORT(cur->ai_next, servname); - } - cur = cur->ai_next; - - *res = sentinel.ai_next; - return 0; - -free: - if (sentinel.ai_next) - freeaddrinfo(sentinel.ai_next); - return error; -} - -/* - * numeric hostname - */ -static int -explore_numeric(pai, hostname, servname, res) - const struct addrinfo *pai; - const char *hostname; - const char *servname; - struct addrinfo **res; -{ - const struct afd *afd; - struct addrinfo *cur; - struct addrinfo sentinel; - int error; - char pton[PTON_MAX]; - - *res = NULL; - sentinel.ai_next = NULL; - cur = &sentinel; - - /* - * if the servname does not match socktype/protocol, ignore it. - */ - if (get_portmatch(pai, servname) != 0) - return 0; - - afd = find_afd(pai->ai_family); - if (afd == NULL) - return 0; - - switch (afd->a_af) { -#if 0 /*X/Open spec*/ - case AF_INET: - if (inet_aton(hostname, (struct in_addr *)pton) == 1) { - if (pai->ai_family == afd->a_af || - pai->ai_family == PF_UNSPEC /*?*/) { - GET_AI(cur->ai_next, afd, pton); - GET_PORT(cur->ai_next, servname); - while (cur && cur->ai_next) - cur = cur->ai_next; - } else - ERR(EAI_FAMILY); /*xxx*/ - } - break; -#endif - default: - if (inet_pton(afd->a_af, hostname, pton) == 1) { - if (pai->ai_family == afd->a_af || - pai->ai_family == PF_UNSPEC /*?*/) { - GET_AI(cur->ai_next, afd, pton); - GET_PORT(cur->ai_next, servname); - while (cur && cur->ai_next) - cur = cur->ai_next; - } else - ERR(EAI_FAMILY); /*xxx*/ - } - break; - } - - *res = sentinel.ai_next; - return 0; - -free: -bad: - if (sentinel.ai_next) - freeaddrinfo(sentinel.ai_next); - return error; -} - -/* - * numeric hostname with scope - */ -static int -explore_numeric_scope(pai, hostname, servname, res) - const struct addrinfo *pai; - const char *hostname; - const char *servname; - struct addrinfo **res; -{ -#if !defined(SCOPE_DELIMITER) || !defined(INET6) - return explore_numeric(pai, hostname, servname, res); -#else - const struct afd *afd; - struct addrinfo *cur; - int error; - char *cp, *hostname2 = NULL, *scope, *addr; - struct sockaddr_in6 *sin6; - - /* - * if the servname does not match socktype/protocol, ignore it. - */ - if (get_portmatch(pai, servname) != 0) - return 0; - - afd = find_afd(pai->ai_family); - if (afd == NULL) - return 0; - - if (!afd->a_scoped) - return explore_numeric(pai, hostname, servname, res); - - cp = strchr(hostname, SCOPE_DELIMITER); - if (cp == NULL) - return explore_numeric(pai, hostname, servname, res); - - /* - * Handle special case of - */ - hostname2 = strdup(hostname); - if (hostname2 == NULL) - return EAI_MEMORY; - /* terminate at the delimiter */ - hostname2[cp - hostname] = '\0'; - addr = hostname2; - scope = cp + 1; - - error = explore_numeric(pai, addr, servname, res); - if (error == 0) { - int scopeid; - - for (cur = *res; cur; cur = cur->ai_next) { - if (cur->ai_family != AF_INET6) - continue; - sin6 = (struct sockaddr_in6 *)(void *)cur->ai_addr; - if ((scopeid = ip6_str2scopeid(scope, sin6)) == -1) { - free(hostname2); - return(EAI_NODATA); /* XXX: is return OK? */ - } - sin6->sin6_scope_id = scopeid; - } - } - - free(hostname2); - - return error; -#endif -} - -static int -get_canonname(pai, ai, str) - const struct addrinfo *pai; - struct addrinfo *ai; - const char *str; -{ -printf("get_canonname\n"); - if ((pai->ai_flags & AI_CANONNAME) != 0) { - ai->ai_canonname = (char *)malloc(strlen(str) + 1); - if (ai->ai_canonname == NULL) - return EAI_MEMORY; - strncpy(ai->ai_canonname, str, strlen(str)); - } - return 0; -} - -static struct addrinfo * -get_ai(pai, afd, addr) - const struct addrinfo *pai; - const struct afd *afd; - const char *addr; -{ - char *p; - struct addrinfo *ai; -printf("get_ai\n"); - - ai = (struct addrinfo *)malloc(sizeof(struct addrinfo) + (afd->a_socklen)); - if (ai == NULL) - return NULL; - - memcpy(ai, pai, sizeof(struct addrinfo)); - ai->ai_addr = (struct sockaddr *)(void *)(ai + 1); - - memset(ai->ai_addr, 0, (size_t)afd->a_socklen); - ai->ai_addr->sa_len = afd->a_socklen; - ai->ai_addrlen = afd->a_socklen; - ai->ai_addr->sa_family = ai->ai_family = afd->a_af; - p = (char *)(void *)(ai->ai_addr); - memcpy(p + afd->a_off, addr, (size_t)afd->a_addrlen); - return ai; -} - -static int -get_portmatch(ai, servname) - const struct addrinfo *ai; - const char *servname; -{ - - /* get_port does not touch first argument. when matchonly == 1. */ - /* LINTED const cast */ - return get_port((struct addrinfo *)ai, servname, 1); -} - -static int -get_port(ai, servname, matchonly) - struct addrinfo *ai; - const char *servname; - int matchonly; -{ - const char *proto; - struct servent *sp; - int port; - int allownumeric; - - if (servname == NULL) - return 0; - switch (ai->ai_family) { - case AF_INET: -#ifdef AF_INET6 - case AF_INET6: -#endif - break; - default: - return 0; - } - - switch (ai->ai_socktype) { - case SOCK_RAW: - return EAI_SERVICE; - case SOCK_DGRAM: - case SOCK_STREAM: - allownumeric = 1; - break; - case ANY: - allownumeric = 0; - break; - default: - return EAI_SOCKTYPE; - } - - if (str_isnumber(servname)) { - if (!allownumeric) - return EAI_SERVICE; - port = htons(atoi(servname)); - if (port < 0 || port > 65535) - return EAI_SERVICE; - } else { - switch (ai->ai_socktype) { - case SOCK_DGRAM: - proto = "udp"; - break; - case SOCK_STREAM: - proto = "tcp"; - break; - default: - proto = NULL; - break; - } - - if ((sp = getservbyname(servname, proto)) == NULL) - return EAI_SERVICE; - port = sp->s_port; - } - - if (!matchonly) { - switch (ai->ai_family) { - case AF_INET: - ((struct sockaddr_in *)(void *) - ai->ai_addr)->sin_port = port; - break; -#ifdef INET6 - case AF_INET6: - ((struct sockaddr_in6 *)(void *) - ai->ai_addr)->sin6_port = port; - break; -#endif - } - } - - return 0; -} - -static const struct afd * -find_afd(af) - int af; -{ - const struct afd *afd; - - if (af == PF_UNSPEC) - return NULL; - for (afd = afdl; afd->a_af; afd++) { - if (afd->a_af == af) - return afd; - } - return NULL; -} - -#if 0 -/* - * post-2553: AI_ADDRCONFIG check. if we use getipnodeby* as backend, backend - * will take care of it. - * the semantics of AI_ADDRCONFIG is not defined well. we are not sure - * if the code is right or not. - */ -static int -addrconfig(pai) - const struct addrinfo *pai; -{ - int s; - - /* XXX errno */ - s = socket(pai->ai_family, SOCK_DGRAM, 0); - if (s < 0) - return 0; - close(s); - return 1; -} -#endif - -#ifdef INET6 -/* convert a string to a scope identifier. XXX: IPv6 specific */ -static int -ip6_str2scopeid(scope, sin6) - char *scope; - struct sockaddr_in6 *sin6; -{ - int scopeid; - struct in6_addr *a6 = &sin6->sin6_addr; - char *ep; - - /* empty scopeid portion is invalid */ - if (*scope == '\0') - return -1; - - if (IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) { - /* - * We currently assume a one-to-one mapping between links - * and interfaces, so we simply use interface indices for - * like-local scopes. - */ - scopeid = if_nametoindex(scope); - if (scopeid == 0) - goto trynumeric; - return(scopeid); - } - - /* still unclear about literal, allow numeric only - placeholder */ - if (IN6_IS_ADDR_SITELOCAL(a6) || IN6_IS_ADDR_MC_SITELOCAL(a6)) - goto trynumeric; - if (IN6_IS_ADDR_MC_ORGLOCAL(a6)) - goto trynumeric; - else - goto trynumeric; /* global */ - - /* try to convert to a numeric id as a last resort */ - trynumeric: - scopeid = (int)strtoul(scope, &ep, 10); - if (*ep == '\0') - return scopeid; - else - return -1; -} -#endif - -/* code duplicate with gethnamaddr.c */ - -static const char AskedForGot[] = - "gethostby*.getanswer: asked for \"%s\", got \"%s\""; -static FILE *hostf = NULL; - -static struct addrinfo * -getanswer(answer, anslen, qname, qtype, pai) - const querybuf *answer; - int anslen; - const char *qname; - int qtype; - const struct addrinfo *pai; -{ - struct addrinfo sentinel, *cur; - struct addrinfo ai; - const struct afd *afd; - char *canonname; - const HEADER *hp; - const u_char *cp; - int n; - const u_char *eom; - char *bp; - int type, class, buflen, ancount, qdcount; - int haveanswer, had_error; - char tbuf[MAXDNAME]; - int (*name_ok) (const char *); - char hostbuf[8*1024]; - - memset(&sentinel, 0, sizeof(sentinel)); - cur = &sentinel; - - canonname = NULL; - eom = answer->buf + anslen; - switch (qtype) { - case T_A: - case T_AAAA: - case T_ANY: /*use T_ANY only for T_A/T_AAAA lookup*/ - name_ok = res_hnok; - break; - default: - return (NULL); /* XXX should be abort(); */ - } - /* - * find first satisfactory answer - */ - hp = &answer->hdr; - ancount = ntohs(hp->ancount); - qdcount = ntohs(hp->qdcount); - bp = hostbuf; - buflen = sizeof hostbuf; - cp = answer->buf + HFIXEDSZ; - if (qdcount != 1) { - h_errno = NO_RECOVERY; - return (NULL); - } - n = dn_expand(answer->buf, eom, cp, bp, buflen); - if ((n < 0) || !(*name_ok)(bp)) { - h_errno = NO_RECOVERY; - return (NULL); - } - cp += n + QFIXEDSZ; - if (qtype == T_A || qtype == T_AAAA || qtype == T_ANY) { - /* res_send() has already verified that the query name is the - * same as the one we sent; this just gets the expanded name - * (i.e., with the succeeding search-domain tacked on). - */ - n = strlen(bp) + 1; /* for the \0 */ - if (n >= MAXHOSTNAMELEN) { - h_errno = NO_RECOVERY; - return (NULL); - } - canonname = bp; - bp += n; - buflen -= n; - /* The qname can be abbreviated, but h_name is now absolute. */ - qname = canonname; - } - haveanswer = 0; - had_error = 0; - while (ancount-- > 0 && cp < eom && !had_error) { - n = dn_expand(answer->buf, eom, cp, bp, buflen); - if ((n < 0) || !(*name_ok)(bp)) { - had_error++; - continue; - } - cp += n; /* name */ - type = _getshort(cp); - cp += INT16SZ; /* type */ - class = _getshort(cp); - cp += INT16SZ + INT32SZ; /* class, TTL */ - n = _getshort(cp); - cp += INT16SZ; /* len */ - if (class != C_IN) { - /* XXX - debug? syslog? */ - cp += n; - continue; /* XXX - had_error++ ? */ - } - if ((qtype == T_A || qtype == T_AAAA || qtype == T_ANY) && - type == T_CNAME) { - n = dn_expand(answer->buf, eom, cp, tbuf, sizeof tbuf); - if ((n < 0) || !(*name_ok)(tbuf)) { - had_error++; - continue; - } - cp += n; - /* Get canonical name. */ - n = strlen(tbuf) + 1; /* for the \0 */ - if (n > buflen || n >= MAXHOSTNAMELEN) { - had_error++; - continue; - } - strcpy(bp, tbuf); - canonname = bp; - bp += n; - buflen -= n; - continue; - } - if (qtype == T_ANY) { - if (!(type == T_A || type == T_AAAA)) { - cp += n; - continue; - } - } else if (type != qtype) { - if (type != T_KEY && type != T_SIG) -/* XXX - use printf for the moment... - syslog(LOG_NOTICE|LOG_AUTH, - "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"", - qname, p_class(C_IN), p_type(qtype), - p_type(type)); - */ - printf("gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"", - qname, p_class(C_IN), p_type(qtype), - p_type(type)); - - cp += n; - continue; /* XXX - had_error++ ? */ - } - switch (type) { - case T_A: - case T_AAAA: - if (strcasecmp(canonname, bp) != 0) { -/* XXX - use printf for the moment... - syslog(LOG_NOTICE|LOG_AUTH, - AskedForGot, canonname, bp); - */ - printf(AskedForGot, canonname, bp); - - cp += n; - continue; /* XXX - had_error++ ? */ - } - if (type == T_A && n != INADDRSZ) { - cp += n; - continue; - } - if (type == T_AAAA && n != IN6ADDRSZ) { - cp += n; - continue; - } - if (!haveanswer) { - int nn; - - canonname = bp; - nn = strlen(bp) + 1; /* for the \0 */ - bp += nn; - buflen -= nn; - } - - /* don't overwrite pai */ - ai = *pai; - ai.ai_family = (type == T_A) ? AF_INET : AF_INET6; - afd = find_afd(ai.ai_family); - if (afd == NULL) { - cp += n; - continue; - } - cur->ai_next = get_ai(&ai, afd, (const char *)cp); - if (cur->ai_next == NULL) - had_error++; - while (cur && cur->ai_next) - cur = cur->ai_next; - cp += n; - break; - default: - abort(); - } - if (!had_error) - haveanswer++; - } - if (haveanswer) { - if (!canonname) - (void)get_canonname(pai, sentinel.ai_next, qname); - else - (void)get_canonname(pai, sentinel.ai_next, canonname); - h_errno = NETDB_SUCCESS; - return sentinel.ai_next; - } - - h_errno = NO_RECOVERY; - return NULL; -} - -/*ARGSUSED*/ -static struct addrinfo * -_dns_getaddrinfo(name, pai) - const char *name; - const struct addrinfo *pai; -{ - struct addrinfo *ai; - querybuf buf, buf2; - struct addrinfo sentinel, *cur; - struct res_target q, q2; - - memset(&q, 0, sizeof(q2)); - memset(&q2, 0, sizeof(q2)); - memset(&sentinel, 0, sizeof(sentinel)); - cur = &sentinel; - - switch (pai->ai_family) { - case AF_UNSPEC: - /* prefer IPv6 */ - q.qclass = C_IN; - q.qtype = T_AAAA; - q.answer = buf.buf; - q.anslen = sizeof(buf); - q.next = &q2; - q2.qclass = C_IN; - q2.qtype = T_A; - q2.answer = buf2.buf; - q2.anslen = sizeof(buf2); - break; - case AF_INET: - q.qclass = C_IN; - q.qtype = T_A; - q.answer = buf.buf; - q.anslen = sizeof(buf); - break; - case AF_INET6: - q.qclass = C_IN; - q.qtype = T_AAAA; - q.answer = buf.buf; - q.anslen = sizeof(buf); - break; - default: - return NULL; - } - if (res_searchN(name, &q) < 0) - return NULL; - ai = getanswer(&buf, q.n, q.name, q.qtype, pai); - if (ai) { - cur->ai_next = ai; - while (cur && cur->ai_next) - cur = cur->ai_next; - } - if (q.next) { - ai = getanswer(&buf2, q2.n, q2.name, q2.qtype, pai); - if (ai) - cur->ai_next = ai; - } - return sentinel.ai_next; -} - -static void -_sethtent() -{ - if (!hostf) - hostf = fopen(_PATH_HOSTS, "r" ); - else - rewind(hostf); -} - -static void -_endhtent() -{ - if (hostf) { - (void) fclose(hostf); - hostf = NULL; - } -} - -static struct addrinfo * -_gethtent(name, pai) - const char *name; - const struct addrinfo *pai; -{ - char *p; - char *cp, *tname, *cname; - struct addrinfo hints, *res0, *res; - int error; - const char *addr; - char hostbuf[8*1024]; - - if (!hostf && !(hostf = fopen(_PATH_HOSTS, "r" ))) - return (NULL); - again: - if (!(p = fgets(hostbuf, sizeof hostbuf, hostf))) - return (NULL); - if (*p == '#') - goto again; - if (!(cp = strpbrk(p, "#\n"))) - goto again; - *cp = '\0'; - if (!(cp = strpbrk(p, " \t"))) - goto again; - *cp++ = '\0'; - addr = p; - /* if this is not something we're looking for, skip it. */ - cname = NULL; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (!cname) - cname = cp; - tname = cp; - if ((cp = strpbrk(cp, " \t")) != NULL) - *cp++ = '\0'; - if (strcasecmp(name, tname) == 0) - goto found; - } - goto again; - -found: - hints = *pai; - hints.ai_flags = AI_NUMERICHOST; - error = getaddrinfo(addr, NULL, &hints, &res0); - if (error) - goto again; - for (res = res0; res; res = res->ai_next) { - /* cover it up */ - res->ai_flags = pai->ai_flags; - - if (pai->ai_flags & AI_CANONNAME) { - if (get_canonname(pai, res, cname) != 0) { - freeaddrinfo(res0); - goto again; - } - } - } - return res0; -} - -/*ARGSUSED*/ -static struct addrinfo * -_files_getaddrinfo(name, pai) - const char *name; - const struct addrinfo *pai; -{ - struct addrinfo sentinel, *cur; - struct addrinfo *p; - - memset(&sentinel, 0, sizeof(sentinel)); - cur = &sentinel; - - _sethtent(); - while ((p = _gethtent(name, pai)) != NULL) { - cur->ai_next = p; - while (cur && cur->ai_next) - cur = cur->ai_next; - } - _endhtent(); - - return sentinel.ai_next; -} - -#ifdef YP -static char *__ypdomain; - -/*ARGSUSED*/ -static struct addrinfo * -_yphostent(line, pai) - char *line; - const struct addrinfo *pai; -{ - struct addrinfo sentinel, *cur; - struct addrinfo hints, *res, *res0; - int error; - char *p = line; - const char *addr, *canonname; - char *nextline; - char *cp; - - addr = canonname = NULL; - memset(&sentinel, 0, sizeof(sentinel)); - cur = &sentinel; - -nextline: - /* terminate line */ - cp = strchr(p, '\n'); - if (cp) { - *cp++ = '\0'; - nextline = cp; - } else - nextline = NULL; - - cp = strpbrk(p, " \t"); - if (cp == NULL) { - if (canonname == NULL) - return (NULL); - else - goto done; - } - *cp++ = '\0'; - - addr = p; - - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (!canonname) - canonname = cp; - if ((cp = strpbrk(cp, " \t")) != NULL) - *cp++ = '\0'; - } - - hints = *pai; - hints.ai_flags = AI_NUMERICHOST; - error = getaddrinfo(addr, NULL, &hints, &res0); - if (error == 0) { - for (res = res0; res; res = res->ai_next) { - /* cover it up */ - res->ai_flags = pai->ai_flags; - - if (pai->ai_flags & AI_CANONNAME) - (void)get_canonname(pai, res, canonname); - } - } else - res0 = NULL; - if (res0) { - cur->ai_next = res0; - while (cur && cur->ai_next) - cur = cur->ai_next; - } - - if (nextline) { - p = nextline; - goto nextline; - } - -done: - return sentinel.ai_next; -} - -/*ARGSUSED*/ -static struct addrinfo * -_yp_getaddrinfo(name, pai) - const char *name; - const struct addrinfo *pai; -{ - struct addrinfo sentinel, *cur; - struct addrinfo *ai = NULL; - static char *__ypcurrent; - int __ypcurrentlen, r; - - memset(&sentinel, 0, sizeof(sentinel)); - cur = &sentinel; - - if (!__ypdomain) { - if (_yp_check(&__ypdomain) == 0) - return NULL; - } - if (__ypcurrent) - free(__ypcurrent); - __ypcurrent = NULL; - - /* hosts.byname is only for IPv4 (Solaris8) */ - if (pai->ai_family == PF_UNSPEC || pai->ai_family == PF_INET) { - r = yp_match(__ypdomain, "hosts.byname", name, - (int)strlen(name), &__ypcurrent, &__ypcurrentlen); - if (r == 0) { - struct addrinfo ai4; - - ai4 = *pai; - ai4.ai_family = AF_INET; - ai = _yphostent(__ypcurrent, &ai4); - if (ai) { - cur->ai_next = ai; - while (cur && cur->ai_next) - cur = cur->ai_next; - } - } - } - - /* ipnodes.byname can hold both IPv4/v6 */ - r = yp_match(__ypdomain, "ipnodes.byname", name, - (int)strlen(name), &__ypcurrent, &__ypcurrentlen); - if (r == 0) { - ai = _yphostent(__ypcurrent, pai); - if (ai) { - cur->ai_next = ai; - while (cur && cur->ai_next) - cur = cur->ai_next; - } - } - - return sentinel.ai_next; -} -#endif - - -/* resolver logic */ - -extern const char *__hostalias (const char *); -extern int res_opt (int, u_char *, int, int); - -/* - * Formulate a normal query, send, and await answer. - * Returned answer is placed in supplied buffer "answer". - * Perform preliminary check of answer, returning success only - * if no error is indicated and the answer count is nonzero. - * Return the size of the response on success, -1 on error. - * Error number is left in h_errno. - * - * Caller must parse answer and determine whether it answers the question. - */ -static int -res_queryN(name, target) - const char *name; /* domain name */ - struct res_target *target; -{ - u_char buf[MAXPACKET]; - HEADER *hp; - int n; - struct res_target *t; - int rcode; - int ancount; - - rcode = NOERROR; - ancount = 0; - - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { - h_errno = NETDB_INTERNAL; - return (-1); - } - - for (t = target; t; t = t->next) { - int class, type; - u_char *answer; - int anslen; - - hp = (HEADER *)(void *)t->answer; - hp->rcode = NOERROR; /* default */ - - /* make it easier... */ - class = t->qclass; - type = t->qtype; - answer = t->answer; - anslen = t->anslen; -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf(";; res_query(%s, %d, %d)\n", name, class, type); -#endif - - n = res_mkquery(QUERY, name, class, type, NULL, 0, NULL, - buf, sizeof(buf)); - if (n > 0 && (_res.options & RES_USE_EDNS0) != 0) - n = res_opt(n, buf, sizeof(buf), anslen); - if (n <= 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf(";; res_query: mkquery failed\n"); -#endif - h_errno = NO_RECOVERY; - return (n); - } - n = res_send(buf, n, answer, anslen); -#if 0 - if (n < 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf(";; res_query: send error\n"); -#endif - h_errno = TRY_AGAIN; - return (n); - } -#endif - - if (n < 0 || hp->rcode != NOERROR || ntohs(hp->ancount) == 0) { - rcode = hp->rcode; /* record most recent error */ -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf(";; rcode = %d, ancount=%d\n", hp->rcode, - ntohs(hp->ancount)); -#endif - continue; - } - - ancount += ntohs(hp->ancount); - - t->n = n; - } - - if (ancount == 0) { - switch (rcode) { - case NXDOMAIN: - h_errno = HOST_NOT_FOUND; - break; - case SERVFAIL: - h_errno = TRY_AGAIN; - break; - case NOERROR: - h_errno = NO_DATA; - break; - case FORMERR: - case NOTIMP: - case REFUSED: - default: - h_errno = NO_RECOVERY; - break; - } - return (-1); - } - return (ancount); -} - -/* - * Formulate a normal query, send, and retrieve answer in supplied buffer. - * Return the size of the response on success, -1 on error. - * If enabled, implement search rules until answer or unrecoverable failure - * is detected. Error code, if any, is left in h_errno. - */ -static int -res_searchN(name, target) - const char *name; /* domain name */ - struct res_target *target; -{ - const char *cp, * const *domain; - HEADER *hp = (HEADER *)(void *)target->answer; /*XXX*/ - u_int dots; - int trailing_dot, ret, saved_herrno; - int got_nodata = 0, got_servfail = 0, tried_as_is = 0; - - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { - h_errno = NETDB_INTERNAL; - return (-1); - } - - errno = 0; - h_errno = HOST_NOT_FOUND; /* default, if we never query */ - dots = 0; - for (cp = name; *cp; cp++) - dots += (*cp == '.'); - trailing_dot = 0; - if (cp > name && *--cp == '.') - trailing_dot++; - - /* - * if there aren't any dots, it could be a user-level alias - */ - if (!dots && (cp = __hostalias(name)) != NULL) - return (res_queryN(cp, target)); - - /* - * If there are dots in the name already, let's just give it a try - * 'as is'. The threshold can be set with the "ndots" option. - */ - saved_herrno = -1; - if (dots >= _res.ndots) { - ret = res_querydomainN(name, NULL, target); - if (ret > 0) - return (ret); - saved_herrno = h_errno; - tried_as_is++; - } - - /* - * We do at least one level of search if - * - there is no dot and RES_DEFNAME is set, or - * - there is at least one dot, there is no trailing dot, - * and RES_DNSRCH is set. - */ - if ((!dots && (_res.options & RES_DEFNAMES)) || - (dots && !trailing_dot && (_res.options & RES_DNSRCH))) { - int done = 0; - - for (domain = (const char * const *)_res.dnsrch; - *domain && !done; - domain++) { - - ret = res_querydomainN(name, *domain, target); - if (ret > 0) - return (ret); - - /* - * If no server present, give up. - * If name isn't found in this domain, - * keep trying higher domains in the search list - * (if that's enabled). - * On a NO_DATA error, keep trying, otherwise - * a wildcard entry of another type could keep us - * from finding this entry higher in the domain. - * If we get some other error (negative answer or - * server failure), then stop searching up, - * but try the input name below in case it's - * fully-qualified. - */ - if (errno == ECONNREFUSED) { - h_errno = TRY_AGAIN; - return (-1); - } - - switch (h_errno) { - case NO_DATA: - got_nodata++; - /* FALLTHROUGH */ - case HOST_NOT_FOUND: - /* keep trying */ - break; - case TRY_AGAIN: - if (hp->rcode == SERVFAIL) { - /* try next search element, if any */ - got_servfail++; - break; - } - /* FALLTHROUGH */ - default: - /* anything else implies that we're done */ - done++; - } - /* - * if we got here for some reason other than DNSRCH, - * we only wanted one iteration of the loop, so stop. - */ - if (!(_res.options & RES_DNSRCH)) - done++; - } - } - - /* - * if we have not already tried the name "as is", do that now. - * note that we do this regardless of how many dots were in the - * name or whether it ends with a dot. - */ - if (!tried_as_is) { - ret = res_querydomainN(name, NULL, target); - if (ret > 0) - return (ret); - } - - /* - * if we got here, we didn't satisfy the search. - * if we did an initial full query, return that query's h_errno - * (note that we wouldn't be here if that query had succeeded). - * else if we ever got a nodata, send that back as the reason. - * else send back meaningless h_errno, that being the one from - * the last DNSRCH we did. - */ - if (saved_herrno != -1) - h_errno = saved_herrno; - else if (got_nodata) - h_errno = NO_DATA; - else if (got_servfail) - h_errno = TRY_AGAIN; - return (-1); -} - -/* - * Perform a call on res_query on the concatenation of name and domain, - * removing a trailing dot from name if domain is NULL. - */ -static int -res_querydomainN(name, domain, target) - const char *name, *domain; - struct res_target *target; -{ - char nbuf[MAXDNAME]; - const char *longname = nbuf; - size_t n, d; - - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { - h_errno = NETDB_INTERNAL; - return (-1); - } -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf(";; res_querydomain(%s, %s)\n", - name, domain?domain:""); -#endif - if (domain == NULL) { - /* - * Check for trailing '.'; - * copy without '.' if present. - */ - n = strlen(name); - if (n >= MAXDNAME) { - h_errno = NO_RECOVERY; - return (-1); - } - if (n > 0 && name[--n] == '.') { - strncpy(nbuf, name, n + 1); - } else - longname = name; - } else { - n = strlen(name); - d = strlen(domain); - if (n + d + 1 >= MAXDNAME) { - h_errno = NO_RECOVERY; - return (-1); - } -/* wtf, doesn't metrowerks stdio have snprintf??? */ -#ifdef _WWERKS_STDIO_H - printf(nbuf, "%s.%s", name, domain); -#else - snprintf(nbuf, sizeof(nbuf), "%s.%s", name, domain); -#endif - } - return (res_queryN(longname, target)); -} diff --git a/src/kits/network/old/compat/libnet/gethostnamadr.c b/src/kits/network/old/compat/libnet/gethostnamadr.c deleted file mode 100644 index 0698c08428..0000000000 --- a/src/kits/network/old/compat/libnet/gethostnamadr.c +++ /dev/null @@ -1,1180 +0,0 @@ -/*- - * Copyright (c) 1985, 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - - * --Copyright-- - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef YP -#include -#include -#include -#include "ypinternal.h" -#endif - -#define MULTI_PTRS_ARE_ALIASES 1 /* XXX - experimental */ - -#define MAXALIASES 35 -#define MAXADDRS 35 - -static char *h_addr_ptrs[MAXADDRS + 1]; - -#ifdef YP -static char *__ypdomain; -#endif - -static struct hostent host; -static char *host_aliases[MAXALIASES]; -static char hostbuf[BUFSIZ+1]; -static union { - struct in_addr _host_in_addr; - u_char _host_addr[16]; /* IPv4 or IPv6 */ -} _host_addr_u; -#define host_addr _host_addr_u._host_addr -static FILE *hostf = NULL; -static int stayopen = 0; - -static sem_id gethostnamadr = -1; - -#if INET6 -static void map_v4v6_address (const char *src, char *dst); -static void map_v4v6_hostent (struct hostent *hp, char **bp, int *len); -#endif - -#ifdef RESOLVSORT -static void addrsort (char **, int); -#endif - -int _hokchar (const char *); - -static const char AskedForGot[] = - "gethostby*.getanswer: asked for \"%s\", got \"%s\""; - -#if PACKETSZ > 1024 -#define MAXPACKET PACKETSZ -#else -#define MAXPACKET 1024 -#endif - -typedef union { - HEADER hdr; - u_char buf[MAXPACKET]; -} querybuf; - -typedef union { - int32 al; - char ac; -} align; - -static struct hostent *getanswer (const querybuf *, int, const char *, int); - -int -_hokchar(p) - const char *p; -{ - char c; - - /* - * Many people do not obey RFC 822 and 1035. The valid - * characters are a-z, A-Z, 0-9, '-' and . But the others - * tested for below can happen, and we must be more permissive - * than the resolver until those idiots clean up their act. - * We let '/' through, but not '..' - */ - while ((c = *p++)) { - if (('a' <= c && c <= 'z') || - ('A' <= c && c <= 'Z') || - ('0' <= c && c <= '9')) - continue; - if (strchr("-_/", c)) - continue; - if (c == '.' && *p != '.') - continue; - return 0; - } - return 1; -} - - -static struct hostent *getanswer(const querybuf *answer, - int anslen, - const char *qname, - int qtype) -{ - const HEADER *hp; - const u_char *cp; - int n; - const u_char *eom; - char *bp, **ap, **hap; - int type, class, buflen, ancount, qdcount; - int haveanswer, had_error; - int toobig = 0; - char tbuf[MAXDNAME]; - const char *tname; - int (*name_ok) (const char *); - - tname = qname; - host.h_name = NULL; - eom = answer->buf + anslen; - switch (qtype) { - case T_A: - case T_AAAA: -#ifdef USE_RESOLV_NAME_OK - name_ok = res_hnok; - break; -#endif - case T_PTR: -#ifdef USE_RESOLV_NAME_OK - name_ok = res_dnok; -#else - name_ok = _hokchar; -#endif - break; - default: - return (NULL); - } - /* - * find first satisfactory answer - */ - hp = &answer->hdr; - ancount = ntohs(hp->ancount); - qdcount = ntohs(hp->qdcount); - bp = hostbuf; - buflen = sizeof hostbuf; - cp = answer->buf + HFIXEDSZ; - if (qdcount != 1) { - h_errno = NO_RECOVERY; - return (NULL); - } - n = dn_expand(answer->buf, eom, cp, bp, buflen); - if ((n < 0) || !(*name_ok)(bp)) { - h_errno = NO_RECOVERY; - return (NULL); - } - cp += n + QFIXEDSZ; - if (qtype == T_A || qtype == T_AAAA) { - /* res_send() has already verified that the query name is the - * same as the one we sent; this just gets the expanded name - * (i.e., with the succeeding search-domain tacked on). - */ - n = strlen(bp) + 1; /* for the \0 */ - host.h_name = bp; - bp += n; - buflen -= n; - /* The qname can be abbreviated, but h_name is now absolute. */ - qname = host.h_name; - } - ap = host_aliases; - *ap = NULL; - host.h_aliases = host_aliases; - hap = h_addr_ptrs; - *hap = NULL; - host.h_addr_list = h_addr_ptrs; - haveanswer = 0; - had_error = 0; - while (ancount-- > 0 && cp < eom && !had_error) { - n = dn_expand(answer->buf, eom, cp, bp, buflen); - if ((n < 0) || !(*name_ok)(bp)) { - had_error++; - continue; - } - cp += n; /* name */ - type = _getshort(cp); - cp += INT16SZ; /* type */ - class = _getshort(cp); - cp += INT16SZ + INT32SZ; /* class, TTL */ - n = _getshort(cp); - cp += INT16SZ; /* len */ - if (type == T_SIG) { - /* XXX - ignore signatures as we don't use them yet */ - cp += n; - continue; - } - if (class != C_IN) { - /* XXX - debug? syslog? */ - cp += n; - continue; /* XXX - had_error++ ? */ - } - if ((qtype == T_A || qtype == T_AAAA) && type == T_CNAME) { - if (ap >= &host_aliases[MAXALIASES-1]) - continue; - n = dn_expand(answer->buf, eom, cp, tbuf, sizeof tbuf); - if ((n < 0) || !(*name_ok)(tbuf)) { - had_error++; - continue; - } - cp += n; - /* Store alias. */ - *ap++ = bp; - n = strlen(bp) + 1; /* for the \0 */ - bp += n; - buflen -= n; - /* Get canonical name. */ - n = strlen(tbuf) + 1; /* for the \0 */ - if (n > buflen) { - had_error++; - continue; - } - strcpy(bp, tbuf); - host.h_name = bp; - bp += n; - buflen -= n; - continue; - } - if (qtype == T_PTR && type == T_CNAME) { - n = dn_expand(answer->buf, eom, cp, tbuf, sizeof tbuf); -#ifdef USE_RESOLV_NAME_OK - if ((n < 0) || !res_hnok(tbuf)) { -#else - if ((n < 0) || !_hokchar(tbuf)) { -#endif - had_error++; - continue; - } - cp += n; - /* Get canonical name. */ - n = strlen(tbuf) + 1; /* for the \0 */ - if (n > buflen) { - had_error++; - continue; - } - strcpy(bp, tbuf); - tname = bp; - bp += n; - buflen -= n; - continue; - } - if (type != qtype) { -/* XXX - Fix me! - syslog(LOG_NOTICE|LOG_AUTH, - "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"", - qname, p_class(C_IN), p_type(qtype), - p_type(type)); - */ - cp += n; - continue; /* XXX - had_error++ ? */ - } - switch (type) { - case T_PTR: - if (strcasecmp(tname, bp) != 0) { -/* XXX - Fix me! - syslog(LOG_NOTICE|LOG_AUTH, - AskedForGot, qname, bp); - */ - cp += n; - continue; /* XXX - had_error++ ? */ - } - n = dn_expand(answer->buf, eom, cp, bp, buflen); -#ifdef USE_RESOLV_NAME_OK - if ((n < 0) || !res_hnok(bp)) { -#else - if ((n < 0) || !_hokchar(bp)) { -#endif - had_error++; - break; - } -#if MULTI_PTRS_ARE_ALIASES - cp += n; - if (!haveanswer) - host.h_name = bp; - else if (ap < &host_aliases[MAXALIASES-1]) - *ap++ = bp; - else - n = -1; - if (n != -1) { - n = strlen(bp) + 1; /* for the \0 */ - bp += n; - buflen -= n; - } - break; -#else - host.h_name = bp; - if (_res.options & RES_USE_INET6) { - n = strlen(bp) + 1; /* for the \0 */ - bp += n; - buflen -= n; - map_v4v6_hostent(&host, &bp, &buflen); - } - h_errno = NETDB_SUCCESS; - return (&host); -#endif - case T_A: - case T_AAAA: - if (strcasecmp(host.h_name, bp) != 0) { -/* XXX - Fix me! - syslog(LOG_NOTICE|LOG_AUTH, - AskedForGot, host.h_name, bp); - */ - cp += n; - continue; /* XXX - had_error++ ? */ - } - if (n != host.h_length) { - cp += n; - continue; - } - if (!haveanswer) { - register int nn; - - host.h_name = bp; - nn = strlen(bp) + 1; /* for the \0 */ - bp += nn; - buflen -= nn; - } - - bp += sizeof(align) - ((u_long)bp % sizeof(align)); - - if (bp + n >= &hostbuf[sizeof hostbuf]) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf("size (%d) too big\n", n); -#endif - had_error++; - continue; - } - if (hap >= &h_addr_ptrs[MAXADDRS-1]) { - if (!toobig++) -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf("Too many addresses (%d)\n", MAXADDRS); -#endif - cp += n; - continue; - } - memcpy(*hap++ = bp, cp, n); - bp += n; - buflen -= n; - cp += n; - break; - } - if (!had_error) - haveanswer++; - } - if (haveanswer) { - *ap = NULL; - *hap = NULL; -# if defined(RESOLVSORT) - /* - * Note: we sort even if host can take only one address - * in its return structures - should give it the "best" - * address in that case, not some random one - */ - if (_res.nsort && haveanswer > 1 && qtype == T_A) - addrsort(h_addr_ptrs, haveanswer); -# endif /*RESOLVSORT*/ - if (!host.h_name) { - n = strlen(qname) + 1; /* for the \0 */ - if (n > buflen) - goto try_again; - strcpy(bp, qname); - host.h_name = bp; - bp += n; - buflen -= n; - } -#if INET6 - if (_res.options & RES_USE_INET6) - map_v4v6_hostent(&host, &bp, &buflen); -#endif - h_errno = NETDB_SUCCESS; - return (&host); - } - try_again: - h_errno = TRY_AGAIN; - return (NULL); -} - -#ifdef notyet -/* - * XXX This is an extremely bogus implementation. - * - * FreeBSD has this interface: - * int gethostbyaddr_r(const char *addr, int len, int type, - * struct hostent *result, struct hostent_data *buffer) - */ - -struct hostent * -gethostbyname_r(name, hp, buf, buflen, errorp) - const char * name; - struct hostent * hp; - char * buf; - int buflen; - int * errorp; -{ - struct hostent *res; - - res = gethostbyname(name); - *errorp = h_errno; - if (res == NULL) - return NULL; - memcpy(hp, res, sizeof *hp); /* XXX not sufficient */ - return hp; -} - -/* - * XXX This is an extremely bogus implementation. - */ -struct hostent * -gethostbyaddr_r(addr, len, af, he, buf, buflen, errorp) - const char *addr; /* XXX should have been def'd as u_char! */ - int len, af; - struct hostent * he; - char * buf; - int buflen; - int * errorp; -{ - struct hostent * res; - - res = gethostbyaddr(addr, len, af); - *errorp = h_errno; - if (res == NULL) - return NULL; - memcpy(he, res, sizeof *he); /* XXX not sufficient */ - return he; -} - -/* XXX RFC2133 expects a gethostbyname2_r() -- unimplemented */ -#endif - - - - -struct hostent * gethostbyname(const char *name) -{ - struct hostent *hp; - extern struct hostent *_gethtbyname2(); - - if (gethostnamadr == -1) - gethostnamadr = create_sem(1, "gethostnamadr"); - - acquire_sem_etc(gethostnamadr,1, B_CAN_INTERRUPT, 0); - if ((_res.options & RES_INIT) == 0 && res_init() == -1) - hp = _gethtbyname2(name, AF_INET); -#if INET6 - else if (_res.options & RES_USE_INET6) { - hp = gethostbyname2(name, AF_INET6); - if (hp == NULL) - hp = gethostbyname2(name, AF_INET); - } -#endif - else - hp = gethostbyname2(name, AF_INET); - release_sem_etc(gethostnamadr,1, B_CAN_INTERRUPT); - return hp; -} - - -struct hostent *gethostbyname2(const char *name, int af) -{ - querybuf buf; - register const char *cp; - char *bp; - int n, size, type, len, i; - extern struct hostent *_gethtbyname2(), *_yp_gethtbyname(); - register struct hostent *hp; - char lookups[MAXDNSLUS]; - - if ((_res.options & RES_INIT) == 0 && res_init() == -1) - return (_gethtbyname2(name, af)); - - switch (af) { - case AF_INET: - size = INADDRSZ; - type = T_A; - break; -#if INET6 - case AF_INET6: - size = IN6ADDRSZ; - type = T_AAAA; - break; -#endif - default: - h_errno = NETDB_INTERNAL; - errno = EAFNOSUPPORT; - return (NULL); - } - - host.h_addrtype = af; - host.h_length = size; - - /* - * if there aren't any dots, it could be a user-level alias. - * this is also done in res_query() since we are not the only - * function that looks up host names. - */ - if (!strchr(name, '.') && (cp = __hostalias(name))) - name = cp; - - /* - * disallow names consisting only of digits/dots, unless - * they end in a dot. - */ - if (isdigit(name[0])) - for (cp = name;; ++cp) { - if (!*cp) { - if (*--cp == '.') - break; - /* - * All-numeric, no dot at the end. - * Fake up a hostent as if we'd actually - * done a lookup. - */ - if (inet_pton(af, name, host_addr) <= 0) { - h_errno = HOST_NOT_FOUND; - return (NULL); - } - strncpy(hostbuf, name, MAXHOSTNAMELEN); - bp = hostbuf + MAXHOSTNAMELEN; - len = sizeof hostbuf - MAXHOSTNAMELEN; - host.h_name = hostbuf; - host.h_aliases = host_aliases; - host_aliases[0] = NULL; - h_addr_ptrs[0] = (char *)host_addr; - h_addr_ptrs[1] = NULL; - host.h_addr_list = h_addr_ptrs; -#if INET6 - if (_res.options & RES_USE_INET6) - map_v4v6_hostent(&host, &bp, &len); -#endif - h_errno = NETDB_SUCCESS; - return (&host); - } - if (!isdigit(*cp) && *cp != '.') - break; - } - if ((isxdigit(name[0]) && strchr(name, ':') != NULL) || - name[0] == ':') - for (cp = name;; ++cp) { - if (!*cp) { - if (*--cp == '.') - break; - /* - * All-IPv6-legal, no dot at the end. - * Fake up a hostent as if we'd actually - * done a lookup. - */ - if (inet_pton(af, name, host_addr) <= 0) { - h_errno = HOST_NOT_FOUND; - return (NULL); - } - strncpy(hostbuf, name, MAXHOSTNAMELEN); - bp = hostbuf + MAXHOSTNAMELEN; - len = sizeof hostbuf - MAXHOSTNAMELEN; - host.h_name = hostbuf; - host.h_aliases = host_aliases; - host_aliases[0] = NULL; - h_addr_ptrs[0] = (char *)host_addr; - h_addr_ptrs[1] = NULL; - host.h_addr_list = h_addr_ptrs; - h_errno = NETDB_SUCCESS; - return (&host); - } - if (!isxdigit(*cp) && *cp != ':' && *cp != '.') - break; - } - - memcpy(lookups, _res.lookups, sizeof lookups); - if (lookups[0] == '\0') - strncpy(lookups, "bf", sizeof lookups); - - hp = (struct hostent *)NULL; - for (i = 0; i < MAXDNSLUS && hp == NULL && lookups[i]; i++) { - switch (lookups[i]) { -#ifdef YP - case 'y': - /* YP only supports AF_INET. */ - if (af == AF_INET) - hp = _yp_gethtbyname(name); - break; -#endif - case 'b': - if ((n = res_search(name, C_IN, type, buf.buf, - sizeof(buf))) < 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf("res_search failed\n"); -#endif - break; - } - hp = getanswer(&buf, n, name, type); - break; - case 'f': - hp = _gethtbyname2(name, af); - break; - } - } - /* XXX h_errno not correct in all cases... */ - return (hp); -} - - -struct hostent *gethostbyaddr(const char *addr, int len, int af) -{ - const u_char *uaddr = (const u_char *)addr; - int n, size, i; - querybuf buf; - struct hostent *hp; - char qbuf[MAXDNAME+1], *qp; - extern struct hostent *_gethtbyaddr(), *_yp_gethtbyaddr(); - char lookups[MAXDNSLUS]; - struct hostent *res; - - acquire_sem(gethostnamadr); - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { -//printf("gethostbyaddr: calling _gethtbyaddr\n"); - res = _gethtbyaddr(addr, len, af); - release_sem_etc(gethostnamadr,1, B_CAN_INTERRUPT); - return (res); - } -#if INET6 - if (af == AF_INET6 && len == IN6ADDRSZ && - (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)uaddr) || - IN6_IS_ADDR_V4COMPAT((struct in6_addr *)uaddr))) { - /* Unmap. */ - addr += IN6ADDRSZ - INADDRSZ; - uaddr += IN6ADDRSZ - INADDRSZ; - af = AF_INET; - len = INADDRSZ; - } -#endif - switch (af) { - case AF_INET: - size = INADDRSZ; - break; -#if INET6 - case AF_INET6: - size = IN6ADDRSZ; - break; -#endif - default: - errno = EAFNOSUPPORT; - h_errno = NETDB_INTERNAL; - release_sem_etc(gethostnamadr,1, B_CAN_INTERRUPT); - return (NULL); - } - if (size != len) { - errno = EINVAL; - h_errno = NETDB_INTERNAL; - release_sem_etc(gethostnamadr,1, B_CAN_INTERRUPT); - return (NULL); - } - switch (af) { - case AF_INET: - (void) sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa", - (uint8)(uaddr[3] & 0xff), - (uint8)(uaddr[2] & 0xff), - (uint8)(uaddr[1] & 0xff), - (uint8)(uaddr[0] & 0xff)); - break; - case AF_INET6: - qp = qbuf; - for (n = IN6ADDRSZ - 1; n >= 0; n--) { - qp += sprintf(qp, "%x.%x.", - uaddr[n] & 0xf, - (uaddr[n] >> 4) & 0xf); - } - strcpy(qp, "ip6.int"); - break; - } - - memcpy(lookups, _res.lookups, sizeof lookups); - if (lookups[0] == '\0') - strncpy(lookups, "bf", sizeof lookups); - - hp = (struct hostent *)NULL; - for (i = 0; i < MAXDNSLUS && hp == NULL && lookups[i]; i++) { - switch (lookups[i]) { -#ifdef YP - case 'y': - /* YP only supports AF_INET. */ - if (af == AF_INET) - hp = _yp_gethtbyaddr(addr); - break; -#endif - case 'b': -//printf("res_query for %s\n", qbuf); - n = res_query(qbuf, C_IN, T_PTR, (u_char *)buf.buf, - sizeof buf.buf); - if (n < 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf("res_query failed\n"); -#endif - break; - } - if (!(hp = getanswer(&buf, n, qbuf, T_PTR))) - break; - hp->h_addrtype = af; - hp->h_length = len; - memcpy(host_addr, addr, len); - h_addr_ptrs[0] = (char *)host_addr; - h_addr_ptrs[1] = NULL; - if (af == AF_INET && (_res.options & RES_USE_INET6)) { -#ifdef INET6 - map_v4v6_address((char*)host_addr, - (char*)host_addr); - hp->h_addrtype = AF_INET6; - hp->h_length = IN6ADDRSZ; -#endif - } - h_errno = NETDB_SUCCESS; - break; - case 'f': - hp = _gethtbyaddr(addr, len, af); - break; - } - } - release_sem_etc(gethostnamadr,1, B_CAN_INTERRUPT); - /* XXX h_errno not correct in all cases... */ - return (hp); -} - -void _sethtent(int f) -{ -//printf("_sethtent\n"); - if (hostf == NULL) - hostf = fopen(_PATH_HOSTS, "r" ); - else - rewind(hostf); - stayopen = f; -} - -void _endhtent() -{ - if (hostf && !stayopen) { - (void) fclose(hostf); - hostf = NULL; - } -} - - -struct hostent *_gethtent() -{ - char *p; - register char *cp, **q; - int af = 0; - size_t len = 0; - char lbuf[80]; -//printf("_gethtent\n"); - if (!hostf && !(hostf = fopen(_PATH_HOSTS, "r" ))) { - h_errno = NETDB_INTERNAL; - return (NULL); - } - again: - - if (fgets(lbuf, 80, hostf) == NULL) { - h_errno = HOST_NOT_FOUND; - return (NULL); - } - len = strlen(lbuf); - p = lbuf; - if (p[len-1] == '\n') - len--; - if (len >= sizeof(hostbuf) || len == 0) - goto again; - p = memcpy(hostbuf, p, len); - hostbuf[len] = '\0'; - if (*p == '#') - goto again; - if ((cp = strchr(p, '#'))) - *cp = '\0'; - if (!(cp = strpbrk(p, " \t"))) - goto again; - *cp++ = '\0'; - if (inet_pton(AF_INET6, p, host_addr) > 0) { - af = AF_INET6; - len = IN6ADDRSZ; - } else if (inet_pton(AF_INET, p, host_addr) > 0) { - if (_res.options & RES_USE_INET6) { -#ifdef INET6 - map_v4v6_address((char*)host_addr, (char*)host_addr); - af = AF_INET6; - len = IN6ADDRSZ; -#endif - } else { - af = AF_INET; - len = INADDRSZ; - } - } else { - goto again; - } - /* if this is not something we're looking for, skip it. */ - if (host.h_addrtype != af) - goto again; - if (host.h_length != len) - goto again; - h_addr_ptrs[0] = (char *)host_addr; - h_addr_ptrs[1] = NULL; - host.h_addr_list = h_addr_ptrs; - host.h_length = len; - host.h_addrtype = af; - while (*cp == ' ' || *cp == '\t') - cp++; - host.h_name = cp; - q = host.h_aliases = host_aliases; - if ((cp = strpbrk(cp, " \t"))) - *cp++ = '\0'; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &host_aliases[MAXALIASES - 1]) - *q++ = cp; - if ((cp = strpbrk(cp, " \t"))) - *cp++ = '\0'; - } - *q = NULL; - if (_res.options & RES_USE_INET6) { -#ifdef INET6 - char *bp = hostbuf; - int buflen = sizeof hostbuf; - map_v4v6_hostent(&host, &bp, &buflen); -#endif - } - h_errno = NETDB_SUCCESS; - return (&host); -} - - -struct hostent *_gethtbyname(const char *name) -{ - extern struct hostent *_gethtbyname2(); - struct hostent *hp; - - if (_res.options & RES_USE_INET6) { - hp = _gethtbyname2(name, AF_INET6); - if (hp) - return (hp); - } - return (_gethtbyname2(name, AF_INET)); -} - - -struct hostent *_gethtbyname2(const char *name, int af) -{ - struct hostent *p; - char **cp; - - _sethtent(0); - while ((p = _gethtent())) { - if (p->h_addrtype != af) - continue; - if (strcasecmp(p->h_name, name) == 0) - break; - for (cp = p->h_aliases; *cp != 0; cp++) - if (strcasecmp(*cp, name) == 0) - goto found; - } - found: - _endhtent(); - return (p); -} - - -struct hostent *_gethtbyaddr(const char *addr, int len, int af) -{ - struct hostent *p; -//printf("_gethtbyaddr\n"); - host.h_length = len; - host.h_addrtype = af; - - _sethtent(0); - while ((p = _gethtent())) - if (p->h_addrtype == af && !memcmp(p->h_addr, addr, len)) - break; - _endhtent(); - return (p); -} - -#ifdef YP -struct hostent * -_yphostent(line) - char *line; -{ - static struct in_addr host_addrs[MAXADDRS]; - char *p = line; - char *cp, **q; - char **hap; - struct in_addr *buf; - int more; - - host.h_name = NULL; - host.h_addr_list = h_addr_ptrs; - host.h_length = INADDRSZ; - host.h_addrtype = AF_INET; - hap = h_addr_ptrs; - buf = host_addrs; - q = host.h_aliases = host_aliases; - -nextline: - /* check for host_addrs overflow */ - if (buf >= &host_addrs[sizeof(host_addrs) / sizeof(host_addrs[0])]) - goto done; - - more = 0; - cp = strpbrk(p, " \t"); - if (cp == NULL) - goto done; - *cp++ = '\0'; - - *hap++ = (char *)buf; - (void) inet_aton(p, buf++); - - while (*cp == ' ' || *cp == '\t') - cp++; - p = cp; - cp = strpbrk(p, " \t\n"); - if (cp != NULL) { - if (*cp == '\n') - more = 1; - *cp++ = '\0'; - } - if (!host.h_name) - host.h_name = p; - else if (strcmp(host.h_name, p)==0) - ; - else if (q < &host_aliases[MAXALIASES - 1]) - *q++ = p; - p = cp; - if (more) - goto nextline; - - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (*cp == '\n') { - cp++; - goto nextline; - } - if (q < &host_aliases[MAXALIASES - 1]) - *q++ = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } -done: - if (host.h_name == NULL) - return (NULL); - *q = NULL; - *hap = NULL; - return (&host); -} - -struct hostent * -_yp_gethtbyaddr(addr) - const char *addr; -{ - struct hostent *hp = (struct hostent *)NULL; - static char *__ypcurrent; - int __ypcurrentlen, r; - char name[sizeof("xxx.xxx.xxx.xxx")]; - - if (!__ypdomain) { - if (_yp_check(&__ypdomain) == 0) - return (hp); - } - sprintf(name, "%u.%u.%u.%u", - ((unsigned)addr[0] & 0xff), - ((unsigned)addr[1] & 0xff), - ((unsigned)addr[2] & 0xff), - ((unsigned)addr[3] & 0xff)); - if (__ypcurrent) - free(__ypcurrent); - __ypcurrent = NULL; - r = yp_match(__ypdomain, "hosts.byaddr", name, - strlen(name), &__ypcurrent, &__ypcurrentlen); - if (r==0) - hp = _yphostent(__ypcurrent); - if (hp==NULL) - h_errno = HOST_NOT_FOUND; - return (hp); -} - -struct hostent * -_yp_gethtbyname(name) - const char *name; -{ - struct hostent *hp = (struct hostent *)NULL; - static char *__ypcurrent; - int __ypcurrentlen, r; - - if (strlen(name) >= MAXHOSTNAMELEN) - return (NULL); - if (!__ypdomain) { - if (_yp_check(&__ypdomain) == 0) - return (hp); - } - if (__ypcurrent) - free(__ypcurrent); - __ypcurrent = NULL; - r = yp_match(__ypdomain, "hosts.byname", name, - strlen(name), &__ypcurrent, &__ypcurrentlen); - if (r == 0) - hp = _yphostent(__ypcurrent); - if (hp == NULL) - h_errno = HOST_NOT_FOUND; - return (hp); -} -#endif - -#if INET6 -static void -map_v4v6_address(src, dst) - const char *src; - char *dst; -{ - u_char *p = (u_char *)dst; - char tmp[INADDRSZ]; - int i; - - /* Stash a temporary copy so our caller can update in place. */ - memcpy(tmp, src, INADDRSZ); - /* Mark this ipv6 addr as a mapped ipv4. */ - for (i = 0; i < 10; i++) - *p++ = 0x00; - *p++ = 0xff; - *p++ = 0xff; - /* Retrieve the saved copy and we're done. */ - memcpy((void*)p, tmp, INADDRSZ); -} - -static void -map_v4v6_hostent(hp, bpp, lenp) - struct hostent *hp; - char **bpp; - int *lenp; -{ - char **ap; - - if (hp->h_addrtype != AF_INET || hp->h_length != INADDRSZ) - return; - hp->h_addrtype = AF_INET6; - hp->h_length = IN6ADDRSZ; - for (ap = hp->h_addr_list; *ap; ap++) { - int i = sizeof(align) - ((u_long)*bpp % sizeof(align)); - - if (*lenp < (i + IN6ADDRSZ)) { - /* Out of memory. Truncate address list here. XXX */ - *ap = NULL; - return; - } - *bpp += i; - *lenp -= i; - map_v4v6_address(*ap, *bpp); - *ap = *bpp; - *bpp += IN6ADDRSZ; - *lenp -= IN6ADDRSZ; - } -} -#endif /* INET6 */ - -struct hostent * -gethostent() -{ - return (_gethtent()); -} - -#ifdef RESOLVSORT -static void -addrsort(ap, num) - char **ap; - int num; -{ - int i, j; - char **p; - short aval[MAXADDRS]; - int needsort = 0; - - p = ap; - for (i = 0; i < num; i++, p++) { - for (j = 0 ; (unsigned)j < _res.nsort; j++) - if (_res.sort_list[j].addr.s_addr == - (((struct in_addr *)(*p))->s_addr & _res.sort_list[j].mask)) - break; - aval[i] = j; - if (needsort == 0 && i > 0 && j < aval[i-1]) - needsort = i; - } - if (!needsort) - return; - - while (needsort < num) { - for (j = needsort - 1; j >= 0; j--) { - if (aval[j] > aval[j+1]) { - char *hp; - - i = aval[j]; - aval[j] = aval[j+1]; - aval[j+1] = i; - - hp = ap[j]; - ap[j] = ap[j+1]; - ap[j+1] = hp; - - } else - break; - } - needsort++; - } -} -#endif diff --git a/src/kits/network/old/compat/libnet/getnameinfo.c b/src/kits/network/old/compat/libnet/getnameinfo.c deleted file mode 100644 index a082b39fb1..0000000000 --- a/src/kits/network/old/compat/libnet/getnameinfo.c +++ /dev/null @@ -1,358 +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 - * - RFC2553 says that we should raise error on short buffer. X/Open says - * we need to truncate the result. We obey RFC2553 (and X/Open should be - * modified). ipngwg rough consensus seems to follow RFC2553. - * - What is "local" in NI_FQDN? - * - NI_NAMEREQD and NI_NUMERICHOST conflict with each other. - * - (KAME extension) always attach textual scopeid (fe80::1%lo0), if - * sin6_scope_id is filled - standardization status? - * XXX breaks backward compat for code that expects no scopeid. - * beware on merge. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static const 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; -}; - -#ifdef INET6 -static int ip6_parsenumeric (const struct sockaddr *, const char *, char *, - size_t, int); -static int ip6_sa2str (const struct sockaddr_in6 *, char *, size_t, int); -#endif - -int -getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) - const struct sockaddr *sa; - socklen_t salen; - char *host; - size_t hostlen; - char *serv; - size_t servlen; - int flags; -{ - const struct afd *afd; - struct servent *sp; - struct hostent *hp; - u_short port; - int family, i; - const char *addr; - uint32 v4a; - int h_error; - char numserv[512]; - char numaddr[512]; - - if (sa == NULL) - return EAI_FAIL; - - if (sa->sa_len != salen) - return EAI_FAIL; - - family = sa->sa_family; - for (i = 0; afdl[i].a_af; i++) - if (afdl[i].a_af == family) { - afd = &afdl[i]; - goto found; - } - return EAI_FAMILY; - - found: - if (salen != afd->a_socklen) - return EAI_FAIL; - - /* network byte order */ - port = ((const struct sockinet *)sa)->si_port; - addr = (const char *)sa + afd->a_off; - - if (serv == NULL || servlen == 0) { - /* - * do nothing in this case. - * in case you are wondering if "&&" is more correct than - * "||" here: rfc2553bis-03 says that serv == NULL OR - * servlen == 0 means that the caller does not want the result. - */ - } else { - if (flags & NI_NUMERICSERV) - sp = NULL; - else { - sp = getservbyport(port, - (flags & NI_DGRAM) ? "udp" : "tcp"); - } - if (sp) { - if (strlen(sp->s_name) + 1 > servlen) - return EAI_MEMORY; - strcpy(serv, sp->s_name); - } else { - #ifdef _MWERKS_STDIO_H_ - sprintf(numserv, "%d", ntohs(port)); - #else - snprintf(numserv, sizeof(numserv), "%d", ntohs(port)); - #endif - if (strlen(numserv) + 1 > servlen) - return EAI_MEMORY; - strcpy(serv, numserv); - } - } - - switch (sa->sa_family) { - case AF_INET: - v4a = (uint32) - ntohl(((const 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) - flags |= NI_NUMERICHOST; - break; -#ifdef INET6 - case AF_INET6: - { - const struct sockaddr_in6 *sin6; - sin6 = (const struct sockaddr_in6 *)sa; - switch (sin6->sin6_addr.s6_addr[0]) { - case 0x00: - if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) - ; - else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr)) - ; - else - flags |= NI_NUMERICHOST; - break; - default: - if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { - flags |= NI_NUMERICHOST; - } - else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) - flags |= NI_NUMERICHOST; - break; - } - } - break; -#endif - } - if (host == NULL || hostlen == 0) { - /* - * do nothing in this case. - * in case you are wondering if "&&" is more correct than - * "||" here: rfc2553bis-03 says that host == NULL or - * hostlen == 0 means that the caller does not want the result. - */ - } else if (flags & NI_NUMERICHOST) { - int numaddrlen; - - /* NUMERICHOST and NAMEREQD conflicts with each other */ - if (flags & NI_NAMEREQD) - return EAI_NONAME; - - switch(afd->a_af) { -#ifdef INET6 - case AF_INET6: - { - int error; - - if ((error = ip6_parsenumeric(sa, addr, host, - hostlen, flags)) != 0) - return(error); - break; - } -#endif - default: - if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) - == NULL) - return EAI_SYSTEM; - numaddrlen = strlen(numaddr); - if (numaddrlen + 1 > hostlen) /* don't forget terminator */ - return EAI_MEMORY; - strcpy(host, numaddr); - break; - } - } else { - hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af); - h_error = h_errno; - - if (hp) { -#if 0 - /* - * commented out, since "for local host" is not - * implemented here - see RFC2553 p30 - */ - if (flags & NI_NOFQDN) { - char *p; - p = strchr(hp->h_name, '.'); - if (p) - *p = '\0'; - } -#endif - if (strlen(hp->h_name) + 1 > hostlen) { - return EAI_MEMORY; - } - strcpy(host, hp->h_name); - } else { - if (flags & NI_NAMEREQD) - return EAI_NONAME; - switch(afd->a_af) { -#ifdef INET6 - case AF_INET6: - { - int error; - - if ((error = ip6_parsenumeric(sa, addr, host, - hostlen, - flags)) != 0) - return(error); - break; - } -#endif - default: - if (inet_ntop(afd->a_af, addr, host, - hostlen) == NULL) - return EAI_SYSTEM; - break; - } - } - } - return(0); -} - -#ifdef INET6 -static int -ip6_parsenumeric(sa, addr, host, hostlen, flags) - const struct sockaddr *sa; - const char *addr; - char *host; - size_t hostlen; - int flags; -{ - int numaddrlen; - char numaddr[512]; - - if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL) - return EAI_SYSTEM; - - numaddrlen = strlen(numaddr); - if (numaddrlen + 1 > hostlen) /* don't forget terminator */ - return EAI_MEMORY; - strcpy(host, numaddr); - - if (((const struct sockaddr_in6 *)sa)->sin6_scope_id) { - char zonebuf[MAXHOSTNAMELEN]; - int zonelen; - - zonelen = ip6_sa2str( - (const struct sockaddr_in6 *)(const void *)sa, - zonebuf, sizeof(zonebuf), flags); - if (zonelen < 0) - return EAI_MEMORY; - if (zonelen + 1 + numaddrlen + 1 > hostlen) - return EAI_MEMORY; - - /* construct */ - memcpy(host + numaddrlen + 1, zonebuf, - (size_t)zonelen); - host[numaddrlen] = SCOPE_DELIMITER; - host[numaddrlen + 1 + zonelen] = '\0'; - } - - return 0; -} - -/* ARGSUSED */ -static int -ip6_sa2str(sa6, buf, bufsiz, flags) - const struct sockaddr_in6 *sa6; - char *buf; - size_t bufsiz; - int flags; -{ - unsigned int ifindex; - const struct in6_addr *a6; - int n; - - ifindex = (unsigned int)sa6->sin6_scope_id; - a6 = &sa6->sin6_addr; - -#ifdef notdef - if ((flags & NI_NUMERICSCOPE) != 0) { - n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id); - if (n < 0 || n >= bufsiz) - return -1; - else - return n; - } -#endif - - /* if_indextoname() does not take buffer size. not a good api... */ - if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) && - bufsiz >= IF_NAMESIZE) { - char *p = if_indextoname(ifindex, buf); - if (p) { - return(strlen(p)); - } - } - - /* last resort */ - n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id); - if (n < 0 || n >= bufsiz) - return -1; - else - return n; -} -#endif /* INET6 */ diff --git a/src/kits/network/old/compat/libnet/getnetbyaddr.c b/src/kits/network/old/compat/libnet/getnetbyaddr.c deleted file mode 100644 index 6430206640..0000000000 --- a/src/kits/network/old/compat/libnet/getnetbyaddr.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -extern int _net_stayopen; - -struct netent * -_getnetbyaddr(net, type) - register in_addr_t net; - register int type; -{ - register struct netent *p; - - setnetent(_net_stayopen); - while ((p = getnetent())) - if (p->n_addrtype == type && p->n_net == net) - break; - if (!_net_stayopen) - endnetent(); - return (p); -} diff --git a/src/kits/network/old/compat/libnet/getnetbyname.c b/src/kits/network/old/compat/libnet/getnetbyname.c deleted file mode 100644 index 7cfd6c639c..0000000000 --- a/src/kits/network/old/compat/libnet/getnetbyname.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include - -extern int _net_stayopen; - -struct netent * -_getnetbyname(name) - register const char *name; -{ - register struct netent *p; - register char **cp; - - setnetent(_net_stayopen); - while ((p = getnetent())) { - if (strcasecmp(p->n_name, name) == 0) - break; - for (cp = p->n_aliases; *cp != 0; cp++) - if (strcasecmp(*cp, name) == 0) - goto found; - } -found: - if (!_net_stayopen) - endnetent(); - return (p); -} diff --git a/src/kits/network/old/compat/libnet/getnetent.c b/src/kits/network/old/compat/libnet/getnetent.c deleted file mode 100644 index c43a4703ba..0000000000 --- a/src/kits/network/old/compat/libnet/getnetent.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAXALIASES 35 - -static FILE *netf; -static char line[BUFSIZ+1]; -static struct netent net; -static char *net_aliases[MAXALIASES]; -int _net_stayopen; - -void -setnetent(f) - int f; -{ - if (netf == NULL) - netf = fopen(_PATH_NETWORKS, "r" ); - else - rewind(netf); - _net_stayopen |= f; -} - -void -endnetent() -{ - if (netf) { - fclose(netf); - netf = NULL; - } - _net_stayopen = 0; -} - -struct netent * -getnetent() -{ - char *p, *cp, **q; - size_t len; - char buf[80]; - - if (netf == NULL && (netf = fopen(_PATH_NETWORKS, "r" )) == NULL) - return (NULL); -again: - if (fgets(buf, 80, netf) == NULL) - return NULL; - len = strlen(buf); - p = &buf[len]; -// if ((p = fgetln(netf, &len)) == NULL) -// return (NULL); - if (p[len-1] == '\n') - len--; - if (len >= sizeof(line) || len == 0) - goto again; - p = memcpy(line, p, len); - line[len] = '\0'; - if (*p == '#') - goto again; - if ((cp = strchr(p, '#')) != NULL) - *cp = '\0'; - net.n_name = p; - if (strlen(net.n_name) >= MAXHOSTNAMELEN-1) - net.n_name[MAXHOSTNAMELEN-1] = '\0'; - cp = strpbrk(p, " \t"); - if (cp == NULL) - goto again; - *cp++ = '\0'; - while (*cp == ' ' || *cp == '\t') - cp++; - p = strpbrk(cp, " \t"); - if (p != NULL) - *p++ = '\0'; - net.n_net = inet_network(cp); - net.n_addrtype = AF_INET; - q = net.n_aliases = net_aliases; - if (p != NULL) - cp = p; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &net_aliases[MAXALIASES - 1]) { - *q++ = cp; - if (strlen(cp) >= MAXHOSTNAMELEN-1) - cp[MAXHOSTNAMELEN-1] = '\0'; - } - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - *q = NULL; - return (&net); -} diff --git a/src/kits/network/old/compat/libnet/getnetnamadr.c b/src/kits/network/old/compat/libnet/getnetnamadr.c deleted file mode 100644 index eedadf8f15..0000000000 --- a/src/kits/network/old/compat/libnet/getnetnamadr.c +++ /dev/null @@ -1,391 +0,0 @@ -/* - * Copyright (c) 1997, Jason Downs. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Jason Downs for the - * OpenBSD system. - * 4. Neither the name(s) of the author(s) nor the name OpenBSD - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -/* Copyright (c) 1993 Carlos Leandro and Rui Salgueiro - * Dep. Matematica Universidade de Coimbra, Portugal, Europe - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -struct netent *_getnetbyaddr (in_addr_t net, int type); -struct netent *_getnetbyname (const char *name); - -int _hokchar (const char *); - -#define BYADDR 0 -#define BYNAME 1 -#define MAXALIASES 35 - -#if PACKETSZ > 1024 -#define MAXPACKET PACKETSZ -#else -#define MAXPACKET 1024 -#endif - -typedef union { - HEADER hdr; - u_char buf[MAXPACKET]; -} querybuf; - -typedef union { - long al; - char ac; -} align; - -static struct netent * -getnetanswer(answer, anslen, net_i) - querybuf *answer; - int anslen; - int net_i; -{ - - register HEADER *hp; - register u_char *cp; - register int n; - u_char *eom; - int type, class, buflen, ancount, qdcount, haveanswer, i, nchar; - char aux1[MAXHOSTNAMELEN], aux2[MAXHOSTNAMELEN], ans[MAXHOSTNAMELEN]; - char *in, *st, *pauxt, *bp, **ap; - char *paux1 = &aux1[0], *paux2 = &aux2[0], flag = 0; - static struct netent net_entry; - static char *net_aliases[MAXALIASES], netbuf[BUFSIZ+1]; - - /* - * find first satisfactory answer - * - * answer --> +------------+ ( MESSAGE ) - * | Header | - * +------------+ - * | Question | the question for the name server - * +------------+ - * | Answer | RRs answering the question - * +------------+ - * | Authority | RRs pointing toward an authority - * | Additional | RRs holding additional information - * +------------+ - */ - eom = answer->buf + anslen; - hp = &answer->hdr; - ancount = ntohs(hp->ancount); /* #/records in the answer section */ - qdcount = ntohs(hp->qdcount); /* #/entries in the question section */ - bp = netbuf; - buflen = sizeof(netbuf); - cp = answer->buf + HFIXEDSZ; - if (!qdcount) { - if (hp->aa) - h_errno = HOST_NOT_FOUND; - else - h_errno = TRY_AGAIN; - return (NULL); - } - while (qdcount-- > 0) - cp += __dn_skipname(cp, eom) + QFIXEDSZ; - ap = net_aliases; - *ap = NULL; - net_entry.n_aliases = net_aliases; - haveanswer = 0; - while (--ancount >= 0 && cp < eom) { - n = dn_expand(answer->buf, eom, cp, bp, buflen); -#ifdef USE_RESOLV_NAME_OK - if ((n < 0) || !res_dnok(bp)) -#else - if ((n < 0) || !_hokchar(bp)) -#endif - break; - cp += n; - ans[0] = '\0'; - strncpy(&ans[0], bp, sizeof ans); - GETSHORT(type, cp); - GETSHORT(class, cp); - cp += INT32SZ; /* TTL */ - GETSHORT(n, cp); - if (class == C_IN && type == T_PTR) { - n = dn_expand(answer->buf, eom, cp, bp, buflen); -#ifdef USE_RESOLV_NAME_OK - if ((n < 0) || !res_hnok(bp)) { -#else - if ((n < 0) || !_hokchar(bp)) { -#endif - cp += n; - return (NULL); - } - cp += n; - *ap++ = bp; - bp += strlen(bp) + 1; - net_entry.n_addrtype = - (class == C_IN) ? AF_INET : AF_UNSPEC; - haveanswer++; - } - } - if (haveanswer) { - *ap = NULL; - switch (net_i) { - case BYADDR: - net_entry.n_name = *net_entry.n_aliases; - net_entry.n_net = 0L; - break; - case BYNAME: - in = *net_entry.n_aliases; - net_entry.n_name = &ans[0]; - aux2[0] = '\0'; - for (i = 0; i < 4; i++) { - for (st = in, nchar = 0; - *st != '.'; - st++, nchar++) - ; - if (nchar != 1 || *in != '0' || flag) { - flag = 1; - strncpy(paux1, - (i==0) ? in : in-1, - (i==0) ? nchar+1 : nchar+2); - pauxt = paux2; - paux2 = strcat(paux1, paux2); - paux1 = pauxt; - } - in = ++st; - } - net_entry.n_net = inet_network(paux2); - break; - } - net_entry.n_aliases++; - return (&net_entry); - } - h_errno = TRY_AGAIN; - return (NULL); -} - -struct netent * -getnetbyaddr(net, net_type) - register in_addr_t net; - register int net_type; -{ - unsigned int netbr[4]; - int nn, anslen; - querybuf buf; - char qbuf[MAXDNAME]; - in_addr_t net2; - struct netent *net_entry = NULL; - char lookups[MAXDNSLUS]; - int i; - - if ((_res.options & RES_INIT) == 0 && res_init() == -1) - return(_getnetbyaddr(net, net_type)); - - memcpy(lookups, _res.lookups, sizeof lookups); - if (lookups[0] == '\0') - strncpy(lookups, "bf", sizeof lookups); - - for (i = 0; i < MAXDNSLUS && lookups[i]; i++) { - switch (lookups[i]) { -#ifdef YP - case 'y': - /* There is no YP support. */ - break; -#endif /* YP */ - case 'b': - if (net_type != AF_INET) - break; /* DNS only supports AF_INET? */ - - for (nn = 4, net2 = net; net2; net2 >>= 8) - netbr[--nn] = net2 & 0xff; - switch (nn) { - #ifndef _MWERKS_STDIO_H_ - case 3: /* Class A */ - snprintf(qbuf, sizeof(qbuf), - "0.0.0.%u.in-addr.arpa", netbr[3]); - break; - case 2: /* Class B */ - snprintf(qbuf, sizeof(qbuf), - "0.0.%u.%u.in-addr.arpa", - netbr[3], netbr[2]); - break; - case 1: /* Class C */ - snprintf(qbuf, sizeof(qbuf), - "0.%u.%u.%u.in-addr.arpa", - netbr[3], netbr[2], netbr[1]); - break; - case 0: /* Class D - E */ - snprintf(qbuf, sizeof(qbuf), - "%u.%u.%u.%u.in-addr.arpa", - netbr[3], netbr[2], netbr[1], netbr[0]); - break; - #else - case 3: /* Class A */ - sprintf(qbuf, - "0.0.0.%u.in-addr.arpa", netbr[3]); - break; - case 2: /* Class B */ - sprintf(qbuf, - "0.0.%u.%u.in-addr.arpa", - netbr[3], netbr[2]); - break; - case 1: /* Class C */ - sprintf(qbuf, - "0.%u.%u.%u.in-addr.arpa", - netbr[3], netbr[2], netbr[1]); - break; - case 0: /* Class D - E */ - sprintf(qbuf, - "%u.%u.%u.%u.in-addr.arpa", - netbr[3], netbr[2], netbr[1], netbr[0]); - break; - #endif - } - anslen = res_query(qbuf, C_IN, T_PTR, (u_char *)&buf, - sizeof(buf)); - if (anslen < 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf("res_query failed\n"); -#endif - break; - } - net_entry = getnetanswer(&buf, anslen, BYADDR); - if (net_entry != NULL) { - unsigned u_net = net; /* maybe net should be unsigned ? */ - - /* Strip trailing zeros */ - while ((u_net & 0xff) == 0 && u_net != 0) - u_net >>= 8; - net_entry->n_net = u_net; - return (net_entry); - } - break; - case 'f': - net_entry = _getnetbyaddr(net, net_type); - if (net_entry != NULL) - return (net_entry); - } - } - - /* Nothing matched. */ - return (NULL); -} - -struct netent * -getnetbyname(net) - register const char *net; -{ - int anslen; - querybuf buf; - char qbuf[MAXDNAME]; - struct netent *net_entry = NULL; - char lookups[MAXDNSLUS]; - int i; - - if ((_res.options & RES_INIT) == 0 && res_init() == -1) - return (_getnetbyname(net)); - - memcpy(lookups, _res.lookups, sizeof lookups); - if (lookups[0] == '\0') - strncpy(lookups, "bf", sizeof lookups); - - for (i = 0; i < MAXDNSLUS && lookups[i]; i++) { - switch (lookups[i]) { -#ifdef YP - case 'y': - /* There is no YP support. */ - break; -#endif /* YP */ - case 'b': - strncpy(qbuf, net, sizeof qbuf); - anslen = res_search(qbuf, C_IN, T_PTR, (u_char *)&buf, - sizeof(buf)); - if (anslen < 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf("res_query failed\n"); -#endif - break; - } - net_entry = getnetanswer(&buf, anslen, BYNAME); - if (net_entry != NULL) - return (net_entry); - break; - case 'f': - net_entry = _getnetbyname(net); - if (net_entry != NULL) - return (net_entry); - break; - } - } - - /* Nothing matched. */ - return (NULL); -} diff --git a/src/kits/network/old/compat/libnet/getproto.c b/src/kits/network/old/compat/libnet/getproto.c deleted file mode 100644 index cdda598dc0..0000000000 --- a/src/kits/network/old/compat/libnet/getproto.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include - -extern int _proto_stayopen; - -struct protoent *getprotobynumber(int proto) -{ - struct protoent *p; - - setprotoent(_proto_stayopen); - while ((p = getprotoent())) - if (p->p_proto == proto) - break; - if (!_proto_stayopen) - endprotoent(); - return (p); -} diff --git a/src/kits/network/old/compat/libnet/getprotoent.c b/src/kits/network/old/compat/libnet/getprotoent.c deleted file mode 100644 index ede7f23622..0000000000 --- a/src/kits/network/old/compat/libnet/getprotoent.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include - -#define MAXALIASES 35 - -static FILE *protof = NULL; -static char line[BUFSIZ+1]; -static struct protoent proto; -static char *proto_aliases[MAXALIASES]; -int _proto_stayopen; - -void setprotoent(int f) -{ - if (protof == NULL) - protof = fopen(_PATH_PROTOCOLS, "r" ); - else - rewind(protof); - _proto_stayopen |= f; -} - -void endprotoent() -{ - if (protof) { - fclose(protof); - protof = NULL; - } - _proto_stayopen = 0; -} - -struct protoent *getprotoent() -{ - char *p, *cp, **q, *endp; - long l; - size_t len; - char buf[80]; - - if (protof == NULL && (protof = fopen(_PATH_PROTOCOLS, "r" )) == NULL) - return (NULL); -again: - if (fgets(buf, 80, protof) == NULL) - return NULL; - len = strlen(buf); - p = buf; - -// if ((p = fgetln(protof, &len)) == NULL) -// return (NULL); - if (p[len-1] == '\n') - len--; - if (len >= sizeof(line) || len == 0) - goto again; - p = memcpy(line, p, len); - line[len] = '\0'; - if (*p == '#') - goto again; - if ((cp = strchr(p, '#')) != NULL) - *cp = '\0'; - proto.p_name = p; - cp = strpbrk(p, " \t"); - if (cp == NULL) - goto again; - *cp++ = '\0'; - while (*cp == ' ' || *cp == '\t') - cp++; - p = strpbrk(cp, " \t"); - if (p != NULL) - *p++ = '\0'; - l = strtol(cp, &endp, 10); - if (endp == cp || *endp != '\0' || l < 0 || l >= INT_MAX) - goto again; - proto.p_proto = l; - q = proto.p_aliases = proto_aliases; - if (p != NULL) { - cp = p; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &proto_aliases[MAXALIASES - 1]) - *q++ = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - } - *q = NULL; - return (&proto); -} diff --git a/src/kits/network/old/compat/libnet/getprotoname.c b/src/kits/network/old/compat/libnet/getprotoname.c deleted file mode 100644 index cb1a68be09..0000000000 --- a/src/kits/network/old/compat/libnet/getprotoname.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -extern int _proto_stayopen; - - -struct protoent *getprotobyname(const char *name) -{ - struct protoent *p; - char **cp; - - setprotoent(_proto_stayopen); - while ((p = getprotoent())) { - if (strcmp(p->p_name, name) == 0) - break; - for (cp = p->p_aliases; *cp != 0; cp++) - if (strcmp(*cp, name) == 0) - goto found; - } -found: - if (!_proto_stayopen) - endprotoent(); - return (p); -} diff --git a/src/kits/network/old/compat/libnet/getservbyname.c b/src/kits/network/old/compat/libnet/getservbyname.c deleted file mode 100644 index 400263a4e3..0000000000 --- a/src/kits/network/old/compat/libnet/getservbyname.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - -#include -#include -#include - -extern int _serv_stayopen; -struct servent *getservent(); - -struct servent * -getservbyname_r(name, proto, se, buf, buflen) - const char *name, *proto; - struct servent *se; - char *buf; - int buflen; -{ - register struct servent *p; - register char **cp; - - setservent(_serv_stayopen); - while ((p = getservent())) { - if (strcmp(name, p->s_name) == 0) - goto gotname; - for (cp = p->s_aliases; *cp; cp++) - if (strcmp(name, *cp) == 0) - goto gotname; - continue; -gotname: - if (proto == 0 || strcmp(p->s_proto, proto) == 0) - break; - } - if (!_serv_stayopen) - endservent(); - - return (p); -} - -struct servent *getservbyname(name, proto) - const char *name, *proto; -{ - static char buf[4096]; - char *bufp = (char*)&buf; - - if (bufp == NULL) - return (NULL); - return getservbyname_r(name, proto, (struct servent*) bufp, - bufp + sizeof(struct servent), - sizeof buf - sizeof(struct servent) ); -} diff --git a/src/kits/network/old/compat/libnet/getservbyport.c b/src/kits/network/old/compat/libnet/getservbyport.c deleted file mode 100644 index e17dd77f82..0000000000 --- a/src/kits/network/old/compat/libnet/getservbyport.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -extern int _serv_stayopen; -struct servent *getservent(); - -struct servent * -getservbyport(port, proto) - int port; - const char *proto; -{ - register struct servent *p; - - setservent(_serv_stayopen); - while ((p = getservent())) { - if (p->s_port != port) - continue; - if (proto == 0 || strcmp(p->s_proto, proto) == 0) - break; - } - if (!_serv_stayopen) - endservent(); - return (p); -} diff --git a/src/kits/network/old/compat/libnet/getservent.c b/src/kits/network/old/compat/libnet/getservent.c deleted file mode 100644 index 088d47c767..0000000000 --- a/src/kits/network/old/compat/libnet/getservent.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAXALIASES 35 - -static FILE *servf = NULL; -static char line[BUFSIZ+1]; -static struct servent serv; -static char *serv_aliases[MAXALIASES]; -int _serv_stayopen; - -void -setservent(f) - int f; -{ - if (servf == NULL) - servf = fopen(_PATH_SERVICES, "r" ); - else - rewind(servf); - _serv_stayopen |= f; -} - -void -endservent() -{ - if (servf) { - fclose(servf); - servf = NULL; - } - _serv_stayopen = 0; -} - -struct servent * -getservent() -{ - char *p, *cp, **q, *endp; - long l; - size_t len; - char buf[80]; - - if (servf == NULL && (servf = fopen(_PATH_SERVICES, "r" )) == NULL) - return (NULL); -again: - if (fgets(buf, 80, servf) == NULL) - return NULL; - len = strlen(buf); - p = buf; - -// if ((p = fgetln(servf, &len)) == NULL) -// return (NULL); - if (p[len-1] == '\n') - len--; - if (len >= sizeof(line) || len == 0) - goto again; - p = memcpy(line, p, len); - line[len] = '\0'; - if (*p == '#') - goto again; - if ((cp = strchr(p, '#')) != NULL) - *cp = '\0'; - serv.s_name = p; - p = strpbrk(p, " \t"); - if (p == NULL) - goto again; - *p++ = '\0'; - while (*p == ' ' || *p == '\t') - p++; - cp = strpbrk(p, ",/"); - if (cp == NULL) - goto again; - *cp++ = '\0'; - l = strtol(p, &endp, 10); - if (endp == p || *endp != '\0' || l < 0 || l > USHRT_MAX) - goto again; - serv.s_port = htons((in_port_t)l); - serv.s_proto = cp; - q = serv.s_aliases = serv_aliases; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &serv_aliases[MAXALIASES - 1]) - *q++ = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - *q = NULL; - return (&serv); -} diff --git a/src/kits/network/old/compat/libnet/headers/arpa/inet.h b/src/kits/network/old/compat/libnet/headers/arpa/inet.h deleted file mode 100644 index 034582ab8e..0000000000 --- a/src/kits/network/old/compat/libnet/headers/arpa/inet.h +++ /dev/null @@ -1,57 +0,0 @@ -/* arpa/inet.h */ - -/* public definitions of inet functions... */ - -#ifndef _INET_H_ -#define _INET_H_ - -#include -#include -#include - - -/* R5 libnet function names conflict with libbind. BONE uses a prefix to solve this. */ -#ifndef BUILDING_R5_LIBNET - -#define inet_addr __inet_addr -#define inet_aton __inet_aton -#define inet_lnaof __inet_lnaof -#define inet_makeaddr __inet_makeaddr -#define inet_neta __inet_neta -#define inet_netof __inet_netof -#define inet_network __inet_network -#define inet_net_ntop __inet_net_ntop -#define inet_net_pton __inet_net_pton -#define inet_ntoa __inet_ntoa -#define inet_pton __inet_pton -#define inet_ntop __inet_ntop -#define inet_nsap_addr __inet_nsap_addr -#define inet_nsap_ntoa __inet_nsap_ntoa - -#endif /* BUILDING_R5_LIBNET */ - - -#ifdef __cplusplus -extern "C" { -#endif - -in_addr_t inet_addr (const char *); -int inet_aton (const char *, struct in_addr *); -in_addr_t inet_lnaof (struct in_addr); -struct in_addr inet_makeaddr (in_addr_t , in_addr_t); -char * inet_neta (in_addr_t, char *, size_t); -in_addr_t inet_netof (struct in_addr); -in_addr_t inet_network (const char *); -char *inet_net_ntop (int, const void *, int, char *, size_t); -int inet_net_pton (int, const char *, void *, size_t); -char *inet_ntoa (struct in_addr); -int inet_pton (int, const char *, void *); -const char *inet_ntop (int, const void *, char *, size_t); -u_int inet_nsap_addr (const char *, u_char *, int); -char *inet_nsap_ntoa (int, const u_char *, char *); - -#ifdef __cplusplus -} -#endif - -#endif /* _INET_H */ diff --git a/src/kits/network/old/compat/libnet/headers/arpa/nameser.h b/src/kits/network/old/compat/libnet/headers/arpa/nameser.h deleted file mode 100644 index 35406d0fc1..0000000000 --- a/src/kits/network/old/compat/libnet/headers/arpa/nameser.h +++ /dev/null @@ -1,370 +0,0 @@ -/* $OpenBSD: nameser.h,v 1.6 2001/07/31 22:02:18 jakob Exp $ */ - -/* - * ++Copyright++ 1983, 1989, 1993 - * - - * Copyright (c) 1983, 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - - * Portions Copyright (c) 1995 by International Business Machines, Inc. - * - * International Business Machines, Inc. (hereinafter called IBM) grants - * permission under its copyrights to use, copy, modify, and distribute this - * Software with or without fee, provided that the above copyright notice and - * all paragraphs of this notice appear in all copies, and that the name of IBM - * not be used in connection with the marketing of any product incorporating - * the Software or modifications thereof, without specific, written prior - * permission. - * - * To the extent it has a right to do so, IBM grants an immunity from suit - * under its patents, if any, for the use, sale or manufacture of products to - * the extent that such products are used for performing Domain Name System - * dynamic updates in TCP/IP networks by means of the Software. No immunity is - * granted for any product per se or for any other function of any product. - * - * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, - * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN - * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. - * --Copyright-- - */ - -/* - * @(#)nameser.h 8.1 (Berkeley) 6/2/93 - * $From: nameser.h,v 8.11 1996/10/08 04:51:02 vixie Exp $ - */ - -#ifndef _NAMESER_H_ -#define _NAMESER_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * revision information. this is the release date in YYYYMMDD format. - * it can change every day so the right thing to do with it is use it - * in preprocessor commands such as "#if (__BIND > 19931104)". do not - * compare for equality; rather, use it to determine whether your resolver - * is new enough to contain a certain feature. - */ - -#define __BIND 19960801 /* interface version stamp */ - -/* - * Define constants based on rfc883 - */ -#define PACKETSZ 512 /* maximum packet size */ -#define MAXDNAME 1025 /* maximum presentation domain name */ -#define MAXCDNAME 255 /* maximum compressed domain name */ -#define MAXLABEL 63 /* maximum length of domain label */ -#define HFIXEDSZ 12 /* #/bytes of fixed data in header */ -#define QFIXEDSZ 4 /* #/bytes of fixed data in query */ -#define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */ -#define INT32SZ 4 /* for systems without 32-bit ints */ -#define INT16SZ 2 /* for systems without 16-bit ints */ -#define INADDRSZ 4 /* IPv4 T_A */ -#define IN6ADDRSZ 16 /* IPv6 T_AAAA */ - -/* - * Internet nameserver port number - */ -#define NAMESERVER_PORT 53 - -/* - * Currently defined opcodes - */ -#define QUERY 0x0 /* standard query */ -#define IQUERY 0x1 /* inverse query */ -#define STATUS 0x2 /* nameserver status query */ -/*#define xxx 0x3*/ /* 0x3 reserved */ -#define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */ -/* - * Currently defined response codes - */ -#define NOERROR 0 /* no error */ -#define FORMERR 1 /* format error */ -#define SERVFAIL 2 /* server failure */ -#define NXDOMAIN 3 /* non existent domain */ -#define NOTIMP 4 /* not implemented */ -#define REFUSED 5 /* query refused */ - -/* - * Type values for resources and queries - */ -#define T_A 1 /* host address */ -#define T_NS 2 /* authoritative server */ -#define T_MD 3 /* mail destination */ -#define T_MF 4 /* mail forwarder */ -#define T_CNAME 5 /* canonical name */ -#define T_SOA 6 /* start of authority zone */ -#define T_MB 7 /* mailbox domain name */ -#define T_MG 8 /* mail group member */ -#define T_MR 9 /* mail rename name */ -#define T_NULL 10 /* null resource record */ -#define T_WKS 11 /* well known service */ -#define T_PTR 12 /* domain name pointer */ -#define T_HINFO 13 /* host information */ -#define T_MINFO 14 /* mailbox information */ -#define T_MX 15 /* mail routing information */ -#define T_TXT 16 /* text strings */ -#define T_RP 17 /* responsible person */ -#define T_AFSDB 18 /* AFS cell database */ -#define T_X25 19 /* X_25 calling address */ -#define T_ISDN 20 /* ISDN calling address */ -#define T_RT 21 /* router */ -#define T_NSAP 22 /* NSAP address */ -#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */ -#define T_SIG 24 /* security signature */ -#define T_KEY 25 /* security key */ -#define T_PX 26 /* X.400 mail mapping */ -#define T_GPOS 27 /* geographical position (withdrawn) */ -#define T_AAAA 28 /* IP6 Address */ -#define T_LOC 29 /* Location Information */ -#define T_NXT 30 /* Next Valid Name in Zone */ -#define T_EID 31 /* Endpoint identifier */ -#define T_NIMLOC 32 /* Nimrod locator */ -#define T_SRV 33 /* Server selection */ -#define T_ATMA 34 /* ATM Address */ -#define T_NAPTR 35 /* Naming Authority PoinTeR */ -#define T_OPT 41 /* OPT pseudo-RR, RFC2671 */ - /* non standard */ -#define T_UINFO 100 /* user (finger) information */ -#define T_UID 101 /* user ID */ -#define T_GID 102 /* group ID */ -#define T_UNSPEC 103 /* Unspecified format (binary data) */ - /* Query type values which do not appear in resource records */ -#define T_IXFR 251 /* incremental zone transfer */ -#define T_AXFR 252 /* transfer zone of authority */ -#define T_MAILB 253 /* transfer mailbox records */ -#define T_MAILA 254 /* transfer mail agent records */ -#define T_ANY 255 /* wildcard match */ - -/* - * Values for class field - */ - -#define C_IN 1 /* the arpa internet */ -#define C_CHAOS 3 /* for chaos net (MIT) */ -#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */ - /* Query class values which do not appear in resource records */ -#define C_ANY 255 /* wildcard match */ - -/* - * Flags field of the KEY RR rdata - */ -#define KEYFLAG_TYPEMASK 0xC000 /* Mask for "type" bits */ -#define KEYFLAG_TYPE_AUTH_CONF 0x0000 /* Key usable for both */ -#define KEYFLAG_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */ -#define KEYFLAG_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */ -#define KEYFLAG_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */ -/* The type bits can also be interpreted independently, as single bits: */ -#define KEYFLAG_NO_AUTH 0x8000 /* Key not usable for authentication */ -#define KEYFLAG_NO_CONF 0x4000 /* Key not usable for confidentiality */ - -#define KEYFLAG_EXPERIMENTAL 0x2000 /* Security is *mandatory* if bit=0 */ -#define KEYFLAG_RESERVED3 0x1000 /* reserved - must be zero */ -#define KEYFLAG_RESERVED4 0x0800 /* reserved - must be zero */ -#define KEYFLAG_USERACCOUNT 0x0400 /* key is assoc. with a user acct */ -#define KEYFLAG_ENTITY 0x0200 /* key is assoc. with entity eg host */ -#define KEYFLAG_ZONEKEY 0x0100 /* key is zone key for the zone named */ -#define KEYFLAG_IPSEC 0x0080 /* key is for IPSEC use (host or user)*/ -#define KEYFLAG_EMAIL 0x0040 /* key is for email (MIME security) */ -#define KEYFLAG_RESERVED10 0x0020 /* reserved - must be zero */ -#define KEYFLAG_RESERVED11 0x0010 /* reserved - must be zero */ -#define KEYFLAG_SIGNATORYMASK 0x000F /* key can sign DNS RR's of same name */ - -#define KEYFLAG_RESERVED_BITMASK ( KEYFLAG_RESERVED3 | \ - KEYFLAG_RESERVED4 | \ - KEYFLAG_RESERVED10| KEYFLAG_RESERVED11) - -/* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */ -#define ALGORITHM_MD5RSA 1 /* MD5 with RSA */ -#define ALGORITHM_EXPIRE_ONLY 253 /* No alg, no security */ -#define ALGORITHM_PRIVATE_OID 254 /* Key begins with OID indicating alg */ - -/* Signatures */ - /* Size of a mod or exp in bits */ -#define MIN_MD5RSA_KEY_PART_BITS 512 -#define MAX_MD5RSA_KEY_PART_BITS 2552 - /* Total of binary mod and exp, bytes */ -#define MAX_MD5RSA_KEY_BYTES ((MAX_MD5RSA_KEY_PART_BITS+7/8)*2+3) - /* Max length of text sig block */ -#define MAX_KEY_BASE64 (((MAX_MD5RSA_KEY_BYTES+2)/3)*4) - -/* - * EDNS0 Z-field extended flags - */ -#define DNS_MESSAGEEXTFLAG_DO 0x8000U - -/* - * Status return codes for T_UNSPEC conversion routines - */ -#define CONV_SUCCESS 0 -#define CONV_OVERFLOW (-1) -#define CONV_BADFMT (-2) -#define CONV_BADCKSUM (-3) -#define CONV_BADBUFLEN (-4) - -#if !defined(BYTE_ORDER) || \ - (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \ - BYTE_ORDER != PDP_ENDIAN) - /* you must determine what the correct bit order is for - * your compiler - the next line is an intentional error - * which will force your compiles to bomb until you fix - * the above macros. - */ - error "Undefined or invalid BYTE_ORDER"; -#endif - -/* - * Structure for query header. The order of the fields is machine- and - * compiler-dependent, depending on the byte/bit order and the layout - * of bit fields. We use bit fields only in int variables, as this - * is all ANSI requires. This requires a somewhat confusing rearrangement. - */ - -typedef struct { - unsigned id :16; /* query identification number */ -#if BYTE_ORDER == BIG_ENDIAN - /* fields in third byte */ - unsigned qr: 1; /* response flag */ - unsigned opcode: 4; /* purpose of message */ - unsigned aa: 1; /* authoritive answer */ - unsigned tc: 1; /* truncated message */ - unsigned rd: 1; /* recursion desired */ - /* fields in fourth byte */ - unsigned ra: 1; /* recursion available */ - unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ - unsigned ad: 1; /* authentic data from named */ - unsigned cd: 1; /* checking disabled by resolver */ - unsigned rcode :4; /* response code */ -#endif -#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN - /* fields in third byte */ - unsigned rd :1; /* recursion desired */ - unsigned tc :1; /* truncated message */ - unsigned aa :1; /* authoritive answer */ - unsigned opcode :4; /* purpose of message */ - unsigned qr :1; /* response flag */ - /* fields in fourth byte */ - unsigned rcode :4; /* response code */ - unsigned cd: 1; /* checking disabled by resolver */ - unsigned ad: 1; /* authentic data from named */ - unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ - unsigned ra :1; /* recursion available */ -#endif - /* remaining bytes */ - unsigned qdcount :16; /* number of question entries */ - unsigned ancount :16; /* number of answer entries */ - unsigned nscount :16; /* number of authority entries */ - unsigned arcount :16; /* number of resource entries */ -} HEADER; - -/* - * Defines for handling compressed domain names - */ -#define INDIR_MASK 0xc0 - -extern uint16 _getshort (const u_char *); -extern uint32 _getlong (const u_char *); - -/* - * Inline versions of get/put short/long. Pointer is advanced. - * - * These macros demonstrate the property of C whereby it can be - * portable or it can be elegant but rarely both. - */ -#define GETSHORT(s, cp) { \ - register u_char *t_cp = (u_char *)(cp); \ - (s) = ((uint16)t_cp[0] << 8) \ - | ((uint16)t_cp[1]) \ - ; \ - (cp) += INT16SZ; \ -} - -#define GETLONG(l, cp) { \ - register u_char *t_cp = (u_char *)(cp); \ - (l) = ((uint32)t_cp[0] << 24) \ - | ((uint32)t_cp[1] << 16) \ - | ((uint32)t_cp[2] << 8) \ - | ((uint32)t_cp[3]) \ - ; \ - (cp) += INT32SZ; \ -} - -#define PUTSHORT(s, cp) { \ - register uint16 t_s = (uint16)(s); \ - register u_char *t_cp = (u_char *)(cp); \ - *t_cp++ = t_s >> 8; \ - *t_cp = t_s; \ - (cp) += INT16SZ; \ -} - -#define PUTLONG(l, cp) { \ - register uint32 t_l = (uint32)(l); \ - register u_char *t_cp = (u_char *)(cp); \ - *t_cp++ = t_l >> 24; \ - *t_cp++ = t_l >> 16; \ - *t_cp++ = t_l >> 8; \ - *t_cp = t_l; \ - (cp) += INT32SZ; \ -} - -#ifdef __cplusplus -} -#endif - -#endif /* !_NAMESER_H_ */ diff --git a/src/kits/network/old/compat/libnet/headers/netdb.h b/src/kits/network/old/compat/libnet/headers/netdb.h deleted file mode 100644 index 0925cc54d8..0000000000 --- a/src/kits/network/old/compat/libnet/headers/netdb.h +++ /dev/null @@ -1,185 +0,0 @@ -/* netdb.h */ - -#ifndef NETDB_H -#define NETDB_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 64 -#endif - -#define HOST_NOT_FOUND 1 -#define TRY_AGAIN 2 -#define NO_RECOVERY 3 -#define NO_DATA 4 - -// Make h_errno thread-safe -extern int *_h_errnop(void); -#define h_errno (*(_h_errnop())) - -struct hostent { - char *h_name; - char **h_aliases; - int h_addrtype; - int h_length; - char **h_addr_list; -}; -#define h_addr h_addr_list[0] - -struct servent { - char *s_name; - char **s_aliases; - int s_port; - char *s_proto; -}; - -/* - * Assumption here is that a network number - * fits in an in_addr_t -- probably a poor one. - */ -struct netent { - char *n_name; /* official name of net */ - char **n_aliases; /* alias list */ - int n_addrtype; /* net address type */ - in_addr_t n_net; /* network # */ -}; - -struct protoent { - char *p_name; /* official protocol name */ - char **p_aliases; /* alias list */ - int p_proto; /* protocol # */ -}; - -struct addrinfo { - int ai_flags; /* input flags */ - int ai_family; /* protocol family for socket */ - int ai_socktype; /* socket type */ - int ai_protocol; /* protocol for socket */ - socklen_t ai_addrlen; /* length of socket-address */ - struct sockaddr *ai_addr; /* socket-address for socket */ - char *ai_canonname; /* canonical name for service location (iff req) */ - struct addrinfo *ai_next; /* pointer to next in list */ -}; - - -struct hostent *gethostbyname(const char *hostname); -struct hostent *gethostbyaddr(const char *hostname, int len, int type); -struct servent *getservbyname(const char *name, const char *proto); -void herror(const char *); -unsigned long inet_addr(const char *a_addr); -char *inet_ntoa(struct in_addr addr); - -int gethostname(char *hostname, size_t hostlen); - -/* BE specific, because of lack of UNIX passwd functions */ -int getusername(char *username, size_t userlen); -int getpassword(char *password, size_t passlen); - - -/* These are new! */ -struct netent *getnetbyaddr (in_addr_t, int); -struct netent *getnetbyname (const char *); -struct netent *getnetent (void); -struct protoent *getprotoent (void); -struct protoent *getprotobyname (const char *); -struct protoent *getprotobynumber (int); -struct hostent *gethostbyname2 (const char *, int); -struct servent *getservbyport (int, const char *); - -int getaddrinfo (const char *, const char *, - const struct addrinfo *, - struct addrinfo **); -void freeaddrinfo (struct addrinfo *); -int getnameinfo (const struct sockaddr *, socklen_t, - char *, size_t, char *, size_t, - int); - -void sethostent (int); -void setnetent (int); -void setprotoent (int); -void setservent (int); - -void endhostent (void); -void endnetent (void); -void endprotoent (void); -void endservent (void); - -#define _PATH_HEQUIV "/etc/hosts.equiv" -#define _PATH_HOSTS "/etc/hosts" -#define _PATH_NETWORKS "/etc/networks" -#define _PATH_PROTOCOLS "/etc/protocols" -#define _PATH_SERVICES "/etc/services" - -/* - * Error return codes from gethostbyname() and gethostbyaddr() - * (left in extern int h_errno). - */ - -#define NETDB_INTERNAL -1 /* see errno */ -#define NETDB_SUCCESS 0 /* no problem */ -#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ -#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ -#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ -#define NO_DATA 4 /* Valid name, no data record of requested type */ -#define NO_ADDRESS NO_DATA /* no address, look for MX record */ - -/* Values for getaddrinfo() and getnameinfo() */ -#define AI_PASSIVE 1 /* socket address is intended for bind() */ -#define AI_CANONNAME 2 /* request for canonical name */ -#define AI_NUMERICHOST 4 /* don't ever try nameservice */ -#define AI_EXT 8 /* enable non-portable extensions */ -/* valid flags for addrinfo */ -#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST) - -#define NI_NUMERICHOST 1 /* return the host address, not the name */ -#define NI_NUMERICSERV 2 /* return the service address, not the name */ -#define NI_NOFQDN 4 /* return a short name if in the local domain */ -#define NI_NAMEREQD 8 /* fail if either host or service name is unknown */ -#define NI_DGRAM 16 /* look up datagram service instead of stream */ -#define NI_WITHSCOPEID 32 /* KAME hack: attach scopeid to host portion */ - -#define NI_MAXHOST MAXHOSTNAMELEN /* max host name returned by getnameinfo */ -#define NI_MAXSERV 32 /* max serv. name length returned by getnameinfo */ - -/* - * Scope delimit character (KAME hack) - */ -#define SCOPE_DELIMITER '%' - -#define EAI_BADFLAGS -1 /* invalid value for ai_flags */ -#define EAI_NONAME -2 /* name or service is not known */ -#define EAI_AGAIN -3 /* temporary failure in name resolution */ -#define EAI_FAIL -4 /* non-recoverable failure in name resolution */ -#define EAI_NODATA -5 /* no address associated with name */ -#define EAI_FAMILY -6 /* ai_family not supported */ -#define EAI_SOCKTYPE -7 /* ai_socktype not supported */ -#define EAI_SERVICE -8 /* service not supported for ai_socktype */ -#define EAI_ADDRFAMILY -9 /* address family for name not supported */ -#define EAI_MEMORY -10 /* memory allocation failure */ -#define EAI_SYSTEM -11 /* system error (code indicated in errno) */ -#define EAI_BADHINTS -12 /* invalid value for hints */ -#define EAI_PROTOCOL -13 /* resolved protocol is unknown */ - - -/* - * Flags for getrrsetbyname() - */ -#define RRSET_VALIDATED 1 - -/* - * Return codes for getrrsetbyname() - */ -#define ERRSET_SUCCESS 0 - -#ifdef __cplusplus -} -#endif - -#endif /* NETDB_H */ diff --git a/src/kits/network/old/compat/libnet/headers/resolv.h b/src/kits/network/old/compat/libnet/headers/resolv.h deleted file mode 100644 index 21f2f704c8..0000000000 --- a/src/kits/network/old/compat/libnet/headers/resolv.h +++ /dev/null @@ -1,358 +0,0 @@ -/* $OpenBSD: resolv.h,v 1.7 2001/07/31 22:02:18 jakob Exp $ */ - -/* - * 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. - */ - -/* - * ++Copyright++ 1983, 1987, 1989, 1993 - * - - * Copyright (c) 1983, 1987, 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - - * --Copyright-- - */ - -/* - * @(#)resolv.h 8.1 (Berkeley) 6/2/93 - * $From: resolv.h,v 8.17 1996/11/26 10:11:20 vixie Exp $ - */ - -#ifndef _RESOLV_H_ -#define _RESOLV_H_ - -/* #include */ -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Revision information. This is the release date in YYYYMMDD format. - * It can change every day so the right thing to do with it is use it - * in preprocessor commands such as "#if (__RES > 19931104)". Do not - * compare for equality; rather, use it to determine whether your resolver - * is new enough to contain a certain feature. - */ - -#define __RES 19960801 - -/* - * Resolver configuration file. - * Normally not present, but may contain the address of the - * initial name server(s) to query and the domain search list. - */ - -#ifndef _PATH_RESCONF -#define _PATH_RESCONF "/etc/resolv.conf" -#endif - -/* - * Global defines and variables for resolver stub. - */ -#define MAXNS 3 /* max # name servers we'll track */ -#define MAXDFLSRCH 3 /* # default domain levels to try */ -#define MAXDNSRCH 6 /* max # domains in search path */ -#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */ -#define MAXDNSLUS 4 /* max # of host lookup types */ - -#define RES_TIMEOUT 5 /* min. seconds between retries */ -#define MAXRESOLVSORT 10 /* number of net to sort on */ -#define RES_MAXNDOTS 15 /* should reflect bit field size */ - -struct __res_state { - int retrans; /* retransmition time interval */ - int retry; /* number of times to retransmit */ - u_long options; /* option flags - see below. */ - int nscount; /* number of name servers */ - struct sockaddr_in - nsaddr_list[MAXNS]; /* address of name server */ -#define nsaddr nsaddr_list[0] /* for backward compatibility */ - u_short id; /* current message id */ - char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ - char defdname[256]; /* default domain (deprecated) */ - u_long pfcode; /* RES_PRF_ flags - see below. */ - unsigned ndots:4; /* threshold for initial abs. query */ - unsigned nsort:4; /* number of elements in sort_list[] */ - char unused[3]; - struct { - struct in_addr addr; - uint32 mask; - } sort_list[MAXRESOLVSORT]; - char lookups[MAXDNSLUS]; - char pad[68]; /* on an i386 this means 512b total */ -}; - -#ifdef INET6 -/* - * replacement of __res_state, separated to keep binary compatibility. - */ -struct __res_state_ext { - struct sockaddr_storage nsaddr_list[MAXNS]; - struct { - int af; /* address family for addr, mask */ - union { - struct in_addr ina; - struct in6_addr in6a; - } addr, mask; - } sort_list[MAXRESOLVSORT]; -}; -#endif - - -/* - * Resolver options (keep these in synch with res_debug.c, please) - */ -#define RES_INIT 0x00000001 /* address initialized */ -#define RES_DEBUG 0x00000002 /* print debug messages */ -#define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/ -#define RES_USEVC 0x00000008 /* use virtual circuit */ -#define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */ -#define RES_IGNTC 0x00000020 /* ignore trucation errors */ -#define RES_RECURSE 0x00000040 /* recursion desired */ -#define RES_DEFNAMES 0x00000080 /* use default domain name */ -#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */ -#define RES_DNSRCH 0x00000200 /* search up local domain tree */ -#define RES_INSECURE1 0x00000400 /* type 1 security disabled */ -#define RES_INSECURE2 0x00000800 /* type 2 security disabled */ -#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */ -#define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */ -/* KAME extensions: use higher bit to avoid conflict with ISC use */ -#define RES_USE_EDNS0 0x40000000 /* use EDNS0 */ -/* DNSSEC extensions: use higher bit to avoid conflict with ISC use */ -#define RES_USE_DNSSEC 0x20000000 /* use DNSSEC using OK bit in OPT */ - -#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH) - -/* - * Resolver "pfcode" values. Used by dig. - */ -#define RES_PRF_STATS 0x00000001 -/* 0x00000002 */ -#define RES_PRF_CLASS 0x00000004 -#define RES_PRF_CMD 0x00000008 -#define RES_PRF_QUES 0x00000010 -#define RES_PRF_ANS 0x00000020 -#define RES_PRF_AUTH 0x00000040 -#define RES_PRF_ADD 0x00000080 -#define RES_PRF_HEAD1 0x00000100 -#define RES_PRF_HEAD2 0x00000200 -#define RES_PRF_TTLID 0x00000400 -#define RES_PRF_HEADX 0x00000800 -#define RES_PRF_QUERY 0x00001000 -#define RES_PRF_REPLY 0x00002000 -#define RES_PRF_INIT 0x00004000 -/* 0x00008000 */ - -/* hooks are still experimental as of 4.9.2 */ -typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error } - res_sendhookact; - -typedef res_sendhookact (*res_send_qhook)(struct sockaddr_in * const *ns, - const uchar **query, - int *querylen, - uchar *ans, - int anssiz, - int *resplen); - -typedef res_sendhookact (*res_send_rhook)(const struct sockaddr_in *ns, - const uchar *query, - int querylen, - uchar *ans, - int anssiz, - int *resplen); - -struct res_sym { - int number; /* Identifying number, like T_MX */ - char * name; /* Its symbolic name, like "MX" */ - char * humanname; /* Its fun name, like "mail exchanger" */ -}; - -extern struct __res_state _res; - -#ifdef INET6 -extern struct __res_state_ext _res_ext; -#endif -extern const struct res_sym __p_class_syms[]; -extern const struct res_sym __p_type_syms[]; - -/* Private routines shared between libc/net, named, nslookup and others. */ -#define res_hnok __res_hnok -#define res_ownok __res_ownok -#define res_mailok __res_mailok -#define res_dnok __res_dnok -#define sym_ston __sym_ston -#define sym_ntos __sym_ntos -#define sym_ntop __sym_ntop -#define b64_ntop __b64_ntop -#define b64_pton __b64_pton -#define loc_ntoa __loc_ntoa -#define loc_aton __loc_aton -#define dn_skipname __dn_skipname -#define fp_resstat __fp_resstat -#define fp_query __fp_query -#define fp_nquery __fp_nquery -#define hostalias __hostalias -#define putlong __putlong -#define putshort __putshort -#define p_class __p_class -#define p_time __p_time -#define p_type __p_type -#define p_query __p_query -#define p_cdnname __p_cdnname -#define p_cdname __p_cdname -#define p_fqnname __p_fqnname -#define p_fqname __p_fqname -#define p_rr __p_rr -#define p_option __p_option -#define p_secstodate __p_secstodate -#define dn_count_labels __dn_count_labels -#define dn_comp __dn_comp -#define res_randomid __res_randomid -#define res_send __res_send -#define res_isourserver __res_isourserver -#define res_nameinquery __res_nameinquery -#define res_queriesmatch __res_queriesmatch -#define res_close __res_close -#define res_opt __res_opt - -#ifdef BIND_RES_POSIX3 -#define dn_expand __dn_expand -#define res_init __res_init -#define res_query __res_query -#define res_search __res_search -#define res_querydomain __res_querydomain -#define res_mkquery __res_mkquery -#endif - -int res_hnok (const char *); -int res_ownok (const char *); -int res_mailok (const char *); -int res_dnok (const char *); -int sym_ston (const struct res_sym *, char *, int *); -const char * sym_ntos (const struct res_sym *, int, int *); -const char * sym_ntop (const struct res_sym *, int, int *); -int b64_ntop (uchar const *, size_t, char *, size_t); -int b64_pton (char const *, uchar *, size_t); -int loc_aton (const char *, uchar *); -const char * loc_ntoa (const uchar *, char *); -int dn_skipname (const uchar *, const uchar *); -void fp_resstat (struct __res_state *, FILE *); -void fp_query (const uchar *, FILE *); -void fp_nquery (const uchar *, int, FILE *); -const char * hostalias (const char *); -void putlong (uint32, uchar *); -void putshort (uint16, uchar *); -const char * p_class (int); -const char * p_time (uint32); -const char * p_type (int); -void p_query (const uchar *); -const uchar * p_cdnname (const uchar *, const uchar *, int, FILE *); -const uchar * p_cdname (const uchar *, const uchar *, FILE *); -const uchar * p_fqnname (const uchar *cp, const uchar *msg, - int, char *, int); -const uchar * p_fqname (const uchar *, const uchar *, FILE *); -const uchar * p_rr (const uchar *, const uchar *, FILE *); -const char * p_option (u_long option); -char * p_secstodate (u_long); -int dn_count_labels (char *); -int dn_comp (const char *, uchar *, int, - uchar **, uchar **); -int dn_expand (const uchar *, const uchar *, const uchar *, - char *, int); -int res_init (void); -uint res_randomid (void); -int res_query (const char *, int, int, uchar *, int); -int res_search (const char *, int, int, uchar *, int); -int res_querydomain (const char *, const char *, int, int, - uchar *, int); -int res_mkquery (int, const char *, int, int, const uchar *, int, - const uchar *, uchar *, int); -int res_send (const uchar *, int, uchar *, int); -int res_isourserver (const struct sockaddr_in *); -int res_nameinquery (const char *, int, int, - const uchar *, const uchar *); -int res_queriesmatch (const uchar *, const uchar *, - const uchar *, const uchar *); -void res_close (void); - -#ifdef __cplusplus -} -#endif - -#endif /* !_RESOLV_H_ */ diff --git a/src/kits/network/old/compat/libnet/inet_addr.c b/src/kits/network/old/compat/libnet/inet_addr.c deleted file mode 100644 index c1da3f6819..0000000000 --- a/src/kits/network/old/compat/libnet/inet_addr.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * ++Copyright++ 1983, 1990, 1993 - * - - * Copyright (c) 1983, 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - - * --Copyright-- - */ - -#include -#include -#include -#include -#include - -/* - * Ascii internet address interpretation routine. - * The value returned is in network order. - */ -in_addr_t -inet_addr(cp) - register const char *cp; -{ - struct in_addr val; - - if (inet_aton(cp, &val)) - return (val.s_addr); - return (INADDR_NONE); -} - -/* - * Check whether "cp" is a valid ascii representation - * of an Internet address and convert to a binary address. - * Returns 1 if the address is valid, 0 if not. - * This replaces inet_addr, the return value from which - * cannot distinguish between failure and a local broadcast address. - */ -int -inet_aton(cp, addr) - register const char *cp; - struct in_addr *addr; -{ - register in_addr_t val; - register int base, n; - register char c; - u_int parts[4]; - register u_int *pp = parts; - - c = *cp; - for (;;) { - /* - * Collect number up to ``.''. - * Values are specified as for C: - * 0x=hex, 0=octal, isdigit=decimal. - */ - if (!isdigit(c)) - return (0); - val = 0; base = 10; - if (c == '0') { - c = *++cp; - if (c == 'x' || c == 'X') - base = 16, c = *++cp; - else - base = 8; - } - for (;;) { - if (isascii(c) && isdigit(c)) { - val = (val * base) + (c - '0'); - c = *++cp; - } else if (base == 16 && isascii(c) && isxdigit(c)) { - val = (val << 4) | - (c + 10 - (islower(c) ? 'a' : 'A')); - c = *++cp; - } else - break; - } - if (c == '.') { - /* - * Internet format: - * a.b.c.d - * a.b.c (with c treated as 16 bits) - * a.b (with b treated as 24 bits) - */ - if (pp >= parts + 3) - return (0); - *pp++ = val; - c = *++cp; - } else - break; - } - /* - * Check for trailing characters. - */ - if (c != '\0' && (!isascii(c) || !isspace(c))) - return (0); - /* - * Concoct the address according to - * the number of parts specified. - */ - n = pp - parts + 1; - switch (n) { - - case 0: - return (0); /* initial nondigit */ - - case 1: /* a -- 32 bits */ - break; - - case 2: /* a.b -- 8.24 bits */ - if ((val > 0xffffff) || (parts[0] > 0xff)) - return (0); - val |= parts[0] << 24; - break; - - case 3: /* a.b.c -- 8.8.16 bits */ - if ((val > 0xffff) || (parts[0] > 0xff) || (parts[1] > 0xff)) - return (0); - val |= (parts[0] << 24) | (parts[1] << 16); - break; - - case 4: /* a.b.c.d -- 8.8.8.8 bits */ - if ((val > 0xff) || (parts[0] > 0xff) || (parts[1] > 0xff) || (parts[2] > 0xff)) - return (0); - val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); - break; - } - if (addr) - addr->s_addr = htonl(val); - return (1); -} diff --git a/src/kits/network/old/compat/libnet/inet_lnaof.c b/src/kits/network/old/compat/libnet/inet_lnaof.c deleted file mode 100644 index 212137a43d..0000000000 --- a/src/kits/network/old/compat/libnet/inet_lnaof.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -/* - * Return the local network address portion of an - * internet address; handles class a/b/c network - * number formats. - */ -in_addr_t -inet_lnaof(in) - struct in_addr in; -{ - register in_addr_t i = ntohl(in.s_addr); - - if (IN_CLASSA(i)) - return ((i)&IN_CLASSA_HOST); - else if (IN_CLASSB(i)) - return ((i)&IN_CLASSB_HOST); - else - return ((i)&IN_CLASSC_HOST); -} diff --git a/src/kits/network/old/compat/libnet/inet_neta.c b/src/kits/network/old/compat/libnet/inet_neta.c deleted file mode 100644 index 9c684f06f3..0000000000 --- a/src/kits/network/old/compat/libnet/inet_neta.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 1996 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#include -#include -#include -#include - -#include -#include -#include - -/* - * char * - * inet_neta(src, dst, size) - * format an in_addr_t network number into presentation format. - * return: - * pointer to dst, or NULL if an error occurred (check errno). - * note: - * format of ``src'' is as for inet_network(). - * author: - * Paul Vixie (ISC), July 1996 - */ -char * -inet_neta(src, dst, size) - in_addr_t src; - char *dst; - size_t size; -{ - char *odst = dst; - char *tp; - - while (src & 0xffffffff) { - u_char b = (src & 0xff000000) >> 24; - - src <<= 8; - if (b) { - if (size < sizeof "255.") - goto emsgsize; - tp = dst; - dst += sprintf(dst, "%u", b); - if (src != 0L) { - *dst++ = '.'; - *dst = '\0'; - } - size -= (size_t)(dst - tp); - } - } - if (dst == odst) { - if (size < sizeof "0.0.0.0") - goto emsgsize; - strcpy(dst, "0.0.0.0"); - } - return (odst); - - emsgsize: - errno = EMSGSIZE; - return (NULL); -} diff --git a/src/kits/network/old/compat/libnet/inet_netof.c b/src/kits/network/old/compat/libnet/inet_netof.c deleted file mode 100644 index 7d31623c21..0000000000 --- a/src/kits/network/old/compat/libnet/inet_netof.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -/* - * Return the network number from an internet - * address; handles class a/b/c network #'s. - */ -in_addr_t -inet_netof(in) - struct in_addr in; -{ - register in_addr_t i = ntohl(in.s_addr); - - if (IN_CLASSA(i)) - return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT); - else if (IN_CLASSB(i)) - return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT); - else - return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT); -} diff --git a/src/kits/network/old/compat/libnet/inet_network.c b/src/kits/network/old/compat/libnet/inet_network.c deleted file mode 100644 index 48834d827d..0000000000 --- a/src/kits/network/old/compat/libnet/inet_network.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include - -/* - * Internet network address interpretation routine. - * The library routines call this routine to interpret - * network numbers. - */ -in_addr_t -inet_network(cp) - register const char *cp; -{ - register in_addr_t val, base, n; - register char c; - in_addr_t parts[4], *pp = parts; - register int i; - -again: - val = 0; base = 10; - if (*cp == '0') - base = 8, cp++; - if (*cp == 'x' || *cp == 'X') - base = 16, cp++; - while ((c = *cp)) { - if (isdigit(c)) { - val = (val * base) + (c - '0'); - cp++; - continue; - } - if (base == 16 && isxdigit(c)) { - val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A')); - cp++; - continue; - } - break; - } - if (*cp == '.') { - if (pp >= parts + 3) - return (INADDR_NONE); - *pp++ = val, cp++; - goto again; - } - if (*cp && !isspace(*cp)) - return (INADDR_NONE); - *pp++ = val; - n = pp - parts; - for (val = 0, i = 0; i < 4; i++) { - val <<= 8; - if (i < n) - val |= parts[i] & 0xff; - } - return (val); -} diff --git a/src/kits/network/old/compat/libnet/inet_ntoa.c b/src/kits/network/old/compat/libnet/inet_ntoa.c deleted file mode 100644 index 5d9dc05872..0000000000 --- a/src/kits/network/old/compat/libnet/inet_ntoa.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Convert network-format internet address - * to base 256 d.d.d.d representation. - */ -#include -#include -#include -#include - -char * -inet_ntoa(in) - struct in_addr in; -{ - static char b[18]; - register char *p; - - p = (char *)∈ -#define UC(b) (((int)b)&0xff) - #ifdef _MWERKS_STDIO_H_ - (void)sprintf(b, - "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3])); - #else - (void)snprintf(b, sizeof(b), - "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3])); - #endif - return (b); -} diff --git a/src/kits/network/old/compat/libnet/inet_ntop.c b/src/kits/network/old/compat/libnet/inet_ntop.c deleted file mode 100644 index 2547bfc67d..0000000000 --- a/src/kits/network/old/compat/libnet/inet_ntop.c +++ /dev/null @@ -1,184 +0,0 @@ -/* Copyright (c) 1996 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * 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 u_char *src, char *dst, size_t size); -static const char *inet_ntop6 (const u_char *src, char *dst, size_t size); - -/* char * - * inet_ntop(af, src, dst, size) - * convert a network format address to presentation format. - * return: - * pointer to presentation format address (`dst'), or NULL (see errno). - * author: - * Paul Vixie, 1996. - */ -const char * -inet_ntop(af, src, dst, size) - int af; - const void *src; - char *dst; - size_t size; -{ - switch (af) { - case AF_INET: - return (inet_ntop4(src, dst, size)); - case AF_INET6: - return (inet_ntop6(src, dst, size)); - default: - errno = EAFNOSUPPORT; - return (NULL); - } - /* NOTREACHED */ -} - -/* const char * - * inet_ntop4(src, dst, size) - * format an IPv4 address, more or less like inet_ntoa() - * return: - * `dst' (as a const) - * notes: - * (1) uses no statics - * (2) takes a u_char* not an in_addr as input - * author: - * Paul Vixie, 1996. - */ -static const char * -inet_ntop4(src, dst, size) - const u_char *src; - char *dst; - size_t size; -{ - static const char fmt[] = "%u.%u.%u.%u"; - char tmp[sizeof "255.255.255.255"]; - - if (sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) > size) { - errno = ENOSPC; - return (NULL); - } - strcpy(dst, tmp); - return (dst); -} - -/* const char * - * inet_ntop6(src, dst, size) - * convert IPv6 binary address into presentation (printable) format - * author: - * Paul Vixie, 1996. - */ -static const char * -inet_ntop6(src, dst, size) - const u_char *src; - char *dst; - size_t size; -{ - /* - * Note that int32_t and int16_t need only be "at least" large enough - * to contain a value of the specified size. On some systems, like - * Crays, there is no such thing as an integer variable with 16 bits. - * Keep this in mind if you think this function should have been coded - * to use pointer overlays. All the world's not a VAX. - */ - char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp; - struct { int base, len; } best, cur; - u_int words[IN6ADDRSZ / 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 < IN6ADDRSZ; i++) - words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); - best.base = -1; - cur.base = -1; - for (i = 0; i < (IN6ADDRSZ / 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 < (IN6ADDRSZ / INT16SZ); i++) { - /* Are we inside the best run of 0x00's? */ - if (best.base != -1 && i >= best.base && - i < (best.base + best.len)) { - if (i == best.base) - *tp++ = ':'; - continue; - } - /* Are we following an initial run of 0x00s or any real hex? */ - if (i != 0) - *tp++ = ':'; - /* Is this address an encapsulated IPv4? */ - if (i == 6 && best.base == 0 && - (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { - if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp))) - return (NULL); - tp += strlen(tp); - break; - } - tp += sprintf(tp, "%x", words[i]); - } - /* Was it a trailing run of 0x00's? */ - if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) - *tp++ = ':'; - *tp++ = '\0'; - - /* - * Check for overflow, copy, and we're done. - */ - if ((size_t)(tp - tmp) > size) { - errno = ENOSPC; - return (NULL); - } - strcpy(dst, tmp); - return (dst); -} diff --git a/src/kits/network/old/compat/libnet/inet_pton.c b/src/kits/network/old/compat/libnet/inet_pton.c deleted file mode 100644 index 8a6644499e..0000000000 --- a/src/kits/network/old/compat/libnet/inet_pton.c +++ /dev/null @@ -1,212 +0,0 @@ -/* Copyright (c) 1996 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * 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, u_char *dst); -static int inet_pton6 (const char *src, u_char *dst); - -/* int - * inet_pton(af, src, dst) - * convert from presentation format (which usually means ASCII printable) - * to network format (which is usually some kind of binary format). - * return: - * 1 if the address was valid for the specified address family - * 0 if the address wasn't valid (`dst' is untouched in this case) - * -1 if some other error occurred (`dst' is untouched in this case, too) - * author: - * Paul Vixie, 1996. - */ -int -inet_pton(af, src, dst) - int af; - const char *src; - void *dst; -{ - switch (af) { - case AF_INET: - return (inet_pton4(src, dst)); - case AF_INET6: - return (inet_pton6(src, dst)); - default: - errno = EAFNOSUPPORT; - return (-1); - } - /* NOTREACHED */ -} - -/* int - * inet_pton4(src, dst) - * like inet_aton() but without all the hexadecimal and shorthand. - * return: - * 1 if `src' is a valid dotted quad, else 0. - * notice: - * does not touch `dst' unless it's returning 1. - * author: - * Paul Vixie, 1996. - */ -static int -inet_pton4(src, dst) - const char *src; - u_char *dst; -{ - static const char digits[] = "0123456789"; - int saw_digit, octets, ch; - u_char tmp[INADDRSZ], *tp; - - saw_digit = 0; - octets = 0; - *(tp = tmp) = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr(digits, ch)) != NULL) { - u_int new = *tp * 10 + (pch - digits); - - if (new > 255) - return (0); - if (! saw_digit) { - if (++octets > 4) - return (0); - saw_digit = 1; - } - *tp = new; - } else if (ch == '.' && saw_digit) { - if (octets == 4) - return (0); - *++tp = 0; - saw_digit = 0; - } else - return (0); - } - if (octets < 4) - return (0); - - memcpy(dst, tmp, INADDRSZ); - return (1); -} - -/* int - * inet_pton6(src, dst) - * convert presentation level address to network order binary form. - * return: - * 1 if `src' is a valid [RFC1884 2.2] address, else 0. - * notice: - * (1) does not touch `dst' unless it's returning 1. - * (2) :: in a full address is silently ignored. - * credit: - * inspired by Mark Andrews. - * author: - * Paul Vixie, 1996. - */ -static int -inet_pton6(src, dst) - const char *src; - u_char *dst; -{ - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - u_char tmp[IN6ADDRSZ], *tp, *endp, *colonp; - const char *xdigits, *curtok; - int ch, saw_xdigit; - u_int val; - - memset((tp = tmp), '\0', IN6ADDRSZ); - endp = tp + IN6ADDRSZ; - colonp = NULL; - /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') - return (0); - curtok = src; - saw_xdigit = 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 (val > 0xffff) - return (0); - saw_xdigit = 1; - continue; - } - if (ch == ':') { - curtok = src; - if (!saw_xdigit) { - if (colonp) - return (0); - colonp = tp; - continue; - } else if (*src == '\0') { - return (0); - } - if (tp + INT16SZ > endp) - return (0); - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; - saw_xdigit = 0; - val = 0; - continue; - } - if (ch == '.' && ((tp + INADDRSZ) <= endp) && - inet_pton4(curtok, tp) > 0) { - tp += INADDRSZ; - saw_xdigit = 0; - break; /* '\0' was seen by inet_pton4(). */ - } - return (0); - } - if (saw_xdigit) { - if (tp + INT16SZ > endp) - return (0); - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; - } - if (colonp != NULL) { - /* - * Since some memmove()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const int n = tp - colonp; - int i; - - for (i = 1; i <= n; i++) { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; - } - tp = endp; - } - if (tp != endp) - return (0); - memcpy(dst, tmp, IN6ADDRSZ); - return (1); -} diff --git a/src/kits/network/old/compat/libnet/linkaddr.c b/src/kits/network/old/compat/libnet/linkaddr.c deleted file mode 100644 index ade6c68cd6..0000000000 --- a/src/kits/network/old/compat/libnet/linkaddr.c +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -/* States*/ -#define NAMING 0 -#define GOTONE 1 -#define GOTTWO 2 -#define RESET 3 -/* Inputs */ -#define DIGIT (4*0) -#define END (4*1) -#define DELIM (4*2) -#define LETTER (4*3) - -void -link_addr(addr, sdl) - register const char *addr; - register struct sockaddr_dl *sdl; -{ - register char *cp = sdl->sdl_data; - char *cplim = sdl->sdl_len + (char *)sdl; - register int byte = 0, state = NAMING, newv = 0; - - memset((char *)&sdl->sdl_family, 0, sdl->sdl_len - 1); - sdl->sdl_family = AF_LINK; - do { - state &= ~LETTER; - if ((*addr >= '0') && (*addr <= '9')) { - newv = *addr - '0'; - } else if ((*addr >= 'a') && (*addr <= 'f')) { - newv = *addr - 'a' + 10; - } else if ((*addr >= 'A') && (*addr <= 'F')) { - newv = *addr - 'A' + 10; - } else if (*addr == 0) { - state |= END; - } else if (state == NAMING && - (((*addr >= 'A') && (*addr <= 'Z')) || - ((*addr >= 'a') && (*addr <= 'z')))) - state |= LETTER; - else - state |= DELIM; - addr++; - switch (state /* | INPUT */) { - case NAMING | DIGIT: - case NAMING | LETTER: - *cp++ = addr[-1]; - continue; - case NAMING | DELIM: - state = RESET; - sdl->sdl_nlen = cp - sdl->sdl_data; - continue; - case GOTTWO | DIGIT: - *cp++ = byte; - /* FALLTHROUGH */ - case RESET | DIGIT: - state = GOTONE; - byte = newv; - continue; - case GOTONE | DIGIT: - state = GOTTWO; - byte = newv + (byte << 4); - continue; - default: /* | DELIM */ - state = RESET; - *cp++ = byte; - byte = 0; - continue; - case GOTONE | END: - case GOTTWO | END: - *cp++ = byte; - /* FALLTHROUGH */ - case RESET | END: - break; - } - break; - } while (cp < cplim); - sdl->sdl_alen = cp - LLADDR(sdl); - newv = cp - (char *)sdl; - if (newv > sizeof(*sdl)) - sdl->sdl_len = newv; - return; -} - -static char hexlist[] = "0123456789abcdef"; - -char * -link_ntoa(sdl) - register const struct sockaddr_dl *sdl; -{ - static char obuf[64]; - register char *out = obuf; - register int i; - register u_char *in = (u_char *)LLADDR(sdl); - u_char *inlim = in + sdl->sdl_alen; - int firsttime = 1; - - if (sdl->sdl_nlen) { - memcpy(obuf, sdl->sdl_data, sdl->sdl_nlen); - out += sdl->sdl_nlen; - if (sdl->sdl_alen) - *out++ = ':'; - } - while (in < inlim) { - if (firsttime) - firsttime = 0; - else - *out++ = '.'; - i = *in++; - if (i > 0xf) { - out[1] = hexlist[i & 0xf]; - i >>= 4; - out[0] = hexlist[i]; - out += 2; - } else - *out++ = hexlist[i]; - } - *out = 0; - return (obuf); -} diff --git a/src/kits/network/old/compat/libnet/netconfig.c b/src/kits/network/old/compat/libnet/netconfig.c deleted file mode 100644 index 70328528d7..0000000000 --- a/src/kits/network/old/compat/libnet/netconfig.c +++ /dev/null @@ -1,15 +0,0 @@ -/* -** Copyright 2005, Jérôme DUVAL. All rights reserved. -** Distributed under the terms of the Haiku License. -*/ - -#include - -_EXPORT char * -_netconfig_find(const char *heading, const char *name, char *value, - int nbytes) -{ - printf("_netconfig_find heading:%s, name:%s, value:%s, nbytes:%d\n", heading, name, value, nbytes); - return find_net_setting(NULL, heading, name, value, nbytes); -} - diff --git a/src/kits/network/old/compat/libnet/netdebug.c b/src/kits/network/old/compat/libnet/netdebug.c deleted file mode 100644 index 4407f812b0..0000000000 --- a/src/kits/network/old/compat/libnet/netdebug.c +++ /dev/null @@ -1,12 +0,0 @@ -/* -** Copyright 2005, Jérôme DUVAL. All rights reserved. -** Distributed under the terms of the Haiku License. -*/ - -#include - -_EXPORT void -_debug_setflags(unsigned flags) -{ -} - diff --git a/src/kits/network/old/compat/libnet/networks b/src/kits/network/old/compat/libnet/networks deleted file mode 100644 index 0c3d0ace1e..0000000000 --- a/src/kits/network/old/compat/libnet/networks +++ /dev/null @@ -1,10 +0,0 @@ -# Haiku /etc/networks -# - -# Internet networks (from nic.ddn.mil) -# 1) The multicast network -BASE-ADDRESS.MCAST.NET 224 -loopback 127 loop - -# Your subnets follow... - diff --git a/src/kits/network/old/compat/libnet/poll.c b/src/kits/network/old/compat/libnet/poll.c deleted file mode 100644 index e95311ec1d..0000000000 --- a/src/kits/network/old/compat/libnet/poll.c +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include - -#include - -// ------------------------------- -int poll(struct pollfd *fds, nfds_t numfds, int timeout) -{ - fd_set read_set; - fd_set write_set; - fd_set exception_set; - nfds_t i; - int n; - int rc; - - FD_ZERO(&read_set); - FD_ZERO(&write_set); - FD_ZERO(&exception_set); - - n = -1; - for(i = 0; i < numfds; i++) { - if (fds[i].fd < 0) - continue; - - if (fds[i].events & POLLIN) FD_SET(fds[i].fd, &read_set); - if (fds[i].events & POLLOUT) FD_SET(fds[i].fd, &write_set); - if (fds[i].events & POLLERR) FD_SET(fds[i].fd, &exception_set); - - if (fds[i].fd > n) - n = fds[i].fd; - }; - - if (n == -1) - // Hey!? Nothing to poll, in fact!!! - return 0; - - if (timeout < 0) - rc = select(n+1, &read_set, &write_set, &exception_set, NULL); - else { - struct timeval tv; - - tv.tv_sec = timeout / 1000; - tv.tv_usec = 1000 * (timeout % 1000); - rc = select(n+1, &read_set, &write_set, &exception_set, &tv); - }; - - if (rc < 0) - return rc; - - for(i = 0; i < (nfds_t) n; i++) { - fds[i].revents = 0; - - if (FD_ISSET(fds[i].fd, &read_set)) fds[i].revents |= POLLIN; - if (FD_ISSET(fds[i].fd, &write_set)) fds[i].revents |= POLLOUT; - if (FD_ISSET(fds[i].fd, &exception_set)) fds[i].revents |= POLLERR; - }; - - return rc; -} diff --git a/src/kits/network/old/compat/libnet/protocols b/src/kits/network/old/compat/libnet/protocols deleted file mode 100644 index a0cfb10c6e..0000000000 --- a/src/kits/network/old/compat/libnet/protocols +++ /dev/null @@ -1,110 +0,0 @@ -# -# Internet (IP) protocols -# -# Updated based on RFC 1340, Assigned Numbers (July 1992). -# See also http://www.isi.edu/in-notes/iana/assignments/protocol-numbers -# -ip 0 IP # internet protocol, pseudo protocol number -icmp 1 ICMP # internet control message protocol -igmp 2 IGMP # Internet Group Management -ggp 3 GGP # gateway-gateway protocol -ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'') -st 5 ST # ST datagram mode -tcp 6 TCP # transmission control protocol -ucl 7 UCL # UCL -egp 8 EGP # exterior gateway protocol -igp 9 IGP # any private interior gateway -bbn-rcc-mon 10 BBN-RCC-MON # BBN RCC Monitoring -nvp-ii 11 NVP-II # Network Voice Protocol -pup 12 PUP # PARC universal packet protocol -argus 13 ARGUS # ARGUS -emcon 14 EMCON # EMCON -xnet 15 XNET # Cross Net Debugger -chaos 16 CHAOS # Chaos -udp 17 UDP # user datagram protocol -mux 18MUX# Multiplexing -dcn-meas 19DCN-MEAS# DCN Measurement Subsystems -hmp 20HMP# host monitoring protocol -prm 21PRM# Packet Radio Measurement -xns-idp 22XNS-IDP# Xerox NS IDP -trunk-1 23TRUNK-1# Trunk-1 -trunk-2 24TRUNK-2# Trunk-2 -leaf-1 25LEAF-1# Leaf-1 -leaf-2 26LEAF-2# Leaf-2 -rdp 27RDP# "reliable datagram" protocol -irtp 28IRTP# Internet Reliable Transaction -iso-tp4 29ISO-TP4# ISO Transport Protocol class 4 -netblt 30NETBLT# Bulk Data Transfer Protocol -mfe-nsp 31MFE-NSP# MFE Network Services Protocol -merit-inp 32MERIT-INP# MERIT Internodal Protocol -sep 33SEP# Sequential Exchange Protocol -3pc 343PC# Third Party Connect Protocol -idpr 35IDPR# Inter-Domain Policy Routing Protocol -xtp 36XTP# Xpress Tranfer Protocol -ddp 37DDP# Datagram Delivery Protocol -idpr-cmtp 38IDPR-CMTP# IDPR Control Message Transport Proto -idpr-cmtp 39IDPR-CMTP# IDPR Control Message Transport -il 40IL# IL Transport Protocol -ipv6 41IPv6# Internet Protocol version 6 -sdrp 42SDRP# Source Demand Routing Protocol -sip-sr 43SIP-SR# SIP Source Route -sip-frag 44SIP-FRAG# SIP Fragment -idrp 45IDRP# Inter-Domain Routing Protocol -rsvp 46RSVP# Reservation Protocol -gre 47GRE# General Routing Encapsulation -mhrp 48MHRP# Mobile Host Routing Protocol -bna 49BNA# BNA -esp 50IPSEC-ESP# Encap Security Payload -ah 51IPSEC-AH# Authentication Header -i-nlsp 52I-NLSP# Integrated Net Layer Security TUBA -swipe 53SWIPE# IP with Encryption -nhrp 54NHRP# NBMA Next Hop Resolution Protocol -mobileip 55MOBILEIP# MobileIP encapsulation -skip 57SKIP# SKIP -ipv6-icmp 58IPv6-ICMP# ICMP for IPv6 -ipv6-nonxt 59IPv6-NoNxt# No Next Header for IPv6 -ipv6-opts 60IPv6-Opts# Destination Options for IPv6 -any 61any# host internal protocol -cftp 62CFTP# CFTP -any 63any# local network -sat-expak 64SAT-EXPAK# SATNET and Backroom EXPAK -kryptolan 65KRYPTOLAN# Kryptolan -rvd 66RVD# MIT Remote Virtual Disk Protocol -ippc 67IPPC# Internet Pluribus Packet Core -any 68any# distributed file system -sat-mon 69SAT-MON# SATNET Monitoring -visa 70VISA# VISA Protocol -ipcv 71IPCV# Internet Packet Core Utility -cpnx 72CPNX# Computer Protocol Network Executive -cphb 73CPHB# Computer Protocol Heart Beat -wsn 74WSN# Wang Span Network -pvp 75PVP# Packet Video Protocol -br-sat-mon 76BR-SAT-MON# Backroom SATNET Monitoring -sun-nd 77SUN-ND# SUN ND PROTOCOL-Temporary -wb-mon 78WB-MON# WIDEBAND Monitoring -wb-expak 79WB-EXPAK# WIDEBAND EXPAK -iso-ip 80ISO-IP# ISO Internet Protocol -vmtp 81VMTP# Versatile Message Transport -secure-vmtp 82SECURE-VMTP # SECURE-VMTP -vines 83VINES# VINES -ttp 84TTP# TTP -nsfnet-igp 85NSFNET-IGP# NSFNET-IGP -dgp 86DGP# Dissimilar Gateway Protocol -tcf 87TCF# TCF -igrp 88IGRP# IGRP -ospf 89OSPFIGP# Open Shortest Path First IGP -sprite-rpc 90Sprite-RPC# Sprite RPC Protocol -larp 91LARP# Locus Address Resolution Protocol -mtp 92MTP# Multicast Transport Protocol -ax.25 93AX.25# AX.25 Frames -ipip 94IPIP# Yet Another IP encapsulation -micp 95MICP# Mobile Internetworking Control Pro. -scc-sp 96SCC-SP# Semaphore Communications Sec. Pro. -etherip 97ETHERIP# Ethernet-within-IP Encapsulation -encap 98ENCAP# Yet Another IP encapsulation -any 99any# private encryption scheme -gmtp 100GMTP# GMTP -pim 103PIM# Protocol Independent Multicast -ipcomp 108IPComp# IP Payload Compression Protocol -vrrp 112VRRP# Virtual Router Redundancy Protocol -reserved 255Reserved# \ No newline at end of file diff --git a/src/kits/network/old/compat/libnet/res_comp.c b/src/kits/network/old/compat/libnet/res_comp.c deleted file mode 100644 index c442502a91..0000000000 --- a/src/kits/network/old/compat/libnet/res_comp.c +++ /dev/null @@ -1,499 +0,0 @@ -/* - * ++Copyright++ 1985, 1993 - * - - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - - * --Copyright-- - */ - -#include -#include -#include -#include -#include /* for MAXHOSTNAMELEN */ -#include - -#include -#include -#include -#include - - -static int dn_find (u_char *exp_dn, u_char *msg, - u_char **dnptrs, u_char **lastdnptr); - -/* - * Expand compressed domain name 'comp_dn' to full domain name. - * 'msg' is a pointer to the begining of the message, - * 'eomorig' points to the first location after the message, - * 'exp_dn' is a pointer to a buffer of size 'length' for the result. - * Return size of compressed name or -1 if there was an error. - */ -int -dn_expand(msg, eomorig, comp_dn, exp_dn, length) - const u_char *msg, *eomorig, *comp_dn; - char *exp_dn; - int length; -{ - register const u_char *cp; - register char *dn; - register int n, c; - char *eom; - int len = -1, checked = 0; - - dn = exp_dn; - cp = comp_dn; - if (length > MAXHOSTNAMELEN-1) - length = MAXHOSTNAMELEN-1; - eom = exp_dn + length; - /* - * fetch next label in domain name - */ - while ((n = *cp++)) { - /* - * Check for indirection - */ - switch (n & INDIR_MASK) { - case 0: - if (dn != exp_dn) { - if (dn >= eom) - return (-1); - *dn++ = '.'; - } - if (dn+n >= eom) - return (-1); - checked += n + 1; - while (--n >= 0) { - if (((c = *cp++) == '.') || (c == '\\')) { - if (dn + n + 2 >= eom) - return (-1); - *dn++ = '\\'; - } - *dn++ = c; - if (cp >= eomorig) /* out of range */ - return (-1); - } - break; - - case INDIR_MASK: - if (len < 0) - len = cp - comp_dn + 1; - cp = msg + (((n & 0x3f) << 8) | (*cp & 0xff)); - if (cp < msg || cp >= eomorig) /* out of range */ - return (-1); - checked += 2; - /* - * Check for loops in the compressed name; - * if we've looked at the whole message, - * there must be a loop. - */ - if (checked >= eomorig - msg) - return (-1); - break; - - default: - return (-1); /* flag error */ - } - } - *dn = '\0'; - if (len < 0) - len = cp - comp_dn; - return (len); -} - -/* - * Compress domain name 'exp_dn' into 'comp_dn'. - * Return the size of the compressed name or -1. - * 'length' is the size of the array pointed to by 'comp_dn'. - * 'dnptrs' is a list of pointers to previous compressed names. dnptrs[0] - * is a pointer to the beginning of the message. The list ends with NULL. - * 'lastdnptr' is a pointer to the end of the arrary pointed to - * by 'dnptrs'. Side effect is to update the list of pointers for - * labels inserted into the message as we compress the name. - * If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr' - * is NULL, we don't update the list. - */ -int -dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr) - const char *exp_dn; - u_char *comp_dn, **dnptrs, **lastdnptr; - int length; -{ - register u_char *cp, *dn; - register int c, l; - u_char **cpp, **lpp, *sp, *eob; - u_char *msg; - - dn = (u_char *)exp_dn; - cp = comp_dn; - eob = cp + length; - lpp = cpp = NULL; - if (dnptrs != NULL) { - if ((msg = *dnptrs++) != NULL) { - for (cpp = dnptrs; *cpp != NULL; cpp++) - ; - lpp = cpp; /* end of list to search */ - } - } else - msg = NULL; - for (c = *dn++; c != '\0'; ) { - /* look to see if we can use pointers */ - if (msg != NULL) { - if ((l = dn_find(dn-1, msg, dnptrs, lpp)) >= 0) { - if (cp+1 >= eob) - return (-1); - *cp++ = (l >> 8) | INDIR_MASK; - *cp++ = l % 256; - return (cp - comp_dn); - } - /* not found, save it */ - if (lastdnptr != NULL && cpp < lastdnptr-1) { - *cpp++ = cp; - *cpp = NULL; - } - } - sp = cp++; /* save ptr to length byte */ - do { - if (c == '.') { - c = *dn++; - break; - } - if (c == '\\') { - if ((c = *dn++) == '\0') - break; - } - if (cp >= eob) { - if (msg != NULL) - *lpp = NULL; - return (-1); - } - *cp++ = c; - } while ((c = *dn++) != '\0'); - /* catch trailing '.'s but not '..' */ - if ((l = cp - sp - 1) == 0 && c == '\0') { - cp--; - break; - } - if (l <= 0 || l > MAXLABEL) { - if (msg != NULL) - *lpp = NULL; - return (-1); - } - *sp = l; - } - if (cp >= eob) { - if (msg != NULL) - *lpp = NULL; - return (-1); - } - *cp++ = '\0'; - return (cp - comp_dn); -} - -/* - * Skip over a compressed domain name. Return the size or -1. - */ -int -__dn_skipname(comp_dn, eom) - const u_char *comp_dn, *eom; -{ - register const u_char *cp; - register int n; - - cp = comp_dn; - while (cp < eom && (n = *cp++)) { - /* - * check for indirection - */ - switch (n & INDIR_MASK) { - case 0: /* normal case, n == len */ - cp += n; - continue; - case INDIR_MASK: /* indirection */ - cp++; - break; - default: /* illegal type */ - return (-1); - } - break; - } - if (cp > eom) - return (-1); - return (cp - comp_dn); -} - -static int -mklower(ch) - register int ch; -{ - if (isascii(ch) && isupper(ch)) - return (tolower(ch)); - return (ch); -} - -/* - * Search for expanded name from a list of previously compressed names. - * Return the offset from msg if found or -1. - * dnptrs is the pointer to the first name on the list, - * not the pointer to the start of the message. - */ -static int -dn_find(exp_dn, msg, dnptrs, lastdnptr) - u_char *exp_dn, *msg; - u_char **dnptrs, **lastdnptr; -{ - register u_char *dn, *cp, **cpp; - register int n; - u_char *sp; - - for (cpp = dnptrs; cpp < lastdnptr; cpp++) { - dn = exp_dn; - sp = cp = *cpp; - while ((n = *cp++)) { - /* - * check for indirection - */ - switch (n & INDIR_MASK) { - case 0: /* normal case, n == len */ - while (--n >= 0) { - if (*dn == '.') - goto next; - if (*dn == '\\') - dn++; - if (mklower(*dn++) != mklower(*cp++)) - goto next; - } - if ((n = *dn++) == '\0' && *cp == '\0') - return (sp - msg); - if (n == '.') - continue; - goto next; - - case INDIR_MASK: /* indirection */ - cp = msg + (((n & 0x3f) << 8) | *cp); - break; - - default: /* illegal type */ - return (-1); - } - } - if (*dn == '\0') - return (sp - msg); - next: ; - } - return (-1); -} - -/* - * Verify that a domain name uses an acceptable character set. - */ - -/* - * Note the conspicuous absence of ctype macros in these definitions. On - * non-ASCII hosts, we can't depend on string literals or ctype macros to - * tell us anything about network-format data. The rest of the BIND system - * is not careful about this, but for some reason, we're doing it right here. - */ -#define PERIOD 0x2e -#define hyphenchar(c) ((c) == 0x2d) -#define bslashchar(c) ((c) == 0x5c) -#define periodchar(c) ((c) == PERIOD) -#define asterchar(c) ((c) == 0x2a) -#define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \ - || ((c) >= 0x61 && (c) <= 0x7a)) -#define digitchar(c) ((c) >= 0x30 && (c) <= 0x39) - -#define borderchar(c) (alphachar(c) || digitchar(c)) -#define middlechar(c) (borderchar(c) || hyphenchar(c)) -#define domainchar(c) ((c) > 0x20 && (c) < 0x7f) - -int -res_hnok(dn) - const char *dn; -{ - int pch = PERIOD, ch = *dn++; - - while (ch != '\0') { - int nch = *dn++; - - if (periodchar(ch)) { - ; - } else if (periodchar(pch)) { - if (!borderchar(ch)) - return (0); - } else if (periodchar(nch) || nch == '\0') { - if (!borderchar(ch)) - return (0); - } else { - if (!middlechar(ch)) - return (0); - } - pch = ch, ch = nch; - } - return (1); -} - -/* - * hostname-like (A, MX, WKS) owners can have "*" as their first label - * but must otherwise be as a host name. - */ -int -res_ownok(dn) - const char *dn; -{ - if (asterchar(dn[0])) { - if (periodchar(dn[1])) - return (res_hnok(dn+2)); - if (dn[1] == '\0') - return (1); - } - return (res_hnok(dn)); -} - -/* - * SOA RNAMEs and RP RNAMEs can have any printable character in their first - * label, but the rest of the name has to look like a host name. - */ -int -res_mailok(dn) - const char *dn; -{ - int ch, escaped = 0; - - /* "." is a valid missing representation */ - if (*dn == '\0') - return(1); - - /* otherwise