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.
|
|
|
|
4. All advertising materials mentioning features or use of this software
|
|
|
|
must display the following acknowledgement with the name(s) of the
|
|
|
|
authors as specified in the copyright notice(s) substituted where
|
|
|
|
indicated:
|
|
|
|
|
|
|
|
This product includes software developed by <name(s)>, The Inner
|
|
|
|
Net, and other contributors.
|
|
|
|
|
|
|
|
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. */
|
|
|
|
|
1997-02-19 04:43:53 +00:00
|
|
|
/* getaddrinfo() v1.13 */
|
|
|
|
|
1996-10-21 01:26:31 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdlib.h>
|
1997-02-19 04:43:53 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#include <sys/un.h>
|
1996-10-21 01:26:31 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netdb.h>
|
1997-02-19 04:43:53 +00:00
|
|
|
#include <errno.h>
|
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
|
|
|
#include <arpa/inet.h>
|
1997-02-19 04:43:53 +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
|
|
|
|
#define UNIX_PATH_MAX 108
|
|
|
|
#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
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
static struct gaih_servtuple nullserv = { NULL, 0, 0, 0 };
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
struct gaih_addrtuple
|
|
|
|
{
|
|
|
|
struct gaih_addrtuple *next;
|
|
|
|
int family;
|
|
|
|
char addr[16];
|
|
|
|
};
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
struct gaih_typeproto
|
|
|
|
{
|
|
|
|
int socktype;
|
|
|
|
int protocol;
|
|
|
|
char *name;
|
|
|
|
};
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
static struct gaih_typeproto gaih_inet_typeproto[] =
|
|
|
|
{
|
|
|
|
{ 0, 0, NULL },
|
|
|
|
{ SOCK_STREAM, IPPROTO_TCP, (char *) "tcp" },
|
|
|
|
{ SOCK_DGRAM, IPPROTO_UDP, (char *) "udp" },
|
|
|
|
{ 0, 0, NULL }
|
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,
|
|
|
|
const struct addrinfo *req, struct addrinfo **pai);
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct addrinfo default_hints =
|
|
|
|
{ 0, PF_UNSPEC, 0, 0, 0, NULL, NULL, NULL };
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
gaih_local (const char *name, const struct gaih_service *service,
|
|
|
|
const struct addrinfo *req, struct addrinfo **pai)
|
1997-02-19 04:43:53 +00:00
|
|
|
{
|
|
|
|
struct utsname utsname;
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if ((name != NULL) || (req->ai_flags & AI_CANONNAME))
|
1999-09-12 19:24:42 +00:00
|
|
|
if (uname (&utsname))
|
1997-02-19 04:43:53 +00:00
|
|
|
return -EAI_SYSTEM;
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if (name != NULL)
|
|
|
|
{
|
|
|
|
if (strcmp(name, "localhost") &&
|
|
|
|
strcmp(name, "local") &&
|
|
|
|
strcmp(name, "unix") &&
|
|
|
|
strcmp(name, utsname.nodename))
|
|
|
|
return GAIH_OKIFUNSPEC | -EAI_NONAME;
|
|
|
|
}
|
|
|
|
|
1999-09-12 19:24:42 +00:00
|
|
|
if (req->ai_protocol || req->ai_socktype)
|
|
|
|
{
|
|
|
|
struct gaih_typeproto *tp = gaih_inet_typeproto;
|
|
|
|
|
|
|
|
for (tp++; tp->name &&
|
|
|
|
((req->ai_socktype != tp->socktype) || !req->ai_socktype) &&
|
|
|
|
((req->ai_protocol != tp->protocol) || !req->ai_protocol); tp++);
|
|
|
|
if (tp->name == NULL)
|
|
|
|
{
|
|
|
|
if (req->ai_socktype)
|
|
|
|
return (GAIH_OKIFUNSPEC | -EAI_SOCKTYPE);
|
|
|
|
else
|
|
|
|
return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*pai = malloc (sizeof (struct addrinfo) + sizeof (struct sockaddr_un)
|
1997-08-20 03:53:21 +00:00
|
|
|
+ ((req->ai_flags & AI_CANONNAME)
|
|
|
|
? (strlen(utsname.nodename) + 1): 0));
|
|
|
|
if (*pai == NULL)
|
1997-02-19 04:43:53 +00:00
|
|
|
return -EAI_MEMORY;
|
|
|
|
|
|
|
|
(*pai)->ai_next = NULL;
|
|
|
|
(*pai)->ai_flags = req->ai_flags;
|
|
|
|
(*pai)->ai_family = AF_LOCAL;
|
|
|
|
(*pai)->ai_socktype = req->ai_socktype ? req->ai_socktype : SOCK_STREAM;
|
|
|
|
(*pai)->ai_protocol = req->ai_protocol;
|
1999-09-12 19:24:42 +00:00
|
|
|
(*pai)->ai_addrlen = sizeof (struct sockaddr_un);
|
|
|
|
(*pai)->ai_addr = (void *) (*pai) + sizeof (struct addrinfo);
|
1997-08-20 03:53:21 +00:00
|
|
|
|
1997-02-19 04:43:53 +00:00
|
|
|
#if SALEN
|
1997-08-20 03:53:21 +00:00
|
|
|
((struct sockaddr_un *) (*pai)->ai_addr)->sun_len =
|
|
|
|
sizeof (struct sockaddr_un);
|
1997-02-19 04:43:53 +00:00
|
|
|
#endif /* SALEN */
|
1997-08-20 03:53:21 +00:00
|
|
|
|
1997-02-19 04:43:53 +00:00
|
|
|
((struct sockaddr_un *)(*pai)->ai_addr)->sun_family = AF_LOCAL;
|
|
|
|
memset(((struct sockaddr_un *)(*pai)->ai_addr)->sun_path, 0, UNIX_PATH_MAX);
|
1997-08-20 03:53:21 +00:00
|
|
|
|
|
|
|
if (service)
|
|
|
|
{
|
|
|
|
struct sockaddr_un *sunp = (struct sockaddr_un *) (*pai)->ai_addr;
|
|
|
|
|
|
|
|
if (strchr (service->name, '/') != NULL)
|
|
|
|
{
|
|
|
|
if (strlen (service->name) >= sizeof (sunp->sun_path))
|
|
|
|
return GAIH_OKIFUNSPEC | -EAI_SERVICE;
|
|
|
|
|
|
|
|
strcpy (sunp->sun_path, service->name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (strlen (P_tmpdir "/") + 1 + strlen (service->name) >=
|
|
|
|
sizeof (sunp->sun_path))
|
|
|
|
return GAIH_OKIFUNSPEC | -EAI_SERVICE;
|
|
|
|
|
|
|
|
__stpcpy (__stpcpy (sunp->sun_path, P_tmpdir "/"), service->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (tmpnam (((struct sockaddr_un *) (*pai)->ai_addr)->sun_path) == NULL)
|
|
|
|
return -EAI_SYSTEM;
|
|
|
|
}
|
|
|
|
|
1997-02-19 04:43:53 +00:00
|
|
|
if (req->ai_flags & AI_CANONNAME)
|
1999-09-12 19:24:42 +00:00
|
|
|
(*pai)->ai_canonname = strcpy ((char *) *pai + sizeof (struct addrinfo)
|
|
|
|
+ sizeof (struct sockaddr_un),
|
|
|
|
utsname.nodename);
|
1997-02-19 04:43:53 +00:00
|
|
|
else
|
|
|
|
(*pai)->ai_canonname = NULL;
|
|
|
|
return 0;
|
1997-08-20 03:53:21 +00:00
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
static int
|
|
|
|
gaih_inet_serv (const char *servicename, struct gaih_typeproto *tp,
|
1999-05-02 21:03:32 +00:00
|
|
|
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;
|
|
|
|
st->protocol = tp->protocol;
|
|
|
|
st->port = s->s_port;
|
1996-10-21 01:26:31 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
#define gethosts(_family, _type) \
|
|
|
|
{ \
|
|
|
|
int i, herrno; \
|
|
|
|
size_t tmpbuflen; \
|
|
|
|
struct hostent th; \
|
|
|
|
char *tmpbuf; \
|
|
|
|
tmpbuflen = 512; \
|
|
|
|
do { \
|
|
|
|
tmpbuflen *= 2; \
|
|
|
|
tmpbuf = __alloca (tmpbuflen); \
|
|
|
|
rc = __gethostbyname2_r (name, _family, &th, tmpbuf, \
|
|
|
|
tmpbuflen, &h, &herrno); \
|
1999-09-05 00:08:27 +00:00
|
|
|
} while (rc == ERANGE && herrno == NETDB_INTERNAL); \
|
1999-09-12 19:24:42 +00:00
|
|
|
if (rc != 0 && herrno == NETDB_INTERNAL) \
|
1997-08-20 03:53:21 +00:00
|
|
|
{ \
|
|
|
|
__set_h_errno (herrno); \
|
|
|
|
return -EAI_SYSTEM; \
|
|
|
|
} \
|
|
|
|
if (h != NULL) \
|
|
|
|
{ \
|
|
|
|
for (i = 0; h->h_addr_list[i]; i++) \
|
|
|
|
{ \
|
|
|
|
if (*pat == NULL) \
|
1999-09-12 19:24:42 +00:00
|
|
|
*pat = __alloca (sizeof(struct gaih_addrtuple)); \
|
1997-08-20 03:53:21 +00:00
|
|
|
(*pat)->next = NULL; \
|
|
|
|
(*pat)->family = _family; \
|
|
|
|
memcpy ((*pat)->addr, h->h_addr_list[i], \
|
|
|
|
sizeof(_type)); \
|
|
|
|
pat = &((*pat)->next); \
|
|
|
|
} \
|
|
|
|
} \
|
1999-09-12 19:24:42 +00:00
|
|
|
no_data = rc != 0 && herrno == NO_DATA; \
|
1997-08-20 03:53:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
gaih_inet (const char *name, const struct gaih_service *service,
|
|
|
|
const struct addrinfo *req, struct addrinfo **pai)
|
1996-10-21 01:26:31 +00:00
|
|
|
{
|
|
|
|
struct gaih_typeproto *tp = gaih_inet_typeproto;
|
|
|
|
struct gaih_servtuple *st = &nullserv;
|
1997-02-19 04:43:53 +00:00
|
|
|
struct gaih_addrtuple *at = NULL;
|
1997-08-20 03:53:21 +00:00
|
|
|
int rc;
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if (req->ai_protocol || req->ai_socktype)
|
|
|
|
{
|
|
|
|
for (tp++; tp->name &&
|
|
|
|
((req->ai_socktype != tp->socktype) || !req->ai_socktype) &&
|
|
|
|
((req->ai_protocol != tp->protocol) || !req->ai_protocol); tp++);
|
|
|
|
if (tp->name == NULL)
|
1998-09-09 11:53:19 +00:00
|
|
|
{
|
|
|
|
if (req->ai_socktype)
|
|
|
|
return (GAIH_OKIFUNSPEC | -EAI_SOCKTYPE);
|
|
|
|
else
|
|
|
|
return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
|
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (service != NULL)
|
|
|
|
{
|
|
|
|
if (service->num < 0)
|
|
|
|
{
|
|
|
|
if (tp->name != NULL)
|
|
|
|
{
|
1999-05-02 21:03:32 +00:00
|
|
|
st = (struct gaih_servtuple *)
|
|
|
|
__alloca (sizeof (struct gaih_servtuple));
|
|
|
|
|
|
|
|
if ((rc = gaih_inet_serv (service->name, tp, st)))
|
1997-08-20 03:53:21 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct gaih_servtuple **pst = &st;
|
|
|
|
for (tp++; tp->name; tp++)
|
|
|
|
{
|
1999-05-02 21:03:32 +00:00
|
|
|
struct gaih_servtuple *newp = (struct gaih_servtuple *)
|
|
|
|
__alloca (sizeof (struct gaih_servtuple));
|
|
|
|
|
|
|
|
if ((rc = gaih_inet_serv (service->name, tp, 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
|
|
|
}
|
|
|
|
if (st == &nullserv)
|
|
|
|
return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
|
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
else
|
|
|
|
{
|
1999-09-12 19:24:42 +00:00
|
|
|
st = __alloca (sizeof (struct gaih_servtuple));
|
1997-08-20 03:53:21 +00:00
|
|
|
st->next = NULL;
|
|
|
|
st->socktype = tp->socktype;
|
|
|
|
st->protocol = tp->protocol;
|
|
|
|
st->port = htons (service->num);
|
1996-10-21 01:26:31 +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;
|
1997-08-20 03:53:21 +00:00
|
|
|
at->next = NULL;
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1999-09-12 19:24:42 +00:00
|
|
|
if (inet_pton (AF_INET, name, at->addr) > 0)
|
|
|
|
{
|
|
|
|
if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET)
|
|
|
|
at->family = AF_INET;
|
|
|
|
else
|
|
|
|
return -EAI_ADDRFAMILY;
|
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1999-09-12 19:24:42 +00:00
|
|
|
if (at->family == AF_UNSPEC && inet_pton (AF_INET6, name, at->addr) > 0)
|
|
|
|
{
|
|
|
|
if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET6)
|
|
|
|
at->family = AF_INET6;
|
|
|
|
else
|
|
|
|
return -EAI_ADDRFAMILY;
|
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
|
|
|
|
if (at->family == AF_UNSPEC)
|
|
|
|
{
|
|
|
|
struct hostent *h;
|
|
|
|
struct gaih_addrtuple **pat = &at;
|
1999-09-12 19:24:42 +00:00
|
|
|
int no_data = 0;
|
1997-08-20 03:53:21 +00:00
|
|
|
|
1999-07-28 03:27:45 +00:00
|
|
|
if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET6)
|
1997-08-20 03:53:21 +00:00
|
|
|
gethosts (AF_INET6, struct in6_addr);
|
|
|
|
|
1999-07-28 03:27:45 +00:00
|
|
|
if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET)
|
1997-08-20 03:53:21 +00:00
|
|
|
gethosts (AF_INET, struct in_addr);
|
1999-09-12 19:24:42 +00:00
|
|
|
|
|
|
|
if (no_data != 0)
|
|
|
|
/* We made requests but they turned out no data. The name
|
|
|
|
is known, though. */
|
|
|
|
return (GAIH_OKIFUNSPEC | -EAI_NODATA);
|
1996-10-21 01:26:31 +00:00
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
|
|
|
|
if (at->family == AF_UNSPEC)
|
|
|
|
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
|
|
|
|
1999-07-28 03:27:45 +00:00
|
|
|
if (req->ai_family == 0)
|
|
|
|
{
|
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
|
|
|
|
1999-07-28 03:27:45 +00:00
|
|
|
if (req->ai_family == 0 || req->ai_family == AF_INET6)
|
|
|
|
{
|
|
|
|
at->family = AF_INET6;
|
|
|
|
if ((req->ai_flags & AI_PASSIVE) == 0)
|
|
|
|
memcpy (at->addr, &in6addr_loopback, sizeof (struct in6_addr));
|
|
|
|
atr = at->next;
|
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
|
1999-07-28 03:27:45 +00:00
|
|
|
if (req->ai_family == 0 || req->ai_family == AF_INET)
|
|
|
|
{
|
|
|
|
atr->family = AF_INET;
|
|
|
|
if ((req->ai_flags & AI_PASSIVE) == 0)
|
|
|
|
*(uint32_t *) atr->addr = htonl (INADDR_LOOPBACK);
|
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
}
|
1997-02-19 04:43:53 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if (pai == NULL)
|
|
|
|
return 0;
|
1996-10-21 01:26:31 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
const char *c = NULL;
|
|
|
|
struct gaih_servtuple *st2;
|
|
|
|
struct gaih_addrtuple *at2 = at;
|
1997-08-20 03:53:21 +00:00
|
|
|
size_t socklen, namelen;
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
char buffer[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
while (at2 != NULL)
|
|
|
|
{
|
|
|
|
if (req->ai_flags & AI_CANONNAME)
|
|
|
|
{
|
|
|
|
struct hostent *h = NULL;
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
int herrno;
|
|
|
|
struct hostent th;
|
|
|
|
size_t tmpbuflen = 512;
|
|
|
|
char *tmpbuf;
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
tmpbuflen *= 2;
|
|
|
|
tmpbuf = __alloca (tmpbuflen);
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if (tmpbuf == NULL)
|
|
|
|
return -EAI_MEMORY;
|
|
|
|
|
|
|
|
rc = __gethostbyaddr_r (at2->addr,
|
|
|
|
((at2->family == AF_INET6)
|
|
|
|
? sizeof(struct in6_addr)
|
|
|
|
: sizeof(struct in_addr)),
|
|
|
|
at2->family, &th, tmpbuf, tmpbuflen,
|
|
|
|
&h, &herrno);
|
|
|
|
|
|
|
|
}
|
1999-09-12 19:24:42 +00:00
|
|
|
while (rc == errno && herrno == NETDB_INTERNAL);
|
1997-08-20 03:53:21 +00:00
|
|
|
|
1999-09-12 19:24:42 +00:00
|
|
|
if (rc != 0 && herrno == NETDB_INTERNAL)
|
1997-08-20 03:53:21 +00:00
|
|
|
{
|
|
|
|
__set_h_errno (herrno);
|
|
|
|
return -EAI_SYSTEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (h == NULL)
|
|
|
|
c = inet_ntop (at2->family, at2->addr, buffer, sizeof(buffer));
|
|
|
|
else
|
|
|
|
c = h->h_name;
|
|
|
|
|
|
|
|
if (c == NULL)
|
|
|
|
return GAIH_OKIFUNSPEC | -EAI_NONAME;
|
|
|
|
|
|
|
|
namelen = strlen (c) + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
namelen = 0;
|
|
|
|
|
|
|
|
if (at2->family == AF_INET6)
|
|
|
|
socklen = sizeof (struct sockaddr_in6);
|
|
|
|
else
|
|
|
|
socklen = sizeof (struct sockaddr_in);
|
|
|
|
|
|
|
|
for (st2 = st; st2 != NULL; st2 = st2->next)
|
|
|
|
{
|
|
|
|
*pai = malloc (sizeof (struct addrinfo) + socklen + namelen);
|
|
|
|
if (*pai == NULL)
|
|
|
|
return -EAI_MEMORY;
|
|
|
|
|
|
|
|
(*pai)->ai_flags = req->ai_flags;
|
|
|
|
(*pai)->ai_family = at2->family;
|
|
|
|
(*pai)->ai_socktype = st2->socktype;
|
|
|
|
(*pai)->ai_protocol = st2->protocol;
|
|
|
|
(*pai)->ai_addrlen = socklen;
|
|
|
|
(*pai)->ai_addr = (void *) (*pai) + sizeof(struct addrinfo);
|
1996-10-21 01:26:31 +00:00
|
|
|
#if SALEN
|
1997-08-20 03:53:21 +00:00
|
|
|
((struct sockaddr_in *) (*pai)->ai_addr)->sin_len = i;
|
1996-10-21 01:26:31 +00:00
|
|
|
#endif /* SALEN */
|
1997-08-20 03:53:21 +00:00
|
|
|
((struct sockaddr_in *) (*pai)->ai_addr)->sin_family = at2->family;
|
|
|
|
((struct sockaddr_in *) (*pai)->ai_addr)->sin_port = st2->port;
|
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
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if (at2->family == AF_INET6)
|
|
|
|
{
|
|
|
|
struct sockaddr_in6 *sin6p =
|
|
|
|
(struct sockaddr_in6 *) (*pai)->ai_addr;
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
sin6p->sin6_flowinfo = 0;
|
|
|
|
memcpy (&sin6p->sin6_addr,
|
|
|
|
at2->addr, sizeof (struct in6_addr));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct sockaddr_in *sinp =
|
|
|
|
(struct sockaddr_in *) (*pai)->ai_addr;
|
|
|
|
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
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if (c)
|
|
|
|
{
|
|
|
|
(*pai)->ai_canonname = ((void *) (*pai) +
|
|
|
|
sizeof (struct addrinfo) + socklen);
|
|
|
|
strcpy ((*pai)->ai_canonname, c);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
(*pai)->ai_canonname = NULL;
|
1996-10-21 01:26:31 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
(*pai)->ai_next = NULL;
|
|
|
|
pai = &((*pai)->ai_next);
|
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
static struct gaih gaih[] =
|
|
|
|
{
|
|
|
|
{ PF_INET6, gaih_inet },
|
|
|
|
{ PF_INET, gaih_inet },
|
|
|
|
{ PF_LOCAL, gaih_local },
|
|
|
|
{ PF_UNSPEC, NULL }
|
|
|
|
};
|
1996-10-21 01:26:31 +00:00
|
|
|
|
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
|
|
|
{
|
1999-09-12 19:24:42 +00:00
|
|
|
int i = 0, j = 0, last_i = 0;
|
1997-02-19 04:43:53 +00:00
|
|
|
struct addrinfo *p = NULL, **end;
|
1996-10-21 01:26:31 +00:00
|
|
|
struct gaih *g = gaih, *pg = NULL;
|
|
|
|
struct gaih_service gaih_service, *pservice;
|
|
|
|
|
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
|
|
|
|
1999-02-16 11:06:33 +00:00
|
|
|
if (hints->ai_flags & ~(AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST))
|
1996-10-21 01:26:31 +00:00
|
|
|
return EAI_BADFLAGS;
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if ((hints->ai_flags & AI_CANONNAME) && name == NULL)
|
1996-10-21 01:26:31 +00:00
|
|
|
return EAI_BADFLAGS;
|
|
|
|
|
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);
|
|
|
|
if (*c)
|
|
|
|
gaih_service.num = -1;
|
1997-02-19 04:43:53 +00:00
|
|
|
else
|
1997-08-20 03:53:21 +00:00
|
|
|
/* Can't specify a numerical socket unless a protocol family was
|
|
|
|
given. */
|
|
|
|
if (hints->ai_socktype == 0)
|
1997-02-19 04:43:53 +00:00
|
|
|
return EAI_SERVICE;
|
1997-08-20 03:53:21 +00:00
|
|
|
pservice = &gaih_service;
|
|
|
|
}
|
|
|
|
else
|
1996-10-21 01:26:31 +00:00
|
|
|
pservice = NULL;
|
|
|
|
|
1997-02-19 04:43:53 +00:00
|
|
|
if (pai)
|
|
|
|
end = &p;
|
|
|
|
else
|
|
|
|
end = NULL;
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
while (g->gaih)
|
|
|
|
{
|
1999-07-28 03:27:45 +00:00
|
|
|
if (hints->ai_family == g->family || hints->ai_family == AF_UNSPEC)
|
1997-08-20 03:53:21 +00:00
|
|
|
{
|
|
|
|
j++;
|
1999-07-28 03:27:45 +00:00
|
|
|
if (pg == NULL || pg->gaih != g->gaih)
|
1997-08-20 03:53:21 +00:00
|
|
|
{
|
|
|
|
pg = g;
|
1999-07-28 03:27:45 +00:00
|
|
|
i = g->gaih (name, pservice, hints, end);
|
|
|
|
if (i != 0)
|
1997-08-20 03:53:21 +00:00
|
|
|
{
|
1999-09-12 19:24:42 +00:00
|
|
|
/* EAI_NODATA is a more specific result as it says that
|
|
|
|
we found a result but it is not usable. */
|
|
|
|
if (last_i != (GAIH_OKIFUNSPEC | -EAI_NODATA))
|
|
|
|
last_i = i;
|
|
|
|
|
1999-07-28 03:27:45 +00:00
|
|
|
if (hints->ai_family == AF_UNSPEC && (i & GAIH_OKIFUNSPEC))
|
1997-08-20 03:53:21 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (p)
|
|
|
|
freeaddrinfo (p);
|
|
|
|
|
1999-07-28 03:27:45 +00:00
|
|
|
return -(i & GAIH_EAI);
|
1997-08-20 03:53:21 +00:00
|
|
|
}
|
|
|
|
if (end)
|
|
|
|
while(*end) end = &((*end)->ai_next);
|
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
}
|
1997-08-20 03:53:21 +00:00
|
|
|
++g;
|
1996-10-21 01:26:31 +00:00
|
|
|
}
|
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
if (j == 0)
|
1996-10-21 01:26:31 +00:00
|
|
|
return EAI_FAMILY;
|
|
|
|
|
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
|
|
|
if (pai == NULL && last_i == 0)
|
1997-02-19 04:43:53 +00:00
|
|
|
return 0;
|
|
|
|
|
1996-10-21 01:26:31 +00:00
|
|
|
if (p)
|
1997-08-20 03:53:21 +00:00
|
|
|
freeaddrinfo (p);
|
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
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
free (p);
|
|
|
|
}
|
1996-10-21 01:26:31 +00:00
|
|
|
}
|