summaryrefslogtreecommitdiffstats
path: root/libxrdp
diff options
context:
space:
mode:
authorspeidy <speidy@gmail.com>2014-02-10 05:48:03 +0200
committerspeidy <speidy@gmail.com>2014-02-10 05:48:03 +0200
commitf525c0f8e76b1e2b8294c4a61c0da4d24e0406b4 (patch)
tree9ced797c5cfd480352a73866ebec3a0d86ca4016 /libxrdp
parentcbf5d50a5c96de83178e910318db540334f289b1 (diff)
downloadxrdp-proprietary-f525c0f8e76b1e2b8294c4a61c0da4d24e0406b4.tar.gz
xrdp-proprietary-f525c0f8e76b1e2b8294c4a61c0da4d24e0406b4.zip
libxrdp: work on fastpath input
Diffstat (limited to 'libxrdp')
-rw-r--r--libxrdp/libxrdp.c9
-rw-r--r--libxrdp/libxrdp.h3
-rw-r--r--libxrdp/xrdp_fastpath.c2
-rw-r--r--libxrdp/xrdp_rdp.c88
-rw-r--r--libxrdp/xrdp_sec.c1
5 files changed, 86 insertions, 17 deletions
diff --git a/libxrdp/libxrdp.c b/libxrdp/libxrdp.c
index c220f56f..5e7e72a1 100644
--- a/libxrdp/libxrdp.c
+++ b/libxrdp/libxrdp.c
@@ -137,6 +137,15 @@ libxrdp_process_data(struct xrdp_session *session)
}
break;
+ case 2: /* FASTPATH_INPUT_EVENT */
+ if (xrdp_rdp_process_fastpath_data_input((struct xrdp_rdp *)session->rdp,
+ session->s) != 0)
+ {
+ DEBUG(("libxrdp_process_data returned non zero"));
+ cont = 0;
+ term = 1;
+ }
+ break;
default:
g_writeln("unknown in libxrdp_process_data: code= %d", code);
dead_lock_counter++;
diff --git a/libxrdp/libxrdp.h b/libxrdp/libxrdp.h
index b15cc989..4059dbed 100644
--- a/libxrdp/libxrdp.h
+++ b/libxrdp/libxrdp.h
@@ -82,6 +82,7 @@ struct xrdp_fastpath
struct xrdp_tcp* tcp_layer;
int numEvents;
int secFlags;
+ int firstPacket;
};
/* sec */
@@ -373,6 +374,8 @@ xrdp_rdp_process_confirm_active(struct xrdp_rdp* self, struct stream* s);
int APP_CC
xrdp_rdp_process_data(struct xrdp_rdp* self, struct stream* s);
int APP_CC
+xrdp_rdp_process_fastpath_data_input(struct xrdp_rdp *self, struct stream *s);
+int APP_CC
xrdp_rdp_disconnect(struct xrdp_rdp* self);
int APP_CC
xrdp_rdp_send_deactive(struct xrdp_rdp* self);
diff --git a/libxrdp/xrdp_fastpath.c b/libxrdp/xrdp_fastpath.c
index c8b4927d..0d5c58c3 100644
--- a/libxrdp/xrdp_fastpath.c
+++ b/libxrdp/xrdp_fastpath.c
@@ -88,7 +88,7 @@ xrdp_fastpath_recv(struct xrdp_fastpath *self, struct stream *s)
}
// receive the left bytes
- if (xrdp_tcp_recv(self->tcp_layer, s, len) != 0)
+ if (xrdp_tcp_recv(self->tcp_layer, s, len - (s->p - s->data)) != 0)
{
return 1;
}
diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c
index f98a5dce..e4d79159 100644
--- a/libxrdp/xrdp_rdp.c
+++ b/libxrdp/xrdp_rdp.c
@@ -277,7 +277,9 @@ xrdp_rdp_recv(struct xrdp_rdp *self, struct stream *s, int *code)
if (error == 2) /* we have fastpath packet! */
{
- return xrdp_rdp_recv_fastpath(self, s, code);
+ s->next_packet = 0;
+ *code = 2;
+ return 0;
}
if (error == -1) /* special code for send demand active */
@@ -344,20 +346,6 @@ xrdp_rdp_recv(struct xrdp_rdp *self, struct stream *s, int *code)
}
}
/*****************************************************************************/
-/* returns error */
-int APP_CC
-xrdp_rdp_recv_fastpath(struct xrdp_rdp *self, struct stream *s, int *code)
-{
- int i;
- DEBUG(("in xrdp_rdp_recv_fastpath"));
-// for (i = 0 ; i < self->sec_layer->fastpath_layer->numEvents ; i++) {
-//
-// }
- g_hexdump(s->data, 7);
- DEBUG(("out xrdp_rdp_recv_fastpath"));
- return 1;
-}
-/*****************************************************************************/
int APP_CC
xrdp_rdp_send(struct xrdp_rdp *self, struct stream *s, int pdu_type)
{
@@ -1711,7 +1699,77 @@ xrdp_rdp_send_disconnect_reason(struct xrdp_rdp *self, int reason)
return 0;
}
#endif
+/*****************************************************************************/
+/* FASTPATH_INPUT_EVENT */
+int APP_CC
+xrdp_rdp_process_fastpath_data_input(struct xrdp_rdp *self, struct stream *s)
+{
+ int i;
+ int eventHeader;
+ int eventCode;
+ int eventFlags;
+ int code;
+ int flags;
+
+ // process fastpath input events
+ for (i = 0 ; i < self->sec_layer->fastpath_layer->numEvents ; i++) {
+ in_uint8(s, eventHeader);
+
+ eventFlags = (eventHeader & 0x1F);
+ eventCode = (eventHeader >> 5);
+ g_writeln("eventCode= %d, eventFlags= %d, numEvents= %d", eventCode, eventFlags, self->sec_layer->fastpath_layer->numEvents);
+ switch (eventCode)
+ {
+ case FASTPATH_INPUT_EVENT_SCANCODE:
+ in_uint8(s, code); /* keyCode (1 byte) */
+ g_writeln("scan code detected: %d", code);
+ flags = 0;
+ if ((eventFlags & FASTPATH_INPUT_KBDFLAGS_RELEASE))
+ flags |= KBD_FLAG_UP;
+ else
+ flags |= KBD_FLAG_DOWN;
+
+ if ((eventFlags & FASTPATH_INPUT_KBDFLAGS_EXTENDED))
+ flags |= KBD_FLAG_EXT;
+
+ if (self->session->callback != 0)
+ {
+ /* msg_type can be
+ RDP_INPUT_SYNCHRONIZE - 0
+ RDP_INPUT_SCANCODE - 4
+ RDP_INPUT_MOUSE - 0x8001
+ RDP_INPUT_MOUSEX - 0x8002 */
+ /* call to xrdp_wm.c : callback */
+ self->session->callback(self->session->id, RDP_INPUT_SCANCODE, flags, 0,
+ code, time);
+ }
+ break;
+
+ case FASTPATH_INPUT_EVENT_MOUSE:
+ in_uint8s(s, 6);
+ break;
+
+ case FASTPATH_INPUT_EVENT_MOUSEX:
+ in_uint8s(s, 6);
+ break;
+
+ case FASTPATH_INPUT_EVENT_SYNC:
+
+ break;
+
+ case FASTPATH_INPUT_EVENT_UNICODE:
+ in_uint8s(s, 2);
+ break;
+
+ default:
+ printf("Unknown eventCode %d\n", eventCode);
+ break;
+ }
+
+ }
+ return 0;
+}
/*****************************************************************************/
/* RDP_PDU_DATA */
int APP_CC
diff --git a/libxrdp/xrdp_sec.c b/libxrdp/xrdp_sec.c
index 44eb5812..4846c356 100644
--- a/libxrdp/xrdp_sec.c
+++ b/libxrdp/xrdp_sec.c
@@ -743,7 +743,6 @@ xrdp_sec_recv_fastpath(struct xrdp_sec *self, struct stream *s)
return 1;
}
-
in_uint8s(s, 8); /* dataSignature, skip for now */
if (self->fastpath_layer->secFlags & FASTPATH_INPUT_ENCRYPTED) {