[BACK]Return to uipc_socket.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / kern

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/kern/uipc_socket.c between version 1.25 and 1.33

version 1.25, 1996/08/14 05:53:18 version 1.33, 1998/04/25 17:35:18
Line 32 
Line 32 
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.   * SUCH DAMAGE.
  *   *
  *      @(#)uipc_socket.c       8.3 (Berkeley) 4/15/94   *      @(#)uipc_socket.c       8.6 (Berkeley) 5/2/95
  */   */
   
 #include <sys/param.h>  #include <sys/param.h>
Line 79  socreate(dom, aso, type, proto)
Line 79  socreate(dom, aso, type, proto)
                 return (EPROTOTYPE);                  return (EPROTOTYPE);
         MALLOC(so, struct socket *, sizeof(*so), M_SOCKET, M_WAIT);          MALLOC(so, struct socket *, sizeof(*so), M_SOCKET, M_WAIT);
         bzero((caddr_t)so, sizeof(*so));          bzero((caddr_t)so, sizeof(*so));
           TAILQ_INIT(&so->so_q0);
           TAILQ_INIT(&so->so_q);
         so->so_type = type;          so->so_type = type;
         so->so_proto = prp;          so->so_proto = prp;
           so->so_send = sosend;
           so->so_receive = soreceive;
         error = (*prp->pr_usrreq)(so, PRU_ATTACH, (struct mbuf *)0,          error = (*prp->pr_usrreq)(so, PRU_ATTACH, (struct mbuf *)0,
             (struct mbuf *)(long)proto, (struct mbuf *)0, p);              (struct mbuf *)(long)proto, (struct mbuf *)0, p);
         if (error) {          if (error) {
Line 127  solisten(so, backlog)
Line 131  solisten(so, backlog)
                 splx(s);                  splx(s);
                 return (error);                  return (error);
         }          }
         if (so->so_q == 0)          if (so->so_q.tqh_first == NULL)
                 so->so_options |= SO_ACCEPTCONN;                  so->so_options |= SO_ACCEPTCONN;
         if (backlog < 0)          if (backlog < 0)
                 backlog = 0;                  backlog = 0;
Line 166  soclose(so)
Line 170  soclose(so)
         int error = 0;          int error = 0;
   
         if (so->so_options & SO_ACCEPTCONN) {          if (so->so_options & SO_ACCEPTCONN) {
                 while (so->so_q0)                  while (so->so_q0.tqh_first)
                         (void) soabort(so->so_q0);                          (void) soabort(so->so_q0.tqh_first);
                 while (so->so_q)                  while (so->so_q.tqh_first)
                         (void) soabort(so->so_q);                          (void) soabort(so->so_q.tqh_first);
         }          }
         if (so->so_pcb == 0)          if (so->so_pcb == 0)
                 goto discard;                  goto discard;
Line 186  soclose(so)
Line 190  soclose(so)
                         while (so->so_state & SS_ISCONNECTED) {                          while (so->so_state & SS_ISCONNECTED) {
                                 error = tsleep((caddr_t)&so->so_timeo,                                  error = tsleep((caddr_t)&so->so_timeo,
                                                PSOCK | PCATCH, netcls,                                                 PSOCK | PCATCH, netcls,
                                                so->so_linger);                                                 so->so_linger * hz);
                                 if (error)                                  if (error)
                                         break;                                          break;
                         }                          }
Line 350  sosend(so, addr, uio, top, control, flag
Line 354  sosend(so, addr, uio, top, control, flag
          * of space and resid.  On the other hand, a negative resid           * of space and resid.  On the other hand, a negative resid
          * causes us to loop sending 0-length segments to the protocol.           * causes us to loop sending 0-length segments to the protocol.
          */           */
         if (resid < 0)          if (resid < 0) {
                 return (EINVAL);                  error = EINVAL;
                   goto out;
           }
         dontroute =          dontroute =
             (flags & MSG_DONTROUTE) && (so->so_options & SO_DONTROUTE) == 0 &&              (flags & MSG_DONTROUTE) && (so->so_options & SO_DONTROUTE) == 0 &&
             (so->so_proto->pr_flags & PR_ATOMIC);              (so->so_proto->pr_flags & PR_ATOMIC);
Line 872  sosetopt(so, level, optname, m0)
Line 878  sosetopt(so, level, optname, m0)
                 case SO_REUSEADDR:                  case SO_REUSEADDR:
                 case SO_REUSEPORT:                  case SO_REUSEPORT:
                 case SO_OOBINLINE:                  case SO_OOBINLINE:
                   case SO_TIMESTAMP:
                         if (m == NULL || m->m_len < sizeof (int)) {                          if (m == NULL || m->m_len < sizeof (int)) {
                                 error = EINVAL;                                  error = EINVAL;
                                 goto bad;                                  goto bad;
Line 886  sosetopt(so, level, optname, m0)
Line 893  sosetopt(so, level, optname, m0)
                 case SO_RCVBUF:                  case SO_RCVBUF:
                 case SO_SNDLOWAT:                  case SO_SNDLOWAT:
                 case SO_RCVLOWAT:                  case SO_RCVLOWAT:
                       {
                           int optval;
   
                         if (m == NULL || m->m_len < sizeof (int)) {                          if (m == NULL || m->m_len < sizeof (int)) {
                                 error = EINVAL;                                  error = EINVAL;
                                 goto bad;                                  goto bad;
                         }                          }
   
                           /*
                            * Values < 1 make no sense for any of these
                            * options, so disallow them.
                            */
                           optval = *mtod(m, int *);
                           if (optval < 1) {
                                   error = EINVAL;
                                   goto bad;
                           }
   
                         switch (optname) {                          switch (optname) {
   
                         case SO_SNDBUF:                          case SO_SNDBUF:
                         case SO_RCVBUF:                          case SO_RCVBUF:
                                 if (sbreserve(optname == SO_SNDBUF ?                                  if (sbreserve(optname == SO_SNDBUF ?
                                     &so->so_snd : &so->so_rcv,                                      &so->so_snd : &so->so_rcv,
                                     (u_long) *mtod(m, int *)) == 0) {                                      (u_long) optval) == 0) {
                                         error = ENOBUFS;                                          error = ENOBUFS;
                                         goto bad;                                          goto bad;
                                 }                                  }
                                 break;                                  break;
   
                           /*
                            * Make sure the low-water is never greater than
                            * the high-water.
                            */
                         case SO_SNDLOWAT:                          case SO_SNDLOWAT:
                                 so->so_snd.sb_lowat = *mtod(m, int *);                                  so->so_snd.sb_lowat =
                                       (optval > so->so_snd.sb_hiwat) ?
                                       so->so_snd.sb_hiwat : optval;
                                 break;                                  break;
                         case SO_RCVLOWAT:                          case SO_RCVLOWAT:
                                 so->so_rcv.sb_lowat = *mtod(m, int *);                                  so->so_rcv.sb_lowat =
                                       (optval > so->so_rcv.sb_hiwat) ?
                                       so->so_rcv.sb_hiwat : optval;
                                 break;                                  break;
                         }                          }
                         break;                          break;
                       }
   
                 case SO_SNDTIMEO:                  case SO_SNDTIMEO:
                 case SO_RCVTIMEO:                  case SO_RCVTIMEO:
Line 991  sogetopt(so, level, optname, mp)
Line 1021  sogetopt(so, level, optname, mp)
                 case SO_REUSEPORT:                  case SO_REUSEPORT:
                 case SO_BROADCAST:                  case SO_BROADCAST:
                 case SO_OOBINLINE:                  case SO_OOBINLINE:
                   case SO_TIMESTAMP:
                         *mtod(m, int *) = so->so_options & optname;                          *mtod(m, int *) = so->so_options & optname;
                         break;                          break;
   
Line 1028  sogetopt(so, level, optname, mp)
Line 1059  sogetopt(so, level, optname, mp)
                         m->m_len = sizeof(struct timeval);                          m->m_len = sizeof(struct timeval);
                         mtod(m, struct timeval *)->tv_sec = val / hz;                          mtod(m, struct timeval *)->tv_sec = val / hz;
                         mtod(m, struct timeval *)->tv_usec =                          mtod(m, struct timeval *)->tv_usec =
                             (val % hz) / tick;                              (val % hz) * tick;
                         break;                          break;
                     }                      }
   

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.33

CVSweb <webmaster@jp.NetBSD.org>