From: Erik van der Kouwe Date: Thu, 7 Jan 2010 09:53:08 +0000 (+0000) Subject: Make get/setsockopt handle SOREUSEADDR X-Git-Tag: v3.1.6~102 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.dnssec-keyfromlabel.html?a=commitdiff_plain;h=1a39ed880a1c80e900d4a286bc44333c0aecb623;p=minix.git Make get/setsockopt handle SOREUSEADDR --- diff --git a/lib/ip/getsockopt.c b/lib/ip/getsockopt.c index dbf0ff2a7..861273628 100644 --- a/lib/ip/getsockopt.c +++ b/lib/ip/getsockopt.c @@ -78,6 +78,12 @@ static int _tcp_getsockopt(int socket, int level, int option_name, { int i, r, err; + if (level == SOL_SOCKET && option_name == SO_REUSEADDR) + { + i = 1; /* Binds to TIME_WAIT sockets never cause errors */ + getsockopt_copy(&i, sizeof(i), option_value, option_len); + return 0; + } if (level == SOL_SOCKET && option_name == SO_KEEPALIVE) { i = 1; /* Keepalive is always on */ diff --git a/lib/ip/setsockopt.c b/lib/ip/setsockopt.c index e6ef3631d..58922b9f6 100644 --- a/lib/ip/setsockopt.c +++ b/lib/ip/setsockopt.c @@ -63,6 +63,24 @@ static int _tcp_setsockopt(int socket, int level, int option_name, { int i; + if (level == SOL_SOCKET && option_name == SO_REUSEADDR) + { + if (option_len != sizeof(i)) + { + errno= EINVAL; + return -1; + } + i= *(int *)option_value; + if (!i) + { + /* At the moment there is no way to turn off + * reusing addresses. + */ + errno= ENOSYS; + return -1; + } + return 0; + } if (level == SOL_SOCKET && option_name == SO_KEEPALIVE) { if (option_len != sizeof(i))