Merge pull request #155 from samhed/disconnectreasons

Handle more disconnect reasons
This commit is contained in:
Henrik Andersson 2017-10-05 10:53:43 +02:00 committed by GitHub
commit 12b28b83d7
4 changed files with 248 additions and 109 deletions

View File

@ -540,31 +540,50 @@ enum RDP_INPUT_DEVICE
#define RDPDR_CLIENT_DISPLAY_NAME_PDU 0x00000002
#define RDPDR_USER_LOGGEDON_PDU 0x00000004
/* RDP5 disconnect PDU */
#define exDiscReasonNoInfo 0x0000
#define exDiscReasonAPIInitiatedDisconnect 0x0001
#define exDiscReasonAPIInitiatedLogoff 0x0002
#define exDiscReasonServerIdleTimeout 0x0003
#define exDiscReasonServerLogonTimeout 0x0004
#define exDiscReasonReplacedByOtherConnection 0x0005
#define exDiscReasonOutOfMemory 0x0006
#define exDiscReasonServerDeniedConnection 0x0007
#define exDiscReasonServerDeniedConnectionFips 0x0008
#define exDiscReasonServerInsufficientPrivileges 0x0009
#define exDiscReasonServerFreshCredentialsRequired 0x000a
#define exDiscReasonRPCInitiatedDisconnectByUser 0x000b
#define exDiscReasonByUser 0x000c
#define exDiscReasonLicenseInternal 0x0100
#define exDiscReasonLicenseNoLicenseServer 0x0101
#define exDiscReasonLicenseNoLicense 0x0102
#define exDiscReasonLicenseErrClientMsg 0x0103
#define exDiscReasonLicenseHwidDoesntMatchLicense 0x0104
#define exDiscReasonLicenseErrClientLicense 0x0105
#define exDiscReasonLicenseCantFinishProtocol 0x0106
#define exDiscReasonLicenseClientEndedProtocol 0x0107
#define exDiscReasonLicenseErrClientEncryption 0x0108
#define exDiscReasonLicenseCantUpgradeLicense 0x0109
#define exDiscReasonLicenseNoRemoteConnections 0x010a
/* RDP5 disconnect PDU
*
* Named after the corresponding names on the server side:
* https://msdn.microsoft.com/en-us/library/cc240544.aspx
*/
#define ERRINFO_NO_INFO 0x0000
#define ERRINFO_RPC_INITIATED_DISCONNECT 0x0001
#define ERRINFO_RPC_INITIATED_LOGOFF 0x0002
#define ERRINFO_IDLE_TIMEOUT 0x0003
#define ERRINFO_LOGON_TIMEOUT 0x0004
#define ERRINFO_DISCONNECTED_BY_OTHERCONNECTION 0x0005
#define ERRINFO_OUT_OF_MEMORY 0x0006
#define ERRINFO_SERVER_DENIED_CONNECTION 0x0007
#define ERRINFO_SERVER_DENIED_CONNECTION_FIPS 0x0008
#define ERRINFO_SERVER_INSUFFICIENT_PRIVILEGES 0x0009
#define ERRINFO_SERVER_FRESH_CREDENTIALS_REQUIRED 0x000a
#define ERRINFO_RPC_INITIATED_DISCONNECT_BYUSER 0x000b
#define ERRINFO_LOGOFF_BYUSER 0x000c
#define ERRINFO_LICENSE_INTERNAL 0x0100
#define ERRINFO_LICENSE_NO_LICENSE_SERVER 0x0101
#define ERRINFO_LICENSE_NO_LICENSE 0x0102
#define ERRINFO_LICENSE_BAD_CLIENT_MSG 0x0103
#define ERRINFO_LICENSE_HWID_DOESNT_MATCH_LICENSE 0x0104
#define ERRINFO_LICENSE_BAD_CLIENT_LICENSE 0x0105
#define ERRINFO_LICENSE_CANT_FINISH_PROTOCOL 0x0106
#define ERRINFO_LICENSE_CLIENT_ENDED_PROTOCOL 0x0107
#define ERRINFO_LICENSE_BAD_CLIENT_ENCRYPTION 0x0108
#define ERRINFO_LICENSE_CANT_UPGRADE_LICENSE 0x0109
#define ERRINFO_LICENSE_NO_REMOTE_CONNECTIONS 0x010a
#define ERRINFO_CB_DESTINATION_NOT_FOUND 0x0400
#define ERRINFO_CB_LOADING_DESTINATION 0x0402
#define ERRINFO_CB_REDIRECTING_TO_DESTINATION 0x0404
#define ERRINFO_CB_SESSION_ONLINE_VM_WAKE 0x0405
#define ERRINFO_CB_SESSION_ONLINE_VM_BOOT 0x0406
#define ERRINFO_CB_SESSION_ONLINE_VM_NO_DNS 0x0407
#define ERRINFO_CB_DESTINATION_POOL_NOT_FREE 0x0408
#define ERRINFO_CB_CONNECTION_CANCELLED 0x0409
#define ERRINFO_CB_CONNECTION_ERROR_INVALID_SETTINGS 0x0410
#define ERRINFO_CB_SESSION_ONLINE_VM_BOOT_TIMEOUT 0x0411
#define ERRINFO_CB_SESSION_ONLINE_VM_SESSMON_FAILED 0x0412
#define ERRINFO_REMOTEAPPSNOTENABLED 0x10f3
#define ERRINFO_UPDATESESSIONKEYFAILED 0x1191
#define ERRINFO_DECRYPTFAILED 0x1192
#define ERRINFO_ENCRYPTFAILED 0x1193
/* SeamlessRDP constants */
#define SEAMLESSRDP_NOTYETMAPPED -1

