Author: akhaldi
Date: Fri Oct 21 09:01:35 2016
New Revision: 73006
URL:
http://svn.reactos.org/svn/reactos?rev=73006&view=rev
Log:
[RPCRT4] Import Wine commit 01290cd by Colin and Christoph: Implement
RpcBindingServerFromClient and populate NetworkAddr for each transport.
Modified:
trunk/reactos/dll/win32/rpcrt4/rpc_binding.c
trunk/reactos/dll/win32/rpcrt4/rpc_transport.c
Modified: trunk/reactos/dll/win32/rpcrt4/rpc_binding.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/rpcrt4/rpc_bindi…
==============================================================================
--- trunk/reactos/dll/win32/rpcrt4/rpc_binding.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/rpcrt4/rpc_binding.c [iso-8859-1] Fri Oct 21 09:01:35 2016
@@ -1619,10 +1619,24 @@
* RpcBindingServerFromClient (RPCRT4.@)
*/
RPCRTAPI RPC_STATUS RPC_ENTRY
-RpcBindingServerFromClient( RPC_BINDING_HANDLE ClientBinding, RPC_BINDING_HANDLE
*ServerBinding )
-{
- FIXME("%p %p: stub\n", ClientBinding, ServerBinding);
- return RPC_S_INVALID_BINDING;
+RpcBindingServerFromClient(RPC_BINDING_HANDLE ClientBinding, RPC_BINDING_HANDLE*
ServerBinding)
+{
+ RpcBinding* bind = ClientBinding;
+ RpcBinding* NewBinding;
+
+ if (!bind)
+ bind = I_RpcGetCurrentCallHandle();
+
+ if (!bind->server)
+ return RPC_S_INVALID_BINDING;
+
+ RPCRT4_AllocBinding(&NewBinding, TRUE);
+ NewBinding->Protseq = RPCRT4_strdupA(bind->Protseq);
+ NewBinding->NetworkAddr = RPCRT4_strdupA(bind->NetworkAddr);
+
+ *ServerBinding = NewBinding;
+
+ return RPC_S_OK;
}
/***********************************************************************
Modified: trunk/reactos/dll/win32/rpcrt4/rpc_transport.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/rpcrt4/rpc_trans…
==============================================================================
--- trunk/reactos/dll/win32/rpcrt4/rpc_transport.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/rpcrt4/rpc_transport.c [iso-8859-1] Fri Oct 21 09:01:35 2016
@@ -444,6 +444,7 @@
static RPC_STATUS rpcrt4_ncacn_np_handoff(RpcConnection *old_conn, RpcConnection
*new_conn)
{
+ DWORD len = MAX_COMPUTERNAME_LENGTH + 1;
RPC_STATUS status;
LPSTR pname;
static const char prefix[] = "\\\\.";
@@ -455,6 +456,16 @@
status = rpcrt4_conn_create_pipe(old_conn, pname);
I_RpcFree(pname);
+ /* Store the local computer name as the NetworkAddr for ncacn_np as long as
+ * we don't support named pipes over the network. */
+ FIXME("Using local computer name as NetworkAddr\n");
+ new_conn->NetworkAddr = HeapAlloc(GetProcessHeap(), 0, len);
+ if (!GetComputerNameA(new_conn->NetworkAddr, &len))
+ {
+ ERR("Failed to retrieve the computer name, error %u\n", GetLastError());
+ return RPC_S_OUT_OF_RESOURCES;
+ }
+
return status;
}
@@ -487,6 +498,7 @@
static RPC_STATUS rpcrt4_ncalrpc_handoff(RpcConnection *old_conn, RpcConnection
*new_conn)
{
+ DWORD len = MAX_COMPUTERNAME_LENGTH + 1;
RPC_STATUS status;
LPSTR pname;
static const char prefix[] = "\\\\.\\pipe\\lrpc\\";
@@ -499,7 +511,15 @@
strcat(strcpy(pname, prefix), old_conn->Endpoint);
status = rpcrt4_conn_create_pipe(old_conn, pname);
I_RpcFree(pname);
-
+
+ /* Store the local computer name as the NetworkAddr for ncalrpc. */
+ new_conn->NetworkAddr = HeapAlloc(GetProcessHeap(), 0, len);
+ if (!GetComputerNameA(new_conn->NetworkAddr, &len))
+ {
+ ERR("Failed to retrieve the computer name, error %u\n", GetLastError());
+ return RPC_S_OUT_OF_RESOURCES;
+ }
+
return status;
}
@@ -1549,10 +1569,20 @@
ERR("Failed to accept a TCP connection: error %d\n", ret);
return RPC_S_OUT_OF_RESOURCES;
}
+
nonblocking = 1;
ioctlsocket(ret, FIONBIO, &nonblocking);
client->sock = ret;
- TRACE("Accepted a new TCP connection\n");
+
+ client->common.NetworkAddr = HeapAlloc(GetProcessHeap(), 0, INET6_ADDRSTRLEN);
+ ret = getnameinfo((struct sockaddr*)&address, addrsize,
client->common.NetworkAddr, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST);
+ if (ret != 0)
+ {
+ ERR("Failed to retrieve the IP address, error %d\n", ret);
+ return RPC_S_OUT_OF_RESOURCES;
+ }
+
+ TRACE("Accepted a new TCP connection from %s\n",
client->common.NetworkAddr);
return RPC_S_OK;
}