[BACK]Return to packet.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/packet.c between version 1.18 and 1.19

version 1.18, 1999/12/15 20:03:23 version 1.19, 2000/01/04 00:07:59
Line 104 
Line 104 
         fatal_add_cleanup((void (*) (void *)) packet_close, NULL);          fatal_add_cleanup((void (*) (void *)) packet_close, NULL);
 }  }
   
   /* Returns 1 if remote host is connected via socket, 0 if not. */
   
   int
   packet_connection_is_on_socket()
   {
           struct sockaddr_storage from, to;
           socklen_t fromlen, tolen;
   
           /* filedescriptors in and out are the same, so it's a socket */
           if (connection_in == connection_out)
                   return 1;
           fromlen = sizeof(from);
           memset(&from, 0, sizeof(from));
           if (getpeername(connection_in, (struct sockaddr *) & from, &fromlen) < 0)
                   return 0;
           tolen = sizeof(to);
           memset(&to, 0, sizeof(to));
           if (getsockname(connection_out, (struct sockaddr *)&to, &tolen) < 0)
                   return 0;
           if (fromlen != tolen || memcmp(&from, &to, fromlen) != 0)
                   return 0;
           if (from.ss_family != AF_INET && from.ss_family != AF_INET6)
                   return 0;
           return 1;
   }
   
   /* returns 1 if connection is via ipv4 */
   
   int
   packet_connection_is_ipv4()
   {
           struct sockaddr_storage to;
           socklen_t tolen;
   
           memset(&to, 0, sizeof(to));
           if (getsockname(connection_out, (struct sockaddr *)&to, &tolen) < 0)
                   return 0;
           if (to.ss_family != AF_INET)
                   return 0;
           return 1;
   }
   
 /* Sets the connection into non-blocking mode. */  /* Sets the connection into non-blocking mode. */
   
 void  void
Line 735 
Line 777 
         /* Record that we are in interactive mode. */          /* Record that we are in interactive mode. */
         interactive_mode = interactive;          interactive_mode = interactive;
   
         /*          /* Only set socket options if using a socket.  */
          * Only set socket options if using a socket (as indicated by the          if (!packet_connection_is_on_socket())
          * descriptors being the same).  
          */  
         if (connection_in != connection_out)  
                 return;                  return;
   
         if (keepalives) {          if (keepalives) {
                 /* Set keepalives if requested. */                  /* Set keepalives if requested. */
                 if (setsockopt(connection_in, SOL_SOCKET, SO_KEEPALIVE, (void *) &on,                  if (setsockopt(connection_in, SOL_SOCKET, SO_KEEPALIVE, (void *) &on,
                                sizeof(on)) < 0)                      sizeof(on)) < 0)
                         error("setsockopt SO_KEEPALIVE: %.100s", strerror(errno));                          error("setsockopt SO_KEEPALIVE: %.100s", strerror(errno));
         }          }
           /*
            * IPTOS_LOWDELAY, TCP_NODELAY and IPTOS_THROUGHPUT are IPv4 only
            */
           if (!packet_connection_is_ipv4())
                   return;
         if (interactive) {          if (interactive) {
                 /*                  /*
                  * Set IP options for an interactive connection.  Use                   * Set IP options for an interactive connection.  Use
Line 755 
Line 798 
                  */                   */
                 int lowdelay = IPTOS_LOWDELAY;                  int lowdelay = IPTOS_LOWDELAY;
                 if (setsockopt(connection_in, IPPROTO_IP, IP_TOS, (void *) &lowdelay,                  if (setsockopt(connection_in, IPPROTO_IP, IP_TOS, (void *) &lowdelay,
                                sizeof(lowdelay)) < 0)                      sizeof(lowdelay)) < 0)
                         error("setsockopt IPTOS_LOWDELAY: %.100s", strerror(errno));                          error("setsockopt IPTOS_LOWDELAY: %.100s", strerror(errno));
                 if (setsockopt(connection_in, IPPROTO_TCP, TCP_NODELAY, (void *) &on,                  if (setsockopt(connection_in, IPPROTO_TCP, TCP_NODELAY, (void *) &on,
                                sizeof(on)) < 0)                      sizeof(on)) < 0)
                         error("setsockopt TCP_NODELAY: %.100s", strerror(errno));                          error("setsockopt TCP_NODELAY: %.100s", strerror(errno));
         } else {          } else {
                 /*                  /*
Line 767 
Line 810 
                  */                   */
                 int throughput = IPTOS_THROUGHPUT;                  int throughput = IPTOS_THROUGHPUT;
                 if (setsockopt(connection_in, IPPROTO_IP, IP_TOS, (void *) &throughput,                  if (setsockopt(connection_in, IPPROTO_IP, IP_TOS, (void *) &throughput,
                                sizeof(throughput)) < 0)                      sizeof(throughput)) < 0)
                         error("setsockopt IPTOS_THROUGHPUT: %.100s", strerror(errno));                          error("setsockopt IPTOS_THROUGHPUT: %.100s", strerror(errno));
         }          }
 }  }

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19