CVS: rdesktop iso.c,1.14,1.15 mcs.c,1.15,1.16 proto.h,1.65,1.66 rdp.c,1.66,1.67 rdp5.c,1.11,1.12 secure.c,1.46,1.47
Jay Sorg <[email protected]>
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15278
Modified Files:
iso.c mcs.c proto.h rdp.c rdp5.c secure.c
Log Message:
bring the rdp5 packets through the various layers
Index: iso.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/iso.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** iso.c 11 Aug 2003 11:08:19 -0000 1.14
--- iso.c 5 Jul 2004 19:09:07 -0000 1.15
***************
*** 73,77 ****
/* Receive a message on the ISO layer, return code */
static STREAM
! iso_recv_msg(uint8 * code)
{
STREAM s;
--- 73,77 ----
/* Receive a message on the ISO layer, return code */
static STREAM
! iso_recv_msg(uint8 * code, uint8 * rdpver)
{
STREAM s;
***************
*** 79,122 ****
uint8 version;
- next_packet:
s = tcp_recv(NULL, 4);
if (s == NULL)
return NULL;
-
in_uint8(s, version);
! switch (version & 3)
{
! 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;
! }
!
in_uint8s(s, 1); /* hdrlen */
in_uint8(s, *code);
-
if (*code == ISO_PDU_DT)
{
--- 79,109 ----
uint8 version;
s = tcp_recv(NULL, 4);
if (s == NULL)
return NULL;
in_uint8(s, version);
! if (rdpver != NULL)
! *rdpver = version;
! if (version == 3)
{
! in_uint8s(s, 1); /* pad */
! in_uint16_be(s, length);
! }
! else
! {
! in_uint8(s, length);
! if (length & 0x80)
! {
! length &= ~0x80;
! next_be(s, length);
! }
}
s = tcp_recv(s, length - 4);
if (s == NULL)
return NULL;
! if (version != 3)
! return s;
in_uint8s(s, 1); /* hdrlen */
in_uint8(s, *code);
if (*code == ISO_PDU_DT)
{
***************
*** 124,128 ****
return s;
}
-
in_uint8s(s, 5); /* dst_ref, src_ref, class */
return s;
--- 111,114 ----
***************
*** 163,175 ****
/* Receive ISO transport data packet */
STREAM
! iso_recv(void)
{
STREAM s;
! uint8 code;
! s = iso_recv_msg(&code);
if (s == NULL)
return NULL;
!
if (code != ISO_PDU_DT)
{
--- 149,163 ----
/* Receive ISO transport data packet */
STREAM
! iso_recv(uint8 * rdpver)
{
STREAM s;
! uint8 code = 0;
! s = iso_recv_msg(&code, rdpver);
if (s == NULL)
return NULL;
! if (rdpver != NULL)
! if (*rdpver != 3)
! return s;
if (code != ISO_PDU_DT)
{
***************
*** 177,181 ****
return NULL;
}
-
return s;
}
--- 165,168 ----
***************
*** 185,189 ****
iso_connect(char *server, char *username)
{
! uint8 code;
if (!tcp_connect(server))
--- 172,176 ----
iso_connect(char *server, char *username)
{
! uint8 code = 0;
if (!tcp_connect(server))
***************
*** 192,196 ****
iso_send_connection_request(username);
! if (iso_recv_msg(&code) == NULL)
return False;
--- 179,183 ----
iso_send_connection_request(username);
! if (iso_recv_msg(&code, NULL) == NULL)
return False;
Index: mcs.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/mcs.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** mcs.c 1 Jul 2003 09:31:24 -0000 1.15
--- mcs.c 5 Jul 2004 19:09:07 -0000 1.16
***************
*** 155,159 ****
STREAM s;
! s = iso_recv();
if (s == NULL)
return False;
--- 155,159 ----
STREAM s;
! s = iso_recv(NULL);
if (s == NULL)
return False;
***************
*** 228,232 ****
STREAM s;
! s = iso_recv();
if (s == NULL)
return False;
--- 228,232 ----
STREAM s;
! s = iso_recv(NULL);
if (s == NULL)
return False;
***************
*** 277,281 ****
STREAM s;
! s = iso_recv();
if (s == NULL)
return False;
--- 277,281 ----
STREAM s;
! s = iso_recv(NULL);
if (s == NULL)
return False;
***************
*** 342,354 ****
/* Receive an MCS transport data packet */
STREAM
! mcs_recv(uint16 * channel)
{
uint8 opcode, appid, length;
STREAM s;
! s = iso_recv();
if (s == NULL)
return NULL;
!
in_uint8(s, opcode);
appid = opcode >> 2;
--- 342,356 ----
/* Receive an MCS transport data packet */
STREAM
! mcs_recv(uint16 * channel, uint8 * rdpver)
{
uint8 opcode, appid, length;
STREAM s;
! s = iso_recv(rdpver);
if (s == NULL)
return NULL;
! if (rdpver != NULL)
! if (*rdpver != 3)
! return s;
in_uint8(s, opcode);
appid = opcode >> 2;
***************
*** 361,365 ****
return NULL;
}
-
in_uint8s(s, 2); /* userid */
in_uint16_be(s, *channel);
--- 363,366 ----
***************
*** 368,372 ****
if (length & 0x80)
in_uint8s(s, 1); /* second byte of length */
-
return s;
}
--- 369,372 ----
Index: proto.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/proto.h,v
retrieving revision 1.65
retrieving revision 1.66
diff -C2 -d -r1.65 -r1.66
*** proto.h 27 Jun 2004 17:51:54 -0000 1.65
--- proto.h 5 Jul 2004 19:09:07 -0000 1.66
***************
*** 40,44 ****
STREAM iso_init(int length);
void iso_send(STREAM s);
! STREAM iso_recv(void);
BOOL iso_connect(char *server, char *username);
void iso_disconnect(void);
--- 40,44 ----
STREAM iso_init(int length);
void iso_send(STREAM s);
! STREAM iso_recv(uint8 * rdpver);
BOOL iso_connect(char *server, char *username);
void iso_disconnect(void);
***************
*** 49,53 ****
void mcs_send_to_channel(STREAM s, uint16 channel);
void mcs_send(STREAM s);
! STREAM mcs_recv(uint16 * channel);
BOOL mcs_connect(char *server, STREAM mcs_data, char *username);
void mcs_disconnect(void);
--- 49,53 ----
void mcs_send_to_channel(STREAM s, uint16 channel);
void mcs_send(STREAM s);
! STREAM mcs_recv(uint16 * channel, uint8 * rdpver);
BOOL mcs_connect(char *server, STREAM mcs_data, char *username);
void mcs_disconnect(void);
***************
*** 92,96 ****
BOOL rd_lock_file(int fd, int start, int len);
/* rdp5.c */
! void rdp5_process(STREAM s, BOOL encryption);
/* rdp.c */
void rdp_out_unistr(STREAM s, char *string, int len);
--- 92,96 ----
BOOL rd_lock_file(int fd, int start, int len);
/* rdp5.c */
! void rdp5_process(STREAM s);
/* rdp.c */
void rdp_out_unistr(STREAM s, char *string, int len);
***************
*** 139,143 ****
void sec_send(STREAM s, uint32 flags);
void sec_process_mcs_data(STREAM s);
! STREAM sec_recv(void);
BOOL sec_connect(char *server, char *username);
void sec_disconnect(void);
--- 139,143 ----
void sec_send(STREAM s, uint32 flags);
void sec_process_mcs_data(STREAM s);
! STREAM sec_recv(uint8 * rdpver);
BOOL sec_connect(char *server, char *username);
void sec_disconnect(void);
Index: rdp.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdp.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -C2 -d -r1.66 -r1.67
*** rdp.c 29 Jun 2004 16:22:41 -0000 1.66
--- rdp.c 5 Jul 2004 19:09:07 -0000 1.67
***************
*** 52,61 ****
static STREAM rdp_s;
uint16 length, pdu_type;
if ((rdp_s == NULL) || (g_next_packet >= rdp_s->end))
{
! rdp_s = sec_recv();
if (rdp_s == NULL)
return NULL;
g_next_packet = rdp_s->p;
--- 52,69 ----
static STREAM rdp_s;
uint16 length, pdu_type;
+ uint8 rdpver;
if ((rdp_s == NULL) || (g_next_packet >= rdp_s->end))
{
! 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;
***************
*** 1136,1180 ****
/* Process incoming packets */
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;
}
! /* used in uiports, processes the rdp packets waiting */
BOOL
rdp_loop(BOOL * deactivated, uint32 * ext_disc_reason)
--- 1144,1156 ----
/* Process incoming packets */
+ /* nevers gets out of here till app is done */
void
rdp_main_loop(BOOL * deactivated, uint32 * ext_disc_reason)
{
! while (rdp_loop(deactivated, ext_disc_reason))
! ;
}
! /* used in uiports and rdp_main_loop, processes the rdp packets waiting */
BOOL
rdp_loop(BOOL * deactivated, uint32 * ext_disc_reason)
Index: rdp5.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdp5.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** rdp5.c 16 Jun 2004 03:08:55 -0000 1.11
--- rdp5.c 5 Jul 2004 19:09:07 -0000 1.12
***************
*** 27,31 ****
void
! rdp5_process(STREAM s, BOOL encryption)
{
uint16 length, count, x, y;
--- 27,31 ----
void
! rdp5_process(STREAM s)
{
uint16 length, count, x, y;
***************
*** 37,46 ****
struct stream *ts;
- if (encryption)
- {
- in_uint8s(s, 8); /* signature */
- sec_decrypt(s->p, s->end - s->p);
- }
-
#if 0
printf("RDP5 data:\n");
--- 37,40 ----
Index: secure.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/secure.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** secure.c 15 Jun 2004 22:17:08 -0000 1.46
--- secure.c 5 Jul 2004 19:09:07 -0000 1.47
***************
*** 821,825 ****
/* Receive secure transport packet */
STREAM
! sec_recv(void)
{
uint32 sec_flags;
--- 821,825 ----
/* Receive secure transport packet */
STREAM
! sec_recv(uint8 * rdpver)
{
uint32 sec_flags;
***************
*** 827,832 ****
STREAM s;
! while ((s = mcs_recv(&channel)) != NULL)
{
if (g_encryption || !g_licence_issued)
{
--- 827,844 ----
STREAM s;
! 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)
{
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com