2 * FreeRDP: A Remote Desktop Protocol Client
3 * Transport Packets (TPKTs)
5 * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
25 * TPKTs are defined in:
27 * http://tools.ietf.org/html/rfc1006/
28 * RFC 1006 - ISO Transport Service on top of the TCP
30 * http://www.itu.int/rec/T-REC-T.123/
31 * ITU-T T.123 (01/2007) - Network-specific data protocol stacks for multimedia conferencing
34 * ____________________ byte
37 * |____________________|
40 * |____________________|
43 * |____________________|
46 * |____________________|
48 * | X.224 TPDU | 5 - ?
51 * A TPKT header is of fixed length 4, and the following X.224 TPDU is at least three bytes long.
52 * Therefore, the minimum TPKT length is 7, and the maximum TPKT length is 65535. Because the TPKT
53 * length includes the TPKT header (4 bytes), the maximum X.224 TPDU length is 65531.
57 * Verify if a packet has valid TPKT header.\n
62 boolean tpkt_verify_header(STREAM* s)
66 stream_peek_uint8(s, version);
74 * Read a TPKT header.\n
79 uint16 tpkt_read_header(STREAM* s)
84 stream_peek_uint8(s, version);
89 stream_read_uint16_be(s, length);
93 /* not a TPKT header */
101 * Write a TPKT header.\n
106 void tpkt_write_header(STREAM* s, uint16 length)
108 stream_write_uint8(s, 3); /* version */
109 stream_write_uint8(s, 0); /* reserved */
110 stream_write_uint16_be(s, length); /* length */