From fd3573b27dcecd10afaaabada6892a0e65974e44 Mon Sep 17 00:00:00 2001 From: Abhishek Sansanwal Date: Thu, 3 Aug 2017 09:27:22 +0530 Subject: Changes required for DHCP leased seconds API Change-Id: I0727c24f30be5162d27e49996dfa376348f98527 Signed-off-by: Abhishek Sansanwal --- gdhcp/client.c | 12 ++++++++++++ gdhcp/gdhcp.h | 5 +++++ src/connman.h | 5 +++++ src/dhcp.c | 9 +++++++++ src/ipconfig.c | 14 ++++++++++++++ 5 files changed, 45 insertions(+) diff --git a/gdhcp/client.c b/gdhcp/client.c index ff4539b7..d3794bde 100755 --- a/gdhcp/client.c +++ b/gdhcp/client.c @@ -178,6 +178,7 @@ struct _GDHCPClient { struct timeval start_time; bool request_bcast; #if defined TIZEN_EXT + uint32_t dhcp_lease_seconds; gboolean init_reboot; #endif }; @@ -2383,6 +2384,10 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition, dhcp_client->lease_seconds = get_lease(&packet); +#if defined TIZEN_EXT + dhcp_client->dhcp_lease_seconds = dhcp_client->lease_seconds; +#endif + get_request(dhcp_client, &packet); switch_listening_mode(dhcp_client, L_NONE); @@ -3036,6 +3041,13 @@ char *g_dhcp_client_get_server_address(GDHCPClient *dhcp_client) #endif } +#if defined TIZEN_EXT +int g_dhcp_client_get_dhcp_lease_duration(GDHCPClient *dhcp_client) +{ + return dhcp_client->dhcp_lease_seconds; +} +#endif + char *g_dhcp_client_get_address(GDHCPClient *dhcp_client) { return g_strdup(dhcp_client->assigned_ip); diff --git a/gdhcp/gdhcp.h b/gdhcp/gdhcp.h index 59b562bf..fd6ce548 100755 --- a/gdhcp/gdhcp.h +++ b/gdhcp/gdhcp.h @@ -151,6 +151,11 @@ GDHCPClientError g_dhcp_client_set_send(GDHCPClient *client, const char *option_value); char *g_dhcp_client_get_server_address(GDHCPClient *client); + +#if defined TIZEN_EXT +int g_dhcp_client_get_dhcp_lease_duration(GDHCPClient *client); +#endif + char *g_dhcp_client_get_address(GDHCPClient *client); char *g_dhcp_client_get_netmask(GDHCPClient *client); GList *g_dhcp_client_get_option(GDHCPClient *client, diff --git a/src/connman.h b/src/connman.h index 7c44d1c1..237c1ec7 100755 --- a/src/connman.h +++ b/src/connman.h @@ -367,6 +367,11 @@ const char *__connman_ipconfig_get_broadcast(struct connman_ipconfig *ipconfig); void __connman_ipconfig_set_broadcast(struct connman_ipconfig *ipconfig, const char *broadcast); const char *__connman_ipconfig_get_gateway(struct connman_ipconfig *ipconfig); void __connman_ipconfig_set_gateway(struct connman_ipconfig *ipconfig, const char *gateway); + +#if defined TIZEN_EXT +void __connman_ipconfig_set_dhcp_lease_duration(struct connman_ipconfig *ipconfig, int dhcp_lease_duration); +#endif + unsigned char __connman_ipconfig_get_prefixlen(struct connman_ipconfig *ipconfig); void __connman_ipconfig_set_prefixlen(struct connman_ipconfig *ipconfig, unsigned char prefixlen); diff --git a/src/dhcp.c b/src/dhcp.c index 7e5f71d2..b6273625 100755 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -473,6 +473,10 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data) __connman_ipconfig_set_dhcp_address(dhcp->ipconfig, address); DBG("last address %s", address); +#if defined TIZEN_EXT + int dhcp_lease_duration = g_dhcp_client_get_dhcp_lease_duration(dhcp_client); +#endif + option = g_dhcp_client_get_option(dhcp_client, G_DHCP_SUBNET); if (option) netmask = g_strdup(option->data); @@ -505,6 +509,11 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data) __connman_ipconfig_set_method(dhcp->ipconfig, CONNMAN_IPCONFIG_METHOD_DHCP); + +#if defined TIZEN_EXT + __connman_ipconfig_set_dhcp_lease_duration(dhcp->ipconfig, dhcp_lease_duration); +#endif + if (ip_change) { __connman_ipconfig_set_local(dhcp->ipconfig, address); __connman_ipconfig_set_prefixlen(dhcp->ipconfig, prefixlen); diff --git a/src/ipconfig.c b/src/ipconfig.c index 411fc450..700384fe 100755 --- a/src/ipconfig.c +++ b/src/ipconfig.c @@ -53,6 +53,10 @@ struct connman_ipconfig { struct connman_ipaddress *address; struct connman_ipaddress *system; +#if defined TIZEN_EXT + int dhcp_lease_duration; +#endif + int ipv6_privacy_config; char *last_dhcp_address; char **last_dhcpv6_prefixes; @@ -1097,6 +1101,14 @@ void __connman_ipconfig_set_gateway(struct connman_ipconfig *ipconfig, ipconfig->address->gateway = g_strdup(gateway); } +#if defined TIZEN_EXT +void __connman_ipconfig_set_dhcp_lease_duration(struct connman_ipconfig *ipconfig, + int dhcp_lease_duration) +{ + ipconfig->dhcp_lease_duration = dhcp_lease_duration; +} +#endif + #if defined TIZEN_EXT int __connman_ipconfig_gateway_add(struct connman_ipconfig *ipconfig, struct connman_service *service) #else @@ -1903,6 +1915,8 @@ void __connman_ipconfig_append_ipv4(struct connman_ipconfig *ipconfig, DBUS_TYPE_STRING, &server_ip); g_free(server_ip); } + connman_dbus_dict_append_basic(iter, "DHCPLeaseDuration", + DBUS_TYPE_INT32, &ipconfig->dhcp_lease_duration); } #endif } -- cgit v1.2.3