diff --git a/kame/kame/libinet6/getaddrinfo.c b/kame/kame/libinet6/getaddrinfo.c index 65ac0f98d0..03e2e25fda 100644 --- a/kame/kame/libinet6/getaddrinfo.c +++ b/kame/kame/libinet6/getaddrinfo.c @@ -1,4 +1,4 @@ -/* $KAME: getaddrinfo.c,v 1.190 2004/06/15 07:55:55 itojun Exp $ */ +/* $KAME: getaddrinfo.c,v 1.191 2004/06/15 07:58:32 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -119,12 +119,6 @@ #include #include -#if defined(__bsdi__) && _BSDI_VERSION >= 199802 -#include -#include "port_after.h" -#include "irs_data.h" -#endif - #define ANY 0 #define YES 1 #define NO 0 @@ -3619,202 +3613,6 @@ res_querydomainN(name, domain, target) return (res_queryN(longname, target)); } -#elif defined(__bsdi__) && _BSDI_VERSION >= 199802 - -static struct net_data *init __P((void)); - -struct addrinfo *_hostent2addrinfo __P((struct hostent *, - const struct addrinfo *)); -struct addrinfo *_addr2addrinfo __P((const struct addrinfo *, - const char *)); - -/* - * 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; - struct net_data *net_data = init(); - struct irs_ho *ho; - int error = 0; - char tmp[NS_MAXDNAME]; - const char *cp; - - result = NULL; - - /* - * if the servname does not match socktype/protocol, ignore it. - */ - if (get_portmatch(pai, servname) != 0) - return(0); - - if (!net_data || !(ho = net_data->ho)) - return(0); -#if 0 /* XXX (notyet) */ - if (net_data->ho_stayopen && net_data->ho_last && - net_data->ho_last->h_addrtype == af) { - if (ns_samename(name, net_data->ho_last->h_name) == 1) - return (net_data->ho_last); - for (hap = net_data->ho_last->h_aliases; hap && *hap; hap++) - if (ns_samename(name, *hap) == 1) - return (net_data->ho_last); - } -#endif - if (!strchr(hostname, '.') && - (cp = res_hostalias(net_data->res, hostname, - tmp, sizeof(tmp)))) - hostname = cp; - result = (*ho->addrinfo)(ho, hostname, pai); - if (!net_data->ho_stayopen) { - (*ho->minimize)(ho); - } - if (result == NULL) { - int *e = __h_errno(); - - switch(*e) { - case NETDB_INTERNAL: - error = EAI_SYSTEM; - break; - case TRY_AGAIN: - error = EAI_AGAIN; - break; - case NO_RECOVERY: - error = EAI_FAIL; - break; - case HOST_NOT_FOUND: - case NO_DATA: - error = EAI_NONAME; - break; - default: - case NETDB_SUCCESS: /* should be impossible... */ - error = EAI_NONAME; - break; - } - goto free; - } - - for (cur = result; cur; cur = cur->ai_next) { - GET_PORT(cur, servname); /* XXX: redundant lookups... */ - /* canonname should already be filled. */ - } - - *res = result; - - return(0); - -free: - if (result) - freeaddrinfo(result); - return error; -} - -struct addrinfo * -_hostent2addrinfo(hp, pai) - struct hostent *hp; - const struct addrinfo *pai; -{ - int i, af, error = 0; - char **aplist = NULL, *ap; - struct addrinfo sentinel, *cur; - const struct afd *afd; - - af = hp->h_addrtype; - if (pai->ai_family != AF_UNSPEC && af != pai->ai_family) - return(NULL); - - afd = find_afd(af); - if (afd == NULL) - return(NULL); - - aplist = hp->h_addr_list; - - memset(&sentinel, 0, sizeof(sentinel)); - cur = &sentinel; - - for (i = 0; (ap = aplist[i]) != NULL; i++) { -#if 0 /* the trick seems too much */ -#ifdef INET6 - af = hp->h_addr_list; - if (af == AF_INET6 && - IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) { - af = AF_INET; - ap = ap + sizeof(struct in6_addr) - - sizeof(struct in_addr); - } - afd = find_afd(af); - if (afd == NULL) - continue; -#endif -#endif /* 0 */ - - GET_AI(cur->ai_next, afd, ap); - - /* GET_PORT(cur->ai_next, servname); */ - if ((pai->ai_flags & AI_CANONNAME) != 0) { - /* - * RFC2553 says that ai_canonname will be set only for - * the first element. we do it for all the elements, - * just for convenience. - */ - GET_CANONNAME(cur->ai_next, hp->h_name); - } - while (cur && cur->ai_next) /* no need to loop, actually. */ - cur = cur->ai_next; - continue; - - free: - if (cur->ai_next) - freeaddrinfo(cur->ai_next); - cur->ai_next = NULL; - /* continue, without tht pointer CUR advanced. */ - } - - return(sentinel.ai_next); -} - -struct addrinfo * -_addr2addrinfo(pai, cp) - const struct addrinfo *pai; - const char *cp; -{ - const struct afd *afd; - - afd = find_afd(pai->ai_family); - if (afd == NULL) - return(NULL); - - return(get_ai(pai, afd, cp)); -} - -static struct net_data * -init() -{ - struct net_data *net_data; - - if (!(net_data = net_data_init(NULL))) - goto error; - if (!net_data->ho) { - net_data->ho = (*net_data->irs->ho_map)(net_data->irs); - if (!net_data->ho || !net_data->res) { -error: - errno = EIO; - if (net_data && net_data->res) - RES_SET_H_ERRNO(net_data->res, NETDB_INTERNAL); - return (NULL); - } - - (*net_data->ho->res_set)(net_data->ho, net_data->res, NULL); - } - - return (net_data); -} - #elif defined(__FreeBSD__) static struct addrinfo *getanswer __P((const querybuf *, int, const char *,