libfreerdp-code: sending of confirm active pdu

This commit is contained in:
Marc-André Moreau 2011-07-21 13:57:57 -04:00
parent f4353c2a62
commit e0aa20d6e5
4 changed files with 75 additions and 3 deletions

View File

@ -1531,6 +1531,7 @@ void rdp_read_demand_active(STREAM* s, rdpSettings* settings)
void rdp_write_confirm_active(STREAM* s, rdpSettings* settings)
{
uint8 *bm, *em, *lm;
uint16 numberCapabilities;
uint16 lengthSourceDescriptor;
uint16 lengthCombinedCapabilities;
@ -1540,11 +1541,66 @@ void rdp_write_confirm_active(STREAM* s, rdpSettings* settings)
stream_write_uint32(s, settings->share_id); /* shareId (4 bytes) */
stream_write_uint16(s, 0x03EA); /* originatorId (2 bytes) */
stream_write_uint16(s, sizeof(SOURCE_DESCRIPTOR));/* lengthSourceDescriptor (2 bytes) */
/* lengthCombinedCapabilities (2 bytes) */
stream_get_mark(s, lm);
stream_seek_uint16(s); /* lengthCombinedCapabilities (2 bytes) */
stream_write(s, SOURCE_DESCRIPTOR, lengthSourceDescriptor); /* sourceDescriptor */
/* numberCapabilities (2 bytes) */
stream_get_mark(s, bm);
stream_seek_uint16(s); /* numberCapabilities (2 bytes) */
stream_write_uint16(s, 0); /* pad2Octets (2 bytes) */
/* capabilitySets */
/* Mandatory Capability Sets */
numberCapabilities = 11;
rdp_write_general_capability_set(s, settings);
rdp_write_bitmap_capability_set(s, settings);
rdp_write_order_capability_set(s, settings);
rdp_write_bitmap_cache_capability_set(s, settings);
rdp_write_pointer_capability_set(s, settings);
rdp_write_input_capability_set(s, settings);
rdp_write_brush_capability_set(s, settings);
rdp_write_glyph_cache_capability_set(s, settings);
rdp_write_offscreen_bitmap_cache_capability_set(s, settings);
rdp_write_virtual_channel_capability_set(s, settings);
rdp_write_sound_capability_set(s, settings);
stream_get_mark(s, em);
stream_set_mark(s, lm); /* go back to lengthCombinedCapabilities */
lengthCombinedCapabilities = (em - bm);
stream_write_uint16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */
stream_set_mark(s, bm); /* go back to numberCapabilities */
stream_write_uint16(s, numberCapabilities); /* numberCapabilities (2 bytes) */
stream_set_mark(s, em);
}
void rdp_send_confirm_active(rdpRdp* rdp)
{
STREAM* s;
uint8 *bm, *em;
uint16 totalLength;
s = rdp_send_stream_init(rdp);
stream_get_mark(s, bm);
stream_seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH);
rdp_write_confirm_active(s, rdp->settings);
stream_get_mark(s, em);
totalLength = (em - bm);
stream_set_mark(s, bm); /* go back to share control header */
rdp_write_share_control_header(s, totalLength, PDU_TYPE_CONFIRM_ACTIVE,
MCS_BASE_CHANNEL_ID + rdp->mcs->user_id);
stream_set_mark(s, em);
rdp_write_header(rdp, s, totalLength);
transport_write(rdp->transport, s);
}
void rdp_read_deactivate_all(STREAM* s, rdpSettings* settings)

View File

@ -20,6 +20,8 @@
#ifndef __CAPABILITIES_H
#define __CAPABILITIES_H
#include "rdp.h"
#include <freerdp/freerdp.h>
#include <freerdp/settings.h>
#include <freerdp/utils/stream.h>
@ -179,6 +181,7 @@
void rdp_read_demand_active(STREAM* s, rdpSettings* settings);
void rdp_write_confirm_active(STREAM* s, rdpSettings* settings);
void rdp_send_confirm_active(rdpRdp* rdp);
void rdp_read_deactivate_all(STREAM* s, rdpSettings* settings);

View File

@ -56,6 +56,14 @@ void rdp_read_share_control_header(STREAM* s, uint16* length, uint16* type, uint
*type &= 0x0F; /* type is in the 4 least significant bits */
}
void rdp_write_share_control_header(STREAM* s, uint16 length, uint16 type, uint16 channel_id)
{
/* Share Control Header */
stream_write_uint16(s, length); /* totalLength */
stream_write_uint16(s, type); /* pduType */
stream_write_uint16(s, channel_id); /* pduSource */
}
/**
* Initialize an RDP packet stream.\n
* @param rdp rdp module
@ -65,7 +73,7 @@ void rdp_read_share_control_header(STREAM* s, uint16* length, uint16* type, uint
STREAM* rdp_send_stream_init(rdpRdp* rdp)
{
STREAM* s;
s = transport_send_stream_init(rdp->transport, 1024);
s = transport_send_stream_init(rdp->transport, 2048);
stream_seek(s, RDP_PACKET_HEADER_LENGTH);
return s;
}
@ -162,6 +170,7 @@ void rdp_recv(rdpRdp* rdp)
{
case PDU_TYPE_DEMAND_ACTIVE:
rdp_read_demand_active(s, rdp->settings);
rdp_send_confirm_active(rdp);
break;
case PDU_TYPE_DEACTIVATE_ALL:

View File

@ -55,6 +55,7 @@ typedef struct rdp_rdp rdpRdp;
#define SEC_PKT_MASK (SEC_PKT_CS_MASK | SEC_PKT_SC_MASK)
#define RDP_SECURITY_HEADER_LENGTH 4
#define RDP_SHARE_CONTROL_HEADER_LENGTH 6
#define RDP_PACKET_HEADER_LENGTH (TPDU_DATA_LENGTH + MCS_SEND_DATA_HEADER_LENGTH)
#define PDU_TYPE_DEMAND_ACTIVE 0x1
@ -77,6 +78,9 @@ struct rdp_rdp
void rdp_read_security_header(STREAM* s, uint16* flags);
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);
STREAM* rdp_send_stream_init(rdpRdp* rdp);
void rdp_write_header(rdpRdp* rdp, STREAM* s, int length);