/*
         *  Helper Methods
         */

        static void ReversePingTest(RpcProtseq protocol, string[] hostNames, string endpoint, params RpcAuthentication[] authTypes)
        {
            foreach (RpcAuthentication auth in authTypes)
            {
                ReversePingTest(protocol, hostNames, endpoint, auth);
            }
        }
Example #2
0
 static void ReversePingTest(RpcProtseq protocol, string[] hostNames, string endpoint, params RPC_C_AUTHN[] authTypes)
 {
     foreach (RPC_C_AUTHN auth in authTypes)
     {
         ReversePingTest(protocol, hostNames, endpoint, auth);
     }
 }
 /// <summary>
 /// </summary>
 public msgSender(RpcProtseq protocol, string endPoint, string codeAPI)
 {
     Protocol       = protocol;
     EndPoint       = endPoint;
     CodeAPI        = codeAPI;
     Authentication = msgAuthentication.none;
 }
Example #4
0
 public RpcClientApi(Guid iid, RpcProtseq protocol, string server, string endpoint)
 {
     this._handle   = (RpcHandle) new RpcClientApi.RpcClientHandle();
     this.IID       = iid;
     this._protocol = protocol;
     this._binding  = RpcClientApi.StringBindingCompose(protocol, server, endpoint, (string)null);
     this.Connect();
 }
 /// <summary>
 /// </summary>
 public msgSender(RpcProtseq protocol, string endPoint, string codeAPI, string token)
 {
     Protocol       = protocol;
     EndPoint       = endPoint;
     CodeAPI        = codeAPI;
     Authentication = msgAuthentication.token;
     Token          = token;
 }
 /// <summary>
 /// </summary>
 public msgSender(RpcProtseq protocol, string endPoint, string codeAPI, string username, string password)
 {
     Protocol       = protocol;
     EndPoint       = endPoint;
     CodeAPI        = codeAPI;
     Authentication = msgAuthentication.login;
     Username       = username;
     Password       = password;
 }
Example #7
0
        public Client(EndpointBindingInfo endpointBindingInfo)
        {
            _handle   = new RpcClientHandle();
            _protocol = endpointBindingInfo.Protseq;
            _binding  = stringBindingCompose(endpointBindingInfo, null);
            RpcTrace.Verbose("Client('{0}:{1}')", endpointBindingInfo.NetworkAddr, endpointBindingInfo.EndPoint);

            bindingFromStringBinding(_handle, _binding);
        }
Example #8
0
        private void PrepareRpcHandleAndBindingString(Guid iid, RpcProtseq protocol, string server, string endpoint)
        {
            _handle   = new RpcClientHandle();
            IID       = iid;
            _protocol = protocol;
            Log.Verbose("RpcClient('{0}:{1}')", server, endpoint);

            _binding = StringBindingCompose(protocol, server, endpoint, null);
        }
Example #9
0
        /// <summary>
        /// Connects to the provided server interface with the given protocol and server:endpoint
        /// </summary>
        public RpcClientApi(Guid iid, RpcProtseq protocol, string server, string endpoint)
        {
            _handle   = new RpcClientHandle();
            IID       = iid;
            _protocol = protocol;
            Log.Verbose("RpcClient('{0}:{1}')", server, endpoint);

            _binding = StringBindingCompose(protocol, server, endpoint, null);
            Connect();
        }
        private static void ServerUseProtseqEp(RpcProtseq protocol, uint maxCalls, String endpoint)
        {
            Log.Verbose("ServerUseProtseqEp({0})", protocol);
            RpcError err = RpcServerUseProtseqEp(protocol.ToString(), maxCalls, endpoint, IntPtr.Zero);

            if (err != RpcError.RPC_S_DUPLICATE_ENDPOINT)
            {
                RpcException.Assert(err);
            }
        }
        /// <summary>
        /// Connects to the provided server interface with the given protocol and server:endpoint
        /// </summary>
        public RpcClientApi(Guid iid, RpcProtseq protocol, string server, string endpoint)
        {
            _handle = new RpcClientHandle();
            IID = iid;
            _protocol = protocol;
            Log.Verbose("RpcClient('{0}:{1}')", server, endpoint);

            _binding = StringBindingCompose(protocol, server, endpoint, null);
            Connect();
        }
Example #12
0
        private static bool ServerUseProtseqEp(RpcProtseq protocol, int maxCalls, string endpoint)
        {
            RpcError errorCode = RpcServerApi.RpcServerUseProtseqEp(protocol.ToString(), maxCalls, endpoint, IntPtr.Zero);

            if (errorCode != RpcError.RPC_S_DUPLICATE_ENDPOINT)
            {
                RpcException.Assert(errorCode);
            }

            return(errorCode == RpcError.RPC_S_OK);
        }
