From: Julien Massot Date: Mon, 20 Dec 2010 16:24:01 +0000 (+0000) Subject: gdhcp: Add netmask getter X-Git-Tag: 2.0_alpha~1976 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7b4007c167f35e6a6b4e58ffd1aec83dae0b18a;p=framework%2Fconnectivity%2Fconnman.git gdhcp: Add netmask getter --- diff --git a/gdhcp/client.c b/gdhcp/client.c index 3508b1e..107077a 100644 --- a/gdhcp/client.c +++ b/gdhcp/client.c @@ -1413,6 +1413,30 @@ char *g_dhcp_client_get_address(GDHCPClient *dhcp_client) return g_strdup(dhcp_client->assigned_ip); } +char *g_dhcp_client_get_netmask(GDHCPClient *dhcp_client) +{ + GList *option = NULL; + + switch (dhcp_client->state) { + case IPV4LL_DEFEND: + case IPV4LL_MONITOR: + return g_strdup("255.255.0.0"); + case BOUND: + case RENEWING: + case REBINDING: + option = g_dhcp_client_get_option(dhcp_client, G_DHCP_SUBNET); + if (option != NULL) + return g_strdup(option->data); + case INIT_SELECTING: + case REQUESTING: + case RELEASED: + case IPV4LL_PROBE: + case IPV4LL_ANNOUNCE: + break; + } + return NULL; +} + GDHCPClientError g_dhcp_client_set_request(GDHCPClient *dhcp_client, unsigned char option_code) { diff --git a/gdhcp/gdhcp.h b/gdhcp/gdhcp.h index 63c395d..4f583ff 100644 --- a/gdhcp/gdhcp.h +++ b/gdhcp/gdhcp.h @@ -91,6 +91,7 @@ GDHCPClientError g_dhcp_client_set_send(GDHCPClient *client, const char *option_value); char *g_dhcp_client_get_address(GDHCPClient *client); +char *g_dhcp_client_get_netmask(GDHCPClient *client); GList *g_dhcp_client_get_option(GDHCPClient *client, unsigned char option_code); int g_dhcp_client_get_index(GDHCPClient *client);