8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-26 08:03:03 +01:00
firebird-mirror/src/remote/remote.h

692 lines
20 KiB
C
Raw Normal View History

2001-05-23 15:26:42 +02:00
/*
* PROGRAM: JRD Remote Interface/Server
* MODULE: remote.h
* DESCRIPTION: Common descriptions
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
2002-10-30 07:40:58 +01:00
*
* 2002.10.29 Sean Leyne - Removed obsolete "Netware" port
*
* 2002.10.30 Sean Leyne - Removed support for obsolete "PC_PLATFORM" define
*
2001-05-23 15:26:42 +02:00
*/
#ifndef REMOTE_REMOTE_H
#define REMOTE_REMOTE_H
#include "../jrd/common.h"
#include "../remote/remote_def.h"
#include "../jrd/thd.h"
2006-03-03 17:20:42 +01:00
#include "../common/classes/objects_array.h"
2006-12-08 19:38:15 +01:00
#include "../auth/trusted/AuthSspi.h"
#include "../common/classes/fb_string.h"
#include "../common/classes/ClumpletWriter.h"
#include "../common/StatusHolder.h"
2001-05-23 15:26:42 +02:00
/* Include some apollo include files for tasking */
#if !(defined VMS || defined WIN_NT)
#include <signal.h>
2001-05-23 15:26:42 +02:00
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#endif /* !VMS || !WIN_NT */
// Uncomment this line if you need to trace module activity
//#define REMOTE_DEBUG
#ifdef REMOTE_DEBUG
DEFINE_TRACE_ROUTINE(remote_trace);
#define REMOTE_TRACE(args) remote_trace args
#else
#define REMOTE_TRACE(args) /* nothing */
#endif
2001-05-23 15:26:42 +02:00
#ifdef DEV_BUILD
/* Debug packet/XDR memory allocation */
/* Temporarily disabling DEBUG_XDR_MEMORY */
/* #define DEBUG_XDR_MEMORY */
#endif
2004-05-17 12:22:34 +02:00
const int BLOB_LENGTH = 16384;
2001-05-23 15:26:42 +02:00
#include "../remote/protocol.h"
/* Block types */
struct blk;
2001-05-23 15:26:42 +02:00
#ifndef INCLUDE_FB_BLK
2001-12-24 03:51:06 +01:00
#include "../include/old_fb_blk.h"
2001-05-23 15:26:42 +02:00
#endif
// fwd. decl.
struct rem_port;
2001-05-23 15:26:42 +02:00
2004-06-09 20:23:27 +02:00
typedef struct rdb
2001-05-23 15:26:42 +02:00
{
blk rdb_header;
2001-05-23 15:26:42 +02:00
USHORT rdb_id;
USHORT rdb_flags;
2004-05-03 01:06:37 +02:00
FB_API_HANDLE rdb_handle; /* database handle */
rem_port* rdb_port; /* communication port */
2001-05-23 15:26:42 +02:00
struct rtr* rdb_transactions; /* linked list of transactions */
struct rrq* rdb_requests; /* compiled requests */
struct rvnt* rdb_events; /* known events */
struct rsr* rdb_sql_requests; /* SQL requests */
2003-04-10 12:31:28 +02:00
ISC_STATUS* rdb_status_vector;
2001-05-23 15:26:42 +02:00
PACKET rdb_packet; /* Communication structure */
2004-06-09 20:23:27 +02:00
} *RDB;
2001-05-23 15:26:42 +02:00
2004-05-17 12:22:34 +02:00
// rdb_flags
const USHORT RDB_service = 1; /* structure relates to a service */
2001-05-23 15:26:42 +02:00
2004-06-09 20:23:27 +02:00
typedef struct rtr
2001-05-23 15:26:42 +02:00
{
blk rtr_header;
rdb* rtr_rdb;
rtr* rtr_next;
2001-05-23 15:26:42 +02:00
struct rbl* rtr_blobs;
2004-05-03 01:06:37 +02:00
FB_API_HANDLE rtr_handle;
2001-05-23 15:26:42 +02:00
USHORT rtr_flags;
USHORT rtr_id;
2004-06-09 20:23:27 +02:00
} *RTR;
2001-05-23 15:26:42 +02:00
2004-05-17 12:22:34 +02:00
// rtr_flags
const USHORT RTR_limbo = 1;
2001-05-23 15:26:42 +02:00
2004-06-09 20:23:27 +02:00
typedef struct rbl
2001-05-23 15:26:42 +02:00
{
blk rbl_header;
rdb* rbl_rdb;
rtr* rbl_rtr;
rbl* rbl_next;
2004-05-03 01:06:37 +02:00
FB_API_HANDLE rbl_handle;
2001-05-23 15:26:42 +02:00
SLONG rbl_offset; /* Apparent (to user) offset in blob */
USHORT rbl_id;
USHORT rbl_flags;
UCHAR* rbl_ptr;
UCHAR* rbl_buffer;
USHORT rbl_buffer_length;
USHORT rbl_length;
USHORT rbl_fragment_length;
USHORT rbl_source_interp; /* source interp (for writing) */
USHORT rbl_target_interp; /* destination interp (for reading) */
UCHAR rbl_data[1];
2004-06-09 20:23:27 +02:00
} *RBL;
2001-05-23 15:26:42 +02:00
2004-05-17 12:22:34 +02:00
// rbl_flags
const USHORT RBL_eof = 1;
const USHORT RBL_segment = 2;
const USHORT RBL_eof_pending= 4;
const USHORT RBL_create = 8;
2001-05-23 15:26:42 +02:00
2004-06-09 20:23:27 +02:00
typedef struct rvnt
2001-05-23 15:26:42 +02:00
{
blk rvnt_header;
rvnt* rvnt_next;
rdb* rvnt_rdb;
2003-12-22 11:00:59 +01:00
FPTR_EVENT_CALLBACK rvnt_ast;
2001-05-23 15:26:42 +02:00
void* rvnt_arg;
SLONG rvnt_id;
SLONG rvnt_rid; /* used by server to store client-side id */
rem_port* rvnt_port; /* used to id server from whence async came */
const UCHAR* rvnt_items;
2001-05-23 15:26:42 +02:00
SSHORT rvnt_length;
2004-06-09 20:23:27 +02:00
} *RVNT;
2001-05-23 15:26:42 +02:00
struct rem_vec
2001-05-23 15:26:42 +02:00
{
blk vec_header;
2001-05-23 15:26:42 +02:00
ULONG vec_count;
blk* vec_object[1];
};
2001-05-23 15:26:42 +02:00
//struct rem_vcl
//{
// blk vcl_header;
// ULONG vcl_count;
// SLONG vcl_long[1];
//};
2001-05-23 15:26:42 +02:00
/* Random string block -- jack of all kludges */
struct rem_str
2001-05-23 15:26:42 +02:00
{
blk str_header;
2001-05-23 15:26:42 +02:00
USHORT str_length;
SCHAR str_data[2];
};
2001-05-23 15:26:42 +02:00
/* Include definition of descriptor */
#include "../jrd/dsc.h"
struct rem_fmt
2001-05-23 15:26:42 +02:00
{
blk fmt_header;
2001-05-23 15:26:42 +02:00
USHORT fmt_length;
USHORT fmt_net_length;
USHORT fmt_count;
USHORT fmt_version;
USHORT fmt_flags; // unused
2001-05-23 15:26:42 +02:00
struct dsc fmt_desc[1];
};
2001-05-23 15:26:42 +02:00
2004-05-17 12:22:34 +02:00
// fmt_flags (not used)
//#define FMT_has_P10_specific_datatypes 0x1 /* datatypes don't exist in P9 */
2001-05-23 15:26:42 +02:00
/* Windows declares a msg structure, so rename the structure
to avoid overlap problems. */
2004-06-09 20:23:27 +02:00
typedef struct message
2001-05-23 15:26:42 +02:00
{
blk msg_header;
message* msg_next; /* Next available message */
2001-05-23 15:26:42 +02:00
#ifdef SCROLLABLE_CURSORS
message* msg_prior; /* Next available message */
ULONG msg_absolute; /* Absolute record number in cursor result set */
2001-05-23 15:26:42 +02:00
#endif
/* Please DO NOT re-arrange the order of following two fields.
This could result in alignment problems while trying to access
'msg_buffer' as a 'long', leading to "core" drops
Sriram - 04-Jun-97 */
USHORT msg_number; /* Message number */
UCHAR* msg_address; /* Address of message */
UCHAR msg_buffer[1]; /* Allocated message */
2004-06-09 20:23:27 +02:00
} *REM_MSG;
2001-05-23 15:26:42 +02:00
/* remote stored procedure request */
2004-06-09 20:23:27 +02:00
typedef struct rpr
2001-05-23 15:26:42 +02:00
{
blk rpr_header;
rdb* rpr_rdb;
rtr* rpr_rtr;
2004-05-03 01:06:37 +02:00
FB_API_HANDLE rpr_handle;
message* rpr_in_msg; /* input message */
message* rpr_out_msg; /* output message */
rem_fmt* rpr_in_format; /* Format of input message */
rem_fmt* rpr_out_format; /* Format of output message */
USHORT rpr_flags; // unused
2004-06-09 20:23:27 +02:00
} *RPR;
2001-05-23 15:26:42 +02:00
// rpr_flags (not used)
2004-05-17 12:22:34 +02:00
//#define RPR_eof 1 /* End-of-stream encountered */
2001-05-23 15:26:42 +02:00
struct rrq
2001-05-23 15:26:42 +02:00
{
blk rrq_header;
rdb* rrq_rdb;
rtr* rrq_rtr;
rrq* rrq_next;
rrq* rrq_levels; /* RRQ block for next level */
2004-05-03 01:06:37 +02:00
FB_API_HANDLE rrq_handle;
2001-05-23 15:26:42 +02:00
USHORT rrq_id;
USHORT rrq_max_msg;
USHORT rrq_level;
2003-04-16 12:18:51 +02:00
ISC_STATUS_ARRAY rrq_status_vector;
2001-05-23 15:26:42 +02:00
struct rrq_repeat
{
rem_fmt* rrq_format; /* format for this message */
message* rrq_message; /* beginning or end of cache, depending on whether it is client or server */
message* rrq_xdr; /* point at which cache is read or written by xdr */
2001-05-23 15:26:42 +02:00
#ifdef SCROLLABLE_CURSORS
message* rrq_last; /* last message returned */
ULONG rrq_absolute; /* current offset in result set for record being read into cache */
USHORT rrq_flags;
2001-05-23 15:26:42 +02:00
#endif
USHORT rrq_msgs_waiting; /* count of full rrq_messages */
USHORT rrq_rows_pending; /* How many rows in waiting */
USHORT rrq_reorder_level; /* Reorder when rows_pending < this level */
USHORT rrq_batch_count; /* Count of batches in pipeline */
2001-05-23 15:26:42 +02:00
} rrq_rpt[1];
};
2001-05-23 15:26:42 +02:00
2004-05-17 12:22:34 +02:00
// rrq_flags
#ifdef SCROLLABLE_CURSORS
2004-05-17 12:22:34 +02:00
const USHORT RRQ_backward = 1; /* the cache was created in the backward direction */
const USHORT RRQ_absolute_backward = 2; /* rrq_absolute is measured from the end of the stream */
const USHORT RRQ_last_backward = 4; /* last time, the next level up asked for us to scroll in the backward direction */
#endif
2001-05-23 15:26:42 +02:00
/* remote SQL request */
2004-06-09 20:23:27 +02:00
typedef struct rsr
2001-05-23 15:26:42 +02:00
{
blk rsr_header;
rsr* rsr_next;
rdb* rsr_rdb;
rtr* rsr_rtr;
2004-05-03 01:06:37 +02:00
FB_API_HANDLE rsr_handle;
rem_fmt* rsr_bind_format; /* Format of bind message */
rem_fmt* rsr_select_format; /* Format of select message */
rem_fmt* rsr_user_select_format; /* Format of user's select message */
rem_fmt* rsr_format; /* Format of current message */
message* rsr_message; /* Next message to process */
message* rsr_buffer; /* Next buffer to use */
Firebird::StatusHolder* rsr_status; /* saved status for buffered errors */
2001-05-23 15:26:42 +02:00
USHORT rsr_id;
USHORT rsr_flags;
USHORT rsr_fmt_length;
ULONG rsr_rows_pending; /* How many rows are pending */
USHORT rsr_msgs_waiting; /* count of full rsr_messages */
USHORT rsr_reorder_level; /* Trigger pipelining at this level */
USHORT rsr_batch_count; /* Count of batches in pipeline */
2004-06-09 20:23:27 +02:00
} *RSR;
2001-05-23 15:26:42 +02:00
2004-05-17 12:22:34 +02:00
// rsr_flags
const USHORT RSR_fetched = 1; /* Cleared by execute, set by fetch */
const USHORT RSR_eof = 2; /* End-of-stream encountered */
const USHORT RSR_blob = 4; /* Statement relates to blob op */
const USHORT RSR_no_batch = 8; /* Do not batch fetch rows */
const USHORT RSR_stream_err = 16; /* There is an error pending in the batched rows */
const USHORT RSR_lazy = 32; /* To be allocated at the first reference */
const USHORT RSR_defer_execute = 64; // op_execute can be deferred
2007-11-19 01:21:18 +01:00
const USHORT RSR_past_eof = 128; // EOF was returned by fetch from this statement
2001-05-23 15:26:42 +02:00
// will be methods of remote statement class
inline void stmt_save_exception(RSR statement, const ISC_STATUS* status, bool overwrite)
{
if (!statement->rsr_status) {
statement->rsr_status = new Firebird::StatusHolder();
}
if (overwrite || !statement->rsr_status->getError()) {
statement->rsr_status->save(status);
}
}
inline void stmt_clear_exception(RSR statement)
{
if (statement->rsr_status)
statement->rsr_status->clear();
}
inline ISC_STATUS stmt_have_exception(RSR statement)
{
return (statement->rsr_status ?
statement->rsr_status->getError() : 0);
}
inline void stmt_raise_exception(RSR statement)
{
if (statement->rsr_status)
statement->rsr_status->raise();
}
inline void stmt_release_exception(RSR statement)
{
if (statement->rsr_status)
{
delete statement->rsr_status;
statement->rsr_status = NULL;
}
}
2001-05-23 15:26:42 +02:00
enum blk_t
{
type_MIN = 0,
type_vec,
type_rdb,
type_fmt,
type_rrq,
type_rtr,
type_str,
type_rbl,
type_port,
type_msg,
type_rsr,
type_rvnt,
type_rpr,
type_rmtque,
type_MAX
};
#include "../remote/xdr.h"
2001-05-23 15:26:42 +02:00
/* Generalized port definition. */
2001-12-24 03:51:06 +01:00
enum rem_port_t
2001-05-23 15:26:42 +02:00
{
port_inet, /* Internet (TCP/IP) */
port_pipe, /* Windows NT named pipe connection */
2006-02-04 11:37:15 +01:00
port_xnet /* Windows NT shared memory connection */
2001-05-23 15:26:42 +02:00
};
enum state_t
{
state_closed, /* no connection */
state_pending, /* connection is pending */
state_eof, /* other side has shut down */
state_broken, /* connection is broken */
state_active, /* connection is complete */
state_disconnected /* port is disconnected */
};
#ifndef WIN_NT
2004-05-18 02:45:46 +02:00
typedef int HANDLE;
2001-05-23 15:26:42 +02:00
#endif /* WIN_NT */
//////////////////////////////////////////////////////////////////
// fwd. decl.
struct p_cnct;
struct rmtque;
2001-05-23 15:26:42 +02:00
/* Queue of deferred packets */
struct rem_que_packet
{
PACKET packet;
bool sent;
};
typedef Firebird::Array<rem_que_packet> PacketQueue;
2006-12-08 19:38:15 +01:00
#ifdef TRUSTED_AUTH
// delayed authentication block for trusted auth callback
class ServerAuth
{
public:
typedef void Part2(rem_port*, P_OP, const char* fName, int fLen, const UCHAR* pb, int pbLen, PACKET*);
Firebird::PathName fileName;
Firebird::HalfStaticArray<UCHAR, 128> clumplet;
AuthSspi* authSspi;
Part2* part2;
P_OP operation;
ServerAuth(const char* fName, int fLen, const Firebird::ClumpletWriter& pb, Part2* p2, P_OP op);
~ServerAuth();
};
2006-12-09 02:23:17 +01:00
#endif // TRUSTED_AUTH
2006-12-08 19:38:15 +01:00
/* Port itself */
2001-05-23 15:26:42 +02:00
class port_interface
{
public:
virtual int accept_(rem_port* pPort, p_cnct* pConnection) = 0;
2001-05-23 15:26:42 +02:00
};
2004-03-07 08:58:55 +01:00
//typedef XDR_INT (*t_event_ast)();
typedef void (*t_event_ast)(rem_port*);
typedef rem_port* (*t_port_connect)(rem_port*, PACKET*, t_event_ast);
struct rem_port
2001-05-23 15:26:42 +02:00
{
blk port_header;
2001-12-24 03:51:06 +01:00
enum rem_port_t port_type; /* type of port */
2001-05-23 15:26:42 +02:00
enum state_t port_state; /* state of port */
P_ARCH port_client_arch; /* so we can tell arch of client */
rem_port* port_clients; /* client ports */
rem_port* port_next; /* next client port */
rem_port* port_parent; /* parent port (for client ports) */
rem_port* port_async; /* asynchronous sibling port */
2001-05-23 15:26:42 +02:00
struct srvr* port_server; /* server of port */
USHORT port_server_flags; /* TRUE if server */
USHORT port_protocol; /* protocol version number */
USHORT port_buff_size; /* port buffer size (approx) */
USHORT port_flags; /* Misc flags */
SLONG port_connect_timeout; /* Connection timeout value */
SLONG port_dummy_packet_interval; /* keep alive dummy packet interval */
SLONG port_dummy_timeout; /* time remaining until keepalive packet */
2003-04-10 12:31:28 +02:00
ISC_STATUS* port_status_vector;
2001-05-23 15:26:42 +02:00
HANDLE port_handle; /* handle for connection (from by OS) */
int port_channel; /* handle for connection (from by OS) */
int port_misc1;
SLONG port_semaphore;
struct linger port_linger; /* linger value as defined by SO_LINGER */
/* port function pointers (C "emulation" of virtual functions) */
int (*port_accept)(rem_port*, p_cnct*);
void (*port_disconnect)(rem_port*);
rem_port* (*port_receive_packet)(rem_port*, PACKET*);
XDR_INT (*port_send_packet)(rem_port*, PACKET*);
XDR_INT (*port_send_partial)(rem_port*, PACKET*);
2006-03-03 17:20:42 +01:00
t_port_connect port_connect; /* Establish secondary connection */
rem_port* (*port_request)(rem_port*, PACKET*); /* Request to establish secondary connection */
2006-03-03 17:20:42 +01:00
rem_port* (*port_select_multi)(rem_port*, UCHAR*, SSHORT, SSHORT*); // get packet from active port
rdb* port_context;
t_event_ast port_ast; /* AST for events */
2001-05-23 15:26:42 +02:00
XDR port_receive;
XDR port_send;
#ifdef DEBUG_XDR_MEMORY
rem_vec* port_packet_vector; /* Vector of send/receive packets */
2001-05-23 15:26:42 +02:00
#endif
rem_vec* port_object_vector;
2001-05-23 15:26:42 +02:00
BLK* port_objects;
rem_str* port_version;
rem_str* port_host; /* Our name */
rem_str* port_connection; /* Name of connection */
rem_str* port_user_name;
rem_str* port_passwd;
rem_str* port_protocol_str; // String containing protocol name for this port
rem_str* port_address_str; // Protocol-specific address string for the port
rpr* port_rpr; /* port stored procedure reference */
rsr* port_statement; /* Statement for execute immediate */
rmtque* port_receive_rmtque; /* for client, responses waiting */
2001-05-23 15:26:42 +02:00
USHORT port_requests_queued; /* requests currently queued */
#ifdef VMS
USHORT port_iosb[4];
#endif
2006-05-02 03:32:41 +02:00
void* port_xcc; /* interprocess structure */
PacketQueue* port_deferred_packets; /* queue of deferred packets */
OBJCT port_last_object_id; /* cached last id */
2006-03-03 17:20:42 +01:00
#ifdef SUPERSERVER
Firebird::ObjectsArray< Firebird::Array< char > >* port_queue;
size_t port_qoffset; // current packet in the queue
2006-12-08 19:38:15 +01:00
#endif
#ifdef TRUSTED_AUTH
ServerAuth* port_trusted_auth;
2006-03-03 17:20:42 +01:00
#endif
2001-05-23 15:26:42 +02:00
UCHAR port_buffer[1];
/* TMN: Beginning of C++ port */
/* TMN: ugly, but at least a start */
int accept(p_cnct* cnct);
void disconnect();
rem_port* receive(PACKET* pckt);
2001-05-23 15:26:42 +02:00
XDR_INT send(PACKET* pckt);
XDR_INT send_partial(PACKET* pckt);
rem_port* connect(PACKET* pckt, t_event_ast);
rem_port* request(PACKET* pckt);
2006-03-03 17:20:42 +01:00
rem_port* select_multi(UCHAR* buffer, SSHORT bufsize, SSHORT* length);
bool haveRecvData() const
{
return (port_receive.x_handy > 0
#ifdef SUPERSERVER
|| port_queue && (port_qoffset < port_queue->getCount())
#endif
);
}
void clearRecvQue()
{
#ifdef SUPERSERVER
if (port_queue)
port_queue->clear();
port_qoffset = 0;
#endif
port_receive.x_private = port_receive.x_base;
}
class RecvQueState
{
public:
int save_handy;
size_t save_private;
2007-04-03 10:18:11 +02:00
#ifdef SUPERSERVER
size_t save_qoffset;
2007-04-03 10:18:11 +02:00
#endif
RecvQueState(rem_port* port)
{
save_handy = port->port_receive.x_handy;
save_private = port->port_receive.x_private - port->port_receive.x_base;
#ifdef SUPERSERVER
save_qoffset = port->port_qoffset;
#endif
}
};
RecvQueState getRecvState()
{
return RecvQueState(this);
}
2007-04-03 10:18:11 +02:00
void setRecvState(const RecvQueState& rs)
{
#ifdef SUPERSERVER
if (rs.save_qoffset > 0 && (rs.save_qoffset != port_qoffset))
{
2007-04-03 10:18:11 +02:00
Firebird::Array<char>& q = (*port_queue)[rs.save_qoffset - 1];
memcpy(port_receive.x_base, q.begin(), q.getCount());
}
port_qoffset = rs.save_qoffset;
#endif
port_receive.x_private = port_receive.x_base + rs.save_private;
port_receive.x_handy = rs.save_handy;
}
2001-05-23 15:26:42 +02:00
/* TMN: The following member functions are conceptually private
* to server.cpp and should be _made_ private in due time!
* That is, if we don't factor these method out.
*/
2003-04-10 12:31:28 +02:00
ISC_STATUS compile(P_CMPL*, PACKET*);
ISC_STATUS ddl(P_DDL*, PACKET*);
2001-05-23 15:26:42 +02:00
void disconnect(PACKET*, PACKET*);
void drop_database(P_RLSE*, PACKET*);
2003-04-10 12:31:28 +02:00
ISC_STATUS end_blob(P_OP, P_RLSE*, PACKET*);
ISC_STATUS end_database(P_RLSE*, PACKET*);
ISC_STATUS end_request(P_RLSE*, PACKET*);
ISC_STATUS end_statement(P_SQLFREE*, PACKET*);
ISC_STATUS end_transaction(P_OP, P_RLSE*, PACKET*);
ISC_STATUS execute_immediate(P_OP, P_SQLST*, PACKET*);
ISC_STATUS execute_statement(P_OP, P_SQLDATA*, PACKET*);
ISC_STATUS fetch(P_SQLDATA*, PACKET*);
ISC_STATUS fetch_blob(P_SQLDATA*, PACKET*);
2001-05-23 15:26:42 +02:00
OBJCT get_id(BLK);
2003-04-10 12:31:28 +02:00
ISC_STATUS get_segment(P_SGMT*, PACKET*);
ISC_STATUS get_slice(P_SLC*, PACKET*);
ISC_STATUS info(P_OP, P_INFO*, PACKET*);
ISC_STATUS insert(P_SQLDATA*, PACKET*);
ISC_STATUS open_blob(P_OP, P_BLOB*, PACKET*);
ISC_STATUS prepare(P_PREP*, PACKET*);
ISC_STATUS prepare_statement(P_SQLST*, PACKET*);
ISC_STATUS put_segment(P_OP, P_SGMT*, PACKET*);
ISC_STATUS put_slice(P_SLC*, PACKET*);
ISC_STATUS que_events(P_EVENT*, PACKET*);
ISC_STATUS receive_after_start(P_DATA*, PACKET*, ISC_STATUS*);
ISC_STATUS receive_msg(P_DATA*, PACKET*);
ISC_STATUS seek_blob(P_SEEK*, PACKET*);
ISC_STATUS send_msg(P_DATA*, PACKET*);
ISC_STATUS send_response(PACKET*, OBJCT, USHORT, const ISC_STATUS*, bool);
2006-12-08 19:38:15 +01:00
ISC_STATUS service_attach(const char*, const USHORT, Firebird::ClumpletWriter&, PACKET*);
2003-04-10 12:31:28 +02:00
ISC_STATUS service_end(P_RLSE*, PACKET*);
ISC_STATUS service_start(P_INFO*, PACKET*);
ISC_STATUS set_cursor(P_SQLCUR*, PACKET*);
ISC_STATUS start(P_OP, P_DATA*, PACKET*);
ISC_STATUS start_and_send(P_OP, P_DATA*, PACKET*);
ISC_STATUS start_transaction(P_OP, P_STTR*, PACKET*);
ISC_STATUS transact_request(P_TRRQ *, PACKET*);
};
2001-05-23 15:26:42 +02:00
2004-05-17 12:22:34 +02:00
// port_flags
const USHORT PORT_symmetric = 1; /* Server/client archiectures are symmetic */
const USHORT PORT_rpc = 2; /* Protocol is remote procedure call */
const USHORT PORT_pend_ack = 4; /* An ACK is pending on the port */
const USHORT PORT_broken = 8; /* Connect is broken */
const USHORT PORT_async = 16; /* Port is asynchronous channel for events */
const USHORT PORT_no_oob = 32; /* Don't send out of band data */
const USHORT PORT_disconnect = 64; /* Disconnect is in progress */
//const USHORT PORT_pend_rec = 128; // A record is pending on the port
// This is set only in inet.cpp but never tested.
2004-05-17 12:22:34 +02:00
const USHORT PORT_not_trusted = 256; /* Connection is from an untrusted node */
// This is tested only in wnet.cpp but never set.
//const USHORT PORT_impersonate = 512; // A remote user is being impersonated
2004-05-17 12:22:34 +02:00
const USHORT PORT_dummy_pckt_set= 1024; /* A dummy packet interval is set */
const USHORT PORT_partial_data = 2048; /* Physical packet doesn't contain all API packet */
const USHORT PORT_lazy = 4096; /* Deferred operations are allowed */
2007-04-03 10:18:11 +02:00
const USHORT PORT_busy = 8192; // disable receive - port is busy now
2001-05-23 15:26:42 +02:00
/* Misc declarations */
#include "../remote/allr_proto.h"
#include "../jrd/thd.h"
/* Thread specific remote database block */
class trdb : public ThreadData
2001-05-23 15:26:42 +02:00
{
public:
trdb(ISC_STATUS* status)
: ThreadData(ThreadData::tddRDB), trdb_status_vector(status)
{
trdb_database = 0;
}
rdb* trdb_database;
2003-04-10 12:31:28 +02:00
ISC_STATUS* trdb_status_vector;
};
typedef trdb* TRDB;
2001-05-23 15:26:42 +02:00
inline trdb* REM_get_thread_data() {
return (trdb*) ThreadData::getSpecific();
}
inline void REM_set_thread_data(trdb* &tdrdb, trdb* thd_context) {
tdrdb = thd_context;
tdrdb->putSpecific();
}
inline void REM_restore_thread_data() {
ThreadData::restoreSpecific();
}
2001-05-23 15:26:42 +02:00
/* Queuing structure for Client batch fetches */
typedef bool (*t_rmtque_fn)(trdb*, rem_port*, rmtque*, ISC_STATUS*, USHORT);
2004-06-09 20:23:27 +02:00
typedef struct rmtque
2001-05-23 15:26:42 +02:00
{
blk rmtque_header; // Memory allocator header
rmtque* rmtque_next; // Next entry in queue
void* rmtque_parm; // What request has response in queue
rrq::rrq_repeat* rmtque_message; // What message is pending
rdb* rmtque_rdb; // What database has pending msg
2001-05-23 15:26:42 +02:00
/* Fn that receives queued entry */
t_rmtque_fn rmtque_function;
2004-06-09 20:23:27 +02:00
} *RMTQUE;
2001-05-23 15:26:42 +02:00
#endif // REMOTE_REMOTE_H
2001-05-23 15:26:42 +02:00