1 |
/* |
/* |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
Protocol services - RDP layer |
Protocol services - RDP layer |
4 |
Copyright (C) Matthew Chapman 1999-2001 |
Copyright (C) Matthew Chapman 1999-2002 |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
7 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
79 |
} |
} |
80 |
|
|
81 |
in_uint16_le(rdp_s, length); |
in_uint16_le(rdp_s, length); |
82 |
|
/* 32k packets are really 8, keepalive fix */ |
83 |
|
if (length == 0x8000) |
84 |
|
{ |
85 |
|
next_packet += 8; |
86 |
|
*type = 0; |
87 |
|
return rdp_s; |
88 |
|
} |
89 |
in_uint16_le(rdp_s, pdu_type); |
in_uint16_le(rdp_s, pdu_type); |
90 |
in_uint8s(rdp_s, 2); /* userid */ |
in_uint8s(rdp_s, 2); /* userid */ |
91 |
*type = pdu_type & 0xf; |
*type = pdu_type & 0xf; |
203 |
|
|
204 |
/* Send a synchronisation PDU */ |
/* Send a synchronisation PDU */ |
205 |
static void |
static void |
206 |
rdp_send_synchronise() |
rdp_send_synchronise(void) |
207 |
{ |
{ |
208 |
STREAM s; |
STREAM s; |
209 |
|
|
441 |
|
|
442 |
/* Send a confirm active PDU */ |
/* Send a confirm active PDU */ |
443 |
static void |
static void |
444 |
rdp_send_confirm_active() |
rdp_send_confirm_active(void) |
445 |
{ |
{ |
446 |
STREAM s; |
STREAM s; |
447 |
uint16 caplen = |
uint16 caplen = |
552 |
{ |
{ |
553 |
uint16 num_updates; |
uint16 num_updates; |
554 |
uint16 left, top, right, bottom, width, height; |
uint16 left, top, right, bottom, width, height; |
555 |
uint16 cx, cy, bpp, compress, bufsize, size; |
uint16 cx, cy, bpp, Bpp, compress, bufsize, size; |
556 |
uint8 *data, *bmpdata; |
uint8 *data, *bmpdata; |
557 |
int i; |
int i; |
558 |
|
|
567 |
in_uint16_le(s, width); |
in_uint16_le(s, width); |
568 |
in_uint16_le(s, height); |
in_uint16_le(s, height); |
569 |
in_uint16_le(s, bpp); |
in_uint16_le(s, bpp); |
570 |
|
Bpp = (bpp + 7) / 8; |
571 |
in_uint16_le(s, compress); |
in_uint16_le(s, compress); |
572 |
in_uint16_le(s, bufsize); |
in_uint16_le(s, bufsize); |
573 |
|
|
580 |
if (!compress) |
if (!compress) |
581 |
{ |
{ |
582 |
int y; |
int y; |
583 |
bmpdata = xmalloc(width * height); |
bmpdata = xmalloc(width * height * Bpp); |
584 |
for (y = 0; y < height; y++) |
for (y = 0; y < height; y++) |
585 |
{ |
{ |
586 |
in_uint8a(s, &bmpdata[(height - y - 1) * width], width); |
in_uint8a(s, &bmpdata[(height - y - 1) * (width * Bpp)], width * Bpp); |
587 |
} |
} |
588 |
ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata); |
ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata); |
589 |
xfree(bmpdata); |
xfree(bmpdata); |
594 |
in_uint16_le(s, size); |
in_uint16_le(s, size); |
595 |
in_uint8s(s, 4); /* line_size, final_size */ |
in_uint8s(s, 4); /* line_size, final_size */ |
596 |
in_uint8p(s, data, size); |
in_uint8p(s, data, size); |
597 |
|
bmpdata = xmalloc(width * height * Bpp); |
598 |
bmpdata = xmalloc(width * height); |
if (bitmap_decompress(bmpdata, width, height, data, size, Bpp)) |
|
if (bitmap_decompress(bmpdata, width, height, data, size)) |
|
599 |
{ |
{ |
600 |
ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata); |
ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata); |
601 |
} |
} |
|
|
|
602 |
xfree(bmpdata); |
xfree(bmpdata); |
603 |
} |
} |
604 |
} |
} |
607 |
static void |
static void |
608 |
process_palette(STREAM s) |
process_palette(STREAM s) |
609 |
{ |
{ |
610 |
HCOLOURMAP hmap; |
COLOURENTRY *entry; |
611 |
COLOURMAP map; |
COLOURMAP map; |
612 |
uint8 *colours; |
HCOLOURMAP hmap; |
613 |
|
int i; |
614 |
|
|
615 |
in_uint8s(s, 2); /* pad */ |
in_uint8s(s, 2); /* pad */ |
616 |
in_uint16_le(s, map.ncolours); |
in_uint16_le(s, map.ncolours); |
617 |
in_uint8s(s, 2); /* pad */ |
in_uint8s(s, 2); /* pad */ |
618 |
in_uint8p(s, colours, (map.ncolours * 3)); |
|
619 |
map.colours = (COLOURENTRY *) colours; |
map.colours = xmalloc(3 * map.ncolours); |
620 |
|
|
621 |
|
for (i = 0; i < map.ncolours; i++) |
622 |
|
{ |
623 |
|
entry = &map.colours[i]; |
624 |
|
in_uint8(s, entry->red); |
625 |
|
in_uint8(s, entry->green); |
626 |
|
in_uint8(s, entry->blue); |
627 |
|
} |
628 |
|
|
629 |
hmap = ui_create_colourmap(&map); |
hmap = ui_create_colourmap(&map); |
630 |
ui_set_colourmap(hmap); |
ui_set_colourmap(hmap); |
631 |
|
|
632 |
|
xfree(map.colours); |
633 |
} |
} |
634 |
|
|
635 |
/* Process an update PDU */ |
/* Process an update PDU */ |
698 |
|
|
699 |
/* Process incoming packets */ |
/* Process incoming packets */ |
700 |
void |
void |
701 |
rdp_main_loop() |
rdp_main_loop(void) |
702 |
{ |
{ |
703 |
uint8 type; |
uint8 type; |
704 |
STREAM s; |
STREAM s; |
718 |
process_data_pdu(s); |
process_data_pdu(s); |
719 |
break; |
break; |
720 |
|
|
721 |
|
case 0: |
722 |
|
break; |
723 |
|
|
724 |
default: |
default: |
725 |
unimpl("PDU %d\n", type); |
unimpl("PDU %d\n", type); |
726 |
} |
} |
741 |
|
|
742 |
/* Disconnect from the RDP layer */ |
/* Disconnect from the RDP layer */ |
743 |
void |
void |
744 |
rdp_disconnect() |
rdp_disconnect(void) |
745 |
{ |
{ |
746 |
sec_disconnect(); |
sec_disconnect(); |
747 |
} |
} |