+static errno_t
+ether_inet_prmod_ioctl(ifnet_t ifp, protocol_family_t protocol_family,
+ u_long command, void *data)
+{
+#pragma unused(protocol_family)
+ int error = 0;
+
+ switch (command) {
+ case SIOCSIFADDR: /* struct ifaddr pointer */
+ case SIOCAIFADDR: { /* struct ifaddr pointer */
+ /*
+ * Note: caller of ifnet_ioctl() passes in pointer to
+ * struct ifaddr as parameter to SIOC{A,S}IFADDR, for
+ * legacy reasons.
+ */
+ struct ifaddr *ifa = data;
+
+ if (!(ifnet_flags(ifp) & IFF_RUNNING)) {
+ ifnet_set_flags(ifp, IFF_UP, IFF_UP);
+ ifnet_ioctl(ifp, 0, SIOCSIFFLAGS, NULL);
+ }
+
+ if (ifaddr_address_family(ifa) != AF_INET) {
+ break;
+ }
+
+ inet_arp_init_ifaddr(ifp, ifa);
+
+ if (command != SIOCSIFADDR) {
+ break;
+ }
+
+ /*
+ * Register new IP and MAC addresses with the kernel
+ * debugger if the interface is the same as was registered
+ * by IOKernelDebugger. If no interface was registered,
+ * fall back and just match against en0 interface.
+ * Do this only for the first address of the interface
+ * and not for aliases.
+ */
+ if ((kdp_get_interface() != 0 &&
+ kdp_get_interface() == ifp->if_softc) ||
+ (kdp_get_interface() == 0 && ifp->if_unit == 0)) {
+ kdp_set_ip_and_mac_addresses(&(IA_SIN(ifa)->sin_addr),
+ (struct ether_addr *)IF_LLADDR(ifp));
+ }
+ break;
+ }