+static void udhcp_bound(DBusMessage *msg, gboolean renew)
+{
+ struct task_data *task;
+ struct connman_element *element, *parent;
+ const char *interface, *address, *netmask, *broadcast, *gateway, *dns;
+ int index;
+
+ dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &interface,
+ DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_STRING, &netmask,
+ DBUS_TYPE_STRING, &broadcast,
+ DBUS_TYPE_STRING, &gateway,
+ DBUS_TYPE_STRING, &dns,
+ DBUS_TYPE_INVALID);
+
+ DBG("%s ==> address %s gateway %s", interface, address, gateway);
+
+ index = inet_name2index(interface);
+ if (index < 0)
+ return;
+
+ task = task_find_by_index(index);
+ if (task == NULL)
+ return;
+
+ parent = task_get_data(task);
+ if (parent == NULL)
+ return;
+
+ g_free(parent->ipv4.address);
+ parent->ipv4.address = g_strdup(address);
+
+ g_free(parent->ipv4.netmask);
+ parent->ipv4.netmask = g_strdup(netmask);
+
+ g_free(parent->ipv4.broadcast);
+ parent->ipv4.broadcast = g_strdup(broadcast);
+
+ g_free(parent->ipv4.gateway);
+ parent->ipv4.gateway = g_strdup(gateway);
+
+ g_free(parent->ipv4.nameserver);
+ parent->ipv4.nameserver = g_strdup(dns);
+
+ connman_element_update(parent);
+
+ if (renew == TRUE)
+ return;
+
+ element = connman_element_create(NULL);
+ if (element == NULL)
+ return;
+
+ element->type = CONNMAN_ELEMENT_TYPE_IPV4;
+ element->index = index;
+
+ if (connman_element_register(element, parent) < 0)
+ connman_element_unref(element);
+}
+
+static DBusHandlerResult udhcp_filter(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ if (dbus_message_is_method_call(msg, UDHCPC_INTF, "bound") == TRUE) {
+ udhcp_bound(msg, FALSE);
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
+ if (dbus_message_is_method_call(msg, UDHCPC_INTF, "renew") == TRUE) {
+ udhcp_bound(msg, TRUE);
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static DBusConnection *connection;
+
+static const char *udhcp_rule = "path=" UDHCPC_PATH ",interface=" UDHCPC_INTF;
+