2011-07-19 10:07:15 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-07-19 10:07:15 +04:00
|
|
|
* Dynamic Virtual Channel Unit Tests
|
|
|
|
*
|
|
|
|
* 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 <string.h>
|
|
|
|
#include <stdlib.h>
|
2012-11-22 06:22:06 +04:00
|
|
|
|
2011-07-19 10:07:15 +04:00
|
|
|
#include <freerdp/freerdp.h>
|
|
|
|
#include <freerdp/constants.h>
|
2011-10-16 22:57:15 +04:00
|
|
|
#include <freerdp/channels/channels.h>
|
2011-07-19 10:07:15 +04:00
|
|
|
#include <freerdp/utils/event.h>
|
2012-12-14 08:54:54 +04:00
|
|
|
#include <winpr/print.h>
|
2011-07-19 10:07:15 +04:00
|
|
|
|
|
|
|
#include "test_drdynvc.h"
|
|
|
|
|
|
|
|
int init_drdynvc_suite(void)
|
|
|
|
{
|
2011-10-16 22:57:15 +04:00
|
|
|
freerdp_channels_global_init();
|
2011-07-19 10:07:15 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int clean_drdynvc_suite(void)
|
|
|
|
{
|
2011-10-16 22:57:15 +04:00
|
|
|
freerdp_channels_global_uninit();
|
2011-07-19 10:07:15 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int add_drdynvc_suite(void)
|
|
|
|
{
|
|
|
|
add_test_suite(drdynvc);
|
|
|
|
|
|
|
|
add_test_function(drdynvc);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
static const BYTE test_capability_request_data[] =
|
2011-07-19 10:07:15 +04:00
|
|
|
{
|
|
|
|
"\x58\x00\x02\x00\x33\x33\x11\x11\x3D\x0A\xA7\x04"
|
|
|
|
};
|
|
|
|
|
|
|
|
static int data_received = 0;
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
static int test_rdp_channel_data(freerdp* instance, int chan_id, BYTE* data, int data_size)
|
2011-07-19 10:07:15 +04:00
|
|
|
{
|
|
|
|
printf("chan_id %d data_size %d\n", chan_id, data_size);
|
2012-12-14 08:54:54 +04:00
|
|
|
winpr_HexDump(data, data_size);
|
2011-07-19 10:07:15 +04:00
|
|
|
data_received = 1;
|
2011-08-07 22:37:26 +04:00
|
|
|
return 0;
|
2011-07-19 10:07:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_drdynvc(void)
|
|
|
|
{
|
2011-10-16 22:57:15 +04:00
|
|
|
rdpChannels* chan_man;
|
2011-07-19 10:07:15 +04:00
|
|
|
rdpSettings settings = { 0 };
|
2011-07-28 09:04:01 +04:00
|
|
|
freerdp instance = { 0 };
|
2011-07-19 10:07:15 +04:00
|
|
|
|
2012-11-08 00:13:14 +04:00
|
|
|
settings.Hostname = "testhost";
|
2011-07-28 09:04:01 +04:00
|
|
|
instance.settings = &settings;
|
2011-08-02 22:12:08 +04:00
|
|
|
instance.SendChannelData = test_rdp_channel_data;
|
2011-07-19 10:07:15 +04:00
|
|
|
|
2011-10-16 22:57:15 +04:00
|
|
|
chan_man = freerdp_channels_new();
|
2011-07-19 10:07:15 +04:00
|
|
|
|
2011-10-16 22:57:15 +04:00
|
|
|
freerdp_channels_load_plugin(chan_man, &settings, "../channels/drdynvc/drdynvc.so", NULL);
|
|
|
|
freerdp_channels_pre_connect(chan_man, &instance);
|
|
|
|
freerdp_channels_post_connect(chan_man, &instance);
|
2011-07-19 10:07:15 +04:00
|
|
|
|
|
|
|
/* server sends capability request PDU */
|
2011-10-16 22:57:15 +04:00
|
|
|
freerdp_channels_data(&instance, 0, (char*)test_capability_request_data, sizeof(test_capability_request_data) - 1,
|
2011-07-19 10:07:15 +04:00
|
|
|
CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_capability_request_data) - 1);
|
|
|
|
|
|
|
|
/* drdynvc sends capability response PDU to server */
|
|
|
|
data_received = 0;
|
|
|
|
while (!data_received)
|
|
|
|
{
|
2011-10-16 22:57:15 +04:00
|
|
|
freerdp_channels_check_fds(chan_man, &instance);
|
2011-07-19 10:07:15 +04:00
|
|
|
}
|
|
|
|
|
2011-10-16 22:57:15 +04:00
|
|
|
freerdp_channels_close(chan_man, &instance);
|
|
|
|
freerdp_channels_free(chan_man);
|
2011-07-19 10:07:15 +04:00
|
|
|
}
|