Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Mar 2009 16:23:43 +0000 (UTC)
From:      Hajimu UMEMOTO <ume@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r190416 - head/lib/libc/net
Message-ID:  <200903251623.n2PGNhNX081388@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ume
Date: Wed Mar 25 16:23:43 2009
New Revision: 190416
URL: http://svn.freebsd.org/changeset/base/190416

Log:
  Add support for SCTP to getaddrinfo(3).
  Now, getaddrinfo(3) returns two SOCK_STREAMs, IPPROTO_TCP and
  IPPROTO_SCTP.  It confuses some programs.  If getaddrinfo(3) returns
  IPPROTO_SCTP when SOCK_STREAM is specified by hints.ai_socktype, at
  least Apache doesn't work.  So, I made getaddrinfo(3) to return
  IPPROTO_SCTP with SOCK_STREAM only when IPPROTO_SCTP is specified
  explicitly by hints.ai_protocol.
  
  PR:		bin/128167
  Submitted by:	Bruce Cran <bruce__at__cran.org.uk> (partly)
  MFC after:	2 week

Modified:
  head/lib/libc/net/getaddrinfo.c

Modified: head/lib/libc/net/getaddrinfo.c
==============================================================================
--- head/lib/libc/net/getaddrinfo.c	Wed Mar 25 15:42:07 2009	(r190415)
+++ head/lib/libc/net/getaddrinfo.c	Wed Mar 25 16:23:43 2009	(r190416)
@@ -165,18 +165,24 @@ struct explore {
 
 static const struct explore explore[] = {
 #if 0
-	{ PF_LOCAL, 0, ANY, ANY, NULL, 0x01 },
+	{ PF_LOCAL, ANY, ANY, NULL, 0x01 },
 #endif
 #ifdef INET6
 	{ PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
 	{ PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
+	{ PF_INET6, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x03 },
+	{ PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 },
 	{ PF_INET6, SOCK_RAW, ANY, NULL, 0x05 },
 #endif
 	{ PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
 	{ PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
+	{ PF_INET, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x03 },
+	{ PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 },
 	{ PF_INET, SOCK_RAW, ANY, NULL, 0x05 },
 	{ PF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
 	{ PF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
+	{ PF_UNSPEC, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x03 },
+	{ PF_UNSPEC, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 },
 	{ PF_UNSPEC, SOCK_RAW, ANY, NULL, 0x05 },
 	{ -1, 0, 0, NULL, 0 },
 };
@@ -417,10 +423,12 @@ getaddrinfo(const char *hostname, const 
 				if (ex->e_protocol == ANY)
 					continue;
 				if (pai->ai_socktype == ex->e_socktype &&
-				    pai->ai_protocol != ex->e_protocol) {
-					ERR(EAI_BADHINTS);
-				}
+				    pai->ai_protocol == ex->e_protocol)
+					break;
 			}
+
+			if (ex->e_af < 0)
+				ERR(EAI_BADHINTS);
 		}
 	}
 
@@ -1344,6 +1352,7 @@ get_port(struct addrinfo *ai, const char
 		return EAI_SERVICE;
 	case SOCK_DGRAM:
 	case SOCK_STREAM:
+	case SOCK_SEQPACKET:
 		allownumeric = 1;
 		break;
 	case ANY:
@@ -1373,13 +1382,17 @@ get_port(struct addrinfo *ai, const char
 	} else {
 		if (ai->ai_flags & AI_NUMERICSERV)
 			return EAI_NONAME;
-		switch (ai->ai_socktype) {
-		case SOCK_DGRAM:
+
+		switch (ai->ai_protocol) {
+		case IPPROTO_UDP:
 			proto = "udp";
 			break;
-		case SOCK_STREAM:
+		case IPPROTO_TCP:
 			proto = "tcp";
 			break;
+		case IPPROTO_SCTP:
+			proto = "sctp";
+			break;
 		default:
 			proto = NULL;
 			break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903251623.n2PGNhNX081388>