public static IResponse ProcessOperation(int operation, IXdrReader xdr)
        {
            switch (operation)
            {
            case IscCodes.op_response:
                return(new GenericResponse(
                           xdr.ReadInt32(),
                           xdr.ReadInt64(),
                           xdr.ReadBuffer(),
                           xdr.ReadStatusVector()));

            case IscCodes.op_fetch_response:
                return(new FetchResponse(xdr.ReadInt32(), xdr.ReadInt32()));

            case IscCodes.op_sql_response:
                return(new SqlResponse(xdr.ReadInt32()));

            case IscCodes.op_trusted_auth:
                return(new AuthResponse(xdr.ReadBuffer()));

            case IscCodes.op_crypt_key_callback:
                return(new CryptKeyCallbackResponse(xdr.ReadBuffer()));

            default:
                throw new ArgumentOutOfRangeException(nameof(operation), $"{nameof(operation)}={operation}");
            }
        }
Exemplo n.º 2
0
 public void ReadFrom(IXdrReader reader)
 {
     Program  = reader.ReadInt();
     Version  = reader.ReadInt();
     Protocol = (ProtocolKind)reader.ReadInt();
     Port     = reader.ReadInt();
 }
Exemplo n.º 3
0
 public void ReadFrom(IXdrReader reader)
 {
     Program   = reader.ReadInt();
     Version   = reader.ReadInt();
     Procedure = reader.ReadInt();
     Arguments = reader.ReadOpaque();
 }
Exemplo n.º 4
0
        public async ValueTask <IResponse> ProcessContAuthResponseAsync(IXdrReader xdr, CancellationToken cancellationToken = default)
        {
            var operation = await xdr.ReadOperationAsync(cancellationToken).ConfigureAwait(false);

            var response = await GdsConnection.ProcessOperationAsync(operation, xdr, cancellationToken).ConfigureAwait(false);

            GdsConnection.HandleResponseException(response);
            if (response is ContAuthResponse)
            {
                return(response);
            }
            else if (response is CryptKeyCallbackResponse)
            {
                return(response);
            }
            else if (response is GenericResponse genericResponse)
            {
                ServerKeys = genericResponse.Data;
                Complete();
            }
            else
            {
                throw new InvalidOperationException($"Unexpected response ({operation}).");
            }
            return(response);
        }
Exemplo n.º 5
0
 public void ReadFrom(IXdrReader reader)
 {
     BoolValue     = reader.ReadBool();
     Int8Value     = reader.ReadByte();
     Int16Value    = reader.ReadShort();
     Int32Value    = reader.ReadInt();
     Int64Value    = reader.ReadLong();
     UInt16Value   = reader.ReadUShort();
     UInt32Value   = reader.ReadUInt();
     UInt64Value   = reader.ReadULong();
     Float64Value  = reader.ReadDouble();
     Float32Value  = reader.ReadFloat();
     BoolValue2    = reader.ReadBoolArray();
     Int8Value2    = reader.ReadByteArray();
     Int16Value2   = reader.ReadShortArray();
     Int32Value2   = reader.ReadIntArray();
     Int64Value2   = reader.ReadLongArray();
     UInt16Value2  = reader.ReadUShortArray();
     UInt32Value2  = reader.ReadUIntArray();
     UInt64Value2  = reader.ReadULongArray();
     Float64Value2 = reader.ReadDoubleArray();
     Float32Value2 = reader.ReadFloatArray();
     reader.ReadBoolArray(BoolValue3);
     reader.ReadByteArray(Int8Value3);
     reader.ReadShortArray(Int16Value3);
     reader.ReadIntArray(Int32Value3);
     reader.ReadLongArray(Int64Value3);
     reader.ReadUShortArray(UInt16Value3);
     reader.ReadUIntArray(UInt32Value3);
     reader.ReadULongArray(UInt64Value3);
     reader.ReadDoubleArray(Float64Value3);
     reader.ReadFloatArray(Float32Value3);
 }