View File

@ -274,13 +274,13 @@ Specify the card name for example; "Telia EID IP5a".
.IP "\fB0\fP"
RDP session terminated normally
.IP "\fB1\fP"
Server initiated disconnect (also returned for logoff by XP joined to a domain)
Administrator initiated disconnect (also returned for logoff by XP joined to a domain)
.IP "\fB2\fP"
Server initiated logoff
Administrator initiated logout
.IP "\fB3\fP"
Server idle timeout reached
Server idle session time limit reached
.IP "\fB4\fP"
Server logon timeout reached
Server active session time limit reached
.IP "\fB5\fP"
The session was replaced
.IP "\fB6\fP"
@ -288,7 +288,7 @@ The server is out of memory
.IP "\fB7\fP"
The server denied the connection
.IP "\fB8\fP"
The server denied the connection for security reason
The server denied the connection for security reasons
.IP "\fB9\fP"
The user cannot connect to the server due to insufficient access
privileges
@ -296,9 +296,9 @@ privileges
The server does not accept saved user credentials and requires that
the user enter their credentials for each connection
.IP "\fB11\fP"
Disconnect initiated by administration tool
.IP "\fB12\fP"
Disconnect initiated by user
.IP "\fB12\fP"
Logout initiated by user
.IP "\fB16\fP"
Internal licensing error
.IP "\fB17\fP"
@ -306,11 +306,11 @@ No license server available
.IP "\fB18\fP"
No valid license available
.IP "\fB19\fP"
Invalid licensing message
Invalid licensing message from client
.IP "\fB20\fP"
Hardware id doesn't match software license
The client license has been modified and does no longer match the hardware ID
.IP "\fB21\fP"
Client license error
The client license is in an invalid format
.IP "\fB22\fP"
Network error during licensing protocol
.IP "\fB23\fP"
@ -318,9 +318,39 @@ Licensing protocol was not completed
.IP "\fB24\fP"
Incorrect client license enryption
.IP "\fB25\fP"
Can't upgrade license
Can't upgrade or renew license
.IP "\fB26\fP"
The server is not licensed to accept remote connections
.IP "\fB30\fP"
The target endpoint chosen by the broker could not be found
.IP "\fB32\fP"
The target endpoint is disconnecting from the broker
.IP "\fB34\fP"
Error occured while being redirected by broker
.IP "\fB35\fP"
Error while the endpoint VM was being awakened by the broker
.IP "\fB36\fP"
Error while the endpoint VM was being started by the broker
.IP "\fB37\fP"
The IP address of the endpoint VM could not be determined by the broker
.IP "\fB38\fP"
No available endpoints in the connection broker pool
.IP "\fB39\fP"
Connection processing cancelled by the broker
.IP "\fB40\fP"
The connection settings could not be validated by the broker
.IP "\fB41\fP"
Timeout while the endpoint VM was being started by the broker
.IP "\fB42\fP"
Session monitoring error while the endpoint VM was being started by the broker
.IP "\fB50\fP"
The server can only host Remote Applications
.IP "\fB51\fP"
Update of session keys failed
.IP "\fB52\fP"
Decryption or session key creation failed
.IP "\fB53\fP"
Encryption failed
.IP "\fB62\fP"
The local client window was closed
.IP "\fB63\fP"

