libfreerdp-core: expose API for FreeRDS WTSVirtualChannelRead
This commit is contained in:
parent
11ae267518
commit
00e3533230
@ -52,6 +52,8 @@ typedef HANDLE (*psPeerVirtualChannelOpen)(freerdp_peer* client, const char* nam
|
|||||||
typedef BOOL (*psPeerVirtualChannelClose)(freerdp_peer* client, HANDLE hChannel);
|
typedef BOOL (*psPeerVirtualChannelClose)(freerdp_peer* client, HANDLE hChannel);
|
||||||
typedef int (*psPeerVirtualChannelRead)(freerdp_peer* client, HANDLE hChannel, BYTE* buffer, UINT32 length);
|
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 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
|
struct rdp_freerdp_peer
|
||||||
{
|
{
|
||||||
@ -89,6 +91,8 @@ struct rdp_freerdp_peer
|
|||||||
psPeerVirtualChannelClose VirtualChannelClose;
|
psPeerVirtualChannelClose VirtualChannelClose;
|
||||||
psPeerVirtualChannelRead VirtualChannelRead;
|
psPeerVirtualChannelRead VirtualChannelRead;
|
||||||
psPeerVirtualChannelWrite VirtualChannelWrite;
|
psPeerVirtualChannelWrite VirtualChannelWrite;
|
||||||
|
psPeerVirtualChannelGetData VirtualChannelGetData;
|
||||||
|
psPeerVirtualChannelSetData VirtualChannelSetData;
|
||||||
|
|
||||||
int pId;
|
int pId;
|
||||||
UINT32 ack_frame_id;
|
UINT32 ack_frame_id;
|
||||||
|
@ -143,8 +143,36 @@ BOOL freerdp_channel_peer_process(freerdp_peer* client, wStream* s, UINT16 chann
|
|||||||
Stream_Read_UINT32(s, flags);
|
Stream_Read_UINT32(s, flags);
|
||||||
chunkLength = Stream_GetRemainingLength(s);
|
chunkLength = Stream_GetRemainingLength(s);
|
||||||
|
|
||||||
IFCALL(client->ReceiveChannelData, client,
|
if (client->VirtualChannelRead)
|
||||||
channelId, Stream_Pointer(s), chunkLength, flags, length);
|
{
|
||||||
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -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)
|
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)
|
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;
|
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)
|
static BOOL freerdp_peer_initialize(freerdp_peer* client)
|
||||||
{
|
{
|
||||||
rdpRdp* rdp = client->context->rdp;
|
rdpRdp* rdp = client->context->rdp;
|
||||||
@ -635,6 +657,9 @@ freerdp_peer* freerdp_peer_new(int sockfd)
|
|||||||
client->VirtualChannelOpen = freerdp_peer_virtual_channel_open;
|
client->VirtualChannelOpen = freerdp_peer_virtual_channel_open;
|
||||||
client->VirtualChannelClose = freerdp_peer_virtual_channel_close;
|
client->VirtualChannelClose = freerdp_peer_virtual_channel_close;
|
||||||
client->VirtualChannelWrite = freerdp_peer_virtual_channel_write;
|
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;
|
return client;
|
||||||
|
@ -66,6 +66,7 @@ struct rdp_peer_channel
|
|||||||
WTSVirtualChannelManager* vcm;
|
WTSVirtualChannelManager* vcm;
|
||||||
freerdp_peer* client;
|
freerdp_peer* client;
|
||||||
|
|
||||||
|
void* extra;
|
||||||
UINT16 index;
|
UINT16 index;
|
||||||
UINT32 channelId;
|
UINT32 channelId;
|
||||||
UINT16 channelType;
|
UINT16 channelType;
|
||||||
|
Loading…
Reference in New Issue
Block a user