aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/posix
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-09-26 08:43:34 +0000
committerUlrich Drepper <drepper@redhat.com>2004-09-26 08:43:34 +0000
commitca225a410beec632da27617ea972df345986b54e (patch)
tree83050d08d3147df88d9723281688ee83dac5563f /sysdeps/posix
parentfe6ce1705917adeaf4db069d484060ecd2aff81b (diff)
downloadglibc-ca225a410beec632da27617ea972df345986b54e.zip
glibc-ca225a410beec632da27617ea972df345986b54e.tar.gz
glibc-ca225a410beec632da27617ea972df345986b54e.tar.bz2
[BZ #358]
Update. 2004-09-26 Ulrich Drepper <drepper@redhat.com> * sysdeps/posix/getaddrinfo.c (getaddrinfo): Remove incorrect requirement on socktype and protocol. (gaih_inet): If numeric port number is given, return records for all possible socket types. * posix/tst-getaddrinfo2.c: New file. * posix/Makefile (tests): Add tst-getaddrinfo2. [BZ #358]
Diffstat (limited to 'sysdeps/posix')
-rw-r--r--sysdeps/posix/getaddrinfo.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 225c1a1..20e60de 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -445,12 +445,35 @@ gaih_inet (const char *name, const struct gaih_service *service,
}
else
{
- 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 = htons (service->num);
+ 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 = htons (service->num);
+ }
+ else
+ {
+ /* Neither socket type nor protocol is set. Return all
+ socket types we know about. */
+ struct gaih_servtuple **lastp = &st;
+ for (tp = gaih_inet_typeproto + 1; tp->name[0]; ++tp)
+ if ((tp->protoflag & GAI_PROTO_NOSERVICE) == 0)
+ {
+ struct gaih_servtuple *newp;
+
+ newp = __alloca (sizeof (struct gaih_servtuple));
+ newp->next = NULL;
+ newp->socktype = tp->socktype;
+ newp->protocol = tp->protocol;
+ newp->port = htons (service->num);
+
+ *lastp = newp;
+ lastp = &newp->next;
+ }
+ }
}
}
else if (req->ai_socktype || req->ai_protocol)
@@ -1493,11 +1516,7 @@ getaddrinfo (const char *name, const char *service,
gaih_service.num = -1;
}
- else
- /* Can't specify a numerical socket unless a protocol family was
- given. */
- if (hints->ai_socktype == 0 && hints->ai_protocol == 0)
- return EAI_SERVICE;
+
pservice = &gaih_service;
}
else