]> andersk Git - gssapi-openssh.git/blobdiff - openssh/sshconnect.c
openssh-4.4p1-hpn12v13.diff
[gssapi-openssh.git] / openssh / sshconnect.c
index a7a4e8a9691b8c5955b3a037df7ba7287e1ab080..e96f02639252569a943fe7decdceb284b28292b4 100644 (file)
@@ -163,6 +163,31 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command)
        return 0;
 }
 
+/*
+ * Set TCP receive buffer if requested.
+ * Note: tuning needs to happen after the socket is
+ * created but before the connection happens
+ * so winscale is negotiated properly -cjr
+ */
+static void
+ssh_set_socket_recvbuf(int sock)
+{
+       void *buf = (void *)&options.tcp_rcv_buf;
+       int sz = sizeof(options.tcp_rcv_buf);
+       int socksize;
+       int socksizelen = sizeof(int);
+
+       debug("setsockopt Attempting to set SO_RCVBUF to %d", options.tcp_rcv_buf);
+       if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, buf, sz) >= 0) {
+         getsockopt(sock, SOL_SOCKET, SO_RCVBUF, &socksize, &socksizelen);
+         debug("setsockopt SO_RCVBUF: %.100s %d", strerror(errno), socksize);
+       }
+       else
+               error("Couldn't set socket receive buffer to %d: %.100s",
+                   options.tcp_rcv_buf, strerror(errno));
+}
+
+
 /*
  * Creates a (possibly privileged) socket for use as the ssh connection.
  */
@@ -186,13 +211,19 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
                            strerror(errno));
                else
                        debug("Allocated local port %d.", p);
+
+               if (options.tcp_rcv_buf > 0)
+                       ssh_set_socket_recvbuf(sock);           
                return sock;
        }
        sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
        if (sock < 0)
                error("socket: %.100s", strerror(errno));
-
-       /* Bind the socket to an alternative local IP address */
+       
+               if (options.tcp_rcv_buf > 0)
+                       ssh_set_socket_recvbuf(sock);
+       
+               /* Bind the socket to an alternative local IP address */
        if (options.bind_address == NULL)
                return sock;
 
@@ -488,7 +519,7 @@ ssh_exchange_identification(void)
        snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s\n",
            compat20 ? PROTOCOL_MAJOR_2 : PROTOCOL_MAJOR_1,
            compat20 ? PROTOCOL_MINOR_2 : minor1,
-           SSH_VERSION);
+           SSH_RELEASE);
        if (atomicio(vwrite, connection_out, buf, strlen(buf)) != strlen(buf))
                fatal("write: %.100s", strerror(errno));
        client_version_string = xstrdup(buf);
This page took 0.036196 seconds and 4 git commands to generate.