rpcrt4: Fix and test RpcNetworkIsProtseqValid.
This commit is contained in:
parent
0f8f927aed
commit
c3a08421a2
|
@ -834,49 +834,6 @@ RPC_STATUS WINAPI I_RpcBindingSetAsync( RPC_BINDING_HANDLE Binding, RPC_BLOCKING
|
|||
return RPC_S_OK;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* RpcNetworkIsProtseqValidA (RPCRT4.@)
|
||||
*/
|
||||
RPC_STATUS WINAPI RpcNetworkIsProtseqValidA(unsigned char *protseq) {
|
||||
UNICODE_STRING protseqW;
|
||||
|
||||
if (!protseq) return RPC_S_INVALID_RPC_PROTSEQ; /* ? */
|
||||
|
||||
if (RtlCreateUnicodeStringFromAsciiz(&protseqW, (char*)protseq)) {
|
||||
RPC_STATUS ret = RpcNetworkIsProtseqValidW(protseqW.Buffer);
|
||||
RtlFreeUnicodeString(&protseqW);
|
||||
return ret;
|
||||
} else return RPC_S_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* RpcNetworkIsProtseqValidW (RPCRT4.@)
|
||||
*
|
||||
* Checks if the given protocol sequence is known by the RPC system.
|
||||
* If it is, returns RPC_S_OK, otherwise RPC_S_PROTSEQ_NOT_SUPPORTED.
|
||||
*
|
||||
* We currently support:
|
||||
* ncalrpc local-only rpc over LPC (LPC is not really used)
|
||||
* ncacn_np rpc over named pipes
|
||||
*/
|
||||
RPC_STATUS WINAPI RpcNetworkIsProtseqValidW(LPWSTR protseq) {
|
||||
static const WCHAR protseqsW[][15] = {
|
||||
{'n','c','a','l','r','p','c',0},
|
||||
{'n','c','a','c','n','_','n','p',0}
|
||||
};
|
||||
static const int count = sizeof(protseqsW) / sizeof(protseqsW[0]);
|
||||
int i;
|
||||
|
||||
if (!protseq) return RPC_S_INVALID_RPC_PROTSEQ; /* ? */
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (!strcmpW(protseq, protseqsW[i])) return RPC_S_OK;
|
||||
}
|
||||
|
||||
FIXME("Unknown protseq %s - we probably need to implement it one day\n", debugstr_w(protseq));
|
||||
return RPC_S_PROTSEQ_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* RpcImpersonateClient (RPCRT4.@)
|
||||
*
|
||||
|
|
|
@ -488,3 +488,40 @@ RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection)
|
|||
HeapFree(GetProcessHeap(), 0, Connection);
|
||||
return RPC_S_OK;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* RpcNetworkIsProtseqValidW (RPCRT4.@)
|
||||
*
|
||||
* Checks if the given protocol sequence is known by the RPC system.
|
||||
* If it is, returns RPC_S_OK, otherwise RPC_S_PROTSEQ_NOT_SUPPORTED.
|
||||
*
|
||||
*/
|
||||
RPC_STATUS WINAPI RpcNetworkIsProtseqValidW(LPWSTR protseq)
|
||||
{
|
||||
char ps[0x10];
|
||||
|
||||
WideCharToMultiByte(CP_ACP, 0, protseq, -1,
|
||||
ps, sizeof ps, NULL, NULL);
|
||||
if (rpcrt4_get_protseq_ops(ps))
|
||||
return RPC_S_OK;
|
||||
|
||||
FIXME("Unknown protseq %s\n", debugstr_w(protseq));
|
||||
|
||||
return RPC_S_INVALID_RPC_PROTSEQ;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* RpcNetworkIsProtseqValidA (RPCRT4.@)
|
||||
*/
|
||||
RPC_STATUS WINAPI RpcNetworkIsProtseqValidA(unsigned char *protseq)
|
||||
{
|
||||
UNICODE_STRING protseqW;
|
||||
|
||||
if (RtlCreateUnicodeStringFromAsciiz(&protseqW, (char*)protseq))
|
||||
{
|
||||
RPC_STATUS ret = RpcNetworkIsProtseqValidW(protseqW.Buffer);
|
||||
RtlFreeUnicodeString(&protseqW);
|
||||
return ret;
|
||||
}
|
||||
return RPC_S_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -165,10 +165,22 @@ static void TestDceErrorInqText (void)
|
|||
ok (0, "Cannot set up for DceErrorInqText\n");
|
||||
}
|
||||
|
||||
static void test_rpc_ncacn_ip_tcp(void)
|
||||
{
|
||||
RPC_STATUS status;
|
||||
|
||||
status = RpcNetworkIsProtseqValid((unsigned char*)"foo");
|
||||
ok(status == RPC_S_INVALID_RPC_PROTSEQ, "return wrong\n");
|
||||
|
||||
status = RpcNetworkIsProtseqValid((unsigned char*)"ncacn_ip_tcp");
|
||||
ok(status == RPC_S_OK, "return wrong\n");
|
||||
}
|
||||
|
||||
START_TEST( rpc )
|
||||
{
|
||||
trace ( " ** Uuid Conversion and Comparison Tests **\n" );
|
||||
UuidConversionAndComparison();
|
||||
trace ( " ** DceErrorInqText **\n");
|
||||
TestDceErrorInqText();
|
||||
test_rpc_ncacn_ip_tcp();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue