xref: /csrg-svn/sys/kern/uipc_domain.c (revision 10025)
1*10025Ssam /*	uipc_domain.c	5.7	82/12/30	*/
27425Sroot 
37425Sroot #include "../h/param.h"
49008Sroot #include "../h/socket.h"
59008Sroot #include "../h/protosw.h"
69008Sroot #include "../h/domain.h"
79161Ssam #include <time.h>
89161Ssam #include "../h/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
29*10025Ssam #include "imp.h"
30*10025Ssam #if NIMP > 0
319008Sroot 	ADDDOMAIN(imp);
329008Sroot #endif
339161Ssam #endif
349008Sroot 
359008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
369008Sroot 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
379008Sroot 			if (pr->pr_init)
389008Sroot 				(*pr->pr_init)();
399161Ssam 	pffasttimo();
409161Ssam 	pfslowtimo();
419008Sroot }
429008Sroot 
439008Sroot struct protosw *
449008Sroot pffindtype(family, type)
459008Sroot 	int family, type;
469008Sroot {
479008Sroot 	register struct domain *dp;
489008Sroot 	register struct protosw *pr;
499008Sroot 
509008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
519008Sroot 		if (dp->dom_family == family)
529008Sroot 			goto found;
539008Sroot 	return (0);
549008Sroot found:
559008Sroot 	for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
569008Sroot 		if (pr->pr_type == type)
579008Sroot 			return (pr);
589008Sroot 	return (0);
599008Sroot }
609008Sroot 
619008Sroot struct protosw *
629008Sroot pffindproto(family, protocol)
639008Sroot 	int family, protocol;
649008Sroot {
659008Sroot 	register struct domain *dp;
669008Sroot 	register struct protosw *pr;
679008Sroot 
689008Sroot 	if (family == 0)
699008Sroot 		return (0);
709008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
719008Sroot 		if (dp->dom_family == family)
729008Sroot 			goto found;
739008Sroot 	return (0);
749008Sroot found:
759161Ssam 	for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
769008Sroot 		if (pr->pr_protocol == protocol)
779008Sroot 			return (pr);
789008Sroot 	return (0);
799008Sroot }
809008Sroot 
819008Sroot pfctlinput(cmd, arg)
829008Sroot 	int cmd;
839008Sroot 	caddr_t arg;
849008Sroot {
859008Sroot 	register struct domain *dp;
869008Sroot 	register struct protosw *pr;
879008Sroot 
889008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
899008Sroot 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
909008Sroot 			if (pr->pr_ctlinput)
919008Sroot 				(*pr->pr_ctlinput)(cmd, arg);
929008Sroot }
939008Sroot 
949008Sroot pfslowtimo()
959008Sroot {
969008Sroot 	register struct domain *dp;
979008Sroot 	register struct protosw *pr;
989008Sroot 
999008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
1009008Sroot 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
1019008Sroot 			if (pr->pr_slowtimo)
1029008Sroot 				(*pr->pr_slowtimo)();
1039161Ssam 	timeout(pfslowtimo, (caddr_t)0, hz/2);
1049008Sroot }
1059008Sroot 
1069008Sroot pffasttimo()
1079008Sroot {
1089008Sroot 	register struct domain *dp;
1099008Sroot 	register struct protosw *pr;
1109008Sroot 
1119008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
1129008Sroot 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
1139008Sroot 			if (pr->pr_fasttimo)
1149008Sroot 				(*pr->pr_fasttimo)();
1159161Ssam 	timeout(pffasttimo, (caddr_t)0, hz/5);
1169008Sroot }
117