2 * FreeRDP: A Remote Desktop Protocol Client
5 * Copyright 2011 Vic Lee
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.
20 #include <freerdp/utils/pcap.h>
24 static int update_recv_surfcmd_surface_bits(rdpUpdate* update, STREAM* s)
27 SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;
29 stream_read_uint16(s, cmd->destLeft);
30 stream_read_uint16(s, cmd->destTop);
31 stream_read_uint16(s, cmd->destRight);
32 stream_read_uint16(s, cmd->destBottom);
33 stream_read_uint8(s, cmd->bpp);
34 stream_seek(s, 2); /* reserved1, reserved2 */
35 stream_read_uint8(s, cmd->codecID);
36 stream_read_uint16(s, cmd->width);
37 stream_read_uint16(s, cmd->height);
38 stream_read_uint32(s, cmd->bitmapDataLength);
39 pos = stream_get_pos(s) + cmd->bitmapDataLength;
40 cmd->bitmapData = stream_get_tail(s);
42 IFCALL(update->SurfaceBits, update->context, cmd);
44 stream_set_pos(s, pos);
46 return 20 + cmd->bitmapDataLength;
49 static int update_recv_surfcmd_frame_marker(rdpUpdate* update, STREAM* s)
51 SURFACE_FRAME_MARKER* marker = &update->surface_frame_marker;
53 stream_read_uint16(s, marker->frameAction);
54 stream_read_uint32(s, marker->frameId);
56 IFCALL(update->SurfaceFrameMarker, update->context, marker);
61 boolean update_recv_surfcmds(rdpUpdate* update, uint32 size, STREAM* s)
69 stream_get_mark(s, mark);
71 stream_read_uint16(s, cmdType);
76 case CMDTYPE_SET_SURFACE_BITS:
77 case CMDTYPE_STREAM_SURFACE_BITS:
78 cmdLength = update_recv_surfcmd_surface_bits(update, s);
81 case CMDTYPE_FRAME_MARKER:
82 cmdLength = update_recv_surfcmd_frame_marker(update, s);
86 DEBUG_WARN("unknown cmdType 0x%X", cmdType);
94 pcap_add_record(update->pcap_rfx, mark, cmdLength + 2);
95 pcap_flush(update->pcap_rfx);
101 void update_write_surfcmd_surface_bits_header(STREAM* s, SURFACE_BITS_COMMAND* cmd)
103 stream_check_size(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH);
105 stream_write_uint16(s, CMDTYPE_STREAM_SURFACE_BITS);
107 stream_write_uint16(s, cmd->destLeft);
108 stream_write_uint16(s, cmd->destTop);
109 stream_write_uint16(s, cmd->destRight);
110 stream_write_uint16(s, cmd->destBottom);
111 stream_write_uint8(s, cmd->bpp);
112 stream_write_uint16(s, 0); /* reserved1, reserved2 */
113 stream_write_uint8(s, cmd->codecID);
114 stream_write_uint16(s, cmd->width);
115 stream_write_uint16(s, cmd->height);
116 stream_write_uint32(s, cmd->bitmapDataLength);
119 void update_write_surfcmd_frame_marker(STREAM* s, uint16 frameAction, uint32 frameId)
121 stream_check_size(s, SURFCMD_FRAME_MARKER_LENGTH);
123 stream_write_uint16(s, CMDTYPE_FRAME_MARKER);
125 stream_write_uint16(s, frameAction);
126 stream_write_uint32(s, frameId);