]> Zhao Yanbai Git Server - minix.git/commitdiff
Added SO_ERROR support for tcp sockets.
authorPhilip Homburg <philip@cs.vu.nl>
Fri, 24 Mar 2006 14:07:42 +0000 (14:07 +0000)
committerPhilip Homburg <philip@cs.vu.nl>
Fri, 24 Mar 2006 14:07:42 +0000 (14:07 +0000)
lib/ip/getsockopt.c

index 537e0c945136b0b366b5d50594b4988720676e0a..f721062648941c6365d2df65ee17f0e5fc2b8b7f 100644 (file)
@@ -61,7 +61,7 @@ int getsockopt(int socket, int level, int option_name,
 static int _tcp_getsockopt(int socket, int level, int option_name,
        void *_RESTRICT option_value, socklen_t *_RESTRICT option_len)
 {
-       int i;
+       int i, r, err;
 
        if (level == SOL_SOCKET && option_name == SO_KEEPALIVE)
        {
@@ -73,6 +73,18 @@ static int _tcp_getsockopt(int socket, int level, int option_name,
                *option_len= sizeof(i);
                return 0;
        }
+       if (level == SOL_SOCKET && option_name == SO_ERROR)
+       {
+               r= ioctl(socket, NWIOTCPGERROR, &err);
+               if (r != 0)
+                       return r;
+               if (*option_len < sizeof(err))
+                       memcpy(option_value, &err, *option_len);
+               else
+                       memcpy(option_value, &err, sizeof(err));
+               *option_len= sizeof(err);
+               return 0;
+       }
        if (level == SOL_SOCKET && option_name == SO_RCVBUF)
        {
                i= 32*1024;     /* Receive buffer in the current