Module: wine Branch: master Commit: 6ccf61fbc730bfbb64ccb75ddbc226bb19968694 URL: https://source.winehq.org/git/wine.git/?a=commit;h=6ccf61fbc730bfbb64ccb75dd...
Author: Zebediah Figura z.figura12@gmail.com Date: Thu May 13 22:54:39 2021 -0500
server: Implement IOCTL_AFD_LISTEN.
Signed-off-by: Zebediah Figura z.figura12@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
include/wine/afd.h | 9 +++++++++ server/sock.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/include/wine/afd.h b/include/wine/afd.h index a711fba23a5..e890020ca88 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -24,6 +24,15 @@ #include <winioctl.h> #include "wine/server_protocol.h"
+#define IOCTL_AFD_LISTEN CTL_CODE(FILE_DEVICE_BEEP, 0x802, METHOD_NEITHER, FILE_ANY_ACCESS) + +struct afd_listen_params +{ + int unknown1; + int backlog; + int unknown2; +}; + #define IOCTL_AFD_WINE_CREATE CTL_CODE(FILE_DEVICE_NETWORK, 200, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_ACCEPT CTL_CODE(FILE_DEVICE_NETWORK, 201, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_ACCEPT_INTO CTL_CODE(FILE_DEVICE_NETWORK, 202, METHOD_BUFFERED, FILE_ANY_ACCESS) diff --git a/server/sock.c b/server/sock.c index dadcc607fbb..945895b51a4 100644 --- a/server/sock.c +++ b/server/sock.c @@ -1354,10 +1354,11 @@ static struct accept_req *alloc_accept_req( struct sock *sock, struct sock *acce static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async ) { struct sock *sock = get_fd_user( fd ); + int unix_fd;
assert( sock->obj.ops == &sock_ops );
- if (code != IOCTL_AFD_WINE_CREATE && get_unix_fd( fd ) < 0) return 0; + if (code != IOCTL_AFD_WINE_CREATE && (unix_fd = get_unix_fd( fd )) < 0) return 0;
switch(code) { @@ -1459,6 +1460,32 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async ) return 1; }
+ case IOCTL_AFD_LISTEN: + { + const struct afd_listen_params *params = get_req_data(); + + if (get_req_data_size() < sizeof(*params)) + { + set_error( STATUS_INVALID_PARAMETER ); + return 0; + } + + if (listen( unix_fd, params->backlog ) < 0) + { + set_error( sock_get_ntstatus( errno ) ); + return 0; + } + + sock->pending_events &= ~FD_ACCEPT; + sock->reported_events &= ~FD_ACCEPT; + sock->state |= FD_WINE_LISTENING; + sock->state &= ~(FD_CONNECT | FD_WINE_CONNECTED); + + /* we may already be selecting for FD_ACCEPT */ + sock_reselect( sock ); + return 0; + } + case IOCTL_AFD_WINE_ADDRESS_LIST_CHANGE: if ((sock->state & FD_WINE_NONBLOCKING) && async_is_blocking( async )) {