xref: /csrg-svn/sys/kern/uipc_domain.c (revision 17102)
1*17102Sbloom /*	uipc_domain.c	6.3	84/08/29	*/
27425Sroot 
3*17102Sbloom #include "param.h"
4*17102Sbloom #include "socket.h"
5*17102Sbloom #include "protosw.h"
6*17102Sbloom #include "domain.h"
7*17102Sbloom #include "time.h"
8*17102Sbloom #include "kernel.h"
97425Sroot 
109008Sroot #define	ADDDOMAIN(x)	{ \
119008Sroot 	extern struct domain x/**/domain; \
129008Sroot 	x/**/domain.dom_next = domains; \
139008Sroot 	domains = &x/**/domain; \
149008Sroot }
159008Sroot 
169008Sroot domaininit()
177500Sroot {
189161Ssam 	register struct domain *dp;
199161Ssam 	register struct protosw *pr;
207500Sroot 
219161Ssam #ifndef lint
229008Sroot 	ADDDOMAIN(unix);
239008Sroot #ifdef INET
249008Sroot 	ADDDOMAIN(inet);
259008Sroot #endif
269008Sroot #ifdef PUP
279008Sroot 	ADDDOMAIN(pup);
289008Sroot #endif
2910025Ssam #include "imp.h"
3010025Ssam #if NIMP > 0
319008Sroot 	ADDDOMAIN(imp);
329008Sroot #endif
339161Ssam #endif
349008Sroot 
3516993Skarels 	for (dp = domains; dp; dp = dp->dom_next) {
3616993Skarels 		if (dp->dom_init)
3716993Skarels 			(*dp->dom_init)();
389008Sroot 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
399008Sroot 			if (pr->pr_init)
409008Sroot 				(*pr->pr_init)();
4116993Skarels 	}
429161Ssam 	pffasttimo();
439161Ssam 	pfslowtimo();
449008Sroot }
459008Sroot 
469008Sroot struct protosw *
479008Sroot pffindtype(family, type)
489008Sroot 	int family, type;
499008Sroot {
509008Sroot 	register struct domain *dp;
519008Sroot 	register struct protosw *pr;
529008Sroot 
539008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
549008Sroot 		if (dp->dom_family == family)
559008Sroot 			goto found;
569008Sroot 	return (0);
579008Sroot found:
589008Sroot 	for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
5911569Ssam 		if (pr->pr_type && pr->pr_type == type)
609008Sroot 			return (pr);
619008Sroot 	return (0);
629008Sroot }
639008Sroot 
649008Sroot struct protosw *
659008Sroot pffindproto(family, protocol)
669008Sroot 	int family, protocol;
679008Sroot {
689008Sroot 	register struct domain *dp;
699008Sroot 	register struct protosw *pr;
709008Sroot 
719008Sroot 	if (family == 0)
729008Sroot 		return (0);
739008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
749008Sroot 		if (dp->dom_family == family)
759008Sroot 			goto found;
769008Sroot 	return (0);
779008Sroot found:
789161Ssam 	for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
799008Sroot 		if (pr->pr_protocol == protocol)
809008Sroot 			return (pr);
819008Sroot 	return (0);
829008Sroot }
839008Sroot 
849008Sroot pfctlinput(cmd, arg)
859008Sroot 	int cmd;
869008Sroot 	caddr_t arg;
879008Sroot {
889008Sroot 	register struct domain *dp;
899008Sroot 	register struct protosw *pr;
909008Sroot 
919008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
929008Sroot 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
939008Sroot 			if (pr->pr_ctlinput)
949008Sroot 				(*pr->pr_ctlinput)(cmd, arg);
959008Sroot }
969008Sroot 
979008Sroot pfslowtimo()
989008Sroot {
999008Sroot 	register struct domain *dp;
1009008Sroot 	register struct protosw *pr;
1019008Sroot 
1029008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
1039008Sroot 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
1049008Sroot 			if (pr->pr_slowtimo)
1059008Sroot 				(*pr->pr_slowtimo)();
1069161Ssam 	timeout(pfslowtimo, (caddr_t)0, hz/2);
1079008Sroot }
1089008Sroot 
1099008Sroot pffasttimo()
1109008Sroot {
1119008Sroot 	register struct domain *dp;
1129008Sroot 	register struct protosw *pr;
1139008Sroot 
1149008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
1159008Sroot 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
1169008Sroot 			if (pr->pr_fasttimo)
1179008Sroot 				(*pr->pr_fasttimo)();
1189161Ssam 	timeout(pffasttimo, (caddr_t)0, hz/5);
1199008Sroot }
120