summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2010-09-28 01:36:32 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2010-09-28 01:39:17 +0200
commitf79f758d3e8e459a72121fc430b5531dccb56115 (patch)
tree0b712e4141739b137f5057a5ccc82ab95aef020e
parentc98264bf67baa934c3855b45118cec610da184c7 (diff)
downloadconnman-f79f758d3e8e459a72121fc430b5531dccb56115.tar.gz
connman-f79f758d3e8e459a72121fc430b5531dccb56115.tar.bz2
connman-f79f758d3e8e459a72121fc430b5531dccb56115.zip
Remove providers based on their VPN service path
-rw-r--r--src/provider.c26
-rwxr-xr-xtest/disconnect-vpn3
2 files changed, 20 insertions, 9 deletions
diff --git a/src/provider.c b/src/provider.c
index b7dc9e9d..adad8dfc 100644
--- a/src/provider.c
+++ b/src/provider.c
@@ -216,18 +216,30 @@ int __connman_provider_connect(struct connman_provider *provider)
int __connman_provider_remove(const char *path)
{
struct connman_provider *provider;
+ GHashTableIter iter;
+ gpointer value, key;
DBG("path %s", path);
- provider = g_hash_table_lookup(provider_hash, path);
- if (provider == NULL) {
- DBG("patch %s not found", path);
- return -ENXIO;
- }
+ g_hash_table_iter_init(&iter, provider_hash);
+ while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+ const char *srv_path;
+ provider = value;
- g_hash_table_remove(provider_hash, path);
+ if (provider->vpn_service == NULL)
+ continue;
- return 0;
+ srv_path = __connman_service_get_path(provider->vpn_service);
+
+ if (g_strcmp0(srv_path, path) == 0) {
+ DBG("Removing VPN %s", provider->identifier);
+ g_hash_table_remove(provider_hash,
+ provider->identifier);
+ return 0;
+ }
+ }
+
+ return -ENXIO;
}
static int set_connected(struct connman_provider *provider,
diff --git a/test/disconnect-vpn b/test/disconnect-vpn
index 2367f13f..21b50d8e 100755
--- a/test/disconnect-vpn
+++ b/test/disconnect-vpn
@@ -4,7 +4,7 @@ import sys
import dbus
if (len(sys.argv) < 2):
- print "Usage: %s <provider name> " % (sys.argv[0])
+ print "Usage: %s <VPN service path> " % (sys.argv[0])
sys.exit(1)
bus = dbus.SystemBus()
@@ -18,5 +18,4 @@ print "remove path is %s" %(path)
manager.RemoveProvider(sys.argv[1])
-print "remove path is %s" %(path)