diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2012-01-05 13:38:14 +0200 |
---|---|---|
committer | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2012-01-05 13:17:26 +0100 |
commit | 53f38ce0bc6505c8b8a7342b0243df442b7db5a4 (patch) | |
tree | ed3550a683f4f77ab7936374f4464ce19d1fbc5d /gdhcp | |
parent | 5f5b3609c4f9884954623d7e6bf2ae1ae7096637 (diff) | |
download | connman-53f38ce0bc6505c8b8a7342b0243df442b7db5a4.tar.gz connman-53f38ce0bc6505c8b8a7342b0243df442b7db5a4.tar.bz2 connman-53f38ce0bc6505c8b8a7342b0243df442b7db5a4.zip |
dhcpv6: Release message implemented.
Diffstat (limited to 'gdhcp')
-rw-r--r-- | gdhcp/client.c | 31 | ||||
-rw-r--r-- | gdhcp/gdhcp.h | 1 |
2 files changed, 32 insertions, 0 deletions
diff --git a/gdhcp/client.c b/gdhcp/client.c index 7743aa50..99f99510 100644 --- a/gdhcp/client.c +++ b/gdhcp/client.c @@ -74,6 +74,7 @@ typedef enum _dhcp_client_state { REQUEST, RENEW, REBIND, + RELEASE, } ClientState; struct _GDHCPClient { @@ -126,6 +127,8 @@ struct _GDHCPClient { gpointer renew_data; GDHCPClientEventFunc rebind_cb; gpointer rebind_data; + GDHCPClientEventFunc release_cb; + gpointer release_data; char *last_address; unsigned char *duid; int duid_len; @@ -817,6 +820,11 @@ static int send_dhcpv6_rebind(GDHCPClient *dhcp_client) return send_dhcpv6_msg(dhcp_client, DHCPV6_REBIND, "rebind"); } +static int send_dhcpv6_release(GDHCPClient *dhcp_client) +{ + return send_dhcpv6_msg(dhcp_client, DHCPV6_RELEASE, "release"); +} + static int send_information_req(GDHCPClient *dhcp_client) { return send_dhcpv6_msg(dhcp_client, DHCPV6_INFORMATION_REQ, @@ -2002,6 +2010,7 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition, case REQUEST: case RENEW: case REBIND: + case RELEASE: if (dhcp_client->type != G_DHCP_IPV6) return TRUE; @@ -2053,6 +2062,11 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition, dhcp_client->rebind_data); return TRUE; } + if (dhcp_client->release_cb != NULL) { + dhcp_client->release_cb(dhcp_client, + dhcp_client->release_data); + return TRUE; + } break; default: break; @@ -2196,6 +2210,16 @@ int g_dhcp_client_start(GDHCPClient *dhcp_client, const char *last_address) return re; } send_dhcpv6_rebind(dhcp_client); + + } else if (dhcp_client->release_cb) { + dhcp_client->state = RENEW; + re = switch_listening_mode(dhcp_client, L3); + if (re != 0) { + switch_listening_mode(dhcp_client, L_NONE); + dhcp_client->state = 0; + return re; + } + send_dhcpv6_release(dhcp_client); } return 0; @@ -2346,6 +2370,12 @@ void g_dhcp_client_register_event(GDHCPClient *dhcp_client, dhcp_client->rebind_cb = func; dhcp_client->rebind_data = data; return; + case G_DHCP_CLIENT_EVENT_RELEASE: + if (dhcp_client->type == G_DHCP_IPV4) + return; + dhcp_client->release_cb = func; + dhcp_client->release_data = data; + return; } } @@ -2386,6 +2416,7 @@ char *g_dhcp_client_get_netmask(GDHCPClient *dhcp_client) case REQUEST: case RENEW: case REBIND: + case RELEASE: break; } return NULL; diff --git a/gdhcp/gdhcp.h b/gdhcp/gdhcp.h index 49b06b1a..edebc9e1 100644 --- a/gdhcp/gdhcp.h +++ b/gdhcp/gdhcp.h @@ -58,6 +58,7 @@ typedef enum { G_DHCP_CLIENT_EVENT_REQUEST, G_DHCP_CLIENT_EVENT_RENEW, G_DHCP_CLIENT_EVENT_REBIND, + G_DHCP_CLIENT_EVENT_RELEASE, } GDHCPClientEvent; typedef enum { |