BSD 4_3_Reno release
[unix-history] / usr / src / sys / kern / uipc_proto.c
index 634b5be..9dbef57 100644 (file)
-/*     uipc_proto.c    4.17    82/03/03        */
-
-#include "../h/param.h"
-#include "../h/socket.h"
-#include "../h/protosw.h"
-#include "../h/mbuf.h"
-#include "../net/in.h"
-#include "../net/in_systm.h"
-
 /*
 /*
- * Protocol configuration table and routines to search it.
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved.
  *
  *
- * SHOULD INCLUDE A HEADER FILE GIVING DESIRED PROTOCOLS
- */
-
-/*
- * Local protocol handler.
- */
-int    piusrreq();
-
-/*
- * TCP/IP protocol family: IP, ICMP, UDP, TCP.
+ * Redistribution is only permitted until one year after the first shipment
+ * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
+ * binary forms are permitted provided that: (1) source distributions retain
+ * this entire copyright notice and comment, and (2) distributions including
+ * binaries display the following acknowledgement:  This product includes
+ * software developed by the University of California, Berkeley and its
+ * contributors'' in the documentation or other materials provided with the
+ * distribution and in all advertising materials mentioning features or use
+ * of this software.  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.
+ * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ *     @(#)uipc_proto.c        7.4 (Berkeley) 6/28/90
  */
  */
-int    ip_output();
-int    ip_init(),ip_slowtimo(),ip_drain();
-int    icmp_input(),icmp_ctlinput();
-int    icmp_drain();
-int    udp_input(),udp_ctlinput();
-int    udp_usrreq();
-int    udp_init();
-int    tcp_input(),tcp_ctlinput();
-int    tcp_usrreq();
-int    tcp_init(),tcp_fasttimo(),tcp_slowtimo(),tcp_drain();
-int    rip_input(),rip_output(),rip_ctlinput();
-int    rip_usrreq(),rip_slowtimo();
 
 
-/*
- * IMP protocol family: raw interface
- */
-#include "imp.h"
-#if NIMP > 0
-int    rimp_usrreq(),rimp_output(),rimp_ctlinput();
-#endif
+#include "param.h"
+#include "socket.h"
+#include "protosw.h"
+#include "domain.h"
+#include "mbuf.h"
 
 /*
 
 /*
- * PUP-I protocol family: raw interface
+ * Definitions of protocols supported in the UNIX domain.
  */
  */
