[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

libssh-0.6.4 Connection to server and build problem


Hello
I use your perfect library for my project on Windows.
I decide to migrate from libssh  0.4.8 to 0.6.4.
I don't use pre-compiled library (prefer to build myself).
For building libssh I use VisualStudio 2010 Express (static build).

I've built libssh with following environmental:
Windows 7 32 bit
zlib - 1.2.8
openssl - 1.0.1j

I haven't got any problem with libssh-0.4.8 but with libssh I have two
problem

1) When I try to build libssh I've got following error:
sftp.obj : error LNK2019: unresolved external symbol _htonll referenced in
function _buffer_add_attributes
sftp.obj : error LNK2019: unresolved external symbol _ntohll referenced in
function _sftp_parse_attr_4

I've fixed this error comment
//#ifndef HAVE_HTONLL
in misc.c and misc.h
patch is attached

2) After fix this error I build my program successfull,     but I got
problem with connect to ssh server. When I call  ssh_connect(session) I got
error *Failed to connect: No error*.
I try to learn your source code and found interesting thing:

    rc = connect(s, itr->ai_addr, itr->ai_addrlen);
    if (rc == -1 && (errno != EINPROGRESS)) {
      ssh_set_error(session, SSH_FATAL,
          "Failed to connect: %s", strerror(errno));
      ssh_connect_socket_close(s);
      s = -1;
      continue;
    }
It's really interesting situation:
Cuz we use nonblocking socket our connect function return -1 but connect
successful done and *errno=0*.
I've fixed this error too (complex patch arrached to e-mail)

Best regards,
 Viktor Butskih
diff -uNrp libssh-0.6.4/include/libssh/misc.h libssh-0.6.4.win_fix2/include/libssh/misc.h
--- libssh-0.6.4/include/libssh/misc.h	2014-09-15 22:54:34.000000000 +0400
+++ libssh-0.6.4.win_fix2/include/libssh/misc.h	2014-12-23 15:14:13.788502000 +0400
@@ -33,14 +33,14 @@ int ssh_analyze_banner(ssh_session sessi
 int ssh_is_ipaddr_v4(const char *str);
 int ssh_is_ipaddr(const char *str);
 
-#ifndef HAVE_NTOHLL
+//#ifndef HAVE_NTOHLL
 /* macro for byte ordering */
 uint64_t ntohll(uint64_t);
-#endif
+//#endif
 
-#ifndef HAVE_HTONLL
+//#ifndef HAVE_HTONLL
 #define htonll(x) ntohll((x))
-#endif
+//#endif
 
 /* list processing */
 
diff -uNrp libssh-0.6.4/src/connect.c libssh-0.6.4.win_fix2/src/connect.c
--- libssh-0.6.4/src/connect.c	2014-12-05 13:42:06.000000000 +0400
+++ libssh-0.6.4.win_fix2/src/connect.c	2014-12-24 13:47:50.897760000 +0400
@@ -383,7 +383,7 @@ socket_t ssh_connect_host_nonblocking(ss
     }
 
     rc = connect(s, itr->ai_addr, itr->ai_addrlen);
-    if (rc == -1 && (errno != EINPROGRESS)) {
+    if (rc == -1 && (errno != EINPROGRESS) && errno != 0) {
       ssh_set_error(session, SSH_FATAL,
           "Failed to connect: %s", strerror(errno));
       ssh_connect_socket_close(s);
diff -uNrp libssh-0.6.4/src/misc.c libssh-0.6.4.win_fix2/src/misc.c
--- libssh-0.6.4/src/misc.c	2014-09-15 22:54:34.000000000 +0400
+++ libssh-0.6.4.win_fix2/src/misc.c	2014-12-23 15:13:36.962656000 +0400
@@ -289,7 +289,7 @@ int ssh_is_ipaddr(const char *str) {
 
 #endif /* _WIN32 */
 
-#ifndef HAVE_NTOHLL
+//#ifndef HAVE_NTOHLL
 uint64_t ntohll(uint64_t a) {
 #ifdef WORDS_BIGENDIAN
   return a;
@@ -304,7 +304,7 @@ uint64_t ntohll(uint64_t a) {
          ((uint64_t)(a)  >> 56));
 #endif /* WORDS_BIGENDIAN */
 }
-#endif /* HAVE_NTOHLL */
+//#endif /* HAVE_NTOHLL */
 
 char *ssh_lowercase(const char* str) {
   char *new, *p;

Follow-Ups:
Re: libssh-0.6.4 Connection to server and build problemAndreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org