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; |
127 |
out_uint32_le(s, rdp_shareid); |
out_uint32_le(s, rdp_shareid); |
128 |
out_uint8(s, 0); /* pad */ |
out_uint8(s, 0); /* pad */ |
129 |
out_uint8(s, 1); /* streamid */ |
out_uint8(s, 1); /* streamid */ |
130 |
out_uint16(s, (length - 14)); |
out_uint16_le(s, (length - 14)); |
131 |
out_uint8(s, data_pdu_type); |
out_uint8(s, data_pdu_type); |
132 |
out_uint8(s, 0); /* compress_type */ |
out_uint8(s, 0); /* compress_type */ |
133 |
out_uint16(s, 0); /* compress_len */ |
out_uint16(s, 0); /* compress_len */ |
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 |
|
|
281 |
out_uint16_le(s, RDP_CAPLEN_BITMAP); |
out_uint16_le(s, RDP_CAPLEN_BITMAP); |
282 |
|
|
283 |
out_uint16_le(s, 8); /* Preferred BPP */ |
out_uint16_le(s, 8); /* Preferred BPP */ |
284 |
out_uint16(s, 1); /* Receive 1 BPP */ |
out_uint16_le(s, 1); /* Receive 1 BPP */ |
285 |
out_uint16(s, 1); /* Receive 4 BPP */ |
out_uint16_le(s, 1); /* Receive 4 BPP */ |
286 |
out_uint16_le(s, 1); /* Receive 8 BPP */ |
out_uint16_le(s, 1); /* Receive 8 BPP */ |
287 |
out_uint16_le(s, 800); /* Desktop width */ |
out_uint16_le(s, 800); /* Desktop width */ |
288 |
out_uint16_le(s, 600); /* Desktop height */ |
out_uint16_le(s, 600); /* Desktop height */ |
327 |
out_uint8p(s, order_caps, 32); /* Orders supported */ |
out_uint8p(s, order_caps, 32); /* Orders supported */ |
328 |
out_uint16_le(s, 0x6a1); /* Text capability flags */ |
out_uint16_le(s, 0x6a1); /* Text capability flags */ |
329 |
out_uint8s(s, 6); /* Pad */ |
out_uint8s(s, 6); /* Pad */ |
330 |
out_uint32(s, desktop_save == False ? 0 : 0x38400); /* Desktop cache size */ |
out_uint32_le(s, desktop_save == False ? 0 : 0x38400); /* Desktop cache size */ |
331 |
out_uint32(s, 0); /* Unknown */ |
out_uint32(s, 0); /* Unknown */ |
332 |
out_uint32(s, 0x4e4); /* Unknown */ |
out_uint32_le(s, 0x4e4); /* Unknown */ |
333 |
} |
} |
334 |
|
|
335 |
/* Output bitmap cache capability set */ |
/* Output bitmap cache capability set */ |
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 = |
608 |
static void |
static void |
609 |
process_palette(STREAM s) |
process_palette(STREAM s) |
610 |
{ |
{ |
611 |
HCOLOURMAP hmap; |
COLOURENTRY *entry; |
612 |
COLOURMAP map; |
COLOURMAP map; |
613 |
uint8 *colours; |
HCOLOURMAP hmap; |
614 |
|
int i; |
615 |
|
|
616 |
in_uint8s(s, 2); /* pad */ |
in_uint8s(s, 2); /* pad */ |
617 |
in_uint16_le(s, map.ncolours); |
in_uint16_le(s, map.ncolours); |
618 |
in_uint8s(s, 2); /* pad */ |
in_uint8s(s, 2); /* pad */ |
619 |
in_uint8p(s, colours, (map.ncolours * 3)); |
|
620 |
map.colours = (COLOURENTRY *) colours; |
map.colours = xmalloc(3 * map.ncolours); |
621 |
|
|
622 |
|
for (i = 0; i < map.ncolours; i++) |
623 |
|
{ |
624 |
|
entry = &map.colours[i]; |
625 |
|
in_uint8(s, entry->red); |
626 |
|
in_uint8(s, entry->green); |
627 |
|
in_uint8(s, entry->blue); |
628 |
|
} |
629 |
|
|
630 |
hmap = ui_create_colourmap(&map); |
hmap = ui_create_colourmap(&map); |
631 |
ui_set_colourmap(hmap); |
ui_set_colourmap(hmap); |
632 |
|
|
633 |
|
xfree(map.colours); |
634 |
} |
} |
635 |
|
|
636 |
/* Process an update PDU */ |
/* Process an update PDU */ |
699 |
|
|
700 |
/* Process incoming packets */ |
/* Process incoming packets */ |
701 |
void |
void |
702 |
rdp_main_loop() |
rdp_main_loop(void) |
703 |
{ |
{ |
704 |
uint8 type; |
uint8 type; |
705 |
STREAM s; |
STREAM s; |
719 |
process_data_pdu(s); |
process_data_pdu(s); |
720 |
break; |
break; |
721 |
|
|
722 |
|
case 0: |
723 |
|
break; |
724 |
|
|
725 |
default: |
default: |
726 |
unimpl("PDU %d\n", type); |
unimpl("PDU %d\n", type); |
727 |
} |
} |
742 |
|
|
743 |
/* Disconnect from the RDP layer */ |
/* Disconnect from the RDP layer */ |
744 |
void |
void |
745 |
rdp_disconnect() |
rdp_disconnect(void) |
746 |
{ |
{ |
747 |
sec_disconnect(); |
sec_disconnect(); |
748 |
} |
} |