View File

@ -266,7 +266,7 @@ handle_disconnect_reason(RD_BOOL deactivated, uint16 reason)
switch (reason)
{
case exDiscReasonNoInfo:
case ERRINFO_NO_INFO:
text = "No information available";
if (deactivated)
retval = EX_OK;
@ -274,134 +274,206 @@ handle_disconnect_reason(RD_BOOL deactivated, uint16 reason)
retval = EXRD_UNKNOWN;
break;
case exDiscReasonAPIInitiatedDisconnect:
text = "Server initiated disconnect";
retval = EXRD_API_DISCONNECT;
case ERRINFO_RPC_INITIATED_DISCONNECT:
text = "Administrator initiated disconnect";
retval = EXRD_DISCONNECT_BY_ADMIN;
break;
case exDiscReasonAPIInitiatedLogoff:
text = "Server initiated logoff";
retval = EXRD_API_LOGOFF;
case ERRINFO_RPC_INITIATED_LOGOFF:
text = "Administrator initiated logout";
retval = EXRD_LOGOFF_BY_ADMIN;
break;
case exDiscReasonServerIdleTimeout:
text = "Server idle timeout reached";
case ERRINFO_IDLE_TIMEOUT:
text = "Server idle session time limit reached";
retval = EXRD_IDLE_TIMEOUT;
break;
case exDiscReasonServerLogonTimeout:
text = "Server logon timeout reached";
case ERRINFO_LOGON_TIMEOUT:
text = "Server active session time limit reached";
retval = EXRD_LOGON_TIMEOUT;
break;
case exDiscReasonReplacedByOtherConnection:
case ERRINFO_DISCONNECTED_BY_OTHERCONNECTION:
text = "The session was replaced";
retval = EXRD_REPLACED;
break;
case exDiscReasonOutOfMemory:
case ERRINFO_OUT_OF_MEMORY:
text = "The server is out of memory";
retval = EXRD_OUT_OF_MEM;
break;
case exDiscReasonServerDeniedConnection:
case ERRINFO_SERVER_DENIED_CONNECTION:
text = "The server denied the connection";
retval = EXRD_DENIED;
break;
case exDiscReasonServerDeniedConnectionFips:
text = "The server denied the connection for security reason";
case ERRINFO_SERVER_DENIED_CONNECTION_FIPS:
text = "The server denied the connection for security reasons";
retval = EXRD_DENIED_FIPS;
break;
case exDiscReasonServerInsufficientPrivileges:
case ERRINFO_SERVER_INSUFFICIENT_PRIVILEGES:
text = "The user cannot connect to the server due to insufficient access privileges.";
retval = EXRD_INSUFFICIENT_PRIVILEGES;
break;
case exDiscReasonServerFreshCredentialsRequired:
case ERRINFO_SERVER_FRESH_CREDENTIALS_REQUIRED:
text = "The server does not accept saved user credentials and requires that the user enter their credentials for each connection.";
retval = EXRD_FRESH_CREDENTIALS_REQUIRED;
break;
case exDiscReasonRPCInitiatedDisconnectByUser:
text = "Disconnect initiated by administration tool";
retval = EXRD_RPC_DISCONNECT_BY_USER;
break;
case exDiscReasonByUser:
case ERRINFO_RPC_INITIATED_DISCONNECT_BYUSER:
text = "Disconnect initiated by user";
retval = EXRD_DISCONNECT_BY_USER;
break;
case exDiscReasonLicenseInternal:
case ERRINFO_LOGOFF_BYUSER:
text = "Logout initiated by user";
retval = EXRD_LOGOFF_BY_USER;
break;
case ERRINFO_LICENSE_INTERNAL:
text = "Internal licensing error";
retval = EXRD_LIC_INTERNAL;
break;
case exDiscReasonLicenseNoLicenseServer:
case ERRINFO_LICENSE_NO_LICENSE_SERVER:
text = "No license server available";
retval = EXRD_LIC_NOSERVER;
break;
case exDiscReasonLicenseNoLicense:
case ERRINFO_LICENSE_NO_LICENSE:
text = "No valid license available";
retval = EXRD_LIC_NOLICENSE;
break;
case exDiscReasonLicenseErrClientMsg:
text = "Invalid licensing message";
case ERRINFO_LICENSE_BAD_CLIENT_MSG:
text = "Invalid licensing message from client";
retval = EXRD_LIC_MSG;
break;
case exDiscReasonLicenseHwidDoesntMatchLicense:
text = "Hardware id doesn't match software license";
case ERRINFO_LICENSE_HWID_DOESNT_MATCH_LICENSE:
text = "The client license has been modified and does no longer match the hardware ID";
retval = EXRD_LIC_HWID;
break;
case exDiscReasonLicenseErrClientLicense:
text = "Client license error";
case ERRINFO_LICENSE_BAD_CLIENT_LICENSE:
text = "The client license is in an invalid format";
retval = EXRD_LIC_CLIENT;
break;
case exDiscReasonLicenseCantFinishProtocol:
case ERRINFO_LICENSE_CANT_FINISH_PROTOCOL:
text = "Network error during licensing protocol";
retval = EXRD_LIC_NET;
break;
case exDiscReasonLicenseClientEndedProtocol:
case ERRINFO_LICENSE_CLIENT_ENDED_PROTOCOL:
text = "Licensing protocol was not completed";
retval = EXRD_LIC_PROTO;
break;
case exDiscReasonLicenseErrClientEncryption:
case ERRINFO_LICENSE_BAD_CLIENT_ENCRYPTION:
text = "Incorrect client license encryption";
retval = EXRD_LIC_ENC;
break;
case exDiscReasonLicenseCantUpgradeLicense:
text = "Can't upgrade license";
case ERRINFO_LICENSE_CANT_UPGRADE_LICENSE:
text = "Can't upgrade or renew license";
retval = EXRD_LIC_UPGRADE;
break;
case exDiscReasonLicenseNoRemoteConnections:
case ERRINFO_LICENSE_NO_REMOTE_CONNECTIONS:
text = "The server is not licensed to accept remote connections";
retval = EXRD_LIC_NOREMOTE;
break;
case ERRINFO_CB_DESTINATION_NOT_FOUND:
text = "The target endpoint chosen by the broker could not be found";
retval = EXRD_CB_DEST_NOT_FOUND;
break;
case ERRINFO_CB_LOADING_DESTINATION:
text = "The target endpoint is disconnecting from the broker";
retval = EXRD_CB_DEST_LOADING;
break;
case ERRINFO_CB_REDIRECTING_TO_DESTINATION:
text = "Error occured while being redirected by broker";
retval = EXRD_CB_REDIR_DEST;
break;
case ERRINFO_CB_SESSION_ONLINE_VM_WAKE:
text = "Error while the endpoint VM was being awakened by the broker";
retval = EXRD_CB_VM_WAKE;
break;
case ERRINFO_CB_SESSION_ONLINE_VM_BOOT:
text = "Error while the endpoint VM was being started by the broker";
retval = EXRD_CB_VM_BOOT;
break;
case ERRINFO_CB_SESSION_ONLINE_VM_NO_DNS:
text = "The IP address of the endpoint VM could not be determined by the broker";
retval = EXRD_CB_VM_NODNS;
break;
case ERRINFO_CB_DESTINATION_POOL_NOT_FREE:
text = "No available endpoints in the connection broker pool";
retval = EXRD_CB_DEST_POOL_NOT_FREE;
break;
case ERRINFO_CB_CONNECTION_CANCELLED:
text = "Connection processing cancelled by the broker";
retval = EXRD_CB_CONNECTION_CANCELLED;
break;
case ERRINFO_CB_CONNECTION_ERROR_INVALID_SETTINGS:
text = "The connection settings could not be validated by the broker";
retval = EXRD_CB_INVALID_SETTINGS;
break;
case ERRINFO_CB_SESSION_ONLINE_VM_BOOT_TIMEOUT:
text = "Timeout while the endpoint VM was being started by the broker";
retval = EXRD_CB_VM_BOOT_TIMEOUT;
break;
case ERRINFO_CB_SESSION_ONLINE_VM_SESSMON_FAILED:
text = "Session monitoring error while the endpoint VM was being started by the broker";
retval = EXRD_CB_VM_BOOT_SESSMON_FAILED;
break;
case ERRINFO_REMOTEAPPSNOTENABLED:
text = "The server can only host Remote Applications";
retval = EXRD_RDP_REMOTEAPPSNOTENABLED;
break;
case ERRINFO_UPDATESESSIONKEYFAILED:
text = "Update of session keys failed";
retval = EXRD_RDP_UPDATESESSIONKEYFAILED;
break;
case ERRINFO_DECRYPTFAILED:
text = "Decryption or session key creation failed";
retval = EXRD_RDP_DECRYPTFAILED;
break;
case ERRINFO_ENCRYPTFAILED:
text = "Encryption failed";
retval = EXRD_RDP_ENCRYPTFAILED;
break;
default:
if (reason > 0x1000 && reason < 0x7fff)
{
text = "Internal protocol error";
}
else
{
text = "Unknown reason";
}
text = "Unknown reason";
retval = EXRD_UNKNOWN;
}
if (reason != exDiscReasonNoInfo)
if (reason > 0x1000 && reason < 0x7fff && retval == EXRD_UNKNOWN) {
fprintf(stderr, "Internal protocol error: %x", reason);
} else if (reason != ERRINFO_NO_INFO) {
fprintf(stderr, "disconnect: %s.\n", text);
}
return retval;
}