-#include "pup.h"
-#if NPUP > 0
-int    rpup_output(),rpup_ctlinput();
-#endif
 
 
-/*
- * Sundries.
-*/
-int    raw_init(),raw_usrreq(),raw_input();
+int    uipc_usrreq();
+int    raw_init(),raw_usrreq(),raw_input(),raw_ctlinput();
+extern struct domain unixdomain;               /* or at least forward */
 
 
-struct protosw protosw[] = {
-{ SOCK_STREAM, PF_UNIX,        0,              PR_CONNREQUIRED,
-  0,           0,              0,              0,
-  piusrreq,
-  0,           0,              0,              0,
-},
-{ SOCK_DGRAM,  PF_UNIX,        0,              PR_ATOMIC|PR_ADDR,
-  0,           0,              0,              0,
-  piusrreq,
-  0,           0,              0,              0,
-},
-{ SOCK_RDM,    PF_UNIX,        0,              PR_ATOMIC|PR_ADDR,
+struct protosw unixsw[] = {
+{ SOCK_STREAM, &unixdomain,    0,      PR_CONNREQUIRED|PR_WANTRCVD|PR_RIGHTS,
   0,           0,              0,              0,
   0,           0,              0,              0,
-  piusrreq,
+  uipc_usrreq,
   0,           0,              0,              0,
 },
   0,           0,              0,              0,
 },
-{ SOCK_RAW,    PF_UNIX,        0,              PR_ATOMIC|PR_ADDR,
+{ SOCK_DGRAM,  &unixdomain,    0,              PR_ATOMIC|PR_ADDR|PR_RIGHTS,
   0,           0,              0,              0,
   0,           0,              0,              0,
-  piusrreq,
+  uipc_usrreq,
   0,           0,              0,              0,
 },
 { 0,           0,              0,              0,
   0,           0,              0,              0,
 },
 { 0,           0,              0,              0,
-  0,           ip_output,      0,              0,
-  0,
-  ip_init,     0,              ip_slowtimo,    ip_drain,
-},
-{ 0,           0,              IPPROTO_ICMP,   0,
-  icmp_input,  0,              icmp_ctlinput,  0,
-  0,
-  0,           0,              0,              icmp_drain,
-},
-{ SOCK_DGRAM,  PF_INET,        IPPROTO_UDP,    PR_ATOMIC|PR_ADDR,
-  udp_input,   0,              udp_ctlinput,   0,
-  udp_usrreq,
-  udp_init,    0,              0,              0,
-},
-{ SOCK_STREAM, PF_INET,        IPPROTO_TCP,    PR_CONNREQUIRED|PR_WANTRCVD,
-  tcp_input,   0,              tcp_ctlinput,   0,
-  tcp_usrreq,
-  tcp_init,    tcp_fasttimo,   tcp_slowtimo,   tcp_drain,
-},
-{ 0,           0,              0,              0,
-  raw_input,   0,              0,              0,
+  raw_input,   0,              raw_ctlinput,   0,
   raw_usrreq,
   raw_init,    0,              0,              0,
   raw_usrreq,
   raw_init,    0,              0,              0,
-},
-{ SOCK_RAW,    PF_INET,        IPPROTO_RAW,    PR_ATOMIC|PR_ADDR,
-  rip_input,   rip_output,     rip_ctlinput,   0,
-  rip_usrreq,
-  0,           0,              0,              0,
-}
-#if NIMP > 0
-,
-{ SOCK_RAW,    PF_IMPLINK,     0,              PR_ATOMIC|PR_ADDR,
-  0,           rimp_output,    rimp_ctlinput,  0,
-  rimp_usrreq,
-  0,           0,              0,              0,
-}
-#endif
-#if NPUP > 0
-,
-{ SOCK_RAW,    PF_PUP,         0,              PR_ATOMIC|PR_ADDR,
-  0,           rpup_output,    rpup_ctlinput,  0,
-  raw_usrreq,
-  0,           0,              0,              0,
 }
 }
-#endif
 };
 
 };
 
-#define        NPROTOSW        (sizeof(protosw) / sizeof(protosw[0]))
-
-struct protosw *protoswLAST = &protosw[NPROTOSW-1];
-
-/*
- * Operations on protocol table and protocol families.
- */
-
-/*
- * Initialize all protocols.
- */
-pfinit()
-{
-       register struct protosw *pr;
-
-COUNT(PFINIT);
-       for (pr = protoswLAST; pr >= protosw; pr--)
-               if (pr->pr_init)
-                       (*pr->pr_init)();
-}
-
-/*
- * Find a standard protocol in a protocol family
- * of a specific type.
- */
-struct protosw *
-pffindtype(family, type)
-       int family, type;
-{
-       register struct protosw *pr;
-
-COUNT(PFFINDTYPE);
-       if (family == 0)
-               return (0);
-       for (pr = protosw; pr <= protoswLAST; pr++)
-               if (pr->pr_family == family && pr->pr_type == type)
-                       return (pr);
-       return (0);
-}
-
-/*
- * Find a specified protocol in a specified protocol family.
- */
-struct protosw *
-pffindproto(family, protocol)
-       int family, protocol;
-{
-       register struct protosw *pr;
-
-COUNT(PFFINDPROTO);
-       if (family == 0)
-               return (0);
-       for (pr = protosw; pr <= protoswLAST; pr++)
-               if (pr->pr_family == family && pr->pr_protocol == protocol)
-                       return (pr);
-       return (0);
-}
-
-/*
- * Slow timeout on all protocols.
- */
-pfslowtimo()
-{
-       register struct protosw *pr;
+int    unp_externalize(), unp_dispose();
 
 
-COUNT(PFSLOWTIMO);
-       for (pr = protoswLAST; pr >= protosw; pr--)
-               if (pr->pr_slowtimo)
-                       (*pr->pr_slowtimo)();
-}
-
-pffasttimo()
-{
-       register struct protosw *pr;
-
-COUNT(PFSLOWTIMO);
-       for (pr = protoswLAST; pr >= protosw; pr--)
-               if (pr->pr_fasttimo)
-                       (*pr->pr_fasttimo)();
-}
+struct domain unixdomain =
+    { AF_UNIX, "unix", 0, unp_externalize, unp_dispose,
+      unixsw, &unixsw[sizeof(unixsw)/sizeof(unixsw[0])] };