Commit | Line | Data |
---|---|---|
d0d50a86 | 1 | /* uipc_domain.c 5.5 82/11/02 */ |
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" | |
7 | ||
8 | #define ADDDOMAIN(x) { \ | |
9 | extern struct domain x/**/domain; \ | |
10 | x/**/domain.dom_next = domains; \ | |
11 | domains = &x/**/domain; \ | |
12 | } | |
13 | ||
14 | domaininit() | |
15 | { | |
16 | ||
17 | ADDDOMAIN(unix); | |
18 | #ifdef INET | |
19 | ADDDOMAIN(inet); | |
20 | #endif | |
21 | #ifdef PUP | |
22 | ADDDOMAIN(pup); | |
23 | #endif | |
24 | #ifdef IMP | |
25 | ADDDOMAIN(imp); | |
26 | #endif | |
27 | pfinit(); | |
28 | } | |
29 | ||
30 | /* | |
31 | * Operations applying to the sets of protocols | |
32 | * defined by the available communications domains. | |
33 | */ | |
34 | pfinit() | |
35 | { | |
36 | register struct domain *dp; | |
37 | register struct protosw *pr; | |
38 | ||
39 | for (dp = domains; dp; dp = dp->dom_next) | |
40 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) | |
41 | if (pr->pr_init) | |
42 | (*pr->pr_init)(); | |
43 | } | |
44 | ||
45 | struct protosw * | |
46 | pffindtype(family, type) | |
47 | int family, type; | |
48 | { | |
49 | register struct domain *dp; | |
50 | register struct protosw *pr; | |
51 | ||
52 | for (dp = domains; dp; dp = dp->dom_next) | |
53 | if (dp->dom_family == family) | |
54 | goto found; | |
55 | return (0); | |
56 | found: | |
57 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) | |
58 | if (pr->pr_type == type) | |
59 | return (pr); | |
60 | return (0); | |
61 | } | |
62 | ||
63 | struct protosw * | |
64 | pffindproto(family, protocol) | |
65 | int family, protocol; | |
66 | { | |
67 | register struct domain *dp; | |
68 | register struct protosw *pr; | |
69 | ||
70 | if (family == 0) | |
71 | return (0); | |
72 | for (dp = domains; dp; dp = dp->dom_next) | |
73 | if (dp->dom_family == family) | |
74 | goto found; | |
75 | return (0); | |
76 | found: | |
77 | for (pr = dp->dom_protosw; pr <= dp->dom_protoswNPROTOSW; pr++) | |
78 | if (pr->pr_protocol == protocol) | |
79 | return (pr); | |
80 | return (0); | |
81 | } | |
82 | ||
83 | pfctlinput(cmd, arg) | |
84 | int cmd; | |
85 | caddr_t arg; | |
86 | { | |
87 | register struct domain *dp; | |
88 | register struct protosw *pr; | |
89 | ||
90 | for (dp = domains; dp; dp = dp->dom_next) | |
91 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) | |
92 | if (pr->pr_ctlinput) | |
93 | (*pr->pr_ctlinput)(cmd, arg); | |
94 | } | |
95 | ||
96 | pfslowtimo() | |
97 | { | |
98 | register struct domain *dp; | |
99 | register struct protosw *pr; | |
100 | ||
101 | for (dp = domains; dp; dp = dp->dom_next) | |
102 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) | |
103 | if (pr->pr_slowtimo) | |
104 | (*pr->pr_slowtimo)(); | |
105 | } | |
106 | ||
107 | pffasttimo() | |
4147b3f6 | 108 | { |
d0d50a86 BJ |
109 | register struct domain *dp; |
110 | register struct protosw *pr; | |
4147b3f6 | 111 | |
d0d50a86 BJ |
112 | for (dp = domains; dp; dp = dp->dom_next) |
113 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) | |
114 | if (pr->pr_fasttimo) | |
115 | (*pr->pr_fasttimo)(); | |
4147b3f6 | 116 | } |