libfreerdp-core: share data header fix

This commit is contained in:
Marc-André Moreau 2011-07-21 16:20:41 -04:00
parent 38f24dd4c6
commit c42cccd9e3
3 changed files with 76 additions and 16 deletions

View File

@ -97,11 +97,16 @@ boolean rdp_client_connect(rdpRdp* rdp)
rdp_send_client_synchronize_pdu(rdp);
rdp_send_client_cooperate_pdu(rdp);
rdp_send_client_request_control_pdu(rdp);
rdp_send_client_persistent_key_list_pdu(rdp);
rdp_send_client_font_list_pdu(rdp);
rdp_recv(rdp);
rdp_recv(rdp);
rdp_recv(rdp);
rdp_recv(rdp);
//rdp_send_client_request_control_pdu(rdp);
//rdp_send_client_persistent_key_list_pdu(rdp);
//rdp_send_client_font_list_pdu(rdp);
return True;
}
@ -128,7 +133,7 @@ void rdp_write_client_cooperate_pdu(STREAM* s, rdpSettings* settings)
{
stream_write_uint16(s, CTRLACTION_COOPERATE); /* action (2 bytes) */
stream_write_uint16(s, 0); /* grantId (2 bytes) */
stream_write_uint16(s, 0); /* controlId (2 bytes) */
stream_write_uint32(s, 0); /* controlId (4 bytes) */
}
void rdp_send_client_cooperate_pdu(rdpRdp* rdp)
@ -147,7 +152,7 @@ void rdp_write_client_request_control_pdu(STREAM* s, rdpSettings* settings)
{
stream_write_uint16(s, CTRLACTION_REQUEST_CONTROL); /* action (2 bytes) */
stream_write_uint16(s, 0); /* grantId (2 bytes) */
stream_write_uint16(s, 0); /* controlId (2 bytes) */
stream_write_uint32(s, 0); /* controlId (4 bytes) */
}
void rdp_send_client_request_control_pdu(rdpRdp* rdp)

View File

@ -64,25 +64,24 @@ void rdp_write_share_control_header(STREAM* s, uint16 length, uint16 type, uint1
stream_write_uint16(s, channel_id); /* pduSource */
}
void rdp_read_share_data_header(STREAM* s, uint16* length, uint16* type, uint16* channel_id)
void rdp_read_share_data_header(STREAM* s, uint16* length, uint8* type, uint32* share_id)
{
/* Share Data Header */
rdp_read_share_control_header(s, length, type, channel_id);
stream_seek_uint32(s); /* shareId (4 bytes) */
stream_read_uint32(s, *share_id); /* shareId (4 bytes) */
stream_seek_uint8(s); /* pad1 (1 byte) */
stream_seek_uint8(s); /* streamId (1 byte) */
stream_seek_uint16(s); /* uncompressedLength (2 bytes) */
stream_seek_uint8(s); /* pduType2, Data PDU Type (1 byte) */
stream_seek_uint16(s); /* compressedLength (2 byte2) */
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) */
}
void rdp_write_share_data_header(STREAM* s, uint16 length, uint16 type, uint16 channel_id, uint32 share_id)
void rdp_write_share_data_header(STREAM* s, uint16 length, uint8 type, uint32 share_id)
{
/* Share Data Header */
rdp_write_share_control_header(s, length, PDU_TYPE_DATA, channel_id);
stream_write_uint32(s, 0); /* shareId (4 bytes) */
stream_write_uint32(s, share_id); /* shareId (4 bytes) */
stream_write_uint8(s, 0); /* pad1 (1 byte) */
stream_write_uint8(s, 0); /* streamId (1 byte) */
stream_write_uint8(s, STREAM_LOW); /* streamId (1 byte) */
stream_write_uint16(s, length); /* uncompressedLength (2 bytes) */
stream_write_uint8(s, type); /* pduType2, Data PDU Type (1 byte) */
stream_write_uint16(s, length); /* compressedLength (2 byte2) */
@ -154,12 +153,43 @@ void rdp_send_data_pdu(rdpRdp* rdp, STREAM* s, uint16 type, uint16 channel_id)
stream_set_pos(s, 0);
rdp_write_header(rdp, s, length);
rdp_write_share_data_header(s, length, type, channel_id, rdp->settings->share_id);
rdp_write_share_control_header(s, length, PDU_TYPE_DATA, channel_id);
rdp_write_share_data_header(s, length, type, rdp->settings->share_id);
stream_set_pos(s, length);
transport_write(rdp->transport, s);
}
void rdp_read_set_error_info_data_pdu(STREAM* s)
{
uint32 errorInfo;
stream_read_uint32(s, errorInfo); /* errorInfo (4 bytes) */
printf("Error Info: 0x%08X\n", errorInfo);
}
void rdp_read_data_pdu(rdpRdp* rdp, STREAM* s)
{
uint8 type;
uint16 length;
uint32 share_id;
rdp_read_share_data_header(s, &length, &type, &share_id);
printf("data pdu type:%d length:%d\n", type, length);
switch (type)
{
case DATA_PDU_TYPE_SET_ERROR_INFO:
rdp_read_set_error_info_data_pdu(s);
break;
default:
break;
}
}
/**
* Receive an RDP packet.\n
* @param rdp RDP module
@ -215,6 +245,10 @@ void rdp_recv(rdpRdp* rdp)
switch (pduType)
{
case PDU_TYPE_DATA:
rdp_read_data_pdu(rdp, s);
break;
case PDU_TYPE_DEMAND_ACTIVE:
rdp_read_demand_active(s, rdp->settings);
rdp_send_confirm_active(rdp);

View File

@ -101,6 +101,24 @@ typedef struct rdp_rdp rdpRdp;
#define PACKET_COMPR_TYPE_RDP61 0x03
#define CompressionTypeMask 0x0F
/* Stream Identifiers */
#define STREAM_UNDEFINED 0x00
#define STREAM_LOW 0x01
#define STREAM_MED 0x02
#define STREAM_HI 0x04
/* Error Info Codes */
#define ERRINFO_RPC_INITIATED_DISCONNECT 0x00000001
#define ERRINFO_RPC_INITIATED_LOGOFF 0x00000002
#define ERRINFO_IDLE_TIMEOUT 0x00000003
#define ERRINFO_LOGON_TIMEOUT 0x00000004
#define ERRINFO_DISCONNECTED_BY_OTHER_CONNECTION 0x00000005
#define ERRINFO_OUT_OF_MEMORY 0x00000006
#define ERRINFO_SERVER_DENIED_CONNECTION 0x00000007
#define ERRINFO_SERVER_INSUFFICIENT_PRIVILEGES 0x00000008
#define ERRINFO_SERVER_FRESH_CREDENTIALS_REQUIRED 0x0000000A
#define ERRINFO_RPC_INITIATED_DISCONNECT_BY_USER 0x0000000B
struct rdp_rdp
{
boolean connected;
@ -118,6 +136,9 @@ void rdp_write_security_header(STREAM* s, uint16 flags);
void 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);
void rdp_read_share_data_header(STREAM* s, uint16* length, uint8* type, uint32* share_id);
void rdp_write_share_data_header(STREAM* s, uint16 length, uint8 type, uint32 share_id);
STREAM* rdp_send_stream_init(rdpRdp* rdp);
void rdp_write_header(rdpRdp* rdp, STREAM* s, int length);