]> andersk Git - openssh.git/blobdiff - sshconnect.c
Hopefully things did not get mixed around too much. It compiles under
[openssh.git] / sshconnect.c
index 59b273a9c92f48bc65a223c4b5de94ea3916e37e..0994126c083fadb30c81a20d6c31a9c32a051976 100644 (file)
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: sshconnect.c,v 1.89 2001/01/04 22:41:03 markus Exp $");
+RCSID("$OpenBSD: sshconnect.c,v 1.91 2001/01/21 19:05:59 markus Exp $");
 
 #include <openssl/bn.h>
-#include <openssl/dsa.h>
-#include <openssl/rsa.h>
 
+#include "ssh.h"
 #include "xmalloc.h"
 #include "rsa.h"
-#include "ssh.h"
 #include "buffer.h"
 #include "packet.h"
 #include "uidswap.h"
 #include "compat.h"
-#include "readconf.h"
 #include "key.h"
 #include "sshconnect.h"
 #include "hostfile.h"
+#include "log.h"
+#include "readconf.h"
+#include "atomicio.h"
+#include "misc.h"
 
 char *client_version_string = NULL;
 char *server_version_string = NULL;
@@ -37,6 +38,9 @@ char *server_version_string = NULL;
 extern Options options;
 extern char *__progname;
 
+/* AF_UNSPEC or AF_INET or AF_INET6 */
+extern int IPv4or6;
+
 /*
  * Connect to the given ssh server using a proxy command.
  */
@@ -187,12 +191,13 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
            int anonymous, uid_t original_real_uid,
            const char *proxy_command)
 {
+       int gaierr;
+       int on = 1;
        int sock = -1, attempt;
-       struct servent *sp;
-       struct addrinfo hints, *ai, *aitop;
        char ntop[NI_MAXHOST], strport[NI_MAXSERV];
-       int gaierr;
+       struct addrinfo hints, *ai, *aitop;
        struct linger linger;
+       struct servent *sp;
 
        debug("ssh_connect: getuid %u geteuid %u anon %d",
              (u_int) getuid(), (u_int) geteuid(), anonymous);
@@ -298,7 +303,13 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
        /* setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)); */
        linger.l_onoff = 1;
        linger.l_linger = 5;
-       setsockopt(sock, SOL_SOCKET, SO_LINGER, (void *) &linger, sizeof(linger));
+       setsockopt(sock, SOL_SOCKET, SO_LINGER, (void *)&linger, sizeof(linger));
+
+       /* Set keepalives if requested. */
+       if (options.keepalives &&
+           setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&on,
+           sizeof(on)) < 0)
+               error("setsockopt SO_KEEPALIVE: %.100s", strerror(errno));
 
        /* Set the connection. */
        packet_set_connection(sock, sock);
This page took 0.186747 seconds and 4 git commands to generate.