Exemplo n.º 6
0
        // TODO: maybe more logic can be pulled up here
        public IResponse ProcessContAuthResponse(IXdrReader xdr)
        {
            var operation = xdr.ReadOperation();
            var response  = GdsConnection.ProcessOperation(operation, xdr);

            GdsConnection.HandleResponseException(response);
            if (response is ContAuthResponse)
            {
                return(response);
            }
            else if (response is CryptKeyCallbackResponse)
            {
                return(response);
            }
            else if (response is GenericResponse genericResponse)
            {
                ServerKeys = genericResponse.Data;
                Complete();
            }
            else
            {
                throw new InvalidOperationException($"Unexpected response ({operation}).");
            }
            return(response);
        }
Exemplo n.º 7
0
 public void ReadFrom(IXdrReader reader)
 {
     RpcVersion = reader.ReadUInt();
     Program    = reader.ReadUInt();
     Version    = reader.ReadUInt();
     Procedure  = reader.ReadUInt();
     Credential = new OpaqueAuthentication(reader);
     Verifier   = new OpaqueAuthentication(reader);
 }
Exemplo n.º 8
0
        public void ReadFrom(IXdrReader reader)
        {
            var         current = this;
            MappingNode next;

            do
            {
                current.Mapping = new Mapping(reader);
                next            = reader.ReadBool() ? new MappingNode() : null;
                current.Next    = next;
                current         = next;
            } while (current != null);
        }
Exemplo n.º 9
0
        public void ReadFrom(IXdrReader reader)
        {
            MessageType = (MessageType)reader.ReadInt();
            switch (MessageType)
            {
            case MessageType.Call:
                CallBody = new CallBody(reader);
                break;

            case MessageType.Reply:
                ReplyBody = new ReplyBody(reader);
                break;
            }
        }
Exemplo n.º 10
0
 internal ReceivedRpcCall(
     int program,
     int[] versions,
     INetworkReader networkReader,
     INetworkWriter networkWriter,
     Action <ReceivedRpcCall> receivedCallDispatcher)
 {
     this.program = program;
     this.receivedCallDispatcher = receivedCallDispatcher;
     this.lowVersion             = (uint)versions.Min();
     this.highVersion            = (uint)versions.Max();
     this.xdrReader = new XdrReader(networkReader);
     this.xdrWriter = new XdrWriter(networkWriter);
 }
Exemplo n.º 11
0
        public void ReadFrom(IXdrReader reader)
        {
            RejectStatus = (RejectStatus)reader.ReadInt();
            switch (RejectStatus)
            {
            case RejectStatus.RpcVersionMismatch:
                MismatchInfo = new MismatchInfo(reader);
                break;

            case RejectStatus.AuthenticationError:
                AuthenticationStatus = (AuthenticationStatus)reader.ReadInt();
                break;
            }
        }
Exemplo n.º 12
0
        public void ReadFrom(IXdrReader reader)
        {
            ReplyStatus = (ReplyStatus)reader.ReadInt();
            switch (ReplyStatus)
            {
            case ReplyStatus.Accepted:
                AcceptedReply = new AcceptedReply(reader);
                break;

            case ReplyStatus.Denied:
                RejectedReply = new RejectedReply(reader);
                break;
            }
        }
Exemplo n.º 13
0
        public void ReadFrom(IXdrReader reader)
        {
            AcceptStatus = (AcceptStatus)reader.ReadInt();
            switch (AcceptStatus)
            {
            case AcceptStatus.Success:
                break;

            case AcceptStatus.ProgramMismatch:
                MismatchInfo = new MismatchInfo(reader);
                break;

            default:
                break;
            }
        }
Exemplo n.º 14
0
        public void ProcessWireCryptResponse(IXdrReader xdr, GdsConnection connection)
        {
            if (WireCrypt == WireCryptOption.Disabled)
            {
                return;
            }

            // after writing before reading
            connection.StartEncryption();

            var response = GdsConnection.ProcessOperation(xdr.ReadOperation(), xdr);

            GdsConnection.HandleResponseException(response);

            WireCryptInitialized = true;
        }
