libxrdp: minor fastpath logic change and indent changes

This commit is contained in:
Jay Sorg 2014-03-06 17:51:35 -08:00
parent fe042b0c61
commit 201bec9794
3 changed files with 192 additions and 178 deletions

View File

@ -1,7 +1,7 @@
/** /**
* xrdp: A Remote Desktop Protocol server. * xrdp: A Remote Desktop Protocol server.
* *
* Copyright (C) Jay Sorg 2012-2013 * Copyright (C) Jay Sorg 2012-2014
* Copyright (C) Idan Freiberg 2013-2014 * Copyright (C) Idan Freiberg 2013-2014
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -52,6 +52,7 @@ xrdp_fastpath_reset(struct xrdp_fastpath *self)
{ {
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
int APP_CC int APP_CC
xrdp_fastpath_recv(struct xrdp_fastpath *self, struct stream *s) xrdp_fastpath_recv(struct xrdp_fastpath *self, struct stream *s)
@ -59,8 +60,10 @@ xrdp_fastpath_recv(struct xrdp_fastpath *self, struct stream *s)
int fp_hdr; int fp_hdr;
int len = 0; /* unused */ int len = 0; /* unused */
int byte; int byte;
DEBUG((" in xrdp_fastpath_recv")); char *holdp;
DEBUG((" in xrdp_fastpath_recv"));
holdp = s->p;
if (!s_check_rem(s, 2)) if (!s_check_rem(s, 2))
{ {
return 1; return 1;
@ -88,11 +91,11 @@ xrdp_fastpath_recv(struct xrdp_fastpath *self, struct stream *s)
{ {
len = byte; len = byte;
} }
s->next_packet = holdp + len;
DEBUG((" out xrdp_fastpath_recv")); DEBUG((" out xrdp_fastpath_recv"));
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
int APP_CC int APP_CC
xrdp_fastpath_init(struct xrdp_fastpath *self) xrdp_fastpath_init(struct xrdp_fastpath *self)
@ -283,10 +286,12 @@ xrdp_fastpath_process_EVENT_SCANCODE(struct xrdp_fastpath *self, int eventFlags,
} }
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
/* FASTPATH_INPUT_EVENT_MOUSE */ /* FASTPATH_INPUT_EVENT_MOUSE */
int APP_CC int APP_CC
xrdp_fastpath_process_EVENT_MOUSE(struct xrdp_fastpath *self, int eventFlags, struct stream *s) xrdp_fastpath_process_EVENT_MOUSE(struct xrdp_fastpath *self, int eventFlags,
struct stream *s)
{ {
int pointerFlags; int pointerFlags;
int xPos; int xPos;
@ -308,15 +313,17 @@ xrdp_fastpath_process_EVENT_MOUSE(struct xrdp_fastpath *self, int eventFlags, st
RDP_INPUT_MOUSE - 0x8001 RDP_INPUT_MOUSE - 0x8001
RDP_INPUT_MOUSEX - 0x8002 */ RDP_INPUT_MOUSEX - 0x8002 */
/* call to xrdp_wm.c : callback */ /* call to xrdp_wm.c : callback */
self->session->callback(self->session->id, RDP_INPUT_MOUSE, xPos, yPos, self->session->callback(self->session->id, RDP_INPUT_MOUSE,
pointerFlags, 0); xPos, yPos, pointerFlags, 0);
} }
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
/* FASTPATH_INPUT_EVENT_MOUSEX */ /* FASTPATH_INPUT_EVENT_MOUSEX */
int APP_CC int APP_CC
xrdp_fastpath_process_EVENT_MOUSEX(struct xrdp_fastpath *self, int eventFlags, struct stream *s) xrdp_fastpath_process_EVENT_MOUSEX(struct xrdp_fastpath *self,
int eventFlags, struct stream *s)
{ {
int pointerFlags; int pointerFlags;
int xPos; int xPos;
@ -338,11 +345,12 @@ xrdp_fastpath_process_EVENT_MOUSEX(struct xrdp_fastpath *self, int eventFlags, s
RDP_INPUT_MOUSE - 0x8001 RDP_INPUT_MOUSE - 0x8001
RDP_INPUT_MOUSEX - 0x8002 */ RDP_INPUT_MOUSEX - 0x8002 */
/* call to xrdp_wm.c : callback */ /* call to xrdp_wm.c : callback */
self->session->callback(self->session->id, RDP_INPUT_MOUSEX, xPos, yPos, self->session->callback(self->session->id, RDP_INPUT_MOUSEX,
pointerFlags, 0); xPos, yPos, pointerFlags, 0);
} }
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
/* FASTPATH_INPUT_EVENT_SYNC */ /* FASTPATH_INPUT_EVENT_SYNC */
int APP_CC int APP_CC
@ -361,15 +369,17 @@ xrdp_fastpath_process_EVENT_SYNC(struct xrdp_fastpath *self, int eventCode, int
RDP_INPUT_MOUSE - 0x8001 RDP_INPUT_MOUSE - 0x8001
RDP_INPUT_MOUSEX - 0x8002 */ RDP_INPUT_MOUSEX - 0x8002 */
/* call to xrdp_wm.c : callback */ /* call to xrdp_wm.c : callback */
self->session->callback(self->session->id, RDP_INPUT_SYNCHRONIZE, eventCode, 0, self->session->callback(self->session->id, RDP_INPUT_SYNCHRONIZE,
eventFlags, 0); eventCode, 0, eventFlags, 0);
} }
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
/* FASTPATH_INPUT_EVENT_UNICODE */ /* FASTPATH_INPUT_EVENT_UNICODE */
int APP_CC int APP_CC
xrdp_fastpath_process_EVENT_UNICODE(struct xrdp_fastpath *self, int eventFlags, struct stream *s) xrdp_fastpath_process_EVENT_UNICODE(struct xrdp_fastpath *self,
int eventFlags, struct stream *s)
{ {
if (!s_check_rem(s, 2)) if (!s_check_rem(s, 2))
{ {
@ -378,6 +388,7 @@ xrdp_fastpath_process_EVENT_UNICODE(struct xrdp_fastpath *self, int eventFlags,
in_uint8s(s, 2); in_uint8s(s, 2);
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
/* FASTPATH_INPUT_EVENT */ /* FASTPATH_INPUT_EVENT */
int APP_CC int APP_CC
@ -389,7 +400,8 @@ xrdp_fastpath_process_input_event(struct xrdp_fastpath *self, struct stream *s)
int eventFlags; int eventFlags;
// process fastpath input events // process fastpath input events
for (i = 0 ; i < self->numEvents ; i++) { for (i = 0; i < self->numEvents; i++)
{
if (!s_check_rem(s, 1)) if (!s_check_rem(s, 1))
{ {
return 1; return 1;
@ -439,8 +451,6 @@ xrdp_fastpath_process_input_event(struct xrdp_fastpath *self, struct stream *s)
g_writeln("xrdp_fastpath_process_input_event: unknown eventCode %d", eventCode); g_writeln("xrdp_fastpath_process_input_event: unknown eventCode %d", eventCode);
break; break;
} }
} }
return 0; return 0;
} }

View File

@ -311,7 +311,7 @@ xrdp_rdp_recv(struct xrdp_rdp *self, struct stream *s, int *code)
{ {
return 1; return 1;
} }
s->next_packet = 0; /* next_packet gets set in xrdp_sec_recv_fastpath */
*code = 2; // special code for fastpath input *code = 2; // special code for fastpath input
DEBUG(("out (fastpath) xrdp_rdp_recv")); DEBUG(("out (fastpath) xrdp_rdp_recv"));
return 0; return 0;

View File

@ -959,13 +959,17 @@ xrdp_sec_recv_fastpath(struct xrdp_sec *self, struct stream *s)
int len; int len;
int pad; int pad;
if (xrdp_fastpath_recv(self->fastpath_layer, s) != 0) { LLOGLN(10, ("xrdp_sec_recv_fastpath:"));
if (xrdp_fastpath_recv(self->fastpath_layer, s) != 0)
{
return 1; return 1;
} }
if (self->fastpath_layer->secFlags & FASTPATH_INPUT_ENCRYPTED)
{
if (self->crypt_level == CRYPT_LEVEL_FIPS) if (self->crypt_level == CRYPT_LEVEL_FIPS)
{ {
if (!s_check_rem(s, 4)) if (!s_check_rem(s, 12))
{ {
return 1; return 1;
} }
@ -981,20 +985,20 @@ xrdp_sec_recv_fastpath(struct xrdp_sec *self, struct stream *s)
LLOGLN(10, ("xrdp_sec_recv_fastpath: data len %d", (int)(s->end - s->p))); LLOGLN(10, ("xrdp_sec_recv_fastpath: data len %d", (int)(s->end - s->p)));
xrdp_sec_fips_decrypt(self, s->p, (int)(s->end - s->p)); xrdp_sec_fips_decrypt(self, s->p, (int)(s->end - s->p));
s->end -= pad; s->end -= pad;
} else { }
else
{
if (!s_check_rem(s, 8)) if (!s_check_rem(s, 8))
{ {
return 1; return 1;
} }
in_uint8s(s, 8); /* dataSignature (8 bytes), skip for now */ in_uint8s(s, 8); /* dataSignature (8 bytes), skip for now */
if (self->fastpath_layer->secFlags & FASTPATH_INPUT_ENCRYPTED)
{
xrdp_sec_decrypt(self, s->p, (int)(s->end - s->p)); xrdp_sec_decrypt(self, s->p, (int)(s->end - s->p));
} }
} }
if (self->fastpath_layer->numEvents == 0) { if (self->fastpath_layer->numEvents == 0)
{
/** /**
* If numberEvents is not provided in fpInputHeader, it will be provided * If numberEvents is not provided in fpInputHeader, it will be provided
* as one additional byte here. * as one additional byte here.