diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-12-07 07:19:29 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-12-07 07:19:29 +0100 |
commit | 21cf9622d48ac41f86c7fe186c6b617e5f661189 (patch) | |
tree | e68d23e78df5241f5f0110a378f8476ab8076a66 | |
parent | 217e0391609f18725d7d6267045b21960bd81faa (diff) | |
download | connman-21cf9622d48ac41f86c7fe186c6b617e5f661189.tar.gz connman-21cf9622d48ac41f86c7fe186c6b617e5f661189.tar.bz2 connman-21cf9622d48ac41f86c7fe186c6b617e5f661189.zip |
Add DHCP bound, renew and fail handling
-rw-r--r-- | include/dhcp.h | 2 | ||||
-rw-r--r-- | src/dhcp.c | 51 |
2 files changed, 53 insertions, 0 deletions
diff --git a/include/dhcp.h b/include/dhcp.h index 2d6704ca..2ec471c0 100644 --- a/include/dhcp.h +++ b/include/dhcp.h @@ -49,6 +49,8 @@ int connman_dhcp_get_index(struct connman_dhcp *dhcp); char *connman_dhcp_get_interface(struct connman_dhcp *dhcp); void connman_dhcp_bound(struct connman_dhcp *dhcp); +void connman_dhcp_renew(struct connman_dhcp *dhcp); +void connman_dhcp_fail(struct connman_dhcp *dhcp); struct connman_dhcp_driver { const char *name; @@ -93,7 +93,48 @@ char *connman_dhcp_get_interface(struct connman_dhcp *dhcp) */ void connman_dhcp_bound(struct connman_dhcp *dhcp) { + struct connman_element *element; + DBG("dhcp %p", dhcp); + + element = connman_element_create(NULL); + if (element == NULL) + return; + + element->type = CONNMAN_ELEMENT_TYPE_IPV4; + element->index = dhcp->index; + + connman_element_update(dhcp->element); + + if (connman_element_register(element, dhcp->element) < 0) + connman_element_unref(element); +} + +/** + * connman_dhcp_renew: + * @dhcp: DHCP structure + * + * Report successful renew of the interface + */ +void connman_dhcp_renew(struct connman_dhcp *dhcp) +{ + DBG("dhcp %p", dhcp); + + connman_element_update(dhcp->element); +} + +/** + * connman_dhcp_fail: + * @dhcp: DHCP structure + * + * Report DHCP failure of the interface + */ +void connman_dhcp_fail(struct connman_dhcp *dhcp) +{ + DBG("dhcp %p", dhcp); + + connman_element_set_error(dhcp->element, + CONNMAN_ELEMENT_ERROR_FAILED); } static GSList *driver_list = NULL; @@ -191,12 +232,22 @@ static void dhcp_remove(struct connman_element *element) connman_dhcp_unref(dhcp); } +static void dhcp_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 dhcp_driver = { .name = "dhcp", .type = CONNMAN_ELEMENT_TYPE_DHCP, .priority = CONNMAN_DRIVER_PRIORITY_LOW, .probe = dhcp_probe, .remove = dhcp_remove, + .change = dhcp_change, }; int __connman_dhcp_init(void) |