Example #13
0
        private static bool serverUseProtseqEp(RpcProtseq protocol, int maxCalls, String endpoint)
        {
            RpcTrace.Verbose("serverUseProtseqEp({0})", protocol);
            // all RPC servers within the process will be available on that protocol
            // once invoked this can not be undone
            //TODO: make server isolated of other process services, make it not static as possible
            RPC_STATUS err = NativeMethods.RpcServerUseProtseqEp(protocol.ToString(), maxCalls, endpoint, IntPtr.Zero);

            if (err != RPC_STATUS.RPC_S_DUPLICATE_ENDPOINT)
            {
                Guard.Assert(err);
            }
            return(err == RPC_STATUS.RPC_S_OK);
        }
Example #14
0
        private static string StringBindingCompose(RpcProtseq ProtSeq, string NetworkAddr, string Endpoint, string Options)
        {
            IntPtr lpBindingString;

            RpcException.Assert(RpcClientApi.RpcStringBindingCompose((string)null, ProtSeq.ToString(), NetworkAddr, Endpoint, Options, out lpBindingString));
            try
            {
                return(Marshal.PtrToStringUni(lpBindingString));
            }
            finally
            {
                RpcException.Assert(RpcClientApi.RpcStringFree(ref lpBindingString));
            }
        }
Example #15
0
        private static String StringBindingCompose(RpcProtseq ProtSeq, String NetworkAddr, String Endpoint,
                                                   String Options)
        {
            IntPtr   lpBindingString;
            RpcError result = RpcStringBindingCompose(null, ProtSeq.ToString(), NetworkAddr, Endpoint, Options,
                                                      out lpBindingString);

            RpcException.Assert(result);

            try
            {
                return(Marshal.PtrToStringUni(lpBindingString));
            }
            finally
            {
                RpcException.Assert(RpcStringFree(ref lpBindingString));
            }
        }
        static void ReversePingTest(RpcProtseq protocol, string[] hostNames, string endpoint, RpcAuthentication auth)
        {
            Guid iid = Guid.NewGuid();

            using (RpcServerApi server = new RpcServerApi(iid))
            {
                server.OnExecute +=
                    delegate(IRpcClientInfo client, byte[] arg)
                {
                    Array.Reverse(arg);
                    return(arg);
                };

                server.AddProtocol(protocol, endpoint, 5);
                server.AddAuthentication(auth);
                server.StartListening();

                byte[] input  = Encoding.ASCII.GetBytes("abc");
                byte[] expect = Encoding.ASCII.GetBytes("cba");

                foreach (string hostName in hostNames)
                {
                    using (RpcClientApi client = new RpcClientApi(iid, protocol, hostName, endpoint))
                    {
                        client.AuthenticateAs(null, auth == RpcAuthentication.RPC_C_AUTHN_NONE
                                                      ? RpcClientApi.Anonymous
                                                      : RpcClientApi.Self,
                                              auth == RpcAuthentication.RPC_C_AUTHN_NONE
                                                      ? RpcProtectionLevel.RPC_C_PROTECT_LEVEL_NONE
                                                      : RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY,
                                              auth);

                        Assert.AreEqual(expect, client.Execute(input));
                    }
                }
            }
        }
Example #17
0
        static void ReversePingTest(RpcProtseq protocol, string[] hostNames, string endpoint, RPC_C_AUTHN auth)
        {
            Guid iid = Guid.NewGuid();

            using (ExplicitBytesServer server = new ExplicitBytesServer(iid))
            {
                server.OnExecute +=
                    delegate(IRpcCallInfo client, byte[] arg)
                {
                    Array.Reverse(arg);
                    return(arg);
                };

                server.AddProtocol(protocol, endpoint, 5);
                server.AddAuthentication(auth);
                server.StartListening();

                byte[] input  = Encoding.ASCII.GetBytes("abc");
                byte[] expect = Encoding.ASCII.GetBytes("cba");

                foreach (string hostName in hostNames)
                {
                    using (ExplicitBytesClient client = new ExplicitBytesClient(iid, new EndpointBindingInfo(protocol, hostName, endpoint)))
                    {
                        client.AuthenticateAs(null, auth == RPC_C_AUTHN.RPC_C_AUTHN_NONE
                                                      ? ExplicitBytesClient.Anonymous
                                                      : ExplicitBytesClient.Self,
                                              auth == RPC_C_AUTHN.RPC_C_AUTHN_NONE
                                                      ? RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_NONE
                                                      : RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
                                              auth);

                        Assert.AreEqual(expect, client.Execute(input));
                    }
                }
            }
        }
