Skip to content

Commit

Permalink
[viosock]: Publish supported socket options also for the kernel
Browse files Browse the repository at this point in the history
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 ([email protected])
  • Loading branch information
Martin Drab authored and YanVugenfirer committed Dec 21, 2022
1 parent ade8dbf commit 42e33f3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
23 changes: 23 additions & 0 deletions viosock/inc/vio_sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,29 @@

#include <ws2def.h>

#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_
Expand Down
18 changes: 0 additions & 18 deletions viosock/sys/Socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 42e33f3

Please sign in to comment.