diff --git a/include/netutils/ifc.h b/include/netutils/ifc.h index 2d49a8758..9a8b282d1 100644 --- a/include/netutils/ifc.h +++ b/include/netutils/ifc.h @@ -31,6 +31,9 @@ extern int ifc_get_hwaddr(const char *name, void *ptr); extern int ifc_up(const char *name); extern int ifc_down(const char *name); +extern int ifc_enable(const char *ifname); +extern int ifc_disable(const char *ifname); + #define RESET_IPV4_ADDRESSES 0x01 #define RESET_IPV6_ADDRESSES 0x02 #define RESET_ALL_ADDRESSES (RESET_IPV4_ADDRESSES | RESET_IPV6_ADDRESSES) diff --git a/libnetutils/ifc_utils.c b/libnetutils/ifc_utils.c index 52ce17156..27863730b 100644 --- a/libnetutils/ifc_utils.c +++ b/libnetutils/ifc_utils.c @@ -563,6 +563,37 @@ int ifc_create_default_route(const char *name, in_addr_t gw) return ret; } +// Needed by code in hidden partner repositories / branches, so don't delete. +int ifc_enable(const char *ifname) +{ + int result; + + ifc_init(); + result = ifc_up(ifname); + ifc_close(); + return result; +} + +int ifc_disable(const char *ifname) +{ + unsigned addr, count; + int result; + + ifc_init(); + result = ifc_down(ifname); + + ifc_set_addr(ifname, 0); + for (count=0, addr=1;((addr != 0) && (count < 255)); count++) { + if (ifc_get_addr(ifname, &addr) < 0) + break; + if (addr) + ifc_set_addr(ifname, 0); + } + + ifc_close(); + return result; +} + int ifc_reset_connections(const char *ifname, const int reset_mask) { #ifdef HAVE_ANDROID_OS