BSD 4_4_Lite1 release
[unix-history] / usr / src / sys / netinet / tcp_usrreq.c
index dab29a7..38a08d6 100644 (file)
@@ -2,9 +2,35 @@
  * Copyright (c) 1982, 1986, 1988, 1993
  *     The Regents of the University of California.  All rights reserved.
  *
  * Copyright (c) 1982, 1986, 1988, 1993
  *     The Regents of the University of California.  All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)tcp_usrreq.c        8.1 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)tcp_usrreq.c        8.2 (Berkeley) 1/3/94
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -56,7 +82,6 @@ tcp_usrreq(so, req, m, nam, control)
        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 *)control));
        if (req == PRU_CONTROL)
                return (in_control(so, (int)m, (caddr_t)nam,
                        (struct ifnet *)control));
@@ -246,9 +271,7 @@ tcp_usrreq(so, req, m, nam, control)
        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;
@@ -311,7 +334,6 @@ tcp_usrreq(so, req, m, nam, control)
 }
 
 int
 }
 
 int
-#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;
@@ -328,6 +350,8 @@ tcp_ctloutput(op, so, level, optname, mp)
        inp = sotoinpcb(so);
        if (inp == NULL) {
                splx(s);
        inp = sotoinpcb(so);
        if (inp == NULL) {
                splx(s);
+               if (op == PRCO_SETOPT && *mp)
+                       (void) m_free(*mp);
                return (ECONNRESET);
        }
        if (level != IPPROTO_TCP) {
                return (ECONNRESET);
        }
        if (level != IPPROTO_TCP) {
@@ -360,7 +384,7 @@ tcp_ctloutput(op, so, level, optname, mp)
                        break;
 
                default:
                        break;
 
                default:
-                       error = EINVAL;
+                       error = ENOPROTOOPT;
                        break;
                }
                if (m)
                        break;
                }
                if (m)
@@ -379,7 +403,7 @@ tcp_ctloutput(op, so, level, optname, mp)
                        *mtod(m, int *) = tp->t_maxseg;
                        break;
                default:
                        *mtod(m, int *) = tp->t_maxseg;
                        break;
                default:
-                       error = EINVAL;
+                       error = ENOPROTOOPT;
                        break;
                }
                break;
                        break;
                }
                break;
@@ -387,7 +411,6 @@ tcp_ctloutput(op, so, level, optname, mp)
        splx(s);
        return (error);
 }
        splx(s);
        return (error);
 }
-#endif
 
 u_long tcp_sendspace = 1024*8;
 u_long tcp_recvspace = 1024*8;
 
 u_long tcp_sendspace = 1024*8;
 u_long tcp_recvspace = 1024*8;