aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2010-01-26 12:25:03 +0000
committerDaniel Stenberg <daniel@haxx.se>2010-01-26 12:25:03 +0000
commit9bc897f380423f40bc9e5f22c12c670f5a28a369 (patch)
tree007581d3ed8efa519466d183b1ff71d2b0987ae8
parent9b0e57b0f79c4e267c9953e5fba69c3ecf8a5951 (diff)
Andre Guibert de Bruet improved the libssh2 error code translation
-rw-r--r--lib/ssh.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/ssh.c b/lib/ssh.c
index 71a8de386..edc89fde8 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -264,8 +264,36 @@ static CURLcode sftp_libssh2_error_to_CURLE(int err)
static CURLcode libssh2_session_error_to_CURLE(int err)
{
- if(err == LIBSSH2_ERROR_ALLOC)
- return CURLE_OUT_OF_MEMORY;
+ switch (err) {
+ /* Ordered by order of appearance in libssh2.h */
+ case LIBSSH2_ERROR_NONE:
+ return CURLE_OK;
+
+ case LIBSSH2_ERROR_SOCKET_NONE:
+ return CURLE_COULDNT_CONNECT;
+
+ case LIBSSH2_ERROR_ALLOC:
+ return CURLE_OUT_OF_MEMORY;
+
+ case LIBSSH2_ERROR_SOCKET_SEND:
+ return CURLE_SEND_ERROR;
+
+ case LIBSSH2_ERROR_HOSTKEY_INIT:
+ case LIBSSH2_ERROR_HOSTKEY_SIGN:
+ case LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED:
+ case LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED:
+ return CURLE_PEER_FAILED_VERIFICATION;
+
+ case LIBSSH2_ERROR_PASSWORD_EXPIRED:
+ return CURLE_LOGIN_DENIED;
+
+ case LIBSSH2_ERROR_SOCKET_TIMEOUT:
+ case LIBSSH2_ERROR_TIMEOUT:
+ return CURLE_OPERATION_TIMEDOUT;
+
+ case LIBSSH2_ERROR_EAGAIN:
+ return CURLE_AGAIN;
+ }
/* TODO: map some more of the libssh2 errors to the more appropriate CURLcode
error code, and possibly add a few new SSH-related one. We must however