libfreerdp-core: check TPKT/FastPath header when processing a PDU.
authorVic Lee <llyzs@163.com>
Tue, 9 Aug 2011 08:40:58 +0000 (16:40 +0800)
committerVic Lee <llyzs@163.com>
Tue, 9 Aug 2011 08:40:58 +0000 (16:40 +0800)
libfreerdp-core/rdp.c
libfreerdp-core/rdp.h
libfreerdp-core/tpkt.c
libfreerdp-core/tpkt.h

index fa81b8f..c94ed16 100644 (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
index 6ec7385..ef3bfb7 100644 (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"
index dd39af9..a07d1cb 100644 (file)
  */
 
 /**
+ * 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 */
index 7cf846a..c754c1c 100644 (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 */