trailing comment after #else or #endif
[unix-history] / usr / src / sys / netns / idp_usrreq.c
index e2278d9..0905016 100644 (file)
@@ -2,41 +2,29 @@
  * Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1984, 1985, 1986, 1987 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.
+ * %sccs.include.redist.c%
  *
  *
- *     @(#)idp_usrreq.c        7.6 (Berkeley) %G%
+ *     @(#)idp_usrreq.c        7.13 (Berkeley) %G%
  */
 
  */
 
-#include "param.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 "stat.h"
-
-#include "../net/if.h"
-#include "../net/route.h"
-
-#include "ns.h"
-#include "ns_pcb.h"
-#include "ns_if.h"
-#include "idp.h"
-#include "idp_var.h"
-#include "ns_error.h"
+#include <sys/param.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 <sys/stat.h>
+
+#include <net/if.h>
+#include <net/route.h>
+
+#include <netns/ns.h>
+#include <netns/ns_pcb.h>
+#include <netns/ns_if.h>
+#include <netns/idp.h>
+#include <netns/idp_var.h>
+#include <netns/ns_error.h>
 
 /*
  * IDP protocol implementation.
 
 /*
  * IDP protocol implementation.
@@ -239,7 +227,7 @@ idp_output(nsp, m0)
                }
        }
        nsp->nsp_lastdst = idp->idp_dna;
                }
        }
        nsp->nsp_lastdst = idp->idp_dna;
-#endif ancient_history
+#endif /* ancient_history */
        if (noIdpRoute) ro = 0;
        return (ns_output(m, ro, so->so_options & SO_BROADCAST));
 }
        if (noIdpRoute) ro = 0;
        return (ns_output(m, ro, so->so_options & SO_BROADCAST));
 }
@@ -343,7 +331,7 @@ idp_ctloutput(req, so, level, name, value)
                case SO_NSIP_ROUTE:
                        error = nsip_route(*value);
                        break;
                case SO_NSIP_ROUTE:
                        error = nsip_route(*value);
                        break;
-#endif NSIP
+#endif /* NSIP */
                default:
                        error = EINVAL;
                }
                default:
                        error = EINVAL;
                }
@@ -355,18 +343,18 @@ idp_ctloutput(req, so, level, name, value)
 }
 
 /*ARGSUSED*/
 }
 
 /*ARGSUSED*/
-idp_usrreq(so, req, m, nam, rights)
+idp_usrreq(so, req, m, nam, control)
        struct socket *so;
        int req;
        struct socket *so;
        int req;
-       struct mbuf *m, *nam, *rights;
+       struct mbuf *m, *nam, *control;
 {
        struct nspcb *nsp = sotonspcb(so);
        int error = 0;
 
        if (req == PRU_CONTROL)
                 return (ns_control(so, (int)m, (caddr_t)nam,
 {
        struct nspcb *nsp = sotonspcb(so);
        int error = 0;
 
        if (req == PRU_CONTROL)
                 return (ns_control(so, (int)m, (caddr_t)nam,
-                       (struct ifnet *)rights));
-       if (rights && rights->m_len) {
+                       (struct ifnet *)control));
+       if (control && control->m_len) {
                error = EINVAL;
                goto release;
        }
                error = EINVAL;
                goto release;
        }
@@ -510,15 +498,17 @@ idp_usrreq(so, req, m, nam, rights)
                panic("idp_usrreq");
        }
 release:
                panic("idp_usrreq");
        }
 release:
+       if (control != NULL)
+               m_freem(control);
        if (m != NULL)
                m_freem(m);
        return (error);
 }
 /*ARGSUSED*/
        if (m != NULL)
                m_freem(m);
        return (error);
 }
 /*ARGSUSED*/
-idp_raw_usrreq(so, req, m, nam, rights)
+idp_raw_usrreq(so, req, m, nam, control)
        struct socket *so;
        int req;
        struct socket *so;
        int req;
-       struct mbuf *m, *nam, *rights;
+       struct mbuf *m, *nam, *control;
 {
        int error = 0;
        struct nspcb *nsp = sotonspcb(so);
 {
        int error = 0;
        struct nspcb *nsp = sotonspcb(so);
@@ -528,7 +518,7 @@ idp_raw_usrreq(so, req, m, nam, rights)
 
        case PRU_ATTACH:
 
 
        case PRU_ATTACH:
 
-               if (!suser() || (nsp != NULL)) {
+               if (!(so->so_state & SS_PRIV) || (nsp != NULL)) {
                        error = EINVAL;
                        break;
                }
                        error = EINVAL;
                        break;
                }
@@ -543,7 +533,7 @@ idp_raw_usrreq(so, req, m, nam, rights)
                nsp->nsp_flags = NSP_RAWIN | NSP_RAWOUT;
                break;
        default:
                nsp->nsp_flags = NSP_RAWIN | NSP_RAWOUT;
                break;
        default:
-               error = idp_usrreq(so, req, m, nam, rights);
+               error = idp_usrreq(so, req, m, nam, control);
        }
        return (error);
 }
        }
        return (error);
 }