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