rpcrt4: Split RPCRT4_process_packet out into separate functions.
This commit is contained in:
parent
4dc91b7ba1
commit
a04641c15b
|
@ -3,6 +3,7 @@
|
|||
*
|
||||
* Copyright 2001 Ove Kåven, TransGaming Technologies
|
||||
* Copyright 2004 Filip Navara
|
||||
* Copyright 2006-2008 Robert Shearman (for CodeWeavers)
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -160,25 +161,14 @@ static WINE_EXCEPTION_FILTER(rpc_filter)
|
|||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSAGE* msg)
|
||||
static RPC_STATUS process_bind_packet(RpcConnection *conn, RpcPktBindHdr *hdr, RPC_MESSAGE *msg)
|
||||
{
|
||||
RpcServerInterface* sif;
|
||||
RPC_DISPATCH_FUNCTION func;
|
||||
UUID *object_uuid;
|
||||
RpcPktHdr *response = NULL;
|
||||
void *buf = msg->Buffer;
|
||||
RPC_STATUS status;
|
||||
BOOL exception;
|
||||
NDR_SCONTEXT context_handle;
|
||||
|
||||
msg->Handle = (RPC_BINDING_HANDLE)conn->server_binding;
|
||||
|
||||
switch (hdr->common.ptype) {
|
||||
case PKT_BIND:
|
||||
TRACE("got bind packet\n");
|
||||
RpcServerInterface* sif;
|
||||
RpcPktHdr *response = NULL;
|
||||
|
||||
/* FIXME: do more checks! */
|
||||
if (hdr->bind.max_tsize < RPC_MIN_PACKET_SIZE ||
|
||||
if (hdr->max_tsize < RPC_MIN_PACKET_SIZE ||
|
||||
!UuidIsNil(&conn->ActiveInterface.SyntaxGUID, &status) ||
|
||||
conn->server_binding) {
|
||||
TRACE("packet size less than min size, or active interface syntax guid non-null\n");
|
||||
|
@ -189,9 +179,9 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA
|
|||
RpcServerAssoc_GetAssociation(rpcrt4_conn_get_name(conn),
|
||||
conn->NetworkAddr, conn->Endpoint,
|
||||
conn->NetworkOptions,
|
||||
hdr->bind.assoc_gid,
|
||||
hdr->assoc_gid,
|
||||
&conn->server_binding->Assoc) == RPC_S_OK)
|
||||
sif = RPCRT4_find_interface(NULL, &hdr->bind.abstract, FALSE);
|
||||
sif = RPCRT4_find_interface(NULL, &hdr->abstract, FALSE);
|
||||
else
|
||||
sif = NULL;
|
||||
}
|
||||
|
@ -202,7 +192,7 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA
|
|||
RPC_VER_MAJOR, RPC_VER_MINOR);
|
||||
} else {
|
||||
TRACE("accepting bind request on connection %p for %s\n", conn,
|
||||
debugstr_guid(&hdr->bind.abstract.SyntaxGUID));
|
||||
debugstr_guid(&hdr->abstract.SyntaxGUID));
|
||||
|
||||
/* accept. */
|
||||
response = RPCRT4_BuildBindAckHeader(NDR_LOCAL_DATA_REPRESENTATION,
|
||||
|
@ -214,21 +204,31 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA
|
|||
&sif->If->TransferSyntax);
|
||||
|
||||
/* save the interface for later use */
|
||||
conn->ActiveInterface = hdr->bind.abstract;
|
||||
conn->MaxTransmissionSize = hdr->bind.max_tsize;
|
||||
conn->ActiveInterface = hdr->abstract;
|
||||
conn->MaxTransmissionSize = hdr->max_tsize;
|
||||
|
||||
RPCRT4_release_server_interface(sif);
|
||||
}
|
||||
|
||||
if (response)
|
||||
status = RPCRT4_Send(conn, response, NULL, 0);
|
||||
else
|
||||
status = ERROR_OUTOFMEMORY;
|
||||
RPCRT4_FreeHeader(response);
|
||||
if (status != RPC_S_OK)
|
||||
goto fail;
|
||||
|
||||
break;
|
||||
return status;
|
||||
}
|
||||
|
||||
case PKT_REQUEST:
|
||||
TRACE("got request packet\n");
|
||||
static RPC_STATUS process_request_packet(RpcConnection *conn, RpcPktRequestHdr *hdr, RPC_MESSAGE *msg)
|
||||
{
|
||||
RPC_STATUS status;
|
||||
RpcPktHdr *response = NULL;
|
||||
RpcServerInterface* sif;
|
||||
RPC_DISPATCH_FUNCTION func;
|
||||
BOOL exception;
|
||||
UUID *object_uuid;
|
||||
NDR_SCONTEXT context_handle;
|
||||
void *buf = msg->Buffer;
|
||||
|
||||
/* fail if the connection isn't bound with an interface */
|
||||
if (UuidIsNil(&conn->ActiveInterface.SyntaxGUID, &status)) {
|
||||
|
@ -238,11 +238,11 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA
|
|||
|
||||
RPCRT4_Send(conn, response, NULL, 0);
|
||||
RPCRT4_FreeHeader(response);
|
||||
break;
|
||||
return RPC_S_OK;
|
||||
}
|
||||
|
||||
if (hdr->common.flags & RPC_FLG_OBJECT_UUID) {
|
||||
object_uuid = (UUID*)(&hdr->request + 1);
|
||||
object_uuid = (UUID*)(hdr + 1);
|
||||
} else {
|
||||
object_uuid = NULL;
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA
|
|||
|
||||
RPCRT4_Send(conn, response, NULL, 0);
|
||||
RPCRT4_FreeHeader(response);
|
||||
break;
|
||||
return RPC_S_OK;
|
||||
}
|
||||
msg->RpcInterfaceInformation = sif->If;
|
||||
/* copy the endpoint vector from sif to msg so that midl-generated code will use it */
|
||||
|
@ -265,7 +265,7 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA
|
|||
}
|
||||
|
||||
/* find dispatch function */
|
||||
msg->ProcNum = hdr->request.opnum;
|
||||
msg->ProcNum = hdr->opnum;
|
||||
if (sif->Flags & RPC_IF_OLE) {
|
||||
/* native ole32 always gives us a dispatch table with a single entry
|
||||
* (I assume that's a wrapper for IRpcStubBuffer::Invoke) */
|
||||
|
@ -324,6 +324,30 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA
|
|||
msg->RpcInterfaceInformation = NULL;
|
||||
RPCRT4_release_server_interface(sif);
|
||||
|
||||
if (msg->Buffer == buf) buf = NULL;
|
||||
TRACE("freeing Buffer=%p\n", buf);
|
||||
I_RpcFree(buf);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSAGE* msg)
|
||||
{
|
||||
RPC_STATUS status;
|
||||
|
||||
msg->Handle = (RPC_BINDING_HANDLE)conn->server_binding;
|
||||
|
||||
switch (hdr->common.ptype) {
|
||||
case PKT_BIND:
|
||||
TRACE("got bind packet\n");
|
||||
|
||||
status = process_bind_packet(conn, &hdr->bind, msg);
|
||||
break;
|
||||
|
||||
case PKT_REQUEST:
|
||||
TRACE("got request packet\n");
|
||||
|
||||
status = process_request_packet(conn, &hdr->request, msg);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -331,11 +355,7 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA
|
|||
break;
|
||||
}
|
||||
|
||||
fail:
|
||||
/* clean up */
|
||||
if (msg->Buffer == buf) msg->Buffer = NULL;
|
||||
TRACE("freeing Buffer=%p\n", buf);
|
||||
I_RpcFree(buf);
|
||||
I_RpcFreeBuffer(msg);
|
||||
RPCRT4_FreeHeader(hdr);
|
||||
HeapFree(GetProcessHeap(), 0, msg);
|
||||
|
|
Loading…
Reference in New Issue