static void cleanup_devices(void) { /* * Check what interfaces are currently up and if connman is * suppose to handle the interface, then cleanup the mess * related to that interface. There might be weird routes etc * that are related to that interface and that might confuse * connmand. So in this case we just turn the interface down * so that kernel removes routes/addresses automatically and * then proceed the startup. * * Note that this cleanup must be done before rtnl/detect code * has activated interface watches. */ char **interfaces; int i; interfaces = __connman_inet_get_running_interfaces(); if (interfaces == NULL) return; for (i = 0; interfaces[i] != NULL; i++) { connman_bool_t filtered; int index; filtered = __connman_device_isfiltered(interfaces[i]); if (filtered == TRUE) continue; index = connman_inet_ifindex(interfaces[i]); if (index < 0) continue; DBG("cleaning up %s index %d", interfaces[i], index); connman_inet_ifdown(index); /* * ConnMan will turn the interface UP automatically so * no need to do it here. */ } g_strfreev(interfaces); }
static void cleanup_devices(void) { /* * Check what interfaces are currently up and if connman is * suppose to handle the interface, then cleanup the mess * related to that interface. There might be weird routes etc * that are related to that interface and that might confuse * connmand. So in this case we just turn the interface down * so that kernel removes routes/addresses automatically and * then proceed the startup. * * Note that this cleanup must be done before rtnl/detect code * has activated interface watches. */ char **interfaces; int i; interfaces = __connman_inet_get_running_interfaces(); if (!interfaces) return; for (i = 0; interfaces[i]; i++) { bool filtered; int index; struct sockaddr_in sin_addr, sin_mask; filtered = __connman_device_isfiltered(interfaces[i]); if (filtered) continue; index = connman_inet_ifindex(interfaces[i]); if (index < 0) continue; if (!__connman_inet_get_address_netmask(index, &sin_addr, &sin_mask)) { char *address = g_strdup(inet_ntoa(sin_addr.sin_addr)); char *netmask = g_strdup(inet_ntoa(sin_mask.sin_addr)); if (__connman_config_address_provisioned(address, netmask)) { DBG("Skip %s which is already provisioned " "with %s/%s", interfaces[i], address, netmask); g_free(address); g_free(netmask); continue; } g_free(address); g_free(netmask); } DBG("cleaning up %s index %d", interfaces[i], index); connman_inet_ifdown(index); /* * ConnMan will turn the interface UP automatically so * no need to do it here. */ } g_strfreev(interfaces); }