/* 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); }
void atalk_load() { atp_init(); atp_link(); adspInited = 0; /* adsp_init(); for 2225395 this happens in adsp_open and is undone on ADSP_UNLINK */ lck_mtx_unlock(domain_proto_mtx); proto_register_input(PF_APPLETALK, at_input_packet, NULL, 0); lck_mtx_lock(domain_proto_mtx); } /* atalk_load */
/* * IP6 initialization: fill in IP6 protocol switch table. * All protocols not implemented in kernel go to raw IP6 protocol handler. */ void ip6_init() { struct ip6protosw *pr; int i; struct timeval tv; #if DIAGNOSTIC if (sizeof(struct protosw) != sizeof(struct ip6protosw)) panic("sizeof(protosw) != sizeof(ip6protosw)"); #endif pr = (struct ip6protosw *)pffindproto_locked(PF_INET6, IPPROTO_RAW, SOCK_RAW); if (pr == 0) panic("ip6_init"); for (i = 0; i < IPPROTO_MAX; i++) ip6_protox[i] = pr; for (pr = (struct ip6protosw*)inet6domain.dom_protosw; pr; pr = pr->pr_next) { if(!(pr->pr_domain)) continue; /* If uninitialized, skip */ if (pr->pr_domain->dom_family == PF_INET6 && pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW) { ip6_protox[pr->pr_protocol] = pr; } } ip6_mutex_grp_attr = lck_grp_attr_alloc_init(); ip6_mutex_grp = lck_grp_alloc_init("ip6", ip6_mutex_grp_attr); ip6_mutex_attr = lck_attr_alloc_init(); if ((ip6_mutex = lck_mtx_alloc_init(ip6_mutex_grp, ip6_mutex_attr)) == NULL) { panic("ip6_init: can't alloc ip6_mutex\n"); } if ((dad6_mutex = lck_mtx_alloc_init(ip6_mutex_grp, ip6_mutex_attr)) == NULL) { panic("ip6_init: can't alloc dad6_mutex\n"); } if ((nd6_mutex = lck_mtx_alloc_init(ip6_mutex_grp, ip6_mutex_attr)) == NULL) { panic("ip6_init: can't alloc nd6_mutex\n"); } if ((prefix6_mutex = lck_mtx_alloc_init(ip6_mutex_grp, ip6_mutex_attr)) == NULL) { panic("ip6_init: can't alloc prefix6_mutex\n"); } if ((scope6_mutex = lck_mtx_alloc_init(ip6_mutex_grp, ip6_mutex_attr)) == NULL) { panic("ip6_init: can't alloc scope6_mutex\n"); } inet6domain.dom_flags = DOM_REENTRANT; ip6intrq.ifq_maxlen = ip6qmaxlen; in6_ifaddr_init(); nd6_init(); frag6_init(); icmp6_init(); /* * in many cases, random() here does NOT return random number * as initialization during bootstrap time occur in fixed order. */ microtime(&tv); ip6_flow_seq = random() ^ tv.tv_usec; microtime(&tv); ip6_desync_factor = (random() ^ tv.tv_usec) % MAX_TEMP_DESYNC_FACTOR; timeout(ip6_init2, (caddr_t)0, 1 * hz); lck_mtx_unlock(domain_proto_mtx); proto_register_input(PF_INET6, ip6_proto_input, NULL, 0); lck_mtx_lock(domain_proto_mtx); }