From 8211c3ab36d48f9ce968711f7a63e7bcb10e78f1 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Thu, 24 Jun 2021 00:00:10 -0500 Subject: [PATCH] server: Introduce IOCTL_AFD_WINE_GET_SO_ERROR. Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- include/wine/afd.h | 1 + server/sock.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/wine/afd.h b/include/wine/afd.h index 6370e00539f..0ccd248e614 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -162,6 +162,7 @@ struct afd_get_events_params #define IOCTL_AFD_WINE_GET_SO_ACCEPTCONN CTL_CODE(FILE_DEVICE_NETWORK, 219, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_GET_SO_BROADCAST CTL_CODE(FILE_DEVICE_NETWORK, 220, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_SET_SO_BROADCAST CTL_CODE(FILE_DEVICE_NETWORK, 221, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_AFD_WINE_GET_SO_ERROR CTL_CODE(FILE_DEVICE_NETWORK, 222, METHOD_BUFFERED, FILE_ANY_ACCESS) struct afd_create_params { diff --git a/server/sock.c b/server/sock.c index 71f22845827..f614bf5feaa 100644 --- a/server/sock.c +++ b/server/sock.c @@ -2546,6 +2546,40 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async ) return 1; } + case IOCTL_AFD_WINE_GET_SO_ERROR: + { + int error; + socklen_t len = sizeof(error); + unsigned int i; + + if (get_reply_max_size() < sizeof(error)) + { + set_error( STATUS_BUFFER_TOO_SMALL ); + return 0; + } + + if (getsockopt( unix_fd, SOL_SOCKET, SO_ERROR, (char *)&error, &len ) < 0) + { + set_error( sock_get_ntstatus( errno ) ); + return 0; + } + + if (!error) + { + for (i = 0; i < ARRAY_SIZE( sock->errors ); ++i) + { + if (sock->errors[i]) + { + error = sock->errors[i]; + break; + } + } + } + + set_reply_data( &error, sizeof(error) ); + return 1; + } + default: set_error( STATUS_NOT_SUPPORTED ); return 0;