Example #18
0
        static void ReversePingTest(RpcProtseq protocol, string[] hostNames, string endpoint, RpcAuthentication auth)
        {
            Guid iid = Guid.NewGuid();
            using (RpcServerApi server = new RpcServerApi(iid))
            {
                server.OnExecute += 
                    delegate(IRpcClientInfo client, byte[] arg)
                    {
                        Array.Reverse(arg);
                        return arg;
                    };

                server.AddProtocol(protocol, endpoint, 5);
                server.AddAuthentication(auth);
                server.StartListening();

                byte[] input = Encoding.ASCII.GetBytes("abc");
                byte[] expect = Encoding.ASCII.GetBytes("cba");

                foreach (string hostName in hostNames)
                {
                    using (RpcClientApi client = new RpcClientApi(iid, protocol, hostName, endpoint))
                    {
                        client.AuthenticateAs(null, auth == RpcAuthentication.RPC_C_AUTHN_NONE
                                                      ? RpcClientApi.Anonymous
                                                      : RpcClientApi.Self, 
                                                  auth == RpcAuthentication.RPC_C_AUTHN_NONE
                                                      ? RpcProtectionLevel.RPC_C_PROTECT_LEVEL_NONE
                                                      : RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY,
                                                  auth);

                        Assert.AreEqual(expect, client.Execute(input));
                    }
                }
            }
        }
Example #19
0
        static void ReversePingTest(RpcProtseq protocol, string[] hostNames, string endpoint, RPC_C_AUTHN auth)
        {
            Guid iid = Guid.NewGuid();
            using (ExplicitBytesServer server = new ExplicitBytesServer(iid))
            {
                server.OnExecute +=
                    delegate(IRpcCallInfo client, byte[] arg)
                    {
                        Array.Reverse(arg);
                        return arg;
                    };

                server.AddProtocol(protocol, endpoint, 5);
                server.AddAuthentication(auth);
                server.StartListening();

                byte[] input = Encoding.ASCII.GetBytes("abc");
                byte[] expect = Encoding.ASCII.GetBytes("cba");

                foreach (string hostName in hostNames)
                {
                    using (ExplicitBytesClient client = new ExplicitBytesClient(iid, new EndpointBindingInfo(protocol, hostName, endpoint)))
                    {
                        client.AuthenticateAs(null, auth == RPC_C_AUTHN.RPC_C_AUTHN_NONE
                                                      ? ExplicitBytesClient.Anonymous
                                                      : ExplicitBytesClient.Self,
                                                  auth == RPC_C_AUTHN.RPC_C_AUTHN_NONE
                                                      ? RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_NONE
                                                      : RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
                                                  auth);

                        Assert.AreEqual(expect, client.Execute(input));
                    }
                }
            }
        }
Example #20
0
        private static void TestPerformanceInternal(RpcProtseq protoseq, string endpointName, int payloadSize)
        {
            Guid iid = Guid.NewGuid();

            using (ExplicitBytesServer server = new ExplicitBytesServer(iid))
            {
                server.AddProtocol(protoseq, endpointName, 5);
                server.AddAuthentication(RPC_C_AUTHN.RPC_C_AUTHN_WINNT);
                server.StartListening();
                server.OnExecute +=
                    delegate(IRpcCallInfo client, byte[] arg) { return(arg); };

                using (
                    ExplicitBytesClient client = new ExplicitBytesClient(iid,
                                                                         new EndpointBindingInfo(protoseq, null, endpointName)))
                {
                    client.AuthenticateAs(null, ExplicitBytesClient.Self, RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
                                          RPC_C_AUTHN.RPC_C_AUTHN_WINNT);
                    client.Execute(new byte[0]);

                    byte[] bytes = new byte[payloadSize];
                    new Random().NextBytes(bytes);

                    Stopwatch timer = new Stopwatch();
                    timer.Start();

                    for (int i = 0; i < 5000; i++)
                    {
                        client.Execute(bytes);
                    }

                    timer.Stop();
                    Trace.WriteLine(timer.ElapsedMilliseconds.ToString(), endpointName);
                }
            }
        }
 /// <summary>
 /// Used to ensure that the server is listening with a specific protocol type.  Once invoked this
 /// can not be undone, and all RPC servers within the process will be available on that protocol
 /// </summary>
 public bool AddProtocol(RpcProtseq protocol, string endpoint, int maxCalls)
 {
     _maxCalls = Math.Max(_maxCalls, maxCalls);
     return(ServerUseProtseqEp(protocol, maxCalls, endpoint));
 }
Example #22
0
 /// <summary>
 /// Connects to the provided server interface with the given protocol and server:endpoint
 /// </summary>
 public RpcClientApi(Guid iid, RpcProtseq protocol, string server, string endpoint)
 {
     PrepareRpcHandleAndBindingString(iid, protocol, server, endpoint);
     Connect();
 }
Example #23
0
 public EndpointBindingInfo(RpcProtseq protseq, string networkAddr, string endPoint)
 {
     Protseq = protseq;
     NetworkAddr = networkAddr;
     EndPoint = endPoint;
 }
