Remade connection setup. Send mstshash in initial packet.
(This might not be needed, but the more lookalike to a MS client we are, the better). Recognize RDP5 packets and hand them to the RDP5 parsing routine. git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@346 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
parent
593d7a04d6
commit
42764b0104
71
iso.c
71
iso.c
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/* -*- c-basic-offset: 8 -*-
|
||||
rdesktop: A Remote Desktop Protocol client.
|
||||
Protocol services - ISO layer
|
||||
Copyright (C) Matthew Chapman 1999-2002
|
||||
@ -42,6 +42,34 @@ iso_send_msg(uint8 code)
|
||||
tcp_send(s);
|
||||
}
|
||||
|
||||
static void
|
||||
iso_send_connection_request(char *username)
|
||||
{
|
||||
STREAM s;
|
||||
int length = 30 + strlen(username);
|
||||
|
||||
s = tcp_init(length);
|
||||
|
||||
out_uint8(s, 3); /* version */
|
||||
out_uint8(s, 0); /* reserved */
|
||||
out_uint16_be(s, length); /* length */
|
||||
|
||||
out_uint8(s, length - 5); /* hdrlen */
|
||||
out_uint8(s, ISO_PDU_CR);
|
||||
out_uint16(s, 0); /* dst_ref */
|
||||
out_uint16(s, 0); /* src_ref */
|
||||
out_uint8(s, 0); /* class */
|
||||
|
||||
out_uint8p(s, "Cookie: mstshash=", strlen("Cookie: mstshash="));
|
||||
out_uint8p(s, username, strlen(username));
|
||||
|
||||
out_uint8(s, 0x0d); /* Unknown */
|
||||
out_uint8(s, 0x0a); /* Unknown */
|
||||
|
||||
s_mark_end(s);
|
||||
tcp_send(s);
|
||||
}
|
||||
|
||||
/* Receive a message on the ISO layer, return code */
|
||||
static STREAM
|
||||
iso_recv_msg(uint8 * code)
|
||||
@ -49,25 +77,50 @@ iso_recv_msg(uint8 * code)
|
||||
STREAM s;
|
||||
uint16 length;
|
||||
uint8 version;
|
||||
BOOL shortform = False; // Shut the compiler up.
|
||||
|
||||
next_packet:
|
||||
s = tcp_recv(4);
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
in_uint8(s, version);
|
||||
if (version != 3)
|
||||
switch (version & 3)
|
||||
{
|
||||
error("TPKT v%d\n", version);
|
||||
return NULL;
|
||||
}
|
||||
case 0:
|
||||
in_uint8(s, length);
|
||||
if (length & 0x80)
|
||||
{
|
||||
length &= ~0x80;
|
||||
next_be(s, length);
|
||||
shortform = False;
|
||||
}
|
||||
else
|
||||
{
|
||||
shortform = True;
|
||||
}
|
||||
break;
|
||||
|
||||
in_uint8s(s, 1); /* pad */
|
||||
in_uint16_be(s, length);
|
||||
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(length - 4);
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((version & 3) == 0)
|
||||
{
|
||||
rdp5_process(s, version & 0x80, shortform);
|
||||
goto next_packet;
|
||||
}
|
||||
|
||||
in_uint8s(s, 1); /* hdrlen */
|
||||
in_uint8(s, *code);
|
||||
|
||||
@ -135,14 +188,14 @@ iso_recv(void)
|
||||
|
||||
/* Establish a connection up to the ISO layer */
|
||||
BOOL
|
||||
iso_connect(char *server)
|
||||
iso_connect(char *server, char *username)
|
||||
{
|
||||
uint8 code;
|
||||
|
||||
if (!tcp_connect(server))
|
||||
return False;
|
||||
|
||||
iso_send_msg(ISO_PDU_CR);
|
||||
iso_send_connection_request(username);
|
||||
|
||||
if (iso_recv_msg(&code) == NULL)
|
||||
return False;
|
||||
|
Loading…
Reference in New Issue
Block a user