[SPIN] Added the connman disconnect reason property.
[platform/upstream/connman.git] / src / dhcp.c
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2013  Intel Corporation. All rights reserved.
6  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25 #include <stdio.h>
26 #include <errno.h>
27 #include <string.h>
28 #include <stdlib.h>
29
30 #include <connman/ipconfig.h>
31 #include <include/setting.h>
32
33 #include <gdhcp/gdhcp.h>
34
35 #include <glib.h>
36
37 #include "connman.h"
38
39 #define RATE_LIMIT_INTERVAL     60      /* delay between successive attempts */
40
41 struct connman_dhcp {
42         struct connman_ipconfig *ipconfig;
43         struct connman_network *network;
44         dhcp_cb callback;
45         gpointer user_data;
46
47         char **nameservers;
48         char **timeservers;
49         char *pac;
50
51         unsigned int timeout;
52
53         GDHCPClient *ipv4ll_client;
54         GDHCPClient *dhcp_client;
55         char *ipv4ll_debug_prefix;
56         char *dhcp_debug_prefix;
57 };
58
59 static GHashTable *ipconfig_table;
60 static bool ipv4ll_running;
61
62 static void dhcp_free(struct connman_dhcp *dhcp)
63 {
64         g_strfreev(dhcp->nameservers);
65         g_strfreev(dhcp->timeservers);
66         g_free(dhcp->pac);
67
68         dhcp->nameservers = NULL;
69         dhcp->timeservers = NULL;
70         dhcp->pac = NULL;
71
72         g_free(dhcp);
73 }
74
75 static void ipv4ll_stop_client(struct connman_dhcp *dhcp)
76 {
77         if (!dhcp->ipv4ll_client)
78                 return;
79
80         g_dhcp_client_stop(dhcp->ipv4ll_client);
81         g_dhcp_client_unref(dhcp->ipv4ll_client);
82         dhcp->ipv4ll_client = NULL;
83         ipv4ll_running = false;
84
85         g_free(dhcp->ipv4ll_debug_prefix);
86         dhcp->ipv4ll_debug_prefix = NULL;
87 }
88
89 static bool apply_dhcp_invalidate_on_network(struct connman_dhcp *dhcp)
90 {
91         struct connman_service *service;
92         int i;
93
94         if (!dhcp->network)
95                 return true;
96
97         service = connman_service_lookup_from_network(dhcp->network);
98         if (!service) {
99                 connman_error("Can not lookup service");
100                 return false;
101         }
102
103         __connman_service_set_domainname(service, NULL);
104         __connman_ipconfig_set_proxy_autoconfig(dhcp->ipconfig, NULL);
105
106         if (dhcp->timeservers) {
107                 for (i = 0; dhcp->timeservers[i]; i++) {
108                         __connman_service_timeserver_remove(service,
109                                                         dhcp->timeservers[i]);
110                 }
111         }
112         if (dhcp->nameservers) {
113                 for (i = 0; dhcp->nameservers[i]; i++) {
114                         __connman_service_nameserver_remove(service,
115                                                 dhcp->nameservers[i], false);
116                 }
117         }
118
119         return true;
120 }
121
122 /**
123  * dhcp_invalidate: Invalidate an existing DHCP lease
124  * @dhcp: pointer to the DHCP lease to invalidate.
125  * @callback: flag indicating whether or not to invoke the client callback
126  *            if present.
127  *
128  * Invalidates an existing DHCP lease, optionally invoking the client
129  * callback. The caller may wish to avoid the client callback invocation
130  * when the invocation of that callback might otherwise unnecessarily upset
131  * service state due to the IP configuration change implied by this
132  * invalidation.
133  */
134 static void dhcp_invalidate(struct connman_dhcp *dhcp, bool callback)
135 {
136         DBG("dhcp %p callback %u", dhcp, callback);
137
138         if (!dhcp)
139                 return;
140
141         __connman_6to4_remove(dhcp->ipconfig);
142
143         if (!apply_dhcp_invalidate_on_network(dhcp))
144                 return;
145
146         __connman_ipconfig_set_dhcp_address(dhcp->ipconfig,
147                                 __connman_ipconfig_get_local(dhcp->ipconfig));
148         DBG("last address %s",
149                         __connman_ipconfig_get_dhcp_address(dhcp->ipconfig));
150
151         __connman_ipconfig_address_remove(dhcp->ipconfig);
152
153         __connman_ipconfig_set_local(dhcp->ipconfig, NULL);
154         __connman_ipconfig_set_broadcast(dhcp->ipconfig, NULL);
155         __connman_ipconfig_set_gateway(dhcp->ipconfig, NULL);
156         __connman_ipconfig_set_prefixlen(dhcp->ipconfig, 0);
157
158         if (dhcp->callback && callback)
159                 dhcp->callback(dhcp->ipconfig, dhcp->network,
160                                                 false, dhcp->user_data);
161 }
162
163 static void dhcp_valid(struct connman_dhcp *dhcp)
164 {
165         if (dhcp->callback)
166                 dhcp->callback(dhcp->ipconfig, dhcp->network,
167                                                 true, dhcp->user_data);
168 }
169
170 static void dhcp_debug(const char *str, void *data)
171 {
172         connman_info("%s: %s", (const char *) data, str);
173 }
174
175 static void ipv4ll_lost_cb(GDHCPClient *dhcp_client, gpointer user_data);
176 static void ipv4ll_available_cb(GDHCPClient *ipv4ll_client, gpointer user_data);
177
178 static int ipv4ll_start_client(struct connman_dhcp *dhcp)
179 {
180         GDHCPClient *ipv4ll_client;
181         GDHCPClientError error;
182         const char *hostname;
183         int index;
184         int err;
185
186         if (dhcp->ipv4ll_client)
187                 return -EALREADY;
188
189         index = __connman_ipconfig_get_index(dhcp->ipconfig);
190
191         ipv4ll_client = g_dhcp_client_new(G_DHCP_IPV4LL, index, &error);
192         if (error != G_DHCP_CLIENT_ERROR_NONE)
193                 return -EINVAL;
194
195 #if !defined TIZEN_EXT
196         if (getenv("CONNMAN_DHCP_DEBUG")) {
197 #endif
198                 dhcp->ipv4ll_debug_prefix = g_strdup_printf("IPv4LL index %d",
199                                                         index);
200                 g_dhcp_client_set_debug(ipv4ll_client, dhcp_debug,
201                                         dhcp->ipv4ll_debug_prefix);
202 #if !defined TIZEN_EXT
203         }
204 #endif
205
206         g_dhcp_client_set_id(ipv4ll_client);
207
208         if (dhcp->network) {
209                 hostname = connman_utsname_get_hostname();
210                 if (hostname)
211                         g_dhcp_client_set_send(ipv4ll_client,
212                                                 G_DHCP_HOST_NAME, hostname);
213         }
214
215         g_dhcp_client_register_event(ipv4ll_client,
216                         G_DHCP_CLIENT_EVENT_IPV4LL_LOST, ipv4ll_lost_cb, dhcp);
217
218         g_dhcp_client_register_event(ipv4ll_client,
219                         G_DHCP_CLIENT_EVENT_IPV4LL_AVAILABLE,
220                                                 ipv4ll_available_cb, dhcp);
221
222         dhcp->ipv4ll_client = ipv4ll_client;
223
224         err = g_dhcp_client_start(dhcp->ipv4ll_client, NULL);
225         if (err < 0) {
226                 ipv4ll_stop_client(dhcp);
227                 return err;
228         }
229
230         ipv4ll_running = true;
231         return 0;
232 }
233
234 static gboolean dhcp_retry_cb(gpointer user_data)
235 {
236         struct connman_dhcp *dhcp = user_data;
237
238         dhcp->timeout = 0;
239
240         g_dhcp_client_start(dhcp->dhcp_client,
241                         __connman_ipconfig_get_dhcp_address(dhcp->ipconfig));
242
243         return FALSE;
244 }
245
246 static void no_lease_cb(GDHCPClient *dhcp_client, gpointer user_data)
247 {
248         struct connman_dhcp *dhcp = user_data;
249         int err;
250
251         DBG("No lease available ipv4ll %d client %p", ipv4ll_running,
252                 dhcp->ipv4ll_client);
253
254         dhcp->timeout = g_timeout_add_seconds(RATE_LIMIT_INTERVAL,
255                                                 dhcp_retry_cb,
256                                                 dhcp);
257         if (ipv4ll_running)
258                 return;
259
260         err = ipv4ll_start_client(dhcp);
261         if (err < 0)
262                 DBG("Cannot start ipv4ll client (%d/%s)", err, strerror(-err));
263
264         /* Only notify upper layer if we have a problem */
265         dhcp_invalidate(dhcp, !ipv4ll_running);
266 }
267
268 static void lease_lost_cb(GDHCPClient *dhcp_client, gpointer user_data)
269 {
270         struct connman_dhcp *dhcp = user_data;
271
272         DBG("Lease lost");
273
274         /* Upper layer will decide what to do, e.g. nothing or retry. */
275         dhcp_invalidate(dhcp, true);
276 }
277
278 static void ipv4ll_lost_cb(GDHCPClient *dhcp_client, gpointer user_data)
279 {
280         struct connman_dhcp *dhcp = user_data;
281
282         DBG("Lease lost");
283
284         ipv4ll_stop_client(dhcp);
285
286         /*
287          * Since we lost our IPv4LL configuration we might as notify
288          * the upper layers.
289          */
290         dhcp_invalidate(dhcp, true);
291 }
292
293 static bool compare_string_arrays(char **array_a, char **array_b)
294 {
295         int i;
296
297         if (!array_a || !array_b)
298                 return false;
299
300         if (g_strv_length(array_a) != g_strv_length(array_b))
301                 return false;
302
303         for (i = 0; array_a[i] &&
304                              array_b[i]; i++) {
305                 if (g_strcmp0(array_a[i], array_b[i]) != 0)
306                         return false;
307         }
308
309         return true;
310 }
311
312 static bool apply_lease_available_on_network(GDHCPClient *dhcp_client,
313                                                 struct connman_dhcp *dhcp)
314 {
315         char **nameservers, **timeservers, *pac = NULL;
316         struct connman_service *service;
317         GList *list, *option = NULL;
318         int ns_entries;
319         int i;
320
321         if (!dhcp->network)
322                 return true;
323
324         service = connman_service_lookup_from_network(dhcp->network);
325         if (!service) {
326                 connman_error("Can not lookup service");
327                 return false;
328         }
329
330         option = g_dhcp_client_get_option(dhcp_client, 252);
331         if (option)
332                 pac = g_strdup(option->data);
333
334         option = g_dhcp_client_get_option(dhcp_client, G_DHCP_DNS_SERVER);
335         ns_entries = g_list_length(option);
336         nameservers = g_try_new0(char *, ns_entries + 1);
337         if (nameservers) {
338                 for (i = 0, list = option;list; list = list->next, i++)
339                         nameservers[i] = g_strdup(list->data);
340                 nameservers[ns_entries] = NULL;
341         }
342
343         option = g_dhcp_client_get_option(dhcp_client, G_DHCP_DOMAIN_NAME);
344         if (option)
345                 __connman_service_set_domainname(service, option->data);
346
347         option = g_dhcp_client_get_option(dhcp_client, G_DHCP_HOST_NAME);
348         if (option)
349                 __connman_service_set_hostname(service, option->data);
350
351         option = g_dhcp_client_get_option(dhcp_client, G_DHCP_NTP_SERVER);
352         ns_entries = g_list_length(option);
353         timeservers = g_try_new0(char *, ns_entries + 1);
354         if (timeservers) {
355                 for (i = 0, list = option; list; list = list->next, i++)
356                         timeservers[i] = g_strdup(list->data);
357                 timeservers[ns_entries] = NULL;
358         }
359
360         if (!compare_string_arrays(nameservers, dhcp->nameservers)) {
361                 if (dhcp->nameservers) {
362                         for (i = 0; dhcp->nameservers[i]; i++) {
363                                 __connman_service_nameserver_remove(service,
364                                                 dhcp->nameservers[i], false);
365                         }
366                         g_strfreev(dhcp->nameservers);
367                 }
368
369                 dhcp->nameservers = nameservers;
370
371                 for (i = 0; dhcp->nameservers && dhcp->nameservers[i]; i++) {
372                         __connman_service_nameserver_append(service,
373                                                 dhcp->nameservers[i], false);
374                 }
375         } else {
376                 g_strfreev(nameservers);
377         }
378
379         if (!compare_string_arrays(timeservers, dhcp->timeservers)) {
380                 if (dhcp->timeservers) {
381                         for (i = 0; dhcp->timeservers[i]; i++) {
382                                 __connman_service_timeserver_remove(service,
383                                                         dhcp->timeservers[i]);
384                         }
385                         g_strfreev(dhcp->timeservers);
386                 }
387
388                 dhcp->timeservers = timeservers;
389
390                 for (i = 0; dhcp->timeservers && dhcp->timeservers[i]; i++) {
391                         __connman_service_timeserver_append(service,
392                                                         dhcp->timeservers[i]);
393                 }
394         } else {
395                 g_strfreev(timeservers);
396         }
397
398         if (g_strcmp0(pac, dhcp->pac) != 0) {
399                 g_free(dhcp->pac);
400                 dhcp->pac = pac;
401
402                 __connman_ipconfig_set_proxy_autoconfig(dhcp->ipconfig,
403                                                                 dhcp->pac);
404         }
405
406         if (connman_setting_get_bool("Enable6to4"))
407                 __connman_6to4_probe(service);
408
409         return true;
410 }
411
412 static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data)
413 {
414         struct connman_dhcp *dhcp = user_data;
415         GList *option = NULL;
416         char *address, *netmask = NULL, *gateway = NULL;
417         const char *c_address, *c_gateway;
418         unsigned char prefixlen, c_prefixlen;
419         bool ip_change;
420
421         DBG("Lease available");
422
423         if (dhcp->ipv4ll_client) {
424                 ipv4ll_stop_client(dhcp);
425                 dhcp_invalidate(dhcp, false);
426         }
427
428         c_address = __connman_ipconfig_get_local(dhcp->ipconfig);
429         c_gateway = __connman_ipconfig_get_gateway(dhcp->ipconfig);
430         c_prefixlen = __connman_ipconfig_get_prefixlen(dhcp->ipconfig);
431
432         address = g_dhcp_client_get_address(dhcp_client);
433
434         __connman_ipconfig_set_dhcp_address(dhcp->ipconfig, address);
435         DBG("last address %s", address);
436
437         option = g_dhcp_client_get_option(dhcp_client, G_DHCP_SUBNET);
438         if (option)
439                 netmask = g_strdup(option->data);
440
441         option = g_dhcp_client_get_option(dhcp_client, G_DHCP_ROUTER);
442         if (option)
443                 gateway = g_strdup(option->data);
444
445         prefixlen = connman_ipaddress_calc_netmask_len(netmask);
446         if (prefixlen == 255)
447                 connman_warn("netmask: %s is invalid", netmask);
448
449         DBG("c_address %s", c_address);
450
451         if (g_strcmp0(address, c_address))
452                 ip_change = true;
453         else if (g_strcmp0(gateway, c_gateway))
454                 ip_change = true;
455         else if (prefixlen != c_prefixlen)
456                 ip_change = true;
457         else
458                 ip_change = false;
459
460         __connman_ipconfig_set_method(dhcp->ipconfig,
461                                                 CONNMAN_IPCONFIG_METHOD_DHCP);
462         if (ip_change) {
463                 __connman_ipconfig_set_local(dhcp->ipconfig, address);
464                 __connman_ipconfig_set_prefixlen(dhcp->ipconfig, prefixlen);
465                 __connman_ipconfig_set_gateway(dhcp->ipconfig, gateway);
466         }
467
468         if (!apply_lease_available_on_network(dhcp_client, dhcp))
469                 goto done;
470
471         if (ip_change)
472                 dhcp_valid(dhcp);
473
474 done:
475         g_free(address);
476         g_free(netmask);
477         g_free(gateway);
478 }
479
480 static void ipv4ll_available_cb(GDHCPClient *ipv4ll_client, gpointer user_data)
481 {
482         struct connman_dhcp *dhcp = user_data;
483 #if !defined TIZEN_EXT
484                 char *address, *netmask;
485                 unsigned char prefixlen;
486 #endif
487
488         DBG("IPV4LL available");
489
490 #if defined TIZEN_EXT
491                 /*
492                  * Description: When DHCP is failed,
493                  *               most of normal users cannot understand auto-generated IP
494                  *              (IPV4 link local) and serious troubles to make Internet connection.
495                  */
496                 dhcp_invalidate(dhcp, true);
497
498                 connman_network_set_error(dhcp->network,
499                                         CONNMAN_NETWORK_ERROR_DHCP_FAIL);
500 #else
501         address = g_dhcp_client_get_address(ipv4ll_client);
502         netmask = g_dhcp_client_get_netmask(ipv4ll_client);
503
504         prefixlen = connman_ipaddress_calc_netmask_len(netmask);
505
506         __connman_ipconfig_set_method(dhcp->ipconfig,
507                                                 CONNMAN_IPCONFIG_METHOD_DHCP);
508         __connman_ipconfig_set_local(dhcp->ipconfig, address);
509         __connman_ipconfig_set_prefixlen(dhcp->ipconfig, prefixlen);
510         __connman_ipconfig_set_gateway(dhcp->ipconfig, NULL);
511
512         dhcp_valid(dhcp);
513
514         g_free(address);
515         g_free(netmask);
516 #endif
517 }
518
519 static int dhcp_initialize(struct connman_dhcp *dhcp)
520 {
521         GDHCPClient *dhcp_client;
522         GDHCPClientError error;
523         int index;
524
525         DBG("dhcp %p", dhcp);
526
527         index = __connman_ipconfig_get_index(dhcp->ipconfig);
528
529         dhcp_client = g_dhcp_client_new(G_DHCP_IPV4, index, &error);
530         if (error != G_DHCP_CLIENT_ERROR_NONE)
531 #if defined TIZEN_EXT
532         {
533                 DBG("failed g_dhcp_client_new(%d), index(%d)", error, index);
534 #endif
535                 return -EINVAL;
536 #if defined TIZEN_EXT
537         }
538 #endif
539
540 #if !defined TIZEN_EXT
541         if (getenv("CONNMAN_DHCP_DEBUG")) {
542 #endif
543                 dhcp->dhcp_debug_prefix = g_strdup_printf("DHCP index %d",
544                                                         index);
545                 g_dhcp_client_set_debug(dhcp_client, dhcp_debug,
546                                         dhcp->dhcp_debug_prefix);
547 #if !defined TIZEN_EXT
548         }
549 #endif
550
551         g_dhcp_client_set_id(dhcp_client);
552
553         if (dhcp->network) {
554                 struct connman_service *service;
555                 const char *hostname;
556
557                 service = connman_service_lookup_from_network(dhcp->network);
558
559                 hostname = __connman_service_get_hostname(service);
560                 if (!hostname)
561                         hostname = connman_utsname_get_hostname();
562
563                 if (hostname)
564                         g_dhcp_client_set_send(dhcp_client,
565                                                 G_DHCP_HOST_NAME, hostname);
566
567                 g_dhcp_client_set_request(dhcp_client, G_DHCP_HOST_NAME);
568                 g_dhcp_client_set_request(dhcp_client, G_DHCP_DNS_SERVER);
569                 g_dhcp_client_set_request(dhcp_client, G_DHCP_DOMAIN_NAME);
570                 g_dhcp_client_set_request(dhcp_client, G_DHCP_NTP_SERVER);
571                 g_dhcp_client_set_request(dhcp_client, 252);
572         }
573
574         g_dhcp_client_set_request(dhcp_client, G_DHCP_SUBNET);
575         g_dhcp_client_set_request(dhcp_client, G_DHCP_ROUTER);
576
577         g_dhcp_client_register_event(dhcp_client,
578                         G_DHCP_CLIENT_EVENT_LEASE_AVAILABLE,
579                                                 lease_available_cb, dhcp);
580
581         g_dhcp_client_register_event(dhcp_client,
582                         G_DHCP_CLIENT_EVENT_LEASE_LOST, lease_lost_cb, dhcp);
583
584         g_dhcp_client_register_event(dhcp_client,
585                         G_DHCP_CLIENT_EVENT_NO_LEASE, no_lease_cb, dhcp);
586
587         dhcp->dhcp_client = dhcp_client;
588
589         return 0;
590 }
591
592 static int dhcp_release(struct connman_dhcp *dhcp)
593 {
594         DBG("dhcp %p", dhcp);
595
596         if (dhcp->timeout > 0) {
597                 g_source_remove(dhcp->timeout);
598                 dhcp->timeout = 0;
599         }
600
601         if (dhcp->dhcp_client) {
602                 g_dhcp_client_stop(dhcp->dhcp_client);
603                 g_dhcp_client_unref(dhcp->dhcp_client);
604         }
605
606         dhcp->dhcp_client = NULL;
607
608         g_free(dhcp->dhcp_debug_prefix);
609         dhcp->dhcp_debug_prefix = NULL;
610
611         ipv4ll_stop_client(dhcp);
612
613         return 0;
614 }
615
616 char *__connman_dhcp_get_server_address(struct connman_ipconfig *ipconfig)
617 {
618         struct connman_dhcp *dhcp;
619
620         dhcp = g_hash_table_lookup(ipconfig_table, ipconfig);
621         if (!dhcp)
622                 return NULL;
623
624         return g_dhcp_client_get_server_address(dhcp->dhcp_client);
625 }
626
627 int __connman_dhcp_start(struct connman_ipconfig *ipconfig,
628                         struct connman_network *network, dhcp_cb callback,
629                         gpointer user_data)
630 {
631         const char *last_addr = NULL;
632         struct connman_dhcp *dhcp;
633         int err;
634
635         DBG("");
636
637         if (network) {
638                 struct connman_service *service;
639
640                 service = connman_service_lookup_from_network(network);
641                 if (!service)
642                         return -EINVAL;
643         }
644
645         last_addr = __connman_ipconfig_get_dhcp_address(ipconfig);
646
647         dhcp = g_hash_table_lookup(ipconfig_table, ipconfig);
648         if (!dhcp) {
649
650                 dhcp = g_try_new0(struct connman_dhcp, 1);
651                 if (!dhcp)
652                         return -ENOMEM;
653
654                 dhcp->ipconfig = ipconfig;
655                 __connman_ipconfig_ref(ipconfig);
656
657                 if (network) {
658                         dhcp->network = network;
659                         connman_network_ref(network);
660                 }
661
662                 err = dhcp_initialize(dhcp);
663
664                 if (err < 0) {
665                         if (network)
666                                 connman_network_unref(network);
667                         g_free(dhcp);
668                         return err;
669                 }
670
671                 g_hash_table_insert(ipconfig_table, ipconfig, dhcp);
672         }
673
674         dhcp->callback = callback;
675         dhcp->user_data = user_data;
676
677         return g_dhcp_client_start(dhcp->dhcp_client, last_addr);
678 }
679
680 void __connman_dhcp_stop(struct connman_ipconfig *ipconfig)
681 {
682         struct connman_dhcp *dhcp;
683
684         DBG("ipconfig_table %p ipconfig %p", ipconfig_table, ipconfig);
685
686         if (!ipconfig_table)
687                 return;
688
689         dhcp = g_hash_table_lookup(ipconfig_table, ipconfig);
690         if (dhcp) {
691                 g_hash_table_remove(ipconfig_table, ipconfig);
692                 __connman_ipconfig_unref(ipconfig);
693                 if (dhcp->network)
694                         connman_network_unref(dhcp->network);
695                 dhcp_release(dhcp);
696                 dhcp_invalidate(dhcp, false);
697                 dhcp_free(dhcp);
698         }
699 }
700
701 int __connman_dhcp_init(void)
702 {
703         DBG("");
704
705         ipconfig_table = g_hash_table_new_full(g_direct_hash, g_direct_equal,
706                                                                 NULL, NULL);
707
708         return 0;
709 }
710
711 void __connman_dhcp_cleanup(void)
712 {
713         DBG("");
714
715         g_hash_table_destroy(ipconfig_table);
716         ipconfig_table = NULL;
717
718         dhcp_cleanup_random();
719 }