rdp: fix byte and packet counters

Best to count bytes directly at the transport level.
This commit is contained in:
David Fort 2019-10-28 12:46:18 +01:00 committed by akallabeth
parent 59d5f888a3
commit 824d09169e
3 changed files with 12 additions and 5 deletions

View File

@ -363,6 +363,7 @@ static int peer_recv_tpkt_pdu(freerdp_peer* client, wStream* s)
return -1;
}
rdp->inPackets++;
if (freerdp_shall_disconnect(rdp->instance))
return 0;
@ -451,6 +452,8 @@ static int peer_recv_fastpath_pdu(freerdp_peer* client, wStream* s)
return -1;
}
rdp->inPackets++;
return fastpath_recv_inputs(fastpath, s);
}

View File

@ -654,7 +654,6 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id)
WLog_DBG(TAG, "%s: sending data (type=0x%x size=%"PRIuz" channelId=%"PRIu16")", __FUNCTION__,
type, Stream_Length(s), channel_id);
rdp->outBytes += Stream_GetRemainingLength(s);
rdp->outPackets++;
if (transport_write(rdp->transport, s) < 0)
goto fail;
@ -1196,7 +1195,6 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s)
return -1;
}
rdp->inPackets++;
if (freerdp_shall_disconnect(rdp->instance))
return 0;
@ -1229,6 +1227,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s)
* - no share control header, nor the 2 byte pad
*/
Stream_Rewind(s, 2);
rdp->inPackets++;
return rdp_recv_enhanced_security_redirection_packet(rdp, s);
}
}
@ -1247,6 +1246,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s)
nextPosition += pduLength;
rdp->settings->PduSource = pduSource;
rdp->inPackets++;
switch (pduType)
{
@ -1291,11 +1291,13 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s)
if (!rdp->settings->UseRdpSecurityLayer)
if (!rdp_read_security_header(s, &securityFlags, NULL))
return -1;
rdp->inPackets++;
return rdp_recv_message_channel_pdu(rdp, s, securityFlags);
}
else
{
rdp->inPackets++;
if (!freerdp_channel_process(rdp->instance, s, channelId))
{
WLog_ERR(TAG, "rdp_recv_tpkt_pdu: freerdp_channel_process() fail");
@ -1357,8 +1359,6 @@ int rdp_recv_callback(rdpTransport* transport, wStream* s, void* extra)
int status = 0;
rdpRdp* rdp = (rdpRdp*) extra;
rdp->inBytes += Stream_GetRemainingLength(s);
/*
* At any point in the connection sequence between when all
* MCS channels have been joined and when the RDP connection

View File

@ -551,6 +551,7 @@ static void transport_bio_error_log(rdpTransport* transport, LPCSTR biofunc, BIO
SSIZE_T transport_read_layer(rdpTransport* transport, BYTE* data, size_t bytes)
{
SSIZE_T read = 0;
rdpRdp *rdp = transport->context->rdp;
if (!transport->frontBio || (bytes > SSIZE_MAX))
{
@ -598,6 +599,7 @@ SSIZE_T transport_read_layer(rdpTransport* transport, BYTE* data, size_t bytes)
VALGRIND_MAKE_MEM_DEFINED(data + read, bytes - read);
#endif
read += status;
rdp->inBytes += status;
}
return read;
@ -793,6 +795,7 @@ int transport_write(rdpTransport* transport, wStream* s)
size_t length;
int status = -1;
int writtenlength = 0;
rdpRdp *rdp = transport->context->rdp;
if (!s)
return -1;
@ -813,6 +816,7 @@ int transport_write(rdpTransport* transport, wStream* s)
if (length > 0)
{
rdp->outBytes += length;
WLog_Packet(transport->log, WLOG_TRACE, Stream_Buffer(s), length,
WLOG_PACKET_OUTBOUND);
}