1996-10-21 01:26:31 +00:00
|
|
|
/* The Inner Net License, Version 2.00
|
|
|
|
|
|
|
|
The author(s) grant permission for redistribution and use in source and
|
|
|
|
binary forms, with or without modification, of the software and documentation
|
|
|
|
provided that the following conditions are met:
|
|
|
|
|
|
|
|
0. If you receive a version of the software that is specifically labelled
|
|
|
|
as not being for redistribution (check the version message and/or README),
|
|
|
|
you are not permitted to redistribute that version of the software in any
|
|
|
|
way or form.
|
|
|
|
1. All terms of the all other applicable copyrights and licenses must be
|
|
|
|
followed.
|
|
|
|
2. Redistributions of source code must retain the authors' copyright
|
|
|
|
notice(s), this list of conditions, and the following disclaimer.
|
|
|
|
3. Redistributions in binary form must reproduce the authors' copyright
|
|
|
|
notice(s), this list of conditions, and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
2002-07-06 06:36:39 +00:00
|
|
|
4. [The copyright holder has authorized the removal of this clause.]
|
1996-10-21 01:26:31 +00:00
|
|
|
5. Neither the name(s) of the author(s) 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 ITS AUTHORS 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 AUTHORS 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.
|
|
|
|
|
|
|
|
If these license terms cause you a real problem, contact the author. */
|
|
|
|
|
|
|
|
/* This software is Copyright 1996 by Craig Metz, All Rights Reserved. */
|
|
|
|
|
2000-03-23 21:34:58 +00:00
|
|
|
#include <assert.h>
|
2006-05-04 06:38:07 +00:00
|
|
|
#include <ctype.h>
|
2000-03-23 21:34:58 +00:00
|
|
|
#include <errno.h>
|
2003-04-24 23:45:17 +00:00
|
|
|
#include <ifaddrs.h>
|
2000-03-23 21:34:58 +00:00
|
|
|
#include <netdb.h>
|
2008-05-10 23:27:39 +00:00
|
|
|
#include <nss.h>
|
2000-05-27 08:09:40 +00:00
|
|
|
#include <resolv.h>
|
2003-04-25 17:54:19 +00:00
|
|
|
#include <stdbool.h>
|
2000-03-23 21:34:58 +00:00
|
|
|
#include <stdio.h>
|
2006-05-04 06:38:07 +00:00
|
|
|
#include <stdio_ext.h>
|
1996-10-21 01:26:31 +00:00
|
|
|
#include <stdlib.h>
|
2000-03-23 21:34:58 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <arpa/inet.h>
|
2006-05-04 06:38:07 +00:00
|
|
|
#include <net/if.h>
|
2004-12-22 20:10:10 +00:00
|
|
|
#include <netinet/in.h>
|
2006-05-04 06:38:07 +00:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/stat.h>
|
2000-03-23 21:34:58 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/un.h>
|
|
|
|
#include <sys/utsname.h>
|
2006-05-04 06:38:07 +00:00
|
|
|
#include <unistd.h>
|
2002-11-20 19:48:07 +00:00
|
|
|
#include <nsswitch.h>
|
2006-05-04 06:38:07 +00:00
|
|
|
#include <bits/libc-lock.h>
|
2003-11-18 07:04:13 +00:00
|
|
|
#include <not-cancel.h>
|
2004-09-15 08:25:49 +00:00
|
|
|
#include <nscd/nscd-client.h>
|
2004-09-16 22:54:54 +00:00
|
|
|
#include <nscd/nscd_proto.h>
|
2008-05-14 21:53:48 +00:00
|
|
|
#include <resolv/res_hconf.h>
|
1997-02-19 04:43:53 +00:00
|
|
|
|
2004-03-13 06:53:42 +00:00
|
|
|
#ifdef HAVE_LIBIDN
|
2004-03-08 04:10:31 +00:00
|
|
|
extern int __idna_to_ascii_lz (const char *input, char **output, int flags);
|
2004-03-13 06:53:42 +00:00
|
|
|
extern int __idna_to_unicode_lzlz (const char *input, char **output,
|
|
|
|
int flags);
|
|
|
|
# include <libidn/idna.h>
|
|
|
|
#endif
|
2004-03-08 04:10:31 +00:00
|
|
|
|
1996-10-21 01:26:31 +00:00
|
|
|
#define GAIH_OKIFUNSPEC 0x0100
|
|
|
|
#define GAIH_EAI ~(GAIH_OKIFUNSPEC)
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
#ifndef UNIX_PATH_MAX
|
2006-04-16 21:34:32 +00:00
|
|
|
# define UNIX_PATH_MAX 108
|
1997-08-20 03:53:21 +00:00
|
|
|
#endif
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
struct gaih_service
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
int num;
|
|
|
|
};
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
struct gaih_servtuple
|
|
|
|
{
|
|
|
|
struct gaih_servtuple *next;
|
|
|
|
int socktype;
|
|
|
|
int protocol;
|
|
|
|
int port;
|
|
|
|
};
|
1996-10-21 01:26:31 +00:00
|
|
|
|
2001-01-21 19:30:28 +00:00
|
|
|
static const struct gaih_servtuple nullserv;
|
1996-10-21 01:26:31 +00:00
|
|
|
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
struct gaih_typeproto
|
|
|
|
{
|
|
|
|
int socktype;
|
|
|
|
int protocol;
|
2008-05-14 17:33:37 +00:00
|
|
|
uint8_t protoflag;
|
|
|
|
bool defaultflag;
|
|
|
|
char name[8];
|
1997-08-20 03:53:21 +00:00
|
|
|
};
|
1996-10-21 01:26:31 +00:00
|
|
|
|
2000-01-05 21:32:20 +00:00
|
|
|
/* Values for `protoflag'. */
|
|
|
|
#define GAI_PROTO_NOSERVICE 1
|
2000-11-10 04:15:55 +00:00
|
|
|
#define GAI_PROTO_PROTOANY 2
|
2000-01-05 21:32:20 +00:00
|
|
|
|
2001-01-21 19:30:28 +00:00
|
|
|
static const struct gaih_typeproto gaih_inet_typeproto[] =
|
1997-08-20 03:53:21 +00:00
|
|
|
{
|
2008-05-14 17:33:37 +00:00
|
|
|
{ 0, 0, 0, false, "" },
|
|
|
|
{ SOCK_STREAM, IPPROTO_TCP, 0, true, "tcp" },
|
|
|
|
{ SOCK_DGRAM, IPPROTO_UDP, 0, true, "udp" },
|
|
|
|
#if defined SOCK_DCCP && defined IPPROTO_DCCP
|
|
|
|
{ SOCK_DCCP, IPPROTO_DCCP, 0, false, "dccp" },
|
|
|
|
#endif
|
|
|
|
#ifdef IPPROTO_UDPLITE
|
|
|
|
{ SOCK_DGRAM, IPPROTO_UDPLITE, 0, false, "udplite" },
|
2008-05-14 17:55:57 +00:00
|
|
|
#endif
|
|
|
|
#ifdef IPPROTO_SCTP
|
|
|
|
{ SOCK_STREAM, IPPROTO_SCTP, 0, false, "sctp" },
|
|
|
|
{ SOCK_SEQPACKET, IPPROTO_SCTP, 0, false, "sctp" },
|
2008-05-14 17:33:37 +00:00
|
|
|
#endif
|
|
|
|
{ SOCK_RAW, 0, GAI_PROTO_PROTOANY|GAI_PROTO_NOSERVICE, true, "raw" },
|
|
|
|
{ 0, 0, 0, false, "" }
|
1996-10-21 01:26:31 +00:00
|
|
|
};
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
struct gaih
|
|
|
|
{
|
|
|
|
int family;
|
|
|
|
int (*gaih)(const char *name, const struct gaih_service *service,
|
2005-11-27 23:13:21 +00:00
|
|
|
const struct addrinfo *req, struct addrinfo **pai,
|
|
|
|
unsigned int *naddrs);
|
1997-08-20 03:53:21 +00:00
|
|
|
};
|
|
|
|
|
2001-01-21 19:30:28 +00:00
|
|
|
static const struct addrinfo default_hints =
|
2003-04-24 23:45:17 +00:00
|
|
|
{
|
|
|
|
.ai_flags = AI_DEFAULT,
|
|
|
|
.ai_family = PF_UNSPEC,
|
|
|
|
.ai_socktype = 0,
|
|
|
|
.ai_protocol = 0,
|
|
|
|
.ai_addrlen = 0,
|
|
|
|
.ai_addr = NULL,
|
|
|
|
.ai_canonname = NULL,
|
|
|
|
.ai_next = NULL
|
|
|
|
};
|
1997-08-20 03:53:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
static int
|
2001-01-21 19:30:28 +00:00
|
|
|
gaih_inet_serv (const char *servicename, const struct gaih_typeproto *tp,
|
2006-04-16 21:34:32 +00:00
|
|
|
const struct addrinfo *req, struct gaih_servtuple *st)
|
1996-10-21 01:26:31 +00:00
|
|
|
{
|
|
|
|
struct servent *s;
|
1997-08-20 03:53:21 +00:00
|
|
|
size_t tmpbuflen = 1024;
|
1997-03-29 17:32:35 +00:00
|
|
|
struct servent ts;
|
1997-08-20 03:53:21 +00:00
|
|
|
char *tmpbuf;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
do
|
1997-03-29 17:32:35 +00:00
|
|
|
{
|
1997-08-20 03:53:21 +00:00
|
|
|
tmpbuf = __alloca (tmpbuflen);
|
|
|
|
|
|
|
|
r = __getservbyname_r (servicename, tp->name, &ts, tmpbuf, tmpbuflen,
|
|
|
|
&s);
|
1999-09-12 19:24:42 +00:00
|
|
|
if (r != 0 || s == NULL)
|
1997-03-29 17:32:35 +00:00
|
|
|
{
|
1999-09-12 19:24:42 +00:00
|
|
|
if (r == ERANGE)
|
1997-08-20 03:53:21 +00:00
|
|
|
tmpbuflen *= 2;
|
|
|
|
else
|
|
|
|
return GAIH_OKIFUNSPEC | -EAI_SERVICE;
|
1997-03-29 17:32:35 +00:00
|
|
|
}
|
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
while (r);
|
1997-03-29 17:32:35 +00:00
|
|
|
|
1999-05-02 21:03:32 +00:00
|
|
|
st->next = NULL;
|
|
|
|
st->socktype = tp->socktype;
|
2000-11-10 04:15:55 +00:00
|
|
|
st->protocol = ((tp->protoflag & GAI_PROTO_PROTOANY)
|
|
|
|
? req->ai_protocol : tp->protocol);
|
1999-05-02 21:03:32 +00:00
|
|
|
st->port = s->s_port;
|
1996-10-21 01:26:31 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-04-24 23:45:17 +00:00
|
|
|
#define gethosts(_family, _type) \
|
|
|
|
{ \
|
2004-08-15 22:39:07 +00:00
|
|
|
int i; \
|
|
|
|
int herrno; \
|
2003-04-24 23:45:17 +00:00
|
|
|
struct hostent th; \
|
2004-09-06 08:26:59 +00:00
|
|
|
struct hostent *h; \
|
2004-09-17 23:47:50 +00:00
|
|
|
char *localcanon = NULL; \
|
2003-04-24 23:45:17 +00:00
|
|
|
no_data = 0; \
|
2004-08-15 22:39:07 +00:00
|
|
|
while (1) { \
|
2003-04-24 23:45:17 +00:00
|
|
|
rc = 0; \
|
2004-09-18 06:46:52 +00:00
|
|
|
status = DL_CALL_FCT (fct, (name, _family, &th, tmpbuf, tmpbuflen, \
|
|
|
|
&rc, &herrno, NULL, &localcanon)); \
|
2004-08-15 22:39:07 +00:00
|
|
|
if (rc != ERANGE || herrno != NETDB_INTERNAL) \
|
|
|
|
break; \
|
|
|
|
tmpbuf = extend_alloca (tmpbuf, tmpbuflen, 2 * tmpbuflen); \
|
|
|
|
} \
|
2003-04-24 23:45:17 +00:00
|
|
|
if (status == NSS_STATUS_SUCCESS && rc == 0) \
|
|
|
|
h = &th; \
|
|
|
|
else \
|
|
|
|
h = NULL; \
|
|
|
|
if (rc != 0) \
|
|
|
|
{ \
|
|
|
|
if (herrno == NETDB_INTERNAL) \
|
|
|
|
{ \
|
|
|
|
__set_h_errno (herrno); \
|
2008-05-10 23:27:39 +00:00
|
|
|
_res.options = old_res_options; \
|
2003-04-24 23:45:17 +00:00
|
|
|
return -EAI_SYSTEM; \
|
|
|
|
} \
|
|
|
|
if (herrno == TRY_AGAIN) \
|
|
|
|
no_data = EAI_AGAIN; \
|
|
|
|
else \
|
|
|
|
no_data = herrno == NO_DATA; \
|
|
|
|
} \
|
|
|
|
else if (h != NULL) \
|
|
|
|
{ \
|
|
|
|
for (i = 0; h->h_addr_list[i]; i++) \
|
|
|
|
{ \
|
2004-08-15 20:23:40 +00:00
|
|
|
if (*pat == NULL) \
|
|
|
|
{ \
|
|
|
|
*pat = __alloca (sizeof (struct gaih_addrtuple)); \
|
|
|
|
(*pat)->scopeid = 0; \
|
|
|
|
} \
|
|
|
|
uint32_t *addr = (*pat)->addr; \
|
2003-04-24 23:45:17 +00:00
|
|
|
(*pat)->next = NULL; \
|
2004-09-06 08:15:50 +00:00
|
|
|
(*pat)->name = i == 0 ? strdupa (h->h_name) : NULL; \
|
2004-08-15 20:23:40 +00:00
|
|
|
if (_family == AF_INET && req->ai_family == AF_INET6) \
|
|
|
|
{ \
|
|
|
|
(*pat)->family = AF_INET6; \
|
|
|
|
addr[3] = *(uint32_t *) h->h_addr_list[i]; \
|
|
|
|
addr[2] = htonl (0xffff); \
|
|
|
|
addr[1] = 0; \
|
|
|
|
addr[0] = 0; \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
(*pat)->family = _family; \
|
|
|
|
memcpy (addr, h->h_addr_list[i], sizeof(_type)); \
|
|
|
|
} \
|
2003-04-24 23:45:17 +00:00
|
|
|
pat = &((*pat)->next); \
|
|
|
|
} \
|
2004-08-15 20:23:40 +00:00
|
|
|
\
|
2004-09-18 06:46:52 +00:00
|
|
|
if (localcanon != NULL && canon == NULL) \
|
2004-09-17 23:47:50 +00:00
|
|
|
canon = strdupa (localcanon); \
|
|
|
|
\
|
2004-08-15 20:23:40 +00:00
|
|
|
if (_family == AF_INET6 && i > 0) \
|
|
|
|
got_ipv6 = true; \
|
2003-04-24 23:45:17 +00:00
|
|
|
} \
|
2002-11-20 19:48:07 +00:00
|
|
|
}
|
|
|
|
|
2004-08-15 20:23:40 +00:00
|
|
|
|
2008-05-10 23:27:39 +00:00
|
|
|
typedef enum nss_status (*nss_gethostbyname4_r)
|
|
|
|
(const char *name, struct gaih_addrtuple **pat,
|
|
|
|
char *buffer, size_t buflen, int *errnop,
|
|
|
|
int *h_errnop, int32_t *ttlp);
|
2004-09-17 23:47:50 +00:00
|
|
|
typedef enum nss_status (*nss_gethostbyname3_r)
|
2002-11-20 19:48:07 +00:00
|
|
|
(const char *name, int af, struct hostent *host,
|
|
|
|
char *buffer, size_t buflen, int *errnop,
|
2004-09-17 23:47:50 +00:00
|
|
|
int *h_errnop, int32_t *ttlp, char **canonp);
|
2004-08-15 20:23:40 +00:00
|
|
|
typedef enum nss_status (*nss_getcanonname_r)
|
|
|
|
(const char *name, char *buffer, size_t buflen, char **result,
|
|
|
|
int *errnop, int *h_errnop);
|
2002-11-20 19:48:07 +00:00
|
|
|
extern service_user *__nss_hosts_database attribute_hidden;
|
|
|
|
|
2006-04-16 21:34:32 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
static int
|
|
|
|
gaih_inet (const char *name, const struct gaih_service *service,
|
2005-11-27 23:13:21 +00:00
|
|
|
const struct addrinfo *req, struct addrinfo **pai,
|
|
|
|
unsigned int *naddrs)
|
1996-10-21 01:26:31 +00:00
|
|
|
{
|
2001-01-21 19:30:28 +00:00
|
|
|
const struct gaih_typeproto *tp = gaih_inet_typeproto;
|
|
|
|
struct gaih_servtuple *st = (struct gaih_servtuple *) &nullserv;
|
1997-02-19 04:43:53 +00:00
|
|
|
struct gaih_addrtuple *at = NULL;
|
1997-08-20 03:53:21 +00:00
|
|
|
int rc;
|
2003-04-24 23:45:17 +00:00
|
|
|
bool got_ipv6 = false;
|
2004-08-15 20:23:40 +00:00
|
|
|
const char *canon = NULL;
|
2004-08-18 08:22:52 +00:00
|
|
|
const char *orig_name = name;
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if (req->ai_protocol || req->ai_socktype)
|
|
|
|
{
|
2000-01-05 21:32:20 +00:00
|
|
|
++tp;
|
|
|
|
|
2001-02-02 08:24:56 +00:00
|
|
|
while (tp->name[0]
|
2000-01-18 09:56:22 +00:00
|
|
|
&& ((req->ai_socktype != 0 && req->ai_socktype != tp->socktype)
|
|
|
|
|| (req->ai_protocol != 0
|
2000-11-10 04:15:55 +00:00
|
|
|
&& !(tp->protoflag & GAI_PROTO_PROTOANY)
|
2000-01-18 09:56:22 +00:00
|
|
|
&& req->ai_protocol != tp->protocol)))
|
2000-01-05 21:32:20 +00:00
|
|
|
++tp;
|
|
|
|
|
2001-02-02 08:24:56 +00:00
|
|
|
if (! tp->name[0])
|
1998-09-09 11:53:19 +00:00
|
|
|
{
|
|
|
|
if (req->ai_socktype)
|
2006-04-16 21:34:32 +00:00
|
|
|
return GAIH_OKIFUNSPEC | -EAI_SOCKTYPE;
|
1998-09-09 11:53:19 +00:00
|
|
|
else
|
2006-04-16 21:34:32 +00:00
|
|
|
return GAIH_OKIFUNSPEC | -EAI_SERVICE;
|
1998-09-09 11:53:19 +00:00
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
}
|
|
|
|
|
2005-11-27 22:58:34 +00:00
|
|
|
int port = 0;
|
1997-08-20 03:53:21 +00:00
|
|
|
if (service != NULL)
|
|
|
|
{
|
2000-01-05 21:32:20 +00:00
|
|
|
if ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0)
|
2006-04-16 21:34:32 +00:00
|
|
|
return GAIH_OKIFUNSPEC | -EAI_SERVICE;
|
2000-01-05 21:32:20 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if (service->num < 0)
|
|
|
|
{
|
2001-02-02 08:24:56 +00:00
|
|
|
if (tp->name[0])
|
1997-08-20 03:53:21 +00:00
|
|
|
{
|
1999-05-02 21:03:32 +00:00
|
|
|
st = (struct gaih_servtuple *)
|
|
|
|
__alloca (sizeof (struct gaih_servtuple));
|
|
|
|
|
2000-11-10 04:15:55 +00:00
|
|
|
if ((rc = gaih_inet_serv (service->name, tp, req, st)))
|
1997-08-20 03:53:21 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct gaih_servtuple **pst = &st;
|
2001-02-02 08:24:56 +00:00
|
|
|
for (tp++; tp->name[0]; tp++)
|
1997-08-20 03:53:21 +00:00
|
|
|
{
|
2000-01-18 09:56:22 +00:00
|
|
|
struct gaih_servtuple *newp;
|
|
|
|
|
|
|
|
if ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0)
|
|
|
|
continue;
|
|
|
|
|
2000-09-29 05:29:24 +00:00
|
|
|
if (req->ai_socktype != 0
|
|
|
|
&& req->ai_socktype != tp->socktype)
|
|
|
|
continue;
|
2000-11-10 04:15:55 +00:00
|
|
|
if (req->ai_protocol != 0
|
|
|
|
&& !(tp->protoflag & GAI_PROTO_PROTOANY)
|
|
|
|
&& req->ai_protocol != tp->protocol)
|
|
|
|
continue;
|
2000-09-29 05:29:24 +00:00
|
|
|
|
2000-01-18 09:56:22 +00:00
|
|
|
newp = (struct gaih_servtuple *)
|
1999-05-02 21:03:32 +00:00
|
|
|
__alloca (sizeof (struct gaih_servtuple));
|
|
|
|
|
2000-11-10 04:15:55 +00:00
|
|
|
if ((rc = gaih_inet_serv (service->name, tp, req, newp)))
|
1997-08-20 03:53:21 +00:00
|
|
|
{
|
|
|
|
if (rc & GAIH_OKIFUNSPEC)
|
|
|
|
continue;
|
|
|
|
return rc;
|
|
|
|
}
|
1999-05-02 21:03:32 +00:00
|
|
|
|
|
|
|
*pst = newp;
|
|
|
|
pst = &(newp->next);
|
1997-08-20 03:53:21 +00:00
|
|
|
}
|
2001-01-21 19:30:28 +00:00
|
|
|
if (st == (struct gaih_servtuple *) &nullserv)
|
2006-04-16 21:34:32 +00:00
|
|
|
return GAIH_OKIFUNSPEC | -EAI_SERVICE;
|
1997-08-20 03:53:21 +00:00
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
else
|
|
|
|
{
|
2005-11-27 22:58:34 +00:00
|
|
|
port = htons (service->num);
|
|
|
|
goto got_port;
|
1996-10-21 01:26:31 +00:00
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
}
|
2000-09-29 05:29:24 +00:00
|
|
|
else
|
|
|
|
{
|
2005-11-27 22:58:34 +00:00
|
|
|
got_port:
|
|
|
|
|
|
|
|
if (req->ai_socktype || req->ai_protocol)
|
|
|
|
{
|
|
|
|
st = __alloca (sizeof (struct gaih_servtuple));
|
|
|
|
st->next = NULL;
|
|
|
|
st->socktype = tp->socktype;
|
|
|
|
st->protocol = ((tp->protoflag & GAI_PROTO_PROTOANY)
|
|
|
|
? req->ai_protocol : tp->protocol);
|
|
|
|
st->port = port;
|
|
|
|
}
|
|
|
|
else
|
2000-09-29 05:29:24 +00:00
|
|
|
{
|
2005-11-27 22:58:34 +00:00
|
|
|
/* Neither socket type nor protocol is set. Return all socket types
|
|
|
|
we know about. */
|
|
|
|
struct gaih_servtuple **lastp = &st;
|
|
|
|
for (++tp; tp->name[0]; ++tp)
|
2008-05-14 17:33:37 +00:00
|
|
|
if (tp->defaultflag)
|
|
|
|
{
|
|
|
|
struct gaih_servtuple *newp;
|
|
|
|
|
|
|
|
newp = __alloca (sizeof (struct gaih_servtuple));
|
|
|
|
newp->next = NULL;
|
|
|
|
newp->socktype = tp->socktype;
|
|
|
|
newp->protocol = tp->protocol;
|
|
|
|
newp->port = port;
|
|
|
|
|
|
|
|
*lastp = newp;
|
|
|
|
lastp = &newp->next;
|
|
|
|
}
|
2000-09-29 05:29:24 +00:00
|
|
|
}
|
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
|
|
|
|
if (name != NULL)
|
|
|
|
{
|
1999-09-12 19:24:42 +00:00
|
|
|
at = __alloca (sizeof (struct gaih_addrtuple));
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1999-09-12 19:24:42 +00:00
|
|
|
at->family = AF_UNSPEC;
|
2000-03-23 21:34:58 +00:00
|
|
|
at->scopeid = 0;
|
1997-08-20 03:53:21 +00:00
|
|
|
at->next = NULL;
|
1996-10-21 01:26:31 +00:00
|
|
|
|
2004-03-08 04:10:31 +00:00
|
|
|
#ifdef HAVE_LIBIDN
|
|
|
|
if (req->ai_flags & AI_IDN)
|
|
|
|
{
|
2004-03-17 20:02:19 +00:00
|
|
|
int idn_flags = 0;
|
|
|
|
if (req->ai_flags & AI_IDN_ALLOW_UNASSIGNED)
|
|
|
|
idn_flags |= IDNA_ALLOW_UNASSIGNED;
|
|
|
|
if (req->ai_flags & AI_IDN_USE_STD3_ASCII_RULES)
|
|
|
|
idn_flags |= IDNA_USE_STD3_ASCII_RULES;
|
|
|
|
|
2004-03-08 04:10:31 +00:00
|
|
|
char *p = NULL;
|
2004-03-17 20:02:19 +00:00
|
|
|
rc = __idna_to_ascii_lz (name, &p, idn_flags);
|
2004-03-08 04:10:31 +00:00
|
|
|
if (rc != IDNA_SUCCESS)
|
2004-03-13 06:53:42 +00:00
|
|
|
{
|
|
|
|
if (rc == IDNA_MALLOC_ERROR)
|
|
|
|
return -EAI_MEMORY;
|
|
|
|
if (rc == IDNA_DLOPEN_ERROR)
|
|
|
|
return -EAI_SYSTEM;
|
|
|
|
return -EAI_IDN_ENCODE;
|
|
|
|
}
|
|
|
|
/* In case the output string is the same as the input string
|
|
|
|
no new string has been allocated. */
|
|
|
|
if (p != name)
|
|
|
|
{
|
|
|
|
name = strdupa (p);
|
|
|
|
free (p);
|
|
|
|
}
|
2004-03-08 04:10:31 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-08-05 09:45:35 +00:00
|
|
|
if (__inet_aton (name, (struct in_addr *) at->addr) != 0)
|
1999-09-12 19:24:42 +00:00
|
|
|
{
|
|
|
|
if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET)
|
|
|
|
at->family = AF_INET;
|
2006-04-30 20:19:09 +00:00
|
|
|
else if (req->ai_family == AF_INET6 && (req->ai_flags & AI_V4MAPPED))
|
2003-04-24 23:45:17 +00:00
|
|
|
{
|
2004-08-15 20:23:40 +00:00
|
|
|
at->addr[3] = at->addr[0];
|
|
|
|
at->addr[2] = htonl (0xffff);
|
|
|
|
at->addr[1] = 0;
|
|
|
|
at->addr[0] = 0;
|
2004-08-05 09:45:35 +00:00
|
|
|
at->family = AF_INET6;
|
2003-04-24 23:45:17 +00:00
|
|
|
}
|
1999-09-12 19:24:42 +00:00
|
|
|
else
|
|
|
|
return -EAI_ADDRFAMILY;
|
2004-09-28 07:11:00 +00:00
|
|
|
|
|
|
|
if (req->ai_flags & AI_CANONNAME)
|
2006-03-29 17:52:29 +00:00
|
|
|
canon = name;
|
1999-09-12 19:24:42 +00:00
|
|
|
}
|
2006-03-29 17:52:29 +00:00
|
|
|
else if (at->family == AF_UNSPEC)
|
1999-09-12 19:24:42 +00:00
|
|
|
{
|
2005-11-03 18:56:56 +00:00
|
|
|
char *namebuf = (char *) name;
|
|
|
|
char *scope_delim = strchr (name, SCOPE_DELIMITER);
|
2000-03-23 21:34:58 +00:00
|
|
|
|
2005-11-03 18:56:56 +00:00
|
|
|
if (__builtin_expect (scope_delim != NULL, 0))
|
|
|
|
{
|
|
|
|
namebuf = alloca (scope_delim - name + 1);
|
|
|
|
*((char *) __mempcpy (namebuf, name, scope_delim - name)) = '\0';
|
|
|
|
}
|
2000-03-23 21:34:58 +00:00
|
|
|
|
|
|
|
if (inet_pton (AF_INET6, namebuf, at->addr) > 0)
|
|
|
|
{
|
|
|
|
if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET6)
|
|
|
|
at->family = AF_INET6;
|
Update.
2004-08-04 Jakub Jelinek <jakub@redhat.com>
* hesiod/hesiod.c (__hesiod_res_get): Use calloc instead of malloc +
memset.
(__hesiod_res_set): Free nsaddrs.
* include/resolv.h (__res_maybe_init): Add prototype.
* resolv/resolv.h (struct __res_state): Add _u._ext.initstamp field.
* resolv/Versions (libc): Add __res_maybe_init@@GLIBC_PRIVATE.
* resolv/res_libc.c (__res_initstamp, lock): New variables.
(res_init): Increase __res_initstamp.
(__res_maybe_init): New function.
* resolv/res_init.c (__res_vinit): Initialize _u._ext.initstamp.
* hesiod/hesiod.c (__hesiod_res_get): Use __res_maybe_init instead
of RES_INIT check and {res_ninit,__res_ninit,res_init} call.
* sysdeps/posix/getaddrinfo.c (gaih_inet): Likewise.
* resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname2_r,
_nss_dns_gethostbyaddr_r): Likewise.
* resolv/nss_dns/dns-network.c (_nss_dns_getnetbyname_r,
_nss_dns_getnetbyaddr_r): Likewise.
* resolv/gethnamaddr.c (gethostbyname, gethostbyname2,
gethostbyaddr): Likewise.
* resolv/res_data.c (fp_nquery, res_mkquery, res_mkupdate,
res_isourserver, res_sendsigned, res_update, res_search,
res_querydomain): Likewise.
* nss/getXXbyYY_r.c (INTERNAL (REENTRANT_NAME)): Likewise.
* nss/digits_dots.c (__nss_hostname_digits_dots): Likewise.
* nss/getnssent_r.c (__nss_setent, __nss_endent, __nss_getent_r):
Likewise.
* sysdeps/posix/getaddrinfo.c (gaih_inet): Set ai_family for
V4-mapped IPv6 addresses and req->ai_family==AF_INET.
Reported by A. Guru <a.guru@sympatico.ca>.
* po/pl.po: Likewise.
characters than necessary.
2004-08-05 23:32:24 +00:00
|
|
|
else if (req->ai_family == AF_INET
|
|
|
|
&& IN6_IS_ADDR_V4MAPPED (at->addr))
|
|
|
|
{
|
2004-08-15 20:23:40 +00:00
|
|
|
at->addr[0] = at->addr[3];
|
Update.
2004-08-04 Jakub Jelinek <jakub@redhat.com>
* hesiod/hesiod.c (__hesiod_res_get): Use calloc instead of malloc +
memset.
(__hesiod_res_set): Free nsaddrs.
* include/resolv.h (__res_maybe_init): Add prototype.
* resolv/resolv.h (struct __res_state): Add _u._ext.initstamp field.
* resolv/Versions (libc): Add __res_maybe_init@@GLIBC_PRIVATE.
* resolv/res_libc.c (__res_initstamp, lock): New variables.
(res_init): Increase __res_initstamp.
(__res_maybe_init): New function.
* resolv/res_init.c (__res_vinit): Initialize _u._ext.initstamp.
* hesiod/hesiod.c (__hesiod_res_get): Use __res_maybe_init instead
of RES_INIT check and {res_ninit,__res_ninit,res_init} call.
* sysdeps/posix/getaddrinfo.c (gaih_inet): Likewise.
* resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname2_r,
_nss_dns_gethostbyaddr_r): Likewise.
* resolv/nss_dns/dns-network.c (_nss_dns_getnetbyname_r,
_nss_dns_getnetbyaddr_r): Likewise.
* resolv/gethnamaddr.c (gethostbyname, gethostbyname2,
gethostbyaddr): Likewise.
* resolv/res_data.c (fp_nquery, res_mkquery, res_mkupdate,
res_isourserver, res_sendsigned, res_update, res_search,
res_querydomain): Likewise.
* nss/getXXbyYY_r.c (INTERNAL (REENTRANT_NAME)): Likewise.
* nss/digits_dots.c (__nss_hostname_digits_dots): Likewise.
* nss/getnssent_r.c (__nss_setent, __nss_endent, __nss_getent_r):
Likewise.
* sysdeps/posix/getaddrinfo.c (gaih_inet): Set ai_family for
V4-mapped IPv6 addresses and req->ai_family==AF_INET.
Reported by A. Guru <a.guru@sympatico.ca>.
* po/pl.po: Likewise.
characters than necessary.
2004-08-05 23:32:24 +00:00
|
|
|
at->family = AF_INET;
|
|
|
|
}
|
2000-03-23 21:34:58 +00:00
|
|
|
else
|
|
|
|
return -EAI_ADDRFAMILY;
|
|
|
|
|
|
|
|
if (scope_delim != NULL)
|
|
|
|
{
|
|
|
|
int try_numericscope = 0;
|
|
|
|
if (IN6_IS_ADDR_LINKLOCAL (at->addr)
|
|
|
|
|| IN6_IS_ADDR_MC_LINKLOCAL (at->addr))
|
|
|
|
{
|
|
|
|
at->scopeid = if_nametoindex (scope_delim + 1);
|
|
|
|
if (at->scopeid == 0)
|
|
|
|
try_numericscope = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
try_numericscope = 1;
|
|
|
|
|
|
|
|
if (try_numericscope != 0)
|
|
|
|
{
|
|
|
|
char *end;
|
|
|
|
assert (sizeof (uint32_t) <= sizeof (unsigned long));
|
|
|
|
at->scopeid = (uint32_t) strtoul (scope_delim + 1, &end,
|
|
|
|
10);
|
|
|
|
if (*end != '\0')
|
|
|
|
return GAIH_OKIFUNSPEC | -EAI_NONAME;
|
|
|
|
}
|
|
|
|
}
|
2004-09-28 07:11:00 +00:00
|
|
|
|
2006-03-29 17:52:29 +00:00
|
|
|
if (req->ai_flags & AI_CANONNAME)
|
|
|
|
canon = name;
|
2000-03-23 21:34:58 +00:00
|
|
|
}
|
1999-09-12 19:24:42 +00:00
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
|
2000-01-12 11:39:14 +00:00
|
|
|
if (at->family == AF_UNSPEC && (req->ai_flags & AI_NUMERICHOST) == 0)
|
1997-08-20 03:53:21 +00:00
|
|
|
{
|
|
|
|
struct gaih_addrtuple **pat = &at;
|
1999-09-12 19:24:42 +00:00
|
|
|
int no_data = 0;
|
2002-11-20 19:48:07 +00:00
|
|
|
int no_inet6_data = 0;
|
2004-08-15 20:23:40 +00:00
|
|
|
service_user *nip = NULL;
|
|
|
|
enum nss_status inet6_status = NSS_STATUS_UNAVAIL;
|
|
|
|
enum nss_status status = NSS_STATUS_UNAVAIL;
|
|
|
|
int no_more;
|
|
|
|
int old_res_options;
|
2004-09-15 08:25:49 +00:00
|
|
|
|
|
|
|
/* If we do not have to look for IPv4 and IPv6 together, use
|
|
|
|
the simple, old functions. */
|
2005-11-03 18:56:56 +00:00
|
|
|
if (req->ai_family == AF_INET
|
|
|
|
|| (req->ai_family == AF_INET6
|
|
|
|
&& ((req->ai_flags & AI_V4MAPPED) == 0
|
|
|
|
|| (req->ai_flags & AI_ALL) == 0)))
|
2004-09-15 08:25:49 +00:00
|
|
|
{
|
|
|
|
int family = req->ai_family;
|
|
|
|
size_t tmpbuflen = 512;
|
|
|
|
char *tmpbuf = alloca (tmpbuflen);
|
|
|
|
int rc;
|
|
|
|
struct hostent th;
|
|
|
|
struct hostent *h;
|
|
|
|
int herrno;
|
|
|
|
|
|
|
|
simple_again:
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
rc = __gethostbyname2_r (name, family, &th, tmpbuf,
|
|
|
|
tmpbuflen, &h, &herrno);
|
|
|
|
if (rc != ERANGE || herrno != NETDB_INTERNAL)
|
|
|
|
break;
|
|
|
|
tmpbuf = extend_alloca (tmpbuf, tmpbuflen, 2 * tmpbuflen);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc == 0)
|
|
|
|
{
|
|
|
|
if (h == NULL)
|
|
|
|
{
|
|
|
|
if (req->ai_family == AF_INET6
|
|
|
|
&& (req->ai_flags & AI_V4MAPPED)
|
|
|
|
&& family == AF_INET6)
|
|
|
|
{
|
|
|
|
/* Try again, this time looking for IPv4
|
|
|
|
addresses. */
|
|
|
|
family = AF_INET;
|
|
|
|
goto simple_again;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We found data, now convert it into the list. */
|
|
|
|
for (int i = 0; h->h_addr_list[i]; ++i)
|
|
|
|
{
|
|
|
|
if (*pat == NULL)
|
|
|
|
{
|
|
|
|
*pat = __alloca (sizeof (struct gaih_addrtuple));
|
|
|
|
(*pat)->scopeid = 0;
|
|
|
|
}
|
|
|
|
(*pat)->next = NULL;
|
|
|
|
(*pat)->family = req->ai_family;
|
|
|
|
if (family == req->ai_family)
|
|
|
|
memcpy ((*pat)->addr, h->h_addr_list[i],
|
|
|
|
h->h_length);
|
|
|
|
else
|
|
|
|
{
|
[BZ #284, BZ #721]
* intl/dcigettext.c (_nl_find_msg): Add a cast.
* nis/nis_clone_dir.c (nis_clone_directory): Use char * for ADDR.
* nis/nis_clone_obj.c (nis_clone_object): Likewise.
* nis/nis_clone_res.c (nis_clone_result): Likewise.
* resolv/nss_dns/dns-network.c (getanswer_r): Use const unsigned char *
for END_OF_MESSAGE and CP.
* resolv/res_send.c (send_dg): Add else branch for case impossible
unless `poll' is buggy.
* crypt/crypt_util.c (__setkey_r): Add a cast.
* locale/programs/linereader.c (get_toplvl_escape): Use size_t for
NBYTES, and unsigned char * for BYTES.
* locale/programs/charmap.c (charmap_new_char): Use size_t and
unsighed char * for NBYTES, BYTES parameters.
* sysdeps/generic/dl-hash.h (_dl_elf_hash): Take const char * argument
and cast it.
* sysdeps/i386/i686/dl-hash.h (_dl_elf_hash): Likewise.
* sunrpc/create_xid.c (_create_xid): Don't use unsigned long for RES.
* sunrpc/svcauth_des.c (_svcauth_des): Fix cast type.
* sunrpc/auth_des.c (authdes_create): Don't use u_char for PKEY_DATA.
(authdes_marshal): Don't use unsigned int for LEN.
* sunrpc/xdr.c (xdr_hyper): Don't use unsigned long for T2.
(xdr_u_hyper): Likewise.
(xdr_u_short): Don't use u_long for L.
* sunrpc/xdr_intXX_t.c (xdr_int64_t): Don't use uint32_t for T2.
* inet/rexec.c (rexec_af): Use socklen_t.
* sunrpc/key_call.c (getkeyserv_handle): Likewise.
* sunrpc/rtime.c (rtime): Likewise.
* resolv/res_send.c (send_vc, send_dg): Likewise.
* nis/nis_callback.c (__nis_create_callback): Likewise.
* sysdeps/generic/libc-start.c: Use unsigned int for nthreads ptr.
* sysdeps/posix/getaddrinfo.c (gaih_inet): Fix type of ADDR local.
* libio/libio.h (_IO_BE): Add parenthesis around EXPR.
* intl/dcigettext.c (INTVARDEF, INTUSE): Macros removed.
(_nl_default_dirname): Use libc_hidden_data_def instead of INTVARDEF.
(libc_freeres_fn, DCIGETTEXT): Don't use INTUSE.
* intl/bindtextdom.c (INTUSE): Macro removed.
(_nl_default_dirname): Use libc_hidden_proto.
(set_binding_values): Don't use INTUSE.
* include/libintl.h (_libc_intl_domainname_internal): Decl removed.
(_libc_intl_domainname): Use libc_hidden_proto.
* posix/regex_internal.h (gettext): Remove INTUSE on it.
* locale/SYS_libc.c (_libc_intl_domainname): Use libc_hidden_data_def
rather than INTDEF.
* include/libintl.h (_): Don't use *_internal name.
* ctype/ctype-extn.c (__ctype_tolower, __ctype_toupper): Use int32_t,
not uint32_t.
* locale/lc-ctype.c (_nl_postload_ctype): Likewise for assignments.
* iconv/gconv_open.c (__gconv_open): Remove useless cast.
[BZ #721]
* sysdeps/i386/dl-machine.h (ELF_MACHINE_NO_RELA): Define this outside
of [RESOLVE_MAP].
* sysdeps/sh/dl-machine.h (ELF_MACHINE_NO_REL): Likewise.
* sysdeps/powerpc/powerpc32/dl-machine.h
(elf_machine_rel, elf_machine_rel_relative): Removed.
* sysdeps/powerpc/powerpc64/dl-machine.h
(elf_machine_rel, elf_machine_rel_relative): Removed.
2005-02-03 Alexandre Oliva <aoliva@redhat.com>
[BZ #721]
* elf/dynamic-link.h: Don't declare nested auto functions that are
not going to be defined.
2004-07-23 Jakub Jelinek <jakub@redhat.com>
[BZ #284]
* include/features.h (_POSIX_SOURCE, _POSIX_C_SOURCE): Define
if _XOPEN_SOURCE >= 500 even if __STRICT_ANSI__ is defined.
2005-02-16 Roland McGrath <roland@redhat.com>
2005-02-17 01:19:55 +00:00
|
|
|
uint32_t *addr = (uint32_t *) (*pat)->addr;
|
2004-09-15 08:25:49 +00:00
|
|
|
addr[3] = *(uint32_t *) h->h_addr_list[i];
|
|
|
|
addr[2] = htonl (0xffff);
|
|
|
|
addr[1] = 0;
|
|
|
|
addr[0] = 0;
|
|
|
|
}
|
|
|
|
pat = &((*pat)->next);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (herrno == NETDB_INTERNAL)
|
|
|
|
{
|
|
|
|
__set_h_errno (herrno);
|
|
|
|
return -EAI_SYSTEM;
|
|
|
|
}
|
|
|
|
if (herrno == TRY_AGAIN)
|
|
|
|
{
|
|
|
|
return -EAI_AGAIN;
|
|
|
|
}
|
|
|
|
/* We made requests but they turned out no data.
|
|
|
|
The name is known, though. */
|
2006-04-16 21:34:32 +00:00
|
|
|
return GAIH_OKIFUNSPEC | -EAI_NODATA;
|
2004-09-15 08:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
goto process_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef USE_NSCD
|
2004-09-16 22:54:54 +00:00
|
|
|
if (__nss_not_use_nscd_hosts > 0
|
|
|
|
&& ++__nss_not_use_nscd_hosts > NSS_NSCD_RETRY)
|
|
|
|
__nss_not_use_nscd_hosts = 0;
|
2004-09-15 08:25:49 +00:00
|
|
|
|
2004-09-16 22:54:54 +00:00
|
|
|
if (!__nss_not_use_nscd_hosts)
|
|
|
|
{
|
|
|
|
/* Try to use nscd. */
|
|
|
|
struct nscd_ai_result *air = NULL;
|
|
|
|
int herrno;
|
|
|
|
int err = __nscd_getai (name, &air, &herrno);
|
|
|
|
if (air != NULL)
|
2004-09-15 08:25:49 +00:00
|
|
|
{
|
2004-09-16 22:54:54 +00:00
|
|
|
/* Transform into gaih_addrtuple list. */
|
|
|
|
bool added_canon = (req->ai_flags & AI_CANONNAME) == 0;
|
|
|
|
char *addrs = air->addrs;
|
2004-09-15 08:25:49 +00:00
|
|
|
|
2004-09-16 22:54:54 +00:00
|
|
|
for (int i = 0; i < air->naddrs; ++i)
|
2004-09-15 08:25:49 +00:00
|
|
|
{
|
2004-09-16 22:54:54 +00:00
|
|
|
socklen_t size = (air->family[i] == AF_INET
|
|
|
|
? INADDRSZ : IN6ADDRSZ);
|
|
|
|
if (*pat == NULL)
|
|
|
|
{
|
|
|
|
*pat = __alloca (sizeof (struct gaih_addrtuple));
|
|
|
|
(*pat)->scopeid = 0;
|
|
|
|
}
|
|
|
|
uint32_t *pataddr = (*pat)->addr;
|
|
|
|
(*pat)->next = NULL;
|
|
|
|
if (added_canon || air->canon == NULL)
|
|
|
|
(*pat)->name = NULL;
|
|
|
|
else
|
|
|
|
canon = (*pat)->name = strdupa (air->canon);
|
|
|
|
|
|
|
|
if (air->family[i] == AF_INET
|
|
|
|
&& req->ai_family == AF_INET6
|
|
|
|
&& (req->ai_flags & AI_V4MAPPED))
|
|
|
|
{
|
|
|
|
(*pat)->family = AF_INET6;
|
|
|
|
pataddr[3] = *(uint32_t *) addrs;
|
|
|
|
pataddr[2] = htonl (0xffff);
|
|
|
|
pataddr[1] = 0;
|
|
|
|
pataddr[0] = 0;
|
|
|
|
pat = &((*pat)->next);
|
|
|
|
added_canon = true;
|
|
|
|
}
|
|
|
|
else if (req->ai_family == AF_UNSPEC
|
|
|
|
|| air->family[i] == req->ai_family)
|
|
|
|
{
|
|
|
|
(*pat)->family = air->family[i];
|
|
|
|
memcpy (pataddr, addrs, size);
|
|
|
|
pat = &((*pat)->next);
|
|
|
|
added_canon = true;
|
|
|
|
if (air->family[i] == AF_INET6)
|
|
|
|
got_ipv6 = true;
|
|
|
|
}
|
|
|
|
addrs += size;
|
2004-09-15 08:25:49 +00:00
|
|
|
}
|
|
|
|
|
2004-11-22 18:43:44 +00:00
|
|
|
free (air);
|
|
|
|
|
2004-09-16 22:54:54 +00:00
|
|
|
if (at->family == AF_UNSPEC)
|
2006-04-16 21:34:32 +00:00
|
|
|
return GAIH_OKIFUNSPEC | -EAI_NONAME;
|
2004-09-15 08:25:49 +00:00
|
|
|
|
2004-09-16 22:54:54 +00:00
|
|
|
goto process_list;
|
|
|
|
}
|
2008-05-17 21:44:56 +00:00
|
|
|
else if (err == 0)
|
|
|
|
/* The database contains a negative entry. */
|
|
|
|
return 0;
|
|
|
|
else if (__nss_not_use_nscd_hosts == 0)
|
2004-09-16 22:54:54 +00:00
|
|
|
{
|
|
|
|
if (herrno == NETDB_INTERNAL && errno == ENOMEM)
|
|
|
|
return -EAI_MEMORY;
|
|
|
|
if (herrno == TRY_AGAIN)
|
|
|
|
return -EAI_AGAIN;
|
|
|
|
return -EAI_SYSTEM;
|
|
|
|
}
|
2004-09-15 08:25:49 +00:00
|
|
|
}
|
|
|
|
#endif
|
2004-08-15 20:23:40 +00:00
|
|
|
|
|
|
|
if (__nss_hosts_database != NULL)
|
|
|
|
{
|
|
|
|
no_more = 0;
|
|
|
|
nip = __nss_hosts_database;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
no_more = __nss_database_lookup ("hosts", NULL,
|
|
|
|
"dns [!UNAVAIL=return] files",
|
|
|
|
&nip);
|
|
|
|
|
2008-06-13 23:35:47 +00:00
|
|
|
/* Initialize configurations. */
|
|
|
|
if (__builtin_expect (!_res_hconf.initialized, 0))
|
|
|
|
_res_hconf_init ();
|
2004-08-15 20:23:40 +00:00
|
|
|
if (__res_maybe_init (&_res, 0) == -1)
|
|
|
|
no_more = 1;
|
|
|
|
|
2000-05-27 08:09:40 +00:00
|
|
|
/* If we are looking for both IPv4 and IPv6 address we don't
|
|
|
|
want the lookup functions to automatically promote IPv4
|
|
|
|
addresses to IPv6 addresses. Currently this is decided
|
|
|
|
by setting the RES_USE_INET6 bit in _res.options. */
|
2004-08-15 20:23:40 +00:00
|
|
|
old_res_options = _res.options;
|
|
|
|
_res.options &= ~RES_USE_INET6;
|
1997-08-20 03:53:21 +00:00
|
|
|
|
2008-07-30 19:14:32 +00:00
|
|
|
size_t tmpbuflen = 1024;
|
2004-09-15 08:25:49 +00:00
|
|
|
char *tmpbuf = alloca (tmpbuflen);
|
|
|
|
|
2004-08-15 20:23:40 +00:00
|
|
|
while (!no_more)
|
|
|
|
{
|
2008-05-10 23:27:39 +00:00
|
|
|
nss_gethostbyname4_r fct4
|
|
|
|
= __nss_lookup_function (nip, "gethostbyname4_r");
|
|
|
|
if (fct4 != NULL)
|
2002-11-20 19:48:07 +00:00
|
|
|
{
|
2008-05-10 23:27:39 +00:00
|
|
|
int herrno;
|
|
|
|
|
|
|
|
while (1)
|
2002-12-17 01:16:31 +00:00
|
|
|
{
|
2008-05-10 23:27:39 +00:00
|
|
|
rc = 0;
|
|
|
|
status = DL_CALL_FCT (fct4, (name, pat, tmpbuf,
|
|
|
|
tmpbuflen, &rc, &herrno,
|
|
|
|
NULL));
|
2008-12-29 23:47:07 +00:00
|
|
|
if (status == NSS_STATUS_SUCCESS)
|
|
|
|
break;
|
2008-05-10 23:27:39 +00:00
|
|
|
if (status != NSS_STATUS_TRYAGAIN
|
|
|
|
|| rc != ERANGE || herrno != NETDB_INTERNAL)
|
|
|
|
{
|
|
|
|
if (herrno == NETDB_INTERNAL)
|
|
|
|
{
|
|
|
|
__set_h_errno (herrno);
|
|
|
|
_res.options = old_res_options;
|
|
|
|
return -EAI_SYSTEM;
|
|
|
|
}
|
|
|
|
if (herrno == TRY_AGAIN)
|
|
|
|
no_data = EAI_AGAIN;
|
|
|
|
else
|
|
|
|
no_data = herrno == NO_DATA;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tmpbuf = extend_alloca (tmpbuf,
|
|
|
|
tmpbuflen, 2 * tmpbuflen);
|
2002-12-17 01:16:31 +00:00
|
|
|
}
|
2008-05-10 23:27:39 +00:00
|
|
|
|
2008-12-03 07:30:39 +00:00
|
|
|
no_inet6_data = no_data;
|
|
|
|
|
2008-05-10 23:27:39 +00:00
|
|
|
if (status == NSS_STATUS_SUCCESS)
|
2004-08-15 20:23:40 +00:00
|
|
|
{
|
2008-05-16 15:36:26 +00:00
|
|
|
if ((req->ai_flags & AI_CANONNAME) != 0 && canon == NULL)
|
|
|
|
canon = (*pat)->name;
|
2002-11-20 19:48:07 +00:00
|
|
|
|
2008-05-10 23:27:39 +00:00
|
|
|
while (*pat != NULL)
|
|
|
|
pat = &((*pat)->next);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nss_gethostbyname3_r fct = NULL;
|
|
|
|
if (req->ai_flags & AI_CANONNAME)
|
|
|
|
/* No need to use this function if we do not look for
|
|
|
|
the canonical name. The function does not exist in
|
|
|
|
all NSS modules and therefore the lookup would
|
|
|
|
often fail. */
|
|
|
|
fct = __nss_lookup_function (nip, "gethostbyname3_r");
|
|
|
|
if (fct == NULL)
|
|
|
|
/* We are cheating here. The gethostbyname2_r
|
|
|
|
function does not have the same interface as
|
|
|
|
gethostbyname3_r but the extra arguments the
|
|
|
|
latter takes are added at the end. So the
|
|
|
|
gethostbyname2_r code will just ignore them. */
|
|
|
|
fct = __nss_lookup_function (nip, "gethostbyname2_r");
|
|
|
|
|
|
|
|
if (fct != NULL)
|
|
|
|
{
|
|
|
|
if (req->ai_family == AF_INET6
|
|
|
|
|| req->ai_family == AF_UNSPEC)
|
2004-08-15 20:23:40 +00:00
|
|
|
{
|
2008-05-10 23:27:39 +00:00
|
|
|
gethosts (AF_INET6, struct in6_addr);
|
2004-08-15 20:23:40 +00:00
|
|
|
no_inet6_data = no_data;
|
|
|
|
inet6_status = status;
|
|
|
|
}
|
2008-05-10 23:27:39 +00:00
|
|
|
if (req->ai_family == AF_INET
|
|
|
|
|| req->ai_family == AF_UNSPEC
|
|
|
|
|| (req->ai_family == AF_INET6
|
|
|
|
&& (req->ai_flags & AI_V4MAPPED)
|
|
|
|
/* Avoid generating the mapped addresses if we
|
|
|
|
know we are not going to need them. */
|
|
|
|
&& ((req->ai_flags & AI_ALL) || !got_ipv6)))
|
2004-08-15 20:23:40 +00:00
|
|
|
{
|
2008-05-10 23:27:39 +00:00
|
|
|
gethosts (AF_INET, struct in_addr);
|
2004-08-19 21:39:39 +00:00
|
|
|
|
2008-05-10 23:27:39 +00:00
|
|
|
if (req->ai_family == AF_INET)
|
2004-08-19 21:39:39 +00:00
|
|
|
{
|
2008-05-10 23:27:39 +00:00
|
|
|
no_inet6_data = no_data;
|
|
|
|
inet6_status = status;
|
2004-08-19 21:39:39 +00:00
|
|
|
}
|
2004-08-15 20:23:40 +00:00
|
|
|
}
|
|
|
|
|
2008-05-10 23:27:39 +00:00
|
|
|
/* If we found one address for AF_INET or AF_INET6,
|
|
|
|
don't continue the search. */
|
|
|
|
if (inet6_status == NSS_STATUS_SUCCESS
|
|
|
|
|| status == NSS_STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
if ((req->ai_flags & AI_CANONNAME) != 0
|
|
|
|
&& canon == NULL)
|
|
|
|
{
|
|
|
|
/* If we need the canonical name, get it
|
|
|
|
from the same service as the result. */
|
|
|
|
nss_getcanonname_r cfct;
|
|
|
|
int herrno;
|
|
|
|
|
|
|
|
cfct = __nss_lookup_function (nip,
|
|
|
|
"getcanonname_r");
|
|
|
|
if (cfct != NULL)
|
|
|
|
{
|
|
|
|
const size_t max_fqdn_len = 256;
|
|
|
|
char *buf = alloca (max_fqdn_len);
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
if (DL_CALL_FCT (cfct, (at->name ?: name,
|
|
|
|
buf, max_fqdn_len,
|
|
|
|
&s, &rc, &herrno))
|
|
|
|
== NSS_STATUS_SUCCESS)
|
|
|
|
canon = s;
|
|
|
|
else
|
|
|
|
/* Set to name now to avoid using
|
|
|
|
gethostbyaddr. */
|
|
|
|
canon = name;
|
|
|
|
}
|
|
|
|
}
|
2004-08-15 20:23:40 +00:00
|
|
|
|
2008-05-10 23:27:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We can have different states for AF_INET and
|
|
|
|
AF_INET6. Try to find a useful one for both. */
|
|
|
|
if (inet6_status == NSS_STATUS_TRYAGAIN)
|
|
|
|
status = NSS_STATUS_TRYAGAIN;
|
|
|
|
else if (status == NSS_STATUS_UNAVAIL
|
|
|
|
&& inet6_status != NSS_STATUS_UNAVAIL)
|
|
|
|
status = inet6_status;
|
|
|
|
}
|
2002-11-20 19:48:07 +00:00
|
|
|
}
|
|
|
|
|
2004-08-15 20:23:40 +00:00
|
|
|
if (nss_next_action (nip, status) == NSS_ACTION_RETURN)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (nip->next == NULL)
|
|
|
|
no_more = -1;
|
|
|
|
else
|
|
|
|
nip = nip->next;
|
2003-06-12 22:31:43 +00:00
|
|
|
}
|
1999-09-12 19:24:42 +00:00
|
|
|
|
2004-08-15 20:23:40 +00:00
|
|
|
_res.options = old_res_options;
|
|
|
|
|
1999-12-08 09:15:00 +00:00
|
|
|
if (no_data != 0 && no_inet6_data != 0)
|
2000-11-18 08:30:20 +00:00
|
|
|
{
|
|
|
|
/* If both requests timed out report this. */
|
|
|
|
if (no_data == EAI_AGAIN && no_inet6_data == EAI_AGAIN)
|
|
|
|
return -EAI_AGAIN;
|
|
|
|
|
|
|
|
/* We made requests but they turned out no data. The name
|
|
|
|
is known, though. */
|
2006-04-16 21:34:32 +00:00
|
|
|
return GAIH_OKIFUNSPEC | -EAI_NODATA;
|
2000-11-18 08:30:20 +00:00
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
|
2004-09-15 08:25:49 +00:00
|
|
|
process_list:
|
1997-08-20 03:53:21 +00:00
|
|
|
if (at->family == AF_UNSPEC)
|
2006-04-16 21:34:32 +00:00
|
|
|
return GAIH_OKIFUNSPEC | -EAI_NONAME;
|
1996-10-21 01:26:31 +00:00
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
else
|
|
|
|
{
|
1999-07-28 03:27:45 +00:00
|
|
|
struct gaih_addrtuple *atr;
|
1999-09-12 19:24:42 +00:00
|
|
|
atr = at = __alloca (sizeof (struct gaih_addrtuple));
|
|
|
|
memset (at, '\0', sizeof (struct gaih_addrtuple));
|
1997-08-20 03:53:21 +00:00
|
|
|
|
2004-08-15 20:23:40 +00:00
|
|
|
if (req->ai_family == AF_UNSPEC)
|
1999-07-28 03:27:45 +00:00
|
|
|
{
|
1999-09-12 19:24:42 +00:00
|
|
|
at->next = __alloca (sizeof (struct gaih_addrtuple));
|
|
|
|
memset (at->next, '\0', sizeof (struct gaih_addrtuple));
|
1999-07-28 03:27:45 +00:00
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
|
2004-08-15 20:23:40 +00:00
|
|
|
if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET6)
|
1999-07-28 03:27:45 +00:00
|
|
|
{
|
|
|
|
at->family = AF_INET6;
|
|
|
|
if ((req->ai_flags & AI_PASSIVE) == 0)
|
* sysdeps/posix/system.c (do_system): New function, guts broken out of
__libc_system.
(__libc_system): Call it, putting just the line == NULL test here.
* include/libc-symbols.h (__hidden_proto): Add extern keywords so
variables work right.
* elf/dl-open.c (dl_open_worker): Use _ macro instead of gettext.
* elf/dl-close.c (_dl_close): Likewise.
* include/netinet/in.h: Use libc_hidden_proto for bindresvport,
in6addr_any, in6addr_loopback. Remove decls for
bindresvport_internal, in6addr_any_internal, in6addr_loopback_internal.
* sunrpc/svc_udp.c (svcudp_bufcreate): Nix INTUSE for bindresvport.
* sunrpc/svc_tcp.c (svctcp_create): Likewise.
* sunrpc/clnt_udp.c (clntudp_bufcreate): Likewise.
* sunrpc/bindrsvprt.c: Change INTDEF to libc_hidden_def.
* inet/in6_addr.c: Change INTVARDEF to libc_hidden_def.
* sysdeps/posix/getaddrinfo.c (gaih_inet): Nix INTUSE for
in6addr_loopback.
* inet/gethstbyad_r.c (PREPROCESS): Nix INTUSE for in6addr_any.
* include/netinet/ether.h: Use libc_hidden_proto for ether_ntoa_r,
ether_aton_r.
* inet/ether_aton_r.c: Add libc_hidden_def.
* inet/ether_ntoa_r.c: Likewise.
* include/rpc/auth.h: Use libc_hidden_proto for getnetname,
netname2user, host2netname.
* sunrpc/netname.c: Add libc_hidden_def.
* include/netdb.h: Use libc_hidden_proto for innetgr, rcmd_af,
rexec_af, rresvport_af, ruserok_af.
* inet/rcmd.c: Add libc_hidden_def.
* inet/getnetgrent_r.c: Likewise.
2002-08-06 04:30:03 +00:00
|
|
|
memcpy (at->addr, &in6addr_loopback, sizeof (struct in6_addr));
|
1999-07-28 03:27:45 +00:00
|
|
|
atr = at->next;
|
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
|
2004-08-15 20:23:40 +00:00
|
|
|
if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET)
|
1999-07-28 03:27:45 +00:00
|
|
|
{
|
|
|
|
atr->family = AF_INET;
|
|
|
|
if ((req->ai_flags & AI_PASSIVE) == 0)
|
2004-08-15 20:23:40 +00:00
|
|
|
atr->addr[0] = htonl (INADDR_LOOPBACK);
|
1999-07-28 03:27:45 +00:00
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
}
|
1997-02-19 04:43:53 +00:00
|
|
|
|
1996-10-21 01:26:31 +00:00
|
|
|
{
|
|
|
|
struct gaih_servtuple *st2;
|
|
|
|
struct gaih_addrtuple *at2 = at;
|
2004-08-15 20:23:40 +00:00
|
|
|
size_t socklen;
|
2000-11-10 04:15:55 +00:00
|
|
|
sa_family_t family;
|
1997-08-20 03:53:21 +00:00
|
|
|
|
Update.
1997-07-13 01:18 Ulrich Drepper <drepper@cygnus.com>
* setjmp/setjmp.h: Define _setjmp and _longjmp also if __USE_XOPEN.
* sysdeps/unix/sysv/linux/bits/ipc.h: Fix comment.
* sysdeps/unix/sysv/linux/bits/msq.h: Likewise.
* sysdeps/unix/sysv/linux/bits/sem.h: Likewise.
* sysdeps/unix/sysv/linux/bits/shm.h: Likewise.
* time/Makefile (routines): Add getdate.
* time/time.h: Add prototype for getdate and getdate_r.
* time/getdate.c: New file.
Provided by Mark Kettenis <kettenis@phys.uva.nl>.
1997-06-30 14:49 H.J. Lu <hjl@gnu.ai.mit.edu>
From Ralf Baechle <ralf@informatik.uni-koblenz.de> on
Sat Jun 21 18:11:21 1997:
* sysdeps/unix/sysv/linux/syscalls.list (swapon): Add __swapon alias.
(swapoff): New.
* elf/Makefile: Add linker script support.
(headers): Add bits/dlfcn.h.
* elf/dl-load.c (MAP_BASE_ADDR): New.
* elf/dlfcn.h: Include <bits/dlfcn.h>.
* elf/elf.h: Add MIPS support.
* sysdeps/generic/Dist: Add entry.h.
* sysdeps/generic/entry.h: New, define the entry symbol.
* elf/rtld.c (_start): Include <entry.h>. Change to ENTRY_POINT.
* sysdeps/generic/dl-sysdep.c (_start): Likewise.
* mips/elf/start.S (_start): Likewise.
* sysdeps/mips/bsd-_setjmp.S: Fix PIC.
* sysdeps/mips/bsd-setjmp.S: Likewise.
* sysdeps/mips/setjmp.S: Likewise.
* mips/elf/start.S: Likewise.
* sysdeps/unix/mips/brk.S: Likewise.
* sysdeps/unix/mips/sysdep.S: Likewise.
* sysdeps/unix/mips/sysdep.h: Likewise.
* sysdeps/unix/mips/wait.S: Likewise.
* sysdeps/mips/dl-machine.h: Update for Linux/MIPS.
* sysdeps/mips/fpu_control.h: Likewise.
* sysdeps/generic/bits/dlfcn.h: New file.
* sysdeps/mips/rtld-ldscript.in: New for Linux/MIPS.
* sysdeps/mips/rtld-parms: Likewise.
* sysdeps/mips/bits/dlfcn.h: Likewise.
* sysdeps/mips/mips64/rtld-parms: Likewise.
* sysdeps/mips/mipsel/rtld-parms: Likewise.
* sysdeps/unix/sysv/linux/mips/Dist: Likewise.
* sysdeps/unix/sysv/linux/mips/Makefile: Likewise.
* sysdeps/unix/sysv/linux/mips/clone.S: Likewise.
* sysdeps/unix/sysv/linux/mips/entry.h: Likewise.
* sysdeps/unix/sysv/linux/mips/fpregdef.h: Likewise.
* sysdeps/unix/sysv/linux/mips/fxstat.c: Likewise.
* sysdeps/unix/sysv/linux/mips/kernel_sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/mips/kernel_stat.h: Likewise.
* sysdeps/unix/sysv/linux/mips/kernel_termios.h: Likewise.
* sysdeps/unix/sysv/linux/mips/lxstat.c: Likewise.
* sysdeps/unix/sysv/linux/mips/regdef.h: Likewise.
* sysdeps/unix/sysv/linux/mips/sgidefs.h: Likewise.
* sysdeps/unix/sysv/linux/mips/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/mips/ustat.c: Likewise.
* sysdeps/unix/sysv/linux/mips/xmknod.c: Likewise.
* sysdeps/unix/sysv/linux/mips/xstat.c: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/endian.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/fcntl.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/ioctl-types.h:
* sysdeps/unix/sysv/linux/mips/bits/ipc.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/shm.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/signum.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/socket.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/stat.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/statfs.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/termios.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/time.h: Likewise.
* sysdeps/unix/sysv/linux/mips/sys/acct.h: Likewise.
* sysdeps/unix/sysv/linux/mips/sys/asm.h: Likewise.
* sysdeps/unix/sysv/linux/mips/sys/cachectl.h: Likewise.
* sysdeps/unix/sysv/linux/mips/sys/fpregdef.h: Likewise.
* sysdeps/unix/sysv/linux/mips/sys/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/mips/sys/regdef.h: Likewise.
* sysdeps/unix/sysv/linux/mips/sys/syscall.h: Likewise.
* sysdeps/unix/sysv/linux/mips/sys/sysmips.h: Likewise.
1997-04-09 19:05 H.J. Lu (hjl@gnu.ai.mit.edu)
* isomac.c (xstrndup): New, use it instead of strndup ().
1997-07-02 08:55 H.J. Lu <hjl@gnu.ai.mit.edu>
* sysdeps/i386/dl-machine.h (elf_machine_rel): Print
the program name for different sizes.
1997-07-10 15:47 Fila Kolodny <fila@ibi.com>
* nis/ypclnt.c: Change references to MAXHOSTNAMELEN to NIS_MAXNAMELEN.
Add include of rpcsvc/nis.h.
* inet/getnameinfo.c: Delete references to MAXHOSTNAMELEN.
* sysdeps/posix/getaddrinfo.c: Likewise.
Change size of variable buffer to be big enough to hold an IPv6
address in printable format.
1997-07-12 18:47 Ulrich Drepper <drepper@cygnus.com>
* assert/assert.h [!NDEBUG] (assert, assert_perror): Don't use ||
and && in tests to allow use in C++ code which overloads these
operators. Reported by Istvan Marko <istvan@cmdmail.amd.com>.
* configure.in: Move mips64* recognition before mips*.
Patch by Zack Weinberg <zack@rabi.phys.columbia.edu>.
1997-07-03 20:44 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* Makerules (lib%.so, $(common-objpfx)libc.so): Don't use
automatic variables in dependency lists.
(build-shlib): Always filter out the version script file.
* extra-lib.mk ($(objpfx)$(lib).so): Depend on version script.
1997-07-12 17:56 Ulrich Drepper <drepper@cygnus.com>
* login/login.c (tty_name): Test return value of ttyname_r for !=
0, not < 0.
* misc/ttyslot.c (ttyslot): Test return value of ttyname_r for ==
0, not >= 0.
* sysdeps/unix/getlogin.c (getlogin): Test return value of
ttyname_r for != 0.
* sysdeps/unix/getlogin_r.c (getlogin_r): Likewise.
1997-07-10 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* login/utmp_file.c (getutline_r_file): Fix type: compare with
*result.
1997-07-11 00:21 Mark Kettenis <kettenis@phys.uva.nl>
* login/Makefile (headers): Add utmpx.h and bits/utmpx.h.
1997-07-09 19:21 Mark Kettenis <kettenis@phys.uva.nl>
* login/programs/utmpd.c, login/programs/database.c,
login/programs/request.c: Prepare messages for
internationalization.
* login/programs/utmpd.c:
(main): Change handling of errors in opening the database.
* login/programs/database.c:
(open_database, synchronize_dtatabase, initialize_database):
Properly handle errors.
(get_mtime): Use fstat instead of stat. All callers changed.
* login/getutent_r.c: Make setutxent a weak alias for __setutxent.
* login/getutent.c: Rename getutent to __getutent and make
getutent a weak alias.
Make getutxent a weak alias for __getutent.
* login/utmpx.h: New file.
* sysdeps/gnu/bits/utmp.h: Cleanup. Added comments.
* sysdeps/gnu/bits/utmpx.h: New file.
* stdio-common/strops.c: Partialy undo last change. Will need
more investigation.
1997-07-12 23:35:19 +00:00
|
|
|
/*
|
|
|
|
buffer is the size of an unformatted IPv6 address in printable format.
|
|
|
|
*/
|
1997-08-20 03:53:21 +00:00
|
|
|
while (at2 != NULL)
|
|
|
|
{
|
2004-06-19 00:01:42 +00:00
|
|
|
/* Only the first entry gets the canonical name. */
|
|
|
|
if (at2 == at && (req->ai_flags & AI_CANONNAME) != 0)
|
1997-08-20 03:53:21 +00:00
|
|
|
{
|
2004-08-15 20:23:40 +00:00
|
|
|
if (canon == NULL)
|
1997-08-20 03:53:21 +00:00
|
|
|
{
|
2004-08-15 20:23:40 +00:00
|
|
|
struct hostent *h = NULL;
|
|
|
|
int herrno;
|
|
|
|
struct hostent th;
|
|
|
|
size_t tmpbuflen = 512;
|
|
|
|
char *tmpbuf = NULL;
|
1997-08-20 03:53:21 +00:00
|
|
|
|
2004-08-15 20:23:40 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
tmpbuf = extend_alloca (tmpbuf, tmpbuflen, tmpbuflen * 2);
|
|
|
|
rc = __gethostbyaddr_r (at2->addr,
|
|
|
|
((at2->family == AF_INET6)
|
|
|
|
? sizeof (struct in6_addr)
|
|
|
|
: sizeof (struct in_addr)),
|
|
|
|
at2->family, &th, tmpbuf,
|
|
|
|
tmpbuflen, &h, &herrno);
|
|
|
|
}
|
|
|
|
while (rc == ERANGE && herrno == NETDB_INTERNAL);
|
1997-08-20 03:53:21 +00:00
|
|
|
|
2004-08-15 20:23:40 +00:00
|
|
|
if (rc != 0 && herrno == NETDB_INTERNAL)
|
2002-08-29 08:51:26 +00:00
|
|
|
{
|
2004-08-15 20:23:40 +00:00
|
|
|
__set_h_errno (herrno);
|
|
|
|
return -EAI_SYSTEM;
|
2002-08-29 08:51:26 +00:00
|
|
|
}
|
|
|
|
|
2004-08-15 20:23:40 +00:00
|
|
|
if (h != NULL)
|
|
|
|
canon = h->h_name;
|
|
|
|
else
|
|
|
|
{
|
2004-08-18 08:22:52 +00:00
|
|
|
assert (orig_name != NULL);
|
2004-08-15 20:23:40 +00:00
|
|
|
/* If the canonical name cannot be determined, use
|
|
|
|
the passed in string. */
|
2004-08-18 08:22:52 +00:00
|
|
|
canon = orig_name;
|
2004-08-15 20:23:40 +00:00
|
|
|
}
|
2002-08-29 08:51:26 +00:00
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
|
2004-03-13 06:53:42 +00:00
|
|
|
#ifdef HAVE_LIBIDN
|
|
|
|
if (req->ai_flags & AI_CANONIDN)
|
|
|
|
{
|
2004-03-17 20:02:19 +00:00
|
|
|
int idn_flags = 0;
|
|
|
|
if (req->ai_flags & AI_IDN_ALLOW_UNASSIGNED)
|
|
|
|
idn_flags |= IDNA_ALLOW_UNASSIGNED;
|
|
|
|
if (req->ai_flags & AI_IDN_USE_STD3_ASCII_RULES)
|
|
|
|
idn_flags |= IDNA_USE_STD3_ASCII_RULES;
|
|
|
|
|
2004-03-13 06:53:42 +00:00
|
|
|
char *out;
|
2004-08-15 20:23:40 +00:00
|
|
|
int rc = __idna_to_unicode_lzlz (canon, &out, idn_flags);
|
2004-03-13 06:53:42 +00:00
|
|
|
if (rc != IDNA_SUCCESS)
|
|
|
|
{
|
|
|
|
if (rc == IDNA_MALLOC_ERROR)
|
|
|
|
return -EAI_MEMORY;
|
|
|
|
if (rc == IDNA_DLOPEN_ERROR)
|
|
|
|
return -EAI_SYSTEM;
|
|
|
|
return -EAI_IDN_ENCODE;
|
|
|
|
}
|
|
|
|
/* In case the output string is the same as the input
|
2008-05-16 15:36:26 +00:00
|
|
|
string no new string has been allocated and we
|
2004-08-18 05:10:14 +00:00
|
|
|
make a copy. */
|
|
|
|
if (out == canon)
|
|
|
|
goto make_copy;
|
2004-03-13 06:53:42 +00:00
|
|
|
}
|
2004-08-18 05:10:14 +00:00
|
|
|
else
|
2004-03-13 06:53:42 +00:00
|
|
|
#endif
|
2004-08-18 05:10:14 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_LIBIDN
|
|
|
|
make_copy:
|
|
|
|
#endif
|
|
|
|
canon = strdup (canon);
|
|
|
|
if (canon == NULL)
|
|
|
|
return -EAI_MEMORY;
|
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
}
|
|
|
|
|
2005-11-03 18:56:56 +00:00
|
|
|
family = at2->family;
|
|
|
|
if (family == AF_INET6)
|
2000-11-10 04:15:55 +00:00
|
|
|
{
|
|
|
|
socklen = sizeof (struct sockaddr_in6);
|
2003-04-24 23:45:17 +00:00
|
|
|
|
|
|
|
/* If we looked up IPv4 mapped address discard them here if
|
|
|
|
the caller isn't interested in all address and we have
|
|
|
|
found at least one IPv6 address. */
|
2004-08-15 20:23:40 +00:00
|
|
|
if (got_ipv6
|
2003-04-24 23:45:17 +00:00
|
|
|
&& (req->ai_flags & (AI_V4MAPPED|AI_ALL)) == AI_V4MAPPED
|
|
|
|
&& IN6_IS_ADDR_V4MAPPED (at2->addr))
|
|
|
|
goto ignore;
|
2000-11-10 04:15:55 +00:00
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
else
|
2005-11-03 18:56:56 +00:00
|
|
|
socklen = sizeof (struct sockaddr_in);
|
1997-08-20 03:53:21 +00:00
|
|
|
|
|
|
|
for (st2 = st; st2 != NULL; st2 = st2->next)
|
|
|
|
{
|
2004-08-19 22:56:27 +00:00
|
|
|
struct addrinfo *ai;
|
|
|
|
ai = *pai = malloc (sizeof (struct addrinfo) + socklen);
|
|
|
|
if (ai == NULL)
|
2006-05-10 00:03:41 +00:00
|
|
|
{
|
|
|
|
free ((char *) canon);
|
|
|
|
return -EAI_MEMORY;
|
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
|
2004-08-19 22:56:27 +00:00
|
|
|
ai->ai_flags = req->ai_flags;
|
|
|
|
ai->ai_family = family;
|
|
|
|
ai->ai_socktype = st2->socktype;
|
|
|
|
ai->ai_protocol = st2->protocol;
|
|
|
|
ai->ai_addrlen = socklen;
|
|
|
|
ai->ai_addr = (void *) (ai + 1);
|
2004-08-18 05:10:14 +00:00
|
|
|
|
|
|
|
/* We only add the canonical name once. */
|
2004-08-19 22:56:27 +00:00
|
|
|
ai->ai_canonname = (char *) canon;
|
2004-08-18 05:10:14 +00:00
|
|
|
canon = NULL;
|
|
|
|
|
2005-05-18 19:22:50 +00:00
|
|
|
#ifdef _HAVE_SA_LEN
|
2004-08-19 22:56:27 +00:00
|
|
|
ai->ai_addr->sa_len = socklen;
|
2005-05-18 19:22:50 +00:00
|
|
|
#endif /* _HAVE_SA_LEN */
|
2004-08-19 22:56:27 +00:00
|
|
|
ai->ai_addr->sa_family = family;
|
update from main archive 970221
1997-02-22 00:17 Ulrich Drepper <drepper@cygnus.com>
* catgets/gencat.c: Change to use argp.
* db/makedb: Likewise.
* locale/programs/localedef.c: Likewise.
* locale/programs/locale.c: Little adjustment for better usage of
argp.
1997-02-20 20:07 Greg McGary <gkm@eng.ascend.com>
* Makeconfig: Add rules for libc with bounded pointers.
* Makerules: Likewise.
* config.make.in: Likewise.
* configure.in: Likewise.
1997-02-21 10:41 Miles Bader <miles@gnu.ai.mit.edu>
* argp.h (OPTION_NO_USAGE): New macro.
* argp-help.c (usage_long_opt, usage_argful_short_opt,
add_argless_short_opt): Implement OPTION_NO_USAGE.
1997-02-20 16:41 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* malloc/obstack.h: Fix typo.
1997-02-20 15:56 Miles Bader <miles@gnu.ai.mit.edu>
* argp-fmtstream.c (__argp_fmtstream_update): Account for case
where NEXTLINE points one past the end of the active buffer.
* argp-help.c <stddef.h>: New include.
(__argp_failure): Only exit if STATE says it's ok.
(print_header, hol_entry_help): Use UPARAMS fields rather than
constants.
(_help): Call fill_in_uparams if necessary.
(struct hol_help_state): New type.
(struct pentry_state): Add hhstate field. Remove prev_entry &
sep_groups fields.
(hol_entry_help): Add HHSTATE parameter. Remove prev_entry &
sep_groups parameters.
Suppress duplicate arguments if requested, and note the fact.
(print_header, comma): Use PEST->hhstate fields.
(hol_help): Add HHSTATE variable & pass to hol_entry_help.
Remove LAST_ENTRY & SEP_GROUPS variables.
If any suplicate arguments were suppressed, print explanatory note.
(filter_doc): Replace PEST parameter with STATE.
(struct uparams): New type.
(uparams): New variable.
(struct uparam_name): New type.
(uparam_names): New variable.
(fill_in_uparams): New function.
(__argp_failure, __argp_error, __argp_state_help): Make STATE
parameter const.
* argp.h (argp_state_help, __argp_state_help, argp_usage,
__argp_usage, argp_error, __argp_error, argp_failure,
__argp_failure): Make STATE parameter const.
(ARGP_KEY_HELP_DUP_ARGS_NOTE): New macro.
* argp.h (argp_program_bug_address): Make const.
1997-02-20 19:20 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/mman/syscalls.list: Explain msync interface.
1997-02-19 01:37 Erik Troan <ewt@redhat.com>
* shadow/sgetspent_r.c: Accept empty third, fourth and fifth fields.
1997-02-20 14:44 Andreas Jaeger <aj@arthur.pfalz.de>
* stdio-common/test-fseek.c: Remove temporary file, add
copyright.
1997-02-20 17:51 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/generic/netinet/in.h: Protect contents using
__BEGIN/END_DECLS. Reported by a sun <asun@zoology.washington.edu>.
* inet/net/ethernet.h: Move to sysdeps/unix/sysv/linux/net.
* inet/Makefile (headers): Remove net/ethernet.h.
* sysdeps/unix/sysv/linux/Makefile: Install net/ethernet.h.
* sysdeps/unix/sysv/linux/Dist: Distribute net/ethernet.h.
1997-02-20 15:23 Thorsten Kukuk <kukuk@weber.uni-paderborn.de>
* nss/nsswitch.c (__nss_configure_lookup): Use correct test when
searching in sorted array.
1997-02-20 01:24 Philip Blundell <pjb27@cam.ac.uk>
* inet/getnameinfo.c: Change to use reentrant getXXbyYY functions
and protect modification of global data.
1997-02-19 18:48 Miles Bader <miles@gnu.ai.mit.edu>
* argp-parse.c (argp_default_parser): Set STATE->name for OPT_PROGNAME.
(parser_init): Use the basename for PARSER->state.name.
* argp-help.c (__argp_error, __argp_failure, __argp_state_help):
Use PROGRAM_INVOCATION_SHORT_NAME instead of PROGRAM_INVOCATION_NAME.
* argp-parse.c (parser_init): Set PARSER->state.flags.
Make check whether PARSER has the prog name in argv[0] at the
proper place.
1997-02-19 23:34 Ulrich Drepper <drepper@cygnus.com>
* locale/programs/ld-time.c (time_finish): t_fmt_ampm is optional.
Use default value instead of printing a warning.
* nss/XXX-lookup.c: Add misssing explanation.
1997-02-19 19:14 Andreas Jaeger <aj@arthur.pfalz.de>
* inet/in6_addr.c: Add missing braces.
* inet/getnameinfo.c: Include <arpa/inet.h>.
* sysdeps/posix/getaddrinfo.c: Include <arpa/inet.h>.
1997-02-19 11:46 Ulrich Drepper <drepper@cygnus.com>
* string/strxfrm.c (STRCOLL): Correct handling of `position'
levels with no non-IGNOREd element and handling of NUL byte.
* string/strcoll.c (STRXFRM): Likewise.
* locale/weight.h: Likewise.
* shadow/sgetspent_r.c (LINE_PARSER): Add missing ')'.
1997-02-22 01:20:46 +00:00
|
|
|
|
2006-05-10 00:03:41 +00:00
|
|
|
/* In case of an allocation error the list must be NULL
|
|
|
|
terminated. */
|
|
|
|
ai->ai_next = NULL;
|
|
|
|
|
2000-11-10 04:15:55 +00:00
|
|
|
if (family == AF_INET6)
|
1997-08-20 03:53:21 +00:00
|
|
|
{
|
|
|
|
struct sockaddr_in6 *sin6p =
|
2004-08-19 22:56:27 +00:00
|
|
|
(struct sockaddr_in6 *) ai->ai_addr;
|
1996-10-21 01:26:31 +00:00
|
|
|
|
2004-08-15 20:23:40 +00:00
|
|
|
sin6p->sin6_port = st2->port;
|
1997-08-20 03:53:21 +00:00
|
|
|
sin6p->sin6_flowinfo = 0;
|
|
|
|
memcpy (&sin6p->sin6_addr,
|
|
|
|
at2->addr, sizeof (struct in6_addr));
|
2000-03-23 21:34:58 +00:00
|
|
|
sin6p->sin6_scope_id = at2->scopeid;
|
1997-08-20 03:53:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct sockaddr_in *sinp =
|
2004-08-19 22:56:27 +00:00
|
|
|
(struct sockaddr_in *) ai->ai_addr;
|
2004-08-15 20:23:40 +00:00
|
|
|
sinp->sin_port = st2->port;
|
1997-08-20 03:53:21 +00:00
|
|
|
memcpy (&sinp->sin_addr,
|
|
|
|
at2->addr, sizeof (struct in_addr));
|
|
|
|
memset (sinp->sin_zero, '\0', sizeof (sinp->sin_zero));
|
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
|
2004-08-19 22:56:27 +00:00
|
|
|
pai = &(ai->ai_next);
|
1997-08-20 03:53:21 +00:00
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
|
2005-11-27 23:13:21 +00:00
|
|
|
++*naddrs;
|
|
|
|
|
2003-04-24 23:45:17 +00:00
|
|
|
ignore:
|
1997-08-20 03:53:21 +00:00
|
|
|
at2 = at2->next;
|
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
return 0;
|
1996-10-21 01:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-18 07:04:13 +00:00
|
|
|
struct sort_result
|
|
|
|
{
|
|
|
|
struct addrinfo *dest_addr;
|
2008-01-10 20:00:52 +00:00
|
|
|
/* Using sockaddr_storage is for now overkill. We only support IPv4
|
|
|
|
and IPv6 so far. If this changes at some point we can adjust the
|
|
|
|
type here. */
|
|
|
|
struct sockaddr_in6 source_addr;
|
2004-09-15 08:25:49 +00:00
|
|
|
uint8_t source_addr_len;
|
2003-11-18 07:04:13 +00:00
|
|
|
bool got_source_addr;
|
2006-04-16 21:34:32 +00:00
|
|
|
uint8_t source_addr_flags;
|
2007-11-12 23:55:58 +00:00
|
|
|
uint8_t prefixlen;
|
2007-11-14 06:58:35 +00:00
|
|
|
uint32_t index;
|
|
|
|
int32_t native;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sort_result_combo
|
|
|
|
{
|
|
|
|
struct sort_result *results;
|
|
|
|
int nresults;
|
2003-11-18 07:04:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-11-20 00:41:22 +00:00
|
|
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
|
|
|
# define htonl_c(n) n
|
|
|
|
#else
|
|
|
|
# define htonl_c(n) __bswap_constant_32 (n)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static const struct scopeentry
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
char addr[4];
|
|
|
|
uint32_t addr32;
|
|
|
|
};
|
|
|
|
uint32_t netmask;
|
|
|
|
int32_t scope;
|
|
|
|
} default_scopes[] =
|
|
|
|
{
|
|
|
|
/* Link-local addresses: scope 2. */
|
|
|
|
{ { { 169, 254, 0, 0 } }, htonl_c (0xffff0000), 2 },
|
|
|
|
{ { { 127, 0, 0, 0 } }, htonl_c (0xff000000), 2 },
|
|
|
|
/* Site-local addresses: scope 5. */
|
|
|
|
{ { { 10, 0, 0, 0 } }, htonl_c (0xff000000), 5 },
|
|
|
|
{ { { 172, 16, 0, 0 } }, htonl_c (0xfff00000), 5 },
|
|
|
|
{ { { 192, 168, 0, 0 } }, htonl_c (0xffff0000), 5 },
|
|
|
|
/* Default: scope 14. */
|
|
|
|
{ { { 0, 0, 0, 0 } }, htonl_c (0x00000000), 14 }
|
|
|
|
};
|
|
|
|
|
|
|
|
/* The label table. */
|
|
|
|
static const struct scopeentry *scopes;
|
|
|
|
|
|
|
|
|
2003-11-18 07:04:13 +00:00
|
|
|
static int
|
2008-01-10 20:00:52 +00:00
|
|
|
get_scope (const struct sockaddr_in6 *in6)
|
2003-11-18 07:04:13 +00:00
|
|
|
{
|
|
|
|
int scope;
|
2008-01-10 20:00:52 +00:00
|
|
|
if (in6->sin6_family == PF_INET6)
|
2003-11-18 07:04:13 +00:00
|
|
|
{
|
|
|
|
if (! IN6_IS_ADDR_MULTICAST (&in6->sin6_addr))
|
|
|
|
{
|
2008-05-14 22:33:51 +00:00
|
|
|
if (IN6_IS_ADDR_LINKLOCAL (&in6->sin6_addr)
|
|
|
|
/* RFC 4291 2.5.3 says that the loopback address is to be
|
|
|
|
treated like a link-local address. */
|
|
|
|
|| IN6_IS_ADDR_LOOPBACK (&in6->sin6_addr))
|
2003-11-18 07:04:13 +00:00
|
|
|
scope = 2;
|
|
|
|
else if (IN6_IS_ADDR_SITELOCAL (&in6->sin6_addr))
|
|
|
|
scope = 5;
|
|
|
|
else
|
|
|
|
/* XXX Is this the correct default behavior? */
|
|
|
|
scope = 14;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
scope = in6->sin6_addr.s6_addr[1] & 0xf;
|
|
|
|
}
|
2008-01-10 20:00:52 +00:00
|
|
|
else if (in6->sin6_family == PF_INET)
|
2003-11-18 07:04:13 +00:00
|
|
|
{
|
2008-01-10 20:00:52 +00:00
|
|
|
const struct sockaddr_in *in = (const struct sockaddr_in *) in6;
|
2007-11-20 00:41:22 +00:00
|
|
|
|
|
|
|
size_t cnt = 0;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if ((in->sin_addr.s_addr & scopes[cnt].netmask)
|
|
|
|
== scopes[cnt].addr32)
|
|
|
|
return scopes[cnt].scope;
|
|
|
|
|
|
|
|
++cnt;
|
|
|
|
}
|
|
|
|
/* NOTREACHED */
|
2003-11-18 07:04:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
/* XXX What is a good default? */
|
|
|
|
scope = 15;
|
|
|
|
|
|
|
|
return scope;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-04 06:38:07 +00:00
|
|
|
struct prefixentry
|
2003-11-18 07:04:13 +00:00
|
|
|
{
|
|
|
|
struct in6_addr prefix;
|
|
|
|
unsigned int bits;
|
|
|
|
int val;
|
2006-05-04 06:38:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* The label table. */
|
|
|
|
static const struct prefixentry *labels;
|
|
|
|
|
|
|
|
/* Default labels. */
|
|
|
|
static const struct prefixentry default_labels[] =
|
2003-11-18 07:04:13 +00:00
|
|
|
{
|
|
|
|
/* See RFC 3484 for the details. */
|
2008-01-16 19:47:17 +00:00
|
|
|
{ { .__in6_u
|
|
|
|
= { .__u6_addr8 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 } }
|
|
|
|
}, 128, 0 },
|
|
|
|
{ { .__in6_u
|
|
|
|
= { .__u6_addr8 = { 0x20, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
|
|
|
|
}, 16, 2 },
|
|
|
|
{ { .__in6_u
|
|
|
|
= { .__u6_addr8 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
|
|
|
|
}, 96, 3 },
|
|
|
|
{ { .__in6_u
|
|
|
|
= { .__u6_addr8 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } }
|
|
|
|
}, 96, 4 },
|
2006-05-18 16:58:36 +00:00
|
|
|
/* The next two entries differ from RFC 3484. We need to treat
|
|
|
|
IPv6 site-local addresses special because they are never NATed,
|
|
|
|
unlike site-locale IPv4 addresses. If this would not happen, on
|
|
|
|
machines which have only IPv4 and IPv6 site-local addresses, the
|
|
|
|
sorting would prefer the IPv6 site-local addresses, causing
|
|
|
|
unnecessary delays when trying to connect to a global IPv6 address
|
|
|
|
through a site-local IPv6 address. */
|
2008-01-16 19:47:17 +00:00
|
|
|
{ { .__in6_u
|
|
|
|
= { .__u6_addr8 = { 0xfe, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
|
|
|
|
}, 10, 5 },
|
|
|
|
{ { .__in6_u
|
|
|
|
= { .__u6_addr8 = { 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
|
|
|
|
}, 7, 6 },
|
2007-11-19 17:31:40 +00:00
|
|
|
/* Additional rule for Teredo tunnels. */
|
2008-01-16 19:47:17 +00:00
|
|
|
{ { .__in6_u
|
|
|
|
= { .__u6_addr8 = { 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
|
|
|
|
}, 32, 7 },
|
|
|
|
{ { .__in6_u
|
|
|
|
= { .__u6_addr8 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
|
|
|
|
}, 0, 1 }
|
2003-11-18 07:04:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-05-04 06:38:07 +00:00
|
|
|
/* The precedence table. */
|
|
|
|
static const struct prefixentry *precedence;
|
|
|
|
|
|
|
|
/* The default precedences. */
|
|
|
|
static const struct prefixentry default_precedence[] =
|
2003-11-18 07:04:13 +00:00
|
|
|
{
|
|
|
|
/* See RFC 3484 for the details. */
|
2008-01-16 19:47:17 +00:00
|
|
|
{ { .__in6_u
|
|
|
|
= { .__u6_addr8 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 } }
|
|
|
|
}, 128, 50 },
|
|
|
|
{ { .__in6_u
|
|
|
|
= { .__u6_addr8 = { 0x20, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
|
|
|
|
}, 16, 30 },
|
|
|
|
{ { .__in6_u
|
|
|
|
= { .__u6_addr8 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
|
|
|
|
}, 96, 20 },
|
|
|
|
{ { .__in6_u
|
|
|
|
= { .__u6_addr8 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } }
|
|
|
|
}, 96, 10 },
|
|
|
|
{ { .__in6_u
|
|
|
|
= { .__u6_addr8 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
|
|
|
|
}, 0, 40 }
|
2003-11-18 07:04:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2008-01-10 20:00:52 +00:00
|
|
|
match_prefix (const struct sockaddr_in6 *in6,
|
2006-05-04 06:38:07 +00:00
|
|
|
const struct prefixentry *list, int default_val)
|
2003-11-18 07:04:13 +00:00
|
|
|
{
|
|
|
|
int idx;
|
|
|
|
struct sockaddr_in6 in6_mem;
|
|
|
|
|
2008-01-10 20:00:52 +00:00
|
|
|
if (in6->sin6_family == PF_INET)
|
2003-11-18 07:04:13 +00:00
|
|
|
{
|
2008-01-10 20:00:52 +00:00
|
|
|
const struct sockaddr_in *in = (const struct sockaddr_in *) in6;
|
2003-11-18 07:04:13 +00:00
|
|
|
|
2008-05-14 22:47:15 +00:00
|
|
|
/* Construct a V4-to-6 mapped address. */
|
2003-11-18 07:04:13 +00:00
|
|
|
in6_mem.sin6_family = PF_INET6;
|
|
|
|
in6_mem.sin6_port = in->sin_port;
|
|
|
|
in6_mem.sin6_flowinfo = 0;
|
2008-05-14 22:47:15 +00:00
|
|
|
memset (&in6_mem.sin6_addr, '\0', sizeof (in6_mem.sin6_addr));
|
|
|
|
in6_mem.sin6_addr.s6_addr16[5] = 0xffff;
|
|
|
|
in6_mem.sin6_addr.s6_addr32[3] = in->sin_addr.s_addr;
|
|
|
|
in6_mem.sin6_scope_id = 0;
|
2003-11-18 07:04:13 +00:00
|
|
|
|
|
|
|
in6 = &in6_mem;
|
|
|
|
}
|
2008-01-10 20:00:52 +00:00
|
|
|
else if (in6->sin6_family != PF_INET6)
|
2003-11-18 07:04:13 +00:00
|
|
|
return default_val;
|
|
|
|
|
|
|
|
for (idx = 0; ; ++idx)
|
|
|
|
{
|
|
|
|
unsigned int bits = list[idx].bits;
|
2006-10-02 16:50:55 +00:00
|
|
|
const uint8_t *mask = list[idx].prefix.s6_addr;
|
|
|
|
const uint8_t *val = in6->sin6_addr.s6_addr;
|
2003-11-18 07:04:13 +00:00
|
|
|
|
2005-09-26 16:12:12 +00:00
|
|
|
while (bits >= 8)
|
2003-11-18 07:04:13 +00:00
|
|
|
{
|
|
|
|
if (*mask != *val)
|
|
|
|
break;
|
|
|
|
|
|
|
|
++mask;
|
|
|
|
++val;
|
|
|
|
bits -= 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bits < 8)
|
|
|
|
{
|
2004-02-16 18:48:51 +00:00
|
|
|
if ((*mask & (0xff00 >> bits)) == (*val & (0xff00 >> bits)))
|
2003-11-18 07:04:13 +00:00
|
|
|
/* Match! */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return list[idx].val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2008-01-10 20:00:52 +00:00
|
|
|
get_label (const struct sockaddr_in6 *in6)
|
2003-11-18 07:04:13 +00:00
|
|
|
{
|
|
|
|
/* XXX What is a good default value? */
|
2008-01-10 20:00:52 +00:00
|
|
|
return match_prefix (in6, labels, INT_MAX);
|
2003-11-18 07:04:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2008-01-10 20:00:52 +00:00
|
|
|
get_precedence (const struct sockaddr_in6 *in6)
|
2003-11-18 07:04:13 +00:00
|
|
|
{
|
|
|
|
/* XXX What is a good default value? */
|
2008-01-10 20:00:52 +00:00
|
|
|
return match_prefix (in6, precedence, 0);
|
2003-11-18 07:04:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-26 21:10:16 +00:00
|
|
|
/* Find last bit set in a word. */
|
|
|
|
static int
|
|
|
|
fls (uint32_t a)
|
|
|
|
{
|
|
|
|
uint32_t mask;
|
2007-11-12 23:55:58 +00:00
|
|
|
int n;
|
2005-09-26 21:10:16 +00:00
|
|
|
for (n = 0, mask = 1 << 31; n < 32; mask >>= 1, ++n)
|
|
|
|
if ((a & mask) != 0)
|
|
|
|
break;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-18 07:04:13 +00:00
|
|
|
static int
|
2007-11-14 06:58:35 +00:00
|
|
|
rfc3484_sort (const void *p1, const void *p2, void *arg)
|
2003-11-18 07:04:13 +00:00
|
|
|
{
|
2008-01-10 20:00:52 +00:00
|
|
|
const size_t idx1 = *(const size_t *) p1;
|
|
|
|
const size_t idx2 = *(const size_t *) p2;
|
2007-11-14 06:58:35 +00:00
|
|
|
struct sort_result_combo *src = (struct sort_result_combo *) arg;
|
2008-01-10 20:00:52 +00:00
|
|
|
struct sort_result *a1 = &src->results[idx1];
|
|
|
|
struct sort_result *a2 = &src->results[idx2];
|
2003-11-18 07:04:13 +00:00
|
|
|
|
|
|
|
/* Rule 1: Avoid unusable destinations.
|
|
|
|
We have the got_source_addr flag set if the destination is reachable. */
|
|
|
|
if (a1->got_source_addr && ! a2->got_source_addr)
|
|
|
|
return -1;
|
|
|
|
if (! a1->got_source_addr && a2->got_source_addr)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
|
|
/* Rule 2: Prefer matching scope. Only interesting if both
|
|
|
|
destination addresses are IPv6. */
|
|
|
|
int a1_dst_scope
|
2008-01-10 20:00:52 +00:00
|
|
|
= get_scope ((struct sockaddr_in6 *) a1->dest_addr->ai_addr);
|
2003-11-18 07:04:13 +00:00
|
|
|
|
|
|
|
int a2_dst_scope
|
2008-01-10 20:00:52 +00:00
|
|
|
= get_scope ((struct sockaddr_in6 *) a2->dest_addr->ai_addr);
|
2003-11-18 07:04:13 +00:00
|
|
|
|
|
|
|
if (a1->got_source_addr)
|
|
|
|
{
|
|
|
|
int a1_src_scope = get_scope (&a1->source_addr);
|
|
|
|
int a2_src_scope = get_scope (&a2->source_addr);
|
|
|
|
|
|
|
|
if (a1_dst_scope == a1_src_scope && a2_dst_scope != a2_src_scope)
|
|
|
|
return -1;
|
|
|
|
if (a1_dst_scope != a1_src_scope && a2_dst_scope == a2_src_scope)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-16 21:34:32 +00:00
|
|
|
/* Rule 3: Avoid deprecated addresses. */
|
|
|
|
if (a1->got_source_addr)
|
|
|
|
{
|
|
|
|
if (!(a1->source_addr_flags & in6ai_deprecated)
|
|
|
|
&& (a2->source_addr_flags & in6ai_deprecated))
|
|
|
|
return -1;
|
|
|
|
if ((a1->source_addr_flags & in6ai_deprecated)
|
|
|
|
&& !(a2->source_addr_flags & in6ai_deprecated))
|
|
|
|
return 1;
|
|
|
|
}
|
2003-11-18 07:04:13 +00:00
|
|
|
|
2006-09-24 17:14:11 +00:00
|
|
|
/* Rule 4: Prefer home addresses. */
|
|
|
|
if (a1->got_source_addr)
|
|
|
|
{
|
|
|
|
if (!(a1->source_addr_flags & in6ai_homeaddress)
|
|
|
|
&& (a2->source_addr_flags & in6ai_homeaddress))
|
2006-10-16 15:20:20 +00:00
|
|
|
return 1;
|
2006-09-24 17:14:11 +00:00
|
|
|
if ((a1->source_addr_flags & in6ai_homeaddress)
|
|
|
|
&& !(a2->source_addr_flags & in6ai_homeaddress))
|
2006-10-16 15:20:20 +00:00
|
|
|
return -1;
|
2006-09-24 17:14:11 +00:00
|
|
|
}
|
2003-11-18 07:04:13 +00:00
|
|
|
|
|
|
|
/* Rule 5: Prefer matching label. */
|
|
|
|
if (a1->got_source_addr)
|
|
|
|
{
|
|
|
|
int a1_dst_label
|
2008-01-10 20:00:52 +00:00
|
|
|
= get_label ((struct sockaddr_in6 *) a1->dest_addr->ai_addr);
|
2003-11-18 07:04:13 +00:00
|
|
|
int a1_src_label = get_label (&a1->source_addr);
|
|
|
|
|
|
|
|
int a2_dst_label
|
2008-01-10 20:00:52 +00:00
|
|
|
= get_label ((struct sockaddr_in6 *) a2->dest_addr->ai_addr);
|
2003-11-18 07:04:13 +00:00
|
|
|
int a2_src_label = get_label (&a2->source_addr);
|
|
|
|
|
|
|
|
if (a1_dst_label == a1_src_label && a2_dst_label != a2_src_label)
|
|
|
|
return -1;
|
|
|
|
if (a1_dst_label != a1_src_label && a2_dst_label == a2_src_label)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Rule 6: Prefer higher precedence. */
|
|
|
|
int a1_prec
|
2008-01-10 20:00:52 +00:00
|
|
|
= get_precedence ((struct sockaddr_in6 *) a1->dest_addr->ai_addr);
|
2003-11-18 07:04:13 +00:00
|
|
|
int a2_prec
|
2008-01-10 20:00:52 +00:00
|
|
|
= get_precedence ((struct sockaddr_in6 *) a2->dest_addr->ai_addr);
|
2003-11-18 07:04:13 +00:00
|
|
|
|
|
|
|
if (a1_prec > a2_prec)
|
|
|
|
return -1;
|
|
|
|
if (a1_prec < a2_prec)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
2006-04-16 21:34:32 +00:00
|
|
|
/* Rule 7: Prefer native transport. */
|
|
|
|
if (a1->got_source_addr)
|
|
|
|
{
|
2007-11-14 06:58:35 +00:00
|
|
|
/* The same interface index means the same interface which means
|
|
|
|
there is no difference in transport. This should catch many
|
|
|
|
(most?) cases. */
|
|
|
|
if (a1->index != a2->index)
|
|
|
|
{
|
2008-01-10 22:30:58 +00:00
|
|
|
int a1_native = a1->native;
|
|
|
|
int a2_native = a2->native;
|
|
|
|
|
|
|
|
if (a1_native == -1 || a2_native == -1)
|
2007-11-14 06:58:35 +00:00
|
|
|
{
|
2008-01-10 22:30:58 +00:00
|
|
|
uint32_t a1_index;
|
|
|
|
if (a1_native == -1)
|
|
|
|
{
|
|
|
|
/* If we do not have the information use 'native' as
|
|
|
|
the default. */
|
|
|
|
a1_native = 0;
|
|
|
|
a1_index = a1->index;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
a1_index = 0xffffffffu;
|
|
|
|
|
|
|
|
uint32_t a2_index;
|
|
|
|
if (a2_native == -1)
|
|
|
|
{
|
|
|
|
/* If we do not have the information use 'native' as
|
|
|
|
the default. */
|
|
|
|
a2_native = 0;
|
|
|
|
a2_index = a2->index;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
a2_index = 0xffffffffu;
|
|
|
|
|
|
|
|
__check_native (a1_index, &a1_native, a2_index, &a2_native);
|
2007-11-14 06:58:35 +00:00
|
|
|
|
|
|
|
/* Fill in the results in all the records. */
|
|
|
|
for (int i = 0; i < src->nresults; ++i)
|
2008-01-10 22:30:58 +00:00
|
|
|
if (src->results[i].index == a1_index)
|
|
|
|
{
|
|
|
|
assert (src->results[i].native == -1
|
|
|
|
|| src->results[i].native == a1_native);
|
2007-11-14 06:58:35 +00:00
|
|
|
src->results[i].native = a1_native;
|
2008-01-10 22:30:58 +00:00
|
|
|
}
|
|
|
|
else if (src->results[i].index == a2_index)
|
|
|
|
{
|
|
|
|
assert (src->results[i].native == -1
|
|
|
|
|| src->results[i].native == a2_native);
|
2007-11-14 06:58:35 +00:00
|
|
|
src->results[i].native = a2_native;
|
2008-01-10 22:30:58 +00:00
|
|
|
}
|
2007-11-14 06:58:35 +00:00
|
|
|
}
|
2006-04-16 21:34:32 +00:00
|
|
|
|
2008-01-10 22:30:58 +00:00
|
|
|
if (a1_native && !a2_native)
|
2007-11-14 06:58:35 +00:00
|
|
|
return -1;
|
2008-01-10 22:30:58 +00:00
|
|
|
if (!a1_native && a2_native)
|
2007-11-14 06:58:35 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2006-04-16 21:34:32 +00:00
|
|
|
}
|
2003-11-18 07:04:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Rule 8: Prefer smaller scope. */
|
|
|
|
if (a1_dst_scope < a2_dst_scope)
|
|
|
|
return -1;
|
|
|
|
if (a1_dst_scope > a2_dst_scope)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
|
|
/* Rule 9: Use longest matching prefix. */
|
|
|
|
if (a1->got_source_addr
|
|
|
|
&& a1->dest_addr->ai_family == a2->dest_addr->ai_family)
|
|
|
|
{
|
|
|
|
int bit1 = 0;
|
|
|
|
int bit2 = 0;
|
|
|
|
|
|
|
|
if (a1->dest_addr->ai_family == PF_INET)
|
|
|
|
{
|
2008-01-10 20:00:52 +00:00
|
|
|
assert (a1->source_addr.sin6_family == PF_INET);
|
|
|
|
assert (a2->source_addr.sin6_family == PF_INET);
|
2003-11-18 07:04:13 +00:00
|
|
|
|
2007-11-12 23:55:58 +00:00
|
|
|
/* Outside of subnets, as defined by the network masks,
|
|
|
|
common address prefixes for IPv4 addresses make no sense.
|
|
|
|
So, define a non-zero value only if source and
|
|
|
|
destination address are on the same subnet. */
|
|
|
|
struct sockaddr_in *in1_dst
|
|
|
|
= (struct sockaddr_in *) a1->dest_addr->ai_addr;
|
|
|
|
in_addr_t in1_dst_addr = ntohl (in1_dst->sin_addr.s_addr);
|
|
|
|
struct sockaddr_in *in1_src
|
|
|
|
= (struct sockaddr_in *) &a1->source_addr;
|
|
|
|
in_addr_t in1_src_addr = ntohl (in1_src->sin_addr.s_addr);
|
|
|
|
in_addr_t netmask1 = 0xffffffffu << (32 - a1->prefixlen);
|
|
|
|
|
|
|
|
if ((in1_src_addr & netmask1) == (in1_dst_addr & netmask1))
|
|
|
|
bit1 = fls (in1_dst_addr ^ in1_src_addr);
|
|
|
|
|
|
|
|
struct sockaddr_in *in2_dst
|
|
|
|
= (struct sockaddr_in *) a2->dest_addr->ai_addr;
|
|
|
|
in_addr_t in2_dst_addr = ntohl (in2_dst->sin_addr.s_addr);
|
|
|
|
struct sockaddr_in *in2_src
|
|
|
|
= (struct sockaddr_in *) &a2->source_addr;
|
|
|
|
in_addr_t in2_src_addr = ntohl (in2_src->sin_addr.s_addr);
|
|
|
|
in_addr_t netmask2 = 0xffffffffu << (32 - a2->prefixlen);
|
|
|
|
|
|
|
|
if ((in2_src_addr & netmask2) == (in2_dst_addr & netmask2))
|
|
|
|
bit2 = fls (in2_dst_addr ^ in2_src_addr);
|
2003-11-18 07:04:13 +00:00
|
|
|
}
|
|
|
|
else if (a1->dest_addr->ai_family == PF_INET6)
|
|
|
|
{
|
2008-01-10 20:00:52 +00:00
|
|
|
assert (a1->source_addr.sin6_family == PF_INET6);
|
|
|
|
assert (a2->source_addr.sin6_family == PF_INET6);
|
2003-11-18 07:04:13 +00:00
|
|
|
|
|
|
|
struct sockaddr_in6 *in1_dst;
|
|
|
|
struct sockaddr_in6 *in1_src;
|
|
|
|
struct sockaddr_in6 *in2_dst;
|
|
|
|
struct sockaddr_in6 *in2_src;
|
|
|
|
|
|
|
|
in1_dst = (struct sockaddr_in6 *) a1->dest_addr->ai_addr;
|
|
|
|
in1_src = (struct sockaddr_in6 *) &a1->source_addr;
|
|
|
|
in2_dst = (struct sockaddr_in6 *) a2->dest_addr->ai_addr;
|
|
|
|
in2_src = (struct sockaddr_in6 *) &a2->source_addr;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
if (in1_dst->sin6_addr.s6_addr32[i]
|
|
|
|
!= in1_src->sin6_addr.s6_addr32[i]
|
|
|
|
|| (in2_dst->sin6_addr.s6_addr32[i]
|
|
|
|
!= in2_src->sin6_addr.s6_addr32[i]))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (i < 4)
|
|
|
|
{
|
2005-09-26 21:10:16 +00:00
|
|
|
bit1 = fls (ntohl (in1_dst->sin6_addr.s6_addr32[i]
|
|
|
|
^ in1_src->sin6_addr.s6_addr32[i]));
|
|
|
|
bit2 = fls (ntohl (in2_dst->sin6_addr.s6_addr32[i]
|
|
|
|
^ in2_src->sin6_addr.s6_addr32[i]));
|
2003-11-18 07:04:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bit1 > bit2)
|
|
|
|
return -1;
|
|
|
|
if (bit1 < bit2)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-14 17:58:03 +00:00
|
|
|
/* Rule 10: Otherwise, leave the order unchanged. To ensure this
|
|
|
|
compare with the value indicating the order in which the entries
|
|
|
|
have been received from the services. NB: no two entries can have
|
|
|
|
the same order so the test will never return zero. */
|
2008-01-10 20:00:52 +00:00
|
|
|
return idx1 < idx2 ? -1 : 1;
|
2003-11-18 07:04:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-16 21:34:32 +00:00
|
|
|
static int
|
|
|
|
in6aicmp (const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
struct in6addrinfo *a1 = (struct in6addrinfo *) p1;
|
|
|
|
struct in6addrinfo *a2 = (struct in6addrinfo *) p2;
|
|
|
|
|
|
|
|
return memcmp (a1->addr, a2->addr, sizeof (a1->addr));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-04 06:38:07 +00:00
|
|
|
/* Name of the config file for RFC 3484 sorting (for now). */
|
|
|
|
#define GAICONF_FNAME "/etc/gai.conf"
|
|
|
|
|
|
|
|
|
2007-10-17 16:05:34 +00:00
|
|
|
/* Non-zero if we are supposed to reload the config file automatically
|
2006-05-04 06:38:07 +00:00
|
|
|
whenever it changed. */
|
|
|
|
static int gaiconf_reload_flag;
|
|
|
|
|
2007-10-17 16:05:34 +00:00
|
|
|
/* Non-zero if gaiconf_reload_flag was ever set to true. */
|
|
|
|
static int gaiconf_reload_flag_ever_set;
|
|
|
|
|
2006-05-04 06:38:07 +00:00
|
|
|
/* Last modification time. */
|
|
|
|
static struct timespec gaiconf_mtime;
|
|
|
|
|
|
|
|
|
|
|
|
libc_freeres_fn(fini)
|
|
|
|
{
|
|
|
|
if (labels != default_labels)
|
|
|
|
{
|
|
|
|
const struct prefixentry *old = labels;
|
|
|
|
labels = default_labels;
|
|
|
|
free ((void *) old);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (precedence != default_precedence)
|
|
|
|
{
|
|
|
|
const struct prefixentry *old = precedence;
|
|
|
|
precedence = default_precedence;
|
|
|
|
free ((void *) old);
|
|
|
|
}
|
2007-11-20 00:41:22 +00:00
|
|
|
|
|
|
|
if (scopes != default_scopes)
|
|
|
|
{
|
|
|
|
const struct scopeentry *old = scopes;
|
|
|
|
scopes = default_scopes;
|
|
|
|
free ((void *) old);
|
|
|
|
}
|
2006-05-04 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct prefixlist
|
|
|
|
{
|
|
|
|
struct prefixentry entry;
|
|
|
|
struct prefixlist *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-11-20 00:41:22 +00:00
|
|
|
struct scopelist
|
|
|
|
{
|
|
|
|
struct scopeentry entry;
|
|
|
|
struct scopelist *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-05-04 06:38:07 +00:00
|
|
|
static void
|
|
|
|
free_prefixlist (struct prefixlist *list)
|
|
|
|
{
|
|
|
|
while (list != NULL)
|
|
|
|
{
|
|
|
|
struct prefixlist *oldp = list;
|
|
|
|
list = list->next;
|
|
|
|
free (oldp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-20 00:41:22 +00:00
|
|
|
static void
|
|
|
|
free_scopelist (struct scopelist *list)
|
|
|
|
{
|
|
|
|
while (list != NULL)
|
|
|
|
{
|
|
|
|
struct scopelist *oldp = list;
|
|
|
|
list = list->next;
|
|
|
|
free (oldp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-04 06:38:07 +00:00
|
|
|
static int
|
|
|
|
prefixcmp (const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const struct prefixentry *e1 = (const struct prefixentry *) p1;
|
|
|
|
const struct prefixentry *e2 = (const struct prefixentry *) p2;
|
|
|
|
|
|
|
|
if (e1->bits < e2->bits)
|
|
|
|
return 1;
|
|
|
|
if (e1->bits == e2->bits)
|
|
|
|
return 0;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-20 00:41:22 +00:00
|
|
|
static int
|
|
|
|
scopecmp (const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const struct scopeentry *e1 = (const struct scopeentry *) p1;
|
|
|
|
const struct scopeentry *e2 = (const struct scopeentry *) p2;
|
|
|
|
|
|
|
|
if (e1->netmask > e2->netmask)
|
|
|
|
return -1;
|
|
|
|
if (e1->netmask == e2->netmask)
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-04 06:38:07 +00:00
|
|
|
static void
|
|
|
|
gaiconf_init (void)
|
|
|
|
{
|
|
|
|
struct prefixlist *labellist = NULL;
|
|
|
|
size_t nlabellist = 0;
|
|
|
|
bool labellist_nullbits = false;
|
|
|
|
struct prefixlist *precedencelist = NULL;
|
|
|
|
size_t nprecedencelist = 0;
|
|
|
|
bool precedencelist_nullbits = false;
|
2007-11-20 00:41:22 +00:00
|
|
|
struct scopelist *scopelist = NULL;
|
|
|
|
size_t nscopelist = 0;
|
|
|
|
bool scopelist_nullbits = false;
|
2006-05-04 06:38:07 +00:00
|
|
|
|
|
|
|
FILE *fp = fopen (GAICONF_FNAME, "rc");
|
|
|
|
if (fp != NULL)
|
|
|
|
{
|
|
|
|
struct stat64 st;
|
|
|
|
if (__fxstat64 (_STAT_VER, fileno (fp), &st) != 0)
|
|
|
|
{
|
|
|
|
fclose (fp);
|
|
|
|
goto no_file;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *line = NULL;
|
|
|
|
size_t linelen = 0;
|
|
|
|
|
|
|
|
__fsetlocking (fp, FSETLOCKING_BYCALLER);
|
|
|
|
|
|
|
|
while (!feof_unlocked (fp))
|
|
|
|
{
|
|
|
|
ssize_t n = __getline (&line, &linelen, fp);
|
|
|
|
if (n <= 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Handle comments. No escaping possible so this is easy. */
|
|
|
|
char *cp = strchr (line, '#');
|
|
|
|
if (cp != NULL)
|
|
|
|
*cp = '\0';
|
|
|
|
|
|
|
|
cp = line;
|
|
|
|
while (isspace (*cp))
|
|
|
|
++cp;
|
|
|
|
|
|
|
|
char *cmd = cp;
|
|
|
|
while (*cp != '\0' && !isspace (*cp))
|
|
|
|
++cp;
|
|
|
|
size_t cmdlen = cp - cmd;
|
|
|
|
|
|
|
|
if (*cp != '\0')
|
|
|
|
*cp++ = '\0';
|
|
|
|
while (isspace (*cp))
|
|
|
|
++cp;
|
|
|
|
|
|
|
|
char *val1 = cp;
|
|
|
|
while (*cp != '\0' && !isspace (*cp))
|
|
|
|
++cp;
|
|
|
|
size_t val1len = cp - cmd;
|
|
|
|
|
|
|
|
/* We always need at least two values. */
|
|
|
|
if (val1len == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (*cp != '\0')
|
|
|
|
*cp++ = '\0';
|
|
|
|
while (isspace (*cp))
|
|
|
|
++cp;
|
|
|
|
|
|
|
|
char *val2 = cp;
|
|
|
|
while (*cp != '\0' && !isspace (*cp))
|
|
|
|
++cp;
|
|
|
|
|
|
|
|
/* Ignore the rest of the line. */
|
|
|
|
*cp = '\0';
|
|
|
|
|
|
|
|
struct prefixlist **listp;
|
|
|
|
size_t *lenp;
|
|
|
|
bool *nullbitsp;
|
|
|
|
switch (cmdlen)
|
|
|
|
{
|
|
|
|
case 5:
|
|
|
|
if (strcmp (cmd, "label") == 0)
|
|
|
|
{
|
|
|
|
struct in6_addr prefix;
|
2006-05-30 16:18:07 +00:00
|
|
|
unsigned long int bits;
|
2006-05-04 06:38:07 +00:00
|
|
|
unsigned long int val;
|
|
|
|
char *endp;
|
|
|
|
|
|
|
|
listp = &labellist;
|
|
|
|
lenp = &nlabellist;
|
|
|
|
nullbitsp = &labellist_nullbits;
|
|
|
|
|
|
|
|
new_elem:
|
2006-05-30 16:18:07 +00:00
|
|
|
bits = 128;
|
2006-05-04 06:38:07 +00:00
|
|
|
__set_errno (0);
|
|
|
|
cp = strchr (val1, '/');
|
|
|
|
if (cp != NULL)
|
|
|
|
*cp++ = '\0';
|
|
|
|
if (inet_pton (AF_INET6, val1, &prefix)
|
|
|
|
&& (cp == NULL
|
|
|
|
|| (bits = strtoul (cp, &endp, 10)) != ULONG_MAX
|
|
|
|
|| errno != ERANGE)
|
|
|
|
&& *endp == '\0'
|
2007-11-20 00:41:22 +00:00
|
|
|
&& bits <= 128
|
2006-05-04 06:38:07 +00:00
|
|
|
&& ((val = strtoul (val2, &endp, 10)) != ULONG_MAX
|
|
|
|
|| errno != ERANGE)
|
|
|
|
&& *endp == '\0'
|
|
|
|
&& val <= INT_MAX)
|
|
|
|
{
|
|
|
|
struct prefixlist *newp = malloc (sizeof (*newp));
|
|
|
|
if (newp == NULL)
|
|
|
|
{
|
|
|
|
free (line);
|
|
|
|
fclose (fp);
|
|
|
|
goto no_file;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy (&newp->entry.prefix, &prefix, sizeof (prefix));
|
|
|
|
newp->entry.bits = bits;
|
|
|
|
newp->entry.val = val;
|
|
|
|
newp->next = *listp;
|
|
|
|
*listp = newp;
|
|
|
|
++*lenp;
|
|
|
|
*nullbitsp |= bits == 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
if (strcmp (cmd, "reload") == 0)
|
2007-10-17 16:05:34 +00:00
|
|
|
{
|
|
|
|
gaiconf_reload_flag = strcmp (val1, "yes") == 0;
|
|
|
|
if (gaiconf_reload_flag)
|
|
|
|
gaiconf_reload_flag_ever_set = 1;
|
|
|
|
}
|
2006-05-04 06:38:07 +00:00
|
|
|
break;
|
|
|
|
|
2007-11-20 00:41:22 +00:00
|
|
|
case 7:
|
|
|
|
if (strcmp (cmd, "scopev4") == 0)
|
|
|
|
{
|
|
|
|
struct in6_addr prefix;
|
|
|
|
unsigned long int bits;
|
|
|
|
unsigned long int val;
|
|
|
|
char *endp;
|
|
|
|
|
|
|
|
bits = 32;
|
|
|
|
__set_errno (0);
|
|
|
|
cp = strchr (val1, '/');
|
|
|
|
if (cp != NULL)
|
|
|
|
*cp++ = '\0';
|
|
|
|
if (inet_pton (AF_INET6, val1, &prefix))
|
|
|
|
{
|
2008-03-26 17:45:14 +00:00
|
|
|
bits = 128;
|
2007-11-20 00:41:22 +00:00
|
|
|
if (IN6_IS_ADDR_V4MAPPED (&prefix)
|
|
|
|
&& (cp == NULL
|
|
|
|
|| (bits = strtoul (cp, &endp, 10)) != ULONG_MAX
|
|
|
|
|| errno != ERANGE)
|
|
|
|
&& *endp == '\0'
|
|
|
|
&& bits >= 96
|
|
|
|
&& bits <= 128
|
|
|
|
&& ((val = strtoul (val2, &endp, 10)) != ULONG_MAX
|
|
|
|
|| errno != ERANGE)
|
|
|
|
&& *endp == '\0'
|
|
|
|
&& val <= INT_MAX)
|
|
|
|
{
|
|
|
|
struct scopelist *newp;
|
|
|
|
new_scope:
|
|
|
|
newp = malloc (sizeof (*newp));
|
|
|
|
if (newp == NULL)
|
|
|
|
{
|
|
|
|
free (line);
|
|
|
|
fclose (fp);
|
|
|
|
goto no_file;
|
|
|
|
}
|
|
|
|
|
|
|
|
newp->entry.netmask = htonl (bits != 96
|
|
|
|
? (0xffffffff
|
|
|
|
<< (128 - bits))
|
|
|
|
: 0);
|
|
|
|
newp->entry.addr32 = (prefix.s6_addr32[3]
|
|
|
|
& newp->entry.netmask);
|
|
|
|
newp->entry.scope = val;
|
|
|
|
newp->next = scopelist;
|
|
|
|
scopelist = newp;
|
|
|
|
++nscopelist;
|
|
|
|
scopelist_nullbits |= bits == 96;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (inet_pton (AF_INET, val1, &prefix.s6_addr32[3])
|
|
|
|
&& (cp == NULL
|
|
|
|
|| (bits = strtoul (cp, &endp, 10)) != ULONG_MAX
|
|
|
|
|| errno != ERANGE)
|
|
|
|
&& *endp == '\0'
|
|
|
|
&& bits <= 32
|
|
|
|
&& ((val = strtoul (val2, &endp, 10)) != ULONG_MAX
|
|
|
|
|| errno != ERANGE)
|
|
|
|
&& *endp == '\0'
|
|
|
|
&& val <= INT_MAX)
|
|
|
|
{
|
|
|
|
bits += 96;
|
|
|
|
goto new_scope;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2006-05-04 06:38:07 +00:00
|
|
|
case 10:
|
|
|
|
if (strcmp (cmd, "precedence") == 0)
|
|
|
|
{
|
|
|
|
listp = &precedencelist;
|
|
|
|
lenp = &nprecedencelist;
|
|
|
|
nullbitsp = &precedencelist_nullbits;
|
|
|
|
goto new_elem;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free (line);
|
|
|
|
|
|
|
|
fclose (fp);
|
|
|
|
|
|
|
|
/* Create the array for the labels. */
|
|
|
|
struct prefixentry *new_labels;
|
|
|
|
if (nlabellist > 0)
|
|
|
|
{
|
|
|
|
if (!labellist_nullbits)
|
|
|
|
++nlabellist;
|
|
|
|
new_labels = malloc (nlabellist * sizeof (*new_labels));
|
|
|
|
if (new_labels == NULL)
|
|
|
|
goto no_file;
|
|
|
|
|
|
|
|
int i = nlabellist;
|
|
|
|
if (!labellist_nullbits)
|
|
|
|
{
|
|
|
|
--i;
|
|
|
|
memset (&new_labels[i].prefix, '\0', sizeof (struct in6_addr));
|
|
|
|
new_labels[i].bits = 0;
|
|
|
|
new_labels[i].val = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct prefixlist *l = labellist;
|
|
|
|
while (i-- > 0)
|
|
|
|
{
|
|
|
|
new_labels[i] = l->entry;
|
|
|
|
l = l->next;
|
|
|
|
}
|
|
|
|
free_prefixlist (labellist);
|
|
|
|
|
|
|
|
/* Sort the entries so that the most specific ones are at
|
|
|
|
the beginning. */
|
|
|
|
qsort (new_labels, nlabellist, sizeof (*new_labels), prefixcmp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
new_labels = (struct prefixentry *) default_labels;
|
|
|
|
|
|
|
|
struct prefixentry *new_precedence;
|
|
|
|
if (nprecedencelist > 0)
|
|
|
|
{
|
|
|
|
if (!precedencelist_nullbits)
|
|
|
|
++nprecedencelist;
|
|
|
|
new_precedence = malloc (nprecedencelist * sizeof (*new_precedence));
|
|
|
|
if (new_precedence == NULL)
|
|
|
|
{
|
|
|
|
if (new_labels != default_labels)
|
|
|
|
free (new_labels);
|
|
|
|
goto no_file;
|
|
|
|
}
|
|
|
|
|
|
|
|
int i = nprecedencelist;
|
|
|
|
if (!precedencelist_nullbits)
|
|
|
|
{
|
|
|
|
--i;
|
|
|
|
memset (&new_precedence[i].prefix, '\0',
|
|
|
|
sizeof (struct in6_addr));
|
|
|
|
new_precedence[i].bits = 0;
|
|
|
|
new_precedence[i].val = 40;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct prefixlist *l = precedencelist;
|
|
|
|
while (i-- > 0)
|
|
|
|
{
|
|
|
|
new_precedence[i] = l->entry;
|
|
|
|
l = l->next;
|
|
|
|
}
|
|
|
|
free_prefixlist (precedencelist);
|
|
|
|
|
|
|
|
/* Sort the entries so that the most specific ones are at
|
|
|
|
the beginning. */
|
2007-11-20 00:41:22 +00:00
|
|
|
qsort (new_precedence, nprecedencelist, sizeof (*new_precedence),
|
2006-05-04 06:38:07 +00:00
|
|
|
prefixcmp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
new_precedence = (struct prefixentry *) default_precedence;
|
|
|
|
|
2007-11-20 00:41:22 +00:00
|
|
|
struct scopeentry *new_scopes;
|
|
|
|
if (nscopelist > 0)
|
|
|
|
{
|
|
|
|
if (!scopelist_nullbits)
|
|
|
|
++nscopelist;
|
|
|
|
new_scopes = malloc (nscopelist * sizeof (*new_scopes));
|
|
|
|
if (new_scopes == NULL)
|
|
|
|
{
|
|
|
|
if (new_labels != default_labels)
|
|
|
|
free (new_labels);
|
|
|
|
if (new_precedence != default_precedence)
|
|
|
|
free (new_precedence);
|
|
|
|
goto no_file;
|
|
|
|
}
|
|
|
|
|
|
|
|
int i = nscopelist;
|
|
|
|
if (!scopelist_nullbits)
|
|
|
|
{
|
|
|
|
--i;
|
|
|
|
new_scopes[i].addr32 = 0;
|
|
|
|
new_scopes[i].netmask = 0;
|
|
|
|
new_scopes[i].scope = 14;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct scopelist *l = scopelist;
|
|
|
|
while (i-- > 0)
|
|
|
|
{
|
|
|
|
new_scopes[i] = l->entry;
|
|
|
|
l = l->next;
|
|
|
|
}
|
|
|
|
free_scopelist (scopelist);
|
|
|
|
|
|
|
|
/* Sort the entries so that the most specific ones are at
|
|
|
|
the beginning. */
|
|
|
|
qsort (new_scopes, nscopelist, sizeof (*new_scopes),
|
|
|
|
scopecmp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
new_scopes = (struct scopeentry *) default_scopes;
|
|
|
|
|
2006-05-04 06:38:07 +00:00
|
|
|
/* Now we are ready to replace the values. */
|
|
|
|
const struct prefixentry *old = labels;
|
|
|
|
labels = new_labels;
|
|
|
|
if (old != default_labels)
|
|
|
|
free ((void *) old);
|
|
|
|
|
|
|
|
old = precedence;
|
|
|
|
precedence = new_precedence;
|
|
|
|
if (old != default_precedence)
|
|
|
|
free ((void *) old);
|
|
|
|
|
2007-11-20 00:41:22 +00:00
|
|
|
const struct scopeentry *oldscope = scopes;
|
|
|
|
scopes = new_scopes;
|
|
|
|
if (oldscope != default_scopes)
|
|
|
|
free ((void *) oldscope);
|
|
|
|
|
2006-05-04 06:38:07 +00:00
|
|
|
gaiconf_mtime = st.st_mtim;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
no_file:
|
|
|
|
free_prefixlist (labellist);
|
|
|
|
free_prefixlist (precedencelist);
|
2007-11-20 00:41:22 +00:00
|
|
|
free_scopelist (scopelist);
|
2006-05-04 06:38:07 +00:00
|
|
|
|
|
|
|
/* If we previously read the file but it is gone now, free the
|
|
|
|
old data and use the builtin one. Leave the reload flag
|
|
|
|
alone. */
|
|
|
|
fini ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gaiconf_reload (void)
|
|
|
|
{
|
|
|
|
struct stat64 st;
|
|
|
|
if (__xstat64 (_STAT_VER, GAICONF_FNAME, &st) != 0
|
|
|
|
|| memcmp (&st.st_mtim, &gaiconf_mtime, sizeof (gaiconf_mtime)) != 0)
|
|
|
|
gaiconf_init ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
int
|
|
|
|
getaddrinfo (const char *name, const char *service,
|
|
|
|
const struct addrinfo *hints, struct addrinfo **pai)
|
1996-10-21 01:26:31 +00:00
|
|
|
{
|
2006-04-18 23:35:12 +00:00
|
|
|
int i = 0, last_i = 0;
|
2003-11-18 07:04:13 +00:00
|
|
|
int nresults = 0;
|
2006-04-18 23:35:12 +00:00
|
|
|
struct addrinfo *p = NULL;
|
1996-10-21 01:26:31 +00:00
|
|
|
struct gaih_service gaih_service, *pservice;
|
2003-04-24 23:45:17 +00:00
|
|
|
struct addrinfo local_hints;
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if (name != NULL && name[0] == '*' && name[1] == 0)
|
1997-02-19 04:43:53 +00:00
|
|
|
name = NULL;
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if (service != NULL && service[0] == '*' && service[1] == 0)
|
1997-02-19 04:43:53 +00:00
|
|
|
service = NULL;
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if (name == NULL && service == NULL)
|
1996-10-21 01:26:31 +00:00
|
|
|
return EAI_NONAME;
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if (hints == NULL)
|
|
|
|
hints = &default_hints;
|
1996-10-21 01:26:31 +00:00
|
|
|
|
2003-04-24 23:45:17 +00:00
|
|
|
if (hints->ai_flags
|
|
|
|
& ~(AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST|AI_ADDRCONFIG|AI_V4MAPPED
|
2004-03-08 04:10:31 +00:00
|
|
|
#ifdef HAVE_LIBIDN
|
2004-03-17 20:02:19 +00:00
|
|
|
|AI_IDN|AI_CANONIDN|AI_IDN_ALLOW_UNASSIGNED
|
|
|
|
|AI_IDN_USE_STD3_ASCII_RULES
|
2004-03-08 04:10:31 +00:00
|
|
|
#endif
|
2004-08-05 09:45:35 +00:00
|
|
|
|AI_NUMERICSERV|AI_ALL))
|
1996-10-21 01:26:31 +00:00
|
|
|
return EAI_BADFLAGS;
|
|
|
|
|
2004-02-16 21:00:54 +00:00
|
|
|
if ((hints->ai_flags & AI_CANONNAME) && name == NULL)
|
1996-10-21 01:26:31 +00:00
|
|
|
return EAI_BADFLAGS;
|
|
|
|
|
2006-04-24 17:21:40 +00:00
|
|
|
struct in6addrinfo *in6ai = NULL;
|
2007-04-28 16:09:22 +00:00
|
|
|
size_t in6ailen = 0;
|
2006-04-16 21:34:32 +00:00
|
|
|
bool seen_ipv4 = false;
|
|
|
|
bool seen_ipv6 = false;
|
2007-11-12 23:55:58 +00:00
|
|
|
/* We might need information about what interfaces are available.
|
|
|
|
Also determine whether we have IPv4 or IPv6 interfaces or both. We
|
|
|
|
cannot cache the results since new interfaces could be added at
|
|
|
|
any time. */
|
|
|
|
__check_pf (&seen_ipv4, &seen_ipv6, &in6ai, &in6ailen);
|
2007-04-28 16:09:22 +00:00
|
|
|
|
2003-04-24 23:45:17 +00:00
|
|
|
if (hints->ai_flags & AI_ADDRCONFIG)
|
|
|
|
{
|
|
|
|
/* Now make a decision on what we return, if anything. */
|
2004-08-05 09:45:35 +00:00
|
|
|
if (hints->ai_family == PF_UNSPEC && (seen_ipv4 || seen_ipv6))
|
2003-04-24 23:45:17 +00:00
|
|
|
{
|
|
|
|
/* If we haven't seen both IPv4 and IPv6 interfaces we can
|
|
|
|
narrow down the search. */
|
2008-11-27 06:31:04 +00:00
|
|
|
if ((! seen_ipv4 || ! seen_ipv6) && (seen_ipv4 || seen_ipv6))
|
2003-04-24 23:45:17 +00:00
|
|
|
{
|
|
|
|
local_hints = *hints;
|
|
|
|
local_hints.ai_family = seen_ipv4 ? PF_INET : PF_INET6;
|
|
|
|
hints = &local_hints;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((hints->ai_family == PF_INET && ! seen_ipv4)
|
|
|
|
|| (hints->ai_family == PF_INET6 && ! seen_ipv6))
|
2006-04-16 21:34:32 +00:00
|
|
|
{
|
|
|
|
/* We cannot possibly return a valid answer. */
|
|
|
|
free (in6ai);
|
|
|
|
return EAI_NONAME;
|
|
|
|
}
|
2003-04-24 23:45:17 +00:00
|
|
|
}
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if (service && service[0])
|
|
|
|
{
|
|
|
|
char *c;
|
|
|
|
gaih_service.name = service;
|
|
|
|
gaih_service.num = strtoul (gaih_service.name, &c, 10);
|
2004-08-05 09:45:35 +00:00
|
|
|
if (*c != '\0')
|
|
|
|
{
|
|
|
|
if (hints->ai_flags & AI_NUMERICSERV)
|
2006-04-16 21:34:32 +00:00
|
|
|
{
|
|
|
|
free (in6ai);
|
|
|
|
return EAI_NONAME;
|
|
|
|
}
|
2004-08-05 09:45:35 +00:00
|
|
|
|
|
|
|
gaih_service.num = -1;
|
|
|
|
}
|
2004-09-26 08:43:34 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
pservice = &gaih_service;
|
|
|
|
}
|
|
|
|
else
|
1996-10-21 01:26:31 +00:00
|
|
|
pservice = NULL;
|
|
|
|
|
2008-06-13 23:35:47 +00:00
|
|
|
struct addrinfo **end = &p;
|
1997-02-19 04:43:53 +00:00
|
|
|
|
2005-11-27 23:13:21 +00:00
|
|
|
unsigned int naddrs = 0;
|
2006-04-18 23:35:12 +00:00
|
|
|
if (hints->ai_family == AF_UNSPEC || hints->ai_family == AF_INET
|
|
|
|
|| hints->ai_family == AF_INET6)
|
|
|
|
{
|
|
|
|
last_i = gaih_inet (name, pservice, hints, end, &naddrs);
|
|
|
|
if (last_i != 0)
|
|
|
|
{
|
|
|
|
freeaddrinfo (p);
|
|
|
|
free (in6ai);
|
|
|
|
|
2006-04-26 19:36:15 +00:00
|
|
|
return -(last_i & GAIH_EAI);
|
2006-04-18 23:35:12 +00:00
|
|
|
}
|
2008-06-13 23:35:47 +00:00
|
|
|
while (*end)
|
|
|
|
{
|
|
|
|
end = &((*end)->ai_next);
|
|
|
|
++nresults;
|
|
|
|
}
|
2006-04-18 23:35:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
free (in6ai);
|
|
|
|
return EAI_FAMILY;
|
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
|
2005-11-27 23:13:21 +00:00
|
|
|
if (naddrs > 1)
|
2003-11-18 07:04:13 +00:00
|
|
|
{
|
2006-05-04 06:38:07 +00:00
|
|
|
/* Read the config file. */
|
|
|
|
__libc_once_define (static, once);
|
|
|
|
__typeof (once) old_once = once;
|
|
|
|
__libc_once (once, gaiconf_init);
|
2003-11-18 07:04:13 +00:00
|
|
|
/* Sort results according to RFC 3484. */
|
|
|
|
struct sort_result results[nresults];
|
2008-01-10 20:00:52 +00:00
|
|
|
size_t order[nresults];
|
2003-11-18 07:04:13 +00:00
|
|
|
struct addrinfo *q;
|
2004-09-15 08:25:49 +00:00
|
|
|
struct addrinfo *last = NULL;
|
2004-08-14 20:13:23 +00:00
|
|
|
char *canonname = NULL;
|
2003-11-18 07:04:13 +00:00
|
|
|
|
2007-11-14 06:58:35 +00:00
|
|
|
/* If we have information about deprecated and temporary addresses
|
2006-04-16 21:34:32 +00:00
|
|
|
sort the array now. */
|
|
|
|
if (in6ai != NULL)
|
|
|
|
qsort (in6ai, in6ailen, sizeof (*in6ai), in6aicmp);
|
|
|
|
|
2007-09-19 22:12:22 +00:00
|
|
|
int fd = -1;
|
|
|
|
int af = AF_UNSPEC;
|
|
|
|
|
2004-09-15 08:25:49 +00:00
|
|
|
for (i = 0, q = p; q != NULL; ++i, last = q, q = q->ai_next)
|
2003-11-18 07:04:13 +00:00
|
|
|
{
|
|
|
|
results[i].dest_addr = q;
|
2007-11-14 06:58:35 +00:00
|
|
|
results[i].native = -1;
|
2008-01-10 20:00:52 +00:00
|
|
|
order[i] = i;
|
2003-11-18 07:04:13 +00:00
|
|
|
|
2004-09-25 15:06:34 +00:00
|
|
|
/* If we just looked up the address for a different
|
2004-09-15 08:25:49 +00:00
|
|
|
protocol, reuse the result. */
|
|
|
|
if (last != NULL && last->ai_addrlen == q->ai_addrlen
|
|
|
|
&& memcmp (last->ai_addr, q->ai_addr, q->ai_addrlen) == 0)
|
2003-11-18 07:04:13 +00:00
|
|
|
{
|
2004-09-15 08:25:49 +00:00
|
|
|
memcpy (&results[i].source_addr, &results[i - 1].source_addr,
|
|
|
|
results[i - 1].source_addr_len);
|
|
|
|
results[i].source_addr_len = results[i - 1].source_addr_len;
|
|
|
|
results[i].got_source_addr = results[i - 1].got_source_addr;
|
2006-04-16 21:34:32 +00:00
|
|
|
results[i].source_addr_flags = results[i - 1].source_addr_flags;
|
2007-11-12 23:55:58 +00:00
|
|
|
results[i].prefixlen = results[i - 1].prefixlen;
|
2007-11-14 06:58:35 +00:00
|
|
|
results[i].index = results[i - 1].index;
|
2004-09-15 08:25:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-11-12 23:55:58 +00:00
|
|
|
results[i].got_source_addr = false;
|
2006-04-16 21:34:32 +00:00
|
|
|
results[i].source_addr_flags = 0;
|
2007-11-12 23:55:58 +00:00
|
|
|
results[i].prefixlen = 0;
|
2007-11-14 06:58:35 +00:00
|
|
|
results[i].index = 0xffffffffu;
|
2006-04-16 21:34:32 +00:00
|
|
|
|
2004-09-25 15:06:34 +00:00
|
|
|
/* We overwrite the type with SOCK_DGRAM since we do not
|
|
|
|
want connect() to connect to the other side. If we
|
|
|
|
cannot determine the source address remember this
|
|
|
|
fact. */
|
2007-09-19 22:12:22 +00:00
|
|
|
if (fd == -1 || (af == AF_INET && q->ai_family == AF_INET6))
|
|
|
|
{
|
|
|
|
if (fd != -1)
|
|
|
|
close_retry:
|
2007-09-24 15:18:25 +00:00
|
|
|
close_not_cancel_no_status (fd);
|
2007-09-19 22:12:22 +00:00
|
|
|
af = q->ai_family;
|
|
|
|
fd = __socket (af, SOCK_DGRAM, IPPROTO_IP);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Reset the connection. */
|
|
|
|
struct sockaddr sa = { .sa_family = AF_UNSPEC };
|
|
|
|
__connect (fd, &sa, sizeof (sa));
|
|
|
|
}
|
|
|
|
|
2004-09-25 15:06:34 +00:00
|
|
|
socklen_t sl = sizeof (results[i].source_addr);
|
|
|
|
if (fd != -1
|
|
|
|
&& __connect (fd, q->ai_addr, q->ai_addrlen) == 0
|
|
|
|
&& __getsockname (fd,
|
|
|
|
(struct sockaddr *) &results[i].source_addr,
|
|
|
|
&sl) == 0)
|
2004-09-15 08:25:49 +00:00
|
|
|
{
|
2004-09-25 15:06:34 +00:00
|
|
|
results[i].source_addr_len = sl;
|
|
|
|
results[i].got_source_addr = true;
|
2006-04-16 21:34:32 +00:00
|
|
|
|
2007-11-12 23:55:58 +00:00
|
|
|
if (in6ai != NULL)
|
2006-04-16 21:34:32 +00:00
|
|
|
{
|
2007-09-19 22:12:22 +00:00
|
|
|
/* See whether the source address is on the list of
|
[BZ #2510, BZ #2830, BZ #3137, BZ #3313, BZ #3426, BZ #3465, BZ #3480, BZ #3483, BZ #3493, BZ #3514, BZ #3515, BZ #3664, BZ #3673, BZ #3674]
2007-01-11 Jakub Jelinek <jakub@redhat.com>
* sysdeps/i386/soft-fp/sfp-machine.h: Remove.
* sysdeps/x86_64/soft-fp/sfp-machine.h: Likewise.
2007-01-10 Ulrich Drepper <drepper@redhat.com>
* io/fts.c: Make sure fts_cur is always valid after return from
fts_read.
Patch by Miloslav Trmac <mitr@redhat.com>.
2006-10-27 Richard Sandiford <richard@codesourcery.com>
* elf/elf.h (R_MIPS_GLOB_DAT): Define.
(R_MIPS_NUM): Bump by 1.
2007-01-03 Jakub Jelinek <jakub@redhat.com>
* posix/execvp.c: Include alloca.h.
(allocate_scripts_argv): Renamed to...
(scripts_argv): ... this. Don't allocate buffer here nor count
arguments.
(execvp): Use alloca if possible.
* posix/Makefile: Add rules to build and run tst-vfork3 test.
* posix/tst-vfork3.c: New test.
* stdlib/Makefile (tst-strtod3-ENV): Define.
2007-01-02 Ulrich Drepper <drepper@redhat.com>
* posix/getconf.c: Update copyright year.
* nss/getent.c: Likewise.
* iconv/iconvconfig.c: Likewise.
* iconv/iconv_prog.c: Likewise.
* elf/ldconfig.c: Likewise.
* catgets/gencat.c: Likewise.
* csu/version.c: Likewise.
* elf/ldd.bash.in: Likewise.
* elf/sprof.c (print_version): Likewise.
* locale/programs/locale.c: Likewise.
* locale/programs/localedef.c: Likewise.
* nscd/nscd.c (print_version): Likewise.
* debug/xtrace.sh: Likewise.
* malloc/memusage.sh: Likewise.
* malloc/mtrace.pl: Likewise.
* debug/catchsegv.sh: Likewise.
2006-12-24 Ulrich Drepper <drepper@redhat.com>
* malloc/malloc.c (sYSMALLOc): Remove some unnecessary alignment
attempts.
2006-12-23 Ulrich Drepper <drepper@redhat.com>
* posix/wordexp.c: Remove some unnecessary tests.
2006-12-20 SUGIOKA Toshinobu <sugioka@itonet.co.jp>
* sysdeps/unix/sysv/linux/sh/bits/shm.h: New file.
* nss/getXXbyYY_r.c: Include atomic.h.
(INTERNAL (REENTRANT_NAME)): Write startp after start_fct,
add atomic_write_barrier () in between.
2006-11-28 Jakub Jelinek <jakub@redhat.com>
* elf/dl-support.c: Include dl-procinfo.h.
* sysdeps/powerpc/dl-procinfo.h (PPC_PLATFORM_POWER4,
PPC_PLATFORM_PPC970, PPC_PLATFORM_POWER5, PPC_PLATFORM_POWER5_PLUS,
PPC_PLATFORM_POWER6, PPC_PLATFORM_CELL_BE, PPC_PLATFORM_POWER6X):
Define.
(_dl_string_platform): Use PPC_PLATFORM_* macros instead of
hardcoded constants.
* sysdeps/powerpc/dl-procinfo.c (_dl_powerpc_platform): Use
PPC_PLATFORM_* macros for array designators.
2006-11-11 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/powerpc/dl-procinfo.c (_dl_powerpc_cap_flags): Add 3 new cap
names to the beginning.
(_dl_powerpc_platforms): Add "power6x".
* sysdeps/powerpc/dl-procinfo.h (_DL_HWCAP_FIRST): Decrease.
(HWCAP_IMPORTANT): Add PPC_FEATURE_HAS_DFP.
(_DL_PLATFORMS_COUNT): Increase.
(_dl_string_platform): Handle power6x case.
* sysdeps/powerpc/sysdep.h (PPC_FEATURE_PA6T, PPC_FEATURE_HAS_DFP,
PPC_FEATURE_POWER6_EXT): Define.
(PPC_FEATURE_POWER5, PPC_FEATURE_POWER5_PLUS): Correct Comment.
[-2^31 .. 2^31) range.
* sysdeps/unix/sysv/linux/bits/statvfs.h: Define ST_RELATIME.
* sysdeps/unix/sysv/linux/internal_statvfs.c (__statvfs_getflags):
Handle relatime mount option.
2006-12-13 Jakub Jelinek <jakub@redhat.com>
* sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S: Include
kernel-features.h.
2006-12-11 Ulrich Drepper <drepper@redhat.com>
* stdlib/strtod_l.c (____STRTOF_INTERNAL): Parse thousand
separators also if no non-zero digits found.
* stdlib/Makefile (tests): Add tst-strtod3.
[BZ #3664]
* stdlib/strtod_l.c (____STRTOF_INTERNAL): Fix test to recognize
empty parsed strings.
* stdlib/Makefile (tests): Add tst-strtod2.
* stdlib/tst-strtod2.c: New file.
[BZ #3673]
* stdlib/strtod_l.c (____STRTOF_INTERNAL): Fix exp_limit
computation.
* stdlib/Makefile (tests): Add tst-atof2.
* stdlib/tst-atof2.c: New file.
[BZ #3674]
* stdlib/strtod_l.c (____STRTOF_INTERNAL): Adjust exponent value
correctly if removing trailing zero of hex-float.
* stdlib/Makefile (tests): Add tst-atof1.
* stdlib/tst-atof1.c: New file.
* misc/mntent_r.c (__hasmntopt): Check p[optlen] even when p == rest.
Start searching for next comma at p rather than rest.
* misc/Makefile (tests): Add tst-mntent2.
* misc/tst-mntent2.c: New test.
2006-12-08 Ulrich Drepper <drepper@redhat.com>
* malloc/memusage.c: Handle realloc with new size of zero and
non-NULL pointer correctly.
(me): Really write first record twice.
(struct entry): Make format bi-arch safe.
(dest): Write out more realloc statistics.
* malloc/memusagestat.c (struct entry): Make format bi-arch safe.
2006-12-05 Jakub Jelinek <jakub@redhat.com>
* nis/nis_subr.c (nis_getnames): Revert last change.
2006-12-03 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sys/io.h: Removed.
2006-11-30 H.J. Lu <hongjiu.lu@intel.com>
* sysdeps/i386/i686/memcmp.S: Use jump table as the base of
jump table entries.
2006-11-30 Jan Kratochvil <jan.kratochvil@redhat.com>
* sysdeps/unix/sysv/linux/i386/clone.S: Provide CFI for the outermost
`clone' function to ensure proper unwinding stop of gdb.
* sysdeps/unix/sysv/linux/x86_64/clone.S: Likewise.
2006-12-01 Ulrich Drepper <drepper@redhat.com>
* nscd/nscd.init: Remove obsolete and commented-out -S option
handling.
2006-11-23 Jakub Jelinek <jakub@redhat.com>
[BZ #3514]
* manual/string.texi (strncmp): Fix pastos from wcscmp description.
[BZ #3515]
* manual/string.texi (strtok): Remove duplicate paragraph.
2006-12-01 Jan Kratochvil <jan.kratochvil@redhat.com>
* sysdeps/unix/sysv/linux/x86_64/sigaction.c: Fix compatibility with
libgcc not supporting `rflags' unwinding (register # >= 17).
2006-11-30 Jakub Jelinek <jakub@redhat.com>
* sunrpc/svc_run.c (svc_run): Set my_pollfd to new_pollfd if realloc
succeeded.
2006-11-29 Daniel Jacobowitz <dan@codesourcery.com>
Jakub Jelinek <jakub@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
* sysdeps/unix/sysv/linux/x86_64/sigaction.c (restore_rt): Add correct
unwind information.
* sysdeps/unix/sysv/linux/x86_64/Makefile: Provide symbols for
'restore_rt' even in the 'signal' directory.
* sysdeps/unix/sysv/linux/x86_64/ucontext_i.sym: Extend the regs list.
malloc crashed. Don't allocate memory unnecessarily in each
loop.
2006-10-21 Jakub Jelinek <jakub@redhat.com>
* resolv/mapv4v6addr.h (map_v4v6_address): Fix last change.
2006-11-20 Ulrich Drepper <drepper@redhat.com>
* resolv/mapv4v6addr.h (map_v4v6_address): Optimize a bit.
2006-11-18 Bruno Haible <bruno@clisp.org>
* sysdeps/unix/sysv/linux/i386/getgroups.c (__getgroups): Invoke
__sysconf only after having tried to call getgroups32.
2006-11-19 Ulrich Drepper <drepper@redhat.com>
* nss/nss_files/files-hosts.c (LINE_PARSER): Support IPv6-style
addresses for IPv4 queries if they can be mapped.
2006-11-16 Jakub Jelinek <jakub@redhat.com>
* sysdeps/x86_64/fpu/s_copysignf.S (__copysignf): Switch to .text.
* sysdeps/x86_64/fpu/s_copysign.S (__copysign): Likewise.
(signmask): Add .size directive.
(othermask): Add .type directive.
2006-11-14 Ulrich Drepper <drepper@redhat.com>
* po/nl.po: Update from translation team.
* timezone/zdump.c: Redo fix for BZ #3137.
2006-11-14 Jakub Jelinek <jakub@redhat.com>
* nss/nss_files/files-alias.c (get_next_alias): Set line back
to first_unused after parsing :include: file.
* timezone/africa: Update from tzdata2006o.
* timezone/antarctica: Likewise.
* timezone/asia: Likewise.
* timezone/australasia: Likewise.
* timezone/backward: Likewise.
* timezone/europe: Likewise.
* timezone/iso3166.tab: Likewise.
* timezone/northamerica: Likewise.
* timezone/southamerica: Likewise.
* timezone/zone.tab: Likewise.
* time/tzfile.c (__tzfile_read): Extend to handle new file format
on machines with 64-bit time_t.
* timezone/checktab.awk: Update from tzcode2006o.
* timezone/ialloc.c: Likewise.
* timezone/private.h: Likewise.
* timezone/scheck.c: Likewise.
* timezone/tzfile.h: Likewise.
* timezone/tzselect.ksh: Likewise.
* timezone/zdump.c: Likewise.
* timezone/zic.c: Likewise.
[BZ #3483]
* elf/ldconfig.c (main): Call setlocale and textdomain.
Patch mostly by Benno Schulenberg <bensberg@justemail.net>.
[BZ #3480]
* manual/argp.texi: Fix typos.
* manual/charset.texi: Likewise.
* manual/errno.texi: Likewise.
* manual/filesys.texi: Likewise.
* manual/lang.texi: Likewise.
* manual/maint.texi: Likewise.
* manual/memory.texi: Likewise.
* manual/message.texi: Likewise.
* manual/resource.texi: Likewise.
* manual/search.texi: Likewise.
* manual/signal.texi: Likewise.
* manual/startup.texi: Likewise.
* manual/stdio.texi: Likewise.
* manual/sysinfo.texi: Likewise.
* manual/syslog.texi: Likewise.
* manual/time.texi: Likewise.
Patch by Ralf Wildenhues <Ralf.Wildenhues@gmx.de>.
[BZ #3465]
* sunrpc/clnt_raw.c: Minimal message improvements.
* sunrpc/pm_getmaps.c: Likewise.
* nis/nss_nisplus/nisplus-publickey.c: Likewise.
* nis/nis_print_group_entry.c: Likewise.
* locale/programs/repertoire.c: Likewise.
* locale/programs/charmap.c: Likewise.
* malloc/memusage.sh: Likewise.
* elf/dl-deps.c: Likewise.
* locale/programs/ld-collate.c: Likewise.
* libio/vswprintf.c: Likewise.
* malloc/memusagestat.c: Likewise.
* sunrpc/auth_unix.c: Likewise.
* sunrpc/rpc_main.c: Likewise.
* nscd/cache.c: Likewise.
* locale/programs/repertoire.c: Unify output messages.
* locale/programs/charmap.c: Likewise.
* locale/programs/ld-ctype.c: Likewise.
* locale/programs/ld-monetary.c: Likewise.
* locale/programs/ld-numeric.c: Likewise.
* locale/programs/ld-time.c: Likewise.
* elf/ldconfig.c: Likewise.
* nscd/selinux.c: Likewise.
* elf/cache.c: Likewise.
Patch mostly by Benno Schulenberg <bensberg@justemail.net>.
2006-11-10 Jakub Jelinek <jakub@redhat.com>
* string/strxfrm_l.c (STRXFRM): Fix trailing \1 optimization
if N is one bigger than return value.
* string/tst-strxfrm2.c (do_test): Also test strxfrm with l1 + 1
and l1 last arguments, if buf is defined, verify the return value
equals to strlen (buf) and verify no byte beyond passed length
is modified.
2006-11-10 Ulrich Drepper <drepper@redhat.com>
* po/sv.po: Update from translation team.
* sysdeps/gnu/siglist.c (__old_sys_siglist, __old_sys_sigabbrev):
Use __new_sys_siglist instead of _sys_siglist_internal as
second macro argument.
(_old_sys_siglist): Use declare_symbol_alias macro instead of
strong_alias.
2006-11-09 Ulrich Drepper <drepper@redhat.com>
[BZ #3493]
* posix/unistd.h (sysconf): Remove const attribute.
* sysdeps/posix/getaddrinfo.c (getaddrinfo): Fix test for
temporary or deprecated addresses.
Patch by Sridhar Samudrala <sri@us.ibm.com>.
* string/Makefile (tests): Add tst-strxfrm2.
* string/tst-strxfrm2.c: New file.
2006-10-09 Jakub Jelinek <jakub@redhat.com>
* elf/dl-debug.c (_dl_debug_initialize): Check r->r_map for 0
rather than r->r_brk.
* string/strxfrm_l.c (STRXFRM): Do the trailing \1 removal
optimization even if needed > n.
2006-11-07 Jakub Jelinek <jakub@redhat.com>
* include/libc-symbols.h (declare_symbol): Rename to...
(declare_symbol_alias): ... this. Add ORIGINAL argument, imply
strong_alias (ORIGINAL, SYMBOL) in asm to make sure it preceedes
.size directive.
* sysdeps/gnu/errlist-compat.awk: Adjust for declare_symbol_alias
changes.
* sysdeps/gnu/siglist.c: Likewise.
2006-11-03 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/powerpc/fpu/bits/mathinline.h
[__LIBC_INTERNAL_MATH_INLINES]: Moved to ...
* sysdeps/powerpc/fpu/math_private.h: ...here. New file.
2006-11-05 Ulrich Drepper <drepper@redhat.com>
* sysdeps/unix/sysv/linux/i386/sysconf.c (intel_check_word):
Update handling of cache descriptor 0x49 for new models.
* sysdeps/unix/sysv/linux/x86_64/sysconf.c (intel_check_word):
Likewise.
2006-11-02 Ulrich Drepper <drepper@redhat.com>
* configure.in: Work around ld --help change and avoid -z relro
test completely if the architecture doesn't care about security.
2006-11-01 Ulrich Drepper <drepper@redhat.com>
* po/sv.po: Update from translation team.
2006-10-31 Ulrich Drepper <drepper@redhat.com>
* stdlib/atexit.c (atexit): Don't mark as hidden when used to
generate compatibility version.
2006-10-29 Ulrich Drepper <drepper@redhat.com>
* configure.in: Relax -z relro requirement a bit.
* po/sv.po: Update from translation team.
2006-10-29 Jakub Jelinek <jakub@redhat.com>
* elf/dl-sym.c (do_sym): Use RTLD_SINGLE_THREAD_P.
* elf/dl-runtime.c (_dl_fixup, _dl_profile_fixup): Likewise.
* elf/dl-close.c (_dl_close_worker): Likewise.
* elf/dl-open.c (_dl_open_worker): Likewise.
* sysdeps/generic/sysdep-cancel.h (RTLD_SINGLE_THREAD_P): Define.
* configure.in: Require assembler support for visibility, compiler
support for visibility and aliases, linker support for various -z
options.
* Makeconfig: Remove conditional code which now is unnecessary.
* config.h.in: Likewise.
* config.make.in: Likewise.
* dlfcn/Makefile: Likewise.
* elf/Makefile: Likewise.
* elf/dl-load.c: Likewise.
* elf/rtld.c: Likewise.
* include/libc-symbols.h: Likewise.
* include/stdio.h: Likewise.
* io/Makefile: Likewise.
* io/fstat.c: Likewise.
* io/fstat64.c: Likewise.
* io/fstatat.c: Likewise.
* io/fstatat64.c: Likewise.
* io/lstat.c: Likewise.
* io/lstat64.c: Likewise.
* io/mknod.c: Likewise.
* io/mknodat.c: Likewise.
* io/stat.c: Likewise.
* io/stat64.c: Likewise.
* libio/stdio.c: Likewise.
* nscd/Makefile: Likewise.
* stdlib/Makefile: Likewise.
* stdlib/atexit.c: Likewise.
* sysdeps/generic/ldsodefs.h: Likewise.
* sysdeps/i386/dl-machine.h: Likewise.
* sysdeps/i386/sysdep.h: Likewise.
* sysdeps/i386/i686/memcmp.S: Likewise.
* sysdeps/powerpc/powerpc32/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/i386/sigaction.c: Likewise.
* sysdeps/unix/sysv/linux/x86_64/sigaction.c: Likewise.
* Makerules: USE_TLS support is now default.
* tls.make.c: Likewise.
* csu/Versions: Likewise.
* csu/libc-start.c: Likewise.
* csu/libc-tls.c: Likewise.
* csu/version.c: Likewise.
* dlfcn/dlinfo.c: Likewise.
* elf/dl-addr.c: Likewise.
* elf/dl-cache.c: Likewise.
* elf/dl-close.c: Likewise.
* elf/dl-iteratephdr.c: Likewise.
* elf/dl-load.c: Likewise.
* elf/dl-lookup.c: Likewise.
* elf/dl-object.c: Likewise.
* elf/dl-open.c: Likewise.
* elf/dl-reloc.c: Likewise.
* elf/dl-support.c: Likewise.
* elf/dl-sym.c: Likewise.
* elf/dl-sysdep.c: Likewise.
* elf/dl-tls.c: Likewise.
* elf/ldconfig.c: Likewise.
* elf/rtld.c: Likewise.
* elf/tst-tls-dlinfo.c: Likewise.
* elf/tst-tls1.c: Likewise.
* elf/tst-tls10.h: Likewise.
* elf/tst-tls14.c: Likewise.
* elf/tst-tls2.c: Likewise.
* elf/tst-tls3.c: Likewise.
* elf/tst-tls4.c: Likewise.
* elf/tst-tls5.c: Likewise.
* elf/tst-tls6.c: Likewise.
* elf/tst-tls7.c: Likewise.
* elf/tst-tls8.c: Likewise.
* elf/tst-tls9.c: Likewise.
* elf/tst-tlsmod1.c: Likewise.
* elf/tst-tlsmod13.c: Likewise.
* elf/tst-tlsmod13a.c: Likewise.
* elf/tst-tlsmod14a.c: Likewise.
* elf/tst-tlsmod2.c: Likewise.
* elf/tst-tlsmod3.c: Likewise.
* elf/tst-tlsmod4.c: Likewise.
* elf/tst-tlsmod5.c: Likewise.
* elf/tst-tlsmod6.c: Likewise.
* include/errno.h: Likewise.
* include/link.h: Likewise.
* include/tls.h: Likewise.
* locale/global-locale.c: Likewise.
* locale/localeinfo.h: Likewise.
* malloc/arena.c: Likewise.
* malloc/hooks.c: Likewise.
* malloc/malloc.c: Likewise.
* resolv/Versions: Likewise.
* sysdeps/alpha/dl-machine.h: Likewise.
* sysdeps/alpha/libc-tls.c: Likewise.
* sysdeps/generic/ldsodefs.h: Likewise.
* sysdeps/generic/tls.h: Likewise.
* sysdeps/i386/dl-machine.h: Likewise.
* sysdeps/ia64/dl-machine.h: Likewise.
* sysdeps/ia64/libc-tls.c: Likewise.
* sysdeps/mach/hurd/fork.c: Likewise.
* sysdeps/mach/hurd/i386/tls.h: Likewise.
* sysdeps/powerpc/powerpc32/dl-machine.c: Likwise.
* sysdeps/powerpc/powerpc32/dl-machine.h: Likewise.
* sysdeps/powerpc/powerpc64/dl-machine.h: Likewise.
* sysdeps/s390/libc-tls.c: Likewise.
* sysdeps/s390/s390-32/dl-machine.h: Likewise.
* sysdeps/s390/s390-64/dl-machine.h: Likewise.
* sysdeps/sh/dl-machine.h: Likewise.
* sysdeps/sparc/sparc32/dl-machine.h: Likewise.
* sysdeps/sparc/sparc64/dl-machine.h: Likewise.
* sysdeps/x86_64/dl-machine.h: Likewise.
[BZ #3426]
* stdlib/stdlib.h: Adjust comment for canonicalize_file_name to
reality.
2006-10-27 Jakub Jelinek <jakub@redhat.com>
* elf/dl-lookup.c (_dl_debug_bindings): Remove unused symbol_scope
argument.
(_dl_lookup_symbol_x): Adjust caller.
* sysdeps/generic/ldsodefs.h (struct link_namespaces): Remove
_ns_global_scope.
* elf/rtld.c (dl_main): Don't initialize _ns_global_scope.
* elf/dl-libc.c: Revert l_scope name changes.
* elf/dl-load.c: Likewise.
* elf/dl-object.c: Likewise.
* elf/rtld.c: Likewise.
* elf/dl-close.c (_dl_close): Likewise.
* elf/dl-open.c (dl_open_worker): Likewise. If not SINGLE_THREAD_P,
always use __rtld_mrlock_{change,done}. Always free old scope list
here if not l_scope_mem.
* elf/dl-runtime.c (_dl_fixup, _dl_profile_fixup): Revert l_scope name
change. Never free scope list here. Just __rtld_mrlock_lock before
the lookup and __rtld_mrlock_unlock it after the lookup.
* elf/dl-sym.c: Likewise.
* include/link.h (struct r_scoperec): Remove.
(struct link_map): Replace l_scoperec with l_scope, l_scoperec_mem
with l_scope_mem and l_scoperec_lock with l_scope_lock.
2006-10-25 Ulrich Drepper <drepper@redhat.com>
* sysdeps/gnu/netinet/tcp.h: Define TCP_CONGESTION.
2006-10-18 Ulrich Drepper <drepper@redhat.com>
* configure.in: Disable building profile libraries by default.
2006-10-18 Ulrich Drepper <drepper@redhat.com>
* elf/dl-lookup.c (_dl_lookup_symbol_x): Add warning to
_dl_lookup_symbol_x code.
2006-10-17 Jakub Jelinek <jakub@redhat.com>
* elf/dl-runtime.c: Include sysdep-cancel.h.
(_dl_fixup, _dl_profile_fixup): Use __rtld_mrlock_* and
scoperec->nusers only if !SINGLE_THREAD_P. Use atomic_*
instead of catomic_* macros.
* elf/dl-sym.c: Include sysdep-cancel.h.
(do_sym): Use __rtld_mrlock_* and scoperec->nusers only
if !SINGLE_THREAD_P. Use atomic_* instead of catomic_* macros.
* elf/dl-close.c: Include sysdep-cancel.h.
(_dl_close): Use __rtld_mrlock_* and scoperec->nusers only
if !SINGLE_THREAD_P. Use atomic_* instead of catomic_* macros.
* elf/dl-open.c: Include sysdep-cancel.h.
(dl_open_worker): Use __rtld_mrlock_* and scoperec->nusers only
if !SINGLE_THREAD_P. Use atomic_* instead of catomic_* macros.
2006-10-17 Jakub Jelinek <jakub@redhat.com>
[BZ #3313]
* malloc/malloc.c (malloc_consolidate): Set maxfb to address of last
fastbin rather than end of fastbin array.
2006-10-18 Ulrich Drepper <drepper@redhat.com>
* sysdeps/i386/i486/bits/atomic.h (catomic_decrement): Use correct
body macro.
* sysdeps/x86_64/bits/atomic.h
(__arch_c_compare_and_exchange_val_64_acq): Add missing casts.
(catomic_decrement): Use correct body macro.
2006-10-17 Jakub Jelinek <jakub@redhat.com>
* include/atomic.h: Add a unique prefix to all local variables
in macros.
* csu/tst-atomic.c (do_test): Test also catomic_* macros.
2006-10-14 Ulrich Drepper <drepper@redhat.com>
* resolv/arpa/nameser.h: Document that ns_t_a6 is deprecated.
[BZ #3313]
* malloc/malloc.c (malloc_consolidate): Don't use get_fast_max to
determine highest fast bin to consolidate, always look into all of
them.
(do_check_malloc_state): Only require for empty bins for large
sizes in main arena.
* libio/stdio.h: Add more __wur attributes.
2006-11-12 Andreas Jaeger <aj@suse.de>
[BZ #2510]
* manual/search.texi (Hash Search Function): Clarify.
(Array Search Function): Clarify.
2006-11-12 Joseph Myers <joseph@codesourcery.com>
[BZ #2830]
* math/atest-exp.c (main): Cast hex value to mp_limb_t before
shifting.
* math/atest-exp2.c (read_mpn_hex): Likewise.
* math/atest-sincos.c (main): Likewise.
* sysdeps/unix/sysv/linux/syscalls.list: Add epoll_pwait.
* sysdeps/unix/sysv/linux/sys/epoll.h: Declare epoll_pwait.
* sysdeps/unix/sysv/linux/Versions (libc): Add epoll_pwait for
version GLIBC_2.6.
* Versions.def: Add GLIBC_2.6 for libc.
* sysdeps/i386/i486/bits/atomic.h: Add catomic_* support.
2006-10-11 Jakub Jelinek <jakub@redhat.com>
* malloc/malloc.c (_int_malloc): Remove unused any_larger variable.
* nis/nis_defaults.c (__nis_default_access): Don't call getenv twice.
* nis/nis_subr.c (nis_getnames): Use __secure_getenv instead of getenv.
* sysdeps/generic/unsecvars.h: Add NIS_PATH.
2006-10-11 Ulrich Drepper <drepper@redhat.com>
* include/atomic.c: Define catomic_* operations.
* sysdeps/x86_64/bits/atomic.h: Likewise. Fix a few minor problems.
* stdlib/cxa_finalize.c: Use catomic_* operations instead of atomic_*.
* malloc/memusage.c: Likewise.
* gmon/mcount.c: Likewise.
* elf/dl-close.c: Likewise.
* elf/dl-open.c: Likewise.
* elf/dl-profile.c: Likewise.
* elf/dl-sym.c: Likewise.
* elf/dl-runtime.c: Likewise.
* elf/dl-fptr.c: Likewise.
* resolv/res_libc.c: Likewise.
2006-10-10 Roland McGrath <roland@frob.com>
* sysdeps/mach/hurd/utimes.c: Use a union to avoid an improper cast.
* sysdeps/mach/hurd/futimes.c: Likewise.
* sysdeps/mach/hurd/lutimes.c: Likewise.
2006-10-09 Ulrich Drepper <drepper@redhat.com>
Jakub Jelinek <jakub@redhat.com>
Implement reference counting of scope records.
* elf/dl-close.c (_dl_close): Remove all scopes from removed objects
from the list in objects which remain. Always allocate new scope
record.
* elf/dl-open.c (dl_open_worker): When growing array for scopes,
don't resize, allocate a new one.
* elf/dl-runtime.c: Update reference counters before using a scope
array.
* elf/dl-sym.c: Likewise.
* elf/dl-libc.c: Adjust for l_scope name change.
* elf/dl-load.c: Likewise.
* elf/dl-object.c: Likewise.
* elf/rtld.c: Likewise.
* include/link.h: Include <rtld-lowlevel.h>. Define struct
r_scoperec. Replace r_scope with pointer to r_scoperec structure.
Add l_scoperec_lock.
* sysdeps/generic/ldsodefs.h: Include <rtld-lowlevel.h>.
* sysdeps/generic/rtld-lowlevel.h: New file.
* include/atomic.h: Rename atomic_and to atomic_and_val and
atomic_or to atomic_or_val. Define new macros atomic_and and
atomic_or which do not return values.
* sysdeps/x86_64/bits/atomic.h: Define atomic_and and atomic_or.
Various cleanups.
* sysdeps/i386/i486/bits/atomic.h: Likewise.
* po/sv.po: Update from translation team.
2006-10-07 Ulrich Drepper <drepper@redhat.com>
* Versions.def: Add GLIBC_2.6 to libpthread.
* include/shlib-compat.h (SHLIB_COMPAT): Expand parameters before use.
(versioned_symbol): Likewise.
(compat_symbol): Likewise.
* po/tr.po: Update from translation team.
* nis/Banner: Removed. It's been integral part forever and the
author info is incomplete anyway.
* libio/Banner: Likewise.
2006-10-06 Ulrich Drepper <drepper@redhat.com>
* version.h (VERSION): Bump to 2.5.90 for new development tree.
2007-01-11 21:51:07 +00:00
|
|
|
deprecated or temporary addresses. */
|
2006-04-16 21:34:32 +00:00
|
|
|
struct in6addrinfo tmp;
|
2007-11-12 23:55:58 +00:00
|
|
|
|
|
|
|
if (q->ai_family == AF_INET && af == AF_INET)
|
|
|
|
{
|
|
|
|
struct sockaddr_in *sinp
|
|
|
|
= (struct sockaddr_in *) &results[i].source_addr;
|
|
|
|
tmp.addr[0] = 0;
|
|
|
|
tmp.addr[1] = 0;
|
|
|
|
tmp.addr[2] = htonl (0xffff);
|
|
|
|
tmp.addr[3] = sinp->sin_addr.s_addr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct sockaddr_in6 *sin6p
|
|
|
|
= (struct sockaddr_in6 *) &results[i].source_addr;
|
|
|
|
memcpy (tmp.addr, &sin6p->sin6_addr, IN6ADDRSZ);
|
|
|
|
}
|
2006-04-16 21:34:32 +00:00
|
|
|
|
|
|
|
struct in6addrinfo *found
|
|
|
|
= bsearch (&tmp, in6ai, in6ailen, sizeof (*in6ai),
|
|
|
|
in6aicmp);
|
|
|
|
if (found != NULL)
|
2007-11-12 23:55:58 +00:00
|
|
|
{
|
|
|
|
results[i].source_addr_flags = found->flags;
|
|
|
|
results[i].prefixlen = found->prefixlen;
|
2007-11-14 06:58:35 +00:00
|
|
|
results[i].index = found->index;
|
2007-11-12 23:55:58 +00:00
|
|
|
}
|
2006-04-16 21:34:32 +00:00
|
|
|
}
|
2007-11-12 23:55:58 +00:00
|
|
|
|
|
|
|
if (q->ai_family == AF_INET && af == AF_INET6)
|
2007-09-19 22:12:22 +00:00
|
|
|
{
|
|
|
|
/* We have to convert the address. The socket is
|
|
|
|
IPv6 and the request is for IPv4. */
|
|
|
|
struct sockaddr_in6 *sin6
|
|
|
|
= (struct sockaddr_in6 *) &results[i].source_addr;
|
|
|
|
struct sockaddr_in *sin
|
|
|
|
= (struct sockaddr_in *) &results[i].source_addr;
|
|
|
|
assert (IN6_IS_ADDR_V4MAPPED (sin6->sin6_addr.s6_addr32));
|
2007-11-12 23:55:58 +00:00
|
|
|
sin->sin_family = AF_INET;
|
|
|
|
/* We do not have to initialize sin_port since this
|
|
|
|
fields has the same position and size in the IPv6
|
|
|
|
structure. */
|
|
|
|
assert (offsetof (struct sockaddr_in, sin_port)
|
|
|
|
== offsetof (struct sockaddr_in6, sin6_port));
|
|
|
|
assert (sizeof (sin->sin_port)
|
|
|
|
== sizeof (sin6->sin6_port));
|
2007-09-19 22:12:22 +00:00
|
|
|
memcpy (&sin->sin_addr,
|
|
|
|
&sin6->sin6_addr.s6_addr32[3], INADDRSZ);
|
2007-11-12 23:55:58 +00:00
|
|
|
results[i].source_addr_len = sizeof (struct sockaddr_in);
|
2007-09-19 22:12:22 +00:00
|
|
|
}
|
2004-09-15 08:25:49 +00:00
|
|
|
}
|
2007-09-19 22:12:22 +00:00
|
|
|
else if (errno == EAFNOSUPPORT && af == AF_INET6
|
|
|
|
&& q->ai_family == AF_INET)
|
|
|
|
/* This could mean IPv6 sockets are IPv6-only. */
|
|
|
|
goto close_retry;
|
2004-09-25 15:06:34 +00:00
|
|
|
else
|
|
|
|
/* Just make sure that if we have to process the same
|
|
|
|
address again we do not copy any memory. */
|
|
|
|
results[i].source_addr_len = 0;
|
2003-11-18 07:04:13 +00:00
|
|
|
}
|
2004-08-14 20:13:23 +00:00
|
|
|
|
|
|
|
/* Remember the canonical name. */
|
|
|
|
if (q->ai_canonname != NULL)
|
|
|
|
{
|
|
|
|
assert (canonname == NULL);
|
|
|
|
canonname = q->ai_canonname;
|
|
|
|
q->ai_canonname = NULL;
|
|
|
|
}
|
2003-11-18 07:04:13 +00:00
|
|
|
}
|
|
|
|
|
2007-09-19 22:12:22 +00:00
|
|
|
if (fd != -1)
|
|
|
|
close_not_cancel_no_status (fd);
|
|
|
|
|
2003-11-18 07:04:13 +00:00
|
|
|
/* We got all the source addresses we can get, now sort using
|
|
|
|
the information. */
|
2007-11-14 06:58:35 +00:00
|
|
|
struct sort_result_combo src
|
|
|
|
= { .results = results, .nresults = nresults };
|
2007-10-17 16:05:34 +00:00
|
|
|
if (__builtin_expect (gaiconf_reload_flag_ever_set, 0))
|
|
|
|
{
|
|
|
|
__libc_lock_define_initialized (static, lock);
|
|
|
|
|
|
|
|
__libc_lock_lock (lock);
|
|
|
|
if (old_once && gaiconf_reload_flag)
|
|
|
|
gaiconf_reload ();
|
2008-01-10 20:00:52 +00:00
|
|
|
qsort_r (order, nresults, sizeof (order[0]), rfc3484_sort, &src);
|
2007-10-17 16:05:34 +00:00
|
|
|
__libc_lock_unlock (lock);
|
|
|
|
}
|
|
|
|
else
|
2008-01-10 20:00:52 +00:00
|
|
|
qsort_r (order, nresults, sizeof (order[0]), rfc3484_sort, &src);
|
2003-11-18 07:04:13 +00:00
|
|
|
|
|
|
|
/* Queue the results up as they come out of sorting. */
|
2008-01-10 20:00:52 +00:00
|
|
|
q = p = results[order[0]].dest_addr;
|
2003-11-18 07:04:13 +00:00
|
|
|
for (i = 1; i < nresults; ++i)
|
2008-01-10 20:00:52 +00:00
|
|
|
q = q->ai_next = results[order[i]].dest_addr;
|
2003-11-18 07:04:13 +00:00
|
|
|
q->ai_next = NULL;
|
2004-08-14 20:13:23 +00:00
|
|
|
|
|
|
|
/* Fill in the canonical name into the new first entry. */
|
|
|
|
p->ai_canonname = canonname;
|
2003-11-18 07:04:13 +00:00
|
|
|
}
|
|
|
|
|
2006-04-16 21:34:32 +00:00
|
|
|
free (in6ai);
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
*pai = p;
|
|
|
|
return 0;
|
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1999-09-12 19:24:42 +00:00
|
|
|
return last_i ? -(last_i & GAIH_EAI) : EAI_NONAME;
|
1996-10-21 01:26:31 +00:00
|
|
|
}
|
2002-08-06 06:09:28 +00:00
|
|
|
libc_hidden_def (getaddrinfo)
|
1996-10-21 01:26:31 +00:00
|
|
|
|
2003-06-16 17:18:06 +00:00
|
|
|
static_link_warning (getaddrinfo)
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
void
|
|
|
|
freeaddrinfo (struct addrinfo *ai)
|
1996-10-21 01:26:31 +00:00
|
|
|
{
|
|
|
|
struct addrinfo *p;
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
while (ai != NULL)
|
|
|
|
{
|
|
|
|
p = ai;
|
|
|
|
ai = ai->ai_next;
|
2004-08-18 05:10:14 +00:00
|
|
|
free (p->ai_canonname);
|
1997-08-20 03:53:21 +00:00
|
|
|
free (p);
|
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
}
|
2002-08-06 06:09:28 +00:00
|
|
|
libc_hidden_def (freeaddrinfo)
|