void netifd_restart(void) { static struct uloop_timeout main_timer = { .cb = netifd_do_restart }; interface_set_down(NULL); uloop_timeout_set(&main_timer, 1000); }
status_t domain_interface_control(net_domain_private* domain, int32 option, ifreq* request) { const char* name = request->ifr_name; status_t status = B_OK; net_device_interface* device = get_device_interface(name, false); if (device == NULL) return ENODEV; RecursiveLocker _(domain->lock); net_interface* interface = find_interface(domain, name); if (interface != NULL) { switch (option) { case SIOCDIFADDR: remove_interface_from_domain(interface); break; case SIOCSIFFLAGS: { uint32 requestFlags = request->ifr_flags; request->ifr_flags &= ~(IFF_UP | IFF_LINK | IFF_BROADCAST); if ((requestFlags & IFF_UP) != (interface->flags & IFF_UP)) { if (requestFlags & IFF_UP) { status = interface->first_info->interface_up( interface->first_protocol); if (status == B_OK) interface->flags |= IFF_UP; } else { interface_set_down(interface); } } if (status == B_OK) { // TODO: why shouldn't we able to delete IFF_BROADCAST? interface->flags &= IFF_UP | IFF_LINK | IFF_BROADCAST; interface->flags |= request->ifr_flags; } break; } } } // If the SIOCDIFADDR call above removed the last interface associated with // the device interface, this will effectively remove the interface put_device_interface(device); return status; }