2 * Copyright (c) 1999-2000 Sendmail, Inc. and its suppliers.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
12 static char id[] = "@(#)$Id: sm_gethost.c,v 8.7.8.2 2000/09/17 17:04:24 gshapiro Exp $";
17 #if NETINET || NETINET6
18 # include <arpa/inet.h>
19 #endif /* NETINET || NETINET6 */
22 ** MI_GETHOSTBY{NAME,ADDR} -- compatibility routines for gethostbyXXX
24 ** Some operating systems have wierd problems with the gethostbyXXX
25 ** routines. For example, Solaris versions at least through 2.3
26 ** don't properly deliver a canonical h_name field. This tries to
27 ** work around these problems.
29 ** Support IPv6 as well as IPv4.
32 #if NETINET6 && NEEDSGETIPNODE && __RES < 19990909
35 # define AI_V4MAPPED 0 /* dummy */
36 # endif /* ! AI_V4MAPPED */
38 # define AI_ALL 0 /* dummy */
39 # endif /* ! AI_ALL */
41 static struct hostent *
42 getipnodebyname(name, family, flags, err)
51 if (family == AF_INET6)
53 /* From RFC2133, section 6.1 */
54 resv6 = bitset(RES_USE_INET6, _res.options);
55 _res.options |= RES_USE_INET6;
58 h = gethostbyname(name);
60 if (family == AF_INET6 && !resv6)
61 _res.options &= ~RES_USE_INET6;
64 #endif /* NEEDSGETIPNODE && NETINET6 && __RES < 19990909 */
67 mi_gethostbyname(name, family)
71 struct hostent *h = NULL;
72 #if (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4))
73 # if SOLARIS == 20300 || SOLARIS == 203
74 static struct hostent hp;
75 static char buf[1000];
76 extern struct hostent *_switch_gethostbyname_r();
78 h = _switch_gethostbyname_r(name, &hp, buf, sizeof(buf), &h_errno);
79 # else /* SOLARIS == 20300 || SOLARIS == 203 */
80 extern struct hostent *__switch_gethostbyname();
82 h = __switch_gethostbyname(name);
83 # endif /* SOLARIS == 20300 || SOLARIS == 203 */
84 #else /* (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4)) */
87 # endif /* NETINET6 */
90 h = getipnodebyname(name, family, AI_V4MAPPED|AI_ALL, &err);
93 h = gethostbyname(name);
94 # endif /* NETINET6 */
96 #endif /* (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4)) */
99 #endif /* _FFR_MILTER */