BSD 4_4_Lite2 release
[unix-history] / usr / src / sys / netns / spp_usrreq.c
index 1092212..7ce6723 100644 (file)
@@ -1,47 +1,61 @@
 /*
 /*
- * Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1984, 1985, 1986, 1987, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  *
- * Redistribution and use in source and binary forms are permitted
- * 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.
+ * 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.
  *
  *
- *     @(#)spp_usrreq.c        7.10 (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.
+ *
+ *     @(#)spp_usrreq.c        8.2 (Berkeley) 1/9/95
  */
 
  */
 
-#include "param.h"
-#include "systm.h"
-#include "dir.h"
-#include "user.h"
-#include "malloc.h"
-#include "mbuf.h"
-#include "protosw.h"
-#include "socket.h"
-#include "socketvar.h"
-#include "errno.h"
-
-#include "../net/if.h"
-#include "../net/route.h"
-#include "../netinet/tcp_fsm.h"
-
-#include "ns.h"
-#include "ns_pcb.h"
-#include "idp.h"
-#include "idp_var.h"
-#include "ns_error.h"
-#include "sp.h"
-#include "spidp.h"
-#include "spp_timer.h"
-#include "spp_var.h"
-#include "spp_debug.h"
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/protosw.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/errno.h>
+
+#include <net/if.h>
+#include <net/route.h>
+#include <netinet/tcp_fsm.h>
+
+#include <netns/ns.h>
+#include <netns/ns_pcb.h>
+#include <netns/idp.h>
+#include <netns/idp_var.h>
+#include <netns/ns_error.h>
+#include <netns/sp.h>
+#include <netns/spidp.h>
+#include <netns/spp_timer.h>
+#include <netns/spp_var.h>
+#include <netns/spp_debug.h>
 
 /*
  * SP protocol implementation.
 
 /*
  * SP protocol implementation.
@@ -98,7 +112,7 @@ spp_input(m, nsp)
        if (so->so_options & SO_ACCEPTCONN) {
                struct sppcb *ocb = cb;
 
        if (so->so_options & SO_ACCEPTCONN) {
                struct sppcb *ocb = cb;
 
-               so = sonewconn(so);
+               so = sonewconn(so, 0);
                if (so == 0) {
                        goto drop;
                }
                if (so == 0) {
                        goto drop;
                }
@@ -1240,10 +1254,10 @@ spp_ctloutput(req, so, level, name, value)
 }
 
 /*ARGSUSED*/
 }
 
 /*ARGSUSED*/
-spp_usrreq(so, req, m, nam, rights, controlp)
+spp_usrreq(so, req, m, nam, controlp)
        struct socket *so;
        int req;
        struct socket *so;
        int req;
-       struct mbuf *m, *nam, *rights, *controlp;
+       struct mbuf *m, *nam, *controlp;
 {
        struct nspcb *nsp = sotonspcb(so);
        register struct sppcb *cb;
 {
        struct nspcb *nsp = sotonspcb(so);
        register struct sppcb *cb;
@@ -1253,12 +1267,8 @@ spp_usrreq(so, req, m, nam, rights, controlp)
        register struct sockbuf *sb;
 
        if (req == PRU_CONTROL)
        register struct sockbuf *sb;
 
        if (req == PRU_CONTROL)
-                return (ns_control(so, (int)m, (caddr_t)nam,
-                       (struct ifnet *)rights));
-       if (rights && rights->m_len) {
-               error = EINVAL;
-               goto release;
-       }
+                return (ns_control(so, m, (caddr_t)nam,
+                       (struct ifnet *)controlp));
        if (nsp == NULL) {
                if (req != PRU_ATTACH) {
                        error = EINVAL;
        if (nsp == NULL) {
                if (req != PRU_ATTACH) {
                        error = EINVAL;
@@ -1456,7 +1466,9 @@ spp_usrreq(so, req, m, nam, rights, controlp)
                                cb->s_shdr.sp_dt = *(u_char *)(&p[2]);
                                spp_newchecks[3]++;
                        }
                                cb->s_shdr.sp_dt = *(u_char *)(&p[2]);
                                spp_newchecks[3]++;
                        }
+                       m_freem(controlp);
                }
                }
+               controlp = NULL;
                error = spp_output(cb, m);
                m = NULL;
                break;
                error = spp_output(cb, m);
                m = NULL;
                break;
@@ -1486,18 +1498,20 @@ spp_usrreq(so, req, m, nam, rights, controlp)
        if (cb && (so->so_options & SO_DEBUG || traceallspps))
                spp_trace(SA_USER, (u_char)ostate, cb, (struct spidp *)0, req);
 release:
        if (cb && (so->so_options & SO_DEBUG || traceallspps))
                spp_trace(SA_USER, (u_char)ostate, cb, (struct spidp *)0, req);
 release:
+       if (controlp != NULL)
+               m_freem(controlp);
        if (m != NULL)
                m_freem(m);
        splx(s);
        return (error);
 }
 
        if (m != NULL)
                m_freem(m);
        splx(s);
        return (error);
 }
 
-spp_usrreq_sp(so, req, m, nam, rights, controlp)
+spp_usrreq_sp(so, req, m, nam, controlp)
        struct socket *so;
        int req;
        struct socket *so;
        int req;
-       struct mbuf *m, *nam, *rights, *controlp;
+       struct mbuf *m, *nam, *controlp;
 {
 {
-       int error = spp_usrreq(so, req, m, nam, rights, controlp);
+       int error = spp_usrreq(so, req, m, nam, controlp);
 
        if (req == PRU_ATTACH && error == 0) {
                struct nspcb *nsp = sotonspcb(so);
 
        if (req == PRU_ATTACH && error == 0) {
                struct nspcb *nsp = sotonspcb(so);
@@ -1787,4 +1801,4 @@ spp_timers(cb, timer)
 #ifndef lint
 int SppcbSize = sizeof (struct sppcb);
 int NspcbSize = sizeof (struct nspcb);
 #ifndef lint
 int SppcbSize = sizeof (struct sppcb);
 int NspcbSize = sizeof (struct nspcb);
-#endif lint
+#endif /* lint */