libfreerdp-core: check TPKT/FastPath header when processing a PDU.

This commit is contained in:
Vic Lee 2011-08-09 16:40:58 +08:00
parent 9f2a3e847b
commit e5419bed9f
4 changed files with 39 additions and 11 deletions

View File

@ -351,7 +351,7 @@ void rdp_read_data_pdu(rdpRdp* rdp, STREAM* s)
* @param s stream
*/
void rdp_process_pdu(rdpRdp* rdp, STREAM* s)
static void rdp_process_tpkt_pdu(rdpRdp* rdp, STREAM* s)
{
int length;
uint16 pduType;
@ -362,8 +362,6 @@ void rdp_process_pdu(rdpRdp* rdp, STREAM* s)
boolean processed;
enum DomainMCSPDU MCSPDU;
/* TODO: Check Fast Path header */
MCSPDU = DomainMCSPDU_SendDataIndication;
mcs_read_domain_mcspdu_header(s, &MCSPDU, &length);
@ -435,6 +433,21 @@ void rdp_process_pdu(rdpRdp* rdp, STREAM* s)
}
}
static void rdp_process_fastpath_pdu(rdpRdp* rdp, STREAM* s)
{
uint32 length = fastpath_read_header(s, NULL);
printf("FastPath PDU: length=%d\n", length);
}
static void rdp_process_pdu(rdpRdp* rdp, STREAM* s)
{
if (tpkt_verify_header(s))
rdp_process_tpkt_pdu(rdp, s);
else
rdp_process_fastpath_pdu(rdp, s);
}
/**
* Receive an RDP packet.\n
* @param rdp RDP module

View File

@ -24,6 +24,7 @@ typedef struct rdp_rdp rdpRdp;
#include "mcs.h"
#include "tpkt.h"
#include "fastpath.h"
#include "tpdu.h"
#include "nego.h"
#include "input.h"

View File

@ -53,14 +53,30 @@
* length includes the TPKT header (4 bytes), the maximum X.224 TPDU length is 65531.
*/
/**
* Verify if a packet has valid TPKT header.\n
* @param s
* @return boolean
*/
boolean tpkt_verify_header(STREAM* s)
{
uint8 version;
stream_peek_uint8(s, version);
if (version == 3)
return True;
else
return False;
}
/**
* Read a TPKT header.\n
* @param s
* @return length
*/
uint16
tpkt_read_header(STREAM* s)
uint16 tpkt_read_header(STREAM* s)
{
uint8 version;
uint16 length;
@ -87,8 +103,7 @@ tpkt_read_header(STREAM* s)
* @param length
*/
void
tpkt_write_header(STREAM* s, int length)
void tpkt_write_header(STREAM* s, int length)
{
stream_write_uint8(s, 3); /* version */
stream_write_uint8(s, 0); /* reserved */

View File

@ -27,9 +27,8 @@
#define TPKT_HEADER_LENGTH 4
uint16
tpkt_read_header(STREAM* s);
void
tpkt_write_header(STREAM* s, int length);
boolean tpkt_verify_header(STREAM* s);
uint16 tpkt_read_header(STREAM* s);
void tpkt_write_header(STREAM* s, int length);
#endif /* __TPKT_H */