summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@nokia.com>2011-01-10 18:03:31 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2011-01-10 21:15:25 +0100
commitd4e1dfc943644199849eb3de2463eb0ca0344408 (patch)
tree37cd47cc4c98d7bc08a3954def7c70815c0cc1ab /src
parentd62262f1bb76502d7b6a208f33ba3c53615e2f4e (diff)
downloadconnman-d4e1dfc943644199849eb3de2463eb0ca0344408.tar.gz
connman-d4e1dfc943644199849eb3de2463eb0ca0344408.tar.bz2
connman-d4e1dfc943644199849eb3de2463eb0ca0344408.zip
ipconfig: Restore original IPv6 interface status when connman quits
Diffstat (limited to 'src')
-rw-r--r--src/ipconfig.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 8ef564e6..6ef39c5e 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -77,6 +77,8 @@ struct connman_ipdevice {
struct connman_ipconfig *config_ipv4;
struct connman_ipconfig *config_ipv6;
+
+ gboolean ipv6_enabled;
};
static GHashTable *ipdevice_hash = NULL;
@@ -292,6 +294,35 @@ static const char *scope2str(unsigned char scope)
return "";
}
+static gboolean get_ipv6_state(gchar *ifname)
+{
+ int disabled;
+ gchar *path;
+ FILE *f;
+ gboolean enabled = FALSE;
+
+ if (ifname == NULL)
+ path = g_strdup("/proc/sys/net/ipv6/conf/all/disable_ipv6");
+ else
+ path = g_strdup_printf(
+ "/proc/sys/net/ipv6/conf/%s/disable_ipv6", ifname);
+
+ if (path == NULL)
+ return enabled;
+
+ f = fopen(path, "r");
+
+ g_free(path);
+
+ if (f != NULL) {
+ if (fscanf(f, "%d", &disabled) > 0)
+ enabled = !disabled;
+ fclose(f);
+ }
+
+ return enabled;
+}
+
static void set_ipv6_state(gchar *ifname, gboolean enable)
{
gchar *path;
@@ -344,6 +375,9 @@ static void free_ipdevice(gpointer data)
g_free(ipdevice->pac);
g_free(ipdevice->address);
+
+ set_ipv6_state(ipdevice->ifname, ipdevice->ipv6_enabled);
+
g_free(ipdevice->ifname);
g_free(ipdevice);
}
@@ -439,6 +473,8 @@ void __connman_ipconfig_newlink(int index, unsigned short type,
ipdevice->ifname = connman_inet_ifname(index);
ipdevice->type = type;
+ ipdevice->ipv6_enabled = get_ipv6_state(ipdevice->ifname);
+
ipdevice->address = g_strdup(address);
g_hash_table_insert(ipdevice_hash, GINT_TO_POINTER(index), ipdevice);