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

Diff for /src/usr.bin/ssh/channels.c between version 1.16 and 1.17

version 1.16, 1999/10/17 16:56:08 version 1.17, 1999/10/26 22:39:44
Line 108 
Line 108 
   
 int channel_allocate(int type, int sock, char *remote_name)  int channel_allocate(int type, int sock, char *remote_name)
 {  {
   int i, old_channels;    int i, found;
     Channel *c;
   
   /* Update the maximum file descriptor value. */    /* Update the maximum file descriptor value. */
   if (sock > channel_max_fd_value)    if (sock > channel_max_fd_value)
Line 128 
Line 129 
     }      }
   
   /* Try to find a free slot where to put the new channel. */    /* Try to find a free slot where to put the new channel. */
   for (i = 0; i < channels_alloc; i++)    for (found = -1, i = 0; i < channels_alloc; i++)
     if (channels[i].type == SSH_CHANNEL_FREE)      if (channels[i].type == SSH_CHANNEL_FREE)
       {        {
         /* Found a free slot.  Initialize the fields and return its number. */          /* Found a free slot. */
         buffer_init(&channels[i].input);          found = i;
         buffer_init(&channels[i].output);          break;
         channels[i].self = i;  
         channels[i].type = type;  
         channels[i].x11 = 0;  
         channels[i].sock = sock;  
         channels[i].remote_id = -1;  
         channels[i].remote_name = remote_name;  
         chan_init_iostates(&channels[i]);  
         return i;  
       }        }
   
   /* There are no free slots.  Must expand the array. */    if (found == -1)
   old_channels = channels_alloc;      {
   channels_alloc += 10;        /* There are no free slots.  Take last+1 slot and expand the array.  */
   channels = xrealloc(channels, channels_alloc * sizeof(Channel));        found = channels_alloc;
   for (i = old_channels; i < channels_alloc; i++)        channels_alloc += 10;
     channels[i].type = SSH_CHANNEL_FREE;        debug("channel: expanding %d", channels_alloc);
         channels = xrealloc(channels, channels_alloc * sizeof(Channel));
         for (i = found; i < channels_alloc; i++)
           channels[i].type = SSH_CHANNEL_FREE;
       }
   
   /* We know that the next one after the old maximum channel number is now    /* Initialize and return new channel number. */
      available.  Initialize and return its number. */    c=&channels[found];
   buffer_init(&channels[old_channels].input);    buffer_init(&c->input);
   buffer_init(&channels[old_channels].output);    buffer_init(&c->output);
   channels[old_channels].self = old_channels;    chan_init_iostates(c);
   channels[old_channels].type = type;    c->self = found;
   channels[old_channels].x11 = 0;    c->type = type;
   channels[old_channels].sock = sock;    c->x11 = 0;
   channels[old_channels].remote_id = -1;    c->sock = sock;
   channels[old_channels].remote_name = remote_name;    c->remote_id = -1;
   chan_init_iostates(&channels[old_channels]);    c->remote_name = remote_name;
   return old_channels;    debug("channel %d: new [%s]", found, remote_name);
     return found;
 }  }
   
 /* Free the channel and close its socket. */  /* Free the channel and close its socket. */
Line 336 
Line 334 
             packet_put_int(ch->remote_id);              packet_put_int(ch->remote_id);
             packet_send();              packet_send();
           }else{            }else{
             debug("X11 rejected %d 0x%x 0x%x", ch->self, ch->istate, ch->ostate);              debug("X11 rejected %d i%d/o%d", ch->self, ch->istate, ch->ostate);
             chan_read_failed(ch);              chan_read_failed(ch);
             chan_write_failed(ch);              chan_write_failed(ch);
             debug("X11 rejected %d 0x%x 0x%x", ch->self, ch->istate, ch->ostate);              debug("X11 rejected %d i%d/o%d", ch->self, ch->istate, ch->ostate);
           }            }
           break;            break;
   
Line 407 
Line 405 
                   break;                    break;
                 }                  }
               remote_hostname = get_remote_hostname(newsock);                remote_hostname = get_remote_hostname(newsock);
               snprintf(buf, sizeof buf, "port %d, connection from %.200s port %d",                snprintf(buf, sizeof buf, "listen port %d:%.100s:%d, connect from %.200s:%d",
                       ch->listening_port, remote_hostname,                        ch->listening_port, ch->path, ch->host_port,
                       get_peer_port(newsock));                        remote_hostname, get_peer_port(newsock));
               xfree(remote_hostname);                xfree(remote_hostname);
               newch = channel_allocate(SSH_CHANNEL_OPENING, newsock,                newch = channel_allocate(SSH_CHANNEL_OPENING, newsock,
                                        xstrdup(buf));                                         xstrdup(buf));
Line 830 
Line 828 
       case SSH_CHANNEL_X11_OPEN:        case SSH_CHANNEL_X11_OPEN:
       case SSH_CHANNEL_INPUT_DRAINING:        case SSH_CHANNEL_INPUT_DRAINING:
       case SSH_CHANNEL_OUTPUT_DRAINING:        case SSH_CHANNEL_OUTPUT_DRAINING:
         snprintf(buf, sizeof buf, "  #%d/%d %.300s\r\n",          snprintf(buf, sizeof buf, "  #%d %.300s (t%d r%d i%d o%d)\r\n",
                  c->self,c->type,c->remote_name);                   c->self,c->remote_name,
                    c->type,c->remote_id, c->istate,c->ostate);
         buffer_append(&buffer, buf, strlen(buf));          buffer_append(&buffer, buf, strlen(buf));
         continue;          continue;
       default:        default:

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17