Exemple #1
0
        public override void QueueEvents(RemoteEvent remoteEvent)
        {
            try
            {
                if (_eventManager == null)
                {
                    var(auxHandle, ipAddress, portNumber, timeout) = ConnectionRequest();
                    _eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber, timeout);
                    _eventManager.Open();
                    var dummy = _eventManager.StartWaitingForEvents(remoteEvent);
                }

                remoteEvent.LocalId++;

                var epb     = remoteEvent.BuildEpb();
                var epbData = epb.ToArray();

                Xdr.Write(IscCodes.op_que_events);
                Xdr.Write(_handle);
                Xdr.WriteBuffer(epbData);
                Xdr.Write(AddressOfAstRoutine);
                Xdr.Write(ArgumentToAstRoutine);
                Xdr.Write(remoteEvent.LocalId);

                Xdr.Flush();

                var response = (GenericResponse)ReadResponse();

                remoteEvent.RemoteId = response.ObjectHandle;
            }
            catch (IOException ex)
            {
                throw IscException.ForIOException(ex);
            }
        }
Exemple #2
0
        private void DatabaseInfo(byte[] items, byte[] buffer, int bufferLength)
        {
            try
            {
                Xdr.Write(IscCodes.op_info_database);
                Xdr.Write(_handle);
                Xdr.Write(Incarnation);
                Xdr.WriteBuffer(items, items.Length);
                Xdr.Write(bufferLength);

                Xdr.Flush();

                var response = (GenericResponse)ReadResponse();

                var responseLength = bufferLength;

                if (response.Data.Length < bufferLength)
                {
                    responseLength = response.Data.Length;
                }

                Buffer.BlockCopy(response.Data, 0, buffer, 0, responseLength);
            }
            catch (IOException ex)
            {
                throw IscException.ForErrorCode(IscCodes.isc_network_error, ex);
            }
        }
Exemple #3
0
        private async Task DatabaseInfo(byte[] items, byte[] buffer, int bufferLength, AsyncWrappingCommonArgs async)
        {
            try
            {
                await Xdr.Write(IscCodes.op_info_database, async).ConfigureAwait(false);

                await Xdr.Write(_handle, async).ConfigureAwait(false);

                await Xdr.Write(Incarnation, async).ConfigureAwait(false);

                await Xdr.WriteBuffer(items, items.Length, async).ConfigureAwait(false);

                await Xdr.Write(bufferLength, async).ConfigureAwait(false);

                await Xdr.Flush(async).ConfigureAwait(false);

                var response = (GenericResponse) await ReadResponse(async).ConfigureAwait(false);

                var responseLength = bufferLength;

                if (response.Data.Length < bufferLength)
                {
                    responseLength = response.Data.Length;
                }

                Buffer.BlockCopy(response.Data, 0, buffer, 0, responseLength);
            }
            catch (IOException ex)
            {
                throw IscException.ForIOException(ex);
            }
        }
Exemple #4
0
        public void QueueEvents(RemoteEvent remoteEvent)
        {
            try
            {
                if (_eventManager == null)
                {
                    ConnectionRequest(out var auxHandle, out var ipAddress, out var portNumber);
                    _eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber);
                    var dummy = _eventManager.WaitForEventsAsync(remoteEvent);
                }

                remoteEvent.LocalId++;

                var epb     = remoteEvent.BuildEpb();
                var epbData = epb.ToArray();

                Xdr.Write(IscCodes.op_que_events);
                Xdr.Write(_handle);
                Xdr.WriteBuffer(epbData);
                Xdr.Write(AddressOfAstRoutine);
                Xdr.Write(ArgumentToAstRoutine);
                Xdr.Write(remoteEvent.LocalId);

                Xdr.Flush();

                var response = (GenericResponse)ReadResponse();

                remoteEvent.RemoteId = response.ObjectHandle;
            }
            catch (IOException ex)
            {
                throw IscException.ForErrorCode(IscCodes.isc_network_error, ex);
            }
        }
Exemple #5
0
 protected virtual void SendCreateToBuffer(DatabaseParameterBuffer dpb, string database)
 {
     Xdr.Write(IscCodes.op_create);
     Xdr.Write(DatabaseObjectId);
     if (!string.IsNullOrEmpty(Password))
     {
         dpb.Append(IscCodes.isc_dpb_password, Password);
     }
     Xdr.WriteBuffer(Encoding.Default.GetBytes(database));
     Xdr.WriteBuffer(dpb.ToArray());
 }
 protected void ProcessTrustedAuthResponse(SspiHelper sspiHelper, ref IResponse response)
 {
     while (response is AuthResponse)
     {
         var authData = sspiHelper.GetClientSecurity(((AuthResponse)response).Data);
         Xdr.Write(IscCodes.op_trusted_auth);
         Xdr.WriteBuffer(authData);
         Xdr.Flush();
         response = ReadResponse();
     }
 }
