*
* Connection Manager
*
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
+ * Copyright (C) 2007-2009 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
#include <config.h>
#endif
+#include <unistd.h>
#include <sys/wait.h>
#include <glib/gstdio.h>
+#define CONNMAN_API_SUBJECT_TO_CHANGE
#include <connman/plugin.h>
#include <connman/driver.h>
#include <connman/dbus.h>
DBG("element %p name %s", element, element->name);
+ if (access(DHCLIENT, X_OK) < 0)
+ return -errno;
+
task = g_try_new0(struct dhclient_task, 1);
if (task == NULL)
return -ENOMEM;
element->type = CONNMAN_ELEMENT_TYPE_IPV4;
element->index = task->ifindex;
connman_element_update(task->element);
- connman_element_register(element, task->element);
+ if (connman_element_register(element, task->element) < 0)
+ connman_element_unref(element);
} else if (g_ascii_strcasecmp(text, "RENEW") == 0 ||
g_ascii_strcasecmp(text, "REBIND") == 0) {
connman_element_update(task->element);
static DBusConnection *connection;
+static const char *dhclient_rule = "path=" DHCLIENT_PATH
+ ",interface=" DHCLIENT_INTF;
+
static int dhclient_init(void)
{
- gchar *filter;
int err;
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ connection = connman_dbus_get_connection();
busname = dbus_bus_get_unique_name(connection);
busname = CONNMAN_SERVICE;
dbus_connection_add_filter(connection, dhclient_filter, NULL, NULL);
- filter = g_strdup_printf("interface=%s,path=%s",
- DHCLIENT_INTF, DHCLIENT_PATH);
-
- dbus_bus_add_match(connection, filter, NULL);
-
- g_free(filter);
+ dbus_bus_add_match(connection, dhclient_rule, NULL);
err = connman_driver_register(&dhclient_driver);
if (err < 0) {
connman_driver_unregister(&dhclient_driver);
+ dbus_bus_remove_match(connection, dhclient_rule, NULL);
+
+ dbus_connection_remove_filter(connection, dhclient_filter, NULL);
+
dbus_connection_unref(connection);
}