summaryrefslogtreecommitdiff
path: root/vpn
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-11-12 14:07:37 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-11-23 12:58:51 +0200
commitb04634c4902c12fa9a2044d7bbcfbd0088913b1b (patch)
treea9d15dac5ff676b64cc2c6dd9a3f4faf6d854488 /vpn
parent2023b90de4066fe2cf28b48bfca58c35c92aab20 (diff)
downloadconnman-b04634c4902c12fa9a2044d7bbcfbd0088913b1b.tar.gz
connman-b04634c4902c12fa9a2044d7bbcfbd0088913b1b.tar.bz2
connman-b04634c4902c12fa9a2044d7bbcfbd0088913b1b.zip
vpn: Add preliminary agent support
Diffstat (limited to 'vpn')
-rw-r--r--vpn/main.c2
-rw-r--r--vpn/vpn-manager.c47
2 files changed, 49 insertions, 0 deletions
diff --git a/vpn/main.c b/vpn/main.c
index eb074d4a..732bd4b1 100644
--- a/vpn/main.c
+++ b/vpn/main.c
@@ -308,6 +308,7 @@ int main(int argc, char *argv[])
else
config_init(option_config);
+ __connman_agent_init();
__vpn_provider_init(option_routes);
__vpn_manager_init();
__vpn_ipconfig_init();
@@ -329,6 +330,7 @@ int main(int argc, char *argv[])
__vpn_ipconfig_cleanup();
__vpn_manager_cleanup();
__vpn_provider_cleanup();
+ __connman_agent_cleanup();
__connman_dbus_cleanup();
__connman_log_cleanup(FALSE);
diff --git a/vpn/vpn-manager.c b/vpn/vpn-manager.c
index 680f2fd9..cd851651 100644
--- a/vpn/vpn-manager.c
+++ b/vpn/vpn-manager.c
@@ -27,6 +27,7 @@
#include <gdbus.h>
#include <connman/log.h>
+#include <connman/agent.h>
#include "../src/connman.h"
@@ -87,6 +88,46 @@ static DBusMessage *get_connections(DBusConnection *conn, DBusMessage *msg,
return reply;
}
+static DBusMessage *register_agent(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ const char *sender, *path;
+ int err;
+
+ DBG("conn %p", conn);
+
+ sender = dbus_message_get_sender(msg);
+
+ dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID);
+
+ err = connman_agent_register(sender, path);
+ if (err < 0)
+ return __connman_error_failed(msg, -err);
+
+ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *unregister_agent(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ const char *sender, *path;
+ int err;
+
+ DBG("conn %p", conn);
+
+ sender = dbus_message_get_sender(msg);
+
+ dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID);
+
+ err = connman_agent_unregister(sender, path);
+ if (err < 0)
+ return __connman_error_failed(msg, -err);
+
+ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
static const GDBusMethodTable manager_methods[] = {
{ GDBUS_ASYNC_METHOD("Create",
GDBUS_ARGS({ "properties", "a{sv}" }),
@@ -98,6 +139,12 @@ static const GDBusMethodTable manager_methods[] = {
{ GDBUS_METHOD("GetConnections", NULL,
GDBUS_ARGS({ "connections", "a(oa{sv})" }),
get_connections) },
+ { GDBUS_METHOD("RegisterAgent",
+ GDBUS_ARGS({ "path", "o" }), NULL,
+ register_agent) },
+ { GDBUS_METHOD("UnregisterAgent",
+ GDBUS_ARGS({ "path", "o" }), NULL,
+ unregister_agent) },
{ },
};