CVS: rdesktop mppc.c,1.1,1.2 rdp5.c,1.8,1.9 rdp.c,1.59,1.60

Peter Bystr?m <[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-serv24642

Modified Files:
	mppc.c rdp5.c rdp.c 
Log Message:
rdp5 decompression, but only <= 8-bit depth.

Index: mppc.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/mppc.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** mppc.c	27 Apr 2004 13:05:32 -0000	1.1
--- mppc.c	30 Apr 2004 06:18:08 -0000	1.2
***************
*** 4,8 ****
  #include "rdesktop.h"
  
! /* mppc-like??? decompression               */
  /* http://www.faqs.org/rfcs/rfc2118.html    */
  
--- 4,8 ----
  #include "rdesktop.h"
  
! /* mppc decompression                       */
  /* http://www.faqs.org/rfcs/rfc2118.html    */
  
***************
*** 19,27 ****
  /* through the CAL licenses?                */
  
! /* the dictionary is empty when init. like  */
! /* LZ78,  which is not patented             */
  
  
! RDPCOMP mppc_dict;
  
  int
--- 19,31 ----
  /* through the CAL licenses?                */
  
! /* as the rfc states the algorithm seems to */
! /* be LZ77 with a sliding buffer            */
! /* that is empty at init.                   */
  
+ /* as of my limited knowledge these patents */
+ /* has expired.                             */
  
! 
! RDPCOMP g_mppc_dict;
  
  int
***************
*** 34,38 ****
  	int old_offset, match_bits;
  
! 	signed char *dict = &(mppc_dict.hist);
  
  	if ((ctype & RDP_MPPC_COMPRESSED) == 0)
--- 38,42 ----
  	int old_offset, match_bits;
  
! 	signed char *dict = &(g_mppc_dict.hist);
  
  	if ((ctype & RDP_MPPC_COMPRESSED) == 0)
***************
*** 45,49 ****
  	if ((ctype & RDP_MPPC_RESET) != 0)
  	{
! 		mppc_dict.roff = 0;
  	}
  
--- 49,53 ----
  	if ((ctype & RDP_MPPC_RESET) != 0)
  	{
! 		g_mppc_dict.roff = 0;
  	}
  
***************
*** 51,55 ****
  	{
  		memset(dict, 0, RDP_MPPC_DICT_SIZE);
! 		mppc_dict.roff = 0;
  	}
  
--- 55,59 ----
  	{
  		memset(dict, 0, RDP_MPPC_DICT_SIZE);
! 		g_mppc_dict.roff = 0;
  	}
  
***************
*** 57,61 ****
  	*rlen = 0;
  
! 	walker = mppc_dict.roff;
  
  	next_offset = walker;
--- 61,65 ----
  	*rlen = 0;
  
! 	walker = g_mppc_dict.roff;
  
  	next_offset = walker;
***************
*** 268,272 ****
  
  	/* store history offset */
! 	mppc_dict.roff = next_offset;
  
  	*roff = old_offset;
--- 272,276 ----
  
  	/* store history offset */
! 	g_mppc_dict.roff = next_offset;
  
  	*roff = old_offset;

Index: rdp5.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdp5.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** rdp5.c	22 Oct 2003 10:55:11 -0000	1.8
--- rdp5.c	30 Apr 2004 06:18:08 -0000	1.9
***************
*** 24,34 ****
  extern uint8 *g_next_packet;
  
  void
  rdp5_process(STREAM s, BOOL encryption)
  {
  	uint16 length, count, x, y;
! 	uint8 type;
  	uint8 *next;
  
  	if (encryption)
  	{
--- 24,40 ----
  extern uint8 *g_next_packet;
  
+ extern RDPCOMP g_mppc_dict;
+ 
  void
  rdp5_process(STREAM s, BOOL encryption)
  {
  	uint16 length, count, x, y;
! 	uint8 type, ctype;
  	uint8 *next;
  
+ 	uint32 roff, rlen;
+ 	struct stream *ns = &(g_mppc_dict.ns);
+ 	struct stream *ts;
+ 
  	if (encryption)
  	{
***************
*** 45,51 ****
  	{
  		in_uint8(s, type);
! 		in_uint16_le(s, length);
  		g_next_packet = next = s->p + length;
  
  		switch (type)
  		{
--- 51,88 ----
  	{
  		in_uint8(s, type);
! 		if (type & RDP_COMPRESSION)
! 		{
! 			in_uint8(s, ctype);
! 			in_uint16_le(s, length);
! 			type ^= RDP_COMPRESSION;
! 		}
! 		else
! 		{
! 			ctype = 0;
! 			in_uint16_le(s, length);
! 		}
  		g_next_packet = next = s->p + length;
  
+ 		if (ctype & RDP_MPPC_COMPRESSED)
+ 		{
+ 
+ 			if (mppc_expand(s->p, length, ctype, &roff, &rlen) == -1)
+ 				error("error while decompressing packet\n");
+ 
+ 			/* allocate memory and copy the uncompressed data into the temporary stream */
+ 			ns->data = xrealloc(ns->data, rlen);
+ 
+ 			memcpy((ns->data), (unsigned char *) (g_mppc_dict.hist + roff), rlen);
+ 
+ 			ns->size = rlen;
+ 			ns->end = (ns->data + ns->size);
+ 			ns->p = ns->data;
+ 			ns->rdp_hdr = ns->p;
+ 
+ 			ts = ns;
+ 		}
+ 		else
+ 			ts = s;
+ 
  		switch (type)
  		{
***************
*** 55,68 ****
  				   8! :) */
  			case 0:	/* orders */
! 				in_uint16_le(s, count);
! 				process_orders(s, count);
  				break;
  			case 1:	/* bitmap update (???) */
! 				in_uint8s(s, 2);	/* part length */
! 				process_bitmap_updates(s);
  				break;
  			case 2:	/* palette */
! 				in_uint8s(s, 2);	/* uint16 = 2 */
! 				process_palette(s);
  				break;
  			case 3:	/* probably an palette with offset 3. Weird */
--- 92,105 ----
  				   8! :) */
  			case 0:	/* orders */
! 				in_uint16_le(ts, count);
! 				process_orders(ts, count);
  				break;
  			case 1:	/* bitmap update (???) */
! 				in_uint8s(ts, 2);	/* part length */
! 				process_bitmap_updates(ts);
  				break;
  			case 2:	/* palette */
! 				in_uint8s(ts, 2);	/* uint16 = 2 */
! 				process_palette(ts);
  				break;
  			case 3:	/* probably an palette with offset 3. Weird */
***************
*** 72,85 ****
  				break;
  			case 8:
! 				in_uint16_le(s, x);
! 				in_uint16_le(s, y);
! 				if (s_check(s))
  					ui_move_pointer(x, y);
  				break;
  			case 9:
! 				process_colour_pointer_pdu(s);
  				break;
  			case 10:
! 				process_cached_pointer_pdu(s);
  				break;
  			default:
--- 109,122 ----
  				break;
  			case 8:
! 				in_uint16_le(ts, x);
! 				in_uint16_le(ts, y);
! 				if (s_check(ts))
  					ui_move_pointer(x, y);
  				break;
  			case 9:
! 				process_colour_pointer_pdu(ts);
  				break;
  			case 10:
! 				process_cached_pointer_pdu(ts);
  				break;
  			default:

Index: rdp.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdp.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -d -r1.59 -r1.60
*** rdp.c	27 Apr 2004 12:55:33 -0000	1.59
--- rdp.c	30 Apr 2004 06:18:08 -0000	1.60
***************
*** 39,43 ****
  uint32 g_rdp_shareid;
  
! extern RDPCOMP mppc_dict;
  
  #if WITH_DEBUG
--- 39,43 ----
  uint32 g_rdp_shareid;
  
! extern RDPCOMP g_mppc_dict;
  
  #if WITH_DEBUG
***************
*** 177,190 ****
  	time_t tzone;
  
  	if (!g_use_rdp5 || 1 == g_server_rdp_version)
  	{
  		DEBUG_RDP5(("Sending RDP4-style Logon packet\n"));
  
- #if 0
- 		/* enable rdp compression */
- 		/* decompression also works with rdp5 */
- 		/* but there are some unknown opcodes */
- 		flags |= RDP_COMPRESSION;
- #endif
  		s = sec_init(sec_flags, 18 + len_domain + len_user + len_password
  			     + len_program + len_directory + 10);
--- 177,190 ----
  	time_t tzone;
  
+ #if 0
+ 	/* enable rdp compression */
+ 	/* some problems still exist with rdp5 */
+ 	flags |= RDP_COMPRESSION;
+ #endif
+ 
  	if (!g_use_rdp5 || 1 == g_server_rdp_version)
  	{
  		DEBUG_RDP5(("Sending RDP4-style Logon packet\n"));
  
  		s = sec_init(sec_flags, 18 + len_domain + len_user + len_password
  			     + len_program + len_directory + 10);
***************
*** 963,968 ****
  	uint32 roff, rlen;
  
! 	struct stream *ns = &(mppc_dict.ns);
! 	uint8 *dict = (mppc_dict.hist);
  
  	in_uint8s(s, 6);	/* shareid, pad, streamid */
--- 963,967 ----
  	uint32 roff, rlen;
  
! 	struct stream *ns = &(g_mppc_dict.ns);
  
  	in_uint8s(s, 6);	/* shareid, pad, streamid */
***************
*** 979,994 ****
  			error("error while decompressing packet\n");
  
! 		len -= 18;
! 
! 		/* this should never happen */
! 		if (len != rlen)
! 			error("decompression error len != rlen\n");
  
  		/* allocate memory and copy the uncompressed data into the temporary stream */
! 		ns->data = xrealloc(ns->data, len);
  
! 		memcpy((ns->data), (unsigned char *) (mppc_dict.hist + roff), len);
  
! 		ns->size = len;
  		ns->end = (ns->data + ns->size);
  		ns->p = ns->data;
--- 978,989 ----
  			error("error while decompressing packet\n");
  
! 		//len -= 18;
  
  		/* allocate memory and copy the uncompressed data into the temporary stream */
! 		ns->data = xrealloc(ns->data, rlen);
  
! 		memcpy((ns->data), (unsigned char *) (g_mppc_dict.hist + roff), rlen);
  
! 		ns->size = rlen;
  		ns->end = (ns->data + ns->size);
  		ns->p = ns->data;



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE. 
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.