Exemple #7
0
 protected virtual void SendAttachToBuffer(DatabaseParameterBufferBase dpb, string database)
 {
     Xdr.Write(IscCodes.op_attach);
     Xdr.Write(0);
     if (!string.IsNullOrEmpty(AuthBlock.Password))
     {
         dpb.Append(IscCodes.isc_dpb_password, AuthBlock.Password);
     }
     Xdr.WriteBuffer(Encoding2.Default.GetBytes(database));
     Xdr.WriteBuffer(dpb.ToArray());
 }
Exemple #8
0
 protected internal IResponse ProcessCryptCallbackResponseIfNeeded(IResponse response, byte[] cryptKey)
 {
     while (response is CryptKeyCallbackResponse)
     {
         Xdr.Write(IscCodes.op_crypt_key_callback);
         Xdr.WriteBuffer(cryptKey);
         Xdr.Flush();
         response = ReadResponse();
     }
     return(response);
 }
Exemple #9
0
 protected override void SendCreateToBuffer(DatabaseParameterBufferBase dpb, string database)
 {
     Xdr.Write(IscCodes.op_create);
     Xdr.Write(0);
     if (!string.IsNullOrEmpty(AuthBlock.Password))
     {
         dpb.Append(IscCodes.isc_dpb_password, AuthBlock.Password);
     }
     dpb.Append(IscCodes.isc_dpb_utf8_filename, 0);
     Xdr.WriteBuffer(Encoding.UTF8.GetBytes(database));
     Xdr.WriteBuffer(dpb.ToArray());
 }
 protected override void SendCreateToBuffer(DatabaseParameterBuffer dpb, string database)
 {
     Xdr.Write(IscCodes.op_create);
     Xdr.Write(0);
     if (AuthData != null)
     {
         dpb.Append(IscCodes.isc_dpb_specific_auth_data, AuthData);
     }
     dpb.Append(IscCodes.isc_dpb_utf8_filename, 0);
     Xdr.WriteBuffer(Encoding.UTF8.GetBytes(database));
     Xdr.WriteBuffer(dpb.ToArray());
 }
 protected override void SendAttachToBuffer(DatabaseParameterBuffer dpb, string database)
 {
     Xdr.Write(IscCodes.op_attach);
     Xdr.Write(0);
     if (!string.IsNullOrEmpty(Password))
     {
         dpb.Append(IscCodes.isc_dpb_password, Password);
     }
     dpb.Append(IscCodes.isc_dpb_utf8_filename, 0);
     Xdr.WriteBuffer(Encoding.UTF8.GetBytes(database));
     Xdr.WriteBuffer(dpb.ToArray());
 }
Exemple #12
0
        protected virtual async Task SendCreateToBuffer(DatabaseParameterBufferBase dpb, string database, AsyncWrappingCommonArgs async)
        {
            await Xdr.Write(IscCodes.op_create, async).ConfigureAwait(false);

            await Xdr.Write(DatabaseObjectId, async).ConfigureAwait(false);

            if (!string.IsNullOrEmpty(Password))
            {
                dpb.Append(IscCodes.isc_dpb_password, Password);
            }
            await Xdr.WriteBuffer(Encoding.Default.GetBytes(database), async).ConfigureAwait(false);

            await Xdr.WriteBuffer(dpb.ToArray(), async).ConfigureAwait(false);
        }
        internal async Task <IResponse> ProcessCryptCallbackResponseIfNeeded(IResponse response, byte[] cryptKey, AsyncWrappingCommonArgs async)
        {
            while (response is CryptKeyCallbackResponse cryptResponse)
            {
                await Xdr.Write(IscCodes.op_crypt_key_callback, async).ConfigureAwait(false);

                await Xdr.WriteBuffer(cryptKey, async).ConfigureAwait(false);

                await Xdr.Flush(async).ConfigureAwait(false);

                response = await ReadResponse(async).ConfigureAwait(false);
            }
            return(response);
        }
