merge pull request #87

This commit is contained in:
Marc-André Moreau 2011-09-08 18:25:07 -04:00
commit 1bc97f60c3
9 changed files with 1046 additions and 777 deletions

View File

@ -650,12 +650,12 @@ void test_mppc(void)
rdp.mppc->history_ptr = rdp.mppc->history_buf;
/* store starting time */
/* save starting time */
gettimeofday(&start_time, NULL);
/* uncompress data */
CU_ASSERT(decompress_rdp_5(&rdp, compressed_rd5, sizeof(compressed_rd5),
PACKET_COMPRESSED, &roff, &rlen) == 0);
PACKET_COMPRESSED, &roff, &rlen) == True);
/* get end time */
gettimeofday(&end_time, NULL);

View File

@ -204,6 +204,12 @@ static void fastpath_recv_update_data(rdpFastPath* fastpath, STREAM* s)
uint8 compression;
uint8 compressionFlags;
STREAM* update_stream;
rdpRdp *rdp;
uint32 roff;
uint32 rlen;
uint32 i;
rdp = fastpath->rdp;
fastpath_read_update_header(s, &updateCode, &fragmentation, &compression);
@ -217,9 +223,21 @@ static void fastpath_recv_update_data(rdpFastPath* fastpath, STREAM* s)
if (compressionFlags != 0)
{
printf("FastPath compression is not yet implemented!\n");
if (decompress_rdp(rdp, s->data, size,
compressionFlags, &roff, &rlen))
{
/* need more space to insert decompressed data */
i = rlen - size;
stream_extend(s, i);
/* copy decompressed data */
memcpy(s->p, &rdp->mppc->history_buf[roff], rlen);
}
else
{
printf("decompress_rdp() failed\n");
stream_seek(s, size);
return;
}
}
update_stream = NULL;

View File

@ -495,7 +495,7 @@ void rdp_write_info_packet(STREAM* s, rdpSettings* settings)
flags |= INFO_REMOTECONSOLEAUDIO;
if (settings->compression)
flags |= INFO_COMPRESSION | PACKET_COMPR_TYPE_64K;
flags |= INFO_COMPRESSION | INFO_PACKET_COMPR_TYPE_64K;
domain = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->domain, &length);
cbDomain = length;

File diff suppressed because it is too large Load Diff

View File

@ -22,15 +22,29 @@
#include <stdint.h>
#define _MPPC_DEBUG
#ifdef MPPC_DEBUG
#define mprintf(y...) printf(y);
#else
#define mprintf(y...)
#endif
#define RDP5_HISTORY_BUF_SIZE 65536
struct rdp_mppc
{
uint8_t *history_buf;
uint8_t *history_ptr;
uint8 *history_buf;
uint8 *history_ptr;
};
// forward declarations
int decompress_rdp_5(rdpRdp *, uint8_t *, int, int, uint32_t *, uint32_t *);
int decompress_rdp(rdpRdp *, uint8 *, int, int, uint32 *, uint32 *);
int decompress_rdp_4(rdpRdp *, uint8 *, int, int, uint32 *, uint32 *);
int decompress_rdp_5(rdpRdp *, uint8 *, int, int, uint32 *, uint32 *);
int decompress_rdp_6(rdpRdp *, uint8 *, int, int, uint32 *, uint32 *);
int decompress_rdp_61(rdpRdp *, uint8 *, int, int, uint32 *, uint32 *);
struct rdp_mppc *mppc_new(rdpRdp *rdp);
void mppc_free(rdpRdp *rdp);
#endif

View File

@ -59,8 +59,11 @@ static boolean peer_recv_data_pdu(rdpPeer* peer, STREAM* s)
uint8 type;
uint16 length;
uint32 share_id;
uint8 compressed_type;
uint16 compressed_len;
if (!rdp_read_share_data_header(s, &length, &type, &share_id))
if (!rdp_read_share_data_header(s, &length, &type, &share_id, &compressed_type, &compressed_len))
return False;
switch (type)

View File

@ -113,7 +113,8 @@ void rdp_write_share_control_header(STREAM* s, uint16 length, uint16 type, uint1
stream_write_uint16(s, channel_id); /* pduSource */
}
boolean rdp_read_share_data_header(STREAM* s, uint16* length, uint8* type, uint32* share_id)
boolean rdp_read_share_data_header(STREAM* s, uint16* length, uint8* type, uint32* share_id,
uint8 *compressed_type, uint16 *compressed_len)
{
if (stream_get_left(s) < 12)
return False;
@ -124,8 +125,16 @@ boolean rdp_read_share_data_header(STREAM* s, uint16* length, uint8* type, uint3
stream_seek_uint8(s); /* streamId (1 byte) */
stream_read_uint16(s, *length); /* uncompressedLength (2 bytes) */
stream_read_uint8(s, *type); /* pduType2, Data PDU Type (1 byte) */
stream_seek_uint8(s); /* compressedType (1 byte) */
stream_seek_uint16(s); /* compressedLength (2 bytes) */
if (*type & 0x80)
{
stream_read_uint8(s, *compressed_type); /* compressedType (1 byte) */
stream_read_uint16(s, *compressed_len); /* compressedLength (2 bytes) */
}
else
{
*compressed_type = 0;
*compressed_len = 0;
}
return True;
}
@ -304,8 +313,10 @@ void rdp_recv_data_pdu(rdpRdp* rdp, STREAM* s)
uint8 type;
uint16 length;
uint32 share_id;
uint8 compressed_type;
uint16 compressed_len;
rdp_read_share_data_header(s, &length, &type, &share_id);
rdp_read_share_data_header(s, &length, &type, &share_id, &compressed_type, &compressed_len);
#ifdef WITH_DEBUG_RDP
if (type != DATA_PDU_TYPE_UPDATE)
@ -605,6 +616,7 @@ rdpRdp* rdp_new(freerdp* instance)
rdp->mcs = mcs_new(rdp->transport);
rdp->vchan = vchan_new(instance);
rdp->redirection = redirection_new();
rdp->mppc = mppc_new(rdp);
}
return rdp;
@ -630,6 +642,7 @@ void rdp_free(rdpRdp* rdp)
vchan_free(rdp->vchan);
redirection_free(rdp->redirection);
xfree(rdp);
mppc_free(rdp);
}
}

View File

@ -136,7 +136,9 @@ void rdp_write_security_header(STREAM* s, uint16 flags);
boolean rdp_read_share_control_header(STREAM* s, uint16* length, uint16* type, uint16* channel_id);
void rdp_write_share_control_header(STREAM* s, uint16 length, uint16 type, uint16 channel_id);
boolean rdp_read_share_data_header(STREAM* s, uint16* length, uint8* type, uint32* share_id);
boolean rdp_read_share_data_header(STREAM* s, uint16* length, uint8* type, uint32* share_id,
uint8 *compressed_type, uint16 *compressed_len);
void rdp_write_share_data_header(STREAM* s, uint16 length, uint8 type, uint32 share_id);
STREAM* rdp_send_stream_init(rdpRdp* rdp);

View File

@ -306,13 +306,15 @@ void update_recv(rdpUpdate* update, STREAM* s)
uint16 length;
uint16 source;
uint32 shareId;
uint8 compressed_type;
uint16 compressed_len;
rdp_read_share_control_header(s, &length, &pduType, &source);
if (pduType != PDU_TYPE_DATA)
return;
rdp_read_share_data_header(s, &length, &type, &shareId);
rdp_read_share_data_header(s, &length, &type, &shareId, &compressed_type, &compressed_len);
if (type == DATA_PDU_TYPE_UPDATE)
update_recv(update, s);