mirror of https://github.com/FreeRDP/FreeRDP
commit
f142ac29d6
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* File: errorcodes.h
|
||||
* Author: Arvid
|
||||
*
|
||||
* Created on April 13, 2012, 9:09 AM
|
||||
*/
|
||||
|
||||
#ifndef ERRORCODES_H
|
||||
#define ERRORCODES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This static variable holds an error code if the return value from connect is false.
|
||||
* This variable is always set to 0 in the beginning of the connect sequence.
|
||||
* The returned code can be used to inform the user of the detailed connect error.
|
||||
* The value can hold one of the defined error codes below OR an error according to errno
|
||||
*/
|
||||
extern int connectErrorCode ;
|
||||
#define ERRORSTART 10000
|
||||
#define PREECONNECTERROR ERRORSTART + 1
|
||||
#define UNDEFINEDCONNECTERROR ERRORSTART + 2
|
||||
#define POSTCONNECTERROR ERRORSTART + 3
|
||||
#define DNSERROR ERRORSTART + 4 /* general DNS ERROR */
|
||||
#define DNSNAMENOTFOUND ERRORSTART + 5 /* EAI_NONAME */
|
||||
#define CONNECTERROR ERRORSTART + 6 /* a connect error if errno is not define during tcp connect */
|
||||
#define MCSCONNECTINITIALERROR ERRORSTART + 7
|
||||
#define TLSCONNECTERROR ERRORSTART + 8
|
||||
#define AUTHENTICATIONERROR ERRORSTART + 9
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ERRORCODES_H */
|
||||
|
|
@ -39,6 +39,7 @@ typedef struct rdp_freerdp_peer freerdp_peer;
|
|||
|
||||
#include <freerdp/input.h>
|
||||
#include <freerdp/update.h>
|
||||
#include <freerdp/errorcodes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -107,6 +107,9 @@ boolean rdp_client_connect(rdpRdp* rdp)
|
|||
|
||||
if (mcs_send_connect_initial(rdp->mcs) != true)
|
||||
{
|
||||
if(!connectErrorCode){
|
||||
connectErrorCode = MCSCONNECTINITIALERROR;
|
||||
}
|
||||
printf("Error: unable to send MCS Connect Initial\n");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/utils/memory.h>
|
||||
|
||||
/* connectErrorCode is 'extern' in errorcodes.h. See comment there.*/
|
||||
|
||||
/** Creates a new connection based on the settings found in the "instance" parameter
|
||||
* It will use the callbacks registered on the structure to process the pre/post connect operations
|
||||
* that the caller requires.
|
||||
|
@ -43,6 +45,8 @@ boolean freerdp_connect(freerdp* instance)
|
|||
{
|
||||
rdpRdp* rdp;
|
||||
boolean status = false;
|
||||
/* We always set the return code to 0 before we start the connect sequence*/
|
||||
connectErrorCode = 0 ;
|
||||
|
||||
rdp = instance->context->rdp;
|
||||
|
||||
|
@ -52,6 +56,9 @@ boolean freerdp_connect(freerdp* instance)
|
|||
|
||||
if (status != true)
|
||||
{
|
||||
if(!connectErrorCode){
|
||||
connectErrorCode = PREECONNECTERROR;
|
||||
}
|
||||
printf("freerdp_pre_connect failed\n");
|
||||
return false;
|
||||
}
|
||||
|
@ -74,6 +81,9 @@ boolean freerdp_connect(freerdp* instance)
|
|||
if (status != true)
|
||||
{
|
||||
printf("freerdp_post_connect failed\n");
|
||||
if(!connectErrorCode){
|
||||
connectErrorCode = POSTCONNECTERROR;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -109,7 +119,9 @@ boolean freerdp_connect(freerdp* instance)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!connectErrorCode){
|
||||
connectErrorCode = UNDEFINEDCONNECTERROR;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <freerdp/utils/stream.h>
|
||||
#include <freerdp/utils/memory.h>
|
||||
#include <freerdp/utils/hexdump.h>
|
||||
#include <freerdp/errorcodes.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
@ -88,6 +89,9 @@ boolean transport_connect_tls(rdpTransport* transport)
|
|||
transport->tls->sockfd = transport->tcp->sockfd;
|
||||
|
||||
if (tls_connect(transport->tls) != true) {
|
||||
if(!connectErrorCode){
|
||||
connectErrorCode = TLSCONNECTERROR;
|
||||
}
|
||||
tls_free(transport->tls);
|
||||
transport->tls = NULL;
|
||||
return false;
|
||||
|
@ -108,6 +112,9 @@ boolean transport_connect_nla(rdpTransport* transport)
|
|||
transport->tls->sockfd = transport->tcp->sockfd;
|
||||
|
||||
if (tls_connect(transport->tls) != true) {
|
||||
if(!connectErrorCode){
|
||||
connectErrorCode = TLSCONNECTERROR;
|
||||
}
|
||||
tls_free(transport->tls);
|
||||
transport->tls = NULL;
|
||||
return false;
|
||||
|
@ -126,6 +133,9 @@ boolean transport_connect_nla(rdpTransport* transport)
|
|||
|
||||
if (credssp_authenticate(transport->credssp) < 0)
|
||||
{
|
||||
if(!connectErrorCode){
|
||||
connectErrorCode = AUTHENTICATIONERROR;
|
||||
}
|
||||
printf("Authentication failure, check credentials.\n"
|
||||
"If credentials are valid, the NTLMSSP implementation may be to blame.\n");
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <freerdp/utils/tcp.h>
|
||||
#include <freerdp/utils/print.h>
|
||||
#include <freerdp/errorcodes.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -55,6 +56,9 @@
|
|||
|
||||
#endif
|
||||
|
||||
/* connectErrorCode is 'extern' in errorcodes.h. See comment there.*/
|
||||
int connectErrorCode ;
|
||||
|
||||
int freerdp_tcp_connect(const char* hostname, int port)
|
||||
{
|
||||
int status;
|
||||
|
@ -73,6 +77,14 @@ int freerdp_tcp_connect(const char* hostname, int port)
|
|||
|
||||
if (status != 0)
|
||||
{
|
||||
if(status==EAI_NONAME){
|
||||
if(!connectErrorCode){
|
||||
connectErrorCode = DNSNAMENOTFOUND;
|
||||
}
|
||||
}
|
||||
if(!connectErrorCode){
|
||||
connectErrorCode = DNSERROR;
|
||||
}
|
||||
printf("tcp_connect: getaddrinfo (%s)\n", gai_strerror(status));
|
||||
return -1;
|
||||
}
|
||||
|
@ -90,7 +102,14 @@ int freerdp_tcp_connect(const char* hostname, int port)
|
|||
printf("connected to %s:%s\n", hostname, servname);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!connectErrorCode){
|
||||
int tmperror = errno ;
|
||||
if(tmperror!=0){
|
||||
connectErrorCode = tmperror ;
|
||||
}else{
|
||||
connectErrorCode = CONNECTERROR;
|
||||
}
|
||||
}
|
||||
close(sockfd);
|
||||
sockfd = -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue