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-31 06:06:02 +01:00
|
|
|
* 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
|
|
|
|
|
2002-11-18 17:20:21 +01:00
|
|
|
#include "../jrd/common.h"
|
|
|
|
#include "../remote/remote_def.h"
|
2004-06-08 15:41:08 +02:00
|
|
|
#include "../jrd/thd.h"
|
2006-03-03 17:20:42 +01:00
|
|
|
#include "../common/classes/objects_array.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* Include some apollo include files for tasking */
|
|
|
|
|
|
|
|
#if !(defined VMS || defined WIN_NT)
|
2002-11-02 18:23:37 +01:00
|
|
|
#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 */
|
|
|
|
|
|
|
|
|
2003-09-16 22:59:45 +02:00
|
|
|
// 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 */
|
|
|
|
|
2004-03-18 06:56:06 +01:00
|
|
|
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
|
|
|
|
|
2004-01-28 08:50:41 +01:00
|
|
|
// 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
|
|
|
{
|
2004-03-18 06:56:06 +01: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 */
|
2004-01-28 08:50:41 +01:00
|
|
|
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
|
|
|
{
|
2004-03-18 06:56:06 +01:00
|
|
|
blk rtr_header;
|
2004-02-24 06:34:44 +01:00
|
|
|
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
|
|
|
{
|
2004-03-18 06:56:06 +01:00
|
|
|
blk rbl_header;
|
2004-02-24 06:34:44 +01:00
|
|
|
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
|
|
|
{
|
2004-03-18 06:56:06 +01:00
|
|
|
blk rvnt_header;
|
2004-02-24 06:34:44 +01:00
|
|
|
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 */
|
2004-01-28 08:50:41 +01:00
|
|
|
rem_port* rvnt_port; /* used to id server from whence async came */
|
2003-11-28 07:48:34 +01:00
|
|
|
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
|
|
|
|
2004-02-20 07:43:27 +01:00
|
|
|
struct rem_vec
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
2004-03-18 06:56:06 +01:00
|
|
|
blk vec_header;
|
2001-05-23 15:26:42 +02:00
|
|
|
ULONG vec_count;
|
2004-03-18 06:56:06 +01:00
|
|
|
blk* vec_object[1];
|
2004-02-20 07:43:27 +01:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-02-20 07:43:27 +01:00
|
|
|
//struct rem_vcl
|
|
|
|
//{
|
2004-03-18 06:56:06 +01:00
|
|
|
// blk vcl_header;
|
2004-02-20 07:43:27 +01:00
|
|
|
// ULONG vcl_count;
|
|
|
|
// SLONG vcl_long[1];
|
|
|
|
//};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* Random string block -- jack of all kludges */
|
|
|
|
|
2004-01-03 11:59:52 +01:00
|
|
|
struct rem_str
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
2004-03-18 06:56:06 +01:00
|
|
|
blk str_header;
|
2001-05-23 15:26:42 +02:00
|
|
|
USHORT str_length;
|
|
|
|
SCHAR str_data[2];
|
2004-01-03 11:59:52 +01:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* Include definition of descriptor */
|
|
|
|
|
|
|
|
#include "../jrd/dsc.h"
|
|
|
|
|
|
|
|
|
2004-01-28 08:50:41 +01:00
|
|
|
struct rem_fmt
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
2004-03-18 06:56:06 +01: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;
|
2006-02-23 06:08:26 +01:00
|
|
|
USHORT fmt_flags; // unused
|
2001-05-23 15:26:42 +02:00
|
|
|
struct dsc fmt_desc[1];
|
2004-01-28 08:50:41 +01:00
|
|
|
};
|
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
|
|
|
{
|
2004-03-18 06:56:06 +01:00
|
|
|
blk msg_header;
|
2004-02-24 06:34:44 +01:00
|
|
|
message* msg_next; /* Next available message */
|
2001-05-23 15:26:42 +02:00
|
|
|
#ifdef SCROLLABLE_CURSORS
|
2004-02-24 06:34:44 +01:00
|
|
|
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 */
|
2004-02-24 06:34:44 +01:00
|
|
|
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
|
|
|
{
|
2004-03-18 06:56:06 +01:00
|
|
|
blk rpr_header;
|
2004-02-24 06:34:44 +01:00
|
|
|
rdb* rpr_rdb;
|
|
|
|
rtr* rpr_rtr;
|
2004-05-03 01:06:37 +02:00
|
|
|
FB_API_HANDLE rpr_handle;
|
2004-02-24 06:34:44 +01:00
|
|
|
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 */
|
2006-02-23 06:08:26 +01:00
|
|
|
USHORT rpr_flags; // unused
|
2004-06-09 20:23:27 +02:00
|
|
|
} *RPR;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-05-21 08:16:17 +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
|
|
|
|
2004-01-28 08:50:41 +01:00
|
|
|
struct rrq
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
2004-03-18 06:56:06 +01:00
|
|
|
blk rrq_header;
|
2004-02-24 06:34:44 +01:00
|
|
|
rdb* rrq_rdb;
|
|
|
|
rtr* rrq_rtr;
|
2004-01-28 08:50:41 +01:00
|
|
|
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
|
|
|
|
{
|
2004-02-24 06:34:44 +01:00
|
|
|
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
|
2004-02-24 06:34:44 +01:00
|
|
|
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
|
2004-02-24 06:34:44 +01:00
|
|
|
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];
|
2004-01-28 08:50:41 +01:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-05-17 12:22:34 +02:00
|
|
|
// rrq_flags
|
2006-02-23 06:08:26 +01:00
|
|
|
#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 */
|
2006-02-23 06:08:26 +01:00
|
|
|
#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
|
|
|
{
|
2004-03-18 06:56:06 +01:00
|
|
|
blk rsr_header;
|
2004-02-24 06:34:44 +01:00
|
|
|
rsr* rsr_next;
|
|
|
|
rdb* rsr_rdb;
|
|
|
|
rtr* rsr_rtr;
|
2004-05-03 01:06:37 +02:00
|
|
|
FB_API_HANDLE rsr_handle;
|
2004-02-24 06:34:44 +01:00
|
|
|
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 */
|
2003-04-16 12:18:51 +02:00
|
|
|
ISC_STATUS_ARRAY rsr_status_vector; /* 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 */
|
2006-05-02 00:23:31 +02:00
|
|
|
const USHORT RSR_lazy = 32; /* To be allocated at the first reference */
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-11-18 17:20:21 +01:00
|
|
|
#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;
|
2004-02-24 06:34:44 +01:00
|
|
|
struct rmtque;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2006-05-02 02:04:12 +02:00
|
|
|
/* Queue of deferred packets */
|
2006-05-02 00:23:31 +02:00
|
|
|
|
|
|
|
struct rem_que_packet
|
|
|
|
{
|
|
|
|
PACKET packet;
|
|
|
|
bool sent;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef Firebird::Array<rem_que_packet> PacketQueue;
|
|
|
|
|
|
|
|
/* Port itself */
|
|
|
|
|
2001-05-23 15:26:42 +02:00
|
|
|
class port_interface
|
|
|
|
{
|
|
|
|
public:
|
2004-01-28 08:50:41 +01:00
|
|
|
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*);
|
2004-02-24 06:34:44 +01:00
|
|
|
typedef rem_port* (*t_port_connect)(rem_port*, PACKET*, t_event_ast);
|
|
|
|
|
2004-01-28 08:50:41 +01:00
|
|
|
struct rem_port
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
2004-03-18 06:56:06 +01: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 */
|
2004-01-28 08:50:41 +01:00
|
|
|
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) */
|
2004-02-24 06:34:44 +01:00
|
|
|
int (*port_accept)(rem_port*, p_cnct*);
|
2004-01-28 08:50:41 +01:00
|
|
|
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 */
|
2004-01-28 08:50:41 +01:00
|
|
|
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
|
|
|
|
|
2004-02-24 06:34:44 +01:00
|
|
|
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
|
2004-02-20 07:43:27 +01:00
|
|
|
rem_vec* port_packet_vector; /* Vector of send/receive packets */
|
2001-05-23 15:26:42 +02:00
|
|
|
#endif
|
2004-02-20 07:43:27 +01:00
|
|
|
rem_vec* port_object_vector;
|
2001-05-23 15:26:42 +02:00
|
|
|
BLK* port_objects;
|
2004-02-20 07:43:27 +01:00
|
|
|
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;
|
2004-11-26 02:01:27 +01:00
|
|
|
rem_str* port_protocol_str; // String containing protocol name for this port
|
|
|
|
rem_str* port_address_str; // Protocol-specific address string for the port
|
2004-02-24 06:34:44 +01:00
|
|
|
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
|
|
|
|
void* port_xcc; /* interprocess structure */
|
2006-05-02 02:04:12 +02:00
|
|
|
PacketQueue* port_deferred_packets; /* queue of deferred packets */
|
2006-05-02 00:23:31 +02:00
|
|
|
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
|
|
|
|
#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();
|
2004-01-28 08:50:41 +01:00
|
|
|
rem_port* receive(PACKET* pckt);
|
2001-05-23 15:26:42 +02:00
|
|
|
XDR_INT send(PACKET* pckt);
|
|
|
|
XDR_INT send_partial(PACKET* pckt);
|
2004-02-24 06:34:44 +01:00
|
|
|
rem_port* connect(PACKET* pckt, t_event_ast);
|
2004-01-28 08:50:41 +01:00
|
|
|
rem_port* request(PACKET* pckt);
|
2006-03-03 17:20:42 +01:00
|
|
|
rem_port* select_multi(UCHAR* buffer, SSHORT bufsize, SSHORT* length);
|
|
|
|
|
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*);
|
2006-05-02 00:23:31 +02:00
|
|
|
ISC_STATUS send_response(PACKET*, OBJCT, USHORT, const ISC_STATUS*, bool);
|
2003-04-10 12:31:28 +02:00
|
|
|
ISC_STATUS service_attach(P_ATCH*, PACKET*);
|
|
|
|
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-01-28 08:50:41 +01:00
|
|
|
};
|
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 */
|
2006-02-23 06:08:26 +01:00
|
|
|
//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 */
|
2006-02-23 06:08:26 +01:00
|
|
|
// 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 */
|
2006-05-02 00:23:31 +02:00
|
|
|
const USHORT PORT_partial_data = 2048; /* Physical packet doesn't contain all API packet */
|
2006-05-02 02:04:12 +02:00
|
|
|
const USHORT PORT_lazy = 4096; /* Deferred operations are allowed */
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Misc declarations */
|
|
|
|
|
|
|
|
#include "../remote/allr_proto.h"
|
|
|
|
#include "../jrd/thd.h"
|
|
|
|
|
|
|
|
/* Thread specific remote database block */
|
|
|
|
|
2004-08-30 20:11:08 +02:00
|
|
|
class trdb : public ThreadData
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
2004-06-08 15:41:08 +02:00
|
|
|
public:
|
2004-08-30 20:11:08 +02:00
|
|
|
trdb(ISC_STATUS* status)
|
|
|
|
: ThreadData(ThreadData::tddRDB), trdb_status_vector(status)
|
|
|
|
{
|
|
|
|
trdb_database = 0;
|
|
|
|
}
|
2004-02-24 06:34:44 +01:00
|
|
|
rdb* trdb_database;
|
2003-04-10 12:31:28 +02:00
|
|
|
ISC_STATUS* trdb_status_vector;
|
2004-06-08 15:41:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef trdb* TRDB;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
2004-05-21 17:22:19 +02:00
|
|
|
inline trdb* REM_get_thread_data() {
|
2004-08-30 20:11:08 +02:00
|
|
|
return (trdb*) ThreadData::getSpecific();
|
2004-05-21 17:22:19 +02:00
|
|
|
}
|
|
|
|
inline void REM_set_thread_data(trdb* &tdrdb, trdb* thd_context) {
|
|
|
|
tdrdb = thd_context;
|
2004-06-08 15:41:08 +02:00
|
|
|
tdrdb->putSpecific();
|
2004-05-21 17:22:19 +02:00
|
|
|
}
|
|
|
|
inline void REM_restore_thread_data() {
|
2004-08-30 20:11:08 +02:00
|
|
|
ThreadData::restoreSpecific();
|
2004-05-21 17:22:19 +02:00
|
|
|
}
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* Queuing structure for Client batch fetches */
|
|
|
|
|
2004-02-24 06:34:44 +01:00
|
|
|
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
|
|
|
{
|
2004-03-18 06:56:06 +01:00
|
|
|
blk rmtque_header; // Memory allocator header
|
2004-02-24 06:34:44 +01:00
|
|
|
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 */
|
2004-02-24 06:34:44 +01:00
|
|
|
t_rmtque_fn rmtque_function;
|
2004-06-09 20:23:27 +02:00
|
|
|
} *RMTQUE;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-02-24 06:34:44 +01:00
|
|
|
#endif // REMOTE_REMOTE_H
|
2001-05-23 15:26:42 +02:00
|
|
|
|