Commit ae608a51 authored by dimbor's avatar dimbor

nxcomp: new additional connection channels

parent d10646e3
......@@ -70,6 +70,9 @@ extern "C" {
#define NX_CHANNEL_HTTP 4
#define NX_CHANNEL_FONT 5
#define NX_CHANNEL_SLAVE 6
#define NX_CHANNEL_EXTRA1 7
#define NX_CHANNEL_EXTRA2 8
#define NX_CHANNEL_EXTRA3 9
#define NX_FILE_SESSION 0
#define NX_FILE_ERRORS 1
......@@ -341,8 +344,12 @@ extern int NXTransFlush(int fd);
* NX_CHANNEL_FONT: The channel will forward a X font server
* connection.
*
* NX_CHANNEL_EXTRA[1-3]: The channels will transport user defined
* data; NOTE: EXTRA3 has high priority like
* MEDIA channel
*
* Only a proxy running at the NX server/X client side will be able
* to create a X, CUPS, SMB, MEDIA and HTTP channel. A proxy running
* to create a X, CUPS, SMB, MEDIA, HTTP, EXTA channels. A proxy running
* at the NX client/X server side can create font server connections.
* The channel creation will also fail if the remote end has not been
* set up to forward the connection.
......
......@@ -79,6 +79,9 @@ typedef enum
channel_http,
channel_font,
channel_slave,
channel_extra1,
channel_extra2,
channel_extra3,
channel_last_tag
} T_channel_type;
......
......@@ -84,7 +84,10 @@ void ClientProxy::handlePortConfiguration(ChannelEndPoint &cupsServerPort,
ChannelEndPoint &smbServerPort,
ChannelEndPoint &mediaServerPort,
ChannelEndPoint &httpServerPort,
const char *fontServerPort)
const char *fontServerPort,
ChannelEndPoint &extra1ServerPort,
ChannelEndPoint &extra2ServerPort,
ChannelEndPoint &extra3ServerPort)
{
delete [] fontServerPort_;
......@@ -123,6 +126,18 @@ int ClientProxy::handleNewConnection(T_channel_type type, int clientFd)
{
return handleNewGenericConnection(clientFd, channel_http, "HTTP");
}
case channel_extra1:
{
return handleNewGenericConnection(clientFd, channel_extra1, "EXTRA1");
}
case channel_extra2:
{
return handleNewGenericConnection(clientFd, channel_extra2, "EXTRA2");
}
case channel_extra3:
{
return handleNewGenericConnection(clientFd, channel_extra3, "EXTRA3");
}
case channel_slave:
{
return handleNewSlaveConnection(clientFd);
......
......@@ -50,7 +50,10 @@ class ClientProxy : public Proxy
ChannelEndPoint &smbServerPort,
ChannelEndPoint &mediaServerPort,
ChannelEndPoint &httpServerPort,
const char *fontServerPort);
const char *fontServerPort,
ChannelEndPoint &extra1ServerPort,
ChannelEndPoint &extra2ServerPort,
ChannelEndPoint &extra3ServerPort);
protected:
......
......@@ -78,7 +78,7 @@
// at the NX server side (X client side).
//
#define CHANNEL_MASK 0x07
#define CHANNEL_MASK 0x0F
//
// Kill session if control parameters cannot be
......
......@@ -360,6 +360,133 @@ class HttpChannel : public GenericChannel
}
};
class Extra1Channel : public GenericChannel
{
public:
Extra1Channel(Transport *transport, StaticCompressor *compressor)
: GenericChannel(transport, compressor)
{
}
virtual ~Extra1Channel()
{
}
protected:
virtual T_channel_type getType() const
{
return channel_extra1;
}
virtual int isCompressed()
{
// Since ProtoStep8 (#issue 108)
return 0;
}
virtual int isPrioritized()
{
return 0;
}
virtual void addProtocolBits(unsigned int bitsIn,
unsigned int bitsOut)
{
statistics -> addExtra1Bits(bitsIn, bitsOut);
}
};
class Extra2Channel : public GenericChannel
{
public:
Extra2Channel(Transport *transport, StaticCompressor *compressor)
: GenericChannel(transport, compressor)
{
}
virtual ~Extra2Channel()
{
}
protected:
virtual T_channel_type getType() const
{
return channel_extra2;
}
virtual int isCompressed()
{
// Since ProtoStep8 (#issue 108)
return 0;
}
virtual int isPrioritized()
{
return 0;
}
virtual void addProtocolBits(unsigned int bitsIn,
unsigned int bitsOut)
{
statistics -> addExtra2Bits(bitsIn, bitsOut);
}
};
class Extra3Channel : public GenericChannel
{
public:
Extra3Channel(Transport *transport, StaticCompressor *compressor)
: GenericChannel(transport, compressor)
{
}
virtual ~Extra3Channel()
{
}
protected:
virtual T_channel_type getType() const
{
return channel_extra3;
}
//
// Don't try to compress the media data.
//
virtual int isCompressed()
{
return 0;
}
//
// Reduce the latency of extra3 channels
// by setting them as prioritized, even
// if this will take away bandwidth from
// the X channels.
//
virtual int isPrioritized()
{
return 1;
}
virtual void addProtocolBits(unsigned int bitsIn,
unsigned int bitsOut)
{
statistics -> addExtra3Bits(bitsIn, bitsOut);
}
};
class FontChannel : public GenericChannel
{
public:
......
......@@ -112,6 +112,10 @@ const int DEFAULT_NX_FONT_PORT_OFFSET = 10000;
const int DEFAULT_NX_SLAVE_PORT_CLIENT_OFFSET = 11000;
const int DEFAULT_NX_SLAVE_PORT_SERVER_OFFSET = 12000;
const int DEFAULT_NX_EXTRA1_PORT_OFFSET = 7250;
const int DEFAULT_NX_EXTRA2_PORT_OFFSET = 7500;
const int DEFAULT_NX_EXTRA3_PORT_OFFSET = 7750;
//
// Usage info and copyright.
//
......@@ -276,6 +280,12 @@ static const char UsageInfo[] =
\n\
http=n Enable forwarding of HTTP connections.\n\
\n\
extra1=n Enable forwarding of EXTRA1 connections.\n\
\n\
extra2=n Enable forwarding of EXTRA2 connections.\n\
\n\
extra3=n Enable forwarding of EXTRA3 connections.\n\
\n\
font=n Enable forwarding of reversed connections to a font\n\
server running on the NX server.\n\
\n\
......@@ -976,6 +986,18 @@ const char *DumpControl(int code)
{
return "code_new_media_connection";
}
case code_new_extra1_connection:
{
return "code_new_extra1_connection";
}
case code_new_extra2_connection:
{
return "code_new_extra2_connection";
}
case code_new_extra3_connection:
{
return "code_new_extra3_connection";
}
case code_switch_connection:
{
return "code_switch_connection";
......
......@@ -89,6 +89,9 @@ extern const int DEFAULT_NX_MEDIA_PORT_OFFSET;
extern const int DEFAULT_NX_AUX_PORT_OFFSET;
extern const int DEFAULT_NX_HTTP_PORT_OFFSET;
extern const int DEFAULT_NX_FONT_PORT_OFFSET;
extern const int DEFAULT_NX_EXTRA1_PORT_OFFSET;
extern const int DEFAULT_NX_EXTRA2_PORT_OFFSET;
extern const int DEFAULT_NX_EXTRA3_PORT_OFFSET;
//
// Slave channels can be originated by both sides
......
......@@ -761,6 +761,18 @@ const char *Proxy::getTypeName(T_channel_type type)
{
return "HTTP";
}
case channel_extra1:
{
return "EXTRA1";
}
case channel_extra2:
{
return "EXTRA2";
}
case channel_extra3:
{
return "EXTRA3";
}
case channel_font:
{
return "font";
......@@ -1477,6 +1489,24 @@ int Proxy::handleControlFromProxy(const unsigned char *message)
break;
}
case code_new_extra1_connection:
{
channelType = channel_extra1;
break;
}
case code_new_extra2_connection:
{
channelType = channel_extra2;
break;
}
case code_new_extra3_connection:
{
channelType = channel_extra3;
break;
}
case code_new_font_connection:
{
channelType = channel_font;
......@@ -4482,6 +4512,9 @@ int Proxy::handleControl(T_proxy_code code, int data)
case code_new_smb_connection:
case code_new_media_connection:
case code_new_http_connection:
case code_new_extra1_connection:
case code_new_extra2_connection:
case code_new_extra3_connection:
case code_new_font_connection:
case code_new_slave_connection:
......@@ -6018,6 +6051,24 @@ int Proxy::handleNewGenericConnection(int clientFd, T_channel_type type, const c
break;
}
case channel_extra1:
{
channels_[channelId] = new Extra1Channel(transports_[channelId], compressor_);
break;
}
case channel_extra2:
{
channels_[channelId] = new Extra2Channel(transports_[channelId], compressor_);
break;
}
case channel_extra3:
{
channels_[channelId] = new Extra3Channel(transports_[channelId], compressor_);
break;
}
case channel_font:
{
channels_[channelId] = new FontChannel(transports_[channelId], compressor_);
......@@ -6087,6 +6138,33 @@ int Proxy::handleNewGenericConnection(int clientFd, T_channel_type type, const c
break;
}
case channel_extra1:
{
if (handleControl(code_new_extra1_connection, channelId) < 0)
{
return -1;
}
break;
}
case channel_extra2:
{
if (handleControl(code_new_extra2_connection, channelId) < 0)
{
return -1;
}
break;
}
case channel_extra3:
{
if (handleControl(code_new_extra3_connection, channelId) < 0)
{
return -1;
}
break;
}
case channel_font:
{
if (handleControl(code_new_font_connection, channelId) < 0)
......@@ -6502,6 +6580,24 @@ int Proxy::handlePostConnectionFromProxy(int channelId, int serverFd,
break;
}
case channel_extra1:
{
channels_[channelId] = new Extra1Channel(transports_[channelId], compressor_);
break;
}
case channel_extra2:
{
channels_[channelId] = new Extra2Channel(transports_[channelId], compressor_);
break;
}
case channel_extra3:
{
channels_[channelId] = new Extra3Channel(transports_[channelId], compressor_);
break;
}
case channel_font:
{
channels_[channelId] = new FontChannel(transports_[channelId], compressor_);
......
......@@ -131,6 +131,9 @@ typedef enum
code_split_token_reply,
code_data_token_request,
code_data_token_reply,
code_new_extra1_connection,
code_new_extra2_connection,
code_new_extra3_connection,
code_last_tag
} T_proxy_code;
......@@ -271,7 +274,10 @@ class Proxy
ChannelEndPoint &smbServerPort,
ChannelEndPoint &mediaServerPort,
ChannelEndPoint &httpServerPort,
const char *fontServerPort) = 0;
const char *fontServerPort,
ChannelEndPoint &extra1ServerPort,
ChannelEndPoint &extra2ServerPort,
ChannelEndPoint &extra3ServerPort) = 0;
//
// Create new tunneled channels.
......
......@@ -68,6 +68,10 @@ ServerProxy::ServerProxy(int proxyFd) : Proxy(proxyFd)
mediaServerPort_ = NULL;
httpServerPort_ = NULL;
extra1ServerPort_ = NULL;
extra2ServerPort_ = NULL;
extra3ServerPort_ = NULL;
fontServerPort_ = NULL;
#ifdef DEBUG
......@@ -117,13 +121,20 @@ void ServerProxy::handlePortConfiguration(ChannelEndPoint &cupsServerPort,
ChannelEndPoint &smbServerPort,
ChannelEndPoint &mediaServerPort,
ChannelEndPoint &httpServerPort,
const char *fontServerPort)
const char *fontServerPort,
ChannelEndPoint &extra1ServerPort,
ChannelEndPoint &extra2ServerPort,
ChannelEndPoint &extra3ServerPort)
{
cupsServerPort_ = cupsServerPort;
smbServerPort_ = smbServerPort;
mediaServerPort_ = mediaServerPort;
httpServerPort_ = httpServerPort;
extra1ServerPort_ = extra1ServerPort;
extra2ServerPort_ = extra2ServerPort;
extra3ServerPort_ = extra3ServerPort;
delete [] fontServerPort_;
fontServerPort_ = new char[strlen(fontServerPort) + 1];
......@@ -133,8 +144,11 @@ void ServerProxy::handlePortConfiguration(ChannelEndPoint &cupsServerPort,
#ifdef DEBUG
*logofs << "ServerProxy: Set port configuration to CUPS "
<< cupsServerPort_ << ", SMB " << smbServerPort_
<< ", media " << mediaServerPort_ << ", HTTP "
<< httpServerPort_ << ".\n"
<< ", media " << mediaServerPort_
<< ", HTTP " << httpServerPort_
<< ", extra1 " << extra1ServerPort_
<< ", extra2 " << extra2ServerPort_
<< ", extra3 " << extra3ServerPort_ << ".\n"
<< logofs_flush;
#endif
}
......@@ -195,6 +209,21 @@ int ServerProxy::handleNewConnectionFromProxy(T_channel_type type, int channelId
return handleNewGenericConnectionFromProxy(channelId, channel_http,
httpServerPort_, "HTTP");
}
case channel_extra1:
{
return handleNewGenericConnectionFromProxy(channelId, channel_extra1,
extra1ServerPort_, "EXTRA1");
}
case channel_extra2:
{
return handleNewGenericConnectionFromProxy(channelId, channel_extra2,
extra2ServerPort_, "EXTRA2");
}
case channel_extra3:
{
return handleNewGenericConnectionFromProxy(channelId, channel_extra3,
extra3ServerPort_, "EXTRA3");
}
case channel_slave:
{
return handleNewSlaveConnectionFromProxy(channelId);
......
......@@ -56,7 +56,10 @@ class ServerProxy : public Proxy
ChannelEndPoint &smbServerPort,
ChannelEndPoint &mediaServerPort,
ChannelEndPoint &httpServerPort,
const char *fontServerPort);
const char *fontServerPort,
ChannelEndPoint &extra1ServerPort,
ChannelEndPoint &extra2ServerPort,
ChannelEndPoint &extra3ServerPort);
protected:
......@@ -141,6 +144,9 @@ class ServerProxy : public Proxy
ChannelEndPoint smbServerPort_;
ChannelEndPoint mediaServerPort_;
ChannelEndPoint httpServerPort_;
ChannelEndPoint extra1ServerPort_;
ChannelEndPoint extra2ServerPort_;
ChannelEndPoint extra3ServerPort_;
//
// It will have to be passed to the channel
......
......@@ -153,6 +153,18 @@ Statistics::Statistics(Proxy *proxy) : proxy_(proxy)
protocolPartial_.httpBitsIn_ = 0;
protocolPartial_.httpBitsOut_ = 0;
protocolPartial_.extra1Count_ = 0;
protocolPartial_.extra1BitsIn_ = 0;
protocolPartial_.extra1BitsOut_ = 0;
protocolPartial_.extra2Count_ = 0;
protocolPartial_.extra2BitsIn_ = 0;
protocolPartial_.extra2BitsOut_ = 0;
protocolPartial_.extra3Count_ = 0;
protocolPartial_.extra3BitsIn_ = 0;
protocolPartial_.extra3BitsOut_ = 0;
protocolPartial_.fontCount_ = 0;
protocolPartial_.fontBitsIn_ = 0;
protocolPartial_.fontBitsOut_ = 0;
......@@ -177,6 +189,18 @@ Statistics::Statistics(Proxy *proxy) : proxy_(proxy)
protocolTotal_.httpBitsIn_ = 0;
protocolTotal_.httpBitsOut_ = 0;
protocolTotal_.extra1Count_ = 0;
protocolTotal_.extra1BitsIn_ = 0;
protocolTotal_.extra1BitsOut_ = 0;
protocolTotal_.extra2Count_ = 0;
protocolTotal_.extra2BitsIn_ = 0;
protocolTotal_.extra2BitsOut_ = 0;
protocolTotal_.extra3Count_ = 0;
protocolTotal_.extra3BitsIn_ = 0;
protocolTotal_.extra3BitsOut_ = 0;
protocolTotal_.fontCount_ = 0;
protocolTotal_.fontBitsIn_ = 0;
protocolTotal_.fontBitsOut_ = 0;
......@@ -287,6 +311,18 @@ int Statistics::resetPartialStats()
protocolPartial_.httpBitsIn_ = 0;
protocolPartial_.httpBitsOut_ = 0;
protocolPartial_.extra1Count_ = 0;
protocolPartial_.extra1BitsIn_ = 0;
protocolPartial_.extra1BitsOut_ = 0;
protocolPartial_.extra2Count_ = 0;
protocolPartial_.extra2BitsIn_ = 0;
protocolPartial_.extra2BitsOut_ = 0;
protocolPartial_.extra3Count_ = 0;
protocolPartial_.extra3BitsIn_ = 0;
protocolPartial_.extra3BitsOut_ = 0;
protocolPartial_.fontCount_ = 0;
protocolPartial_.fontBitsIn_ = 0;
protocolPartial_.fontBitsOut_ = 0;
......@@ -957,6 +993,18 @@ int Statistics::getClientProtocolStats(int type, char *&buffer)
countBitsIn += protocolData -> httpBitsIn_;
countBitsOut += protocolData -> httpBitsOut_;
countAnyIn += protocolData -> extra1Count_;
countBitsIn += protocolData -> extra1BitsIn_;
countBitsOut += protocolData -> extra1BitsOut_;
countAnyIn += protocolData -> extra2Count_;
countBitsIn += protocolData -> extra2BitsIn_;
countBitsOut += protocolData -> extra2BitsOut_;
countAnyIn += protocolData -> extra3Count_;
countBitsIn += protocolData -> extra3BitsIn_;
countBitsOut += protocolData -> extra3BitsOut_;
countAnyIn += protocolData -> fontCount_;
countBitsIn += protocolData -> fontBitsIn_;
countBitsOut += protocolData -> fontBitsOut_;
......@@ -1618,6 +1666,18 @@ int Statistics::getServerProtocolStats(int type, char *&buffer)
countBitsIn += protocolData -> httpBitsIn_;
countBitsOut += protocolData -> httpBitsOut_;
countAnyIn += protocolData -> extra1Count_;
countBitsIn += protocolData -> extra1BitsIn_;
countBitsOut += protocolData -> extra1BitsOut_;
countAnyIn += protocolData -> extra2Count_;
countBitsIn += protocolData -> extra2BitsIn_;
countBitsOut += protocolData -> extra2BitsOut_;
countAnyIn += protocolData -> extra3Count_;
countBitsIn += protocolData -> extra3BitsIn_;
countBitsOut += protocolData -> extra3BitsOut_;
countAnyIn += protocolData -> fontCount_;
countBitsIn += protocolData -> fontBitsIn_;
countBitsOut += protocolData -> fontBitsOut_;
......@@ -1873,6 +1933,36 @@ int Statistics::getServicesStats(int type, char *&buffer)
strcat(buffer, format);
}
if (protocolData -> extra1BitsOut_ > 0)
{
sprintf(format, " %.0f EXTRA1 messages, %.0f bytes (%.0f KB) in, %.0f bytes (%.0f KB) out.\n\n",
protocolData -> extra1Count_ , protocolData -> extra1BitsIn_ / 8,
protocolData -> extra1BitsIn_ / 8192, protocolData -> extra1BitsOut_ / 8,
protocolData -> extra1BitsOut_ / 8192);
strcat(buffer, format);
}
if (protocolData -> extra2BitsOut_ > 0)
{
sprintf(format, " %.0f EXTRA2 messages, %.0f bytes (%.0f KB) in, %.0f bytes (%.0f KB) out.\n\n",
protocolData -> extra2Count_ , protocolData -> extra2BitsIn_ / 8,
protocolData -> extra2BitsIn_ / 8192, protocolData -> extra2BitsOut_ / 8,
protocolData -> extra2BitsOut_ / 8192);
strcat(buffer, format);
}
if (protocolData -> extra3BitsOut_ > 0)
{
sprintf(format, " %.0f EXTRA3 messages, %.0f bytes (%.0f KB) in, %.0f bytes (%.0f KB) out.\n\n",
protocolData -> extra3Count_ , protocolData -> extra3BitsIn_ / 8,
protocolData -> extra3BitsIn_ / 8192, protocolData -> extra3BitsOut_ / 8,
protocolData -> extra3BitsOut_ / 8192);
strcat(buffer, format);
}
if (protocolData -> fontBitsOut_ > 0)
{
sprintf(format, " %.0f font server messages, %.0f bytes (%.0f KB) in, %.0f bytes (%.0f KB) out.\n\n",
......
......@@ -346,6 +346,42 @@ class Statistics
protocolTotal_.httpBitsOut_ += bitsOut;
}
void addExtra1Bits(unsigned int bitsIn, unsigned int bitsOut)
{
protocolPartial_.extra1Count_++;
protocolTotal_.extra1Count_++;
protocolPartial_.extra1BitsIn_ += bitsIn;
protocolTotal_.extra1BitsIn_ += bitsIn;
protocolPartial_.extra1BitsOut_ += bitsOut;
protocolTotal_.extra1BitsOut_ += bitsOut;
}
void addExtra2Bits(unsigned int bitsIn, unsigned int bitsOut)
{
protocolPartial_.extra2Count_++;
protocolTotal_.extra2Count_++;
protocolPartial_.extra2BitsIn_ += bitsIn;
protocolTotal_.extra2BitsIn_ += bitsIn;
protocolPartial_.extra2BitsOut_ += bitsOut;
protocolTotal_.extra2BitsOut_ += bitsOut;
}
void addExtra3Bits(unsigned int bitsIn, unsigned int bitsOut)
{
protocolPartial_.extra3Count_++;
protocolTotal_.extra3Count_++;
protocolPartial_.extra3BitsIn_ += bitsIn;
protocolTotal_.extra3BitsIn_ += bitsIn;
protocolPartial_.extra3BitsOut_ += bitsOut;
protocolTotal_.extra3BitsOut_ += bitsOut;
}
void addFontBits(unsigned int bitsIn, unsigned int bitsOut)
{
protocolPartial_.fontCount_++;
......@@ -495,6 +531,9 @@ class Statistics
protocolTotal_.smbBitsOut_ +
protocolTotal_.mediaBitsOut_ +
protocolTotal_.httpBitsOut_ +
protocolTotal_.extra1BitsOut_ +
protocolTotal_.extra2BitsOut_ +
protocolTotal_.extra3BitsOut_ +
protocolTotal_.fontBitsOut_ +
protocolTotal_.slaveBitsOut_) / 8;
......@@ -636,6 +675,18 @@ class Statistics
double httpBitsIn_;
double httpBitsOut_;
double extra1Count_;
double extra1BitsIn_;
double extra1BitsOut_;
double extra2Count_;
double extra2BitsIn_;
double extra2BitsOut_;
double extra3Count_;
double extra3BitsIn_;
double extra3BitsOut_;
double fontCount_;
double fontBitsIn_;
double fontBitsOut_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment