libfreerdp-core: add Fast Path header parsing.
This commit is contained in:
parent
04f58fedde
commit
b380423cfb
@ -72,6 +72,8 @@ set(LIBFREERDP_CORE_SRCS
|
||||
tpdu.h
|
||||
tpkt.c
|
||||
tpkt.h
|
||||
fastpath.c
|
||||
fastpath.h
|
||||
transport.c
|
||||
transport.h
|
||||
update.c
|
||||
|
65
libfreerdp-core/fastpath.c
Normal file
65
libfreerdp-core/fastpath.c
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* Fast Path
|
||||
*
|
||||
* Copyright 2011 Vic Lee
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
|
||||
#include "fastpath.h"
|
||||
|
||||
/**
|
||||
* Fast-Path packet format is defined in [MS-RDPBCGR] 2.2.9.1.2, which revises
|
||||
* server output packets from the first byte with the goal of improving
|
||||
* bandwidth.
|
||||
*
|
||||
* Slow-Path packet always starts with TPKT header, which has the first
|
||||
* byte 0x03, while Fast-Path packet starts with 2 zero bits in the first
|
||||
* two less significant bits of the first byte.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Read a Fast-Path packet header.\n
|
||||
* @param s stream
|
||||
* @param encryptionFlags
|
||||
* @return length
|
||||
*/
|
||||
|
||||
uint16 fastpath_read_header(STREAM* s, uint8* encryptionFlags)
|
||||
{
|
||||
uint8 header;
|
||||
uint16 length;
|
||||
uint8 t;
|
||||
|
||||
stream_read_uint8(s, header);
|
||||
if (encryptionFlags != NULL)
|
||||
*encryptionFlags = (header & 0xC0) >> 6;
|
||||
|
||||
stream_read_uint8(s, length); /* length1 */
|
||||
/* If most significant bit is not set, length2 is not presented. */
|
||||
if ((length & 0x80))
|
||||
{
|
||||
length &= 0x7F;
|
||||
length <<= 8;
|
||||
stream_read_uint8(s, t);
|
||||
length += t;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
39
libfreerdp-core/fastpath.h
Normal file
39
libfreerdp-core/fastpath.h
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* Fast Path
|
||||
*
|
||||
* Copyright 2011 Vic Lee
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __FASTPATH_H
|
||||
#define __FASTPATH_H
|
||||
|
||||
#include <freerdp/utils/stream.h>
|
||||
|
||||
enum FASTPATH_OUTPUT_ACTION_TYPE
|
||||
{
|
||||
FASTPATH_OUTPUT_ACTION_FASTPATH = 0x0,
|
||||
FASTPATH_OUTPUT_ACTION_X224 = 0x3
|
||||
};
|
||||
|
||||
enum FASTPATH_OUTPUT_ENCRYPTION_FLAGS
|
||||
{
|
||||
FASTPATH_OUTPUT_SECURE_CHECKSUM = 0x1,
|
||||
FASTPATH_OUTPUT_ENCRYPTED = 0x2
|
||||
};
|
||||
|
||||
uint16 fastpath_read_header(STREAM* s, uint8* encryptionFlags);
|
||||
|
||||
#endif
|
@ -359,6 +359,8 @@ void rdp_process_pdu(rdpRdp* rdp, STREAM* s)
|
||||
uint16 sec_flags;
|
||||
enum DomainMCSPDU MCSPDU;
|
||||
|
||||
/* TODO: Check Fast Path header */
|
||||
|
||||
MCSPDU = DomainMCSPDU_SendDataIndication;
|
||||
mcs_read_domain_mcspdu_header(s, &MCSPDU, &length);
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "tpkt.h"
|
||||
#include "fastpath.h"
|
||||
#include "credssp.h"
|
||||
#include "transport.h"
|
||||
|
||||
@ -214,8 +215,8 @@ int transport_check_fds(rdpTransport* transport)
|
||||
stream_peek_uint8(transport->recv_buffer, header);
|
||||
if (header == 0x03) /* TPKT */
|
||||
length = tpkt_read_header(transport->recv_buffer);
|
||||
else /* TODO: Fast Path */
|
||||
length = 0;
|
||||
else /* Fast Path */
|
||||
length = fastpath_read_header(transport->recv_buffer, NULL);
|
||||
|
||||
if (length == 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user