Example #24
0
 static void ReversePingTest(RpcProtseq protocol, string[] hostNames, string endpoint, params RPC_C_AUTHN[] authTypes)
 {
     foreach (RPC_C_AUTHN auth in authTypes)
         ReversePingTest(protocol, hostNames, endpoint, auth);
 }
Example #25
0
 private static bool serverUseProtseqEp(RpcProtseq protocol, int maxCalls, String endpoint)
 {
     RpcTrace.Verbose("serverUseProtseqEp({0})", protocol);
     // all RPC servers within the process will be available on that protocol
     // once invoked this can not be undone
     //TODO: make server isolated of other process services, make it not static as possible
     RPC_STATUS err = NativeMethods.RpcServerUseProtseqEp(protocol.ToString(), maxCalls, endpoint, IntPtr.Zero);
     if (err != RPC_STATUS.RPC_S_DUPLICATE_ENDPOINT)
         Guard.Assert(err);
     return err == RPC_STATUS.RPC_S_OK;
 }
        private static bool ServerUseProtseqEp(RpcProtseq protocol, int maxCalls, String endpoint)
        {
            Log.Verbose("ServerUseProtseqEp({0})", protocol);
            RpcError err = RpcServerUseProtseqEp(protocol.ToString(), maxCalls, endpoint, IntPtr.Zero);
            if (err != RpcError.RPC_S_DUPLICATE_ENDPOINT)
                RpcException.Assert(err);

            return err == RpcError.RPC_S_OK;
        }
 /// <summary>
 /// Used to ensure that the server is listening with a specific protocol type.  Once invoked this
 /// can not be undone, and all RPC servers within the process will be available on that protocol
 /// </summary>
 public bool AddProtocol(RpcProtseq protocol, string endpoint, int maxCalls)
 {
     _maxCalls = Math.Max(_maxCalls, maxCalls);
     return ServerUseProtseqEp(protocol, maxCalls, endpoint);
 }
Example #28
0
        /*
         *  Helper Methods
         */

        static void ReversePingTest(RpcProtseq protocol, string[] hostNames, string endpoint, params RpcAuthentication[] authTypes)
        {
            foreach (RpcAuthentication auth in authTypes)
                ReversePingTest(protocol, hostNames, endpoint, auth);
        }
        private static String StringBindingCompose(RpcProtseq ProtSeq, String NetworkAddr, String Endpoint,
                                                   String Options)
        {
            IntPtr lpBindingString;
            RpcError result = RpcStringBindingCompose(null, ProtSeq.ToString(), NetworkAddr, Endpoint, Options,
                                                      out lpBindingString);
            RpcException.Assert(result);

            try
            {
                return Marshal.PtrToStringUni(lpBindingString);
            }
            finally
            {
                RpcException.Assert(RpcStringFree(ref lpBindingString));
            }
        }
Example #30
0
        private static void TestPerformanceInternal(RpcProtseq protoseq, string endpointName,int payloadSize)
        {
            Guid iid = Guid.NewGuid();
            using (ExplicitBytesServer server = new ExplicitBytesServer(iid))
            {
                server.AddProtocol(protoseq, endpointName, 5);
                server.AddAuthentication(RPC_C_AUTHN.RPC_C_AUTHN_WINNT);
                server.StartListening();
                server.OnExecute +=
                    delegate(IRpcCallInfo client, byte[] arg) { return arg; };

                using (
                    ExplicitBytesClient client = new ExplicitBytesClient(iid,
                        new EndpointBindingInfo(protoseq, null, endpointName)))
                {
                    client.AuthenticateAs(null, ExplicitBytesClient.Self, RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
                        RPC_C_AUTHN.RPC_C_AUTHN_WINNT);
                    client.Execute(new byte[0]);

                    byte[] bytes = new byte[payloadSize];
                    new Random().NextBytes(bytes);

                    Stopwatch timer = new Stopwatch();
                    timer.Start();

                    for (int i = 0; i < 5000; i++)
                        client.Execute(bytes);

                    timer.Stop();
                    Trace.WriteLine(timer.ElapsedMilliseconds.ToString(), endpointName);
                }
            }
        }
 /// <summary>
 /// Used to ensure that the server is listening with a specific protocol type.  Once invoked this
 /// can not be undone, and all RPC servers within the process will be available on that protocol
 /// </summary>
 public void AddProtocol(RpcProtseq protocol, string endpoint, uint maxCalls)
 {
     ServerUseProtseqEp(protocol, maxCalls, endpoint);
     _maxCalls = Math.Max(_maxCalls, maxCalls);
 }
 public EndpointBindingInfo(RpcProtseq protseq, string networkAddr, string endPoint)
 {
     Protseq     = protseq;
     NetworkAddr = networkAddr;
     EndPoint    = endPoint;
 }