mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
* sysdeps/posix/getaddrinfo.c (getaddrinfo): Rewrite to avoid loop
over gaih array. There is only on function to call in the moment.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2006-04-18 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* sysdeps/posix/getaddrinfo.c (getaddrinfo): Rewrite to avoid loop
|
||||||
|
over gaih array. There is only on function to call in the moment.
|
||||||
|
|
||||||
2006-04-16 Ulrich Drepper <drepper@redhat.com>
|
2006-04-16 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* include/ifaddrs.h: Define struct in6addrinfo.
|
* include/ifaddrs.h: Define struct in6addrinfo.
|
||||||
|
@ -1095,6 +1095,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static const struct gaih gaih[] =
|
static const struct gaih gaih[] =
|
||||||
{
|
{
|
||||||
{ PF_INET6, gaih_inet },
|
{ PF_INET6, gaih_inet },
|
||||||
@ -1104,6 +1105,7 @@ static const struct gaih gaih[] =
|
|||||||
#endif
|
#endif
|
||||||
{ PF_UNSPEC, NULL }
|
{ PF_UNSPEC, NULL }
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
struct sort_result
|
struct sort_result
|
||||||
{
|
{
|
||||||
@ -1484,11 +1486,9 @@ int
|
|||||||
getaddrinfo (const char *name, const char *service,
|
getaddrinfo (const char *name, const char *service,
|
||||||
const struct addrinfo *hints, struct addrinfo **pai)
|
const struct addrinfo *hints, struct addrinfo **pai)
|
||||||
{
|
{
|
||||||
int i = 0, j = 0, last_i = 0;
|
int i = 0, last_i = 0;
|
||||||
int nresults = 0;
|
int nresults = 0;
|
||||||
struct addrinfo *p = NULL, **end;
|
struct addrinfo *p = NULL;
|
||||||
const struct gaih *g = gaih;
|
|
||||||
const struct gaih *pg = NULL;
|
|
||||||
struct gaih_service gaih_service, *pservice;
|
struct gaih_service gaih_service, *pservice;
|
||||||
struct addrinfo local_hints;
|
struct addrinfo local_hints;
|
||||||
|
|
||||||
@ -1575,12 +1575,21 @@ getaddrinfo (const char *name, const char *service,
|
|||||||
else
|
else
|
||||||
pservice = NULL;
|
pservice = NULL;
|
||||||
|
|
||||||
|
struct addrinfo **end;
|
||||||
if (pai)
|
if (pai)
|
||||||
end = &p;
|
end = &p;
|
||||||
else
|
else
|
||||||
end = NULL;
|
end = NULL;
|
||||||
|
|
||||||
unsigned int naddrs = 0;
|
unsigned int naddrs = 0;
|
||||||
|
#if 0
|
||||||
|
/* If we would support more protocols than just IPv4 and IPv6 we
|
||||||
|
would iterate over a table with appropriate callback functions.
|
||||||
|
Since we currently only handle IPv4 and IPv6 this is not
|
||||||
|
necessary. */
|
||||||
|
const struct gaih *g = gaih;
|
||||||
|
const struct gaih *pg = NULL;
|
||||||
|
int j = 0;
|
||||||
while (g->gaih)
|
while (g->gaih)
|
||||||
{
|
{
|
||||||
if (hints->ai_family == g->family || hints->ai_family == AF_UNSPEC)
|
if (hints->ai_family == g->family || hints->ai_family == AF_UNSPEC)
|
||||||
@ -1624,6 +1633,31 @@ getaddrinfo (const char *name, const char *service,
|
|||||||
free (in6ai);
|
free (in6ai);
|
||||||
return EAI_FAMILY;
|
return EAI_FAMILY;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
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);
|
||||||
|
|
||||||
|
return -(i & GAIH_EAI);
|
||||||
|
}
|
||||||
|
if (end)
|
||||||
|
while (*end)
|
||||||
|
{
|
||||||
|
end = &((*end)->ai_next);
|
||||||
|
++nresults;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
free (in6ai);
|
||||||
|
return EAI_FAMILY;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (naddrs > 1)
|
if (naddrs > 1)
|
||||||
{
|
{
|
||||||
|
@ -131,7 +131,7 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IFA_ADDRESS:
|
case IFA_ADDRESS:
|
||||||
address = RTA_DATA (ta);
|
address = RTA_DATA (rta);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6,
|
|||||||
memcpy (newp->info.addr, address ?: local,
|
memcpy (newp->info.addr, address ?: local,
|
||||||
sizeof (newp->info.addr));
|
sizeof (newp->info.addr));
|
||||||
newp->next = in6ailist;
|
newp->next = in6ailist;
|
||||||
in6ailsit = newp;
|
in6ailist = newp;
|
||||||
++in6ailistlen;
|
++in6ailistlen;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user