View File

@ -92,33 +92,51 @@
#endif
/* rdesktop specific exit codes, lined up with disconnect PDU reasons */
#define EXRD_API_DISCONNECT 1
#define EXRD_API_LOGOFF 2
#define EXRD_IDLE_TIMEOUT 3
#define EXRD_LOGON_TIMEOUT 4
#define EXRD_REPLACED 5
#define EXRD_OUT_OF_MEM 6
#define EXRD_DENIED 7
#define EXRD_DENIED_FIPS 8
#define EXRD_INSUFFICIENT_PRIVILEGES 9
#define EXRD_FRESH_CREDENTIALS_REQUIRED 10
#define EXRD_RPC_DISCONNECT_BY_USER 11
#define EXRD_DISCONNECT_BY_USER 12
#define EXRD_LIC_INTERNAL 16
#define EXRD_LIC_NOSERVER 17
#define EXRD_LIC_NOLICENSE 18
#define EXRD_LIC_MSG 19
#define EXRD_LIC_HWID 20
#define EXRD_LIC_CLIENT 21
#define EXRD_LIC_NET 22
#define EXRD_LIC_PROTO 23
#define EXRD_LIC_ENC 24
#define EXRD_LIC_UPGRADE 25
#define EXRD_LIC_NOREMOTE 26
#define EXRD_DISCONNECT_BY_ADMIN 1
#define EXRD_LOGOFF_BY_ADMIN 2
#define EXRD_IDLE_TIMEOUT 3
#define EXRD_LOGON_TIMEOUT 4
#define EXRD_REPLACED 5
#define EXRD_OUT_OF_MEM 6
#define EXRD_DENIED 7
#define EXRD_DENIED_FIPS 8
#define EXRD_INSUFFICIENT_PRIVILEGES 9
#define EXRD_FRESH_CREDENTIALS_REQUIRED 10
#define EXRD_DISCONNECT_BY_USER 11
#define EXRD_LOGOFF_BY_USER 12
#define EXRD_LIC_INTERNAL 16
#define EXRD_LIC_NOSERVER 17
#define EXRD_LIC_NOLICENSE 18
#define EXRD_LIC_MSG 19
#define EXRD_LIC_HWID 20
#define EXRD_LIC_CLIENT 21
#define EXRD_LIC_NET 22
#define EXRD_LIC_PROTO 23
#define EXRD_LIC_ENC 24
#define EXRD_LIC_UPGRADE 25
#define EXRD_LIC_NOREMOTE 26
#define EXRD_CB_DEST_NOT_FOUND 30
#define EXRD_CB_DEST_LOADING 32
#define EXRD_CB_REDIR_DEST 34
#define EXRD_CB_VM_WAKE 35
#define EXRD_CB_VM_BOOT 36
#define EXRD_CB_VM_NODNS 37
#define EXRD_CB_DEST_POOL_NOT_FREE 38
#define EXRD_CB_CONNECTION_CANCELLED 39
#define EXRD_CB_INVALID_SETTINGS 40
#define EXRD_CB_VM_BOOT_TIMEOUT 41
#define EXRD_CB_VM_BOOT_SESSMON_FAILED 42
#define EXRD_RDP_REMOTEAPPSNOTENABLED 50
#define EXRD_RDP_UPDATESESSIONKEYFAILED 51
#define EXRD_RDP_DECRYPTFAILED 52
#define EXRD_RDP_ENCRYPTFAILED 53
/* other exit codes */
#define EXRD_WINDOW_CLOSED 62
#define EXRD_UNKNOWN 63
#define EXRD_WINDOW_CLOSED 62
#define EXRD_UNKNOWN 63
#define STRNCPY(dst,src,n) { strncpy(dst,src,n-1); dst[n-1] = 0; }