Diff for /qemu/slirp/sbuf.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2018/04/24 16:37:52 version 1.1.1.2, 2018/04/24 16:49:12
Line 1 Line 1
 /*  /*
  * Copyright (c) 1995 Danny Gasparovski.   * Copyright (c) 1995 Danny Gasparovski.
  *    *
  * Please read the file COPYRIGHT for the    * Please read the file COPYRIGHT for the
  * terms and conditions of the copyright.   * terms and conditions of the copyright.
  */   */
   
 #include <slirp.h>  #include <slirp.h>
   
   static void sbappendsb(struct sbuf *sb, struct mbuf *m);
   
 /* Done as a macro in socket.h */  /* Done as a macro in socket.h */
 /* int  /* int
  * sbspace(struct sockbuff *sb)    * sbspace(struct sockbuff *sb)
  * {   * {
  *      return SB_DATALEN - sb->sb_cc;   *      return SB_DATALEN - sb->sb_cc;
  * }   * }
Line 25  sbfree(sb) Line 27  sbfree(sb)
 void  void
 sbdrop(sb, num)  sbdrop(sb, num)
         struct sbuf *sb;          struct sbuf *sb;
         int num;           int num;
 {  {
         /*           /*
          * We can only drop how much we have           * We can only drop how much we have
          * This should never succeed            * This should never succeed
          */           */
         if(num > sb->sb_cc)          if(num > sb->sb_cc)
                 num = sb->sb_cc;                  num = sb->sb_cc;
Line 37  sbdrop(sb, num) Line 39  sbdrop(sb, num)
         sb->sb_rptr += num;          sb->sb_rptr += num;
         if(sb->sb_rptr >= sb->sb_data + sb->sb_datalen)          if(sb->sb_rptr >= sb->sb_data + sb->sb_datalen)
                 sb->sb_rptr -= sb->sb_datalen;                  sb->sb_rptr -= sb->sb_datalen;
      
 }  }
   
 void  void
Line 77  sbappend(so, m) Line 79  sbappend(so, m)
         struct mbuf *m;          struct mbuf *m;
 {  {
         int ret = 0;          int ret = 0;
           
         DEBUG_CALL("sbappend");          DEBUG_CALL("sbappend");
         DEBUG_ARG("so = %lx", (long)so);          DEBUG_ARG("so = %lx", (long)so);
         DEBUG_ARG("m = %lx", (long)m);          DEBUG_ARG("m = %lx", (long)m);
         DEBUG_ARG("m->m_len = %d", m->m_len);          DEBUG_ARG("m->m_len = %d", m->m_len);
           
         /* Shouldn't happen, but...  e.g. foreign host closes connection */          /* Shouldn't happen, but...  e.g. foreign host closes connection */
         if (m->m_len <= 0) {          if (m->m_len <= 0) {
                 m_free(m);                  m_free(m);
                 return;                  return;
         }          }
           
         /*          /*
          * If there is urgent data, call sosendoob           * If there is urgent data, call sosendoob
          * if not all was sent, sowrite will take care of the rest           * if not all was sent, sowrite will take care of the rest
Line 100  sbappend(so, m) Line 102  sbappend(so, m)
                 sosendoob(so);                  sosendoob(so);
                 return;                  return;
         }          }
           
         /*          /*
          * We only write if there's nothing in the buffer,           * We only write if there's nothing in the buffer,
          * ottherwise it'll arrive out of order, and hence corrupt           * ottherwise it'll arrive out of order, and hence corrupt
          */           */
         if (!so->so_rcv.sb_cc)          if (!so->so_rcv.sb_cc)
            ret = send(so->s, m->m_data, m->m_len, 0);             ret = send(so->s, m->m_data, m->m_len, 0);
           
         if (ret <= 0) {          if (ret <= 0) {
                 /*                   /*
                  * Nothing was written                   * Nothing was written
                  * It's possible that the socket has closed, but                   * It's possible that the socket has closed, but
                  * we don't need to check because if it has closed,                   * we don't need to check because if it has closed,
Line 133  sbappend(so, m) Line 135  sbappend(so, m)
  * Copy the data from m into sb   * Copy the data from m into sb
  * The caller is responsible to make sure there's enough room   * The caller is responsible to make sure there's enough room
  */   */
 void  static void
 sbappendsb(sb, m)  sbappendsb(struct sbuf *sb, struct mbuf *m)
          struct sbuf *sb;  
          struct mbuf *m;  
 {  {
         int len, n,  nn;          int len, n,  nn;
           
         len = m->m_len;          len = m->m_len;
   
         if (sb->sb_wptr < sb->sb_rptr) {          if (sb->sb_wptr < sb->sb_rptr) {
Line 180  sbcopy(sb, off, len, to) Line 180  sbcopy(sb, off, len, to)
         char *to;          char *to;
 {  {
         char *from;          char *from;
           
         from = sb->sb_rptr + off;          from = sb->sb_rptr + off;
         if (from >= sb->sb_data + sb->sb_datalen)          if (from >= sb->sb_data + sb->sb_datalen)
                 from -= sb->sb_datalen;                  from -= sb->sb_datalen;
Line 198  sbcopy(sb, off, len, to) Line 198  sbcopy(sb, off, len, to)
                    memcpy(to+off,sb->sb_data,len);                     memcpy(to+off,sb->sb_data,len);
         }          }
 }  }
                   

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


unix.superglobalmegacorp.com