bring the rdp5 packets through the various layers
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@732 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
parent
73ce8ad4d6
commit
125922c748
51
iso.c
51
iso.c
@ -72,58 +72,44 @@ iso_send_connection_request(char *username)
|
||||
|
||||
/* Receive a message on the ISO layer, return code */
|
||||
static STREAM
|
||||
iso_recv_msg(uint8 * code)
|
||||
iso_recv_msg(uint8 * code, uint8 * rdpver)
|
||||
{
|
||||
STREAM s;
|
||||
uint16 length;
|
||||
uint8 version;
|
||||
|
||||
next_packet:
|
||||
s = tcp_recv(NULL, 4);
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
in_uint8(s, version);
|
||||
switch (version & 3)
|
||||
if (rdpver != NULL)
|
||||
*rdpver = version;
|
||||
if (version == 3)
|
||||
{
|
||||
in_uint8s(s, 1); /* pad */
|
||||
in_uint16_be(s, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
case 0:
|
||||
in_uint8(s, length);
|
||||
if (length & 0x80)
|
||||
{
|
||||
length &= ~0x80;
|
||||
next_be(s, length);
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
in_uint8s(s, 1); /* pad */
|
||||
in_uint16_be(s, length);
|
||||
break;
|
||||
|
||||
default:
|
||||
error("TPKT v%d\n", version);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s = tcp_recv(s, length - 4);
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((version & 3) == 0)
|
||||
{
|
||||
rdp5_process(s, version & 0x80);
|
||||
goto next_packet;
|
||||
}
|
||||
|
||||
if (version != 3)
|
||||
return s;
|
||||
in_uint8s(s, 1); /* hdrlen */
|
||||
in_uint8(s, *code);
|
||||
|
||||
if (*code == ISO_PDU_DT)
|
||||
{
|
||||
in_uint8s(s, 1); /* eot */
|
||||
return s;
|
||||
}
|
||||
|
||||
in_uint8s(s, 5); /* dst_ref, src_ref, class */
|
||||
return s;
|
||||
}
|
||||
@ -162,21 +148,22 @@ iso_send(STREAM s)
|
||||
|
||||
/* Receive ISO transport data packet */
|
||||
STREAM
|
||||
iso_recv(void)
|
||||
iso_recv(uint8 * rdpver)
|
||||
{
|
||||
STREAM s;
|
||||
uint8 code;
|
||||
uint8 code = 0;
|
||||
|
||||
s = iso_recv_msg(&code);
|
||||
s = iso_recv_msg(&code, rdpver);
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
if (rdpver != NULL)
|
||||
if (*rdpver != 3)
|
||||
return s;
|
||||
if (code != ISO_PDU_DT)
|
||||
{
|
||||
error("expected DT, got 0x%x\n", code);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -184,14 +171,14 @@ iso_recv(void)
|
||||
BOOL
|
||||
iso_connect(char *server, char *username)
|
||||
{
|
||||
uint8 code;
|
||||
uint8 code = 0;
|
||||
|
||||
if (!tcp_connect(server))
|
||||
return False;
|
||||
|
||||
iso_send_connection_request(username);
|
||||
|
||||
if (iso_recv_msg(&code) == NULL)
|
||||
if (iso_recv_msg(&code, NULL) == NULL)
|
||||
return False;
|
||||
|
||||
if (code != ISO_PDU_CC)
|
||||
|
16
mcs.c
16
mcs.c
@ -154,7 +154,7 @@ mcs_recv_connect_response(STREAM mcs_data)
|
||||
int length;
|
||||
STREAM s;
|
||||
|
||||
s = iso_recv();
|
||||
s = iso_recv(NULL);
|
||||
if (s == NULL)
|
||||
return False;
|
||||
|
||||
@ -227,7 +227,7 @@ mcs_recv_aucf(uint16 * mcs_userid)
|
||||
uint8 opcode, result;
|
||||
STREAM s;
|
||||
|
||||
s = iso_recv();
|
||||
s = iso_recv(NULL);
|
||||
if (s == NULL)
|
||||
return False;
|
||||
|
||||
@ -276,7 +276,7 @@ mcs_recv_cjcf(void)
|
||||
uint8 opcode, result;
|
||||
STREAM s;
|
||||
|
||||
s = iso_recv();
|
||||
s = iso_recv(NULL);
|
||||
if (s == NULL)
|
||||
return False;
|
||||
|
||||
@ -341,15 +341,17 @@ mcs_send(STREAM s)
|
||||
|
||||
/* Receive an MCS transport data packet */
|
||||
STREAM
|
||||
mcs_recv(uint16 * channel)
|
||||
mcs_recv(uint16 * channel, uint8 * rdpver)
|
||||
{
|
||||
uint8 opcode, appid, length;
|
||||
STREAM s;
|
||||
|
||||
s = iso_recv();
|
||||
s = iso_recv(rdpver);
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
if (rdpver != NULL)
|
||||
if (*rdpver != 3)
|
||||
return s;
|
||||
in_uint8(s, opcode);
|
||||
appid = opcode >> 2;
|
||||
if (appid != MCS_SDIN)
|
||||
@ -360,14 +362,12 @@ mcs_recv(uint16 * channel)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
in_uint8s(s, 2); /* userid */
|
||||
in_uint16_be(s, *channel);
|
||||
in_uint8s(s, 1); /* flags */
|
||||
in_uint8(s, length);
|
||||
if (length & 0x80)
|
||||
in_uint8s(s, 1); /* second byte of length */
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
8
proto.h
8
proto.h
@ -39,7 +39,7 @@ int get_current_workarea(uint32 * x, uint32 * y, uint32 * width, uint32 * height
|
||||
/* iso.c */
|
||||
STREAM iso_init(int length);
|
||||
void iso_send(STREAM s);
|
||||
STREAM iso_recv(void);
|
||||
STREAM iso_recv(uint8 * rdpver);
|
||||
BOOL iso_connect(char *server, char *username);
|
||||
void iso_disconnect(void);
|
||||
/* licence.c */
|
||||
@ -48,7 +48,7 @@ void licence_process(STREAM s);
|
||||
STREAM mcs_init(int length);
|
||||
void mcs_send_to_channel(STREAM s, uint16 channel);
|
||||
void mcs_send(STREAM s);
|
||||
STREAM mcs_recv(uint16 * channel);
|
||||
STREAM mcs_recv(uint16 * channel, uint8 * rdpver);
|
||||
BOOL mcs_connect(char *server, STREAM mcs_data, char *username);
|
||||
void mcs_disconnect(void);
|
||||
/* orders.c */
|
||||
@ -91,7 +91,7 @@ int rd_write_file(int fd, void* ptr, int len);
|
||||
int rd_lseek_file(int fd, int offset);
|
||||
BOOL rd_lock_file(int fd, int start, int len);
|
||||
/* rdp5.c */
|
||||
void rdp5_process(STREAM s, BOOL encryption);
|
||||
void rdp5_process(STREAM s);
|
||||
/* rdp.c */
|
||||
void rdp_out_unistr(STREAM s, char *string, int len);
|
||||
int rdp_in_unistr(STREAM s, char *string, int uni_len);
|
||||
@ -138,7 +138,7 @@ STREAM sec_init(uint32 flags, int maxlen);
|
||||
void sec_send_to_channel(STREAM s, uint32 flags, uint16 channel);
|
||||
void sec_send(STREAM s, uint32 flags);
|
||||
void sec_process_mcs_data(STREAM s);
|
||||
STREAM sec_recv(void);
|
||||
STREAM sec_recv(uint8 * rdpver);
|
||||
BOOL sec_connect(char *server, char *username);
|
||||
void sec_disconnect(void);
|
||||
/* serial.c */
|
||||
|
50
rdp.c
50
rdp.c
@ -51,12 +51,20 @@ rdp_recv(uint8 * type)
|
||||
{
|
||||
static STREAM rdp_s;
|
||||
uint16 length, pdu_type;
|
||||
uint8 rdpver;
|
||||
|
||||
if ((rdp_s == NULL) || (g_next_packet >= rdp_s->end))
|
||||
{
|
||||
rdp_s = sec_recv();
|
||||
rdp_s = sec_recv(&rdpver);
|
||||
if (rdp_s == NULL)
|
||||
return NULL;
|
||||
if (rdpver != 3)
|
||||
{
|
||||
/* rdp5_process should move g_next_packet ok */
|
||||
rdp5_process(rdp_s);
|
||||
*type = 0;
|
||||
return rdp_s;
|
||||
}
|
||||
|
||||
g_next_packet = rdp_s->p;
|
||||
}
|
||||
@ -1135,47 +1143,15 @@ process_data_pdu(STREAM s, uint32 * ext_disc_reason)
|
||||
}
|
||||
|
||||
/* Process incoming packets */
|
||||
/* nevers gets out of here till app is done */
|
||||
void
|
||||
rdp_main_loop(BOOL * deactivated, uint32 * ext_disc_reason)
|
||||
{
|
||||
uint8 type;
|
||||
BOOL disc = False; /* True when a disconnect PDU was received */
|
||||
STREAM s;
|
||||
|
||||
while ((s = rdp_recv(&type)) != NULL)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case RDP_PDU_DEMAND_ACTIVE:
|
||||
process_demand_active(s);
|
||||
*deactivated = False;
|
||||
break;
|
||||
|
||||
case RDP_PDU_DEACTIVATE:
|
||||
DEBUG(("RDP_PDU_DEACTIVATE\n"));
|
||||
*deactivated = True;
|
||||
break;
|
||||
|
||||
case RDP_PDU_DATA:
|
||||
disc = process_data_pdu(s, ext_disc_reason);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
break;
|
||||
|
||||
default:
|
||||
unimpl("PDU %d\n", type);
|
||||
}
|
||||
|
||||
if (disc)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
while (rdp_loop(deactivated, ext_disc_reason))
|
||||
;
|
||||
}
|
||||
|
||||
/* used in uiports, processes the rdp packets waiting */
|
||||
/* used in uiports and rdp_main_loop, processes the rdp packets waiting */
|
||||
BOOL
|
||||
rdp_loop(BOOL * deactivated, uint32 * ext_disc_reason)
|
||||
{
|
||||
|
8
rdp5.c
8
rdp5.c
@ -26,7 +26,7 @@ extern uint8 *g_next_packet;
|
||||
extern RDPCOMP g_mppc_dict;
|
||||
|
||||
void
|
||||
rdp5_process(STREAM s, BOOL encryption)
|
||||
rdp5_process(STREAM s)
|
||||
{
|
||||
uint16 length, count, x, y;
|
||||
uint8 type, ctype;
|
||||
@ -36,12 +36,6 @@ rdp5_process(STREAM s, BOOL encryption)
|
||||
struct stream *ns = &(g_mppc_dict.ns);
|
||||
struct stream *ts;
|
||||
|
||||
if (encryption)
|
||||
{
|
||||
in_uint8s(s, 8); /* signature */
|
||||
sec_decrypt(s->p, s->end - s->p);
|
||||
}
|
||||
|
||||
#if 0
|
||||
printf("RDP5 data:\n");
|
||||
hexdump(s->p, s->end - s->p);
|
||||
|
16
secure.c
16
secure.c
@ -820,14 +820,26 @@ sec_process_mcs_data(STREAM s)
|
||||
|
||||
/* Receive secure transport packet */
|
||||
STREAM
|
||||
sec_recv(void)
|
||||
sec_recv(uint8 * rdpver)
|
||||
{
|
||||
uint32 sec_flags;
|
||||
uint16 channel;
|
||||
STREAM s;
|
||||
|
||||
while ((s = mcs_recv(&channel)) != NULL)
|
||||
while ((s = mcs_recv(&channel, rdpver)) != NULL)
|
||||
{
|
||||
if (rdpver != NULL)
|
||||
{
|
||||
if (*rdpver != 3)
|
||||
{
|
||||
if (*rdpver & 0x80)
|
||||
{
|
||||
in_uint8s(s, 8); /* signature */
|
||||
sec_decrypt(s->p, s->end - s->p);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
if (g_encryption || !g_licence_issued)
|
||||
{
|
||||
in_uint32_le(s, sec_flags);
|
||||
|
Loading…
Reference in New Issue
Block a user