13#include <winpr/wtsapi.h>
15#include <freerdp/client.h>
16#include <freerdp/channels/channels.h>
22#define TEST_CHANNEL_ID 1004
23#define TEST_OPEN_HANDLE 7
31static void VCAPITYPE test_open_event(LPVOID userParam, WINPR_ATTR_UNUSED DWORD openHandle,
32 UINT event, WINPR_ATTR_UNUSED LPVOID data,
33 WINPR_ATTR_UNUSED UINT32 dataLength,
34 WINPR_ATTR_UNUSED UINT32 totalLength,
35 WINPR_ATTR_UNUSED UINT32 flags)
37 TEST_STATE* state = userParam;
39 if (event == CHANNEL_EVENT_DATA_RECEIVED)
43static BOOL test_bridge_send(WINPR_ATTR_UNUSED
void* custom, WINPR_ATTR_UNUSED
const BYTE* data,
44 WINPR_ATTR_UNUSED
size_t length)
49static void test_bridge_free(
void* custom)
51 TEST_STATE* state = custom;
56int TestClientStaticBridge(WINPR_ATTR_UNUSED
int argc, WINPR_ATTR_UNUSED
char* argv[])
59 TEST_STATE state = WINPR_C_ARRAY_INIT;
60 const BYTE data[] = { 1, 2, 3, 4 };
62 RDP_CLIENT_ENTRY_POINTS entry = WINPR_C_ARRAY_INIT;
63 entry.Version = RDP_CLIENT_INTERFACE_VERSION;
64 entry.Size =
sizeof(RDP_CLIENT_ENTRY_POINTS_V1);
65 entry.ContextSize =
sizeof(rdpClientContext);
67 rdpContext* context = freerdp_client_context_new(&entry);
68 if (!context || !context->channels || !context->rdp || !context->rdp->mcs)
71 rdpChannels* channels = context->channels;
72 rdpMcs* mcs = context->rdp->mcs;
75 channels->openDataCount = 1;
76 openData->channels = channels;
77 openData->lpUserParam = &state;
78 openData->pChannelOpenEventProcEx = test_open_event;
79 openData->stats.channelId = TEST_OPEN_HANDLE;
80 (void)strncpy(openData->stats.channelName,
"test", CHANNEL_NAME_LEN);
82 mcs->channelCount = 1;
83 mcs->channels[0].ChannelId = TEST_CHANNEL_ID;
84 mcs->channels[0].joined = TRUE;
85 (void)strncpy(mcs->channels[0].Name,
"test", CHANNEL_NAME_LEN);
88 if (!freerdp_channels_data(context->instance, TEST_CHANNEL_ID, data,
sizeof(data),
89 CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST,
sizeof(data)) ||
90 (state.deliveries != 1))
93 if (!freerdp_channels_set_static_bridge(context->instance,
"test", test_bridge_send,
94 test_bridge_free, &state))
98 if (!freerdp_channels_data(context->instance, TEST_CHANNEL_ID, data,
sizeof(data),
99 CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST,
sizeof(data)) ||
100 (state.deliveries != 1))
104 if (!freerdp_channels_data_bridge(context->instance, TEST_CHANNEL_ID, data,
sizeof(data),
105 CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST,
sizeof(data)) ||
106 (state.deliveries != 2))
109 if (!freerdp_channels_set_static_bridge(context->instance,
"test",
nullptr,
nullptr, &state) ||
110 (state.bridgeFrees != 1))
114 if (!freerdp_channels_data(context->instance, TEST_CHANNEL_ID, data,
sizeof(data),
115 CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST,
sizeof(data)) ||
116 (state.deliveries != 2))
121 freerdp_client_context_free(context);