botched non-QUOTA code (from kre)
[unix-history] / usr / src / sys / kern / uipc_domain.c
CommitLineData
04ac1ad8 1/* uipc_domain.c 5.8 83/02/10 */
2f6bcc97
BJ
2
3#include "../h/param.h"
d0d50a86
BJ
4#include "../h/socket.h"
5#include "../h/protosw.h"
6#include "../h/domain.h"
04ac1ad8 7#include "../h/time.h"
4f083fd7 8#include "../h/kernel.h"
d0d50a86
BJ
9
10#define ADDDOMAIN(x) { \
11 extern struct domain x/**/domain; \
12 x/**/domain.dom_next = domains; \
13 domains = &x/**/domain; \
14}
15
16domaininit()
17{
4f083fd7
SL
18 register struct domain *dp;
19 register struct protosw *pr;
d0d50a86 20
4f083fd7 21#ifndef lint
d0d50a86
BJ
22 ADDDOMAIN(unix);
23#ifdef INET
24 ADDDOMAIN(inet);
25#endif
26#ifdef PUP
27 ADDDOMAIN(pup);
28#endif
bd65e3c4
SL
29#include "imp.h"
30#if NIMP > 0
d0d50a86
BJ
31 ADDDOMAIN(imp);
32#endif
4f083fd7 33#endif
d0d50a86
BJ
34
35 for (dp = domains; dp; dp = dp->dom_next)
36 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
37 if (pr->pr_init)
38 (*pr->pr_init)();
4f083fd7
SL
39 pffasttimo();
40 pfslowtimo();
d0d50a86
BJ
41}
42
43struct protosw *
44pffindtype(family, type)
45 int family, type;
46{
47 register struct domain *dp;
48 register struct protosw *pr;
49
50 for (dp = domains; dp; dp = dp->dom_next)
51 if (dp->dom_family == family)
52 goto found;
53 return (0);
54found:
55 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
56 if (pr->pr_type == type)
57 return (pr);
58 return (0);
59}
60
61struct protosw *
62pffindproto(family, protocol)
63 int family, protocol;
64{
65 register struct domain *dp;
66 register struct protosw *pr;
67
68 if (family == 0)
69 return (0);
70 for (dp = domains; dp; dp = dp->dom_next)
71 if (dp->dom_family == family)
72 goto found;
73 return (0);
74found:
4f083fd7 75 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
d0d50a86
BJ
76 if (pr->pr_protocol == protocol)
77 return (pr);
78 return (0);
79}
80
81pfctlinput(cmd, arg)
82 int cmd;
83 caddr_t arg;
84{
85 register struct domain *dp;
86 register struct protosw *pr;
87
88 for (dp = domains; dp; dp = dp->dom_next)
89 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
90 if (pr->pr_ctlinput)
91 (*pr->pr_ctlinput)(cmd, arg);
92}
93
94pfslowtimo()
95{
96 register struct domain *dp;
97 register struct protosw *pr;
98
99 for (dp = domains; dp; dp = dp->dom_next)
100 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
101 if (pr->pr_slowtimo)
102 (*pr->pr_slowtimo)();
4f083fd7 103 timeout(pfslowtimo, (caddr_t)0, hz/2);
d0d50a86
BJ
104}
105
106pffasttimo()
4147b3f6 107{
d0d50a86
BJ
108 register struct domain *dp;
109 register struct protosw *pr;
4147b3f6 110
d0d50a86
BJ
111 for (dp = domains; dp; dp = dp->dom_next)
112 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
113 if (pr->pr_fasttimo)
114 (*pr->pr_fasttimo)();
4f083fd7 115 timeout(pffasttimo, (caddr_t)0, hz/5);
4147b3f6 116}