Skip to content

Commit

Permalink
server: implement user-initiated disconnection sequence on server.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vic Lee committed Apr 13, 2012
1 parent fcf07f7 commit 3a407c2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/freerdp/peer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef void (*psPeerContextFree)(freerdp_peer* client, rdpContext* context);
typedef boolean (*psPeerInitialize)(freerdp_peer* client);
typedef boolean (*psPeerGetFileDescriptor)(freerdp_peer* client, void** rfds, int* rcount);
typedef boolean (*psPeerCheckFileDescriptor)(freerdp_peer* client);
typedef boolean (*psPeerClose)(freerdp_peer* client);
typedef void (*psPeerDisconnect)(freerdp_peer* client);
typedef boolean (*psPeerCapabilities)(freerdp_peer* client);
typedef boolean (*psPeerPostConnect)(freerdp_peer* client);
Expand All @@ -57,6 +58,7 @@ struct rdp_freerdp_peer
psPeerInitialize Initialize;
psPeerGetFileDescriptor GetFileDescriptor;
psPeerCheckFileDescriptor CheckFileDescriptor;
psPeerClose Close;
psPeerDisconnect Disconnect;

psPeerCapabilities Capabilities;
Expand Down
13 changes: 13 additions & 0 deletions libfreerdp-core/peer.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,18 @@ static boolean peer_recv_callback(rdpTransport* transport, STREAM* s, void* extr
return true;
}

static boolean freerdp_peer_close(freerdp_peer* client)
{
/**
* [MS-RDPBCGR] 1.3.1.4.2 User-Initiated Disconnection Sequence on Server
* The server first sends the client a Deactivate All PDU followed by an
* optional MCS Disconnect Provider Ultimatum PDU.
*/
if (!rdp_send_deactivate_all(client->context->rdp))
return false;
return mcs_send_disconnect_provider_ultimatum(client->context->rdp->mcs);
}

static void freerdp_peer_disconnect(freerdp_peer* client)
{
transport_disconnect(client->context->rdp->transport);
Expand Down Expand Up @@ -351,6 +363,7 @@ freerdp_peer* freerdp_peer_new(int sockfd)
client->Initialize = freerdp_peer_initialize;
client->GetFileDescriptor = freerdp_peer_get_fds;
client->CheckFileDescriptor = freerdp_peer_check_fds;
client->Close = freerdp_peer_close;
client->Disconnect = freerdp_peer_disconnect;
client->SendChannelData = freerdp_peer_send_channel_data;
}
Expand Down
4 changes: 4 additions & 0 deletions server/test/tfreerdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ void tf_peer_keyboard_event(rdpInput* input, uint16 flags, uint16 code)
WTSVirtualChannelWrite(context->debug_channel, (uint8*) "test2", 5, NULL);
}
}
else if ((flags & 0x4000) && code == 0x2D) /* 'x' key */
{
client->Close(client);
}
}

void tf_peer_unicode_keyboard_event(rdpInput* input, uint16 flags, uint16 code)
Expand Down

0 comments on commit 3a407c2

Please sign in to comment.