Commit 0a33ac4a authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

server: Move the implementation of IOCTL_AFD_GET_EVENTS to a dedicated server call.

parent 8ab7120b
......@@ -1552,10 +1552,32 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc
}
case IOCTL_AFD_GET_EVENTS:
{
struct afd_get_events_params *params = out_buffer;
HANDLE reset_event = in_buffer; /* sic */
TRACE( "reset_event %p\n", reset_event );
if (in_size) FIXME( "unexpected input size %u\n", in_size );
status = STATUS_BAD_DEVICE_TYPE;
break;
if (out_size < sizeof(*params))
{
status = STATUS_INVALID_PARAMETER;
break;
}
SERVER_START_REQ( socket_get_events )
{
req->handle = wine_server_obj_handle( handle );
req->event = wine_server_obj_handle( reset_event );
wine_server_set_reply( req, params->status, sizeof(params->status) );
if (!(status = wine_server_call( req )))
params->flags = reply->flags;
}
SERVER_END_REQ;
complete_async( handle, event, apc, apc_user, io, status, 0 );
return status;
}
case IOCTL_AFD_POLL:
status = STATUS_BAD_DEVICE_TYPE;
......
......@@ -1841,6 +1841,23 @@ struct send_socket_reply
struct socket_get_events_request
{
struct request_header __header;
obj_handle_t handle;
obj_handle_t event;
char __pad_20[4];
};
struct socket_get_events_reply
{
struct reply_header __header;
unsigned int flags;
/* VARARG(status,uints); */
char __pad_12[4];
};
struct socket_send_icmp_id_request
{
struct request_header __header;
......@@ -5633,6 +5650,7 @@ enum request
REQ_unlock_file,
REQ_recv_socket,
REQ_send_socket,
REQ_socket_get_events,
REQ_socket_send_icmp_id,
REQ_socket_get_icmp_id,
REQ_get_next_console_request,
......@@ -5921,6 +5939,7 @@ union generic_request
struct unlock_file_request unlock_file_request;
struct recv_socket_request recv_socket_request;
struct send_socket_request send_socket_request;
struct socket_get_events_request socket_get_events_request;
struct socket_send_icmp_id_request socket_send_icmp_id_request;
struct socket_get_icmp_id_request socket_get_icmp_id_request;
struct get_next_console_request_request get_next_console_request_request;
......@@ -6207,6 +6226,7 @@ union generic_reply
struct unlock_file_reply unlock_file_reply;
struct recv_socket_reply recv_socket_reply;
struct send_socket_reply send_socket_reply;
struct socket_get_events_reply socket_get_events_reply;
struct socket_send_icmp_id_reply socket_send_icmp_id_reply;
struct socket_get_icmp_id_reply socket_get_icmp_id_reply;
struct get_next_console_request_reply get_next_console_request_reply;
......@@ -6436,7 +6456,7 @@ union generic_reply
/* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 779
#define SERVER_PROTOCOL_VERSION 780
/* ### protocol_version end ### */
......
......@@ -1514,6 +1514,16 @@ enum server_fd_type
@END
/* Get socket event flags */
@REQ(socket_get_events)
obj_handle_t handle; /* socket handle */
obj_handle_t event; /* event to reset */
@REPLY
unsigned int flags; /* event mask */
VARARG(status,uints); /* array of status codes */
@END
/* Store ICMP id for ICMP over datagram fixup */
@REQ(socket_send_icmp_id)
obj_handle_t handle; /* socket handle */
......
......@@ -175,6 +175,7 @@ DECL_HANDLER(lock_file);
DECL_HANDLER(unlock_file);
DECL_HANDLER(recv_socket);
DECL_HANDLER(send_socket);
DECL_HANDLER(socket_get_events);
DECL_HANDLER(socket_send_icmp_id);
DECL_HANDLER(socket_get_icmp_id);
DECL_HANDLER(get_next_console_request);
......@@ -462,6 +463,7 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
(req_handler)req_unlock_file,
(req_handler)req_recv_socket,
(req_handler)req_send_socket,
(req_handler)req_socket_get_events,
(req_handler)req_socket_send_icmp_id,
(req_handler)req_socket_get_icmp_id,
(req_handler)req_get_next_console_request,
......@@ -1085,6 +1087,11 @@ C_ASSERT( FIELD_OFFSET(struct send_socket_reply, wait) == 8 );
C_ASSERT( FIELD_OFFSET(struct send_socket_reply, options) == 12 );
C_ASSERT( FIELD_OFFSET(struct send_socket_reply, nonblocking) == 16 );
C_ASSERT( sizeof(struct send_socket_reply) == 24 );
C_ASSERT( FIELD_OFFSET(struct socket_get_events_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct socket_get_events_request, event) == 16 );
C_ASSERT( sizeof(struct socket_get_events_request) == 24 );
C_ASSERT( FIELD_OFFSET(struct socket_get_events_reply, flags) == 8 );
C_ASSERT( sizeof(struct socket_get_events_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct socket_send_icmp_id_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct socket_send_icmp_id_request, icmp_id) == 16 );
C_ASSERT( FIELD_OFFSET(struct socket_send_icmp_id_request, icmp_seq) == 18 );
......
......@@ -2762,28 +2762,6 @@ static void sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
}
return;
case IOCTL_AFD_GET_EVENTS:
{
struct afd_get_events_params params = {0};
unsigned int i;
if (get_reply_max_size() < sizeof(params))
{
set_error( STATUS_INVALID_PARAMETER );
return;
}
params.flags = sock->pending_events & sock->mask;
for (i = 0; i < ARRAY_SIZE( params.status ); ++i)
params.status[i] = sock_get_ntstatus( sock->errors[i] );
sock->pending_events &= ~sock->mask;
sock_reselect( sock );
set_reply_data( &params, sizeof(params) );
return;
}
case IOCTL_AFD_EVENT_SELECT:
{
struct event *event = NULL;
......@@ -3937,6 +3915,32 @@ DECL_HANDLER(send_socket)
release_object( sock );
}
DECL_HANDLER(socket_get_events)
{
struct sock *sock = (struct sock *)get_handle_obj( current->process, req->handle, 0, &sock_ops );
unsigned int status[13];
unsigned int i;
if (get_reply_max_size() < sizeof(status))
{
set_error( STATUS_INVALID_PARAMETER );
return;
}
if (!sock) return;
reply->flags = sock->pending_events & sock->mask;
for (i = 0; i < ARRAY_SIZE( status ); ++i)
status[i] = sock_get_ntstatus( sock->errors[i] );
sock->pending_events &= ~sock->mask;
sock_reselect( sock );
set_reply_data( status, sizeof(status) );
release_object( sock );
}
DECL_HANDLER(socket_send_icmp_id)
{
struct sock *sock = (struct sock *)get_handle_obj( current->process, req->handle, 0, &sock_ops );
......
......@@ -2089,6 +2089,18 @@ static void dump_send_socket_reply( const struct send_socket_reply *req )
fprintf( stderr, ", nonblocking=%d", req->nonblocking );
}
static void dump_socket_get_events_request( const struct socket_get_events_request *req )
{
fprintf( stderr, " handle=%04x", req->handle );
fprintf( stderr, ", event=%04x", req->event );
}
static void dump_socket_get_events_reply( const struct socket_get_events_reply *req )
{
fprintf( stderr, " flags=%08x", req->flags );
dump_varargs_uints( ", status=", cur_size );
}
static void dump_socket_send_icmp_id_request( const struct socket_send_icmp_id_request *req )
{
fprintf( stderr, " handle=%04x", req->handle );
......@@ -4623,6 +4635,7 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_unlock_file_request,
(dump_func)dump_recv_socket_request,
(dump_func)dump_send_socket_request,
(dump_func)dump_socket_get_events_request,
(dump_func)dump_socket_send_icmp_id_request,
(dump_func)dump_socket_get_icmp_id_request,
(dump_func)dump_get_next_console_request_request,
......@@ -4907,6 +4920,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
NULL,
(dump_func)dump_recv_socket_reply,
(dump_func)dump_send_socket_reply,
(dump_func)dump_socket_get_events_reply,
NULL,
(dump_func)dump_socket_get_icmp_id_reply,
(dump_func)dump_get_next_console_request_reply,
......@@ -5191,6 +5205,7 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
"unlock_file",
"recv_socket",
"send_socket",
"socket_get_events",
"socket_send_icmp_id",
"socket_get_icmp_id",
"get_next_console_request",
......
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