5 * Copyright (C) 2007-2013 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 #include <net/ethernet.h>
32 #define IPV6_MIN_MTU 1280
35 #include <connman/ipconfig.h>
36 #include <include/setting.h>
38 #include <gdhcp/gdhcp.h>
44 #define RATE_LIMIT_INTERVAL 60 /* delay between successive attempts */
47 struct connman_ipconfig *ipconfig;
48 struct connman_network *network;
58 GDHCPClient *ipv4ll_client;
59 GDHCPClient *dhcp_client;
60 char *ipv4ll_debug_prefix;
61 char *dhcp_debug_prefix;
66 static GHashTable *ipconfig_table;
68 static void dhcp_free(struct connman_dhcp *dhcp)
71 DBG("dhcp_free [%p]", dhcp);
73 g_strfreev(dhcp->nameservers);
74 g_strfreev(dhcp->timeservers);
77 dhcp->nameservers = NULL;
78 dhcp->timeservers = NULL;
87 static void ipv4ll_stop_client(struct connman_dhcp *dhcp)
90 DBG("dhcp [%p] ipv4ll_client [%p]", dhcp, dhcp->ipv4ll_client);
92 if (!dhcp->ipv4ll_client)
95 g_dhcp_client_stop(dhcp->ipv4ll_client);
96 g_dhcp_client_unref(dhcp->ipv4ll_client);
97 dhcp->ipv4ll_client = NULL;
98 dhcp->ipv4ll_running = false;
100 g_free(dhcp->ipv4ll_debug_prefix);
101 dhcp->ipv4ll_debug_prefix = NULL;
104 static bool apply_dhcp_invalidate_on_network(struct connman_dhcp *dhcp)
106 struct connman_service *service;
112 service = connman_service_lookup_from_network(dhcp->network);
114 connman_error("Can not lookup service");
118 __connman_service_set_domainname(service, NULL);
119 __connman_ipconfig_set_proxy_autoconfig(dhcp->ipconfig, NULL);
121 if (dhcp->timeservers) {
122 for (i = 0; dhcp->timeservers[i]; i++) {
123 __connman_service_timeserver_remove(service,
124 dhcp->timeservers[i]);
126 g_strfreev(dhcp->timeservers);
127 dhcp->timeservers = NULL;
129 if (dhcp->nameservers) {
130 for (i = 0; dhcp->nameservers[i]; i++) {
131 #if defined TIZEN_EXT
132 __connman_service_nameserver_remove(service,
133 dhcp->nameservers[i], false,
134 CONNMAN_IPCONFIG_TYPE_IPV4);
136 __connman_service_nameserver_remove(service,
137 dhcp->nameservers[i], false);
140 g_strfreev(dhcp->nameservers);
141 dhcp->nameservers = NULL;
148 * dhcp_invalidate: Invalidate an existing DHCP lease
149 * @dhcp: pointer to the DHCP lease to invalidate.
150 * @callback: flag indicating whether or not to invoke the client callback
153 * Invalidates an existing DHCP lease, optionally invoking the client
154 * callback. The caller may wish to avoid the client callback invocation
155 * when the invocation of that callback might otherwise unnecessarily upset
156 * service state due to the IP configuration change implied by this
159 static void dhcp_invalidate(struct connman_dhcp *dhcp, bool callback)
161 DBG("dhcp %p callback %u", dhcp, callback);
166 __connman_6to4_remove(dhcp->ipconfig);
168 if (!apply_dhcp_invalidate_on_network(dhcp))
171 __connman_ipconfig_set_dhcp_address(dhcp->ipconfig,
172 __connman_ipconfig_get_local(dhcp->ipconfig));
173 DBG("last address %s",
174 __connman_ipconfig_get_dhcp_address(dhcp->ipconfig));
176 __connman_ipconfig_address_remove(dhcp->ipconfig);
178 __connman_ipconfig_set_local(dhcp->ipconfig, NULL);
179 __connman_ipconfig_set_broadcast(dhcp->ipconfig, NULL);
180 __connman_ipconfig_set_gateway(dhcp->ipconfig, NULL);
181 __connman_ipconfig_set_prefixlen(dhcp->ipconfig, 0);
183 if (dhcp->callback && callback)
184 dhcp->callback(dhcp->ipconfig, dhcp->network,
185 false, dhcp->user_data);
188 static void dhcp_valid(struct connman_dhcp *dhcp)
191 dhcp->callback(dhcp->ipconfig, dhcp->network,
192 true, dhcp->user_data);
195 static void dhcp_debug(const char *str, void *data)
197 connman_info("%s: %s", (const char *) data, str);
200 static void ipv4ll_lost_cb(GDHCPClient *dhcp_client, gpointer user_data);
201 static void ipv4ll_available_cb(GDHCPClient *ipv4ll_client, gpointer user_data);
203 static int ipv4ll_start_client(struct connman_dhcp *dhcp)
205 GDHCPClient *ipv4ll_client;
206 GDHCPClientError error;
207 const char *hostname;
211 #if defined TIZEN_EXT
212 DBG("dhcp %p", dhcp);
215 if (dhcp->ipv4ll_client)
218 index = __connman_ipconfig_get_index(dhcp->ipconfig);
220 ipv4ll_client = g_dhcp_client_new(G_DHCP_IPV4LL, index, &error);
221 if (error != G_DHCP_CLIENT_ERROR_NONE)
224 #if !defined TIZEN_EXT
225 if (getenv("CONNMAN_DHCP_DEBUG")) {
227 dhcp->ipv4ll_debug_prefix = g_strdup_printf("IPv4LL index %d",
229 g_dhcp_client_set_debug(ipv4ll_client, dhcp_debug,
230 dhcp->ipv4ll_debug_prefix);
231 #if !defined TIZEN_EXT
235 g_dhcp_client_set_id(ipv4ll_client);
238 hostname = connman_utsname_get_hostname();
240 g_dhcp_client_set_send(ipv4ll_client,
241 G_DHCP_HOST_NAME, hostname);
244 g_dhcp_client_register_event(ipv4ll_client,
245 G_DHCP_CLIENT_EVENT_IPV4LL_LOST, ipv4ll_lost_cb, dhcp);
247 g_dhcp_client_register_event(ipv4ll_client,
248 G_DHCP_CLIENT_EVENT_IPV4LL_AVAILABLE,
249 ipv4ll_available_cb, dhcp);
251 dhcp->ipv4ll_client = ipv4ll_client;
253 err = g_dhcp_client_start(dhcp->ipv4ll_client, NULL);
255 ipv4ll_stop_client(dhcp);
259 dhcp->ipv4ll_running = true;
263 static gboolean dhcp_retry_cb(gpointer user_data)
265 struct connman_dhcp *dhcp = user_data;
269 #if defined TIZEN_EXT
270 DBG("dhcp %p", dhcp);
271 DBG("dhcp->timeout %d", dhcp->timeout);
273 g_dhcp_client_start(dhcp->dhcp_client,
274 __connman_ipconfig_get_dhcp_address(dhcp->ipconfig));
279 static void no_lease_cb(GDHCPClient *dhcp_client, gpointer user_data)
281 struct connman_dhcp *dhcp = user_data;
284 DBG("No lease available ipv4ll %d client %p", dhcp->ipv4ll_running,
285 dhcp->ipv4ll_client);
287 #if defined TIZEN_EXT
289 connman_network_get_bool(dhcp->network, "WiFi.RoamingDHCP")) {
290 connman_network_set_bool(dhcp->network, "WiFi.RoamingDHCP", false);
291 __connman_network_enable_ipconfig(dhcp->network, dhcp->ipconfig);
296 if (connman_setting_get_bool("EnableAutoIp") == false) {
297 DBG("link-local address autoconfiguration is disabled.");
299 __connman_network_disconnect(dhcp->network);
303 if (dhcp->timeout > 0)
304 g_source_remove(dhcp->timeout);
306 dhcp->timeout = g_timeout_add_seconds(RATE_LIMIT_INTERVAL,
309 if (dhcp->ipv4ll_running)
312 err = ipv4ll_start_client(dhcp);
314 DBG("Cannot start ipv4ll client (%d/%s)", err, strerror(-err));
316 /* Only notify upper layer if we have a problem */
317 dhcp_invalidate(dhcp, !dhcp->ipv4ll_running);
320 static void lease_lost_cb(GDHCPClient *dhcp_client, gpointer user_data)
322 struct connman_dhcp *dhcp = user_data;
326 /* Upper layer will decide what to do, e.g. nothing or retry. */
327 dhcp_invalidate(dhcp, true);
330 static void ipv4ll_lost_cb(GDHCPClient *dhcp_client, gpointer user_data)
332 struct connman_dhcp *dhcp = user_data;
336 ipv4ll_stop_client(dhcp);
339 * Since we lost our IPv4LL configuration we might as notify
342 dhcp_invalidate(dhcp, true);
345 static bool compare_string_arrays(char **array_a, char **array_b)
349 if (!array_a || !array_b)
352 if (g_strv_length(array_a) != g_strv_length(array_b))
355 for (i = 0; array_a[i] &&
357 if (g_strcmp0(array_a[i], array_b[i]) != 0)
364 static bool apply_lease_available_on_network(GDHCPClient *dhcp_client,
365 struct connman_dhcp *dhcp)
367 char **nameservers, **timeservers, *pac = NULL;
368 struct connman_service *service;
369 GList *list, *option = NULL;
376 service = connman_service_lookup_from_network(dhcp->network);
378 connman_error("Can not lookup service");
382 option = g_dhcp_client_get_option(dhcp_client, G_DHCP_MTU);
383 if (option && option->data) {
386 mtu = atoi(option->data);
388 if (mtu >= IPV6_MIN_MTU && mtu <= ETH_DATA_LEN) {
389 index = __connman_ipconfig_get_index(dhcp->ipconfig);
390 err = connman_inet_set_mtu(index, mtu);
392 DBG("MTU %d index %d err %d", mtu, index, err);
396 option = g_dhcp_client_get_option(dhcp_client, 252);
398 pac = g_strdup(option->data);
400 option = g_dhcp_client_get_option(dhcp_client, G_DHCP_DNS_SERVER);
401 ns_entries = g_list_length(option);
402 nameservers = g_try_new0(char *, ns_entries + 1);
404 for (i = 0, list = option;list; list = list->next, i++)
405 nameservers[i] = g_strdup(list->data);
406 nameservers[ns_entries] = NULL;
409 option = g_dhcp_client_get_option(dhcp_client, G_DHCP_DOMAIN_NAME);
411 __connman_service_set_domainname(service, option->data);
413 option = g_dhcp_client_get_option(dhcp_client, G_DHCP_HOST_NAME);
415 __connman_service_set_hostname(service, option->data);
417 option = g_dhcp_client_get_option(dhcp_client, G_DHCP_NTP_SERVER);
418 ns_entries = g_list_length(option);
419 timeservers = g_try_new0(char *, ns_entries + 1);
421 for (i = 0, list = option; list; list = list->next, i++)
422 timeservers[i] = g_strdup(list->data);
423 timeservers[ns_entries] = NULL;
426 if (!compare_string_arrays(nameservers, dhcp->nameservers)) {
427 if (dhcp->nameservers) {
428 #if defined TIZEN_EXT
429 for (i = 0; dhcp->nameservers[i] != NULL; i++) {
430 __connman_service_nameserver_remove(service,
431 dhcp->nameservers[i], false,
432 CONNMAN_IPCONFIG_TYPE_IPV4);
435 for (i = 0; dhcp->nameservers[i]; i++) {
436 __connman_service_nameserver_remove(service,
437 dhcp->nameservers[i], false);
440 g_strfreev(dhcp->nameservers);
443 dhcp->nameservers = nameservers;
445 for (i = 0; dhcp->nameservers && dhcp->nameservers[i]; i++) {
446 #if defined TIZEN_EXT
447 __connman_service_nameserver_append(service,
448 dhcp->nameservers[i], false,
449 CONNMAN_IPCONFIG_TYPE_IPV4);
451 __connman_service_nameserver_append(service,
452 dhcp->nameservers[i], false);
456 g_strfreev(nameservers);
459 if (!compare_string_arrays(timeservers, dhcp->timeservers)) {
460 if (dhcp->timeservers) {
461 for (i = 0; dhcp->timeservers[i]; i++) {
462 __connman_service_timeserver_remove(service,
463 dhcp->timeservers[i]);
465 g_strfreev(dhcp->timeservers);
468 dhcp->timeservers = timeservers;
470 for (i = 0; dhcp->timeservers && dhcp->timeservers[i]; i++) {
471 __connman_service_timeserver_append(service,
472 dhcp->timeservers[i]);
475 g_strfreev(timeservers);
478 if (g_strcmp0(pac, dhcp->pac) != 0) {
482 __connman_ipconfig_set_proxy_autoconfig(dhcp->ipconfig,
486 if (connman_setting_get_bool("Enable6to4"))
487 __connman_6to4_probe(service);
492 static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data)
494 struct connman_dhcp *dhcp = user_data;
495 GList *option = NULL;
496 enum connman_ipconfig_method old_method;
497 char *address, *netmask = NULL, *gateway = NULL;
498 const char *c_address, *c_gateway;
499 unsigned char prefixlen, c_prefixlen;
500 bool ip_change = false;
502 DBG("Lease available");
504 if (dhcp->ipv4ll_client) {
505 ipv4ll_stop_client(dhcp);
506 dhcp_invalidate(dhcp, false);
509 c_address = __connman_ipconfig_get_local(dhcp->ipconfig);
510 c_gateway = __connman_ipconfig_get_gateway(dhcp->ipconfig);
511 c_prefixlen = __connman_ipconfig_get_prefixlen(dhcp->ipconfig);
513 address = g_dhcp_client_get_address(dhcp_client);
515 __connman_ipconfig_set_dhcp_address(dhcp->ipconfig, address);
516 DBG("last address %s", address);
518 #if defined TIZEN_EXT
519 int dhcp_lease_duration = g_dhcp_client_get_dhcp_lease_duration(dhcp_client);
522 option = g_dhcp_client_get_option(dhcp_client, G_DHCP_SUBNET);
524 netmask = g_strdup(option->data);
526 option = g_dhcp_client_get_option(dhcp_client, G_DHCP_ROUTER);
528 gateway = g_strdup(option->data);
530 prefixlen = connman_ipaddress_calc_netmask_len(netmask);
531 if (prefixlen == 255)
532 connman_warn("netmask: %s is invalid", netmask);
534 DBG("c_address %s", c_address);
536 if (g_strcmp0(address, c_address)) {
539 /* Remove old ip address */
540 __connman_ipconfig_address_remove(dhcp->ipconfig);
543 if (g_strcmp0(gateway, c_gateway)) {
546 /* Remove gateway ip address */
547 __connman_ipconfig_gateway_remove(dhcp->ipconfig);
549 } else if (prefixlen != c_prefixlen)
552 old_method = __connman_ipconfig_get_method(dhcp->ipconfig);
553 __connman_ipconfig_set_method(dhcp->ipconfig,
554 CONNMAN_IPCONFIG_METHOD_DHCP);
556 #if defined TIZEN_EXT
557 __connman_ipconfig_set_dhcp_lease_duration(dhcp->ipconfig, dhcp_lease_duration);
561 * Notify IPv4.Configuration's method moved back to DHCP.
563 * This is the case ConnMan initially set an address by using
564 * IPv4LL because DHCP failed but now we got an address from DHCP.
566 if (old_method == CONNMAN_IPCONFIG_METHOD_AUTO) {
567 struct connman_service *service =
568 connman_service_lookup_from_network(dhcp->network);
571 __connman_service_notify_ipv4_configuration(service);
574 #if defined TIZEN_EXT
575 if (connman_network_get_bool(dhcp->network, "WiFi.RoamingDHCP")) {
578 connman_service_notify_reconnection(
579 connman_service_lookup_from_network(dhcp->network));
581 connman_network_set_bool(dhcp->network, "WiFi.RoamingDHCP", false);
586 __connman_ipconfig_set_local(dhcp->ipconfig, address);
587 __connman_ipconfig_set_prefixlen(dhcp->ipconfig, prefixlen);
588 __connman_ipconfig_set_gateway(dhcp->ipconfig, gateway);
591 if (!apply_lease_available_on_network(dhcp_client, dhcp))
603 static void ipv4ll_available_cb(GDHCPClient *ipv4ll_client, gpointer user_data)
605 struct connman_dhcp *dhcp = user_data;
606 enum connman_ipconfig_method old_method;
607 char *address, *netmask;
608 unsigned char prefixlen;
610 DBG("IPV4LL available");
612 address = g_dhcp_client_get_address(ipv4ll_client);
613 netmask = g_dhcp_client_get_netmask(ipv4ll_client);
615 prefixlen = connman_ipaddress_calc_netmask_len(netmask);
617 old_method = __connman_ipconfig_get_method(dhcp->ipconfig);
618 __connman_ipconfig_set_method(dhcp->ipconfig,
619 CONNMAN_IPCONFIG_METHOD_AUTO);
622 * Notify IPv4.Configuration's method is AUTO now.
624 * This is the case DHCP failed thus ConnMan used IPv4LL to get an
625 * address. Set IPv4.Configuration method to AUTO allows user to
626 * ask for a DHCP address by setting the method again to DHCP.
628 if (old_method == CONNMAN_IPCONFIG_METHOD_DHCP) {
629 struct connman_service *service =
630 connman_service_lookup_from_network(dhcp->network);
633 __connman_service_notify_ipv4_configuration(service);
636 __connman_ipconfig_set_local(dhcp->ipconfig, address);
637 __connman_ipconfig_set_prefixlen(dhcp->ipconfig, prefixlen);
638 __connman_ipconfig_set_gateway(dhcp->ipconfig, NULL);
646 static int dhcp_initialize(struct connman_dhcp *dhcp)
648 GDHCPClient *dhcp_client;
649 GDHCPClientError error;
651 const char *vendor_class_id;
653 DBG("dhcp %p", dhcp);
655 index = __connman_ipconfig_get_index(dhcp->ipconfig);
657 dhcp_client = g_dhcp_client_new(G_DHCP_IPV4, index, &error);
658 if (error != G_DHCP_CLIENT_ERROR_NONE)
659 #if defined TIZEN_EXT
661 DBG("failed g_dhcp_client_new(%d), index(%d)", error, index);
664 #if defined TIZEN_EXT
668 #if !defined TIZEN_EXT
669 if (getenv("CONNMAN_DHCP_DEBUG")) {
671 dhcp->dhcp_debug_prefix = g_strdup_printf("DHCP index %d",
673 g_dhcp_client_set_debug(dhcp_client, dhcp_debug,
674 dhcp->dhcp_debug_prefix);
675 #if !defined TIZEN_EXT
679 g_dhcp_client_set_id(dhcp_client);
682 struct connman_service *service;
683 const char *hostname;
685 service = connman_service_lookup_from_network(dhcp->network);
687 hostname = __connman_service_get_hostname(service);
689 hostname = connman_utsname_get_hostname();
692 g_dhcp_client_set_send(dhcp_client,
693 G_DHCP_HOST_NAME, hostname);
695 g_dhcp_client_set_request(dhcp_client, G_DHCP_HOST_NAME);
696 g_dhcp_client_set_request(dhcp_client, G_DHCP_DNS_SERVER);
697 g_dhcp_client_set_request(dhcp_client, G_DHCP_DOMAIN_NAME);
698 g_dhcp_client_set_request(dhcp_client, G_DHCP_NTP_SERVER);
699 g_dhcp_client_set_request(dhcp_client, 252);
700 g_dhcp_client_set_request(dhcp_client, G_DHCP_MTU);
703 g_dhcp_client_set_request(dhcp_client, G_DHCP_ROUTER);
704 g_dhcp_client_set_request(dhcp_client, G_DHCP_SUBNET);
706 vendor_class_id = connman_setting_get_string("VendorClassID");
708 g_dhcp_client_set_send(dhcp_client, G_DHCP_VENDOR_CLASS_ID,
711 g_dhcp_client_register_event(dhcp_client,
712 G_DHCP_CLIENT_EVENT_LEASE_AVAILABLE,
713 lease_available_cb, dhcp);
715 g_dhcp_client_register_event(dhcp_client,
716 G_DHCP_CLIENT_EVENT_LEASE_LOST, lease_lost_cb, dhcp);
718 g_dhcp_client_register_event(dhcp_client,
719 G_DHCP_CLIENT_EVENT_NO_LEASE, no_lease_cb, dhcp);
721 dhcp->dhcp_client = dhcp_client;
726 static int dhcp_release(struct connman_dhcp *dhcp)
728 DBG("dhcp %p", dhcp);
730 if (dhcp->timeout > 0) {
731 g_source_remove(dhcp->timeout);
735 if (dhcp->dhcp_client) {
736 g_dhcp_client_stop(dhcp->dhcp_client);
737 g_dhcp_client_unref(dhcp->dhcp_client);
740 dhcp->dhcp_client = NULL;
742 g_free(dhcp->dhcp_debug_prefix);
743 dhcp->dhcp_debug_prefix = NULL;
745 ipv4ll_stop_client(dhcp);
750 char *__connman_dhcp_get_server_address(struct connman_ipconfig *ipconfig)
752 struct connman_dhcp *dhcp;
754 dhcp = g_hash_table_lookup(ipconfig_table, ipconfig);
758 return g_dhcp_client_get_server_address(dhcp->dhcp_client);
761 #if defined TIZEN_EXT_WIFI_MESH
762 int __connman_mesh_dhcp_start(struct connman_ipconfig *ipconfig,
763 dhcp_cb callback, gpointer user_data)
765 struct connman_dhcp *dhcp;
770 dhcp = g_hash_table_lookup(ipconfig_table, ipconfig);
773 dhcp = g_try_new0(struct connman_dhcp, 1);
777 dhcp->ipconfig = ipconfig;
778 __connman_ipconfig_ref(ipconfig);
780 err = dhcp_initialize(dhcp);
787 g_hash_table_insert(ipconfig_table, ipconfig, dhcp);
790 dhcp->callback = callback;
791 dhcp->user_data = user_data;
792 return g_dhcp_client_start(dhcp->dhcp_client, NULL);
796 int __connman_dhcp_start(struct connman_ipconfig *ipconfig,
797 struct connman_network *network, dhcp_cb callback,
800 #if !defined TIZEN_EXT
801 const char *last_addr = NULL;
803 struct connman_dhcp *dhcp;
809 struct connman_service *service;
811 service = connman_service_lookup_from_network(network);
816 #if !defined TIZEN_EXT
817 last_addr = __connman_ipconfig_get_dhcp_address(ipconfig);
820 dhcp = g_hash_table_lookup(ipconfig_table, ipconfig);
823 dhcp = g_try_new0(struct connman_dhcp, 1);
827 dhcp->ipconfig = ipconfig;
828 __connman_ipconfig_ref(ipconfig);
831 dhcp->network = network;
832 connman_network_ref(network);
835 err = dhcp_initialize(dhcp);
839 connman_network_unref(network);
844 g_hash_table_insert(ipconfig_table, ipconfig, dhcp);
847 dhcp->callback = callback;
848 dhcp->user_data = user_data;
850 #if defined TIZEN_EXT
851 if (connman_network_get_bool(network, "WiFi.RoamingDHCP")) {
852 const char *last_addr = __connman_ipconfig_get_dhcp_address(ipconfig);
854 DBG("Start DHCP with last address request");
855 return g_dhcp_client_start(dhcp->dhcp_client, last_addr);
857 DBG("Start DHCP with DHCPDISCOVER request");
858 return g_dhcp_client_start(dhcp->dhcp_client, NULL);
861 return g_dhcp_client_start(dhcp->dhcp_client, last_addr);
865 void __connman_dhcp_stop(struct connman_ipconfig *ipconfig)
867 struct connman_dhcp *dhcp;
869 DBG("ipconfig_table %p ipconfig %p", ipconfig_table, ipconfig);
874 dhcp = g_hash_table_lookup(ipconfig_table, ipconfig);
876 g_hash_table_remove(ipconfig_table, ipconfig);
877 __connman_ipconfig_unref(ipconfig);
879 connman_network_unref(dhcp->network);
881 dhcp_invalidate(dhcp, false);
886 void __connman_dhcp_decline(struct connman_ipconfig *ipconfig)
888 struct connman_dhcp *dhcp;
892 DBG("ipconfig_table %p ipconfig %p", ipconfig_table, ipconfig);
897 dhcp = g_hash_table_lookup(ipconfig_table, ipconfig);
899 address = __connman_ipconfig_get_local(ipconfig);
903 if (inet_pton(AF_INET, address, &addr) != 1)
904 connman_error("Could not convert address %s", address);
906 g_dhcp_client_decline(dhcp->dhcp_client, htonl(addr.s_addr));
910 int __connman_dhcp_init(void)
914 ipconfig_table = g_hash_table_new_full(g_direct_hash, g_direct_equal,
920 void __connman_dhcp_cleanup(void)
924 g_hash_table_destroy(ipconfig_table);
925 ipconfig_table = NULL;