From 42e33f344b2e702ef3a2fbc8c8844e2aff305b39 Mon Sep 17 00:00:00 2001 From: Martin Drab Date: Mon, 19 Dec 2022 07:41:43 -0800 Subject: [PATCH] [viosock]: Publish supported socket options also for the kernel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Socket driver enables its users to set several socket options, however, their values are not defined in kernel mode (winsock2.h defines them for usermode code). This commit moves these definitions from internal source file of the Socket driver into its public header file. Signed-off-by: Martin DrĂ¡b (martin.drab@virtuozzo.com) --- viosock/inc/vio_sockets.h | 23 +++++++++++++++++++++++ viosock/sys/Socket.c | 18 ------------------ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/viosock/inc/vio_sockets.h b/viosock/inc/vio_sockets.h index 90ffe2330..bb37a4284 100644 --- a/viosock/inc/vio_sockets.h +++ b/viosock/inc/vio_sockets.h @@ -37,6 +37,29 @@ #include +#ifndef _WINSOCK2API_ + +#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */ +#define IOC_VOID 0x20000000 /* no parameters */ +#define IOC_OUT 0x40000000 /* copy out parameters */ +#define IOC_IN 0x80000000 /* copy in parameters */ + +#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) +#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) + +#define FIONREAD _IOR('f', 127, ULONG) /* get # bytes to read */ +#define FIONBIO _IOW('f', 126, ULONG) /* set/clear non-blocking i/o */ + +#define IOC_WS2 0x08000000 + +#define _WSAIO(x,y) (IOC_VOID|(x)|(y)) +#define _WSAIOR(x,y) (IOC_OUT|(x)|(y)) + +#define SIO_ADDRESS_LIST_QUERY _WSAIOR(IOC_WS2,22) +#define SIO_ADDRESS_LIST_CHANGE _WSAIO(IOC_WS2,23) + +#endif + #define VIOSOCK_NAME L"\\??\\Viosock" #ifdef _WINBASE_ diff --git a/viosock/sys/Socket.c b/viosock/sys/Socket.c index 2edaa95ad..1d1cfddce 100644 --- a/viosock/sys/Socket.c +++ b/viosock/sys/Socket.c @@ -2393,24 +2393,6 @@ VIOSockSetSockOpt( return status; } -#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */ -#define IOC_VOID 0x20000000 /* no parameters */ -#define IOC_OUT 0x40000000 /* copy out parameters */ -#define IOC_IN 0x80000000 /* copy in parameters */ - -#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) -#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) - -#define FIONREAD _IOR('f', 127, ULONG) /* get # bytes to read */ -#define FIONBIO _IOW('f', 126, ULONG) /* set/clear non-blocking i/o */ - -#define IOC_WS2 0x08000000 - -#define _WSAIO(x,y) (IOC_VOID|(x)|(y)) -#define _WSAIOR(x,y) (IOC_OUT|(x)|(y)) - -#define SIO_ADDRESS_LIST_QUERY _WSAIOR(IOC_WS2,22) -#define SIO_ADDRESS_LIST_CHANGE _WSAIO(IOC_WS2,23) static NTSTATUS