libfreerdp-core: expose API for FreeRDS WTSVirtualChannelRead

This commit is contained in:
Marc-André Moreau 2014-10-10 17:19:38 -04:00
parent 11ae267518
commit 00e3533230
4 changed files with 61 additions and 3 deletions

View File

@ -52,6 +52,8 @@ typedef HANDLE (*psPeerVirtualChannelOpen)(freerdp_peer* client, const char* nam
typedef BOOL (*psPeerVirtualChannelClose)(freerdp_peer* client, HANDLE hChannel);
typedef int (*psPeerVirtualChannelRead)(freerdp_peer* client, HANDLE hChannel, BYTE* buffer, UINT32 length);
typedef int (*psPeerVirtualChannelWrite)(freerdp_peer* client, HANDLE hChannel, BYTE* buffer, UINT32 length);
typedef void* (*psPeerVirtualChannelGetData)(freerdp_peer* client, HANDLE hChannel);
typedef int (*psPeerVirtualChannelSetData)(freerdp_peer* client, HANDLE hChannel, void* data);
struct rdp_freerdp_peer
{
@ -89,6 +91,8 @@ struct rdp_freerdp_peer
psPeerVirtualChannelClose VirtualChannelClose;
psPeerVirtualChannelRead VirtualChannelRead;
psPeerVirtualChannelWrite VirtualChannelWrite;
psPeerVirtualChannelGetData VirtualChannelGetData;
psPeerVirtualChannelSetData VirtualChannelSetData;
int pId;
UINT32 ack_frame_id;

View File

@ -143,8 +143,36 @@ BOOL freerdp_channel_peer_process(freerdp_peer* client, wStream* s, UINT16 chann
Stream_Read_UINT32(s, flags);
chunkLength = Stream_GetRemainingLength(s);
IFCALL(client->ReceiveChannelData, client,
channelId, Stream_Pointer(s), chunkLength, flags, length);
if (client->VirtualChannelRead)
{
UINT32 index;
BOOL found = FALSE;
HANDLE hChannel = 0;
rdpContext* context = client->context;
rdpMcs* mcs = context->rdp->mcs;
rdpMcsChannel* mcsChannel = NULL;
for (index = 0; index < mcs->channelCount; index++)
{
mcsChannel = &(mcs->channels[index]);
if (mcsChannel->ChannelId == channelId)
{
hChannel = (HANDLE) mcsChannel->handle;
found = TRUE;
break;
}
}
if (!found)
return FALSE;
client->VirtualChannelRead(client, hChannel, Stream_Pointer(s), Stream_GetRemainingLength(s));
}
else if (client->ReceiveChannelData)
{
client->ReceiveChannelData(client, channelId, Stream_Pointer(s), chunkLength, flags, length);
}
return TRUE;
}

View File

@ -113,7 +113,7 @@ static BOOL freerdp_peer_virtual_channel_close(freerdp_peer* client, HANDLE hCha
int freerdp_peer_virtual_channel_read(freerdp_peer* client, HANDLE hChannel, BYTE* buffer, UINT32 length)
{
return 1;
return 0; /* this needs to be implemented by the server application */
}
static int freerdp_peer_virtual_channel_write(freerdp_peer* client, HANDLE hChannel, BYTE* buffer, UINT32 length)
@ -170,6 +170,28 @@ static int freerdp_peer_virtual_channel_write(freerdp_peer* client, HANDLE hChan
return 1;
}
void* freerdp_peer_virtual_channel_get_data(freerdp_peer* client, HANDLE hChannel)
{
rdpPeerChannel* peerChannel = (rdpPeerChannel*) hChannel;
if (!hChannel)
return NULL;
return peerChannel->extra;
}
int freerdp_peer_virtual_channel_set_data(freerdp_peer* client, HANDLE hChannel, void* data)
{
rdpPeerChannel* peerChannel = (rdpPeerChannel*) hChannel;
if (!hChannel)
return -1;
peerChannel->extra = data;
return 1;
}
static BOOL freerdp_peer_initialize(freerdp_peer* client)
{
rdpRdp* rdp = client->context->rdp;
@ -635,6 +657,9 @@ freerdp_peer* freerdp_peer_new(int sockfd)
client->VirtualChannelOpen = freerdp_peer_virtual_channel_open;
client->VirtualChannelClose = freerdp_peer_virtual_channel_close;
client->VirtualChannelWrite = freerdp_peer_virtual_channel_write;
client->VirtualChannelRead = NULL; /* must be defined by server application */
client->VirtualChannelGetData = freerdp_peer_virtual_channel_get_data;
client->VirtualChannelSetData = freerdp_peer_virtual_channel_set_data;
}
return client;

View File

@ -66,6 +66,7 @@ struct rdp_peer_channel
WTSVirtualChannelManager* vcm;
freerdp_peer* client;
void* extra;
UINT16 index;
UINT32 channelId;
UINT16 channelType;