Commit | Line | Data |
---|---|---|
94368568 | 1 | /* uipc_domain.c 6.3 84/08/29 */ |
2f6bcc97 | 2 | |
94368568 JB |
3 | #include "param.h" |
4 | #include "socket.h" | |
5 | #include "protosw.h" | |
6 | #include "domain.h" | |
7 | #include "time.h" | |
8 | #include "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 | ||
16 | domaininit() | |
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 | 34 | |
261a8548 MK |
35 | for (dp = domains; dp; dp = dp->dom_next) { |
36 | if (dp->dom_init) | |
37 | (*dp->dom_init)(); | |
d0d50a86 BJ |
38 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) |
39 | if (pr->pr_init) | |
40 | (*pr->pr_init)(); | |
261a8548 | 41 | } |
4f083fd7 SL |
42 | pffasttimo(); |
43 | pfslowtimo(); | |
d0d50a86 BJ |
44 | } |
45 | ||
46 | struct protosw * | |
47 | pffindtype(family, type) | |
48 | int family, type; | |
49 | { | |
50 | register struct domain *dp; | |
51 | register struct protosw *pr; | |
52 | ||
53 | for (dp = domains; dp; dp = dp->dom_next) | |
54 | if (dp->dom_family == family) | |
55 | goto found; | |
56 | return (0); | |
57 | found: | |
58 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) | |
6cd6d0de | 59 | if (pr->pr_type && pr->pr_type == type) |
d0d50a86 BJ |
60 | return (pr); |
61 | return (0); | |
62 | } | |
63 | ||
64 | struct protosw * | |
65 | pffindproto(family, protocol) | |
66 | int family, protocol; | |
67 | { | |
68 | register struct domain *dp; | |
69 | register struct protosw *pr; | |
70 | ||
71 | if (family == 0) | |
72 | return (0); | |
73 | for (dp = domains; dp; dp = dp->dom_next) | |
74 | if (dp->dom_family == family) | |
75 | goto found; | |
76 | return (0); | |
77 | found: | |
4f083fd7 | 78 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) |
d0d50a86 BJ |
79 | if (pr->pr_protocol == protocol) |
80 | return (pr); | |
81 | return (0); | |
82 | } | |
83 | ||
84 | pfctlinput(cmd, arg) | |
85 | int cmd; | |
86 | caddr_t arg; | |
87 | { | |
88 | register struct domain *dp; | |
89 | register struct protosw *pr; | |
90 | ||
91 | for (dp = domains; dp; dp = dp->dom_next) | |
92 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) | |
93 | if (pr->pr_ctlinput) | |
94 | (*pr->pr_ctlinput)(cmd, arg); | |
95 | } | |
96 | ||
97 | pfslowtimo() | |
98 | { | |
99 | register struct domain *dp; | |
100 | register struct protosw *pr; | |
101 | ||
102 | for (dp = domains; dp; dp = dp->dom_next) | |
103 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) | |
104 | if (pr->pr_slowtimo) | |
105 | (*pr->pr_slowtimo)(); | |
4f083fd7 | 106 | timeout(pfslowtimo, (caddr_t)0, hz/2); |
d0d50a86 BJ |
107 | } |
108 | ||
109 | pffasttimo() | |
4147b3f6 | 110 | { |
d0d50a86 BJ |
111 | register struct domain *dp; |
112 | register struct protosw *pr; | |
4147b3f6 | 113 | |
d0d50a86 BJ |
114 | for (dp = domains; dp; dp = dp->dom_next) |
115 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) | |
116 | if (pr->pr_fasttimo) | |
117 | (*pr->pr_fasttimo)(); | |
4f083fd7 | 118 | timeout(pffasttimo, (caddr_t)0, hz/5); |
4147b3f6 | 119 | } |