Commit 29334489 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

server: Introduce IOCTL_AFD_CREATE.

parent db8a7531
/*
* Socket driver ioctls
*
* Copyright 2020 Zebediah Figura for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_WINE_AFD_H
#define __WINE_WINE_AFD_H
#include <winioctl.h>
#define IOCTL_AFD_CREATE CTL_CODE(FILE_DEVICE_NETWORK, 200, METHOD_BUFFERED, FILE_WRITE_ACCESS)
struct afd_create_params
{
int family, type, protocol;
unsigned int flags;
};
#endif
......@@ -58,6 +58,7 @@
#include "winerror.h"
#define USE_WS_PREFIX
#include "winsock2.h"
#include "wine/afd.h"
#include "process.h"
#include "file.h"
......@@ -133,6 +134,7 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
static void sock_queue_async( struct fd *fd, struct async *async, int type, int count );
static void sock_reselect_async( struct fd *fd, struct async_queue *queue );
static int init_socket( struct sock *sock, int family, int type, int protocol, unsigned int flags );
static int sock_get_ntstatus( int err );
static unsigned int sock_get_error( int err );
......@@ -542,10 +544,23 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
assert( sock->obj.ops == &sock_ops );
if (get_unix_fd( fd ) == -1) return 0;
if (get_unix_fd( fd ) == -1 && code != IOCTL_AFD_CREATE) return 0;
switch(code)
{
case IOCTL_AFD_CREATE:
{
const struct afd_create_params *params = get_req_data();
if (get_req_data_size() != sizeof(*params))
{
set_error( STATUS_INVALID_PARAMETER );
return 0;
}
init_socket( sock, params->family, params->type, params->protocol, params->flags );
return 0;
}
case WS_SIO_ADDRESS_LIST_CHANGE:
if ((sock->state & FD_WINE_NONBLOCKING) && async_is_blocking( async ))
{
......@@ -680,6 +695,8 @@ static int init_socket( struct sock *sock, int family, int type, int protocol, u
sock->type = type;
sock->family = family;
if (sock->fd) release_object( sock->fd );
if (!(sock->fd = create_anonymous_fd( &sock_fd_ops, sockfd, &sock->obj,
(flags & WSA_FLAG_OVERLAPPED) ? 0 : FILE_SYNCHRONOUS_IO_NONALERT )))
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment