/*
* Copyright (c) 1999-2001, 2004, 2010, 2013 Proofpoint, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
*/
SM_RCSID("@(#)$Id: sm_gethost.c,v 8.32 2013-11-22 20:51:36 ca Exp $")
#include <sendmail.h>
#endif /* NETINET || NETINET6 */
#include "libmilter.h"
/*
** MI_GETHOSTBY{NAME,ADDR} -- compatibility routines for gethostbyXXX
**
** Some operating systems have wierd problems with the gethostbyXXX
** routines. For example, Solaris versions at least through 2.3
** don't properly deliver a canonical h_name field. This tries to
** work around these problems.
**
** Support IPv6 as well as IPv4.
*/
#if NETINET6 && NEEDSGETIPNODE
# ifndef AI_ADDRCONFIG
# endif /* ! AI_ADDRCONFIG */
# ifndef AI_ALL
# endif /* ! AI_ALL */
# ifndef AI_DEFAULT
# endif /* ! AI_DEFAULT */
static struct hostent *
const char *name;
int family;
int flags;
int *err;
{
bool resv6 = true;
struct hostent *h;
{
/* From RFC2133, section 6.1 */
}
SM_SET_H_ERRNO(0);
h = gethostbyname(name);
/* the function is supposed to return only the requested family */
{
# if NETINET6
freehostent(h);
# endif /* NETINET6 */
h = NULL;
}
else
return h;
}
void
freehostent(h)
struct hostent *h;
{
/*
** Stub routine -- if they don't have getipnodeby*(),
** they probably don't have the free routine either.
*/
return;
}
#else /* NEEDSGETIPNODE && NETINET6 */
#define sm_getipnodebyname getipnodebyname
#endif /* NEEDSGETIPNODE && NETINET6 */
struct hostent *
char *name;
int family;
{
#if (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4))
extern struct hostent *_switch_gethostbyname_r();
# else /* SOLARIS == 20300 || SOLARIS == 203 */
extern struct hostent *__switch_gethostbyname();
h = __switch_gethostbyname(name);
# endif /* SOLARIS == 20300 || SOLARIS == 203 */
#else /* (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4)) */
# if NETINET6
# ifndef SM_IPNODEBYNAME_FLAGS
/* For IPv4-mapped addresses, use: AI_DEFAULT|AI_ALL */
# endif /* SM_IPNODEBYNAME_FLAGS */
int err;
# endif /* NETINET6 */
# if NETINET6
# if ADDRCONFIG_IS_BROKEN
flags &= ~AI_ADDRCONFIG;
# endif /* ADDRCONFIG_IS_BROKEN */
# else /* NETINET6 */
h = gethostbyname(name);
# endif /* NETINET6 */
#endif /* (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4)) */
/* the function is supposed to return only the requested family */
{
# if NETINET6
freehostent(h);
# endif /* NETINET6 */
h = NULL;
}
return h;
}
#if NETINET6
/*
** MI_INET_PTON -- convert printed form to network address.
**
** Wrapper for inet_pton() which handles IPv6: labels.
**
** Parameters:
** family -- address family
** src -- string
** dst -- destination address structure
**
** Returns:
** 1 if the address was valid
** 0 if the address wasn't parseable
** -1 if error
*/
int
int family;
const char *src;
void *dst;
{
src += 5;
}
#endif /* NETINET6 */