Propagate DHCP errors to parent elements
authorMarcel Holtmann <marcel@holtmann.org>
Tue, 24 Mar 2009 14:13:57 +0000 (15:13 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 24 Mar 2009 14:13:57 +0000 (15:13 +0100)
plugins/dhclient.c

index 7e5e6d0ac86160eee97b7aae9821681a3f8a74c5..0bf9ad113884715dc0d55281bf4dbb7ff710f044 100644 (file)
@@ -215,11 +215,21 @@ static void dhclient_remove(struct connman_element *element)
        kill_task(task);
 }
 
+static void dhclient_change(struct connman_element *element)
+{
+       DBG("element %p name %s", element, element->name);
+
+       if (element->state == CONNMAN_ELEMENT_STATE_ERROR)
+               connman_element_set_error(element->parent,
+                                       CONNMAN_ELEMENT_ERROR_DHCP_FAILED);
+}
+
 static struct connman_driver dhclient_driver = {
        .name           = "dhclient",
        .type           = CONNMAN_ELEMENT_TYPE_DHCP,
        .probe          = dhclient_probe,
        .remove         = dhclient_remove,
+       .change         = dhclient_change,
 };
 
 static DBusHandlerResult dhclient_filter(DBusConnection *conn,
@@ -306,6 +316,9 @@ static DBusHandlerResult dhclient_filter(DBusConnection *conn,
        } else if (g_ascii_strcasecmp(text, "RENEW") == 0 ||
                                g_ascii_strcasecmp(text, "REBIND") == 0) {
                connman_element_update(task->element);
+       } else if (g_ascii_strcasecmp(text, "FAIL") == 0) {
+               connman_element_set_error(task->element,
+                                               CONNMAN_ELEMENT_ERROR_FAILED);
        } else {
        }