summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSreeram Ramachandran <sreeram@google.com>2014-07-23 09:30:53 -0700
committerSreeram Ramachandran <sreeram@google.com>2014-07-23 09:30:53 -0700
commiteec232603d314e486888e5a0d2dd8d507c266be7 (patch)
tree5b6a6fc48afc1d60696257809ef5707cabb8c248
parent759356bbd889d780a57c51c19761b32cbba8e6ef (diff)
downloadsystem_core-eec232603d314e486888e5a0d2dd8d507c266be7.zip
system_core-eec232603d314e486888e5a0d2dd8d507c266be7.tar.gz
system_core-eec232603d314e486888e5a0d2dd8d507c266be7.tar.bz2
Put back some deleted code.
http://ag/507249 removed a bunch of supposedly dead (unused) code. It turns out at least ifc_disable() is being used in some protected partner branches. Put back that as well as ifc_enable() to keep it symmetric. Bug: 15413389 Change-Id: Ibec83a66e5d9079876ccf36d250b95b7c0294c03
-rw-r--r--include/netutils/ifc.h3
-rw-r--r--libnetutils/ifc_utils.c31
2 files changed, 34 insertions, 0 deletions
diff --git a/include/netutils/ifc.h b/include/netutils/ifc.h
index 2d49a87..9a8b282 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 52ce171..2786373 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