rdesktop/rdp5.c
Henrik Andersson 87d8d123b8 Rework the logging system
This commit will add a logging system to solve the problem that
one actually need to recompile rdesktop from source to enable
different debug logging.

- Same logging api  for all kind of logging and messages to
   end user.

- Adding -v for verbose output when running rdesktop.

- All messages are logged into a subject and with a type, eg:

     logger(Keyboard, Notice, "Autos-electing %s based on locale.", locale);

- Debug logging is enabled trough a environment variable RDEKSTOP_DEBUG,
  which specifies subjects of interest, comma separated. There is a special
  subject named All which includes all subject for debug loggin. There is also
  a simple logic opeartor '!' = NOT which can be used in combination like:

    RDESKTOP_DEBUG=All,!Graphics,!Sound

  Which would give debug log output for All subject except Graphics and Sound.
2017-01-26 14:19:40 +01:00

121 lines
2.9 KiB
C

/* -*- c-basic-offset: 8 -*-
rdesktop: A Remote Desktop Protocol client.
Protocol services - RDP5 short form PDU processing
Copyright (C) Matthew Chapman <matthewc.unsw.edu.au> 1999-2008
Copyright 2003-2008 Erik Forsberg <forsberg@cendio.se> for Cendio AB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rdesktop.h"
extern uint8 *g_next_packet;
extern RDPCOMP g_mppc_dict;
void
rdp5_process(STREAM s)
{
uint16 length, count, x, y;
uint8 type, ctype;
uint8 *next;
uint32 roff, rlen;
struct stream *ns = &(g_mppc_dict.ns);
struct stream *ts;
ui_begin_update();
while (s->p < s->end)
{
in_uint8(s, type);
if (type & RDP5_COMPRESSED)
{
in_uint8(s, ctype);
in_uint16_le(s, length);
type ^= RDP5_COMPRESSED;
}
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)
logger(Protocol, Error,
"rdp5_process(), error while decompressing packet");
/* allocate memory and copy the uncompressed data into the temporary stream */
ns->data = (uint8 *) 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)
{
case 0: /* update orders */
in_uint16_le(ts, count);
process_orders(ts, count);
break;
case 1: /* update bitmap */
in_uint8s(ts, 2); /* part length */
process_bitmap_updates(ts);
break;
case 2: /* update palette */
in_uint8s(ts, 2); /* uint16 = 2 */
process_palette(ts);
break;
case 3: /* update synchronize */
break;
case 5: /* null pointer */
ui_set_null_cursor();
break;
case 6: /* default pointer */
break;
case 8: /* pointer position */
in_uint16_le(ts, x);
in_uint16_le(ts, y);
if (s_check(ts))
ui_move_pointer(x, y);
break;
case 9: /* color pointer */
process_colour_pointer_pdu(ts);
break;
case 10: /* cached pointer */
process_cached_pointer_pdu(ts);
break;
case 11:
process_new_pointer_pdu(ts);
break;
default:
logger(Protocol, Warning, "rdp5_process(), unhandled opcode %d",
type);
}
s->p = next;
}
ui_end_update();
}