diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5f336efd61..6bb9033ea0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -155,7 +155,6 @@ endif()
set(FB_PREFIX ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME})
set(FB_IPC_NAME "FirebirdIPI")
set(FB_LOGFILENAME "firebird.log")
-set(FB_PIPE_NAME "interbas")
set(FB_SERVICE_NAME "gds_db")
set(FB_SERVICE_PORT 3050)
diff --git a/builds/install/misc/firebird.conf b/builds/install/misc/firebird.conf
index 61a503f578..54711f45cf 100644
--- a/builds/install/misc/firebird.conf
+++ b/builds/install/misc/firebird.conf
@@ -41,9 +41,8 @@
#
# String
# ------
-# Strings are also what they sound like, strings. Examples:
+# Strings are also what they sound like, strings. Example:
# RemoteServiceName = gds_db
-# RemotePipeName = pipe47
#
# Scopes
# ------
@@ -1083,18 +1082,6 @@
#
#IpcName = FIREBIRD
-#
-# The name of the pipe used as a transport channel in NetBEUI protocol.
-# Has the same meaning as a port number for TCP/IP. The default value is
-# compatible with IB/FB1.
-#
-# Per-connection configurable.
-#
-# Type: string
-#
-#RemotePipeName = interbas
-
-
# ============================
# Settings for Unix/Linux platforms
# ============================
diff --git a/builds/mac_os_x/CS/CS.pbproj/project.pbxproj b/builds/mac_os_x/CS/CS.pbproj/project.pbxproj
index c75d4835fa..628a47746d 100644
--- a/builds/mac_os_x/CS/CS.pbproj/project.pbxproj
+++ b/builds/mac_os_x/CS/CS.pbproj/project.pbxproj
@@ -6767,16 +6767,6 @@
path = winvx.cpp;
refType = 4;
};
- F616C8C00200B0D001EF0ADE = {
- isa = PBXFileReference;
- path = wnet.cpp;
- refType = 4;
- };
- F616C8C10200B0D001EF0ADE = {
- isa = PBXFileReference;
- path = wnet_proto.h;
- refType = 4;
- };
F616C8C20200B0D001EF0ADE = {
isa = PBXFileReference;
path = xdr.cpp;
diff --git a/builds/win32/msvc15/remote.vcxproj b/builds/win32/msvc15/remote.vcxproj
index 41d0aa0e9e..691b114bdd 100644
--- a/builds/win32/msvc15/remote.vcxproj
+++ b/builds/win32/msvc15/remote.vcxproj
@@ -157,7 +157,6 @@
-
@@ -165,7 +164,6 @@
-
diff --git a/builds/win32/msvc15/remote.vcxproj.filters b/builds/win32/msvc15/remote.vcxproj.filters
index 391b076fc8..5ebb99e644 100644
--- a/builds/win32/msvc15/remote.vcxproj.filters
+++ b/builds/win32/msvc15/remote.vcxproj.filters
@@ -29,9 +29,6 @@
REMOTE files
-
- REMOTE files
-
AUTH files
@@ -64,9 +61,6 @@
Header files
-
- Header files
-
Header files
diff --git a/configure.ac b/configure.ac
index 0dcb0ca19a..e845e3cf89 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1222,15 +1222,6 @@ case "$PLATFORM" in
;;
win32)
- FB_PIPE_NAME=interbas
- AC_ARG_WITH(pipe-name,
- [ --with-pipe-name specify wnet pipe name (default=interbas)],
- [FB_PIPE_NAME=${withval}])
- AH_VERBATIM(FB_PIPE_NAME,
-[/* Wnet pipe name */
-#define FB_PIPE_NAME "interbas"])
- AC_DEFINE_UNQUOTED(FB_PIPE_NAME,"$FB_PIPE_NAME")
- AC_SUBST(FB_PIPE_NAME)
XE_PREPEND( -mthreads -lmpr -lversion -lws2_32 -lole32,LIBS)
;;
@@ -1503,10 +1494,6 @@ esac
echo " Service name : $FB_SERVICE_NAME"
echo " Service port : $FB_SERVICE_PORT"
-case "$PLATFORM" in
- win32) echo " Pipe name : $FB_PIPE_NAME";;
-esac
-
echo " GPRE modules : c_cxx.cpp$GPRE_LANGUAGE_MODULES"
echo
diff --git a/doc/Firebird_conf.txt b/doc/Firebird_conf.txt
index 99a485e21f..06871c017c 100644
--- a/doc/Firebird_conf.txt
+++ b/doc/Firebird_conf.txt
@@ -94,9 +94,8 @@ you only use 0/1
String
------
-Strings are also what they sound like, strings. Examples:
+Strings are also what they sound like, strings. Example:
RootDirectory = /opt/firebird
-RemotePipeName = "pipe47"
Configuration options
@@ -144,8 +143,7 @@ DeadThreadsCollection integer default 50
PriorityBoost integer default 5
RemoteServiceName string default gds_db
RemoteServicePort integer default 3050 (TCP port number)
-RemotePipeName string default "interbas" (Windows only?)
-IpcName string default "FirebirdIPI" (Windows only)
+IpcName string default "FIREBIRD" (Windows only)
MaxUnflushedWrites integer
# of writes before file writes are forcibly synched.
diff --git a/doc/README.connection_strings b/doc/README.connection_strings
index a43908808d..39fe8b538a 100644
--- a/doc/README.connection_strings
+++ b/doc/README.connection_strings
@@ -10,10 +10,6 @@ For TCP (aka INET) protocol:
[ / ] :
-For named pipes (aka NetBEUI, aka WNET) protocol:
-
- \\ [ @ ] \
-
For local connections as simple as:
@@ -55,11 +51,6 @@ Examples:
myserver/fb_db:mydb
localhost/fb_db:mydb
- Connect via named pipes:
-
- \\myserver\C:\db\mydb.fdb
- \\myserver@fb_db\C:\db\mydb.fdb
-
Local connection:
/db/mydb.fdb
@@ -71,8 +62,7 @@ connection strings:
[ : // [ [ : ] ] ] /
-Where protocol is one of: INET (means TCP), WNET (means named pipes) or XNET
-(means shared memory).
+Where protocol is one of: INET (means TCP) or XNET (means shared memory).
Examples:
@@ -114,22 +104,12 @@ Examples:
inet4://myserver/mydb
inet6://myserver/mydb
- Connect via named pipes:
-
- wnet://myserver/C:\db\mydb.fdb
- wnet://myserver:fb_db/C:\db\mydb.fdb
-
Loopback connection via TCP:
inet:///db/mydb.fdb
inet://C:\db\mydb.fdb
inet://mydb
- Loopback connection via named pipes:
-
- wnet://C:\db\mydb.fdb
- wnet://mydb
-
Local connection via shared memory:
xnet://C:\db\mydb.fdb
@@ -155,9 +135,7 @@ to connect locally using a specific transport protocol, please specify:
inet://
or
- wnet://
- or
xnet://
-Note: WNET (named pipes) and XNET (shared memory) protocols are available on Windows only.
+Note: XNET (shared memory) protocol is available on Windows only.
diff --git a/doc/sql.extensions/README.context_variables2 b/doc/sql.extensions/README.context_variables2
index 5ef0fff719..88dff5daf1 100644
--- a/doc/sql.extensions/README.context_variables2
+++ b/doc/sql.extensions/README.context_variables2
@@ -48,7 +48,7 @@ Usage:
Variable name Value
------------------------------------------------------------------------------
NETWORK_PROTOCOL | The network protocol used by client to connect. Currently
- | used values: "TCPv4", "TCPv6", "WNET", "XNET" and NULL.
+ | used values: "TCPv4", "TCPv6", "XNET" and NULL.
|
WIRE_COMPRESSED | Compression status of current connection.
| If connection is compressed - returns "TRUE", if it is
diff --git a/src/alice/alice.h b/src/alice/alice.h
index 0648f297ac..b6b87033a2 100644
--- a/src/alice/alice.h
+++ b/src/alice/alice.h
@@ -98,30 +98,21 @@ struct user_action
-// String block: used to store a string of constant length.
-
-class alice_str : public pool_alloc_rpt
-{
-public:
- USHORT str_length;
- UCHAR str_data[2];
-};
-
// Transaction block: used to store info about a multi-database transaction.
// Transaction Description Record
struct tdr : public pool_alloc
{
- tdr* tdr_next; // next sub-transaction
- TraNumber tdr_id; // database-specific transaction id
- alice_str* tdr_fullpath; // full (possibly) remote pathname
- const TEXT* tdr_filename; // filename within full pathname
- alice_str* tdr_host_site; // host for transaction
- alice_str* tdr_remote_site; // site for remote transaction
- FB_API_HANDLE tdr_handle; // reconnected transaction handle
- FB_API_HANDLE tdr_db_handle; // re-attached database handle
- USHORT tdr_db_caps; // capabilities of database
- USHORT tdr_state; // see flags below
+ tdr* tdr_next; // next sub-transaction
+ TraNumber tdr_id; // database-specific transaction id
+ Firebird::string tdr_fullpath; // full (possibly) remote pathname
+ Firebird::string tdr_filename; // filename
+ Firebird::string tdr_host_site; // host for transaction
+ Firebird::string tdr_remote_site; // site for remote transaction
+ FB_API_HANDLE tdr_handle; // reconnected transaction handle
+ FB_API_HANDLE tdr_db_handle; // re-attached database handle
+ USHORT tdr_db_caps; // capabilities of database
+ USHORT tdr_state; // see flags below
};
// CVC: This information should match Transaction Description Record constants in acl.h
diff --git a/src/alice/alice_meta.epp b/src/alice/alice_meta.epp
index fc99727e19..651602fcc6 100644
--- a/src/alice/alice_meta.epp
+++ b/src/alice/alice_meta.epp
@@ -39,6 +39,7 @@
#include "../common/classes/UserBlob.h"
#include "../alice/alice_proto.h"
#include "../common/utils_proto.h"
+#include "../common/isc_f_proto.h"
#include
@@ -54,7 +55,7 @@ DATABASE DB = STATIC FILENAME "yachts.lnk";
typedef Firebird::HalfStaticArray TextBuffer;
-static alice_str* alloc_string(const TEXT**);
+static void get_string(const TEXT**, Firebird::string&);
static USHORT get_capabilities(ISC_STATUS*);
static tdr* get_description(ISC_QUAD*);
static void parse_fullpath(tdr*);
@@ -242,19 +243,15 @@ void MET_set_capabilities(ISC_STATUS* user_status, tdr* trans)
* Eat a string with a byte-encoded length.
*/
-static alice_str* alloc_string(const TEXT** ptr)
+static void get_string(const TEXT** ptr, Firebird::string& str)
{
AliceGlobals* tdgbl = AliceGlobals::getSpecific();
const TEXT* p = *ptr;
-
const USHORT length = (USHORT) *p++;
- alice_str* string = FB_NEW_RPT(*tdgbl->getDefaultPool(), length + 1) alice_str;
- memcpy(string->str_data, p, length);
- string->str_data[length] = 0;
*ptr = p + length;
- return string;
+ str.assign(p, length);
}
@@ -319,8 +316,8 @@ static tdr* get_description(ISC_QUAD* blob_id)
return NULL;
tdr* trans = NULL;
- alice_str* host_site = NULL;
- alice_str* database_path = NULL;
+ Firebird::string host_site;
+ Firebird::string database_path;
const TEXT* p = buffer.begin();
@@ -336,11 +333,11 @@ static tdr* get_description(ISC_QUAD* blob_id)
switch (*p++)
{
case TDR_HOST_SITE:
- host_site = alloc_string(&p);
+ get_string(&p, host_site);
break;
case TDR_DATABASE_PATH:
- database_path = alloc_string(&p);
+ get_string(&p, database_path);
break;
case TDR_TRANSACTION_ID:
@@ -359,7 +356,7 @@ static tdr* get_description(ISC_QUAD* blob_id)
ptr->tdr_fullpath = database_path;
parse_fullpath(ptr);
ptr->tdr_id = id;
- database_path = NULL;
+ database_path.clear();
break;
default:
@@ -382,73 +379,17 @@ static tdr* get_description(ISC_QUAD* blob_id)
static void parse_fullpath(tdr* trans)
{
- AliceGlobals* tdgbl = AliceGlobals::getSpecific();
+ Firebird::PathName filename = trans->tdr_fullpath.c_str();
+ Firebird::PathName hostname;
- // start at the end of the full pathname
+ // Find the last remote node in the path
- const TEXT* p = (TEXT*) trans->tdr_fullpath->str_data;
- const TEXT* const start = p;
- while (*p)
- p++;
- const TEXT* const end = p;
+ while (ISC_analyze_tcp(filename, hostname))
+ trans->tdr_remote_site = hostname.c_str();
- // Check for a named pipes name - \\node\path\db or //node/path/db
- while (p > start && !(*p == '/' && p[-1] == '/') && !(*p == '\\' && p[-1] == '\\'))
- {
- --p;
- }
+ // At this point the filename is clear from any remote nodes
- if (p > start)
- {
- // Increment p past slash, & search forward for end of node name
- p = p + 1;
- const TEXT* q = p;
-
- while (*q && *q != '/' && *q != '\\')
- q++;
- if (*q)
- {
- trans->tdr_filename = q + 1;
-
- trans->tdr_remote_site = FB_NEW_RPT(*tdgbl->getDefaultPool(), q - p + 1) alice_str;
- fb_utils::copy_terminate((char*) trans->tdr_remote_site->str_data, (char*) p, q - p + 1);
- }
- }
- else
- {
- p = end;
-
- // If not named pipes, check the other protocols
- // work backwards until we find a remote protocol specifier
-
-
- while (p >= start && (*p != '^' && *p != ':' && *p != '@'))
- p--;
- // dimitr: make sure that the remote path is parsed correctly
- // for win32 servers, i.e. the drive separator is taken into account
- if ((p - 2 >= start) && p[-2] == ':' && (p[0] == ':'))
- p -= 2;
- trans->tdr_filename = p + 1;
-
- // now find the last remote node in the chain
-
- while (p > start && (*p == ':' || *p == '^' || *p == '@'))
- p--;
-
- USHORT length = 0;
- for (; p >= start && (*p != '^' && *p != ':' && *p != '@'); ++length)
- --p;
- ++p;
-
- if (length)
- {
- trans->tdr_remote_site = FB_NEW_RPT(*tdgbl->getDefaultPool(), length + 1) alice_str;
- TEXT* q = (TEXT *) trans->tdr_remote_site->str_data;
- while (length--)
- *q++ = *p++;
- *q = 0;
- }
- }
+ trans->tdr_filename = filename.c_str();
}
diff --git a/src/alice/tdr.cpp b/src/alice/tdr.cpp
index 29762496d6..f7b1e89b0b 100644
--- a/src/alice/tdr.cpp
+++ b/src/alice/tdr.cpp
@@ -472,7 +472,7 @@ bool TDR_reconnect_multiple(FB_API_HANDLE handle, TraNumber id, const TEXT* name
{
if (ptr->tdr_state == TRA_limbo)
{
- reconnect(ptr->tdr_db_handle, ptr->tdr_id, ptr->tdr_filename, switches);
+ reconnect(ptr->tdr_db_handle, ptr->tdr_id, ptr->tdr_filename.c_str(), switches);
}
}
}
@@ -504,28 +504,23 @@ static void print_description(const tdr* trans)
AliceGlobals* tdgbl = AliceGlobals::getSpecific();
if (!trans)
- {
return;
- }
if (!tdgbl->uSvc->isService())
- {
ALICE_print(92); // msg 92: Multidatabase transaction:
- }
bool prepared_seen = false;
for (const tdr* ptr = trans; ptr; ptr = ptr->tdr_next)
{
- if (ptr->tdr_host_site)
+ const auto host_site = ptr->tdr_host_site.nullStr();
+ if (host_site)
{
- const char* pszHostSize = reinterpret_cast(ptr->tdr_host_site->str_data);
-
if (!tdgbl->uSvc->isService())
{
// msg 93: Host Site: %s
- ALICE_print(93, SafeArg() << pszHostSize);
+ ALICE_print(93, SafeArg() << host_site);
}
- tdgbl->uSvc->putLine(isc_spb_tra_host_site, pszHostSize);
+ tdgbl->uSvc->putLine(isc_spb_tra_host_site, host_site);
}
if (ptr->tdr_id)
@@ -586,28 +581,26 @@ static void print_description(const tdr* trans)
break;
}
- if (ptr->tdr_remote_site)
+ const auto remote_site = ptr->tdr_remote_site.nullStr();
+ if (remote_site)
{
- const char* pszRemoteSite = reinterpret_cast(ptr->tdr_remote_site->str_data);
-
if (!tdgbl->uSvc->isService())
{
// msg 101: Remote Site: %s
- ALICE_print(101, SafeArg() << pszRemoteSite);
+ ALICE_print(101, SafeArg() << remote_site);
}
- tdgbl->uSvc->putLine(isc_spb_tra_remote_site, pszRemoteSite);
+ tdgbl->uSvc->putLine(isc_spb_tra_remote_site, remote_site);
}
- if (ptr->tdr_fullpath)
+ const auto fullpath = ptr->tdr_fullpath.nullStr();
+ if (fullpath)
{
- const char* pszFullpath = reinterpret_cast(ptr->tdr_fullpath->str_data);
-
if (!tdgbl->uSvc->isService())
{
// msg 102: Database Path: %s
- ALICE_print(102, SafeArg() << pszFullpath);
+ ALICE_print(102, SafeArg() << fullpath);
}
- tdgbl->uSvc->putLine(isc_spb_tra_db_path, pszFullpath);
+ tdgbl->uSvc->putLine(isc_spb_tra_db_path, fullpath);
}
}
@@ -649,10 +642,9 @@ static void print_description(const tdr* trans)
static SINT64 ask()
{
AliceGlobals* tdgbl = AliceGlobals::getSpecific();
+
if (tdgbl->uSvc->isService())
- {
return ~SINT64(0);
- }
char response[32];
SINT64 switches = 0;
@@ -694,79 +686,56 @@ static SINT64 ask()
static void reattach_database(tdr* trans)
{
ISC_STATUS_ARRAY status_vector;
- char buffer[1024];
+ char buffer[BUFFER_LARGE];
// sizeof(buffer) - 1 => leave space for the terminator.
const char* const end = buffer + sizeof(buffer) - 1;
AliceGlobals* tdgbl = AliceGlobals::getSpecific();
- ISC_get_host(buffer, sizeof(buffer));
-
- if (trans->tdr_fullpath)
+ if (trans->tdr_fullpath.hasData())
{
+ Firebird::string hostname;
+ ISC_get_host(hostname);
+
// if this is being run from the same host,
// try to reconnect using the same pathname
- if (!strcmp(buffer, reinterpret_cast(trans->tdr_host_site->str_data)))
+ if (trans->tdr_host_site == hostname)
{
- if (TDR_attach_database(status_vector, trans,
- reinterpret_cast(trans->tdr_fullpath->str_data)))
- {
+ if (TDR_attach_database(status_vector, trans, trans->tdr_fullpath.c_str()))
return;
- }
}
- else if (trans->tdr_host_site)
+ else if (trans->tdr_host_site.hasData())
{
// try going through the previous host with all available
// protocols, using chaining to try the same method of
// attachment originally used from that host
- char* p = buffer;
- const UCHAR* q = trans->tdr_host_site->str_data;
- while (*q && p < end)
- *p++ = *q++;
- *p++ = ':';
- q = trans->tdr_fullpath->str_data;
- while (*q && p < end)
- *p++ = *q++;
- *p = 0;
- if (TDR_attach_database(status_vector, trans, buffer))
- {
+ const Firebird::string pathname = trans->tdr_host_site + ':' + trans->tdr_fullpath;
+ if (TDR_attach_database(status_vector, trans, pathname.c_str()))
return;
- }
}
// attaching using the old method didn't work;
// try attaching to the remote node directly
- if (trans->tdr_remote_site)
+ if (trans->tdr_remote_site.hasData())
{
- char* p = buffer;
- const UCHAR* q = trans->tdr_remote_site->str_data;
- while (*q && p < end)
- *p++ = *q++;
- *p++ = ':';
- q = reinterpret_cast(trans->tdr_filename);
- while (*q && p < end)
- *p++ = *q++;
- *p = 0;
- if (TDR_attach_database (status_vector, trans, buffer))
- {
+ const Firebird::string pathname = trans->tdr_remote_site + ':' + trans->tdr_filename;
+ if (TDR_attach_database(status_vector, trans, pathname.c_str()))
return;
- }
}
}
+
// we have failed to reattach; notify the user
// and let them try to succeed where we have failed
ALICE_print(86, SafeArg() << trans->tdr_id);
// msg 86: Could not reattach to database for transaction %ld.
- ALICE_print(87, SafeArg() << (trans->tdr_fullpath ? (char*)(trans->tdr_fullpath->str_data) : "is unknown"));
+ ALICE_print(87, SafeArg() << (trans->tdr_fullpath.hasData() ? trans->tdr_fullpath.c_str() : "unknown"));
// msg 87: Original path: %s
if (tdgbl->uSvc->isService())
- {
ALICE_exit(FINI_ERROR, tdgbl);
- }
for (;;)
{
@@ -782,12 +751,8 @@ static void reattach_database(tdr* trans)
++p;
if (TDR_attach_database(status_vector, trans, p))
{
- const size_t p_len = strlen(p);
- alice_str* string = FB_NEW_RPT(*tdgbl->getDefaultPool(), p_len + 1) alice_str;
- strcpy(reinterpret_cast(string->str_data), p);
- string->str_length = static_cast(p_len);
- trans->tdr_fullpath = string;
- trans->tdr_filename = (TEXT *) string->str_data;
+ trans->tdr_fullpath.assign(p);
+ trans->tdr_filename = trans->tdr_fullpath;
return;
}
ALICE_print(89); // msg 89: Attach unsuccessful.
diff --git a/src/common/config/config.h b/src/common/config/config.h
index 2550cb9b55..d8bcdd7577 100644
--- a/src/common/config/config.h
+++ b/src/common/config/config.h
@@ -137,7 +137,6 @@ enum ConfigKey
KEY_DEADLOCK_TIMEOUT,
KEY_REMOTE_SERVICE_NAME,
KEY_REMOTE_SERVICE_PORT,
- KEY_REMOTE_PIPE_NAME,
KEY_IPC_NAME,
KEY_MAX_UNFLUSHED_WRITES,
KEY_MAX_UNFLUSHED_WRITE_TIME,
@@ -232,7 +231,6 @@ constexpr ConfigEntry entries[MAX_CONFIG_KEY] =
{TYPE_INTEGER, "DeadlockTimeout", false, 10}, // seconds
{TYPE_STRING, "RemoteServiceName", false, FB_SERVICE_NAME},
{TYPE_INTEGER, "RemoteServicePort", false, 0},
- {TYPE_STRING, "RemotePipeName", false, FB_PIPE_NAME},
{TYPE_STRING, "IpcName", false, FB_IPC_NAME},
#ifdef WIN_NT
{TYPE_INTEGER, "MaxUnflushedWrites", false, 100},
@@ -522,9 +520,6 @@ public:
// Service port for INET
CONFIG_GET_PER_DB_KEY(unsigned short, getRemoteServicePort, KEY_REMOTE_SERVICE_PORT, getInt);
- // Pipe name for WNET
- CONFIG_GET_PER_DB_STR(getRemotePipeName, KEY_REMOTE_PIPE_NAME);
-
// Name for IPC-related objects
CONFIG_GET_PER_DB_STR(getIpcName, KEY_IPC_NAME);
diff --git a/src/common/isc_f_proto.h b/src/common/isc_f_proto.h
index 021092be4d..718f8f8208 100644
--- a/src/common/isc_f_proto.h
+++ b/src/common/isc_f_proto.h
@@ -30,13 +30,15 @@
#include "../common/classes/fb_string.h"
#include "../common/common.h"
-enum iscProtocol {ISC_PROTOCOL_LOCAL, ISC_PROTOCOL_TCPIP, ISC_PROTOCOL_WLAN};
+enum iscProtocol {ISC_PROTOCOL_LOCAL, ISC_PROTOCOL_TCPIP};
#ifndef NO_NFS
bool ISC_analyze_nfs(Firebird::PathName&, Firebird::PathName&);
#endif
-bool ISC_analyze_protocol(const char*, Firebird::PathName&, Firebird::PathName&, const char*, bool needFile);
+#ifdef WIN_NT
bool ISC_analyze_pclan(Firebird::PathName&, Firebird::PathName&);
+#endif
+bool ISC_analyze_protocol(const char*, Firebird::PathName&, Firebird::PathName&, const char*, bool needFile);
bool ISC_analyze_tcp(Firebird::PathName&, Firebird::PathName&, bool = true);
bool ISC_check_if_remote(const Firebird::PathName&, bool);
iscProtocol ISC_extract_host(Firebird::PathName&, Firebird::PathName&, bool);
diff --git a/src/common/isc_file.cpp b/src/common/isc_file.cpp
index fae006bcc6..10222ac6b6 100644
--- a/src/common/isc_file.cpp
+++ b/src/common/isc_file.cpp
@@ -346,6 +346,47 @@ bool ISC_analyze_nfs(tstring& expanded_filename, tstring& node_name)
#endif
+#if defined(WIN_NT)
+bool ISC_analyze_pclan(tstring& expanded_name, tstring& node_name)
+{
+/**************************************
+ *
+ * I S C _ a n a l y z e _ p c l a n
+ *
+ **************************************
+ *
+ * Functional description
+ * Check a file name for a SMB mount point. If so,
+ * decompose into node name and remote file name.
+ *
+ **************************************/
+ ISC_expand_share(expanded_name);
+
+ if (expanded_name.length() < 2 ||
+ (expanded_name[0] != '\\' && expanded_name[0] != '/') ||
+ (expanded_name[1] != '\\' && expanded_name[1] != '/'))
+ {
+ return false;
+ }
+
+ const size p = expanded_name.find_first_of("\\/", 2);
+ if (p == npos)
+ return false;
+
+ if (Config::getRemoteFileOpenAbility())
+ {
+ if (expanded_name.find(':', p + 1) == npos)
+ return false;
+ }
+
+ node_name = expanded_name.substr(2, p - 2);
+ expanded_name.erase(0, p + 1);
+
+ return true;
+}
+#endif
+
+
bool ISC_analyze_protocol(const char* protocol, tstring& expanded_name, tstring& node_name,
const char* separator, bool need_file)
{
@@ -403,57 +444,6 @@ bool ISC_analyze_protocol(const char* protocol, tstring& expanded_name, tstring&
}
-#if defined(WIN_NT)
-bool ISC_analyze_pclan(tstring& expanded_name, tstring& node_name)
-{
-/**************************************
- *
- * I S C _ a n a l y z e _ p c l a n
- *
- **************************************
- *
- * Functional description
- * Analyze a filename for a named pipe node name on the front.
- * If one is found, extract the node name, compute the residual
- * file name, and return true. Otherwise return false.
- *
- **************************************/
- node_name.erase();
- if (expanded_name.length() < 2 ||
- (expanded_name[0] != '\\' && expanded_name[0] != '/') ||
- (expanded_name[1] != '\\' && expanded_name[1] != '/'))
- {
- return false;
- }
-
- const size p = expanded_name.find_first_of("\\/", 2);
- if (p == npos)
- return false;
-
- if (Config::getRemoteFileOpenAbility())
- {
- if (expanded_name.find(':', p + 1) == npos)
- return false;
- }
-
- node_name = "\\\\";
- node_name += expanded_name.substr(2, p - 2);
-
- // If this is a loopback, substitute "." for the host name. Otherwise,
- // the CreateFile on the pipe will fail.
- TEXT localhost[MAXHOSTLEN];
- ISC_get_host(localhost, sizeof(localhost));
- if (node_name.substr(2, npos) == localhost)
- {
- node_name.replace(2, npos, ".");
- }
-
- expanded_name.erase(0, p + 1);
- return true;
-}
-#endif // WIN_NT
-
-
bool ISC_analyze_tcp(tstring& file_name, tstring& node_name, bool need_file)
{
/**************************************
@@ -564,46 +554,22 @@ iscProtocol ISC_extract_host(Firebird::PathName& file_name,
// Always check for an explicit TCP node name
if (ISC_analyze_tcp(file_name, host_name))
- {
return ISC_PROTOCOL_TCPIP;
- }
-#ifndef NO_NFS
+
if (implicit_flag)
{
- // Check for a file on an NFS mounted device
+ // Check for a file on a network mount
- if (ISC_analyze_nfs(file_name, host_name))
- {
+#ifdef WIN_NT
+ if (ISC_analyze_pclan(file_name, host_name))
return ISC_PROTOCOL_TCPIP;
- }
- }
#endif
-#if defined(WIN_NT)
- // Check for an explicit named pipe node name
-
- if (ISC_analyze_pclan(file_name, host_name))
- {
- return ISC_PROTOCOL_WLAN;
- }
-
- if (implicit_flag)
- {
- // Check for a file on a shared drive. First try to expand
- // the path. Then check the expanded path for a TCP or named pipe.
-
- ISC_expand_share(file_name);
- if (ISC_analyze_tcp(file_name, host_name))
- {
+#ifndef NO_NFS
+ if (ISC_analyze_nfs(file_name, host_name))
return ISC_PROTOCOL_TCPIP;
- }
- if (ISC_analyze_pclan(file_name, host_name))
- {
- return ISC_PROTOCOL_WLAN;
- }
-
+#endif
}
-#endif // WIN_NT
return ISC_PROTOCOL_LOCAL;
}
diff --git a/src/include/cross/android.arm64 b/src/include/cross/android.arm64
index 4a4e30160f..825570e26b 100644
--- a/src/include/cross/android.arm64
+++ b/src/include/cross/android.arm64
@@ -61,9 +61,6 @@
/* message files DIR (PREFIX) */
#define FB_MSGDIR ""
-/* Wnet pipe name */
-#define FB_PIPE_NAME "interbas"
-
/* plugins DIR (PREFIX) */
#define FB_PLUGDIR ""
diff --git a/src/include/cross/android.arme b/src/include/cross/android.arme
index 70973d5cdf..5dcdba3a8b 100644
--- a/src/include/cross/android.arme
+++ b/src/include/cross/android.arme
@@ -67,9 +67,6 @@
/* message files DIR (PREFIX) */
#define FB_MSGDIR ""
-/* Wnet pipe name */
-#define FB_PIPE_NAME "interbas"
-
/* plugins DIR (PREFIX) */
#define FB_PLUGDIR ""
diff --git a/src/include/cross/android.x86 b/src/include/cross/android.x86
index 73bb83c51e..47503e2661 100644
--- a/src/include/cross/android.x86
+++ b/src/include/cross/android.x86
@@ -61,9 +61,6 @@
/* message files DIR (PREFIX) */
#define FB_MSGDIR ""
-/* Wnet pipe name */
-#define FB_PIPE_NAME "interbas"
-
/* plugins DIR (PREFIX) */
#define FB_PLUGDIR ""
diff --git a/src/include/cross/android.x86_64 b/src/include/cross/android.x86_64
index 2910dd421a..cc5d8844ed 100644
--- a/src/include/cross/android.x86_64
+++ b/src/include/cross/android.x86_64
@@ -61,9 +61,6 @@
/* message files DIR (PREFIX) */
#define FB_MSGDIR ""
-/* Wnet pipe name */
-#define FB_PIPE_NAME "interbas"
-
/* plugins DIR (PREFIX) */
#define FB_PLUGDIR ""
diff --git a/src/include/firebird/impl/consts_pub.h b/src/include/firebird/impl/consts_pub.h
index 2802d23c08..723ef16603 100644
--- a/src/include/firebird/impl/consts_pub.h
+++ b/src/include/firebird/impl/consts_pub.h
@@ -160,8 +160,7 @@
::=
"TCPv4" |
"TCPv6" |
- "XNET" |
- "WNET" |
+ "XNET"
....
::=
diff --git a/src/include/gen/autoconfig.h.in b/src/include/gen/autoconfig.h.in
index d3d6ac8161..de0489a3bd 100644
--- a/src/include/gen/autoconfig.h.in
+++ b/src/include/gen/autoconfig.h.in
@@ -94,9 +94,6 @@
/* log file name within log dir */
#define FB_LOGFILENAME "@FB_LOGFILENAME@"
-/* Wnet pipe name */
-#define FB_PIPE_NAME "@FB_PIPE_NAME@"
-
/* Installation path prefix */
#define FB_PREFIX "@FB_PREFIX@"
diff --git a/src/include/gen/autoconfig_msvc.h b/src/include/gen/autoconfig_msvc.h
index d7ba71254b..1e25478c64 100644
--- a/src/include/gen/autoconfig_msvc.h
+++ b/src/include/gen/autoconfig_msvc.h
@@ -285,9 +285,6 @@
#define FB_SERVICE_NAME "gds_db"
#define FB_SERVICE_PORT 3050
-/* Wnet pipe name */
-#define FB_PIPE_NAME "interbas"
-
/* Xnet objects name */
#define FB_IPC_NAME "FIREBIRD"
diff --git a/src/remote/CMakeLists.txt b/src/remote/CMakeLists.txt
index 49d6dac09b..8c2fdc6e1b 100644
--- a/src/remote/CMakeLists.txt
+++ b/src/remote/CMakeLists.txt
@@ -17,8 +17,6 @@ set(remote_src
../auth/trusted/AuthSspi.cpp
)
add_src_win32(remote_src
- os/win32/wnet.cpp
- os/win32/wnet_proto.h
os/win32/xnet.cpp
os/win32/xnet.h
os/win32/xnet_proto.h
diff --git a/src/remote/client/interface.cpp b/src/remote/client/interface.cpp
index 6567b98f9c..38091ad2c0 100644
--- a/src/remote/client/interface.cpp
+++ b/src/remote/client/interface.cpp
@@ -83,7 +83,6 @@
#if defined(WIN_NT)
#include "../common/isc_proto.h"
-#include "../remote/os/win32/wnet_proto.h"
#include "../remote/os/win32/xnet_proto.h"
#endif
@@ -97,15 +96,10 @@ const char* const PROTOCOL_INET4 = "inet4";
const char* const PROTOCOL_INET6 = "inet6";
#ifdef WIN_NT
-const char* const PROTOCOL_WNET = "wnet";
const char* const PROTOCOL_XNET = "xnet";
-
-const char* const WNET_SEPARATOR = "@";
-const char* const WNET_LOCALHOST = "\\\\.";
#endif
const char* const INET_SEPARATOR = "/";
-
const char* const INET_LOCALHOST = "localhost";
@@ -4726,13 +4720,11 @@ bool ResultSet::fetch(CheckStatusWrapper* status, void* buffer, P_FETCH operatio
( // Low in inventory
(statement->rsr_rows_pending <= statement->rsr_reorder_level) &&
(statement->rsr_msgs_waiting <= statement->rsr_reorder_level) &&
- // not using named pipe on NT
// Pipelining causes both server & client to
- // write at the same time. In named pipes, writes
+ // write at the same time. In XNET, writes
// block for the other end to read - and so when both
// attempt to write simultaneously, they end up
- // waiting indefinitely for the other end to read
- (port->port_type != rem_port::PIPE) &&
+ // waiting indefinitely for the other end to read.
(port->port_type != rem_port::XNET) &&
// We're fetching either forward or backward
(operation == fetch_next || operation == fetch_prior) &&
@@ -5871,12 +5863,11 @@ void Request::receive(CheckStatusWrapper* status, int level, unsigned int msg_ty
(tail->rrq_rows_pending <= tail->rrq_reorder_level && // Low in inventory
tail->rrq_msgs_waiting <= tail->rrq_reorder_level &&
// Pipelining causes both server & client to
- // write at the same time. In named pipes, writes
+ // write at the same time. In XNET, writes
// block for the other end to read - and so when both
// attempt to write simultaenously, they end up
- // waiting indefinetly for the other end to read
- (port->port_type != rem_port::PIPE) && // not named pipe on NT
- (port->port_type != rem_port::XNET) && // not shared memory on NT
+ // waiting indefinetly for the other end to read.
+ (port->port_type != rem_port::XNET) &&
request->rrq_max_msg <= 1)))
{
// there's only one message type
@@ -7295,20 +7286,6 @@ static rem_port* analyze(ClntAuthBlock& cBlock, PathName& attach_name, unsigned
#ifdef WIN_NT
if (ISC_analyze_protocol(PROTOCOL_XNET, attach_name, node_name, NULL, needFile))
port = XNET_analyze(&cBlock, attach_name, flags & ANALYZE_USER_VFY, cBlock.getConfig(), ref_db_name);
- else if (ISC_analyze_protocol(PROTOCOL_WNET, attach_name, node_name, WNET_SEPARATOR, needFile) ||
- ISC_analyze_pclan(attach_name, node_name))
- {
- if (node_name.isEmpty())
- node_name = WNET_LOCALHOST;
- else
- {
- ISC_unescape(node_name);
- ISC_utf8ToSystem(node_name);
- }
-
- port = WNET_analyze(&cBlock, attach_name, node_name.c_str(), flags & ANALYZE_USER_VFY,
- cBlock.getConfig(), ref_db_name);
- }
else
#endif
@@ -7341,15 +7318,13 @@ static rem_port* analyze(ClntAuthBlock& cBlock, PathName& attach_name, unsigned
if (!port)
{
PathName expanded_name = attach_name;
- ISC_expand_share(expanded_name);
-
if (ISC_analyze_pclan(expanded_name, node_name))
{
ISC_unescape(node_name);
ISC_utf8ToSystem(node_name);
- port = WNET_analyze(&cBlock, expanded_name, node_name.c_str(), flags & ANALYZE_USER_VFY,
- cBlock.getConfig(), ref_db_name);
+ port = INET_analyze(&cBlock, expanded_name, node_name.c_str(), flags & ANALYZE_USER_VFY, pb,
+ cBlock.getConfig(), ref_db_name, cryptCb);
}
}
#endif
@@ -7383,12 +7358,6 @@ static rem_port* analyze(ClntAuthBlock& cBlock, PathName& attach_name, unsigned
port = XNET_analyze(&cBlock, attach_name, flags & ANALYZE_USER_VFY,
cBlock.getConfig(), ref_db_name);
}
-
- if (!port)
- {
- port = WNET_analyze(&cBlock, attach_name, WNET_LOCALHOST, flags & ANALYZE_USER_VFY,
- cBlock.getConfig(), ref_db_name);
- }
#endif
if (!port)
{
@@ -7809,20 +7778,9 @@ static void disconnect( rem_port* port)
}
}
- // BAND-AID:
- // It seems as if we are disconnecting the port
- // on both the server and client side. For now
- // let the server handle this for named pipes
+ packet->p_operation = op_disconnect;
+ port->send(packet);
- // 8-Aug-1997 M. Duquette
- // R. Kumar
- // M. Romanini
-
- if (port->port_type != rem_port::PIPE)
- {
- packet->p_operation = op_disconnect;
- port->send(packet);
- }
REMOTE_free_packet(port, packet);
}
diff --git a/src/remote/inet.cpp b/src/remote/inet.cpp
index 92471b149c..103169eb1e 100644
--- a/src/remote/inet.cpp
+++ b/src/remote/inet.cpp
@@ -671,7 +671,7 @@ rem_port* INET_analyze(ClntAuthBlock* cBlock,
ISC_get_user(&buffer, &eff_uid, &eff_gid);
#ifdef WIN_NT
- // WNET and XNET lowercase user names (as it's always case-insensitive in Windows)
+ // XNET lowercases user names (as it's always case-insensitive in Windows),
// so let's be consistent and use the same trick for INET as well
buffer.lower();
#endif
diff --git a/src/remote/os/win32/wnet.cpp b/src/remote/os/win32/wnet.cpp
deleted file mode 100644
index 192f34322e..0000000000
--- a/src/remote/os/win32/wnet.cpp
+++ /dev/null
@@ -1,1476 +0,0 @@
-/*
- * PROGRAM: JRD Remote Interface/Server
- * MODULE: wnet.cpp
- * DESCRIPTION: Windows Net Communications module.
- *
- * 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): ______________________________________.
- */
-
-#ifdef DEBUG
-// define WNET_trace to 0 (zero) for no packet debugging
-#define WNET_trace
-#endif
-
-#include "firebird.h"
-#include
-#include
-#include "../remote/remote.h"
-#include "ibase.h"
-
-#include "../utilities/install/install_nt.h"
-
-#include "../remote/proto_proto.h"
-#include "../remote/remot_proto.h"
-#include "../remote/os/win32/wnet_proto.h"
-#include "../yvalve/gds_proto.h"
-#include "../common/isc_proto.h"
-#include "../common/isc_f_proto.h"
-#include "../common/config/config.h"
-#include "../common/utils_proto.h"
-#include "../common/classes/ClumpletWriter.h"
-#include "../common/classes/init.h"
-
-#include
-
-using namespace Firebird;
-
-const int MAX_DATA = 2048;
-const int BUFFER_SIZE = MAX_DATA;
-
-const char* PIPE_PREFIX = "pipe"; // win32-specific
-const char* SERVER_PIPE_SUFFIX = "server";
-const char* EVENT_PIPE_SUFFIX = "event";
-AtomicCounter event_counter;
-
-static GlobalPtr wnet_ports;
-static GlobalPtr init_mutex;
-static volatile bool wnet_initialized = false;
-static volatile bool wnet_shutdown = false;
-
-static bool accept_connection(rem_port*, const P_CNCT*);
-static rem_port* alloc_port(rem_port*);
-static rem_port* aux_connect(rem_port*, PACKET*);
-static rem_port* aux_request(rem_port*, PACKET*);
-static bool connect_client(rem_port*);
-static void disconnect(rem_port*);
-#ifdef NOT_USED_OR_REPLACED
-static void exit_handler(void*);
-#endif
-static void force_close(rem_port*);
-static rem_str* make_pipe_name(const RefPtr&, const TEXT*, const TEXT*, const TEXT*);
-static rem_port* receive(rem_port*, PACKET*);
-static int send_full(rem_port*, PACKET*);
-static int send_partial(rem_port*, PACKET*);
-static RemoteXdr* xdrwnet_create(rem_port*, UCHAR *, USHORT, xdr_op);
-static bool_t xdrwnet_endofrecord(RemoteXdr*);//, int);
-static bool wnet_error(rem_port*, const TEXT*, ISC_STATUS, int);
-static void wnet_gen_error(rem_port*, const Arg::StatusVector& v);
-static bool_t wnet_read(RemoteXdr*);
-static bool_t wnet_write(RemoteXdr*); //, int);
-#ifdef DEBUG
-static void packet_print(const TEXT*, const UCHAR*, const int);
-#endif
-static bool packet_receive(rem_port*, UCHAR*, SSHORT, SSHORT*);
-static bool packet_send(rem_port*, const SCHAR*, SSHORT);
-static void wnet_make_file_name(TEXT*, DWORD);
-
-static int cleanup_ports(const int, const int, void*);
-
-struct WnetXdr : public RemoteXdr
-{
- virtual bool_t x_getbytes(SCHAR *, unsigned); // get some bytes from "
- virtual bool_t x_putbytes(const SCHAR*, unsigned); // put some bytes to "
-};
-
-
-rem_port* WNET_analyze(ClntAuthBlock* cBlock,
- const PathName& file_name,
- const TEXT* node_name,
- bool uv_flag,
- RefPtr* config,
- const Firebird::PathName* ref_db_name)
-{
-/**************************************
- *
- * W N E T _ a n a l y z e
- *
- **************************************
- *
- * Functional description
- * Determine whether the file name has a "\\nodename".
- * If so, establish an external connection to the node.
- *
- * If a connection is established, return a port block, otherwise
- * return NULL.
- *
- **************************************/
-
- // We need to establish a connection to a remote server. Allocate the necessary
- // blocks and get ready to go.
-
- Rdb* rdb = FB_NEW Rdb;
- PACKET* packet = &rdb->rdb_packet;
-
- // Pick up some user identification information
- string buffer;
- ClumpletWriter user_id(ClumpletReader::UnTagged, 64000);
- if (cBlock)
- {
- cBlock->extractDataFromPluginTo(user_id);
- }
-
- ISC_get_user(&buffer, 0, 0);
- buffer.lower();
- ISC_systemToUtf8(buffer);
- user_id.insertString(CNCT_user, buffer);
-
- ISC_get_host(buffer);
- buffer.lower();
- ISC_systemToUtf8(buffer);
- user_id.insertString(CNCT_host, buffer);
-
- if (uv_flag) {
- user_id.insertTag(CNCT_user_verification);
- }
-
- // Establish connection to server
-
- P_CNCT* const cnct = &packet->p_cnct;
- packet->p_operation = op_connect;
- cnct->p_cnct_operation = 0;
- cnct->p_cnct_cversion = CONNECT_VERSION3;
- cnct->p_cnct_client = ARCHITECTURE;
-
- const PathName& cnct_file(ref_db_name ? (*ref_db_name) : file_name);
- cnct->p_cnct_file.cstr_length = (ULONG) cnct_file.length();
- cnct->p_cnct_file.cstr_address = reinterpret_cast(cnct_file.c_str());
-
- // If we want user verification, we can't speak anything less than version 7
-
- cnct->p_cnct_user_id.cstr_length = (ULONG) user_id.getBufferLength();
- cnct->p_cnct_user_id.cstr_address = user_id.getBuffer();
-
- static const p_cnct::p_cnct_repeat protocols_to_try[] =
- {
- REMOTE_PROTOCOL(PROTOCOL_VERSION10, ptype_batch_send, 1),
- REMOTE_PROTOCOL(PROTOCOL_VERSION11, ptype_batch_send, 2),
- REMOTE_PROTOCOL(PROTOCOL_VERSION12, ptype_batch_send, 3),
- REMOTE_PROTOCOL(PROTOCOL_VERSION13, ptype_batch_send, 4),
- REMOTE_PROTOCOL(PROTOCOL_VERSION14, ptype_batch_send, 5),
- REMOTE_PROTOCOL(PROTOCOL_VERSION15, ptype_batch_send, 6),
- REMOTE_PROTOCOL(PROTOCOL_VERSION16, ptype_batch_send, 7),
- REMOTE_PROTOCOL(PROTOCOL_VERSION17, ptype_batch_send, 8)
- };
- fb_assert(FB_NELEM(protocols_to_try) <= FB_NELEM(cnct->p_cnct_versions));
- cnct->p_cnct_count = FB_NELEM(protocols_to_try);
-
- for (size_t i = 0; i < cnct->p_cnct_count; i++) {
- cnct->p_cnct_versions[i] = protocols_to_try[i];
- }
-
- // If we can't talk to a server, punt. Let somebody else generate an error.
-
- rem_port* port = NULL;
- try
- {
- port = WNET_connect(node_name, packet, 0, config);
- }
- catch (const Exception&)
- {
- delete rdb;
- throw;
- }
-
- // Get response packet from server.
-
- rdb->rdb_port = port;
- port->port_context = rdb;
- port->receive(packet);
-
- P_ACPT* accept = NULL;
- switch (packet->p_operation)
- {
- case op_accept_data:
- case op_cond_accept:
- accept = &packet->p_acpd;
- if (cBlock)
- {
- cBlock->storeDataForPlugin(packet->p_acpd.p_acpt_data.cstr_length,
- packet->p_acpd.p_acpt_data.cstr_address);
- cBlock->authComplete = packet->p_acpd.p_acpt_authenticated;
- port->addServerKeys(&packet->p_acpd.p_acpt_keys);
- cBlock->resetClnt(&packet->p_acpd.p_acpt_keys);
- }
- break;
-
- case op_accept:
- if (cBlock)
- {
- cBlock->resetClnt();
- }
- accept = &packet->p_acpt;
- break;
-
- case op_response:
- try
- {
- Firebird::LocalStatus warning; // Ignore connect warnings for a while
- REMOTE_check_response(&warning, rdb, packet);
- }
- catch (const Firebird::Exception&)
- {
- disconnect(port);
- delete rdb;
- throw;
- }
- // fall through - response is not a required accept
-
- default:
- disconnect(port);
- delete rdb;
- Arg::Gds(isc_connect_reject).raise();
- break;
- }
-
- fb_assert(accept);
- fb_assert(port);
- port->port_protocol = accept->p_acpt_version;
-
- // once we've decided on a protocol, concatenate the version
- // string to reflect it...
-
- string temp;
- temp.printf("%s/P%d", port->port_version->str_data,
- port->port_protocol & FB_PROTOCOL_MASK);
- delete port->port_version;
- port->port_version = REMOTE_make_string(temp.c_str());
-
- if (accept->p_acpt_architecture == ARCHITECTURE)
- port->port_flags |= PORT_symmetric;
-
- if (accept->p_acpt_type != ptype_out_of_band)
- port->port_flags |= PORT_no_oob;
-
- return port;
-}
-
-
-rem_port* WNET_connect(const TEXT* name, PACKET* packet, USHORT flag, Firebird::RefPtr* config)
-{
-/**************************************
- *
- * W N E T _ c o n n e c t
- *
- **************************************
- *
- * Functional description
- * Establish half of a communication link. If a connect packet is given,
- * the connection is on behalf of a remote interface. Otherwise the
- * connect is for a server process.
- *
- **************************************/
- rem_port* const port = alloc_port(0);
- if (config)
- {
- port->port_config = *config;
- }
-
- delete port->port_connection;
- port->port_connection = make_pipe_name(port->getPortConfig(), name, SERVER_PIPE_SUFFIX, 0);
-
- // If we're a host, just make the connection
-
- if (packet)
- {
- while (true)
- {
- port->port_pipe = CreateFile(port->port_connection->str_data,
- GENERIC_WRITE | GENERIC_READ,
- 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
- if (port->port_pipe != INVALID_HANDLE_VALUE) {
- break;
- }
- const ISC_STATUS status = GetLastError();
- if (status != ERROR_PIPE_BUSY)
- {
- wnet_error(port, "CreateFile", isc_net_connect_err, status);
- disconnect(port);
- return NULL;
- }
- WaitNamedPipe(port->port_connection->str_data, 3000L);
- }
- send_full(port, packet);
- return port;
- }
-
- // We're a server, so wait for a host to show up
-
- wnet_ports->registerPort(port);
- while (!wnet_shutdown)
- {
- port->port_pipe =
- CreateNamedPipe(port->port_connection->str_data,
- PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
- PIPE_WAIT | PIPE_TYPE_BYTE | PIPE_READMODE_BYTE,
- PIPE_UNLIMITED_INSTANCES,
- MAX_DATA,
- MAX_DATA,
- 0,
- ISC_get_security_desc());
- if (port->port_pipe == INVALID_HANDLE_VALUE)
- {
- const DWORD dwError = GetLastError();
- if (dwError == ERROR_CALL_NOT_IMPLEMENTED)
- {
- disconnect(port);
- wnet_shutdown = true;
- break;
- }
-
- wnet_error(port, "CreateNamedPipe", isc_net_connect_listen_err, dwError);
- disconnect(port);
- return NULL;
- }
-
- if (!connect_client(port))
- break;
-
- if (flag & (SRVR_debug | SRVR_multi_client))
- {
- port->port_server_flags |= SRVR_server;
- port->port_flags |= PORT_server;
- if (flag & SRVR_multi_client)
- {
- port->port_server_flags |= SRVR_multi_client;
- }
-
- return port;
- }
-
- TEXT name[MAXPATHLEN];
- GetModuleFileName(NULL, name, sizeof(name));
-
- string cmdLine;
- cmdLine.printf("%s -w -h %" HANDLEFORMAT"@%" ULONGFORMAT, name, port->port_pipe, GetCurrentProcessId());
-
- STARTUPINFO start_crud;
- PROCESS_INFORMATION pi;
- start_crud.cb = sizeof(STARTUPINFO);
- start_crud.lpReserved = NULL;
- start_crud.lpReserved2 = NULL;
- start_crud.cbReserved2 = 0;
- start_crud.lpDesktop = NULL;
- start_crud.lpTitle = NULL;
- start_crud.dwFlags = STARTF_FORCEOFFFEEDBACK;
-
- if (CreateProcess(NULL, cmdLine.begin(), NULL, NULL, FALSE,
- (flag & SRVR_high_priority ?
- HIGH_PRIORITY_CLASS | DETACHED_PROCESS :
- NORMAL_PRIORITY_CLASS | DETACHED_PROCESS),
- NULL, NULL, &start_crud, &pi))
- {
- // hvlad: child process will close our handle of client pipe
- CloseHandle(pi.hThread);
- CloseHandle(pi.hProcess);
- }
- else
- {
- gds__log("WNET/wnet_error: fork/CreateProcess errno = %d", GetLastError());
- CloseHandle(port->port_pipe);
- }
-
- if (wnet_shutdown)
- disconnect(port);
- }
-
- if (wnet_shutdown)
- {
- Arg::Gds temp(isc_net_server_shutdown);
- temp << Arg::Str("WNET");
- temp.raise();
- }
-
- return NULL;
-}
-
-
-rem_port* WNET_reconnect(HANDLE handle)
-{
-/**************************************
- *
- * W N E T _ r e c o n n e c t
- *
- **************************************
- *
- * Functional description
- * A communications link has been established by another
- * process. We have inherited the handle. Set up
- * a port block.
- *
- **************************************/
- rem_port* const port = alloc_port(0);
-
- delete port->port_connection;
- port->port_connection = make_pipe_name(port->getPortConfig(), NULL, SERVER_PIPE_SUFFIX, 0);
-
- port->port_pipe = handle;
- port->port_server_flags |= SRVR_server;
- port->port_flags |= PORT_server;
-
- return port;
-}
-
-
-static bool accept_connection( rem_port* port, const P_CNCT* cnct)
-{
-/**************************************
- *
- * a c c e p t _ c o n n e c t i o n
- *
- **************************************
- *
- * Functional description
- * Accept an incoming request for connection. This is purely a lower
- * level handshaking function, and does not constitute the server
- * response for protocol selection.
- *
- **************************************/
- // Default account to "guest" (in theory all packets contain a name)
-
- string user_name("guest"), host_name;
-
- // Pick up account and host name, if given
-
- ClumpletReader id(ClumpletReader::UnTagged,
- cnct->p_cnct_user_id.cstr_address,
- cnct->p_cnct_user_id.cstr_length);
-
- for (id.rewind(); !id.isEof(); id.moveNext())
- {
- switch (id.getClumpTag())
- {
- case CNCT_user:
- id.getString(user_name);
- break;
-
- case CNCT_host:
- id.getString(host_name);
- break;
-
- default:
- break;
- }
- }
-
- port->port_login = port->port_user_name = user_name;
- port->port_peer_name = host_name;
- port->port_protocol_id = "WNET";
-
- return true;
-}
-
-
-static rem_port* alloc_port( rem_port* parent)
-{
-/**************************************
- *
- * a l l o c _ p o r t
- *
- **************************************
- *
- * Functional description
- * Allocate a port block, link it in to parent (if there is a parent),
- * and initialize input and output XDR streams.
- *
- **************************************/
-
- if (!wnet_initialized)
- {
- MutexLockGuard guard(init_mutex, FB_FUNCTION);
- if (!wnet_initialized)
- {
- wnet_initialized = true;
- fb_shutdown_callback(0, cleanup_ports, fb_shut_postproviders, 0);
- }
- }
-
- rem_port* port = FB_NEW rem_port(rem_port::PIPE, BUFFER_SIZE * 2);
-
- TEXT buffer[BUFFER_TINY];
- ISC_get_host(buffer, sizeof(buffer));
- port->port_host = REMOTE_make_string(buffer);
- port->port_connection = REMOTE_make_string(buffer);
- sprintf(buffer, "WNet (%s)", port->port_host->str_data);
- port->port_version = REMOTE_make_string(buffer);
-
- port->port_accept = accept_connection;
- port->port_disconnect = disconnect;
- port->port_force_close = force_close;
- port->port_receive_packet = receive;
- port->port_send_packet = send_full;
- port->port_send_partial = send_partial;
- port->port_connect = aux_connect;
- port->port_request = aux_request;
- port->port_buff_size = BUFFER_SIZE;
-
- port->port_event = CreateEvent(NULL, TRUE, TRUE, NULL);
-
- port->port_send = xdrwnet_create(port, &port->port_buffer[BUFFER_SIZE], BUFFER_SIZE, XDR_ENCODE);
-
- port->port_receive = xdrwnet_create(port, port->port_buffer, 0, XDR_DECODE);
-
- if (parent)
- {
- delete port->port_connection;
- port->port_connection = nullptr;
- port->port_connection = REMOTE_make_string(parent->port_connection->str_data);
-
- port->linkParent(parent);
- }
-
- return port;
-}
-
-
-static rem_port* aux_connect( rem_port* port, PACKET* packet)
-{
-/**************************************
- *
- * a u x _ c o n n e c t
- *
- **************************************
- *
- * Functional description
- * Try to establish an alternative connection. Somebody has already
- * done a successfull connect request ("packet" contains the response).
- *
- **************************************/
- // If this is a server, we're got an auxiliary connection. Accept it
-
- if (port->port_server_flags)
- {
- if (!connect_client(port))
- return NULL;
-
- port->port_flags |= PORT_async;
- return port;
- }
-
- // The server will be sending its process id in the packet to
- // create a unique pipe name.
-
- P_RESP* response = &packet->p_resp;
-
- TEXT str_pid[32];
- const TEXT* p = 0;
- if (response->p_resp_data.cstr_length)
- {
- // Avoid B.O.
- const size_t len = MIN(response->p_resp_data.cstr_length, sizeof(str_pid) - 1);
- memcpy(str_pid, response->p_resp_data.cstr_address, len);
- str_pid[len] = 0;
- p = str_pid;
- }
-
- rem_port* const new_port = alloc_port(port->port_parent);
- port->port_async = new_port;
- new_port->port_flags = port->port_flags & PORT_no_oob;
- new_port->port_flags |= PORT_async;
- new_port->port_connection = make_pipe_name(port->getPortConfig(),
- port->port_connection->str_data, EVENT_PIPE_SUFFIX, p);
-
- while (true)
- {
- new_port->port_pipe =
- CreateFile(new_port->port_connection->str_data, GENERIC_READ, 0,
- NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
- if (new_port->port_pipe != INVALID_HANDLE_VALUE)
- break;
- const ISC_STATUS status = GetLastError();
- if (status != ERROR_PIPE_BUSY)
- {
- wnet_error(new_port, "CreateFile", isc_net_event_connect_err, status);
- return NULL;
- }
- WaitNamedPipe(new_port->port_connection->str_data, 3000L);
- }
-
- return new_port;
-}
-
-
-static rem_port* aux_request( rem_port* vport, PACKET* packet)
-{
-/**************************************
- *
- * a u x _ r e q u e s t
- *
- **************************************
- *
- * Functional description
- * A remote interface has requested the server prepare an auxiliary
- * connection; the server calls aux_request to set up the connection.
- * Send the servers process id on the packet. If at a later time
- * a multi client server is used, there may be a need to
- * generate a unique id based on connection.
- *
- **************************************/
-
- const DWORD server_pid = (vport->port_server_flags & SRVR_multi_client) ?
- ++event_counter : GetCurrentProcessId();
- rem_port* const new_port = alloc_port(vport->port_parent);
- new_port->port_server_flags = vport->port_server_flags;
- new_port->port_flags = (vport->port_flags & PORT_no_oob) | PORT_connecting;
- vport->port_async = new_port;
-
- TEXT str_pid[32];
- wnet_make_file_name(str_pid, server_pid);
- new_port->port_connection = make_pipe_name(vport->getPortConfig(),
- vport->port_connection->str_data, EVENT_PIPE_SUFFIX, str_pid);
-
- new_port->port_pipe =
- CreateNamedPipe(new_port->port_connection->str_data,
- PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
- PIPE_WAIT | PIPE_TYPE_BYTE | PIPE_READMODE_BYTE,
- PIPE_UNLIMITED_INSTANCES,
- MAX_DATA,
- MAX_DATA,
- 0,
- ISC_get_security_desc());
-
- if (new_port->port_pipe == INVALID_HANDLE_VALUE)
- {
- wnet_error(new_port, "CreateNamedPipe", isc_net_event_listen_err, ERRNO);
- disconnect(new_port);
- return NULL;
- }
-
- P_RESP* response = &packet->p_resp;
- response->p_resp_data.cstr_length = (ULONG) strlen(str_pid);
- memcpy(response->p_resp_data.cstr_address, str_pid, response->p_resp_data.cstr_length);
-
- return new_port;
-}
-
-
-static bool connect_client(rem_port *port)
-{
-/**************************************
- *
- * c o n n e c t _ c l i e n t
- *
- **************************************
- *
- * Functional description
- * Wait for new client connected.
- *
- **************************************/
-
- OVERLAPPED ovrl = {0};
- ovrl.hEvent = port->port_event;
- if (!ConnectNamedPipe(port->port_pipe, &ovrl))
- {
- DWORD err = GetLastError();
- switch (err)
- {
- case ERROR_PIPE_CONNECTED:
- break;
-
- case ERROR_IO_PENDING:
- if (WaitForSingleObject(port->port_event, INFINITE) == WAIT_OBJECT_0)
- {
- if (!wnet_shutdown)
- break;
- }
- else
- err = GetLastError(); // fall thru
-
- default:
- if (!wnet_shutdown) {
- wnet_error(port, "ConnectNamedPipe", isc_net_connect_err, err);
- }
- disconnect(port);
- return false;
- }
- }
- return true;
-}
-
-
-static void disconnect(rem_port* port)
-{
-/**************************************
- *
- * d i s c o n n e c t
- *
- **************************************
- *
- * Functional description
- * Break a remote connection.
- *
- **************************************/
-
- if (port->port_state == rem_port::DISCONNECTED)
- return;
-
- port->port_state = rem_port::DISCONNECTED;
-
- if (port->port_async)
- {
- disconnect(port->port_async);
- port->port_async = NULL;
- }
- port->port_context = NULL;
-
- // If this is a sub-port, unlink it from its parent
- port->unlinkParent();
- port->port_flags &= ~PORT_connecting;
-
- if (port->port_server_flags & SRVR_server)
- {
- FlushFileBuffers(port->port_pipe);
- DisconnectNamedPipe(port->port_pipe);
- }
- if (port->port_event != INVALID_HANDLE_VALUE)
- {
- CloseHandle(port->port_event);
- port->port_event = INVALID_HANDLE_VALUE;
- }
- if (port->port_pipe != INVALID_HANDLE_VALUE)
- {
- CloseHandle(port->port_pipe);
- port->port_pipe = INVALID_HANDLE_VALUE;
- }
-
- wnet_ports->unRegisterPort(port);
-
- if (port->port_thread_guard && port->port_events_thread && !port->port_events_threadId.isCurrent())
- port->port_thread_guard->setWait(port->port_events_thread);
- else
- port->releasePort();
-}
-
-
-static void force_close(rem_port* port)
-{
-/**************************************
- *
- * f o r c e _ c l o s e
- *
- **************************************
- *
- * Functional description
- * Forcibly close remote connection.
- *
- **************************************/
-
- if (port->port_event != INVALID_HANDLE_VALUE)
- {
- port->port_state = rem_port::BROKEN;
-
- const HANDLE handle = port->port_pipe;
- port->port_pipe = INVALID_HANDLE_VALUE;
- SetEvent(port->port_event);
- CloseHandle(handle);
- }
-}
-
-
-#ifdef NOT_USED_OR_REPLACED
-static void exit_handler(void* main_port)
-{
-/**************************************
- *
- * e x i t _ h a n d l e r
- *
- **************************************
- *
- * Functional description
- * Shutdown all active connections
- * to allow restart.
- *
- **************************************/
- for (rem_port* vport = static_cast(main_port); vport; vport = vport->port_next)
- CloseHandle(vport->port_pipe);
-}
-#endif
-
-
-static rem_str* make_pipe_name(const RefPtr& config, const TEXT* connect_name,
- const TEXT* suffix_name, const TEXT* str_pid)
-{
-/**************************************
- *
- * m a k e _ p i p e _ n a m e
- *
- **************************************
- *
- * Functional description
- * Construct a name for the pipe connection.
- * Figure out whether we need a remote node name,
- * and construct the pipe name accordingly.
- * If a server pid != 0, append it to pipe name as <>/
- *
- **************************************/
- string buffer("\\\\");
-
- const TEXT* p = connect_name;
-
- if (!p || *p++ != '\\' || *p++ != '\\')
- p = ".";
-
- while (*p && *p != '\\' && *p != '@')
- buffer += *p++;
-
- const TEXT* protocol = NULL;
- switch (*p)
- {
- case 0:
- protocol = config->getRemoteServiceName();
- break;
- case '@':
- protocol = p + 1;
- break;
- default:
- while (*p)
- {
- if (*p++ == '\\')
- protocol = p;
- }
- }
-
- buffer += '\\';
- buffer += PIPE_PREFIX;
- buffer += '\\';
- const char *pipe_name = config->getRemotePipeName();
- buffer += pipe_name;
- buffer += '\\';
- buffer += suffix_name;
- buffer += '\\';
- buffer += protocol;
-
- if (str_pid)
- {
- buffer += '\\';
- buffer += str_pid;
- }
-
- return REMOTE_make_string(buffer.c_str());
-}
-
-
-static rem_port* receive( rem_port* main_port, PACKET* packet)
-{
-/**************************************
- *
- * r e c e i v e
- *
- **************************************
- *
- * Functional description
- * Receive a message from a port or clients of a port. If the process
- * is a server and a connection request comes in, generate a new port
- * block for the client.
- *
- **************************************/
-
- if (!xdr_protocol(main_port->port_receive, packet))
- packet->p_operation = op_exit;
-
- return main_port;
-}
-
-
-static int send_full( rem_port* port, PACKET* packet)
-{
-/**************************************
- *
- * s e n d _ f u l l
- *
- **************************************
- *
- * Functional description
- * Send a packet across a port to another process.
- *
- **************************************/
-
- if (!xdr_protocol(port->port_send, packet))
- return FALSE;
-
- return xdrwnet_endofrecord(port->port_send); //, TRUE);
-}
-
-
-static int send_partial( rem_port* port, PACKET* packet)
-{
-/**************************************
- *
- * s e n d _ p a r t i a l
- *
- **************************************
- *
- * Functional description
- * Send a packet across a port to another process.
- *
- **************************************/
-
- return xdr_protocol(port->port_send, packet);
-}
-
-
-static RemoteXdr* xdrwnet_create(rem_port* port, UCHAR* buffer, USHORT length, xdr_op x_op)
-{
-/**************************************
- *
- * x d r w n e t _ c r e a t e
- *
- **************************************
- *
- * Functional description
- * Initialize an XDR stream for Apollo mailboxes.
- *
- **************************************/
-
- RemoteXdr* xdrs = FB_NEW WnetXdr;
-
- xdrs->x_public = port;
- xdrs->create(reinterpret_cast(buffer), length, x_op);
-
- return xdrs;
-}
-
-
-static bool_t xdrwnet_endofrecord( RemoteXdr* xdrs) //, bool_t flushnow)
-{
-/**************************************
- *
- * x d r w n e t _ e n d o f r e c o r d
- *
- **************************************
- *
- * Functional description
- * Write out the rest of a record.
- *
- **************************************/
-
- return wnet_write(xdrs); //, flushnow);
-}
-
-
-static bool wnet_error(rem_port* port,
- const TEXT* function, ISC_STATUS operation, int status)
-{
-/**************************************
- *
- * w n e t _ e r r o r
- *
- **************************************
- *
- * Functional description
- * An I/O error has occurred. If a status vector is present,
- * generate an error return. In any case, return NULL, which
- * is used to indicate and error.
- *
- **************************************/
- if (status)
- {
- if (port->port_state == rem_port::PENDING)
- {
- gds__log("WNET/wnet_error: %s errno = %d", function, status);
- }
-
- wnet_gen_error(port, Arg::Gds(operation) << SYS_ERR(status));
- }
- else
- {
- wnet_gen_error(port, Arg::Gds(operation));
- }
-
- return false;
-}
-
-
-static void wnet_gen_error (rem_port* port, const Arg::StatusVector& v)
-{
-/**************************************
- *
- * w n e t _ g e n _ e r r o r
- *
- **************************************
- *
- * Functional description
- * An error has occurred. Mark the port as broken.
- * Format the status vector if there is one and
- * save the status vector strings in a permanent place.
- *
- **************************************/
- port->port_state = rem_port::BROKEN;
-
- TEXT node_name[MAXPATHLEN];
- if (port->port_connection)
- {
- fb_utils::copy_terminate(node_name, port->port_connection->str_data + 2, sizeof(node_name));
- TEXT* const p = strchr(node_name, '\\');
- if (p != NULL)
- *p = '\0';
- }
- else
- {
- strcpy(node_name, "(unknown)");
- }
-
- Arg::Gds error(isc_network_error);
- error << Arg::Str(node_name) << v;
- error.raise();
-}
-
-
-bool_t WnetXdr::x_getbytes(SCHAR* buff, unsigned bytecount)
-{
-/**************************************
- *
- * w n e t _ g e t b y t e s
- *
- **************************************
- *
- * Functional description
- * Get a bunch of bytes from a memory stream if it fits.
- *
- **************************************/
- // Use memcpy to optimize bulk transfers.
-
- while (bytecount > (SLONG) sizeof(ISC_QUAD))
- {
- if (x_handy >= bytecount)
- {
- memcpy(buff, x_private, bytecount);
- x_private += bytecount;
- x_handy -= bytecount;
- return TRUE;
- }
- if (x_handy > 0)
- {
- memcpy(buff, x_private, x_handy);
- x_private += x_handy;
- buff += x_handy;
- bytecount -= x_handy;
- x_handy = 0;
- }
- if (!wnet_read(this))
- return FALSE;
- }
-
- // Scalar values and bulk transfer remainder fall thru
- // to be moved byte-by-byte to avoid memcpy setup costs.
-
- if (!bytecount)
- return TRUE;
-
- if (x_handy >= bytecount)
- {
- x_handy -= bytecount;
- do {
- *buff++ = *x_private++;
- } while (--bytecount);
- return TRUE;
- }
-
- while (bytecount--)
- {
- if (x_handy == 0 && !wnet_read(this))
- return FALSE;
- *buff++ = *x_private++;
- --x_handy;
- }
-
- return TRUE;
-}
-
-
-bool_t WnetXdr::x_putbytes(const SCHAR* buff, unsigned count)
-{
-/**************************************
- *
- * w n e t _ p u t b y t e s
- *
- **************************************
- *
- * Functional description
- * Put a bunch of bytes to a memory stream if it fits.
- *
- **************************************/
- SLONG bytecount = count;
-
- // Use memcpy to optimize bulk transfers.
-
- while (bytecount > (SLONG) sizeof(ISC_QUAD))
- {
- if (x_handy >= bytecount)
- {
- memcpy(x_private, buff, bytecount);
- x_private += bytecount;
- x_handy -= bytecount;
- return TRUE;
- }
- if (x_handy > 0)
- {
- memcpy(x_private, buff, x_handy);
- x_private += x_handy;
- buff += x_handy;
- bytecount -= x_handy;
- x_handy = 0;
- }
- if (!wnet_write(this /*, 0*/))
- return FALSE;
- }
-
- // Scalar values and bulk transfer remainder fall thru
- // to be moved byte-by-byte to avoid memcpy setup costs.
-
- if (!bytecount)
- return TRUE;
-
- if (x_handy >= bytecount)
- {
- x_handy -= bytecount;
- do {
- *x_private++ = *buff++;
- } while (--bytecount);
- return TRUE;
- }
-
- while (bytecount--)
- {
- if (x_handy == 0 && !wnet_write(this /*, 0*/))
- return FALSE;
- --x_handy;
- *x_private++ = *buff++;
- }
-
- return TRUE;
-}
-
-
-static bool_t wnet_read( RemoteXdr* xdrs)
-{
-/**************************************
- *
- * w n e t _ r e a d
- *
- **************************************
- *
- * Functional description
- * Read a buffer full of data. If we receive a bad packet,
- * send the moral equivalent of a NAK and retry. ACK all
- * partial packets. Don't ACK the last packet -- the next
- * message sent will handle this.
- *
- **************************************/
- rem_port* port = xdrs->x_public;
- SCHAR* p = xdrs->x_base;
- const SCHAR* const end = p + BUFFER_SIZE;
-
- // If buffer is not completely empty, slide down what what's left
-
- if (xdrs->x_handy > 0)
- {
- memmove(p, xdrs->x_private, xdrs->x_handy);
- p += xdrs->x_handy;
- }
-
- while (true)
- {
- SSHORT length = end - p;
- if (!packet_receive(port, reinterpret_cast(p), length, &length))
- {
- return FALSE;
- }
- if (length >= 0)
- {
- p += length;
- break;
- }
- p -= length;
- if (!packet_send(port, 0, 0))
- return FALSE;
- }
-
- xdrs->x_handy = p - xdrs->x_base;
- xdrs->x_private = xdrs->x_base;
-
- return TRUE;
-}
-
-
-static bool_t wnet_write( RemoteXdr* xdrs /*, bool_t end_flag*/)
-{
-/**************************************
- *
- * w n e t _ w r i t e
- *
- **************************************
- *
- * Functional description
- * Write a buffer fulll of data.
- * Obsolete: If the end_flag isn't set, indicate
- * that the buffer is a fragment, and reset the XDR for another buffer
- * load.
- *
- **************************************/
- // Encode the data portion of the packet
-
- rem_port* vport = xdrs->x_public;
- const SCHAR* p = xdrs->x_base;
- SSHORT length = xdrs->x_private - p;
-
- // Send data in manageable hunks. If a packet is partial, indicate
- // that with a negative length. A positive length marks the end.
-
- while (length)
- {
- const SSHORT l = MIN(length, MAX_DATA);
- length -= l;
- if (!packet_send(vport, p, (SSHORT) (length ? -l : l)))
- return FALSE;
- p += l;
- }
-
- xdrs->x_private = xdrs->x_base;
- xdrs->x_handy = BUFFER_SIZE;
-
- return TRUE;
-}
-
-
-#ifdef DEBUG
-static void packet_print(const TEXT* string, const UCHAR* packet, const int length)
-{
-/**************************************
- *
- * p a c k e t _ p r i n t
- *
- **************************************
- *
- * Functional description
- * Print a summary of packet.
- *
- **************************************/
- int sum = 0;
- int l = length;
-
- if (l)
- {
- do {
- sum += *packet++;
- } while (--l);
- }
-
- printf("%s\t: length = %d, checksum = %d\n", string, length, sum);
-}
-#endif
-
-
-static bool packet_receive(rem_port* port, UCHAR* buffer, SSHORT buffer_length, SSHORT* length)
-{
-/**************************************
- *
- * p a c k e t _ r e c e i v e
- *
- **************************************
- *
- * Functional description
- * Receive a packet and pass on it's goodness. If it's good,
- * return true and the reported length of the packet, and update
- * the receive sequence number. If it's bad, return false. If it's
- * a duplicate message, just ignore it.
- *
- **************************************/
- DWORD n = 0;
- OVERLAPPED ovrl = {0};
- ovrl.hEvent = port->port_event;
-
- BOOL status = ReadFile(port->port_pipe, buffer, buffer_length, &n, &ovrl);
- DWORD dwError = GetLastError();
-
- if (!status && dwError == ERROR_IO_PENDING)
- {
- status = GetOverlappedResult(port->port_pipe, &ovrl, &n, TRUE);
- dwError = GetLastError();
- }
- if (!status && dwError != ERROR_BROKEN_PIPE) {
- return wnet_error(port, "ReadFile", isc_net_read_err, dwError);
- }
-
- if (!n)
- {
- if (port->port_flags & (PORT_detached | PORT_disconnect))
- return false;
-
- return wnet_error(port, "ReadFile end-of-file", isc_net_read_err, dwError);
- }
-
- // decrypt
- if (port->port_crypt_plugin)
- {
- LocalStatus ls;
- CheckStatusWrapper st(&ls);
-
- port->port_crypt_plugin->decrypt(&st, n, buffer, buffer);
- if (st.getState() & IStatus::STATE_ERRORS)
- {
- status_exception::raise(&st);
- }
- }
-
-#if defined(DEBUG) && defined(WNET_trace)
- packet_print("receive", buffer, n);
-#endif
-
- port->port_rcv_packets++;
- port->port_rcv_bytes += n;
-
- *length = (SSHORT) n;
-
- return true;
-}
-
-
-static bool packet_send( rem_port* port, const SCHAR* buffer, SSHORT buffer_length)
-{
-/**************************************
- *
- * p a c k e t _ s e n d
- *
- **************************************
- *
- * Functional description
- * Send some data on it's way.
- *
- **************************************/
- const SCHAR* data = buffer;
- const DWORD length = buffer_length;
-
- // encrypt
- HalfStaticArray b;
- if (port->port_crypt_plugin && port->port_crypt_complete)
- {
- LocalStatus ls;
- CheckStatusWrapper st(&ls);
-
- char* d = b.getBuffer(buffer_length);
- port->port_crypt_plugin->encrypt(&st, buffer_length, data, d);
- if (st.getState() & IStatus::STATE_ERRORS)
- {
- status_exception::raise(&st);
- }
-
- data = d;
- }
-
- OVERLAPPED ovrl = {0};
- ovrl.hEvent = port->port_event;
-
- DWORD n;
- BOOL status = WriteFile(port->port_pipe, data, length, &n, &ovrl);
- DWORD dwError = GetLastError();
-
- if (!status && dwError == ERROR_IO_PENDING)
- {
- status = GetOverlappedResult(port->port_pipe, &ovrl, &n, TRUE);
- dwError = GetLastError();
- }
- if (!status && dwError != ERROR_NO_DATA)
- return wnet_error(port, "WriteFile", isc_net_write_err, dwError);
- if (n != length)
- {
- if (port->port_flags & (PORT_detached | PORT_disconnect))
- return false;
-
- return wnet_error(port, "WriteFile truncated", isc_net_write_err, dwError);
- }
-
-#if defined(DEBUG) && defined(WNET_trace)
- packet_print("send", reinterpret_cast(buffer), buffer_length);
-#endif
-
- port->port_snd_packets++;
- port->port_snd_bytes += buffer_length;
-
- return true;
-}
-
-
-static void wnet_make_file_name( TEXT* name, DWORD number)
-{
-/**************************************
- *
- * w n e t _ m a k e _ f i l e _ n a m e
- *
- **************************************
- *
- * Functional description
- * Create a file name out of a number making sure
- * the Windows <8>.<3> limitations are handled.
- *
- **************************************/
- TEXT temp[32];
-
- sprintf(temp, "%lu", number);
-
- size_t length = strlen(temp);
- if (length < 8)
- {
- strcpy(name, temp);
- return;
- }
-
- TEXT* p = name;
- const TEXT* q = temp;
-
- while (length)
- {
- size_t len = (length > 8) ? 8 : length;
- length -= len;
- do {
- *p++ = *q++;
- } while (--len != 0);
-
- if (length)
- *p++ = '\\';
- }
- *p++ = 0;
-}
-
-static int cleanup_ports(const int, const int, void*)
-{
-/**************************************
- *
- * c l e a n u p _ p o r t s
- *
- **************************************
- *
- * Functional description
- * Shutdown all active connections
- * to allow correct shutdown.
- *
- **************************************/
- wnet_shutdown = true;
-
- wnet_ports->closePorts();
- return 0;
-}
diff --git a/src/remote/os/win32/wnet_proto.h b/src/remote/os/win32/wnet_proto.h
deleted file mode 100644
index e3251ecebd..0000000000
--- a/src/remote/os/win32/wnet_proto.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * PROGRAM: JRD Remote Interface/Server
- * MODULE: wnet_proto.h
- * DESCRIPTION: Prototpe header file for wnet.cpp
- *
- * 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): ______________________________________.
- */
-
-#ifndef REMOTE_WNET_PROTO_H
-#define REMOTE_WNET_PROTO_H
-
-#include "../common/classes/fb_string.h"
-
-rem_port* WNET_analyze(ClntAuthBlock*, const Firebird::PathName&, const TEXT*, bool,
- Firebird::RefPtr*, const Firebird::PathName*);
-rem_port* WNET_connect(const TEXT*, struct packet*, USHORT, Firebird::RefPtr*);
-rem_port* WNET_reconnect(HANDLE);
-
-
-#endif // REMOTE_WNET_PROTO_H
diff --git a/src/remote/remote.h b/src/remote/remote.h
index 0fa6ae8e72..befc838c65 100644
--- a/src/remote/remote.h
+++ b/src/remote/remote.h
@@ -1042,7 +1042,6 @@ struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted
enum rem_port_t {
INET, // Internet (TCP/IP)
- PIPE, // Windows NT named pipe connection
XNET // Windows NT shared memory connection
} port_type;
enum state_t {
diff --git a/src/remote/remote_def.h b/src/remote/remote_def.h
index 58daa1aa7a..39e34e0e59 100644
--- a/src/remote/remote_def.h
+++ b/src/remote/remote_def.h
@@ -81,11 +81,10 @@ const USHORT SRVR_server = 1; // server
const USHORT SRVR_multi_client = 2; // multi-client server
const USHORT SRVR_debug = 4; // debug run
const USHORT SRVR_inet = 8; // Inet protocol
-const USHORT SRVR_wnet = 16; // Wnet (named pipe) protocol (WinNT)
-const USHORT SRVR_xnet = 32; // Xnet protocol (Win32)
-const USHORT SRVR_non_service = 64; // not running as an NT service
-const USHORT SRVR_high_priority = 128; // fork off server at high priority
-const USHORT SRVR_thread_per_port = 256; // bind thread to a port
-const USHORT SRVR_no_icon = 512; // tell the server not to show the icon
+const USHORT SRVR_xnet = 16; // Xnet protocol (Win32)
+const USHORT SRVR_non_service = 32; // not running as an NT service
+const USHORT SRVR_high_priority = 64; // fork off server at high priority
+const USHORT SRVR_thread_per_port = 128; // bind thread to a port
+const USHORT SRVR_no_icon = 256; // tell the server not to show the icon
#endif /* REMOTE_REMOTE_DEF_H */
diff --git a/src/remote/server/os/win32/property.cpp b/src/remote/server/os/win32/property.cpp
index 94a3eab1d0..00ff4cf690 100644
--- a/src/remote/server/os/win32/property.cpp
+++ b/src/remote/server/os/win32/property.cpp
@@ -154,7 +154,7 @@ LRESULT CALLBACK GeneralPage(HWND hDlg, UINT unMsg, WPARAM wParam, LPARAM lParam
lstrcpy(szText, FB_VERSION);
SetDlgItemText(hDlg, IDC_STAT1, szText);
- if (usServerFlags & (SRVR_inet | SRVR_wnet))
+ if (usServerFlags & SRVR_inet)
LoadString(hInstance, IDS_SERVERPROD_NAME, szText, sizeof(szText));
else
LoadString(hInstance, IDS_LOCALPROD_NAME, szText, sizeof(szText));
@@ -241,14 +241,6 @@ static char* MakeVersionString(char* pchBuf, size_t nLen, USHORT usServerFlagMas
if (p < end)
*p++ = '\n';
}
- if ((usServerFlagMask & SRVR_wnet) && end > p)
- {
- p += LoadString(hInstance, IDS_NP, p, end - p);
- if (p < end)
- *p++ = '\r';
- if (p < end)
- *p++ = '\n';
- }
if ((usServerFlagMask & SRVR_xnet) && end > p)
{
p += LoadString(hInstance, IDS_IPC, p, end - p);
diff --git a/src/remote/server/os/win32/property.rc b/src/remote/server/os/win32/property.rc
index 4223a9e1e3..ba69270590 100644
--- a/src/remote/server/os/win32/property.rc
+++ b/src/remote/server/os/win32/property.rc
@@ -45,7 +45,6 @@ STRINGTABLE
BEGIN
IDS_TCP, "TCP/IP Client Support"
IDS_IPC, "Local Client Support"
- IDS_NP, "NetBEUI Client Support"
IDS_SUPER, "Multithreaded Server"
IDS_SERVERPROD_NAME, "Firebird SQL Server for Windows"
IDS_LOCALPROD_NAME, "Local Firebird Server"
diff --git a/src/remote/server/os/win32/property.rh b/src/remote/server/os/win32/property.rh
index 6d72d4ec36..f4cefc774c 100644
--- a/src/remote/server/os/win32/property.rh
+++ b/src/remote/server/os/win32/property.rh
@@ -48,7 +48,6 @@ produced by Borland Resource Workshop
#define IDI_IBSVR 1007
#define IDS_TCP 11
-#define IDS_NP 12
#define IDS_IPC 13
#define IDS_SUPER 14
diff --git a/src/remote/server/os/win32/srvr_w32.cpp b/src/remote/server/os/win32/srvr_w32.cpp
index bd753380c5..9eaf7c9572 100644
--- a/src/remote/server/os/win32/srvr_w32.cpp
+++ b/src/remote/server/os/win32/srvr_w32.cpp
@@ -103,7 +103,6 @@
#include "../remote/server/serve_proto.h"
#include "../remote/server/ReplServer.h"
#include "../remote/server/os/win32/window_proto.h"
-#include "../remote/os/win32/wnet_proto.h"
#include "../remote/server/os/win32/window.rh"
#include "../remote/os/win32/xnet_proto.h"
#include "../yvalve/gds_proto.h"
@@ -118,7 +117,6 @@
static THREAD_ENTRY_DECLARE inet_connect_wait_thread(THREAD_ENTRY_PARAM);
-static THREAD_ENTRY_DECLARE wnet_connect_wait_thread(THREAD_ENTRY_PARAM);
static THREAD_ENTRY_DECLARE xnet_connect_wait_thread(THREAD_ENTRY_PARAM);
static THREAD_ENTRY_DECLARE start_connections_thread(THREAD_ENTRY_PARAM);
static THREAD_ENTRY_DECLARE process_connection_thread(THREAD_ENTRY_PARAM);
@@ -129,7 +127,6 @@ static int wait_threads(const int reason, const int mask, void* arg);
static HINSTANCE hInst;
static TEXT protocol_inet[128];
-static TEXT protocol_wnet[128];
static TEXT instance[MAXPATHLEN];
static USHORT server_flag = 0;
static bool server_shutdown = false;
@@ -224,7 +221,6 @@ int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE /*hPrevInst*/, LPSTR lpszArgs,
SetProcessAffinityMask(GetCurrentProcess(), affinity);
protocol_inet[0] = 0;
- protocol_wnet[0] = 0;
strcpy(instance, FB_DEFAULT_INSTANCE);
@@ -295,8 +291,6 @@ int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE /*hPrevInst*/, LPSTR lpszArgs,
port = NULL;
}
}
- else if (server_flag & SRVR_wnet)
- port = WNET_reconnect(connection_handle);
else if (server_flag & SRVR_xnet)
port = XNET_reconnect((ULONG_PTR) connection_handle);
@@ -428,56 +422,6 @@ static THREAD_ENTRY_DECLARE inet_connect_wait_thread(THREAD_ENTRY_PARAM)
}
-static THREAD_ENTRY_DECLARE wnet_connect_wait_thread(THREAD_ENTRY_PARAM)
-{
-/**************************************
- *
- * w n e t _ c o n n e c t _ w a i t _ t h r e a d
- *
- **************************************
- *
- * Functional description
- *
- **************************************/
- ThreadCounter counter;
-
- while (!server_shutdown)
- {
- rem_port* port = NULL;
-
- try
- {
- port = WNET_connect(protocol_wnet, NULL, server_flag, NULL);
- }
- catch (const Exception& ex)
- {
- SimpleStatusVector<> status_vector;
- ex.stuffException(status_vector);
-
- if (status_vector[1] == isc_net_server_shutdown)
- break;
-
- iscLogException("WNET_connect", ex);
- }
-
- if (port)
- {
- try
- {
- Thread::start(process_connection_thread, port, THREAD_medium);
- }
- catch (const Exception&)
- {
- gds__log("WNET: can't start worker thread, connection terminated");
- port->disconnect(NULL, NULL);
- }
- }
- }
-
- return 0;
-}
-
-
static THREAD_ENTRY_DECLARE xnet_connect_wait_thread(THREAD_ENTRY_PARAM)
{
/**************************************
@@ -571,18 +515,6 @@ static THREAD_ENTRY_DECLARE start_connections_thread(THREAD_ENTRY_PARAM)
}
}
- if (server_flag & SRVR_wnet)
- {
- try
- {
- Thread::start(wnet_connect_wait_thread, 0, THREAD_medium);
- }
- catch (const Exception& ex)
- {
- iscLogException("WNET: can't start listener thread", ex);
- }
- }
-
if (server_flag & SRVR_xnet)
{
try
@@ -650,19 +582,10 @@ static HANDLE parse_args(LPCSTR lpszArgs, USHORT* pserver_flag)
if (*p)
{
TEXT buffer[32];
+ const char* end = buffer + sizeof(buffer) - 1;
char* pp = buffer;
- while (*p && *p != ' ' && (pp - buffer < sizeof(buffer) - 1))
- {
- if (*p == '@')
- {
- p++;
- *pp++ = '\0';
- connection_handle = (HANDLE) _atoi64(buffer);
- pp = buffer;
- }
- else
- *pp++ = *p++;
- }
+ while (*p && *p != ' ' && pp < end)
+ *pp++ = *p++;
*pp++ = '\0';
if (connection_handle == INVALID_HANDLE_VALUE)
@@ -699,7 +622,7 @@ static HANDLE parse_args(LPCSTR lpszArgs, USHORT* pserver_flag)
*pserver_flag |= SRVR_no_icon;
break;
- case 'P': // Specify a port or named pipe other than the default
+ case 'P': // Specify a port other than the default
while (*p && *p == ' ')
p++;
if (*p)
@@ -708,23 +631,14 @@ static HANDLE parse_args(LPCSTR lpszArgs, USHORT* pserver_flag)
// in the future, hence I did generic code.
char* pi = protocol_inet;
const char* piend = protocol_inet + sizeof(protocol_inet) - 1;
- char* pw = protocol_wnet;
- const char* pwend = protocol_wnet + sizeof(protocol_wnet) - 1;
*pi++ = '/';
- *pw++ = '\\';
- *pw++ = '\\';
- *pw++ = '.';
- *pw++ = '@';
while (*p && *p != ' ')
{
if (pi < piend)
*pi++ = *p;
- if (pw < pwend)
- *pw++ = *p++;
}
*pi++ = '\0';
- *pw++ = '\0';
}
break;
@@ -766,10 +680,6 @@ static HANDLE parse_args(LPCSTR lpszArgs, USHORT* pserver_flag)
}
break;
- case 'W':
- *pserver_flag |= SRVR_wnet;
- break;
-
case 'X':
*pserver_flag |= SRVR_xnet;
break;
@@ -791,9 +701,8 @@ static HANDLE parse_args(LPCSTR lpszArgs, USHORT* pserver_flag)
}
}
- if ((*pserver_flag & (SRVR_inet | SRVR_wnet | SRVR_xnet)) == 0)
+ if ((*pserver_flag & (SRVR_inet | SRVR_xnet)) == 0)
{
- *pserver_flag |= SRVR_wnet;
*pserver_flag |= SRVR_inet;
*pserver_flag |= SRVR_xnet;
}
diff --git a/src/remote/server/server.cpp b/src/remote/server/server.cpp
index 10c6ea2dbe..d1e3965144 100644
--- a/src/remote/server/server.cpp
+++ b/src/remote/server/server.cpp
@@ -2536,7 +2536,7 @@ static void aux_request( rem_port* port, /*P_REQ* request,*/ PACKET* send)
return;
}
- // This buffer is used by INET and WNET transports
+ // This buffer is used by INET transport
// to return the server identification string
UCHAR buffer[BUFFER_TINY];
send->p_resp.p_resp_data.cstr_address = buffer;
@@ -2937,7 +2937,7 @@ void rem_port::disconnect(PACKET* sendL, PACKET* receiveL)
return;
}
- // For WNET and XNET we should send dummy op_disconnect packet
+ // For XNET we should send dummy op_disconnect packet
// to wakeup async port handling events on client side.
// For INET it's not necessary because INET client's async port
// wakes up while server performs shutdown(socket) call on its async port.
@@ -2946,7 +2946,7 @@ void rem_port::disconnect(PACKET* sendL, PACKET* receiveL)
PACKET *packet = &rdb->rdb_packet;
if (this->port_async)
{
- if ((this->port_type == rem_port::XNET) || (this->port_type == rem_port::PIPE))
+ if (this->port_type == rem_port::XNET)
{
packet->p_operation = op_disconnect;
this->port_async->send(packet);
diff --git a/src/utilities/gsec/gsec.cpp b/src/utilities/gsec/gsec.cpp
index d7150af14e..b6ba23f236 100644
--- a/src/utilities/gsec/gsec.cpp
+++ b/src/utilities/gsec/gsec.cpp
@@ -396,22 +396,12 @@ int gsec(Firebird::UtilSvc* uSvc)
const Firebird::string sqlRoleName(user_data->role.entered() ? user_data->role.get() : "");
Firebird::PathName serverName;
- const bool useServices = !uSvc->isService();
-
- switch (ISC_extract_host(databaseName, serverName, true))
- {
- case ISC_PROTOCOL_TCPIP:
+ if (ISC_extract_host(databaseName, serverName, true) == ISC_PROTOCOL_TCPIP)
serverName += ":";
- break;
- case ISC_PROTOCOL_WLAN:
- serverName = "\\\\" + serverName + "\\";
- break;
- }
+ const bool useServices = !uSvc->isService();
if (!useServices)
- {
serverName = "";
- }
Firebird::LocalStatus s;
Firebird::CheckStatusWrapper statusWrapper(&s);
diff --git a/src/utilities/gstat/dba.epp b/src/utilities/gstat/dba.epp
index 17e842c735..df27fd696a 100644
--- a/src/utilities/gstat/dba.epp
+++ b/src/utilities/gstat/dba.epp
@@ -593,18 +593,13 @@ int gstat(Firebird::UtilSvc* uSvc)
const Firebird::PathName connName = fileName;
Firebird::PathName tempStr;
-#ifdef WIN_NT
- if (!ISC_analyze_pclan(fileName, tempStr))
-#endif
+ if (!ISC_analyze_tcp(fileName, tempStr))
{
- if (!ISC_analyze_tcp(fileName, tempStr))
- {
#ifndef NO_NFS
- if (!ISC_analyze_nfs(fileName, tempStr))
+ if (!ISC_analyze_nfs(fileName, tempStr))
#endif
- {
- fileName = connName;
- }
+ {
+ fileName = connName;
}
}