summaryrefslogtreecommitdiffstats
path: root/libxrdp
diff options
context:
space:
mode:
authorspeidy <speidy@gmail.com>2014-02-08 20:55:41 +0200
committerspeidy <speidy@gmail.com>2014-02-08 20:55:41 +0200
commit9a98299e2b3bb0c3e4f047efa4ad8f8450656dda (patch)
tree974bd50a67eb278da4f438c3f3fd4b27b920cad2 /libxrdp
parent113f2696fe4103474cb2703e3d2f8848304fdd3d (diff)
downloadxrdp-proprietary-9a98299e2b3bb0c3e4f047efa4ad8f8450656dda.tar.gz
xrdp-proprietary-9a98299e2b3bb0c3e4f047efa4ad8f8450656dda.zip
libxrdp: work on fastpath
Diffstat (limited to 'libxrdp')
-rw-r--r--libxrdp/xrdp_iso.c55
-rw-r--r--libxrdp/xrdp_mcs.c72
-rw-r--r--libxrdp/xrdp_rdp.c25
-rw-r--r--libxrdp/xrdp_sec.c14
4 files changed, 77 insertions, 89 deletions
diff --git a/libxrdp/xrdp_iso.c b/libxrdp/xrdp_iso.c
index 09c08f94..82a76e5f 100644
--- a/libxrdp/xrdp_iso.c
+++ b/libxrdp/xrdp_iso.c
@@ -95,9 +95,14 @@ xrdp_iso_recv_msg(struct xrdp_iso *self, struct stream *s, int *code, int *len)
*len = 0; // X.224 Length Indicator
plen = xrdp_iso_recv_tpkt_header(self, s);
- if (plen == 1)
+
+ if (plen == 2)
{
- DEBUG((" xrdp_iso_recv_msg: error in tpkt header reading"));
+ DEBUG((" xrdp_iso_recv_msg: non-TPKT header detected, we try fastpath"));
+ return plen;
+ }
+
+ if (plen == 1) {
return 1;
}
@@ -118,10 +123,19 @@ xrdp_iso_recv(struct xrdp_iso *self, struct stream *s)
{
int code;
int len;
+ int iso_msg;
DEBUG((" in xrdp_iso_recv"));
- if (xrdp_iso_recv_msg(self, s, &code, &len) != 0)
+ iso_msg = xrdp_iso_recv_msg(self, s, &code, &len);
+
+ if (iso_msg == 2) // non-TPKT header
+ {
+ DEBUG((" out xrdp_iso_recv xrdp_iso_recv_msg return 2, non-TPKT header detected"));
+ return iso_msg;
+ }
+
+ if (iso_msg == 1) // error
{
DEBUG((" out xrdp_iso_recv xrdp_iso_recv_msg return non zero"));
return 1;
@@ -137,38 +151,32 @@ xrdp_iso_recv(struct xrdp_iso *self, struct stream *s)
return 0;
}
/*****************************************************************************/
-/* returns error */
+/* returns packet length or error (1) */
int APP_CC
-xrdp_iso_detect_tpkt(struct xrdp_iso *self, struct stream *s)
+xrdp_iso_recv_tpkt_header(struct xrdp_iso *self, struct stream *s)
{
+ int plen;
int ver;
- DEBUG((" in xrdp_iso_detect_tpkt"));
+ DEBUG((" in xrdp_iso_recv_tpkt_header"));
+
if (xrdp_tcp_recv(self->tcp_layer, s, 1) != 0)
{
return 1;
}
in_uint8_peek(s, ver);
- g_writeln("tpkt version: %x", ver);
+ g_writeln(" tpkt version: %x", ver);
if (ver != 3)
{
- return 1;
+ /*
+ * special error code that means we got non-TPKT header,
+ * so we gonna try fastpath input.
+ */
+ return 2;
}
- DEBUG((" out xrdp_iso_detect_tpkt"));
- return 0;
-}
-/*****************************************************************************/
-/* returns packet length or error (1) */
-int APP_CC
-xrdp_iso_recv_tpkt_header(struct xrdp_iso *self, struct stream *s)
-{
- int plen;
-
- DEBUG((" in xrdp_iso_recv_tpkt_header"));
-
if (xrdp_tcp_recv(self->tcp_layer, s, 3) != 0)
{
return 1;
@@ -374,13 +382,6 @@ xrdp_iso_incoming(struct xrdp_iso *self)
init_stream(s, 8192);
DEBUG((" in xrdp_iso_incoming"));
- if (xrdp_iso_detect_tpkt(self, s) != 0)
- {
- g_writeln("xrdp_iso_incoming: TPKT not detected");
- free_stream(s);
- return 1;
- }
-
if (xrdp_iso_recv_msg(self, s, &code, &len) != 0)
{
DEBUG((" in xrdp_iso_recv_msg error!!"));
diff --git a/libxrdp/xrdp_mcs.c b/libxrdp/xrdp_mcs.c
index 1828b28b..81e8b758 100644
--- a/libxrdp/xrdp_mcs.c
+++ b/libxrdp/xrdp_mcs.c
@@ -122,18 +122,25 @@ xrdp_mcs_recv(struct xrdp_mcs *self, struct stream *s, int *chan)
int len;
int userid;
int chanid;
-
+ int iso_msg;
DEBUG((" in xrdp_mcs_recv"));
while (1)
{
- if (xrdp_iso_recv(self->iso_layer, s) != 0)
+ iso_msg = xrdp_iso_recv(self->iso_layer, s);
+
+ if (iso_msg == 2) // non-TPKT header
{
- free_stream(s);
- return 1;
+ DEBUG((" out xrdp_mcs_recv, non-TPKT header detected, we try fastpath"));
+ return iso_msg;
}
+ if (iso_msg == 1) // error
+ {
+ DEBUG((" out xrdp_mcs_recv, xrdp_iso_recv return non zero"));
+ return 1;
+ }
if (!s_check_rem(s, 1))
{
@@ -322,16 +329,10 @@ xrdp_mcs_recv_connect_initial(struct xrdp_mcs *self)
make_stream(s);
init_stream(s, 16 * 1024);
- if (xrdp_iso_detect_tpkt(self->iso_layer, s) == 0) {
- if (xrdp_iso_recv(self->iso_layer, s) != 0)
- {
- free_stream(s);
- return 1;
- }
- } else {
- g_writeln("xrdp_mcs_recv_connect_initial: TPKT not detected");
- free_stream(s);
- return 1;
+ if (xrdp_iso_recv(self->iso_layer, s) != 0)
+ {
+ free_stream(s);
+ return 1;
}
if (xrdp_mcs_ber_parse_header(self, s, MCS_CONNECT_INITIAL, &len) != 0)
@@ -449,16 +450,10 @@ xrdp_mcs_recv_edrq(struct xrdp_mcs *self)
make_stream(s);
init_stream(s, 8192);
- if (xrdp_iso_detect_tpkt(self->iso_layer, s) == 0) {
- if (xrdp_iso_recv(self->iso_layer, s) != 0)
- {
- free_stream(s);
- return 1;
- }
- } else {
- g_writeln("xrdp_mcs_recv_edrq: TPKT not detected");
- free_stream(s);
- return 1;
+ if (xrdp_iso_recv(self->iso_layer, s) != 0)
+ {
+ free_stream(s);
+ return 1;
}
if (!s_check_rem(s, 1))
@@ -517,19 +512,12 @@ xrdp_mcs_recv_aurq(struct xrdp_mcs *self)
make_stream(s);
init_stream(s, 8192);
- if (xrdp_iso_detect_tpkt(self->iso_layer, s) == 0) {
- if (xrdp_iso_recv(self->iso_layer, s) != 0)
- {
- free_stream(s);
- return 1;
- }
- } else {
- g_writeln("xrdp_mcs_recv_aurq: TPKT not detected");
- free_stream(s);
- return 1;
+ if (xrdp_iso_recv(self->iso_layer, s) != 0)
+ {
+ free_stream(s);
+ return 1;
}
-
if (!s_check_rem(s, 1))
{
free_stream(s);
@@ -611,16 +599,10 @@ xrdp_mcs_recv_cjrq(struct xrdp_mcs *self)
make_stream(s);
init_stream(s, 8192);
- if (xrdp_iso_detect_tpkt(self->iso_layer, s) == 0) {
- if (xrdp_iso_recv(self->iso_layer, s) != 0)
- {
- free_stream(s);
- return 1;
- }
- } else {
- g_writeln("xrdp_mcs_recv_cjrq: TPKT not detected");
- free_stream(s);
- return 1;
+ if (xrdp_iso_recv(self->iso_layer, s) != 0)
+ {
+ free_stream(s);
+ return 1;
}
if (!s_check_rem(s, 1))
diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c
index fa62c9c2..923b0358 100644
--- a/libxrdp/xrdp_rdp.c
+++ b/libxrdp/xrdp_rdp.c
@@ -263,19 +263,6 @@ xrdp_rdp_init_data(struct xrdp_rdp *self, struct stream *s)
int APP_CC
xrdp_rdp_recv(struct xrdp_rdp *self, struct stream *s, int *code)
{
- // Detect TPKT or FastPath
- if (xrdp_iso_detect_tpkt(self->sec_layer->mcs_layer->iso_layer, s) == 0) {
- return xrdp_rdp_recv_tpkt(self, s, code);
- } else {
- return xrdp_rdp_recv_fastpath(self, s, code);
- }
-
-}
-/*****************************************************************************/
-/* returns error */
-int APP_CC
-xrdp_rdp_recv_tpkt(struct xrdp_rdp *self, struct stream *s, int *code)
-{
int error = 0;
int len = 0;
int pdu_code = 0;
@@ -288,6 +275,11 @@ xrdp_rdp_recv_tpkt(struct xrdp_rdp *self, struct stream *s, int *code)
chan = 0;
error = xrdp_sec_recv(self->sec_layer, s, &chan);
+ if (error == 2) /* we have fastpath packet! */
+ {
+ return xrdp_rdp_recv_fastpath(self, s, code);
+ }
+
if (error == -1) /* special code for send demand active */
{
s->next_packet = 0;
@@ -357,7 +349,10 @@ int APP_CC
xrdp_rdp_recv_fastpath(struct xrdp_rdp *self, struct stream *s, int *code)
{
g_writeln("Booyah!");
- return 0;
+ int msg;
+ in_uint8(s, msg);
+ g_writeln("msg= %x", msg);
+ return 1;
}
/*****************************************************************************/
int APP_CC
@@ -793,7 +788,7 @@ xrdp_rdp_send_demand_active(struct xrdp_rdp *self)
INPUT_FLAG_FASTPATH_INPUT 0x0008
INPUT_FLAG_FASTPATH_INPUT2 0x0020 */
flags = 0x0001 | 0x0004;
- if (self->client_info.use_fast_path & 2)
+// if (self->client_info.use_fast_path & 2)
flags |= 0x0008 | 0x0020;
out_uint16_le(s, flags);
out_uint8s(s, 82);
diff --git a/libxrdp/xrdp_sec.c b/libxrdp/xrdp_sec.c
index 38ee93f3..40fedb85 100644
--- a/libxrdp/xrdp_sec.c
+++ b/libxrdp/xrdp_sec.c
@@ -740,12 +740,22 @@ xrdp_sec_recv(struct xrdp_sec *self, struct stream *s, int *chan)
{
int flags;
int len;
+ int mcs_msg;
DEBUG((" in xrdp_sec_recv"));
- if (xrdp_mcs_recv(self->mcs_layer, s, chan) != 0)
+ mcs_msg = xrdp_mcs_recv(self->mcs_layer, s, chan);
+
+ if (mcs_msg == 2)
+ {
+ DEBUG((" out xrdp_sec_recv : non-TPKT msg detected, we try fastpath"));
+// xrdp_sec_recv_fastpath(self->mcs_layer->iso_layer, s);
+ return mcs_msg;
+ }
+
+ if (mcs_msg == 1)
{
- DEBUG((" out xrdp_sec_recv error"));
+ DEBUG((" out xrdp_sec_recv : error"));
return 1;
}