[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.229 and 1.230

version 1.229, 2016/02/17 22:20:14 version 1.230, 2016/03/07 19:02:43
Line 46 
Line 46 
 #include <netinet/ip.h>  #include <netinet/ip.h>
   
 #include <errno.h>  #include <errno.h>
   #include <netdb.h>
 #include <stdarg.h>  #include <stdarg.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 290 
Line 291 
             (r = cipher_init(&state->receive_context, none,              (r = cipher_init(&state->receive_context, none,
             (const u_char *)"", 0, NULL, 0, CIPHER_DECRYPT)) != 0) {              (const u_char *)"", 0, NULL, 0, CIPHER_DECRYPT)) != 0) {
                 error("%s: cipher_init failed: %s", __func__, ssh_err(r));                  error("%s: cipher_init failed: %s", __func__, ssh_err(r));
                 free(ssh);                  free(ssh); /* XXX need ssh_free_session_state? */
                 return NULL;                  return NULL;
         }          }
         state->newkeys[MODE_IN] = state->newkeys[MODE_OUT] = NULL;          state->newkeys[MODE_IN] = state->newkeys[MODE_OUT] = NULL;
Line 373 
Line 374 
         struct sockaddr_storage from, to;          struct sockaddr_storage from, to;
         socklen_t fromlen, tolen;          socklen_t fromlen, tolen;
   
           if (state->connection_in == -1 || state->connection_out == -1)
                   return 0;
   
         /* filedescriptors in and out are the same, so it's a socket */          /* filedescriptors in and out are the same, so it's a socket */
         if (state->connection_in == state->connection_out)          if (state->connection_in == state->connection_out)
                 return 1;                  return 1;
Line 457 
Line 461 
         if (ssh->remote_ipaddr == NULL) {          if (ssh->remote_ipaddr == NULL) {
                 if (ssh_packet_connection_is_on_socket(ssh)) {                  if (ssh_packet_connection_is_on_socket(ssh)) {
                         ssh->remote_ipaddr = get_peer_ipaddr(sock);                          ssh->remote_ipaddr = get_peer_ipaddr(sock);
                         ssh->remote_port = get_sock_port(sock, 0);                          ssh->remote_port = get_peer_port(sock);
                           ssh->local_ipaddr = get_local_ipaddr(sock);
                           ssh->local_port = get_local_port(sock);
                 } else {                  } else {
                         ssh->remote_ipaddr = strdup("UNKNOWN");                          ssh->remote_ipaddr = strdup("UNKNOWN");
                         ssh->remote_port = 0;                          ssh->remote_port = 65535;
                           ssh->local_ipaddr = strdup("UNKNOWN");
                           ssh->local_port = 65535;
                 }                  }
         }          }
         return ssh->remote_ipaddr;          return ssh->remote_ipaddr;
Line 473 
Line 481 
 {  {
         (void)ssh_remote_ipaddr(ssh); /* Will lookup and cache. */          (void)ssh_remote_ipaddr(ssh); /* Will lookup and cache. */
         return ssh->remote_port;          return ssh->remote_port;
   }
   
   /*
    * Returns the IP-address of the local host as a string.  The returned
    * string must not be freed.
    */
   
   const char *
   ssh_local_ipaddr(struct ssh *ssh)
   {
           (void)ssh_remote_ipaddr(ssh); /* Will lookup and cache. */
           return ssh->local_ipaddr;
   }
   
   /* Returns the port number of the local host. */
   
   int
   ssh_local_port(struct ssh *ssh)
   {
           (void)ssh_remote_ipaddr(ssh); /* Will lookup and cache. */
           return ssh->local_port;
 }  }
   
 /* Closes the connection and clears and frees internal data structures. */  /* Closes the connection and clears and frees internal data structures. */

Legend:
Removed from v.1.229  
changed lines
  Added in v.1.230