Exemple #14
0
        protected async Task <IResponse> ProcessTrustedAuthResponse(SspiHelper sspiHelper, IResponse response, AsyncWrappingCommonArgs async)
        {
            while (response is AuthResponse)
            {
                var authData = sspiHelper.GetClientSecurity(((AuthResponse)response).Data);
                await Xdr.Write(IscCodes.op_trusted_auth, async).ConfigureAwait(false);

                await Xdr.WriteBuffer(authData, async).ConfigureAwait(false);

                await Xdr.Flush(async).ConfigureAwait(false);

                response = await ReadResponse(async).ConfigureAwait(false);
            }
            return(response);
        }
Exemple #15
0
        protected override async Task SendCreateToBuffer(DatabaseParameterBufferBase dpb, string database, AsyncWrappingCommonArgs async)
        {
            await Xdr.Write(IscCodes.op_create, async).ConfigureAwait(false);

            await Xdr.Write(0, async).ConfigureAwait(false);

            if (!string.IsNullOrEmpty(Password))
            {
                dpb.Append(IscCodes.isc_dpb_password, Password);
            }
            dpb.Append(IscCodes.isc_dpb_utf8_filename, 0);
            await Xdr.WriteBuffer(Encoding.UTF8.GetBytes(database), async).ConfigureAwait(false);

            await Xdr.WriteBuffer(dpb.ToArray(), async).ConfigureAwait(false);
        }
        protected override async Task SendCreateToBuffer(DatabaseParameterBufferBase dpb, string database, AsyncWrappingCommonArgs async)
        {
            await Xdr.Write(IscCodes.op_create, async).ConfigureAwait(false);

            await Xdr.Write(0, async).ConfigureAwait(false);

            if (AuthData != null)
            {
                dpb.Append(IscCodes.isc_dpb_specific_auth_data, AuthData);
            }
            dpb.Append(IscCodes.isc_dpb_utf8_filename, 0);
            await Xdr.WriteBuffer(Encoding.UTF8.GetBytes(database), async).ConfigureAwait(false);

            await Xdr.WriteBuffer(dpb.ToArray(), async).ConfigureAwait(false);
        }
Exemple #17
0
 protected override void SendCreateToBuffer(DatabaseParameterBufferBase dpb, string database)
 {
     Xdr.Write(IscCodes.op_create);
     Xdr.Write(0);
     if (!AuthBlock.HasClientData)
     {
         dpb.Append(IscCodes.isc_dpb_auth_plugin_name, AuthBlock.AcceptPluginName);
         dpb.Append(IscCodes.isc_dpb_specific_auth_data, AuthBlock.PublicClientData);
     }
     else
     {
         dpb.Append(IscCodes.isc_dpb_specific_auth_data, AuthBlock.ClientData);
     }
     dpb.Append(IscCodes.isc_dpb_utf8_filename, 0);
     Xdr.WriteBuffer(Encoding.UTF8.GetBytes(database));
     Xdr.WriteBuffer(dpb.ToArray());
 }
Exemple #18
0
        public override async Task QueueEvents(RemoteEvent remoteEvent, AsyncWrappingCommonArgs async)
        {
            try
            {
                if (_eventManager == null)
                {
                    var(auxHandle, ipAddress, portNumber) = await ConnectionRequest(async).ConfigureAwait(false);

                    _eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber);
                    await _eventManager.Open(async).ConfigureAwait(false);

                    var dummy = _eventManager.WaitForEvents(remoteEvent, new AsyncWrappingCommonArgs(true));
                }

                remoteEvent.LocalId++;

                var epb     = remoteEvent.BuildEpb();
                var epbData = epb.ToArray();

                await Xdr.Write(IscCodes.op_que_events, async).ConfigureAwait(false);

                await Xdr.Write(_handle, async).ConfigureAwait(false);

                await Xdr.WriteBuffer(epbData, async).ConfigureAwait(false);

                await Xdr.Write(AddressOfAstRoutine, async).ConfigureAwait(false);

                await Xdr.Write(ArgumentToAstRoutine, async).ConfigureAwait(false);

                await Xdr.Write(remoteEvent.LocalId, async).ConfigureAwait(false);

                await Xdr.Flush(async).ConfigureAwait(false);

                var response = (GenericResponse) await ReadResponse(async).ConfigureAwait(false);

                remoteEvent.RemoteId = response.ObjectHandle;
            }
            catch (IOException ex)
            {
                throw IscException.ForIOException(ex);
            }
        }