[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.241 and 1.242

version 1.241, 2016/09/28 21:44:52 version 1.242, 2016/09/30 09:19:13
Line 198 
Line 198 
         /* Used in packet_send2 */          /* Used in packet_send2 */
         int rekeying;          int rekeying;
   
           /* Used in ssh_packet_send_mux() */
           int mux;
   
         /* Used in packet_set_interactive */          /* Used in packet_set_interactive */
         int set_interactive_called;          int set_interactive_called;
   
Line 319 
Line 322 
                 state->packet_timeout_ms = timeout * count * 1000;                  state->packet_timeout_ms = timeout * count * 1000;
 }  }
   
   void
   ssh_packet_set_mux(struct ssh *ssh)
   {
           ssh->state->mux = 1;
           ssh->state->rekeying = 0;
   }
   
 int  int
   ssh_packet_get_mux(struct ssh *ssh)
   {
           return ssh->state->mux;
   }
   
   int
 ssh_packet_stop_discard(struct ssh *ssh)  ssh_packet_stop_discard(struct ssh *ssh)
 {  {
         struct session_state *state = ssh->state;          struct session_state *state = ssh->state;
Line 1067 
Line 1083 
 }  }
   
 /* Used to mute debug logging for noisy packet types */  /* Used to mute debug logging for noisy packet types */
 static int  int
 ssh_packet_log_type(u_char type)  ssh_packet_log_type(u_char type)
 {  {
         switch (type) {          switch (type) {
Line 1611 
Line 1627 
         return r;          return r;
 }  }
   
   static int
   ssh_packet_read_poll2_mux(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
   {
           struct session_state *state = ssh->state;
           const u_char *cp;
           size_t need;
           int r;
   
           if (ssh->kex)
                   return SSH_ERR_INTERNAL_ERROR;
           *typep = SSH_MSG_NONE;
           cp = sshbuf_ptr(state->input);
           if (state->packlen == 0) {
                   if (sshbuf_len(state->input) < 4 + 1)
                           return 0; /* packet is incomplete */
                   state->packlen = PEEK_U32(cp);
                   if (state->packlen < 4 + 1 ||
                       state->packlen > PACKET_MAX_SIZE)
                           return SSH_ERR_MESSAGE_INCOMPLETE;
           }
           need = state->packlen + 4;
           if (sshbuf_len(state->input) < need)
                   return 0; /* packet is incomplete */
           sshbuf_reset(state->incoming_packet);
           if ((r = sshbuf_put(state->incoming_packet, cp + 4,
               state->packlen)) != 0 ||
               (r = sshbuf_consume(state->input, need)) != 0 ||
               (r = sshbuf_get_u8(state->incoming_packet, NULL)) != 0 ||
               (r = sshbuf_get_u8(state->incoming_packet, typep)) != 0)
                   return r;
           if (ssh_packet_log_type(*typep))
                   debug3("%s: type %u", __func__, *typep);
           /* sshbuf_dump(state->incoming_packet, stderr); */
           /* reset for next packet */
           state->packlen = 0;
           return r;
   }
   
 int  int
 ssh_packet_read_poll2(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)  ssh_packet_read_poll2(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
 {  {
Line 1623 
Line 1677 
         struct sshcomp *comp = NULL;          struct sshcomp *comp = NULL;
         int r;          int r;
   
           if (state->mux)
                   return ssh_packet_read_poll2_mux(ssh, typep, seqnr_p);
   
         *typep = SSH_MSG_NONE;          *typep = SSH_MSG_NONE;
   
         if (state->packet_discard)          if (state->packet_discard)
Line 2851 
Line 2908 
         return sshbuf_put(ssh->state->outgoing_packet, buf, len);          return sshbuf_put(ssh->state->outgoing_packet, buf, len);
 }  }
   
   static int
   ssh_packet_send_mux(struct ssh *ssh)
   {
           struct session_state *state = ssh->state;
           u_char type, *cp;
           size_t len;
           int r;
   
           if (ssh->kex)
                   return SSH_ERR_INTERNAL_ERROR;
           len = sshbuf_len(state->outgoing_packet);
           if (len < 6)
                   return SSH_ERR_INTERNAL_ERROR;
           cp = sshbuf_mutable_ptr(state->outgoing_packet);
           type = cp[5];
           if (ssh_packet_log_type(type))
                   debug3("%s: type %u", __func__, type);
           /* drop everything, but the connection protocol */
           if (type >= SSH2_MSG_CONNECTION_MIN &&
               type <= SSH2_MSG_CONNECTION_MAX) {
                   POKE_U32(cp, len - 4);
                   if ((r = sshbuf_putb(state->output,
                       state->outgoing_packet)) != 0)
                           return r;
                   /* sshbuf_dump(state->output, stderr); */
           }
           sshbuf_reset(state->outgoing_packet);
           return 0;
   }
   
 /* send it */  /* send it */
   
 int  int
 sshpkt_send(struct ssh *ssh)  sshpkt_send(struct ssh *ssh)
 {  {
           if (ssh->state && ssh->state->mux)
                   return ssh_packet_send_mux(ssh);
         if (compat20)          if (compat20)
                 return ssh_packet_send2(ssh);                  return ssh_packet_send2(ssh);
         else          else

Legend:
Removed from v.1.241  
changed lines
  Added in v.1.242