Commit 6bb03d7d authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

rpcrt4: Add new function RPCRT4_ReceiveWithAuth to receive a fragment and return…

rpcrt4: Add new function RPCRT4_ReceiveWithAuth to receive a fragment and return the authentication data received, if any.
parent dec4acd8
...@@ -795,19 +795,22 @@ fail: ...@@ -795,19 +795,22 @@ fail:
} }
/*********************************************************************** /***********************************************************************
* RPCRT4_Receive (internal) * RPCRT4_ReceiveWithAuth (internal)
* *
* Receive a packet from connection and merge the fragments. * Receive a packet from connection, merge the fragments and return the auth
* data.
*/ */
RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header, RPC_STATUS RPCRT4_ReceiveWithAuth(RpcConnection *Connection, RpcPktHdr **Header,
PRPC_MESSAGE pMsg) PRPC_MESSAGE pMsg,
unsigned char **auth_data_out,
unsigned long *auth_length_out)
{ {
RPC_STATUS status; RPC_STATUS status;
DWORD hdr_length; DWORD hdr_length;
unsigned short first_flag; unsigned short first_flag;
unsigned long data_length; unsigned long data_length;
unsigned long buffer_length; unsigned long buffer_length;
unsigned long auth_length; unsigned long auth_length = 0;
unsigned char *auth_data = NULL; unsigned char *auth_data = NULL;
RpcPktHdr *CurrentHeader = NULL; RpcPktHdr *CurrentHeader = NULL;
void *payload = NULL; void *payload = NULL;
...@@ -815,7 +818,7 @@ RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header, ...@@ -815,7 +818,7 @@ RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header,
*Header = NULL; *Header = NULL;
pMsg->Buffer = NULL; pMsg->Buffer = NULL;
TRACE("(%p, %p, %p)\n", Connection, Header, pMsg); TRACE("(%p, %p, %p, %p)\n", Connection, Header, pMsg, auth_data_out);
RPCRT4_SetThreadCurrentConnection(Connection); RPCRT4_SetThreadCurrentConnection(Connection);
...@@ -911,9 +914,7 @@ RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header, ...@@ -911,9 +914,7 @@ RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header,
/* these packets are handled specially, not by the generic SecurePacket /* these packets are handled specially, not by the generic SecurePacket
* function */ * function */
if (((*Header)->common.ptype != PKT_BIND) && if (!auth_data_out && SecIsValidHandle(&Connection->ctx))
((*Header)->common.ptype != PKT_BIND_ACK) &&
((*Header)->common.ptype != PKT_AUTH3))
{ {
status = RPCRT4_SecurePacket(Connection, SECURE_PACKET_RECEIVE, status = RPCRT4_SecurePacket(Connection, SECURE_PACKET_RECEIVE,
CurrentHeader, hdr_length, CurrentHeader, hdr_length,
...@@ -970,12 +971,28 @@ fail: ...@@ -970,12 +971,28 @@ fail:
RPCRT4_FreeHeader(*Header); RPCRT4_FreeHeader(*Header);
*Header = NULL; *Header = NULL;
} }
if (auth_data_out && status == RPC_S_OK) {
*auth_length_out = auth_length;
*auth_data_out = auth_data;
}
else
HeapFree(GetProcessHeap(), 0, auth_data); HeapFree(GetProcessHeap(), 0, auth_data);
HeapFree(GetProcessHeap(), 0, payload); HeapFree(GetProcessHeap(), 0, payload);
return status; return status;
} }
/*********************************************************************** /***********************************************************************
* RPCRT4_Receive (internal)
*
* Receive a packet from connection and merge the fragments.
*/
RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header,
PRPC_MESSAGE pMsg)
{
return RPCRT4_ReceiveWithAuth(Connection, Header, pMsg, NULL, NULL);
}
/***********************************************************************
* I_RpcNegotiateTransferSyntax [RPCRT4.@] * I_RpcNegotiateTransferSyntax [RPCRT4.@]
* *
* Negotiates the transfer syntax used by a client connection by connecting * Negotiates the transfer syntax used by a client connection by connecting
......
...@@ -34,6 +34,7 @@ RpcPktHdr *RPCRT4_BuildBindAckHeader(unsigned long DataRepresentation, unsigned ...@@ -34,6 +34,7 @@ RpcPktHdr *RPCRT4_BuildBindAckHeader(unsigned long DataRepresentation, unsigned
VOID RPCRT4_FreeHeader(RpcPktHdr *Header); VOID RPCRT4_FreeHeader(RpcPktHdr *Header);
RPC_STATUS RPCRT4_Send(RpcConnection *Connection, RpcPktHdr *Header, void *Buffer, unsigned int BufferLength); RPC_STATUS RPCRT4_Send(RpcConnection *Connection, RpcPktHdr *Header, void *Buffer, unsigned int BufferLength);
RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header, PRPC_MESSAGE pMsg); RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header, PRPC_MESSAGE pMsg);
RPC_STATUS RPCRT4_ReceiveWithAuth(RpcConnection *Connection, RpcPktHdr **Header, PRPC_MESSAGE pMsg, unsigned char **auth_data_out, unsigned long *auth_length_out);
NCA_STATUS RPC2NCA_STATUS(RPC_STATUS status); NCA_STATUS RPC2NCA_STATUS(RPC_STATUS status);
RPC_STATUS NCA2RPC_STATUS(NCA_STATUS status); RPC_STATUS NCA2RPC_STATUS(NCA_STATUS status);
......
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