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

Diff for /src/usr.bin/ssh/canohost.c between version 1.8 and 1.9

version 1.8, 1999/11/24 19:53:44 version 1.9, 1999/12/09 00:00:52
Line 143 
Line 143 
 static char *canonical_host_name = NULL;  static char *canonical_host_name = NULL;
 static char *canonical_host_ip = NULL;  static char *canonical_host_ip = NULL;
   
   /* Returns 1 if remote host is connected via socket, 0 if not. */
   
   int
   peer_connection_is_on_socket()
   {
           struct sockaddr_in from;
           int fromlen;
           int in = packet_get_connection_in();
           int out = packet_get_connection_out();
   
           /* filedescriptors in and out are the same, so it's a socket */
           if (in == out)
                   return 1;
           fromlen = sizeof(from);
           memset(&from, 0, sizeof(from));
           if (getpeername(in, (struct sockaddr *) & from, &fromlen) < 0)
                   return 0;
           if (from.sin_family != AF_INET && from.sin_family != AF_INET6)
                   return 0;
           return 1;
   }
   
 /*  /*
  * Return the canonical name of the host in the other side of the current   * Return the canonical name of the host in the other side of the current
  * connection.  The host name is cached, so it is efficient to call this   * connection.  The host name is cached, so it is efficient to call this
Line 157 
Line 179 
                 return canonical_host_name;                  return canonical_host_name;
   
         /* Get the real hostname if socket; otherwise return UNKNOWN. */          /* Get the real hostname if socket; otherwise return UNKNOWN. */
         if (packet_get_connection_in() == packet_get_connection_out())          if (peer_connection_is_on_socket())
                 canonical_host_name = get_remote_hostname(packet_get_connection_in());                  canonical_host_name = get_remote_hostname(packet_get_connection_in());
         else          else
                 canonical_host_name = xstrdup("UNKNOWN");                  canonical_host_name = xstrdup("UNKNOWN");
Line 181 
Line 203 
                 return canonical_host_ip;                  return canonical_host_ip;
   
         /* If not a socket, return UNKNOWN. */          /* If not a socket, return UNKNOWN. */
         if (packet_get_connection_in() != packet_get_connection_out()) {          if (!peer_connection_is_on_socket()) {
                 canonical_host_ip = xstrdup("UNKNOWN");                  canonical_host_ip = xstrdup("UNKNOWN");
                 return canonical_host_ip;                  return canonical_host_ip;
         }          }
Line 232 
Line 254 
          * If the connection is not a socket, return 65535.  This is           * If the connection is not a socket, return 65535.  This is
          * intentionally chosen to be an unprivileged port number.           * intentionally chosen to be an unprivileged port number.
          */           */
         if (packet_get_connection_in() != packet_get_connection_out())          if (!peer_connection_is_on_socket())
                 return 65535;                  return 65535;
   
         /* Get client socket. */          /* Get client socket. */

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9