/* Initialize the PF_INET domain, and add in the pre-defined protos */ void in_dinit(struct domain *dp) { struct protosw *pr; int i; domain_unguard_t unguard; VERIFY(!(dp->dom_flags & DOM_INITIALIZED)); VERIFY(inetdomain == NULL); inetdomain = dp; /* * Attach first, then initialize; ip_init() needs raw IP handler. */ for (i = 0, pr = &inetsw[0]; i < in_proto_count; i++, pr++) net_add_proto(pr, dp, 0); for (i = 0, pr = &inetsw[0]; i < in_proto_count; i++, pr++) net_init_proto(pr, dp); inet_domain_mutex = dp->dom_mtx; unguard = domain_unguard_deploy(); i = proto_register_input(PF_INET, ip_proto_input, NULL, 1); if (i != 0) { panic("%s: failed to register PF_INET protocol: %d\n", __func__, i); /* NOTREACHED */ } domain_unguard_release(unguard); }
/* Initialize the PF_INET6 domain, and add in the pre-defined protos */ void in6_dinit(struct domain *dp) { struct ip6protosw *pr; int i; VERIFY(!(dp->dom_flags & DOM_INITIALIZED)); VERIFY(inet6domain == NULL); inet6domain = dp; _CASSERT(sizeof (struct protosw) == sizeof (struct ip6protosw)); _CASSERT(offsetof(struct ip6protosw, pr_entry) == offsetof(struct protosw, pr_entry)); _CASSERT(offsetof(struct ip6protosw, pr_domain) == offsetof(struct protosw, pr_domain)); _CASSERT(offsetof(struct ip6protosw, pr_protosw) == offsetof(struct protosw, pr_protosw)); _CASSERT(offsetof(struct ip6protosw, pr_type) == offsetof(struct protosw, pr_type)); _CASSERT(offsetof(struct ip6protosw, pr_protocol) == offsetof(struct protosw, pr_protocol)); _CASSERT(offsetof(struct ip6protosw, pr_flags) == offsetof(struct protosw, pr_flags)); _CASSERT(offsetof(struct ip6protosw, pr_input) == offsetof(struct protosw, pr_input)); _CASSERT(offsetof(struct ip6protosw, pr_output) == offsetof(struct protosw, pr_output)); _CASSERT(offsetof(struct ip6protosw, pr_ctlinput) == offsetof(struct protosw, pr_ctlinput)); _CASSERT(offsetof(struct ip6protosw, pr_ctloutput) == offsetof(struct protosw, pr_ctloutput)); _CASSERT(offsetof(struct ip6protosw, pr_usrreqs) == offsetof(struct protosw, pr_usrreqs)); _CASSERT(offsetof(struct ip6protosw, pr_init) == offsetof(struct protosw, pr_init)); _CASSERT(offsetof(struct ip6protosw, pr_drain) == offsetof(struct protosw, pr_drain)); _CASSERT(offsetof(struct ip6protosw, pr_sysctl) == offsetof(struct protosw, pr_sysctl)); _CASSERT(offsetof(struct ip6protosw, pr_lock) == offsetof(struct protosw, pr_lock)); _CASSERT(offsetof(struct ip6protosw, pr_unlock) == offsetof(struct protosw, pr_unlock)); _CASSERT(offsetof(struct ip6protosw, pr_getlock) == offsetof(struct protosw, pr_getlock)); _CASSERT(offsetof(struct ip6protosw, pr_filter_head) == offsetof(struct protosw, pr_filter_head)); _CASSERT(offsetof(struct ip6protosw, pr_old) == offsetof(struct protosw, pr_old)); /* * Attach first, then initialize. ip6_init() needs raw IP6 handler. */ for (i = 0, pr = &inet6sw[0]; i < in6_proto_count; i++, pr++) net_add_proto((struct protosw *)pr, dp, 0); for (i = 0, pr = &inet6sw[0]; i < in6_proto_count; i++, pr++) net_init_proto((struct protosw *)pr, dp); inet6_domain_mutex = dp->dom_mtx; }