5 * Copyright (C) 2007-2010 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
27 #include <net/if_arp.h>
28 #include <linux/if_link.h>
33 #define IFF_LOWER_UP 0x10000
40 struct connman_ipconfig {
43 enum connman_ipconfig_type type;
45 struct connman_ipconfig *origin;
47 const struct connman_ipconfig_ops *ops;
50 enum connman_ipconfig_method method;
51 struct connman_ipaddress *address;
52 struct connman_ipaddress *system;
55 struct connman_ipdevice {
77 struct connman_ipconfig *config_ipv4;
78 struct connman_ipconfig *config_ipv6;
81 static GHashTable *ipdevice_hash = NULL;
82 static GList *ipconfig_list = NULL;
84 struct connman_ipaddress *connman_ipaddress_alloc(int family)
86 struct connman_ipaddress *ipaddress;
88 ipaddress = g_try_new0(struct connman_ipaddress, 1);
89 if (ipaddress == NULL)
92 ipaddress->family = family;
93 ipaddress->prefixlen = 0;
94 ipaddress->local = NULL;
95 ipaddress->peer = NULL;
96 ipaddress->broadcast = NULL;
97 ipaddress->gateway = NULL;
102 void connman_ipaddress_free(struct connman_ipaddress *ipaddress)
104 if (ipaddress == NULL)
107 g_free(ipaddress->broadcast);
108 g_free(ipaddress->peer);
109 g_free(ipaddress->local);
110 g_free(ipaddress->gateway);
114 unsigned char __connman_ipconfig_netmask_prefix_len(const char *netmask)
123 mask = inet_network(netmask);
126 /* a valid netmask must be 2^n - 1 */
127 if ((host & (host + 1)) != 0)
131 for (; mask; mask <<= 1)
137 static gboolean check_ipv6_address(const char *address)
139 unsigned char buf[sizeof(struct in6_addr)];
142 err = inet_pton(AF_INET6, address, buf);
149 int connman_ipaddress_set_ipv6(struct connman_ipaddress *ipaddress,
150 const char *address, const char *gateway,
151 unsigned char prefix_length)
153 if (ipaddress == NULL)
156 if (check_ipv6_address(address) == FALSE)
159 if (check_ipv6_address(gateway) == FALSE)
162 DBG("prefix_len %d address %s gateway %s",
163 prefix_length, address, gateway);
165 ipaddress->prefixlen = prefix_length;
167 g_free(ipaddress->local);
168 ipaddress->local = g_strdup(address);
170 g_free(ipaddress->gateway);
171 ipaddress->gateway = g_strdup(gateway);
176 void connman_ipaddress_set_ipv4(struct connman_ipaddress *ipaddress,
177 const char *address, const char *netmask, const char *gateway)
179 if (ipaddress == NULL)
182 ipaddress->prefixlen = __connman_ipconfig_netmask_prefix_len(netmask);
184 g_free(ipaddress->local);
185 ipaddress->local = g_strdup(address);
187 g_free(ipaddress->gateway);
188 ipaddress->gateway = g_strdup(gateway);
191 void connman_ipaddress_clear(struct connman_ipaddress *ipaddress)
193 if (ipaddress == NULL)
196 ipaddress->prefixlen = 0;
198 g_free(ipaddress->local);
199 ipaddress->local = NULL;
201 g_free(ipaddress->peer);
202 ipaddress->peer = NULL;
204 g_free(ipaddress->broadcast);
205 ipaddress->broadcast = NULL;
207 g_free(ipaddress->gateway);
208 ipaddress->gateway = NULL;
211 void connman_ipaddress_copy(struct connman_ipaddress *ipaddress,
212 struct connman_ipaddress *source)
214 if (ipaddress == NULL || source == NULL)
217 ipaddress->family = source->family;
218 ipaddress->prefixlen = source->prefixlen;
220 g_free(ipaddress->local);
221 ipaddress->local = g_strdup(source->local);
223 g_free(ipaddress->peer);
224 ipaddress->peer = g_strdup(source->peer);
226 g_free(ipaddress->broadcast);
227 ipaddress->broadcast = g_strdup(source->broadcast);
229 g_free(ipaddress->gateway);
230 ipaddress->gateway = g_strdup(source->gateway);
233 static void free_address_list(struct connman_ipdevice *ipdevice)
237 for (list = ipdevice->address_list; list; list = list->next) {
238 struct connman_ipaddress *ipaddress = list->data;
240 connman_ipaddress_free(ipaddress);
244 g_slist_free(ipdevice->address_list);
245 ipdevice->address_list = NULL;
248 static struct connman_ipaddress *find_ipaddress(struct connman_ipdevice *ipdevice,
249 unsigned char prefixlen, const char *local)
253 for (list = ipdevice->address_list; list; list = list->next) {
254 struct connman_ipaddress *ipaddress = list->data;
256 if (g_strcmp0(ipaddress->local, local) == 0 &&
257 ipaddress->prefixlen == prefixlen)
264 static const char *type2str(unsigned short type)
269 case ARPHRD_LOOPBACK:
282 static const char *scope2str(unsigned char scope)
294 static void free_ipdevice(gpointer data)
296 struct connman_ipdevice *ipdevice = data;
298 connman_info("%s {remove} index %d", ipdevice->ifname,
301 if (ipdevice->config_ipv4 != NULL) {
302 connman_ipconfig_unref(ipdevice->config_ipv4);
303 ipdevice->config_ipv4 = NULL;
306 if (ipdevice->config_ipv6 != NULL) {
307 connman_ipconfig_unref(ipdevice->config_ipv6);
308 ipdevice->config_ipv6 = NULL;
311 free_address_list(ipdevice);
312 g_free(ipdevice->ipv4_gateway);
313 g_free(ipdevice->ipv6_gateway);
314 g_free(ipdevice->pac);
316 g_free(ipdevice->address);
317 g_free(ipdevice->ifname);
321 static void __connman_ipconfig_lower_up(struct connman_ipdevice *ipdevice)
323 DBG("ipconfig ipv4 %p ipv6 %p", ipdevice->config_ipv4,
324 ipdevice->config_ipv6);
327 static void __connman_ipconfig_lower_down(struct connman_ipdevice *ipdevice)
329 DBG("ipconfig ipv4 %p ipv6 %p", ipdevice->config_ipv4,
330 ipdevice->config_ipv6);
332 if (ipdevice->config_ipv4)
333 connman_inet_clear_address(ipdevice->index,
334 ipdevice->config_ipv4->address);
336 if (ipdevice->config_ipv6)
337 connman_inet_clear_ipv6_address(ipdevice->index,
338 ipdevice->config_ipv6->address->local,
339 ipdevice->config_ipv6->address->prefixlen);
342 static void update_stats(struct connman_ipdevice *ipdevice,
343 struct rtnl_link_stats *stats)
345 struct connman_service *service;
347 if (stats->rx_packets == 0 && stats->tx_packets == 0)
350 connman_info("%s {RX} %u packets %u bytes", ipdevice->ifname,
351 stats->rx_packets, stats->rx_bytes);
352 connman_info("%s {TX} %u packets %u bytes", ipdevice->ifname,
353 stats->tx_packets, stats->tx_bytes);
355 if (ipdevice->config_ipv4 == NULL && ipdevice->config_ipv6 == NULL)
358 if (ipdevice->config_ipv4)
359 service = connman_ipconfig_get_data(ipdevice->config_ipv4);
360 else if (ipdevice->config_ipv6)
361 service = connman_ipconfig_get_data(ipdevice->config_ipv6);
368 ipdevice->rx_packets = stats->rx_packets;
369 ipdevice->tx_packets = stats->tx_packets;
370 ipdevice->rx_bytes = stats->rx_bytes;
371 ipdevice->tx_bytes = stats->tx_bytes;
372 ipdevice->rx_errors = stats->rx_errors;
373 ipdevice->tx_errors = stats->tx_errors;
374 ipdevice->rx_dropped = stats->rx_dropped;
375 ipdevice->tx_dropped = stats->tx_dropped;
377 __connman_service_notify(service,
378 ipdevice->rx_packets, ipdevice->tx_packets,
379 ipdevice->rx_bytes, ipdevice->tx_bytes,
380 ipdevice->rx_errors, ipdevice->tx_errors,
381 ipdevice->rx_dropped, ipdevice->tx_dropped);
384 void __connman_ipconfig_newlink(int index, unsigned short type,
385 unsigned int flags, const char *address,
387 struct rtnl_link_stats *stats)
389 struct connman_ipdevice *ipdevice;
392 gboolean up = FALSE, down = FALSE;
393 gboolean lower_up = FALSE, lower_down = FALSE;
395 DBG("index %d", index);
397 if (type == ARPHRD_LOOPBACK)
400 ipdevice = g_hash_table_lookup(ipdevice_hash, GINT_TO_POINTER(index));
401 if (ipdevice != NULL)
404 ipdevice = g_try_new0(struct connman_ipdevice, 1);
405 if (ipdevice == NULL)
408 ipdevice->index = index;
409 ipdevice->ifname = connman_inet_ifname(index);
410 ipdevice->type = type;
412 ipdevice->address = g_strdup(address);
414 g_hash_table_insert(ipdevice_hash, GINT_TO_POINTER(index), ipdevice);
416 connman_info("%s {create} index %d type %d <%s>", ipdevice->ifname,
417 index, type, type2str(type));
422 update_stats(ipdevice, stats);
424 if (flags == ipdevice->flags)
427 if ((ipdevice->flags & IFF_UP) != (flags & IFF_UP)) {
434 if ((ipdevice->flags & (IFF_RUNNING | IFF_LOWER_UP)) !=
435 (flags & (IFF_RUNNING | IFF_LOWER_UP))) {
436 if ((flags & (IFF_RUNNING | IFF_LOWER_UP)) ==
437 (IFF_RUNNING | IFF_LOWER_UP))
439 else if ((flags & (IFF_RUNNING | IFF_LOWER_UP)) == 0)
443 ipdevice->flags = flags;
445 str = g_string_new(NULL);
450 g_string_append(str, "UP");
452 g_string_append(str, "DOWN");
454 if (flags & IFF_RUNNING)
455 g_string_append(str, ",RUNNING");
457 if (flags & IFF_LOWER_UP)
458 g_string_append(str, ",LOWER_UP");
460 connman_info("%s {update} flags %u <%s>", ipdevice->ifname,
463 g_string_free(str, TRUE);
465 for (list = g_list_first(ipconfig_list); list;
466 list = g_list_next(list)) {
467 struct connman_ipconfig *ipconfig = list->data;
469 if (index != ipconfig->index)
472 if (ipconfig->ops == NULL)
475 if (up == TRUE && ipconfig->ops->up)
476 ipconfig->ops->up(ipconfig);
477 if (lower_up == TRUE && ipconfig->ops->lower_up)
478 ipconfig->ops->lower_up(ipconfig);
480 if (lower_down == TRUE && ipconfig->ops->lower_down)
481 ipconfig->ops->lower_down(ipconfig);
482 if (down == TRUE && ipconfig->ops->down)
483 ipconfig->ops->down(ipconfig);
487 __connman_ipconfig_lower_up(ipdevice);
489 __connman_ipconfig_lower_down(ipdevice);
492 void __connman_ipconfig_dellink(int index, struct rtnl_link_stats *stats)
494 struct connman_ipdevice *ipdevice;
497 DBG("index %d", index);
499 ipdevice = g_hash_table_lookup(ipdevice_hash, GINT_TO_POINTER(index));
500 if (ipdevice == NULL)
503 update_stats(ipdevice, stats);
505 for (list = g_list_first(ipconfig_list); list;
506 list = g_list_next(list)) {
507 struct connman_ipconfig *ipconfig = list->data;
509 if (index != ipconfig->index)
512 ipconfig->index = -1;
514 if (ipconfig->ops == NULL)
517 if (ipconfig->ops->lower_down)
518 ipconfig->ops->lower_down(ipconfig);
519 if (ipconfig->ops->down)
520 ipconfig->ops->down(ipconfig);
523 __connman_ipconfig_lower_down(ipdevice);
525 g_hash_table_remove(ipdevice_hash, GINT_TO_POINTER(index));
528 static inline gint check_duplicate_address(gconstpointer a, gconstpointer b)
530 const struct connman_ipaddress *addr1 = a;
531 const struct connman_ipaddress *addr2 = b;
533 if (addr1->prefixlen != addr2->prefixlen)
534 return addr2->prefixlen - addr1->prefixlen;
536 return g_strcmp0(addr1->local, addr2->local);
539 void __connman_ipconfig_newaddr(int index, int family, const char *label,
540 unsigned char prefixlen, const char *address)
542 struct connman_ipdevice *ipdevice;
543 struct connman_ipaddress *ipaddress;
546 DBG("index %d", index);
548 ipdevice = g_hash_table_lookup(ipdevice_hash, GINT_TO_POINTER(index));
549 if (ipdevice == NULL)
552 ipaddress = connman_ipaddress_alloc(family);
553 if (ipaddress == NULL)
556 ipaddress->prefixlen = prefixlen;
557 ipaddress->local = g_strdup(address);
559 if (g_slist_find_custom(ipdevice->address_list, ipaddress,
560 check_duplicate_address)) {
561 connman_ipaddress_free(ipaddress);
565 ipdevice->address_list = g_slist_append(ipdevice->address_list,
568 connman_info("%s {add} address %s/%u label %s family %d",
569 ipdevice->ifname, address, prefixlen, label, family);
571 if (ipdevice->config_ipv4 != NULL && family == AF_INET)
572 connman_ipaddress_copy(ipdevice->config_ipv4->system,
575 else if (ipdevice->config_ipv6 != NULL && family == AF_INET6)
576 connman_ipaddress_copy(ipdevice->config_ipv6->system,
581 if ((ipdevice->flags & (IFF_RUNNING | IFF_LOWER_UP)) != (IFF_RUNNING | IFF_LOWER_UP))
584 for (list = g_list_first(ipconfig_list); list;
585 list = g_list_next(list)) {
586 struct connman_ipconfig *ipconfig = list->data;
588 if (index != ipconfig->index)
591 if (ipconfig->ops == NULL)
594 if (ipconfig->ops->ip_bound)
595 ipconfig->ops->ip_bound(ipconfig);
599 void __connman_ipconfig_deladdr(int index, int family, const char *label,
600 unsigned char prefixlen, const char *address)
602 struct connman_ipdevice *ipdevice;
603 struct connman_ipaddress *ipaddress;
606 DBG("index %d", index);
608 ipdevice = g_hash_table_lookup(ipdevice_hash, GINT_TO_POINTER(index));
609 if (ipdevice == NULL)
612 ipaddress = find_ipaddress(ipdevice, prefixlen, address);
613 if (ipaddress == NULL)
616 ipdevice->address_list = g_slist_remove(ipdevice->address_list,
619 connman_ipaddress_free(ipaddress);
621 connman_info("%s {del} address %s/%u label %s", ipdevice->ifname,
622 address, prefixlen, label);
624 if ((ipdevice->flags & (IFF_RUNNING | IFF_LOWER_UP)) != (IFF_RUNNING | IFF_LOWER_UP))
627 if (g_slist_length(ipdevice->address_list) > 0)
630 for (list = g_list_first(ipconfig_list); list;
631 list = g_list_next(list)) {
632 struct connman_ipconfig *ipconfig = list->data;
634 if (index != ipconfig->index)
637 if (ipconfig->ops == NULL)
640 if (ipconfig->ops->ip_release)
641 ipconfig->ops->ip_release(ipconfig);
645 void __connman_ipconfig_newroute(int index, int family, unsigned char scope,
646 const char *dst, const char *gateway)
648 struct connman_ipdevice *ipdevice;
650 DBG("index %d", index);
652 ipdevice = g_hash_table_lookup(ipdevice_hash, GINT_TO_POINTER(index));
653 if (ipdevice == NULL)
656 if (scope == 0 && g_strcmp0(dst, "0.0.0.0") == 0) {
660 if (family == AF_INET6) {
661 g_free(ipdevice->ipv6_gateway);
662 ipdevice->ipv6_gateway = g_strdup(gateway);
664 if (ipdevice->config_ipv6 != NULL &&
665 ipdevice->config_ipv6->system != NULL) {
666 g_free(ipdevice->config_ipv6->system->gateway);
667 ipdevice->config_ipv6->system->gateway =
671 g_free(ipdevice->ipv4_gateway);
672 ipdevice->ipv4_gateway = g_strdup(gateway);
674 if (ipdevice->config_ipv4 != NULL &&
675 ipdevice->config_ipv4->system != NULL) {
676 g_free(ipdevice->config_ipv4->system->gateway);
677 ipdevice->config_ipv4->system->gateway =
682 for (list = ipdevice->address_list; list; list = list->next) {
683 struct connman_ipaddress *ipaddress = list->data;
685 g_free(ipaddress->gateway);
686 ipaddress->gateway = g_strdup(gateway);
689 for (config_list = g_list_first(ipconfig_list); config_list;
690 config_list = g_list_next(config_list)) {
691 struct connman_ipconfig *ipconfig = config_list->data;
693 if (index != ipconfig->index)
696 if (ipconfig->ops == NULL)
699 if (ipconfig->ops->ip_bound)
700 ipconfig->ops->ip_bound(ipconfig);
704 connman_info("%s {add} route %s gw %s scope %u <%s>",
705 ipdevice->ifname, dst, gateway,
706 scope, scope2str(scope));
709 void __connman_ipconfig_delroute(int index, int family, unsigned char scope,
710 const char *dst, const char *gateway)
712 struct connman_ipdevice *ipdevice;
714 DBG("index %d", index);
716 ipdevice = g_hash_table_lookup(ipdevice_hash, GINT_TO_POINTER(index));
717 if (ipdevice == NULL)
720 if (scope == 0 && g_strcmp0(dst, "0.0.0.0") == 0) {
724 if (family == AF_INET6) {
725 g_free(ipdevice->ipv6_gateway);
726 ipdevice->ipv6_gateway = NULL;
728 if (ipdevice->config_ipv6 != NULL &&
729 ipdevice->config_ipv6->system != NULL) {
730 g_free(ipdevice->config_ipv6->system->gateway);
731 ipdevice->config_ipv6->system->gateway = NULL;
734 g_free(ipdevice->ipv4_gateway);
735 ipdevice->ipv4_gateway = NULL;
737 if (ipdevice->config_ipv4 != NULL &&
738 ipdevice->config_ipv4->system != NULL) {
739 g_free(ipdevice->config_ipv4->system->gateway);
740 ipdevice->config_ipv4->system->gateway = NULL;
744 for (list = ipdevice->address_list; list; list = list->next) {
745 struct connman_ipaddress *ipaddress = list->data;
747 g_free(ipaddress->gateway);
748 ipaddress->gateway = NULL;
751 for (config_list = g_list_first(ipconfig_list); config_list;
752 config_list = g_list_next(config_list)) {
753 struct connman_ipconfig *ipconfig = config_list->data;
755 if (index != ipconfig->index)
758 if (ipconfig->ops == NULL)
761 if (ipconfig->ops->ip_release)
762 ipconfig->ops->ip_release(ipconfig);
766 connman_info("%s {del} route %s gw %s scope %u <%s>",
767 ipdevice->ifname, dst, gateway,
768 scope, scope2str(scope));
771 void __connman_ipconfig_foreach(void (*function) (int index, void *user_data),
776 keys = g_hash_table_get_keys(ipdevice_hash);
780 for (list = g_list_first(keys); list; list = g_list_next(list)) {
781 int index = GPOINTER_TO_INT(list->data);
783 function(index, user_data);
789 unsigned short __connman_ipconfig_get_type(int index)
791 struct connman_ipdevice *ipdevice;
793 ipdevice = g_hash_table_lookup(ipdevice_hash, GINT_TO_POINTER(index));
794 if (ipdevice == NULL)
797 return ipdevice->type;
800 unsigned int __connman_ipconfig_get_flags(int index)
802 struct connman_ipdevice *ipdevice;
804 ipdevice = g_hash_table_lookup(ipdevice_hash, GINT_TO_POINTER(index));
805 if (ipdevice == NULL)
808 return ipdevice->flags;
811 const char *__connman_ipconfig_get_gateway(int index)
813 struct connman_ipdevice *ipdevice;
815 ipdevice = g_hash_table_lookup(ipdevice_hash, GINT_TO_POINTER(index));
816 if (ipdevice == NULL)
819 if (ipdevice->ipv4_gateway != NULL)
820 return ipdevice->ipv4_gateway;
822 if (ipdevice->config_ipv4 != NULL &&
823 ipdevice->config_ipv4->address != NULL)
824 return ipdevice->config_ipv4->address->gateway;
826 if (ipdevice->ipv6_gateway != NULL)
827 return ipdevice->ipv6_gateway;
829 if (ipdevice->config_ipv6 != NULL &&
830 ipdevice->config_ipv6->address != NULL)
831 return ipdevice->config_ipv6->address->gateway;
836 void __connman_ipconfig_set_index(struct connman_ipconfig *ipconfig, int index)
838 ipconfig->index = index;
841 static struct connman_ipconfig *create_ipv6config(int index)
843 struct connman_ipconfig *ipv6config;
845 DBG("index %d", index);
847 ipv6config = g_try_new0(struct connman_ipconfig, 1);
848 if (ipv6config == NULL)
851 ipv6config->refcount = 1;
853 ipv6config->index = index;
854 ipv6config->type = CONNMAN_IPCONFIG_TYPE_IPV6;
855 ipv6config->method = CONNMAN_IPCONFIG_METHOD_AUTO;
857 ipv6config->address = connman_ipaddress_alloc(AF_INET6);
858 if (ipv6config->address == NULL) {
863 ipv6config->system = connman_ipaddress_alloc(AF_INET6);
865 DBG("ipconfig %p", ipv6config);
871 * connman_ipconfig_create:
873 * Allocate a new ipconfig structure.
875 * Returns: a newly-allocated #connman_ipconfig structure
877 struct connman_ipconfig *connman_ipconfig_create(int index,
878 enum connman_ipconfig_type type)
880 struct connman_ipconfig *ipconfig;
882 if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
883 return create_ipv6config(index);
885 DBG("index %d", index);
887 ipconfig = g_try_new0(struct connman_ipconfig, 1);
888 if (ipconfig == NULL)
891 ipconfig->refcount = 1;
893 ipconfig->index = index;
894 ipconfig->type = CONNMAN_IPCONFIG_TYPE_IPV4;
896 ipconfig->address = connman_ipaddress_alloc(AF_INET);
897 if (ipconfig->address == NULL) {
902 ipconfig->system = connman_ipaddress_alloc(AF_INET);
904 DBG("ipconfig %p", ipconfig);
911 * connman_ipconfig_ref:
912 * @ipconfig: ipconfig structure
914 * Increase reference counter of ipconfig
916 struct connman_ipconfig *connman_ipconfig_ref(struct connman_ipconfig *ipconfig)
918 DBG("ipconfig %p refcount %d", ipconfig,
919 g_atomic_int_get(&ipconfig->refcount) + 1);
921 g_atomic_int_inc(&ipconfig->refcount);
927 * connman_ipconfig_unref:
928 * @ipconfig: ipconfig structure
930 * Decrease reference counter of ipconfig
932 void connman_ipconfig_unref(struct connman_ipconfig *ipconfig)
934 if (ipconfig == NULL)
937 DBG("ipconfig %p refcount %d", ipconfig,
938 g_atomic_int_get(&ipconfig->refcount) - 1);
940 if (g_atomic_int_dec_and_test(&ipconfig->refcount) == TRUE) {
941 __connman_ipconfig_disable(ipconfig);
943 connman_ipconfig_set_ops(ipconfig, NULL);
945 if (ipconfig->origin != NULL) {
946 connman_ipconfig_unref(ipconfig->origin);
947 ipconfig->origin = NULL;
950 connman_ipaddress_free(ipconfig->system);
951 connman_ipaddress_free(ipconfig->address);
957 * connman_ipconfig_get_data:
958 * @ipconfig: ipconfig structure
960 * Get private data pointer
962 void *connman_ipconfig_get_data(struct connman_ipconfig *ipconfig)
964 if (ipconfig == NULL)
967 return ipconfig->ops_data;
971 * connman_ipconfig_set_data:
972 * @ipconfig: ipconfig structure
973 * @data: data pointer
975 * Set private data pointer
977 void connman_ipconfig_set_data(struct connman_ipconfig *ipconfig, void *data)
979 ipconfig->ops_data = data;
983 * connman_ipconfig_get_index:
984 * @ipconfig: ipconfig structure
986 * Get interface index
988 int connman_ipconfig_get_index(struct connman_ipconfig *ipconfig)
990 if (ipconfig == NULL)
993 if (ipconfig->origin != NULL)
994 return ipconfig->origin->index;
996 return ipconfig->index;
1000 * connman_ipconfig_get_ifname:
1001 * @ipconfig: ipconfig structure
1003 * Get interface name
1005 const char *connman_ipconfig_get_ifname(struct connman_ipconfig *ipconfig)
1007 struct connman_ipdevice *ipdevice;
1009 if (ipconfig == NULL)
1012 if (ipconfig->index < 0)
1015 ipdevice = g_hash_table_lookup(ipdevice_hash,
1016 GINT_TO_POINTER(ipconfig->index));
1017 if (ipdevice == NULL)
1020 return ipdevice->ifname;
1024 * connman_ipconfig_set_ops:
1025 * @ipconfig: ipconfig structure
1026 * @ops: operation callbacks
1028 * Set the operation callbacks
1030 void connman_ipconfig_set_ops(struct connman_ipconfig *ipconfig,
1031 const struct connman_ipconfig_ops *ops)
1033 ipconfig->ops = ops;
1037 * connman_ipconfig_set_method:
1038 * @ipconfig: ipconfig structure
1039 * @method: configuration method
1041 * Set the configuration method
1043 int connman_ipconfig_set_method(struct connman_ipconfig *ipconfig,
1044 enum connman_ipconfig_method method)
1046 ipconfig->method = method;
1051 enum connman_ipconfig_method __connman_ipconfig_get_method(struct connman_ipconfig *ipconfig)
1053 if (ipconfig == NULL)
1054 return CONNMAN_IPCONFIG_METHOD_UNKNOWN;
1056 return ipconfig->method;
1060 * connman_ipconfig_bind:
1061 * @ipconfig: ipconfig structure
1062 * @ipaddress: ipaddress structure
1064 * Bind IP address details to configuration
1066 void connman_ipconfig_bind(struct connman_ipconfig *ipconfig,
1067 struct connman_ipaddress *ipaddress)
1069 struct connman_ipconfig *origin;
1071 origin = ipconfig->origin ? ipconfig->origin : ipconfig;
1073 connman_ipaddress_copy(origin->address, ipaddress);
1075 connman_inet_set_address(origin->index, origin->address);
1078 void __connman_ipconfig_set_element_ipv6_gateway(
1079 struct connman_ipconfig *ipconfig,
1080 struct connman_element *element)
1082 if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV6)
1083 element->ipv6.gateway = ipconfig->address->gateway;
1087 * FIXME: The element soulution should be removed in the future
1088 * Set IPv4 and IPv6 gateway
1090 int __connman_ipconfig_set_gateway(struct connman_ipconfig *ipconfig,
1091 struct connman_element *parent)
1093 struct connman_element *connection;
1095 connection = connman_element_create(NULL);
1097 DBG("ipconfig %p", ipconfig);
1099 connection->type = CONNMAN_ELEMENT_TYPE_CONNECTION;
1100 connection->index = ipconfig->index;
1102 if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV4)
1103 connection->ipv4.gateway = ipconfig->address->gateway;
1104 else if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV6)
1105 connection->ipv6.gateway = ipconfig->address->gateway;
1107 if (connman_element_register(connection, parent) < 0)
1108 connman_element_unref(connection);
1113 int __connman_ipconfig_set_address(struct connman_ipconfig *ipconfig)
1117 switch (ipconfig->method) {
1118 case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
1119 case CONNMAN_IPCONFIG_METHOD_OFF:
1120 case CONNMAN_IPCONFIG_METHOD_FIXED:
1121 case CONNMAN_IPCONFIG_METHOD_DHCP:
1122 case CONNMAN_IPCONFIG_METHOD_AUTO:
1124 case CONNMAN_IPCONFIG_METHOD_MANUAL:
1125 if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV4)
1126 return connman_inet_set_address(ipconfig->index,
1128 else if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV6)
1129 return connman_inet_set_ipv6_address(
1130 ipconfig->index, ipconfig->address);
1136 int __connman_ipconfig_clear_address(struct connman_ipconfig *ipconfig)
1140 if (ipconfig == NULL)
1143 DBG("method %d", ipconfig->method);
1145 switch (ipconfig->method) {
1146 case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
1147 case CONNMAN_IPCONFIG_METHOD_OFF:
1148 case CONNMAN_IPCONFIG_METHOD_FIXED:
1149 case CONNMAN_IPCONFIG_METHOD_DHCP:
1150 case CONNMAN_IPCONFIG_METHOD_AUTO:
1152 case CONNMAN_IPCONFIG_METHOD_MANUAL:
1153 if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV4)
1154 return connman_inet_clear_address(ipconfig->index,
1156 else if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV6)
1157 return connman_inet_clear_ipv6_address(
1159 ipconfig->address->local,
1160 ipconfig->address->prefixlen);
1166 int __connman_ipconfig_set_proxy_autoconfig(struct connman_ipconfig *ipconfig,
1169 struct connman_ipdevice *ipdevice;
1171 DBG("ipconfig %p", ipconfig);
1173 if (ipconfig == NULL || ipconfig->index < 0)
1176 ipdevice = g_hash_table_lookup(ipdevice_hash,
1177 GINT_TO_POINTER(ipconfig->index));
1178 if (ipdevice == NULL)
1181 g_free(ipdevice->pac);
1182 ipdevice->pac = g_strdup(url);
1187 const char *__connman_ipconfig_get_proxy_autoconfig(struct connman_ipconfig *ipconfig)
1189 struct connman_ipdevice *ipdevice;
1191 DBG("ipconfig %p", ipconfig);
1193 if (ipconfig == NULL || ipconfig->index < 0)
1196 ipdevice = g_hash_table_lookup(ipdevice_hash,
1197 GINT_TO_POINTER(ipconfig->index));
1198 if (ipdevice == NULL)
1201 return ipdevice->pac;
1204 int __connman_ipconfig_enable(struct connman_ipconfig *ipconfig)
1206 struct connman_ipdevice *ipdevice;
1207 gboolean up = FALSE, down = FALSE;
1208 gboolean lower_up = FALSE, lower_down = FALSE;
1209 enum connman_ipconfig_type type;
1211 DBG("ipconfig %p", ipconfig);
1213 if (ipconfig == NULL || ipconfig->index < 0)
1216 ipdevice = g_hash_table_lookup(ipdevice_hash,
1217 GINT_TO_POINTER(ipconfig->index));
1218 if (ipdevice == NULL)
1221 if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV4) {
1222 if (ipdevice->config_ipv4 == ipconfig)
1224 type = CONNMAN_IPCONFIG_TYPE_IPV4;
1225 } else if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV6) {
1226 if (ipdevice->config_ipv6 == ipconfig)
1228 type = CONNMAN_IPCONFIG_TYPE_IPV6;
1232 if (type == CONNMAN_IPCONFIG_TYPE_IPV4 &&
1233 ipdevice->config_ipv4 != NULL) {
1234 ipconfig_list = g_list_remove(ipconfig_list,
1235 ipdevice->config_ipv4);
1237 connman_ipaddress_clear(ipdevice->config_ipv4->system);
1239 connman_ipconfig_unref(ipdevice->config_ipv4);
1242 if (type == CONNMAN_IPCONFIG_TYPE_IPV6 &&
1243 ipdevice->config_ipv6 != NULL) {
1244 ipconfig_list = g_list_remove(ipconfig_list,
1245 ipdevice->config_ipv6);
1247 connman_ipaddress_clear(ipdevice->config_ipv6->system);
1249 connman_ipconfig_unref(ipdevice->config_ipv6);
1252 if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
1253 ipdevice->config_ipv4 = connman_ipconfig_ref(ipconfig);
1254 else if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
1255 ipdevice->config_ipv6 = connman_ipconfig_ref(ipconfig);
1257 ipconfig_list = g_list_append(ipconfig_list, ipconfig);
1259 if (ipdevice->flags & IFF_UP)
1264 if ((ipdevice->flags & (IFF_RUNNING | IFF_LOWER_UP)) ==
1265 (IFF_RUNNING | IFF_LOWER_UP))
1267 else if ((ipdevice->flags & (IFF_RUNNING | IFF_LOWER_UP)) == 0)
1270 if (up == TRUE && ipconfig->ops->up)
1271 ipconfig->ops->up(ipconfig);
1272 if (lower_up == TRUE && ipconfig->ops->lower_up)
1273 ipconfig->ops->lower_up(ipconfig);
1275 if (lower_down == TRUE && ipconfig->ops->lower_down)
1276 ipconfig->ops->lower_down(ipconfig);
1277 if (down == TRUE && ipconfig->ops->down)
1278 ipconfig->ops->down(ipconfig);
1283 int __connman_ipconfig_disable(struct connman_ipconfig *ipconfig)
1285 struct connman_ipdevice *ipdevice;
1287 DBG("ipconfig %p", ipconfig);
1289 if (ipconfig == NULL || ipconfig->index < 0)
1292 ipdevice = g_hash_table_lookup(ipdevice_hash,
1293 GINT_TO_POINTER(ipconfig->index));
1294 if (ipdevice == NULL)
1297 if (ipdevice->config_ipv4 == NULL && ipdevice->config_ipv6 == NULL)
1300 if (ipdevice->config_ipv4 == ipconfig) {
1301 ipconfig_list = g_list_remove(ipconfig_list, ipconfig);
1303 connman_ipaddress_clear(ipdevice->config_ipv4->system);
1304 connman_ipconfig_unref(ipdevice->config_ipv4);
1305 ipdevice->config_ipv4 = NULL;
1309 if (ipdevice->config_ipv6 == ipconfig) {
1310 ipconfig_list = g_list_remove(ipconfig_list, ipconfig);
1312 connman_ipaddress_clear(ipdevice->config_ipv6->system);
1313 connman_ipconfig_unref(ipdevice->config_ipv6);
1314 ipdevice->config_ipv6 = NULL;
1321 const char *__connman_ipconfig_method2string(enum connman_ipconfig_method method)
1324 case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
1326 case CONNMAN_IPCONFIG_METHOD_OFF:
1328 case CONNMAN_IPCONFIG_METHOD_FIXED:
1330 case CONNMAN_IPCONFIG_METHOD_MANUAL:
1332 case CONNMAN_IPCONFIG_METHOD_DHCP:
1334 case CONNMAN_IPCONFIG_METHOD_AUTO:
1341 enum connman_ipconfig_method __connman_ipconfig_string2method(const char *method)
1343 if (g_strcmp0(method, "off") == 0)
1344 return CONNMAN_IPCONFIG_METHOD_OFF;
1345 else if (g_strcmp0(method, "fixed") == 0)
1346 return CONNMAN_IPCONFIG_METHOD_FIXED;
1347 else if (g_strcmp0(method, "manual") == 0)
1348 return CONNMAN_IPCONFIG_METHOD_MANUAL;
1349 else if (g_strcmp0(method, "dhcp") == 0)
1350 return CONNMAN_IPCONFIG_METHOD_DHCP;
1351 else if (g_strcmp0(method, "auto") == 0)
1352 return CONNMAN_IPCONFIG_METHOD_AUTO;
1354 return CONNMAN_IPCONFIG_METHOD_UNKNOWN;
1357 void __connman_ipconfig_append_ipv4(struct connman_ipconfig *ipconfig,
1358 DBusMessageIter *iter)
1364 if (ipconfig->type != CONNMAN_IPCONFIG_TYPE_IPV4)
1367 str = __connman_ipconfig_method2string(ipconfig->method);
1371 connman_dbus_dict_append_basic(iter, "Method", DBUS_TYPE_STRING, &str);
1373 if (ipconfig->system == NULL)
1376 if (ipconfig->system->local != NULL) {
1378 struct in_addr netmask;
1381 connman_dbus_dict_append_basic(iter, "Address",
1382 DBUS_TYPE_STRING, &ipconfig->system->local);
1384 addr = 0xffffffff << (32 - ipconfig->system->prefixlen);
1385 netmask.s_addr = htonl(addr);
1386 mask = inet_ntoa(netmask);
1387 connman_dbus_dict_append_basic(iter, "Netmask",
1388 DBUS_TYPE_STRING, &mask);
1391 if (ipconfig->system->gateway != NULL)
1392 connman_dbus_dict_append_basic(iter, "Gateway",
1393 DBUS_TYPE_STRING, &ipconfig->system->gateway);
1396 void __connman_ipconfig_append_ipv6(struct connman_ipconfig *ipconfig,
1397 DBusMessageIter *iter)
1403 if (ipconfig->type != CONNMAN_IPCONFIG_TYPE_IPV6)
1406 str = __connman_ipconfig_method2string(ipconfig->method);
1410 connman_dbus_dict_append_basic(iter, "Method", DBUS_TYPE_STRING, &str);
1412 if (ipconfig->system == NULL)
1415 if (ipconfig->system->local != NULL) {
1416 connman_dbus_dict_append_basic(iter, "Address",
1417 DBUS_TYPE_STRING, &ipconfig->system->local);
1418 connman_dbus_dict_append_basic(iter, "PrefixLength",
1420 &ipconfig->system->prefixlen);
1423 if (ipconfig->system->gateway != NULL)
1424 connman_dbus_dict_append_basic(iter, "Gateway",
1425 DBUS_TYPE_STRING, &ipconfig->system->gateway);
1428 void __connman_ipconfig_append_ipv6config(struct connman_ipconfig *ipconfig,
1429 DBusMessageIter *iter)
1435 str = __connman_ipconfig_method2string(ipconfig->method);
1439 connman_dbus_dict_append_basic(iter, "Method", DBUS_TYPE_STRING, &str);
1441 switch (ipconfig->method) {
1442 case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
1443 case CONNMAN_IPCONFIG_METHOD_OFF:
1444 case CONNMAN_IPCONFIG_METHOD_DHCP:
1446 case CONNMAN_IPCONFIG_METHOD_FIXED:
1447 case CONNMAN_IPCONFIG_METHOD_MANUAL:
1448 case CONNMAN_IPCONFIG_METHOD_AUTO:
1452 if (ipconfig->address == NULL)
1455 if (ipconfig->address->local != NULL) {
1456 connman_dbus_dict_append_basic(iter, "Address",
1457 DBUS_TYPE_STRING, &ipconfig->address->local);
1458 connman_dbus_dict_append_basic(iter, "PrefixLength",
1460 &ipconfig->address->prefixlen);
1463 if (ipconfig->address->gateway != NULL)
1464 connman_dbus_dict_append_basic(iter, "Gateway",
1465 DBUS_TYPE_STRING, &ipconfig->address->gateway);
1468 void __connman_ipconfig_append_ipv4config(struct connman_ipconfig *ipconfig,
1469 DBusMessageIter *iter)
1475 str = __connman_ipconfig_method2string(ipconfig->method);
1479 connman_dbus_dict_append_basic(iter, "Method", DBUS_TYPE_STRING, &str);
1481 switch (ipconfig->method) {
1482 case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
1483 case CONNMAN_IPCONFIG_METHOD_OFF:
1484 case CONNMAN_IPCONFIG_METHOD_FIXED:
1485 case CONNMAN_IPCONFIG_METHOD_DHCP:
1486 case CONNMAN_IPCONFIG_METHOD_AUTO:
1488 case CONNMAN_IPCONFIG_METHOD_MANUAL:
1492 if (ipconfig->address == NULL)
1495 if (ipconfig->address->local != NULL) {
1497 struct in_addr netmask;
1500 connman_dbus_dict_append_basic(iter, "Address",
1501 DBUS_TYPE_STRING, &ipconfig->address->local);
1503 addr = 0xffffffff << (32 - ipconfig->address->prefixlen);
1504 netmask.s_addr = htonl(addr);
1505 mask = inet_ntoa(netmask);
1506 connman_dbus_dict_append_basic(iter, "Netmask",
1507 DBUS_TYPE_STRING, &mask);
1510 if (ipconfig->address->gateway != NULL)
1511 connman_dbus_dict_append_basic(iter, "Gateway",
1512 DBUS_TYPE_STRING, &ipconfig->address->gateway);
1515 int __connman_ipconfig_set_config(struct connman_ipconfig *ipconfig,
1516 DBusMessageIter *array)
1518 enum connman_ipconfig_method method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
1519 const char *address = NULL, *netmask = NULL, *gateway = NULL,
1520 *prefix_length_string = NULL;
1521 int prefix_length = 0;
1522 DBusMessageIter dict;
1524 DBG("ipconfig %p", ipconfig);
1526 if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
1529 dbus_message_iter_recurse(array, &dict);
1531 while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
1532 DBusMessageIter entry;
1536 dbus_message_iter_recurse(&dict, &entry);
1538 if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING)
1541 dbus_message_iter_get_basic(&entry, &key);
1542 dbus_message_iter_next(&entry);
1544 type = dbus_message_iter_get_arg_type(&entry);
1546 if (g_str_equal(key, "Method") == TRUE) {
1549 if (type != DBUS_TYPE_STRING)
1552 dbus_message_iter_get_basic(&entry, &str);
1553 method = __connman_ipconfig_string2method(str);
1554 } else if (g_str_equal(key, "Address") == TRUE) {
1555 if (type != DBUS_TYPE_STRING)
1558 dbus_message_iter_get_basic(&entry, &address);
1559 } else if (g_str_equal(key, "PrefixLength") == TRUE) {
1560 if (type != DBUS_TYPE_STRING)
1563 dbus_message_iter_get_basic(&entry,
1564 &prefix_length_string);
1566 prefix_length = atoi(prefix_length_string);
1567 if (prefix_length < 0 || prefix_length > 128)
1570 } else if (g_str_equal(key, "Netmask") == TRUE) {
1571 if (type != DBUS_TYPE_STRING)
1574 dbus_message_iter_get_basic(&entry, &netmask);
1575 } else if (g_str_equal(key, "Gateway") == TRUE) {
1576 if (type != DBUS_TYPE_STRING)
1579 dbus_message_iter_get_basic(&entry, &gateway);
1581 dbus_message_iter_next(&dict);
1584 DBG("method %d address %s netmask %s gateway %s prefix_length %d",
1585 method, address, netmask, gateway, prefix_length);
1588 case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
1589 case CONNMAN_IPCONFIG_METHOD_OFF:
1590 case CONNMAN_IPCONFIG_METHOD_FIXED:
1591 case CONNMAN_IPCONFIG_METHOD_AUTO:
1594 case CONNMAN_IPCONFIG_METHOD_MANUAL:
1595 if (address == NULL)
1598 ipconfig->method = method;
1600 if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV4)
1601 connman_ipaddress_set_ipv4(ipconfig->address,
1602 address, netmask, gateway);
1604 return connman_ipaddress_set_ipv6(
1605 ipconfig->address, address,
1606 gateway, prefix_length);
1609 case CONNMAN_IPCONFIG_METHOD_DHCP:
1610 ipconfig->method = method;
1617 void __connman_ipconfig_append_ethernet(struct connman_ipconfig *ipconfig,
1618 DBusMessageIter *iter)
1620 struct connman_ipdevice *ipdevice;
1621 const char *method = "auto";
1623 connman_dbus_dict_append_basic(iter, "Method",
1624 DBUS_TYPE_STRING, &method);
1626 ipdevice = g_hash_table_lookup(ipdevice_hash,
1627 GINT_TO_POINTER(ipconfig->index));
1628 if (ipdevice == NULL)
1631 if (ipdevice->ifname != NULL)
1632 connman_dbus_dict_append_basic(iter, "Interface",
1633 DBUS_TYPE_STRING, &ipdevice->ifname);
1635 if (ipdevice->address != NULL)
1636 connman_dbus_dict_append_basic(iter, "Address",
1637 DBUS_TYPE_STRING, &ipdevice->address);
1639 if (ipdevice->mtu > 0)
1640 connman_dbus_dict_append_basic(iter, "MTU",
1641 DBUS_TYPE_UINT16, &ipdevice->mtu);
1644 int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
1645 GKeyFile *keyfile, const char *identifier, const char *prefix)
1650 DBG("ipconfig %p identifier %s", ipconfig, identifier);
1652 key = g_strdup_printf("%smethod", prefix);
1653 method = g_key_file_get_string(keyfile, identifier, key, NULL);
1654 if (method == NULL) {
1655 if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV4)
1656 ipconfig->method = CONNMAN_IPCONFIG_METHOD_DHCP;
1658 ipconfig->method = CONNMAN_IPCONFIG_METHOD_OFF;
1660 ipconfig->method = __connman_ipconfig_string2method(method);
1662 if (ipconfig->method == CONNMAN_IPCONFIG_METHOD_UNKNOWN)
1663 ipconfig->method = CONNMAN_IPCONFIG_METHOD_OFF;
1668 key = g_strdup_printf("%snetmask_prefixlen", prefix);
1669 ipconfig->address->prefixlen = g_key_file_get_integer(
1670 keyfile, identifier, key, NULL);
1673 key = g_strdup_printf("%slocal_address", prefix);
1674 ipconfig->address->local = g_key_file_get_string(
1675 keyfile, identifier, key, NULL);
1678 key = g_strdup_printf("%speer_address", prefix);
1679 ipconfig->address->peer = g_key_file_get_string(
1680 keyfile, identifier, key, NULL);
1683 key = g_strdup_printf("%sbroadcast_address", prefix);
1684 ipconfig->address->broadcast = g_key_file_get_string(
1685 keyfile, identifier, key, NULL);
1688 key = g_strdup_printf("%sgateway", prefix);
1689 ipconfig->address->gateway = g_key_file_get_string(
1690 keyfile, identifier, key, NULL);
1696 int __connman_ipconfig_save(struct connman_ipconfig *ipconfig,
1697 GKeyFile *keyfile, const char *identifier, const char *prefix)
1702 DBG("ipconfig %p identifier %s", ipconfig, identifier);
1704 method = __connman_ipconfig_method2string(ipconfig->method);
1706 key = g_strdup_printf("%smethod", prefix);
1707 g_key_file_set_string(keyfile, identifier, key, method);
1710 key = g_strdup_printf("%snetmask_prefixlen", prefix);
1711 g_key_file_set_integer(keyfile, identifier,
1712 key, ipconfig->address->prefixlen);
1715 key = g_strdup_printf("%slocal_address", prefix);
1716 if (ipconfig->address->local != NULL)
1717 g_key_file_set_string(keyfile, identifier,
1718 key, ipconfig->address->local);
1721 key = g_strdup_printf("%speer_address", prefix);
1722 if (ipconfig->address->peer != NULL)
1723 g_key_file_set_string(keyfile, identifier,
1724 key, ipconfig->address->peer);
1727 key = g_strdup_printf("%sbroadcast_address", prefix);
1728 if (ipconfig->address->broadcast != NULL)
1729 g_key_file_set_string(keyfile, identifier,
1730 key, ipconfig->address->broadcast);
1733 key = g_strdup_printf("%sgateway", prefix);
1734 if (ipconfig->address->gateway != NULL)
1735 g_key_file_set_string(keyfile, identifier,
1736 key, ipconfig->address->gateway);
1742 int __connman_ipconfig_init(void)
1746 ipdevice_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal,
1747 NULL, free_ipdevice);
1752 void __connman_ipconfig_cleanup(void)
1756 g_hash_table_destroy(ipdevice_hash);
1757 ipdevice_hash = NULL;