]> Zhao Yanbai Git Server - minix.git/commitdiff
Make get/setsockopt handle SOREUSEADDR
authorErik van der Kouwe <erik@minix3.org>
Thu, 7 Jan 2010 09:53:08 +0000 (09:53 +0000)
committerErik van der Kouwe <erik@minix3.org>
Thu, 7 Jan 2010 09:53:08 +0000 (09:53 +0000)
lib/ip/getsockopt.c
lib/ip/setsockopt.c

index dbf0ff2a7c7a8a35062184a4dd8a9aadab3d65ba..86127362830c416f5ae60af977fa8b53977a827b 100644 (file)
@@ -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 */
index e6ef3631d15d3231d04fd1145c14826b9d002052..58922b9f60608893defcbc4a4a8b60f0b05d8f35 100644 (file)
@@ -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))