summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-01-05 21:32:20 +0000
committerUlrich Drepper <drepper@redhat.com>2000-01-05 21:32:20 +0000
commitf3ac48d0deccc3cab889ac91e4ba9c46b09ae9b3 (patch)
tree1df4ffb0e99e570dbfde4c9d984740186099a9fb
parenteb7c2001aaece98f2d80249cb526381a57d2be1b (diff)
downloadglibc-f3ac48d0deccc3cab889ac91e4ba9c46b09ae9b3.tar.gz
glibc-f3ac48d0deccc3cab889ac91e4ba9c46b09ae9b3.tar.xz
glibc-f3ac48d0deccc3cab889ac91e4ba9c46b09ae9b3.zip
Update.
	* sysdeps/posix/getaddrinfo.c: Add support for SOCK_RAW.
	Patch by YOSHIFUJI Hideaki <yoshifuji@ecei.tohoku.ac.jp>.
-rw-r--r--ChangeLog3
-rw-r--r--sysdeps/posix/getaddrinfo.c38
2 files changed, 31 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 71812013ee..f59386e2ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2000-01-05  Ulrich Drepper  <drepper@cygnus.com>
 
+	* sysdeps/posix/getaddrinfo.c: Add support for SOCK_RAW.
+	Patch by YOSHIFUJI Hideaki <yoshifuji@ecei.tohoku.ac.jp>.
+
 	* io/ftw.c (process_entry): Cache object dev/inode only for
 	directories (PR libc/1514).
 
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 00788b7be1..5d6f3b8e97 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -92,14 +92,19 @@ struct gaih_typeproto
     int socktype;
     int protocol;
     char *name;
+    int protoflag;
   };
 
+/* Values for `protoflag'.  */
+#define GAI_PROTO_NOSERVICE	1
+
 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 }
+  { SOCK_STREAM, IPPROTO_TCP, (char *) "tcp" ,0 },
+  { SOCK_DGRAM, IPPROTO_UDP, (char *) "udp", 0 },
+  { SOCK_RAW, IPPROTO_RAW, (char *) "raw", GAI_PROTO_NOSERVICE },
+  { 0, 0, NULL, 0 }
 };
 
 struct gaih
@@ -134,11 +139,15 @@ gaih_local (const char *name, const struct gaih_service *service,
 
   if (req->ai_protocol || req->ai_socktype)
     {
-      struct gaih_typeproto *tp = gaih_inet_typeproto;
+      struct gaih_typeproto *tp = gaih_inet_typeproto + 1;
+
+      while (tp->name != NULL
+	     && (req->ai_socktype != tp->socktype || req->ai_socktype == 0)
+	     && ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0
+		 || req->ai_protocol != tp->protocol
+		 || req->ai_protocol == 0))
+	++tp;
 
-      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)
@@ -284,9 +293,15 @@ gaih_inet (const char *name, const struct gaih_service *service,
 
   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++);
+      ++tp;
+
+      while (tp->name != NULL
+	     && (req->ai_socktype != tp->socktype || req->ai_socktype == 0)
+	     && ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0
+		 || req->ai_protocol != tp->protocol
+		 || req->ai_protocol == 0))
+	++tp;
+
       if (tp->name == NULL)
 	{
 	  if (req->ai_socktype)
@@ -298,6 +313,9 @@ gaih_inet (const char *name, const struct gaih_service *service,
 
   if (service != NULL)
     {
+      if ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0)
+	return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
+
       if (service->num < 0)
 	{
 	  if (tp->name != NULL)