Mike McCormack : rpcrt4: Fix and test RpcNetworkIsProtseqValid.

Alexandre Julliard julliard at wine.codeweavers.com
Thu May 18 09:44:12 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: c3a08421a2285542223a00f047a98625d6f7bce0
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=c3a08421a2285542223a00f047a98625d6f7bce0

Author: Mike McCormack <mike at codeweavers.com>
Date:   Thu May 18 19:06:30 2006 +0900

rpcrt4: Fix and test RpcNetworkIsProtseqValid.

---

 dlls/rpcrt4/rpc_binding.c   |   43 -------------------------------------------
 dlls/rpcrt4/rpc_transport.c |   37 +++++++++++++++++++++++++++++++++++++
 dlls/rpcrt4/tests/rpc.c     |   12 ++++++++++++
 3 files changed, 49 insertions(+), 43 deletions(-)

diff --git a/dlls/rpcrt4/rpc_binding.c b/dlls/rpcrt4/rpc_binding.c
index 631d46e..8e2c4bb 100644
--- a/dlls/rpcrt4/rpc_binding.c
+++ b/dlls/rpcrt4/rpc_binding.c
@@ -835,49 +835,6 @@ RPC_STATUS WINAPI I_RpcBindingSetAsync( 
 }
 
 /***********************************************************************
- *             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.@)
  *
  * Impersonates the client connected via a binding handle so that security
diff --git a/dlls/rpcrt4/rpc_transport.c b/dlls/rpcrt4/rpc_transport.c
index ba4e8d3..9758b6c 100644
--- a/dlls/rpcrt4/rpc_transport.c
+++ b/dlls/rpcrt4/rpc_transport.c
@@ -488,3 +488,40 @@ RPC_STATUS RPCRT4_DestroyConnection(RpcC
   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;
+}
diff --git a/dlls/rpcrt4/tests/rpc.c b/dlls/rpcrt4/tests/rpc.c
index ce53471..fc0c922 100644
--- a/dlls/rpcrt4/tests/rpc.c
+++ b/dlls/rpcrt4/tests/rpc.c
@@ -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();
 }




More information about the wine-cvs mailing list