xref: /csrg-svn/sys/kern/uipc_domain.c (revision 18816)
1*18816Ssklower /*	uipc_domain.c	6.4	85/04/27	*/
27425Sroot 
317102Sbloom #include "param.h"
417102Sbloom #include "socket.h"
517102Sbloom #include "protosw.h"
617102Sbloom #include "domain.h"
717102Sbloom #include "time.h"
817102Sbloom #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
26*18816Ssklower #ifdef NS
27*18816Ssklower 	ADDDOMAIN(ns);
28*18816Ssklower #endif
299008Sroot #ifdef PUP
309008Sroot 	ADDDOMAIN(pup);
319008Sroot #endif
3210025Ssam #include "imp.h"
3310025Ssam #if NIMP > 0
349008Sroot 	ADDDOMAIN(imp);
359008Sroot #endif
369161Ssam #endif
379008Sroot 
3816993Skarels 	for (dp = domains; dp; dp = dp->dom_next) {
3916993Skarels 		if (dp->dom_init)
4016993Skarels 			(*dp->dom_init)();
419008Sroot 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
429008Sroot 			if (pr->pr_init)
439008Sroot 				(*pr->pr_init)();
4416993Skarels 	}
459161Ssam 	pffasttimo();
469161Ssam 	pfslowtimo();
479008Sroot }
489008Sroot 
499008Sroot struct protosw *
509008Sroot pffindtype(family, type)
519008Sroot 	int family, type;
529008Sroot {
539008Sroot 	register struct domain *dp;
549008Sroot 	register struct protosw *pr;
559008Sroot 
569008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
579008Sroot 		if (dp->dom_family == family)
589008Sroot 			goto found;
599008Sroot 	return (0);
609008Sroot found:
619008Sroot 	for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
6211569Ssam 		if (pr->pr_type && pr->pr_type == type)
639008Sroot 			return (pr);
649008Sroot 	return (0);
659008Sroot }
669008Sroot 
679008Sroot struct protosw *
689008Sroot pffindproto(family, protocol)
699008Sroot 	int family, protocol;
709008Sroot {
719008Sroot 	register struct domain *dp;
729008Sroot 	register struct protosw *pr;
739008Sroot 
749008Sroot 	if (family == 0)
759008Sroot 		return (0);
769008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
779008Sroot 		if (dp->dom_family == family)
789008Sroot 			goto found;
799008Sroot 	return (0);
809008Sroot found:
819161Ssam 	for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
829008Sroot 		if (pr->pr_protocol == protocol)
839008Sroot 			return (pr);
849008Sroot 	return (0);
859008Sroot }
869008Sroot 
879008Sroot pfctlinput(cmd, arg)
889008Sroot 	int cmd;
899008Sroot 	caddr_t arg;
909008Sroot {
919008Sroot 	register struct domain *dp;
929008Sroot 	register struct protosw *pr;
939008Sroot 
949008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
959008Sroot 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
969008Sroot 			if (pr->pr_ctlinput)
979008Sroot 				(*pr->pr_ctlinput)(cmd, arg);
989008Sroot }
999008Sroot 
1009008Sroot pfslowtimo()
1019008Sroot {
1029008Sroot 	register struct domain *dp;
1039008Sroot 	register struct protosw *pr;
1049008Sroot 
1059008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
1069008Sroot 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
1079008Sroot 			if (pr->pr_slowtimo)
1089008Sroot 				(*pr->pr_slowtimo)();
1099161Ssam 	timeout(pfslowtimo, (caddr_t)0, hz/2);
1109008Sroot }
1119008Sroot 
1129008Sroot pffasttimo()
1139008Sroot {
1149008Sroot 	register struct domain *dp;
1159008Sroot 	register struct protosw *pr;
1169008Sroot 
1179008Sroot 	for (dp = domains; dp; dp = dp->dom_next)
1189008Sroot 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
1199008Sroot 			if (pr->pr_fasttimo)
1209008Sroot 				(*pr->pr_fasttimo)();
1219161Ssam 	timeout(pffasttimo, (caddr_t)0, hz/5);
1229008Sroot }
123