libfreerdp-core: reduce reuse of same pdu buffers

This commit is contained in:
Marc-André Moreau 2013-05-15 15:54:33 -04:00
parent fc592a1750
commit 202614a1a4
9 changed files with 177 additions and 74 deletions

View File

@ -285,17 +285,24 @@ BOOL rdp_recv_deactivate_all(rdpRdp* rdp, wStream* s)
*/
if (Stream_GetRemainingLength(s) > 0)
{
do {
if(Stream_GetRemainingLength(s) < 4)
do
{
if (Stream_GetRemainingLength(s) < 4)
break;
Stream_Read_UINT32(s, rdp->settings->ShareId); /* shareId (4 bytes) */
if(Stream_GetRemainingLength(s) < 2)
if (Stream_GetRemainingLength(s) < 2)
break;
Stream_Read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */
if(Stream_GetRemainingLength(s) < lengthSourceDescriptor)
if (Stream_GetRemainingLength(s) < lengthSourceDescriptor)
break;
Stream_Seek(s, lengthSourceDescriptor); /* sourceDescriptor (should be 0x00) */
} while(0);
}
while(0);
}
rdp->state = CONNECTION_STATE_CAPABILITY;
@ -304,6 +311,7 @@ BOOL rdp_recv_deactivate_all(rdpRdp* rdp, wStream* s)
{
if (rdp_check_fds(rdp) < 0)
return FALSE;
if (rdp->disconnect)
break;
}
@ -314,14 +322,20 @@ BOOL rdp_recv_deactivate_all(rdpRdp* rdp, wStream* s)
BOOL rdp_send_deactivate_all(rdpRdp* rdp)
{
wStream* s;
BOOL status;
s = rdp_pdu_init(rdp);
s = Stream_New(NULL, 1024);
rdp_init_stream_pdu(rdp, s);
Stream_Write_UINT32(s, rdp->settings->ShareId); /* shareId (4 bytes) */
Stream_Write_UINT16(s, 1); /* lengthSourceDescriptor (2 bytes) */
Stream_Write_UINT8(s, 0); /* sourceDescriptor (should be 0x00) */
return rdp_send_pdu(rdp, s, PDU_TYPE_DEACTIVATE_ALL, rdp->mcs->user_id);
status = rdp_send_pdu(rdp, s, PDU_TYPE_DEACTIVATE_ALL, rdp->mcs->user_id);
Stream_Free(s, TRUE);
return status;
}
BOOL rdp_server_accept_client_control_pdu(rdpRdp* rdp, wStream* s)
@ -330,11 +344,13 @@ BOOL rdp_server_accept_client_control_pdu(rdpRdp* rdp, wStream* s)
if (!rdp_recv_control_pdu(s, &action))
return FALSE;
if (action == CTRLACTION_REQUEST_CONTROL)
{
if (!rdp_send_server_control_granted_pdu(rdp))
return FALSE;
}
return TRUE;
}
@ -342,6 +358,7 @@ BOOL rdp_server_accept_client_font_list_pdu(rdpRdp* rdp, wStream* s)
{
if (!rdp_recv_client_font_list_pdu(s))
return FALSE;
if (!rdp_send_server_font_map_pdu(rdp))
return FALSE;

View File

@ -209,6 +209,8 @@ void rdp_write_general_capability_set(wStream* s, rdpSettings* settings)
int header;
UINT16 extraFlags;
Stream_EnsureRemainingCapacity(s, 64);
header = rdp_capability_set_start(s);
extraFlags = LONG_CREDENTIALS_SUPPORTED | NO_BITMAP_COMPRESSION_HDR;
@ -349,6 +351,8 @@ void rdp_write_bitmap_capability_set(wStream* s, rdpSettings* settings)
UINT16 desktopResizeFlag;
UINT16 preferredBitsPerPixel;
Stream_EnsureRemainingCapacity(s, 64);
header = rdp_capability_set_start(s);
drawingFlags |= DRAW_ALLOW_SKIP_ALPHA;
@ -489,6 +493,8 @@ void rdp_write_order_capability_set(wStream* s, rdpSettings* settings)
UINT16 orderSupportExFlags;
UINT16 textANSICodePage;
Stream_EnsureRemainingCapacity(s, 64);
header = rdp_capability_set_start(s);
/* see [MSDN-CP]: http://msdn.microsoft.com/en-us/library/dd317756 */
@ -669,6 +675,8 @@ void rdp_write_bitmap_cache_capability_set(wStream* s, rdpSettings* settings)
int header;
UINT16 size;
Stream_EnsureRemainingCapacity(s, 64);
header = rdp_capability_set_start(s);
bpp = (settings->ColorDepth + 7) / 8;
@ -772,6 +780,8 @@ void rdp_write_control_capability_set(wStream* s, rdpSettings* settings)
{
int header;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
Stream_Write_UINT16(s, 0); /* controlFlags (2 bytes) */
@ -839,6 +849,8 @@ void rdp_write_window_activation_capability_set(wStream* s, rdpSettings* setting
{
int header;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
Stream_Write_UINT16(s, 0); /* helpKeyFlag (2 bytes) */
@ -917,6 +929,8 @@ void rdp_write_pointer_capability_set(wStream* s, rdpSettings* settings)
int header;
UINT16 colorPointerFlag;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
colorPointerFlag = (settings->ColorPointerFlag) ? 1 : 0;
@ -985,6 +999,8 @@ void rdp_write_share_capability_set(wStream* s, rdpSettings* settings)
int header;
UINT16 nodeId;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
nodeId = (settings->ServerMode) ? 0x03EA : 0;
@ -1044,6 +1060,8 @@ void rdp_write_color_cache_capability_set(wStream* s, rdpSettings* settings)
{
int header;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
Stream_Write_UINT16(s, 6); /* colorTableCacheSize (2 bytes) */
@ -1106,6 +1124,8 @@ void rdp_write_sound_capability_set(wStream* s, rdpSettings* settings)
int header;
UINT16 soundFlags;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
soundFlags = (settings->SoundBeepsEnabled) ? SOUND_BEEPS_FLAG : 0;
@ -1201,6 +1221,8 @@ void rdp_write_input_capability_set(wStream* s, rdpSettings* settings)
int header;
UINT16 inputFlags;
Stream_EnsureRemainingCapacity(s, 128);
header = rdp_capability_set_start(s);
inputFlags = INPUT_FLAG_SCANCODES | INPUT_FLAG_MOUSEX | INPUT_FLAG_UNICODE;
@ -1284,6 +1306,8 @@ void rdp_write_font_capability_set(wStream* s, rdpSettings* settings)
{
int header;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
Stream_Write_UINT16(s, FONTSUPPORT_FONTLIST); /* fontSupportFlags (2 bytes) */
@ -1340,6 +1364,8 @@ void rdp_write_brush_capability_set(wStream* s, rdpSettings* settings)
{
int header;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
Stream_Write_UINT32(s, BRUSH_COLOR_FULL); /* brushSupportLevel (4 bytes) */
@ -1421,6 +1447,8 @@ void rdp_write_glyph_cache_capability_set(wStream* s, rdpSettings* settings)
{
int header;
Stream_EnsureRemainingCapacity(s, 64);
header = rdp_capability_set_start(s);
/* glyphCache (40 bytes) */
@ -1525,6 +1553,8 @@ void rdp_write_offscreen_bitmap_cache_capability_set(wStream* s, rdpSettings* se
int header;
UINT32 offscreenSupportLevel = FALSE;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
if (settings->OffscreenSupportLevel)
@ -1595,6 +1625,8 @@ void rdp_write_bitmap_cache_host_support_capability_set(wStream* s, rdpSettings*
{
int header;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
Stream_Write_UINT8(s, BITMAP_CACHE_V2); /* cacheVersion (1 byte) */
@ -1692,6 +1724,8 @@ void rdp_write_bitmap_cache_v2_capability_set(wStream* s, rdpSettings* settings)
int header;
UINT16 cacheFlags;
Stream_EnsureRemainingCapacity(s, 64);
header = rdp_capability_set_start(s);
cacheFlags = ALLOW_CACHE_WAITING_LIST_FLAG;
@ -1787,6 +1821,8 @@ void rdp_write_virtual_channel_capability_set(wStream* s, rdpSettings* settings)
int header;
UINT32 flags;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
flags = VCCAPS_NO_COMPR;
@ -1858,6 +1894,8 @@ void rdp_write_draw_nine_grid_cache_capability_set(wStream* s, rdpSettings* sett
int header;
UINT32 drawNineGridSupportLevel;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
drawNineGridSupportLevel = (settings->DrawNineGridEnabled) ? DRAW_NINEGRID_SUPPORTED_V2 : DRAW_NINEGRID_NO_SUPPORT;
@ -1956,6 +1994,8 @@ void rdp_write_draw_gdiplus_cache_capability_set(wStream* s, rdpSettings* settin
UINT32 drawGDIPlusSupportLevel;
UINT32 drawGdiplusCacheLevel;
Stream_EnsureRemainingCapacity(s, 64);
header = rdp_capability_set_start(s);
drawGDIPlusSupportLevel = (settings->DrawGdiPlusEnabled) ? DRAW_GDIPLUS_SUPPORTED : DRAW_GDIPLUS_DEFAULT;
@ -2032,6 +2072,8 @@ void rdp_write_remote_programs_capability_set(wStream* s, rdpSettings* settings)
int header;
UINT32 railSupportLevel;
Stream_EnsureRemainingCapacity(s, 64);
header = rdp_capability_set_start(s);
railSupportLevel = RAIL_LEVEL_SUPPORTED;
@ -2092,6 +2134,8 @@ void rdp_write_window_list_capability_set(wStream* s, rdpSettings* settings)
int header;
UINT32 wndSupportLevel;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
wndSupportLevel = WINDOW_LEVEL_SUPPORTED_EX;
@ -2155,6 +2199,8 @@ void rdp_write_desktop_composition_capability_set(wStream* s, rdpSettings* setti
int header;
UINT16 compDeskSupportLevel;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
compDeskSupportLevel = (settings->AllowDesktopComposition) ? COMPDESK_SUPPORTED : COMPDESK_NOT_SUPPORTED;
@ -2211,6 +2257,8 @@ void rdp_write_multifragment_update_capability_set(wStream* s, rdpSettings* sett
{
int header;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
Stream_Write_UINT32(s, settings->MultifragMaxRequestSize); /* MaxRequestSize (4 bytes) */
@ -2264,6 +2312,8 @@ void rdp_write_large_pointer_capability_set(wStream* s, rdpSettings* settings)
int header;
UINT16 largePointerSupportFlags;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
largePointerSupportFlags = (settings->LargePointerFlag) ? LARGE_POINTER_FLAG_96x96 : 0;
@ -2322,6 +2372,8 @@ void rdp_write_surface_commands_capability_set(wStream* s, rdpSettings* settings
int header;
UINT32 cmdFlags;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
cmdFlags = SURFCMDS_FRAME_MARKER |
@ -2520,6 +2572,8 @@ void rdp_write_rfx_client_capability_container(wStream* s, rdpSettings* settings
UINT32 captureFlags;
BYTE codecMode;
Stream_EnsureRemainingCapacity(s, 64);
captureFlags = settings->RemoteFxOnly ? 0 : CARDP_CAPS_CAPTURE_NON_CAC;
codecMode = settings->RemoteFxCodecMode;
@ -2567,6 +2621,8 @@ void rdp_write_rfx_client_capability_container(wStream* s, rdpSettings* settings
*/
void rdp_write_nsc_client_capability_container(wStream* s, rdpSettings* settings)
{
Stream_EnsureRemainingCapacity(s, 8);
Stream_Write_UINT16(s, 3); /* codecPropertiesLength */
/* TS_NSCODEC_CAPABILITYSET */
@ -2577,6 +2633,8 @@ void rdp_write_nsc_client_capability_container(wStream* s, rdpSettings* settings
void rdp_write_jpeg_client_capability_container(wStream* s, rdpSettings* settings)
{
Stream_EnsureRemainingCapacity(s, 8);
Stream_Write_UINT16(s, 1); /* codecPropertiesLength */
Stream_Write_UINT8(s, settings->JpegQuality);
}
@ -2588,12 +2646,16 @@ void rdp_write_jpeg_client_capability_container(wStream* s, rdpSettings* setting
*/
void rdp_write_rfx_server_capability_container(wStream* s, rdpSettings* settings)
{
Stream_EnsureRemainingCapacity(s, 8);
Stream_Write_UINT16(s, 4); /* codecPropertiesLength */
Stream_Write_UINT32(s, 0); /* reserved */
}
void rdp_write_jpeg_server_capability_container(wStream* s, rdpSettings* settings)
{
Stream_EnsureRemainingCapacity(s, 8);
Stream_Write_UINT16(s, 1); /* codecPropertiesLength */
Stream_Write_UINT8(s, 75);
}
@ -2605,6 +2667,8 @@ void rdp_write_jpeg_server_capability_container(wStream* s, rdpSettings* setting
*/
void rdp_write_nsc_server_capability_container(wStream* s, rdpSettings* settings)
{
Stream_EnsureRemainingCapacity(s, 8);
Stream_Write_UINT16(s, 4); /* codecPropertiesLength */
Stream_Write_UINT32(s, 0); /* reserved */
}
@ -2621,6 +2685,8 @@ void rdp_write_bitmap_codecs_capability_set(wStream* s, rdpSettings* settings)
int header;
BYTE bitmapCodecCount;
Stream_EnsureRemainingCapacity(s, 64);
header = rdp_capability_set_start(s);
bitmapCodecCount = 0;
@ -2789,6 +2855,8 @@ void rdp_write_frame_acknowledge_capability_set(wStream* s, rdpSettings* setting
int header;
UINT32 frame_acknowledge;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
frame_acknowledge = settings->FrameAcknowledge;
@ -2829,6 +2897,8 @@ void rdp_write_bitmap_cache_v3_codec_id_capability_set(wStream* s, rdpSettings*
{
int header;
Stream_EnsureRemainingCapacity(s, 32);
header = rdp_capability_set_start(s);
Stream_Write_UINT8(s, settings->BitmapCacheV3CodecId);
@ -3333,6 +3403,8 @@ void rdp_write_demand_active(wStream* s, rdpSettings* settings)
UINT16 numberCapabilities;
UINT16 lengthCombinedCapabilities;
Stream_EnsureRemainingCapacity(s, 64);
Stream_Write_UINT32(s, settings->ShareId); /* shareId (4 bytes) */
Stream_Write_UINT16(s, 4); /* lengthSourceDescriptor (2 bytes) */
@ -3390,14 +3462,20 @@ void rdp_write_demand_active(wStream* s, rdpSettings* settings)
BOOL rdp_send_demand_active(rdpRdp* rdp)
{
wStream* s;
BOOL status;
s = rdp_pdu_init(rdp);
s = Stream_New(NULL, 4096);
rdp_init_stream_pdu(rdp, s);
rdp->settings->ShareId = 0x10000 + rdp->mcs->user_id;
rdp_write_demand_active(s, rdp->settings);
return rdp_send_pdu(rdp, s, PDU_TYPE_DEMAND_ACTIVE, rdp->mcs->user_id);
status = rdp_send_pdu(rdp, s, PDU_TYPE_DEMAND_ACTIVE, rdp->mcs->user_id);
Stream_Free(s, TRUE);
return status;
}
BOOL rdp_recv_confirm_active(rdpRdp* rdp, wStream* s)
@ -3573,10 +3651,16 @@ void rdp_write_confirm_active(wStream* s, rdpSettings* settings)
BOOL rdp_send_confirm_active(rdpRdp* rdp)
{
wStream* s;
BOOL status;
s = rdp_pdu_init(rdp);
s = Stream_New(NULL, 4096);
rdp_init_stream_pdu(rdp, s);
rdp_write_confirm_active(s, rdp->settings);
return rdp_send_pdu(rdp, s, PDU_TYPE_CONFIRM_ACTIVE, rdp->mcs->user_id);
status = rdp_send_pdu(rdp, s, PDU_TYPE_CONFIRM_ACTIVE, rdp->mcs->user_id);
Stream_Free(s, TRUE);
return status;
}

View File

@ -118,13 +118,15 @@ BOOL freerdp_channel_peer_process(freerdp_peer* client, wStream* s, UINT16 chann
UINT32 flags;
int chunk_length;
if(Stream_GetRemainingLength(s) < 8)
if (Stream_GetRemainingLength(s) < 8)
return FALSE;
Stream_Read_UINT32(s, length);
Stream_Read_UINT32(s, flags);
chunk_length = Stream_GetRemainingLength(s);
IFCALL(client->ReceiveChannelData, client,
channel_id, Stream_Pointer(s), chunk_length, flags, length);
return TRUE;
}

View File

@ -475,12 +475,20 @@ BOOL rdp_recv_client_info(rdpRdp* rdp, wStream* s)
BOOL rdp_send_client_info(rdpRdp* rdp)
{
wStream* s;
BOOL status;
//rdp->settings->crypt_flags |= SEC_INFO_PKT;
rdp->sec_flags |= SEC_INFO_PKT;
s = rdp_send_stream_init(rdp);
s = Stream_New(NULL, 2048);
rdp_init_stream(rdp, s);
rdp_write_info_packet(s, rdp->settings);
return rdp_send(rdp, s, MCS_GLOBAL_CHANNEL_ID);
status = rdp_send(rdp, s, MCS_GLOBAL_CHANNEL_ID);
Stream_Free(s, TRUE);
return status;
}
BOOL rdp_recv_logon_info_v1(rdpRdp* rdp, wStream* s)

View File

@ -467,12 +467,28 @@ void nego_attempt_rdp(rdpNego* nego)
BOOL nego_recv_response(rdpNego* nego)
{
wStream* s = transport_recv_stream_init(nego->transport, 1024);
int status;
wStream* s;
if (transport_read(nego->transport, s) < 0)
s = Stream_New(NULL, 1024);
status = transport_read(nego->transport, s);
if (status < 0)
{
Stream_Free(s, TRUE);
return FALSE;
}
return ((nego_recv(nego->transport, s, nego) < 0) ? FALSE : TRUE);
status = nego_recv(nego->transport, s, nego);
if (status < 0)
{
Stream_Free(s, TRUE);
return FALSE;
}
return TRUE;
}
/**

View File

@ -188,41 +188,43 @@ static int rdp_security_stream_init(rdpRdp* rdp, wStream* s)
return 0;
}
/**
* Initialize an RDP packet stream.\n
* @param rdp rdp module
* @return
*/
int rdp_init_stream(rdpRdp* rdp, wStream* s)
{
Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH);
rdp_security_stream_init(rdp, s);
return 0;
}
wStream* rdp_send_stream_init(rdpRdp* rdp)
{
wStream* s;
s = transport_send_stream_init(rdp->transport, 2048);
Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH);
rdp_security_stream_init(rdp, s);
rdp_init_stream(rdp, s);
return s;
}
wStream* rdp_pdu_init(rdpRdp* rdp)
int rdp_init_stream_pdu(rdpRdp* rdp, wStream* s)
{
wStream* s;
s = transport_send_stream_init(rdp->transport, 2048);
Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH);
rdp_security_stream_init(rdp, s);
Stream_Seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH);
return s;
return 0;
}
int rdp_init_stream_data_pdu(rdpRdp* rdp, wStream* s)
{
Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH);
rdp_security_stream_init(rdp, s);
Stream_Seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH);
Stream_Seek(s, RDP_SHARE_DATA_HEADER_LENGTH);
return 0;
}
wStream* rdp_data_pdu_init(rdpRdp* rdp)
{
wStream* s;
s = transport_send_stream_init(rdp->transport, 2048);
Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH);
rdp_security_stream_init(rdp, s);
Stream_Seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH);
Stream_Seek(s, RDP_SHARE_DATA_HEADER_LENGTH);
rdp_init_stream_data_pdu(rdp, s);
return s;
}
@ -264,12 +266,14 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channel_id
if (Stream_GetRemainingLength(s) < 5)
return FALSE;
per_read_integer16(s, &initiator, MCS_BASE_CHANNEL_ID); /* initiator (UserId) */
per_read_integer16(s, channel_id, 0); /* channelId */
Stream_Seek(s, 1); /* dataPriority + Segmentation (0x70) */
if (!per_read_length(s, length)) /* userData (OCTET_STRING) */
return FALSE;
if (*length > Stream_GetRemainingLength(s))
return FALSE;
@ -405,9 +409,9 @@ static UINT32 rdp_get_sec_bytes(rdpRdp* rdp)
BOOL rdp_send(rdpRdp* rdp, wStream* s, UINT16 channel_id)
{
int secm;
UINT16 length;
UINT32 sec_bytes;
BYTE* sec_hold;
length = Stream_GetPosition(s);
Stream_SetPosition(s, 0);
@ -415,10 +419,10 @@ BOOL rdp_send(rdpRdp* rdp, wStream* s, UINT16 channel_id)
rdp_write_header(rdp, s, length, channel_id);
sec_bytes = rdp_get_sec_bytes(rdp);
sec_hold = Stream_Pointer(s);
secm = Stream_GetPosition(s);
Stream_Seek(s, sec_bytes);
Stream_Pointer(s) = sec_hold;
Stream_SetPosition(s, secm);
length += rdp_security_stream_out(rdp, s, length);
Stream_SetPosition(s, length);
@ -434,7 +438,7 @@ BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id)
{
UINT16 length;
UINT32 sec_bytes;
BYTE* sec_hold;
int sec_hold;
length = Stream_GetPosition(s);
Stream_SetPosition(s, 0);
@ -442,12 +446,12 @@ BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id)
rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID);
sec_bytes = rdp_get_sec_bytes(rdp);
sec_hold = Stream_Pointer(s);
sec_hold = Stream_GetPosition(s);
Stream_Seek(s, sec_bytes);
rdp_write_share_control_header(s, length - sec_bytes, type, channel_id);
Stream_Pointer(s) = sec_hold;
Stream_SetPosition(s, sec_hold);
length += rdp_security_stream_out(rdp, s, length);
Stream_SetPosition(s, length);
@ -463,7 +467,7 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id)
{
UINT16 length;
UINT32 sec_bytes;
BYTE* sec_hold;
int sec_hold;
length = Stream_GetPosition(s);
Stream_SetPosition(s, 0);
@ -471,13 +475,13 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id)
rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID);
sec_bytes = rdp_get_sec_bytes(rdp);
sec_hold = Stream_Pointer(s);
sec_hold = Stream_GetPosition(s);
Stream_Seek(s, sec_bytes);
rdp_write_share_control_header(s, length - sec_bytes, PDU_TYPE_DATA, channel_id);
rdp_write_share_data_header(s, length - sec_bytes, type, rdp->settings->ShareId);
Stream_Pointer(s) = sec_hold;
Stream_SetPosition(s, sec_hold);
length += rdp_security_stream_out(rdp, s, length);
Stream_SetPosition(s, length);
@ -891,21 +895,6 @@ static int rdp_recv_pdu(rdpRdp* rdp, wStream* s)
return rdp_recv_fastpath_pdu(rdp, s);
}
/**
* Receive an RDP packet.\n
* @param rdp RDP module
*/
void rdp_recv(rdpRdp* rdp)
{
wStream* s;
s = transport_recv_stream_init(rdp->transport, 4096);
transport_read(rdp->transport, s);
rdp_recv_pdu(rdp, s);
}
static int rdp_recv_callback(rdpTransport* transport, wStream* s, void* extra)
{
int status = 0;

View File

@ -170,12 +170,13 @@ BOOL rdp_read_share_data_header(wStream* s, UINT16* length, BYTE* type, UINT32*
void rdp_write_share_data_header(wStream* s, UINT16 length, BYTE type, UINT32 share_id);
int rdp_init_stream(rdpRdp* rdp, wStream* s);
wStream* rdp_send_stream_init(rdpRdp* rdp);
BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channel_id);
void rdp_write_header(rdpRdp* rdp, wStream* s, UINT16 length, UINT16 channel_id);
wStream* rdp_pdu_init(rdpRdp* rdp);
int rdp_init_stream_pdu(rdpRdp* rdp, wStream* s);
BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id);
wStream* rdp_data_pdu_init(rdpRdp* rdp);
@ -183,7 +184,6 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id);
int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s);
BOOL rdp_send(rdpRdp* rdp, wStream* s, UINT16 channel_id);
void rdp_recv(rdpRdp* rdp);
int rdp_send_channel_data(rdpRdp* rdp, int channel_id, BYTE* data, int size);

View File

@ -50,14 +50,6 @@
static void* transport_client_thread(void* arg);
wStream* transport_recv_stream_init(rdpTransport* transport, int size)
{
wStream* s = transport->ReceiveStream;
Stream_EnsureCapacity(s, size);
Stream_SetPosition(s, 0);
return s;
}
wStream* transport_send_stream_init(rdpTransport* transport, int size)
{
wStream* s = transport->SendStream;
@ -842,7 +834,6 @@ rdpTransport* transport_new(rdpSettings* settings)
transport->connectedEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
/* buffers for blocking read/write */
transport->ReceiveStream = StreamPool_Take(transport->ReceivePool, 0);
transport->SendStream = Stream_New(NULL, BUFFER_SIZE);
transport->blocking = TRUE;
@ -860,9 +851,6 @@ void transport_free(rdpTransport* transport)
if (transport->ReceiveBuffer)
Stream_Release(transport->ReceiveBuffer);
if (transport->ReceiveStream)
Stream_Release(transport->ReceiveStream);
StreamPool_Free(transport->ReceivePool);
Stream_Free(transport->SendStream, TRUE);

View File

@ -76,7 +76,6 @@ struct rdp_transport
BOOL async;
};
wStream* transport_recv_stream_init(rdpTransport* transport, int size);
wStream* transport_send_stream_init(rdpTransport* transport, int size);
BOOL transport_connect(rdpTransport* transport, const char* hostname, UINT16 port);
void transport_attach(rdpTransport* transport, int sockfd);