protected override 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); } dpb.Append(IscCodes.isc_dpb_utf8_filename, 0); Xdr.WriteBuffer(Encoding.UTF8.GetBytes(database)); Xdr.WriteBuffer(dpb.ToArray()); }
protected internal override IResponse ProcessCryptCallbackResponseIfNeeded(IResponse response, byte[] cryptKey) { while (response is CryptKeyCallbackResponse cryptKeyCallbackResponse) { Xdr.Write(IscCodes.op_crypt_key_callback); Xdr.WriteBuffer(cryptKey); Xdr.Write(cryptKeyCallbackResponse.Size); Xdr.Flush(); response = ReadResponse(); } return(response); }
protected override void SendCreateToBuffer(DatabaseParameterBufferBase 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()); }
public override async Task Detach(AsyncWrappingCommonArgs async) { if (TransactionCount > 0) { throw IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount); } try { await CloseEventManager(async).ConfigureAwait(false); var detach = _handle != -1; if (detach) { await Xdr.Write(IscCodes.op_detach, async).ConfigureAwait(false); await Xdr.Write(_handle, async).ConfigureAwait(false); } await Xdr.Write(IscCodes.op_disconnect, async).ConfigureAwait(false); await Xdr.Flush(async).ConfigureAwait(false); if (detach) { await ReadResponse(async).ConfigureAwait(false); } await CloseConnection(async).ConfigureAwait(false); } catch (IOException ex) { try { await CloseConnection(async).ConfigureAwait(false); } catch (IOException) { } throw IscException.ForIOException(ex); } finally { _connection = null; Charset = null; _eventManager = null; ServerVersion = null; Dialect = 0; _handle = -1; PacketSize = 0; WarningMessage = null; TransactionCount = 0; } }
public virtual void ConnectionRequest(out int auxHandle, out string ipAddress, out int portNumber) { try { Xdr.Write(IscCodes.op_connect_request); Xdr.Write(IscCodes.P_REQ_async); Xdr.Write(_handle); Xdr.Write(PartnerIdentification); Xdr.Flush(); ReadOperation(); auxHandle = Xdr.ReadInt32(); var garbage1 = new byte[8]; Xdr.ReadBytes(garbage1, 8); var respLen = Xdr.ReadInt32(); respLen += respLen % 4; var sin_family = new byte[2]; Xdr.ReadBytes(sin_family, 2); respLen -= 2; var sin_port = new byte[2]; Xdr.ReadBytes(sin_port, 2); portNumber = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(sin_port, 0)); respLen -= 2; // * The address returned by the server may be incorrect if it is behind a NAT box // * so we must use the address that was used to connect the main socket, not the // * address reported by the server. var sin_addr = new byte[4]; Xdr.ReadBytes(sin_addr, 4); //ipAddress = string.Format( // CultureInfo.InvariantCulture, // "{0}.{1}.{2}.{3}", // buffer[0], buffer[1], buffer[2], buffer[3]); ipAddress = _connection.IPAddress.ToString(); respLen -= 4; var garbage2 = new byte[respLen]; Xdr.ReadBytes(garbage2, respLen); Xdr.ReadStatusVector(); } catch (IOException ex) { throw IscException.ForErrorCode(IscCodes.isc_network_error, ex); } }
public virtual void Detach() { if (TransactionCount > 0) { throw IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount); } try { CloseEventManager(); var detach = _handle != -1; if (detach) { Xdr.Write(IscCodes.op_detach); Xdr.Write(_handle); } Xdr.Write(IscCodes.op_disconnect); Xdr.Flush(); if (detach) { ReadResponse(); } CloseConnection(); } catch (IOException ex) { try { CloseConnection(); } catch (IOException ex2) { throw IscException.ForErrorCode(IscCodes.isc_network_error, ex2); } throw IscException.ForErrorCode(IscCodes.isc_network_error, ex); } finally { _connection = null; _charset = null; _eventManager = null; _serverVersion = null; _dialect = 0; _handle = -1; _packetSize = 0; _warningMessage = null; _transactionCount = 0; } }
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); }
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); }
public virtual (int auxHandle, string ipAddress, int portNumber, int timeout) ConnectionRequest() { try { Xdr.Write(IscCodes.op_connect_request); Xdr.Write(IscCodes.P_REQ_async); Xdr.Write(_handle); Xdr.Write(PartnerIdentification); Xdr.Flush(); ReadOperation(); var auxHandle = Xdr.ReadInt32(); var garbage1 = new byte[8]; Xdr.ReadBytes(garbage1, 8); var respLen = Xdr.ReadInt32(); respLen += respLen % 4; var sin_family = new byte[2]; Xdr.ReadBytes(sin_family, 2); respLen -= 2; var sin_port = new byte[2]; Xdr.ReadBytes(sin_port, 2); var portNumber = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(sin_port, 0)); respLen -= 2; // * The address returned by the server may be incorrect if it is behind a NAT box // * so we must use the address that was used to connect the main socket, not the // * address reported by the server. var sin_addr = new byte[4]; Xdr.ReadBytes(sin_addr, 4); var ipAddress = _connection.IPAddress.ToString(); respLen -= 4; var garbage2 = new byte[respLen]; Xdr.ReadBytes(garbage2, respLen); Xdr.ReadStatusVector(); return(auxHandle, ipAddress, portNumber, _connection.Timeout); } catch (IOException ex) { throw IscException.ForIOException(ex); } }
public override void Detach() { if (TransactionCount > 0) { throw IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount); } try { CloseEventManager(); var detach = _handle != -1; if (detach) { Xdr.Write(IscCodes.op_detach); Xdr.Write(_handle); } Xdr.Write(IscCodes.op_disconnect); Xdr.Flush(); if (detach) { ReadResponse(); } CloseConnection(); } catch (IOException ex) { try { CloseConnection(); } catch (IOException) { } throw IscException.ForIOException(ex); } finally { _connection = null; Charset = null; _eventManager = null; ServerVersion = null; Dialect = 0; _handle = -1; PacketSize = 0; WarningMessage = null; TransactionCount = 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); }
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); }
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); }
public virtual void DropDatabase() { try { Xdr.Write(IscCodes.op_drop_database); Xdr.Write(_handle); Xdr.Flush(); ReadResponse(); _handle = -1; } catch (IOException ex) { throw IscException.ForErrorCode(IscCodes.isc_network_error, ex); } }
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()); }
public void CancelEvents(RemoteEvent events) { try { Xdr.Write(IscCodes.op_cancel_events); Xdr.Write(_handle); Xdr.Write(events.LocalId); Xdr.Flush(); ReadResponse(); } catch (IOException ex) { throw IscException.ForErrorCode(IscCodes.isc_network_error, ex); } }
public override void CancelEvents(RemoteEvent events) { try { Xdr.Write(IscCodes.op_cancel_events); Xdr.Write(_handle); Xdr.Write(events.LocalId); Xdr.Flush(); ReadResponse(); } catch (IOException ex) { throw IscException.ForIOException(ex); } }
public override void DropDatabase() { try { Xdr.Write(IscCodes.op_drop_database); Xdr.Write(_handle); Xdr.Flush(); ReadResponse(); _handle = -1; } catch (IOException ex) { throw IscException.ForIOException(ex); } }
public override async Task CancelEvents(RemoteEvent events, AsyncWrappingCommonArgs async) { try { await Xdr.Write(IscCodes.op_cancel_events, async).ConfigureAwait(false); await Xdr.Write(_handle, async).ConfigureAwait(false); await Xdr.Write(events.LocalId, async).ConfigureAwait(false); await Xdr.Flush(async).ConfigureAwait(false); await ReadResponse(async).ConfigureAwait(false); } catch (IOException ex) { throw IscException.ForIOException(ex); } }
public override async Task DropDatabase(AsyncWrappingCommonArgs async) { try { await Xdr.Write(IscCodes.op_drop_database, async).ConfigureAwait(false); await Xdr.Write(_handle, async).ConfigureAwait(false); await Xdr.Flush(async).ConfigureAwait(false); await ReadResponse(async).ConfigureAwait(false); _handle = -1; } catch (IOException ex) { throw IscException.ForIOException(ex); } }
public virtual async Task DropDatabase(AsyncWrappingCommonArgs async) { try { await Xdr.Write(IscCodes.op_drop_database, async).ConfigureAwait(false); await Xdr.Write(_handle, async).ConfigureAwait(false); await Xdr.Flush(async).ConfigureAwait(false); await ReadResponse(async).ConfigureAwait(false); _handle = -1; } catch (IOException ex) { throw IscException.ForErrorCode(IscCodes.isc_network_error, ex); } }
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); } }
protected void DoReleaseObjectPacket(int op, int id) { Xdr.Write(op); Xdr.Write(id); }
protected virtual void SendReleaseObjectToBuffer(int op, int id) { Xdr.Write(op); Xdr.Write(id); }
protected virtual async Task SendReleaseObjectToBuffer(int op, int id, AsyncWrappingCommonArgs async) { await Xdr.Write(op, async).ConfigureAwait(false); await Xdr.Write(id, async).ConfigureAwait(false); }
protected void SendCancelOperationToBuffer(int kind) { Xdr.Write(IscCodes.op_cancel); Xdr.Write(kind); }
protected async Task SendCancelOperationToBuffer(int kind, AsyncWrappingCommonArgs async) { await Xdr.Write(IscCodes.op_cancel, async).ConfigureAwait(false); await Xdr.Write(kind, async).ConfigureAwait(false); }