add ioctl's and errno
[unix-history] / usr / src / sys / kern / uipc_domain.c
CommitLineData
4f083fd7 1/* uipc_domain.c 5.6 82/11/13 */
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"
4f083fd7
SL
7#include <time.h>
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
29#ifdef IMP
30 ADDDOMAIN(imp);
31#endif
4f083fd7 32#endif
d0d50a86
BJ
33
34 for (dp = domains; dp; dp = dp->dom_next)
35 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
36 if (pr->pr_init)
37 (*pr->pr_init)();
4f083fd7
SL
38 pffasttimo();
39 pfslowtimo();
d0d50a86
BJ
40}
41
42struct protosw *
43pffindtype(family, type)
44 int family, type;
45{
46 register struct domain *dp;
47 register struct protosw *pr;
48
49 for (dp = domains; dp; dp = dp->dom_next)
50 if (dp->dom_family == family)
51 goto found;
52 return (0);
53found:
54 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
55 if (pr->pr_type == type)
56 return (pr);
57 return (0);
58}
59
60struct protosw *
61pffindproto(family, protocol)
62 int family, protocol;
63{
64 register struct domain *dp;
65 register struct protosw *pr;
66
67 if (family == 0)
68 return (0);
69 for (dp = domains; dp; dp = dp->dom_next)
70 if (dp->dom_family == family)
71 goto found;
72 return (0);
73found:
4f083fd7 74 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
d0d50a86
BJ
75 if (pr->pr_protocol == protocol)
76 return (pr);
77 return (0);
78}
79
80pfctlinput(cmd, arg)
81 int cmd;
82 caddr_t arg;
83{
84 register struct domain *dp;
85 register struct protosw *pr;
86
87 for (dp = domains; dp; dp = dp->dom_next)
88 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
89 if (pr->pr_ctlinput)
90 (*pr->pr_ctlinput)(cmd, arg);
91}
92
93pfslowtimo()
94{
95 register struct domain *dp;
96 register struct protosw *pr;
97
98 for (dp = domains; dp; dp = dp->dom_next)
99 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
100 if (pr->pr_slowtimo)
101 (*pr->pr_slowtimo)();
4f083fd7 102 timeout(pfslowtimo, (caddr_t)0, hz/2);
d0d50a86
BJ
103}
104
105pffasttimo()
4147b3f6 106{
d0d50a86
BJ
107 register struct domain *dp;
108 register struct protosw *pr;
4147b3f6 109
d0d50a86
BJ
110 for (dp = domains; dp; dp = dp->dom_next)
111 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
112 if (pr->pr_fasttimo)
113 (*pr->pr_fasttimo)();
4f083fd7 114 timeout(pffasttimo, (caddr_t)0, hz/5);
4147b3f6 115}