summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2009-03-25 16:23:43 +0000
committerume <ume@FreeBSD.org>2009-03-25 16:23:43 +0000
commitb9602dae34d92edee464230618658e3b11a8af61 (patch)
tree60eb9610bfffd58e1da4df9c9176060ed6b95f85
parent6cd843f315b7e0a753bcda79de1b66be9f061b3c (diff)
downloadFreeBSD-src-b9602dae34d92edee464230618658e3b11a8af61.zip
FreeBSD-src-b9602dae34d92edee464230618658e3b11a8af61.tar.gz
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
-rw-r--r--lib/libc/net/getaddrinfo.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index 21ba70e..121b861 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -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 char *servname,
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 *servname, int matchonly)
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 *servname, int matchonly)
} 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;
OpenPOWER on IntegriCloud