Exemplo n.º 15
0
        public async ValueTask ProcessWireCryptResponseAsync(IXdrReader xdr, GdsConnection connection, CancellationToken cancellationToken = default)
        {
            if (WireCrypt == WireCryptOption.Disabled)
            {
                return;
            }

            // after writing before reading
            connection.StartEncryption();

            var response = await GdsConnection.ProcessOperationAsync(await xdr.ReadOperationAsync(cancellationToken).ConfigureAwait(false), xdr, cancellationToken).ConfigureAwait(false);

            GdsConnection.HandleResponseException(response);

            WireCryptInitialized = true;
        }
Exemplo n.º 16
0
 public RpcCall(
     int program,
     IPEndPoint remoteIpEndPoint,
     INetworkReader networkReader,
     INetworkWriter networkWriter,
     Action reestablishConnection,
     ILogger logger = default)
 {
     this.remoteIpEndPoint = remoteIpEndPoint;
     this.networkReader    = networkReader;
     this.networkWriter    = networkWriter;
     this.xdrReader        = new XdrReader(networkReader);
     this.xdrWriter        = new XdrWriter(networkWriter);
     this.rpcMessage       = new RpcMessage
     {
         Body = new Body
         {
             MessageType = MessageType.Call,
             CallBody    = new CallBody
             {
                 RpcVersion = 2,
                 Program    = (uint)program,
                 Credential = new OpaqueAuthentication
                 {
                     AuthenticationFlavor = AuthenticationFlavor.None, Body = new byte[0]
                 },
                 Verifier = new OpaqueAuthentication
                 {
                     AuthenticationFlavor = AuthenticationFlavor.None, Body = new byte[0]
                 }
             }
         }
     };
     this.logger = logger;
     this.reestablishConnection = reestablishConnection;
 }
Exemplo n.º 17
0
 public PingStruct(IXdrReader reader)
 {
     ReadFrom(reader);
 }
Exemplo n.º 18
0
 public MyStruct(IXdrReader reader)
 {
     ReadFrom(reader);
 }
Exemplo n.º 19
0
 public void ReadFrom(IXdrReader reader)
 {
     Low  = reader.ReadUInt();
     High = reader.ReadUInt();
 }
Exemplo n.º 20
0
 public RpcMessage(IXdrReader reader)
 {
     ReadFrom(reader);
 }
Exemplo n.º 21
0
 public void ReadFrom(IXdrReader reader)
 {
     Xid  = reader.ReadUInt();
     Body = new Body(reader);
 }
Exemplo n.º 22
0
 public OpaqueAuthentication(IXdrReader reader)
 {
     ReadFrom(reader);
 }
Exemplo n.º 23
0
 public void ReadFrom(IXdrReader reader)
 {
     Verifier  = new OpaqueAuthentication(reader);
     ReplyData = new ReplyData(reader);
 }
Exemplo n.º 24
0
 public MismatchInfo(IXdrReader reader)
 {
     ReadFrom(reader);
 }
Exemplo n.º 25
0
 public void ReadFrom(IXdrReader reader)
 {
     Value = reader.ReadInt();
 }
Exemplo n.º 26
0
 public ReplyBody(IXdrReader reader)
 {
     ReadFrom(reader);
 }
Exemplo n.º 27
0
 public AcceptedReply(IXdrReader reader)
 {
     ReadFrom(reader);
 }
Exemplo n.º 28
0
 public void ReadFrom(IXdrReader reader)
 {
     AuthenticationFlavor = (AuthenticationFlavor)reader.ReadInt();
     Body = reader.ReadOpaque();
 }
Exemplo n.º 29
0
 public RejectedReply(IXdrReader reader)
 {
     ReadFrom(reader);
 }
Exemplo n.º 30
0
 public ReplyData(IXdrReader reader)
 {
     ReadFrom(reader);
 }