new signals
[unix-history] / usr / src / sys / netinet / tcp_usrreq.c
index 5bb0d3f..ebed585 100644 (file)
@@ -1,19 +1,25 @@
 /*
 /*
- * Copyright (c) 1982, 1986 Regents of the University of California.
+ * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of California at Berkeley. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  *
- *     @(#)tcp_usrreq.c        7.6 (Berkeley) %G%
+ *     @(#)tcp_usrreq.c        7.12 (Berkeley) %G%
  */
 
 #include "param.h"
 #include "systm.h"
  */
 
 #include "param.h"
 #include "systm.h"
+#include "malloc.h"
 #include "mbuf.h"
 #include "socket.h"
 #include "socketvar.h"
 #include "mbuf.h"
 #include "socket.h"
 #include "socketvar.h"
@@ -42,7 +48,6 @@
  */
 extern char *tcpstates[];
 struct tcpcb *tcp_newtcpcb();
  */
 extern char *tcpstates[];
 struct tcpcb *tcp_newtcpcb();
-int    tcpsenderrors;
 
 /*
  * Process a TCP user request for TCP tb.  If this is a send request
 
 /*
  * Process a TCP user request for TCP tb.  If this is a send request
@@ -61,9 +66,14 @@ tcp_usrreq(so, req, m, nam, rights)
        int error = 0;
        int ostate;
 
        int error = 0;
        int ostate;
 
+#if BSD>=43
        if (req == PRU_CONTROL)
                return (in_control(so, (int)m, (caddr_t)nam,
                        (struct ifnet *)rights));
        if (req == PRU_CONTROL)
                return (in_control(so, (int)m, (caddr_t)nam,
                        (struct ifnet *)rights));
+#else
+       if (req == PRU_CONTROL)
+               return(EOPNOTSUPP);
+#endif
        if (rights && rights->m_len)
                return (EINVAL);
 
        if (rights && rights->m_len)
                return (EINVAL);
 
@@ -164,7 +174,7 @@ tcp_usrreq(so, req, m, nam, rights)
                soisconnecting(so);
                tcpstat.tcps_connattempt++;
                tp->t_state = TCPS_SYN_SENT;
                soisconnecting(so);
                tcpstat.tcps_connattempt++;
                tp->t_state = TCPS_SYN_SENT;
-               tp->t_timer[TCPT_KEEP] = TCPTV_KEEP;
+               tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
                tp->iss = tcp_iss; tcp_iss += TCP_ISSINCR/2;
                tcp_sendseqinit(tp);
                error = tcp_output(tp);
                tp->iss = tcp_iss; tcp_iss += TCP_ISSINCR/2;
                tcp_sendseqinit(tp);
                error = tcp_output(tp);
@@ -202,6 +212,7 @@ tcp_usrreq(so, req, m, nam, rights)
 
                nam->m_len = sizeof (struct sockaddr_in);
                sin->sin_family = AF_INET;
 
                nam->m_len = sizeof (struct sockaddr_in);
                sin->sin_family = AF_INET;
+               sin->sin_len = sizeof(*sin);
                sin->sin_port = inp->inp_fport;
                sin->sin_addr = inp->inp_faddr;
                break;
                sin->sin_port = inp->inp_fport;
                sin->sin_addr = inp->inp_faddr;
                break;
@@ -231,11 +242,6 @@ tcp_usrreq(so, req, m, nam, rights)
        case PRU_SEND:
                sbappend(&so->so_snd, m);
                error = tcp_output(tp);
        case PRU_SEND:
                sbappend(&so->so_snd, m);
                error = tcp_output(tp);
-               if (error) {            /* XXX fix to use other path */
-                       if (error == ENOBUFS)           /* XXX */
-                               error = 0;              /* XXX */
-                       tcpsenderrors++;
-               }
                break;
 
        /*
                break;
 
        /*
@@ -253,7 +259,9 @@ tcp_usrreq(so, req, m, nam, rights)
        case PRU_RCVOOB:
                if ((so->so_oobmark == 0 &&
                    (so->so_state & SS_RCVATMARK) == 0) ||
        case PRU_RCVOOB:
                if ((so->so_oobmark == 0 &&
                    (so->so_state & SS_RCVATMARK) == 0) ||
+#ifdef SO_OOBINLINE
                    so->so_options & SO_OOBINLINE ||
                    so->so_options & SO_OOBINLINE ||
+#endif
                    tp->t_oobflags & TCPOOB_HADDATA) {
                        error = EINVAL;
                        break;
                    tp->t_oobflags & TCPOOB_HADDATA) {
                        error = EINVAL;
                        break;
@@ -315,6 +323,7 @@ tcp_usrreq(so, req, m, nam, rights)
        return (error);
 }
 
        return (error);
 }
 
+#if BSD>=43
 tcp_ctloutput(op, so, level, optname, mp)
        int op;
        struct socket *so;
 tcp_ctloutput(op, so, level, optname, mp)
        int op;
        struct socket *so;
@@ -372,9 +381,11 @@ tcp_ctloutput(op, so, level, optname, mp)
        }
        return (error);
 }
        }
        return (error);
 }
+#endif
+
+u_long tcp_sendspace = 1024*4;
+u_long tcp_recvspace = 1024*4;
 
 
-int    tcp_sendspace = 1024*4;
-int    tcp_recvspace = 1024*4;
 /*
  * Attach TCP protocol to socket, allocating
  * internet protocol control block, tcp control block,
 /*
  * Attach TCP protocol to socket, allocating
  * internet protocol control block, tcp control block,
@@ -387,9 +398,11 @@ tcp_attach(so)
        struct inpcb *inp;
        int error;
 
        struct inpcb *inp;
        int error;
 
-       error = soreserve(so, tcp_sendspace, tcp_recvspace);
-       if (error)
-               return (error);
+       if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
+               error = soreserve(so, tcp_sendspace, tcp_recvspace);
+               if (error)
+                       return (error);
+       }
        error = in_pcballoc(so, &tcb);
        if (error)
                return (error);
        error = in_pcballoc(so, &tcb);
        if (error)
                return (error);