connect error codes added

This commit is contained in:
norrarvid 2012-04-13 13:16:08 +02:00
parent 6e5a5a0fe5
commit 86faf2d268
5 changed files with 47 additions and 2 deletions

View File

@ -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" {

View File

@ -103,6 +103,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;
}

View File

@ -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;
}

View File

@ -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>
@ -93,6 +94,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;
@ -113,6 +117,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;
@ -131,6 +138,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");

View File

@ -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;
}