libfreerdp-core: fix encoding of MCS and RDP headers, completed activation sequence
This commit is contained in:
parent
db98c00f18
commit
8ceb8e1ea8
@ -1534,29 +1534,6 @@ void rdp_recv_demand_active(rdpRdp* rdp, STREAM* s, rdpSettings* settings)
|
||||
rdp_read_demand_active(s, settings);
|
||||
rdp_send_confirm_active(rdp);
|
||||
rdp_send_client_synchronize_pdu(rdp);
|
||||
|
||||
return;
|
||||
rdp_recv(rdp); /* synchronize */
|
||||
|
||||
rdp_send_client_control_pdu(rdp, CTRLACTION_COOPERATE);
|
||||
rdp_recv(rdp); /* cooperate */
|
||||
|
||||
rdp_send_client_control_pdu(rdp, CTRLACTION_REQUEST_CONTROL);
|
||||
rdp_recv(rdp); /* request control */
|
||||
|
||||
if (rdp->settings->rdp_version >= 5)
|
||||
{
|
||||
//rdp_send_client_persistent_key_list_pdu(rdp);
|
||||
rdp_send_client_font_list_pdu(rdp, FONTLIST_FIRST | FONTLIST_LAST);
|
||||
rdp_recv(rdp); /* font map */
|
||||
}
|
||||
else
|
||||
{
|
||||
rdp_send_client_font_list_pdu(rdp, FONTLIST_FIRST);
|
||||
rdp_send_client_font_list_pdu(rdp, FONTLIST_LAST);
|
||||
}
|
||||
|
||||
rdp->activated = True;
|
||||
}
|
||||
|
||||
void rdp_write_confirm_active(STREAM* s, rdpSettings* settings)
|
||||
|
@ -138,8 +138,7 @@ void rdp_send_client_synchronize_pdu(rdpRdp* rdp)
|
||||
|
||||
rdp_write_client_synchronize_pdu(s, rdp->settings);
|
||||
|
||||
rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_SYNCHRONIZE,
|
||||
MCS_BASE_CHANNEL_ID + rdp->mcs->user_id);
|
||||
rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_SYNCHRONIZE, rdp->mcs->user_id);
|
||||
}
|
||||
|
||||
void rdp_read_server_control_pdu(STREAM* s, uint16* action)
|
||||
@ -170,7 +169,16 @@ void rdp_recv_server_control_pdu(rdpRdp* rdp, STREAM* s, rdpSettings* settings)
|
||||
}
|
||||
else if (action == CTRLACTION_GRANTED_CONTROL)
|
||||
{
|
||||
rdp_send_client_font_list_pdu(rdp, FONTLIST_FIRST | FONTLIST_LAST);
|
||||
if (rdp->settings->rdp_version >= 5)
|
||||
{
|
||||
//rdp_send_client_persistent_key_list_pdu(rdp);
|
||||
rdp_send_client_font_list_pdu(rdp, FONTLIST_FIRST | FONTLIST_LAST);
|
||||
}
|
||||
else
|
||||
{
|
||||
rdp_send_client_font_list_pdu(rdp, FONTLIST_FIRST);
|
||||
rdp_send_client_font_list_pdu(rdp, FONTLIST_LAST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,8 +192,7 @@ void rdp_send_client_control_pdu(rdpRdp* rdp, uint16 action)
|
||||
|
||||
rdp_write_client_control_pdu(s, action);
|
||||
|
||||
rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_CONTROL,
|
||||
MCS_BASE_CHANNEL_ID + rdp->mcs->user_id);
|
||||
rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_CONTROL, rdp->mcs->user_id);
|
||||
}
|
||||
|
||||
void rdp_write_persistent_list_entry(STREAM* s, uint32 key1, uint32 key2)
|
||||
@ -221,8 +228,7 @@ void rdp_send_client_persistent_key_list_pdu(rdpRdp* rdp)
|
||||
|
||||
rdp_write_client_persistent_key_list_pdu(s, rdp->settings);
|
||||
|
||||
rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_BITMAP_CACHE_PERSISTENT_LIST,
|
||||
MCS_BASE_CHANNEL_ID + rdp->mcs->user_id);
|
||||
rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_BITMAP_CACHE_PERSISTENT_LIST, rdp->mcs->user_id);
|
||||
}
|
||||
|
||||
void rdp_write_client_font_list_pdu(STREAM* s, uint16 flags)
|
||||
@ -241,6 +247,10 @@ void rdp_send_client_font_list_pdu(rdpRdp* rdp, uint16 flags)
|
||||
|
||||
rdp_write_client_font_list_pdu(s, flags);
|
||||
|
||||
rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_FONT_LIST,
|
||||
MCS_BASE_CHANNEL_ID + rdp->mcs->user_id);
|
||||
rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_FONT_LIST, rdp->mcs->user_id);
|
||||
}
|
||||
|
||||
void rdp_recv_server_font_map_pdu(rdpRdp* rdp, STREAM* s, rdpSettings* settings)
|
||||
{
|
||||
rdp->activated = True;
|
||||
}
|
||||
|
@ -53,5 +53,6 @@ void rdp_read_server_control_pdu(STREAM* s, uint16* action);
|
||||
void rdp_send_client_control_pdu(rdpRdp* rdp, uint16 action);
|
||||
void rdp_send_client_persistent_key_list_pdu(rdpRdp* rdp);
|
||||
void rdp_send_client_font_list_pdu(rdpRdp* rdp, uint16 flags);
|
||||
void rdp_recv_server_font_map_pdu(rdpRdp* rdp, STREAM* s, rdpSettings* settings);
|
||||
|
||||
#endif /* __CONNECTION_H */
|
||||
|
@ -96,6 +96,8 @@ void rdp_read_share_control_header(STREAM* s, uint16* length, uint16* type, uint
|
||||
|
||||
void rdp_write_share_control_header(STREAM* s, uint16 length, uint16 type, uint16 channel_id)
|
||||
{
|
||||
length -= RDP_PACKET_HEADER_LENGTH;
|
||||
|
||||
/* Share Control Header */
|
||||
stream_write_uint16(s, length); /* totalLength */
|
||||
stream_write_uint16(s, type | 0x10); /* pduType */
|
||||
@ -116,6 +118,10 @@ void rdp_read_share_data_header(STREAM* s, uint16* length, uint8* type, uint32*
|
||||
|
||||
void rdp_write_share_data_header(STREAM* s, uint16 length, uint8 type, uint32 share_id)
|
||||
{
|
||||
length -= RDP_PACKET_HEADER_LENGTH;
|
||||
length -= RDP_SHARE_CONTROL_HEADER_LENGTH;
|
||||
length -= RDP_SHARE_DATA_HEADER_LENGTH;
|
||||
|
||||
/* Share Data Header */
|
||||
stream_write_uint32(s, share_id); /* shareId (4 bytes) */
|
||||
stream_write_uint8(s, 0); /* pad1 (1 byte) */
|
||||
@ -154,6 +160,7 @@ STREAM* rdp_data_pdu_init(rdpRdp* rdp)
|
||||
STREAM* s;
|
||||
s = transport_send_stream_init(rdp->transport, 2048);
|
||||
stream_seek(s, RDP_PACKET_HEADER_LENGTH);
|
||||
stream_seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH);
|
||||
stream_seek(s, RDP_SHARE_DATA_HEADER_LENGTH);
|
||||
return s;
|
||||
}
|
||||
@ -171,7 +178,9 @@ void rdp_write_header(rdpRdp* rdp, STREAM* s, int length)
|
||||
per_write_integer16(s, rdp->mcs->user_id, MCS_BASE_CHANNEL_ID); /* initiator */
|
||||
per_write_integer16(s, MCS_GLOBAL_CHANNEL_ID, 0); /* channelId */
|
||||
stream_write_uint8(s, 0x70); /* dataPriority + segmentation */
|
||||
per_write_length(s, length - RDP_PACKET_HEADER_LENGTH); /* userData (OCTET_STRING) */
|
||||
|
||||
length = (length - RDP_PACKET_HEADER_LENGTH) | 0x8000;
|
||||
stream_write_uint16_be(s, length); /* userData (OCTET_STRING) */
|
||||
}
|
||||
|
||||
/**
|
||||
@ -284,6 +293,7 @@ void rdp_read_data_pdu(rdpRdp* rdp, STREAM* s)
|
||||
break;
|
||||
|
||||
case DATA_PDU_TYPE_FONT_MAP:
|
||||
rdp_recv_server_font_map_pdu(rdp, s, rdp->settings);
|
||||
break;
|
||||
|
||||
case DATA_PDU_TYPE_SET_KEYBOARD_INDICATORS:
|
||||
@ -369,7 +379,7 @@ void rdp_recv(rdpRdp* rdp)
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("incorrect security flags: 0x%04X\n", sec_flags);
|
||||
//printf("incorrect security flags: 0x%04X\n", sec_flags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ typedef struct rdp_rdp rdpRdp;
|
||||
|
||||
#define RDP_SECURITY_HEADER_LENGTH 4
|
||||
#define RDP_SHARE_CONTROL_HEADER_LENGTH 6
|
||||
#define RDP_SHARE_DATA_HEADER_LENGTH 18
|
||||
#define RDP_SHARE_DATA_HEADER_LENGTH 12
|
||||
#define RDP_PACKET_HEADER_LENGTH (TPDU_DATA_LENGTH + MCS_SEND_DATA_HEADER_LENGTH)
|
||||
|
||||
#define PDU_TYPE_DEMAND_ACTIVE 0x1
|
||||
|
@ -106,6 +106,9 @@ int tls_write(rdpTls* tls, uint8* data, int length)
|
||||
int status;
|
||||
int sent = 0;
|
||||
|
||||
printf("length:%d\n", length);
|
||||
freerdp_hexdump(data, length);
|
||||
|
||||
while (sent < length)
|
||||
{
|
||||
status = SSL_write(tls->ssl, data, length);
|
||||
|
Loading…
Reference in New Issue
Block a user