public IRpcClientTransport Connect(RpcEndpoint endpoint, RpcTransportSecurity transport_security)
            {
                string hostname = string.IsNullOrEmpty(endpoint.NetworkAddress) ? "127.0.0.1" : endpoint.NetworkAddress;
                int    port     = int.Parse(endpoint.Endpoint);

                return(new RpcTcpClientTransport(hostname, port, transport_security));
            }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="stream">The stream to use to communicate with the transport.</param>
 /// <param name="max_recv_fragment">The initial maximum receive fragment length.</param>
 /// <param name="max_send_fragment">The initial maximum send fragment length.</param>
 /// <param name="transport_security">The transport security for the connection.</param>
 /// <param name="data_rep">The data representation.</param>
 protected RpcStreamClientTransport(Stream stream, ushort max_recv_fragment, ushort max_send_fragment,
                                    NdrDataRepresentation data_rep, RpcTransportSecurity transport_security)
     : base(max_recv_fragment, max_send_fragment, data_rep, transport_security)
 {
     _reader = new BinaryReader(stream, Encoding.ASCII, true);
     _writer = new BinaryWriter(stream, Encoding.ASCII, true);
 }
Ejemplo n.º 3
0
 internal RpcTransportSecurityContext(IRpcClientTransport client_transport,
                                      RpcTransportSecurity transport_security, int context_id)
 {
     _client_transport = client_transport;
     ContextId         = context_id;
     TransportSecurity = transport_security;
     AuthContext       = transport_security.CreateClientContext();
 }
        /// <summary>
        /// Connect a client transport from an endpoint.
        /// </summary>
        /// <param name="endpoint">The RPC endpoint.</param>
        /// <param name="transport_security">The transport security for the connection.</param>
        /// <returns>The  connected client transport.</returns>
        /// <exception cref="ArgumentException">Thrown if protocol sequence unsupported.</exception>
        /// <exception cref="Exception">Other exceptions depending on the connection.</exception>
        public static IRpcClientTransport ConnectEndpoint(RpcEndpoint endpoint, RpcTransportSecurity transport_security)
        {
            if (!_factories.ContainsKey(endpoint.ProtocolSequence))
            {
                throw new ArgumentException($"Unsupported protocol sequence {endpoint.ProtocolSequence}", nameof(endpoint));
            }

            return(_factories[endpoint.ProtocolSequence].Connect(endpoint, transport_security));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="max_recv_fragment">The initial maximum receive fragment length.</param>
 /// <param name="max_send_fragment">The initial maximum send fragment length.</param>
 /// <param name="transport_security">The transport security for the connection.</param>
 /// <param name="data_rep">The data representation.</param>
 protected RpcConnectedClientTransport(ushort max_recv_fragment, ushort max_send_fragment,
                                       NdrDataRepresentation data_rep, RpcTransportSecurity transport_security)
 {
     _max_recv_fragment  = max_recv_fragment;
     _max_send_fragment  = max_send_fragment;
     _data_rep           = data_rep;
     _transport_security = transport_security;
     _auth_context       = transport_security.CreateClientContext();
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="path">The NT pipe path to connect. e.g. \??\pipe\ABC.</param>
        /// <param name="transport_security">The transport security for the connection.</param>
        public RpcNamedPipeClientTransport(string path, RpcTransportSecurity transport_security)
            : base(MaxRecvFrag, MaxXmitFrag, new NdrDataRepresentation(), transport_security)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentException("Must specify a path to connect to", nameof(path));
            }

            _pipe    = ConnectPipe(path, transport_security.SecurityQualityOfService);
            Endpoint = path;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="max_recv_fragment">The initial maximum receive fragment length.</param>
        /// <param name="max_send_fragment">The initial maximum send fragment length.</param>
        /// <param name="transport_security">The transport security for the connection.</param>
        /// <param name="data_rep">The data representation.</param>
        protected RpcConnectedClientTransport(ushort max_recv_fragment, ushort max_send_fragment,
                                              NdrDataRepresentation data_rep, RpcTransportSecurity transport_security)
        {
            _max_recv_fragment        = max_recv_fragment;
            _max_send_fragment        = max_send_fragment;
            _data_rep                 = data_rep;
            _security_context         = new Dictionary <int, RpcTransportSecurityContext>();
            _current_security_context = new RpcTransportSecurityContext(this, transport_security, _current_context_id++);
            _security_context[_current_security_context.ContextId] = _current_security_context;
            switch (transport_security.AuthenticationLevel)
            {
            case RpcAuthenticationLevel.PacketIntegrity:
            case RpcAuthenticationLevel.PacketPrivacy:
                _auth_data_required = true;
                break;
            }

            if (DisableBindTimeFeatureNegotiation)
            {
                _bind_time_features = BindTimeFeatureNegotiation.None;
            }
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="endpoint">The HyperV socket endpoint to connect to.</param>
 /// <param name="transport_security">The transport security for the connection.</param>
 public RpcHyperVClientTransport(HyperVEndPoint endpoint, RpcTransportSecurity transport_security)
     : base(CreateSocket(endpoint), MaxRecvFrag, MaxXmitFrag, new NdrDataRepresentation(), transport_security)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="hostname">The hostname to connect to.</param>
 /// <param name="port">The TCP port to connect to.</param>
 /// <param name="transport_security">The transport security for the connection.</param>
 public RpcTcpClientTransport(string hostname, int port, RpcTransportSecurity transport_security)
     : base(CreateSocket(hostname, port), MaxRecvFrag, MaxXmitFrag, new NdrDataRepresentation(), transport_security)
 {
 }
 /// <summary>
 /// Add and authenticate a new security context.
 /// </summary>
 /// <param name="transport_security">The transport security for the context.</param>
 /// <returns>The created security context.</returns>
 public RpcTransportSecurityContext AddSecurityContext(RpcTransportSecurity transport_security)
 {
     throw new InvalidOperationException("Transport doesn't support multiple security context.");
 }
 public IRpcClientTransport Connect(RpcEndpoint endpoint, RpcTransportSecurity transport_security)
 {
     return(new RpcNamedPipeClientTransport(endpoint.EndpointPath, transport_security));
 }
 public IRpcClientTransport Connect(RpcEndpoint endpoint, RpcTransportSecurity transport_security)
 {
     return(new RpcAlpcClientTransport(endpoint.EndpointPath, transport_security.SecurityQualityOfService));
 }
 public IRpcClientTransport Connect(RpcEndpoint endpoint, RpcTransportSecurity transport_security)
 {
     return(new RpcHyperVClientTransport(GetEndpoint(endpoint), transport_security));
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="socket">The socket to use to communicate.</param>
 /// <param name="max_recv_fragment">The initial maximum receive fragment length.</param>
 /// <param name="max_send_fragment">The initial maximum send fragment length.</param>
 /// <param name="transport_security">The transport security for the connection.</param>
 /// <param name="data_rep">The data representation.</param>
 protected RpcStreamSocketClientTransport(Socket socket, ushort max_recv_fragment, ushort max_send_fragment,
                                          NdrDataRepresentation data_rep, RpcTransportSecurity transport_security)
     : base(new NetworkStream(socket), max_recv_fragment, max_send_fragment, data_rep, transport_security)
 {
     _socket = socket;
 }