__private_extern__ int ether_family_init(void) { errno_t error = 0; /* Register protocol registration functions */ if ((error = proto_register_plumber(PF_INET, APPLE_IF_FAM_ETHERNET, ether_attach_inet, ether_detach_inet)) != 0) { printf("proto_register_plumber failed for PF_INET error=%d\n", error); goto done; } #if INET6 if ((error = proto_register_plumber(PF_INET6, APPLE_IF_FAM_ETHERNET, ether_attach_inet6, ether_detach_inet6)) != 0) { printf("proto_register_plumber failed for PF_INET6 error=%d\n", error); goto done; } #endif /* INET6 */ #if NETAT if ((error = proto_register_plumber(PF_APPLETALK, APPLE_IF_FAM_ETHERNET, ether_attach_at, ether_detach_at)) != 0) { printf("proto_register_plumber failed PF_APPLETALK error=%d\n", error); goto done; } #endif /* NETAT */ #if VLAN vlan_family_init(); #endif /* VLAN */ #if BOND bond_family_init(); #endif /* BOND */ done: return (error); }
errno_t utun_register_control(void) { struct kern_ctl_reg kern_ctl; errno_t result = 0; /* Create a tag to allocate memory */ utun_malloc_tag = OSMalloc_Tagalloc(UTUN_CONTROL_NAME, OSMT_DEFAULT); /* Find a unique value for our interface family */ result = mbuf_tag_id_find(UTUN_CONTROL_NAME, &utun_family); if (result != 0) { printf("utun_register_control - mbuf_tag_id_find_internal failed: %d\n", result); return result; } bzero(&kern_ctl, sizeof(kern_ctl)); strlcpy(kern_ctl.ctl_name, UTUN_CONTROL_NAME, sizeof(kern_ctl.ctl_name)); kern_ctl.ctl_name[sizeof(kern_ctl.ctl_name) - 1] = 0; kern_ctl.ctl_flags = CTL_FLAG_PRIVILEGED | CTL_FLAG_REG_EXTENDED; /* Require root */ kern_ctl.ctl_sendsize = 512 * 1024; kern_ctl.ctl_recvsize = 512 * 1024; kern_ctl.ctl_connect = utun_ctl_connect; kern_ctl.ctl_disconnect = utun_ctl_disconnect; kern_ctl.ctl_send = utun_ctl_send; kern_ctl.ctl_setopt = utun_ctl_setopt; kern_ctl.ctl_getopt = utun_ctl_getopt; kern_ctl.ctl_rcvd = utun_ctl_rcvd; utun_ctl_init_crypto(); result = ctl_register(&kern_ctl, &utun_kctlref); if (result != 0) { printf("utun_register_control - ctl_register failed: %d\n", result); return result; } /* Register the protocol plumbers */ if ((result = proto_register_plumber(PF_INET, utun_family, utun_attach_proto, NULL)) != 0) { printf("utun_register_control - proto_register_plumber(PF_INET, %d) failed: %d\n", utun_family, result); ctl_deregister(utun_kctlref); return result; } /* Register the protocol plumbers */ if ((result = proto_register_plumber(PF_INET6, utun_family, utun_attach_proto, NULL)) != 0) { proto_unregister_plumber(PF_INET, utun_family); ctl_deregister(utun_kctlref); printf("utun_register_control - proto_register_plumber(PF_INET6, %d) failed: %d\n", utun_family, result); return result; } return 0; }
/* ----------------------------------------------------------------------------- init function ----------------------------------------------------------------------------- */ int ppp_ipv6_init(int init_arg) { return proto_register_plumber(PF_INET6, APPLE_IF_FAM_PPP, ppp_ipv6_attach, ppp_ipv6_detach); }