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.
23 #include <freerdp/freerdp.h>
24 #include <freerdp/peer.h>
25 #include <freerdp/constants.h>
26 #include <freerdp/utils/memory.h>
27 #include <freerdp/utils/stream.h>
32 boolean freerdp_channel_send(rdpRdp* rdp, uint16 channel_id, uint8* data, int size)
38 rdpChannel* channel = NULL;
40 for (i = 0; i < rdp->settings->num_channels; i++)
42 if (rdp->settings->channels[i].channel_id == channel_id)
44 channel = &rdp->settings->channels[i];
51 printf("freerdp_channel_send: unknown channel_id %d\n", channel_id);
55 flags = CHANNEL_FLAG_FIRST;
59 s = rdp_send_stream_init(rdp);
61 if (left > (int) rdp->settings->vc_chunk_size)
63 chunk_size = rdp->settings->vc_chunk_size;
68 flags |= CHANNEL_FLAG_LAST;
70 if ((channel->options & CHANNEL_OPTION_SHOW_PROTOCOL))
72 flags |= CHANNEL_FLAG_SHOW_PROTOCOL;
75 stream_write_uint32(s, size);
76 stream_write_uint32(s, flags);
77 stream_check_size(s, chunk_size);
78 stream_write(s, data, chunk_size);
80 rdp_send(rdp, s, channel_id);
90 void freerdp_channel_process(freerdp* instance, STREAM* s, uint16 channel_id)
96 stream_read_uint32(s, length);
97 stream_read_uint32(s, flags);
98 chunk_length = stream_get_left(s);
100 IFCALL(instance->ReceiveChannelData, instance,
101 channel_id, stream_get_tail(s), chunk_length, flags, length);
104 void freerdp_channel_peer_process(freerdp_peer* client, STREAM* s, uint16 channel_id)
110 stream_read_uint32(s, length);
111 stream_read_uint32(s, flags);
112 chunk_length = stream_get_left(s);
114 IFCALL(client->ReceiveChannelData, client,
115 channel_id, stream_get_tail(s), chunk_length, flags, length);