wtsvc: implement channel open/close.

This commit is contained in:
Vic Lee 2011-12-12 14:12:16 +08:00
parent 3b3c27648d
commit b1ee431a3e
5 changed files with 110 additions and 5 deletions

View File

@ -20,7 +20,8 @@
set(FREERDP_CHANNELS_SRCS set(FREERDP_CHANNELS_SRCS
libchannels.c libchannels.c
libchannels.h libchannels.h
wtsvc.c) wtsvc.c
wtsvc.h)
add_library(freerdp-channels ${FREERDP_CHANNELS_SRCS}) add_library(freerdp-channels ${FREERDP_CHANNELS_SRCS})

View File

@ -21,16 +21,52 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/memory.h> #include <freerdp/utils/memory.h>
#include <freerdp/channels/wtsvc.h>
#include "wtsvc.h"
void* WTSVirtualChannelOpenEx( void* WTSVirtualChannelOpenEx(
/* __in */ freerdp_peer* client, /* __in */ freerdp_peer* client,
/* __in */ const char* pVirtualName, /* __in */ const char* pVirtualName,
/* __in */ uint32 flags) /* __in */ uint32 flags)
{ {
return NULL; int i;
int len;
rdpPeerChannel* channel;
const char* channel_name;
channel_name = ((flags & WTS_CHANNEL_OPTION_DYNAMIC) != 0 ? "drdynvc" : pVirtualName);
len = strlen(channel_name);
if (len > 8)
return NULL;
for (i = 0; i < client->settings->num_channels; i++)
{
if (client->settings->channels[i].joined &&
strncmp(client->settings->channels[i].name, channel_name, len) == 0)
{
break;
}
}
if (i >= client->settings->num_channels)
return NULL;
channel = xnew(rdpPeerChannel);
channel->client = client;
channel->channel_id = client->settings->channels[i].channel_id;
if ((flags & WTS_CHANNEL_OPTION_DYNAMIC) != 0)
{
channel->channel_type = RDP_PEER_CHANNEL_TYPE_DVC;
/* TODO: do DVC channel initialization here using pVirtualName */
}
else
{
channel->channel_type = RDP_PEER_CHANNEL_TYPE_SVC;
}
return channel;
} }
boolean WTSVirtualChannelQuery( boolean WTSVirtualChannelQuery(
@ -69,5 +105,10 @@ boolean WTSVirtualChannelWrite(
boolean WTSVirtualChannelClose( boolean WTSVirtualChannelClose(
/* __in */ void* hChannelHandle) /* __in */ void* hChannelHandle)
{ {
return false; rdpPeerChannel* channel = (rdpPeerChannel*) hChannelHandle;
if (channel != NULL)
xfree(channel);
return true;
} }

View File

@ -0,0 +1,41 @@
/**
* FreeRDP: A Remote Desktop Protocol client.
* Server Virtual Channel Interface
*
* Copyright 2011-2012 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.
*/
#ifndef __WTSVC_H
#define __WTSVC_H
#include <freerdp/freerdp.h>
#include <freerdp/utils/list.h>
#include <freerdp/utils/mutex.h>
#include <freerdp/channels/wtsvc.h>
enum
{
RDP_PEER_CHANNEL_TYPE_SVC = 0,
RDP_PEER_CHANNEL_TYPE_DVC = 1
};
typedef struct rdp_peer_channel
{
freerdp_peer* client;
uint16 channel_id;
uint16 channel_type;
} rdpPeerChannel;
#endif /* __WTSVC_H */

View File

@ -23,3 +23,4 @@ add_executable(tfreerdp-server
target_link_libraries(tfreerdp-server freerdp-core) target_link_libraries(tfreerdp-server freerdp-core)
target_link_libraries(tfreerdp-server freerdp-utils) target_link_libraries(tfreerdp-server freerdp-utils)
target_link_libraries(tfreerdp-server freerdp-codec) target_link_libraries(tfreerdp-server freerdp-codec)
target_link_libraries(tfreerdp-server freerdp-channels)

View File

@ -31,6 +31,7 @@
#include <freerdp/utils/thread.h> #include <freerdp/utils/thread.h>
#include <freerdp/codec/rfx.h> #include <freerdp/codec/rfx.h>
#include <freerdp/listener.h> #include <freerdp/listener.h>
#include <freerdp/channels/wtsvc.h>
static char* test_pcap_file = NULL; static char* test_pcap_file = NULL;
static boolean test_dump_rfx_realtime = true; static boolean test_dump_rfx_realtime = true;
@ -54,6 +55,7 @@ struct test_peer_context
int icon_x; int icon_x;
int icon_y; int icon_y;
boolean activated; boolean activated;
void* debug_channel;
}; };
typedef struct test_peer_context testPeerContext; typedef struct test_peer_context testPeerContext;
@ -319,6 +321,9 @@ void tf_peer_dump_rfx(freerdp_peer* client)
boolean tf_peer_post_connect(freerdp_peer* client) boolean tf_peer_post_connect(freerdp_peer* client)
{ {
int i;
testPeerContext* context = (testPeerContext*) client->context;
/** /**
* This callback is called when the entire connection sequence is done, i.e. we've received the * This callback is called when the entire connection sequence is done, i.e. we've received the
* Font List PDU from the client and sent out the Font Map PDU. * Font List PDU from the client and sent out the Font Map PDU.
@ -342,6 +347,22 @@ boolean tf_peer_post_connect(freerdp_peer* client)
/* A real server should tag the peer as activated here and start sending updates in mainloop. */ /* A real server should tag the peer as activated here and start sending updates in mainloop. */
test_peer_load_icon(client); test_peer_load_icon(client);
/* Iterate all channel names requested by the client and activate those supported by the server */
for (i = 0; i < client->settings->num_channels; i++)
{
if (client->settings->channels[i].joined)
{
if (strncmp(client->settings->channels[i].name, "rdpdbg", 6) == 0)
{
context->debug_channel = WTSVirtualChannelOpenEx(client, "rdpdbg", 0);
if (context->debug_channel != NULL)
{
printf("Open channel rdpdbg.\n");
}
}
}
}
/* Return false here would stop the execution of the peer mainloop. */ /* Return false here would stop the execution of the peer mainloop. */
return true; return true;
} }