static void add_nat_rules(struct connman_session *session) { struct connman_ipconfig *ipconfig; const char *addr; char *ifname; int index, id, err; if (!session->fw) return; DBG(""); ipconfig = __connman_service_get_ip4config(session->service); index = __connman_ipconfig_get_index(ipconfig); ifname = connman_inet_ifname(index); addr = __connman_ipconfig_get_local(ipconfig); id = __connman_firewall_add_rule(session->fw, "nat", "POSTROUTING", "-o %s -j SNAT --to-source %s", ifname, addr); g_free(ifname); if (id < 0) { DBG("failed to add SNAT rule"); return; } err = __connman_firewall_enable_rule(session->fw, id); if (err < 0) { DBG("could not enable SNAT rule"); __connman_firewall_remove_rule(session->fw, id); return; } session->snat_id = id; }
static void ipv4ll_available_cb(GDHCPClient *dhcp_client, gpointer user_data) { struct connman_dhcp *dhcp = user_data; char *address, *netmask; struct connman_service *service; struct connman_ipconfig *ipconfig; unsigned char prefixlen; DBG("IPV4LL available"); service = __connman_service_lookup_from_network(dhcp->network); if (service == NULL) return; ipconfig = __connman_service_get_ip4config(service); if (ipconfig == NULL) return; address = g_dhcp_client_get_address(dhcp_client); netmask = g_dhcp_client_get_netmask(dhcp_client); prefixlen = __connman_ipconfig_netmask_prefix_len(netmask); connman_ipconfig_set_method(ipconfig, CONNMAN_IPCONFIG_METHOD_DHCP); __connman_ipconfig_set_local(ipconfig, address); __connman_ipconfig_set_prefixlen(ipconfig, prefixlen); __connman_ipconfig_set_gateway(ipconfig, NULL); dhcp_valid(dhcp); g_free(address); g_free(netmask); }
static void add_default_route(struct connman_session *session) { struct connman_ipconfig *ipconfig; int err; struct in_addr addr = { INADDR_ANY }; if (!session->service) return; ipconfig = __connman_service_get_ip4config(session->service); session->index = __connman_ipconfig_get_index(ipconfig); session->gateway = g_strdup(__connman_ipconfig_get_gateway(ipconfig)); if (!session->gateway) session->gateway = g_strdup(inet_ntoa(addr)); session->prefixlen = __connman_ipconfig_get_prefixlen(ipconfig); DBG("index %d routing table %d default gateway %s/%u", session->index, session->mark, session->gateway, session->prefixlen); err = __connman_inet_add_default_to_table(session->mark, session->index, session->gateway); if (err < 0) DBG("session %p %s", session, strerror(-err)); err = __connman_inet_add_subnet_to_table(session->mark, session->index, session->gateway, session->prefixlen); if (err < 0) DBG("session add subnet route %p %s", session, strerror(-err)); }
static int dhcp_request(struct connman_dhcp *dhcp) { struct connman_service *service; struct connman_ipconfig *ipconfig; GDHCPClient *dhcp_client; GDHCPClientError error; const char *hostname; int index; DBG("dhcp %p", dhcp); index = connman_network_get_index(dhcp->network); dhcp_client = g_dhcp_client_new(G_DHCP_IPV4, index, &error); if (error != G_DHCP_CLIENT_ERROR_NONE) return -EINVAL; if (getenv("CONNMAN_DHCP_DEBUG")) g_dhcp_client_set_debug(dhcp_client, dhcp_debug, "DHCP"); hostname = connman_utsname_get_hostname(); if (hostname != NULL) g_dhcp_client_set_send(dhcp_client, G_DHCP_HOST_NAME, hostname); g_dhcp_client_set_request(dhcp_client, G_DHCP_HOST_NAME); g_dhcp_client_set_request(dhcp_client, G_DHCP_SUBNET); g_dhcp_client_set_request(dhcp_client, G_DHCP_DNS_SERVER); g_dhcp_client_set_request(dhcp_client, G_DHCP_DOMAIN_NAME); g_dhcp_client_set_request(dhcp_client, G_DHCP_NTP_SERVER); g_dhcp_client_set_request(dhcp_client, G_DHCP_ROUTER); g_dhcp_client_set_request(dhcp_client, 252); g_dhcp_client_register_event(dhcp_client, G_DHCP_CLIENT_EVENT_LEASE_AVAILABLE, lease_available_cb, dhcp); g_dhcp_client_register_event(dhcp_client, G_DHCP_CLIENT_EVENT_IPV4LL_AVAILABLE, ipv4ll_available_cb, dhcp); g_dhcp_client_register_event(dhcp_client, G_DHCP_CLIENT_EVENT_LEASE_LOST, lease_lost_cb, dhcp); g_dhcp_client_register_event(dhcp_client, G_DHCP_CLIENT_EVENT_IPV4LL_LOST, ipv4ll_lost_cb, dhcp); g_dhcp_client_register_event(dhcp_client, G_DHCP_CLIENT_EVENT_NO_LEASE, no_lease_cb, dhcp); dhcp->dhcp_client = dhcp_client; service = __connman_service_lookup_from_network(dhcp->network); ipconfig = __connman_service_get_ip4config(service); return g_dhcp_client_start(dhcp_client, __connman_ipconfig_get_dhcp_address(ipconfig)); }
static void ipv4ll_available_cb(GDHCPClient *dhcp_client, gpointer user_data) { struct connman_dhcp *dhcp = user_data; char *address, *netmask; struct connman_service *service; struct connman_ipconfig *ipconfig; unsigned char prefixlen; DBG("IPV4LL available"); #if defined TIZEN_EXT /* * Description: When DHCP is failed, * most of naive users cannot understand auto-generated IP * (IPV4 link local) and serious troubles to make Internet connection. */ dhcp_invalidate(dhcp, TRUE); service = __connman_service_lookup_from_network(dhcp->network); if (service == NULL) return; __connman_service_ipconfig_indicate_state(service, CONNMAN_SERVICE_STATE_IDLE, CONNMAN_IPCONFIG_TYPE_IPV4); __connman_service_ipconfig_indicate_state(service, CONNMAN_SERVICE_STATE_IDLE, CONNMAN_IPCONFIG_TYPE_IPV6); return; #endif service = __connman_service_lookup_from_network(dhcp->network); if (service == NULL) return; ipconfig = __connman_service_get_ip4config(service); if (ipconfig == NULL) return; address = g_dhcp_client_get_address(dhcp_client); netmask = g_dhcp_client_get_netmask(dhcp_client); prefixlen = __connman_ipconfig_netmask_prefix_len(netmask); connman_ipconfig_set_method(ipconfig, CONNMAN_IPCONFIG_METHOD_DHCP); __connman_ipconfig_set_local(ipconfig, address); __connman_ipconfig_set_prefixlen(ipconfig, prefixlen); __connman_ipconfig_set_gateway(ipconfig, NULL); dhcp_valid(dhcp); g_free(address); g_free(netmask); }
/** * dhcp_invalidate: Invalidate an existing DHCP lease * @dhcp: pointer to the DHCP lease to invalidate. * @callback: flag indicating whether or not to invoke the client callback * if present. * * Invalidates an existing DHCP lease, optionally invoking the client * callback. The caller may wish to avoid the client callback invocation * when the invocation of that callback might otherwise unnecessarily upset * service state due to the IP configuration change implied by this * invalidation. */ static void dhcp_invalidate(struct connman_dhcp *dhcp, connman_bool_t callback) { struct connman_service *service; struct connman_ipconfig *ipconfig; int i; DBG("dhcp %p callback %u", dhcp, callback); if (dhcp == NULL) return; service = connman_service_lookup_from_network(dhcp->network); if (service == NULL) goto out; ipconfig = __connman_service_get_ip4config(service); if (ipconfig == NULL) goto out; __connman_6to4_remove(ipconfig); __connman_service_set_domainname(service, NULL); __connman_service_set_pac(service, NULL); if (dhcp->timeservers != NULL) { for (i = 0; dhcp->timeservers[i] != NULL; i++) { __connman_service_timeserver_remove(service, dhcp->timeservers[i]); } } if (dhcp->nameservers != NULL) { for (i = 0; dhcp->nameservers[i] != NULL; i++) { __connman_service_nameserver_remove(service, dhcp->nameservers[i], FALSE); } } __connman_ipconfig_set_dhcp_address(ipconfig, __connman_ipconfig_get_local(ipconfig)); DBG("last address %s", __connman_ipconfig_get_dhcp_address(ipconfig)); __connman_ipconfig_address_remove(ipconfig); __connman_ipconfig_set_local(ipconfig, NULL); __connman_ipconfig_set_broadcast(ipconfig, NULL); __connman_ipconfig_set_gateway(ipconfig, NULL); __connman_ipconfig_set_prefixlen(ipconfig, 0); if (dhcp->callback != NULL && callback) dhcp->callback(dhcp->network, FALSE, NULL); out: dhcp_free(dhcp); }
/** * connman_network_set_index: * @network: network structure * @index: index number * * Set index number of network */ void connman_network_set_index(struct connman_network *network, int index) { struct connman_service *service; struct connman_ipconfig *ipconfig; service = __connman_service_lookup_from_network(network); if (service == NULL) goto done; ipconfig = __connman_service_get_ip4config(service); DBG("index %d service %p ip4config %p", network->index, service, ipconfig); if (network->index < 0 && ipconfig == NULL) { ipconfig = __connman_service_get_ip4config(service); if (ipconfig == NULL) /* * This is needed for plugins that havent set their * ipconfig layer yet, due to not being able to get * a network index prior to creating a service. */ __connman_service_create_ip4config(service, index); else __connman_ipconfig_set_index(ipconfig, index); } else { /* If index changed, the index of ipconfig must be reset. */ if (ipconfig == NULL) goto done; __connman_ipconfig_set_index(ipconfig, index); } done: network->index = index; }
void connman_network_set_ipv4_method(struct connman_network *network, enum connman_ipconfig_method method) { struct connman_service *service; struct connman_ipconfig *ipconfig; service = __connman_service_lookup_from_network(network); if (service == NULL) return; ipconfig = __connman_service_get_ip4config(service); if (ipconfig == NULL) return; connman_ipconfig_set_method(ipconfig, method); }
static void append_ipconfig_ipv4(DBusMessageIter *iter, void *user_data) { struct connman_service *service = user_data; struct connman_ipconfig *ipconfig_ipv4; if (!service) return; if (!__connman_service_is_connected_state(service, CONNMAN_IPCONFIG_TYPE_IPV4)) return; ipconfig_ipv4 = __connman_service_get_ip4config(service); if (!ipconfig_ipv4) return; __connman_ipconfig_append_ipv4(ipconfig_ipv4, iter); }
const char *connman_network_get_ifname(struct connman_network *network) { struct connman_service *service; struct connman_ipconfig *ipconfig; const char *ifname = NULL; service = __connman_service_lookup_from_network(network); if (service == NULL) return NULL; ipconfig = __connman_service_get_ip4config(service); if (ipconfig != NULL) ifname = connman_ipconfig_get_ifname(ipconfig); DBG("index %d, service %p ip4config %p ifname %s", network->index, service, ipconfig, ifname); return ifname; }
static void set_connected_manual(struct connman_network *network) { struct connman_service *service; struct connman_ipconfig *ipconfig; int err; DBG("network %p", network); service = __connman_service_lookup_from_network(network); ipconfig = __connman_service_get_ip4config(service); if (__connman_ipconfig_get_local(ipconfig) == NULL) __connman_service_read_ip4config(service); set_configuration(network); err = __connman_ipconfig_address_add(ipconfig); if (err < 0) goto err; #if defined TIZEN_EXT /* * Description: __connman_service_lookup_from_index cannot find correct service */ err = __connman_ipconfig_gateway_add(ipconfig, service); #else err = __connman_ipconfig_gateway_add(ipconfig); #endif if (err < 0) goto err; network->connecting = FALSE; connman_network_set_associating(network, FALSE); return; err: connman_network_set_error(network, CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL); return; }
static void add_default_route(struct connman_session *session) { struct connman_ipconfig *ipconfig; int err; if (!session->service) return; ipconfig = __connman_service_get_ip4config(session->service); session->index = __connman_ipconfig_get_index(ipconfig); session->gateway = g_strdup(__connman_ipconfig_get_gateway(ipconfig)); DBG("index %d routing table %d default gateway %s", session->index, session->mark, session->gateway); err = __connman_inet_add_default_to_table(session->mark, session->index, session->gateway); if (err < 0) DBG("session %p %s", session, strerror(-err)); }
static void append_ipconfig_ipv6(DBusMessageIter *iter, void *user_data) { struct connman_service *service = user_data; struct connman_ipconfig *ipconfig_ipv4, *ipconfig_ipv6; if (service == NULL) return; if (__connman_service_is_connected_state(service, CONNMAN_IPCONFIG_TYPE_IPV6) == FALSE) { return; } ipconfig_ipv4 = __connman_service_get_ip4config(service); ipconfig_ipv6 = __connman_service_get_ip6config(service); if (ipconfig_ipv6 == NULL) return; __connman_ipconfig_append_ipv6(ipconfig_ipv6, iter, ipconfig_ipv4); }
static int set_connected_fixed(struct connman_network *network) { struct connman_service *service; struct connman_ipconfig *ipconfig_ipv4; int err; DBG(""); service = __connman_service_lookup_from_network(network); ipconfig_ipv4 = __connman_service_get_ip4config(service); set_configuration(network); network->connecting = FALSE; connman_network_set_associating(network, FALSE); err = __connman_ipconfig_address_add(ipconfig_ipv4); if (err < 0) goto err; #if defined TIZEN_EXT /* * Description: __connman_service_lookup_from_index cannot find correct service */ err = __connman_ipconfig_gateway_add(ipconfig_ipv4, service); #else err = __connman_ipconfig_gateway_add(ipconfig_ipv4); #endif if (err < 0) goto err; return 0; err: connman_network_set_error(network, CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL); return err; }
static int init_firewall_session(struct connman_session *session) { struct firewall_context *fw; int err; struct connman_ipconfig *ipconfig = NULL; const char *addr = NULL; if (session->policy_config->id_type == CONNMAN_SESSION_ID_TYPE_UNKNOWN && !session->info->config.source_ip_rule) return 0; DBG(""); if (session->info->config.source_ip_rule) { ipconfig = __connman_service_get_ip4config(session->service); if (session->policy_config->id_type == CONNMAN_SESSION_ID_TYPE_UNKNOWN && !ipconfig) return 0; } fw = __connman_firewall_create(); if (!fw) return -ENOMEM; if (session->info->config.source_ip_rule && ipconfig) { addr = __connman_ipconfig_get_local(ipconfig); } err =__connman_firewall_enable_marking(fw, session->policy_config->id_type, session->policy_config->id, addr, session->mark); if (err < 0) { __connman_firewall_destroy(fw); return err; } session->id_type = session->policy_config->id_type; session->fw = fw; return 0; }
static void add_nat_rules(struct connman_session *session) { struct connman_ipconfig *ipconfig; struct fw_snat *fw_snat; const char *addr; int index, err; char *ifname; if (!session->service) return; ipconfig = __connman_service_get_ip4config(session->service); index = __connman_ipconfig_get_index(ipconfig); ifname = connman_inet_ifname(index); addr = __connman_ipconfig_get_local(ipconfig); if (!addr) return; g_free(session->addr); session->addr = g_strdup(addr); session->snat_enabled = true; fw_snat = fw_snat_lookup(index, session->addr); if (fw_snat) { fw_snat_ref(session, fw_snat); return; } err = fw_snat_create(session, index, ifname, addr); if (err < 0) { DBG("failed to add SNAT rule"); session->snat_enabled = false; } g_free(ifname); }
static gboolean set_connected(gpointer user_data) { struct connman_network *network = user_data; struct connman_service *service; struct connman_ipconfig *ipconfig_ipv4, *ipconfig_ipv6; enum connman_ipconfig_method ipv4_method, ipv6_method; service = __connman_service_lookup_from_network(network); ipconfig_ipv4 = __connman_service_get_ip4config(service); ipconfig_ipv6 = __connman_service_get_ip6config(service); DBG("service %p ipv4 %p ipv6 %p", service, ipconfig_ipv4, ipconfig_ipv6); ipv4_method = __connman_ipconfig_get_method(ipconfig_ipv4); ipv6_method = __connman_ipconfig_get_method(ipconfig_ipv6); DBG("method ipv4 %d ipv6 %d", ipv4_method, ipv6_method); DBG("network connected %d", network->connected); if (network->connected == TRUE) { int ret; switch (ipv6_method) { case CONNMAN_IPCONFIG_METHOD_UNKNOWN: case CONNMAN_IPCONFIG_METHOD_OFF: break; case CONNMAN_IPCONFIG_METHOD_AUTO: autoconf_ipv6_set(network); break; case CONNMAN_IPCONFIG_METHOD_FIXED: case CONNMAN_IPCONFIG_METHOD_MANUAL: ret = manual_ipv6_set(network, ipconfig_ipv6); if (ret != 0) { connman_network_set_error(network, CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL); return FALSE; } break; case CONNMAN_IPCONFIG_METHOD_DHCP: break; } switch (ipv4_method) { case CONNMAN_IPCONFIG_METHOD_UNKNOWN: case CONNMAN_IPCONFIG_METHOD_OFF: case CONNMAN_IPCONFIG_METHOD_AUTO: return FALSE; case CONNMAN_IPCONFIG_METHOD_FIXED: if (set_connected_fixed(network) < 0) { connman_network_set_error(network, CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL); return FALSE; } return TRUE; case CONNMAN_IPCONFIG_METHOD_MANUAL: set_connected_manual(network); return TRUE; case CONNMAN_IPCONFIG_METHOD_DHCP: if (set_connected_dhcp(network) < 0) { connman_network_set_error(network, CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL); return FALSE; } } } else { enum connman_service_state state; __connman_device_set_network(network->device, NULL); switch (ipv4_method) { case CONNMAN_IPCONFIG_METHOD_UNKNOWN: case CONNMAN_IPCONFIG_METHOD_OFF: case CONNMAN_IPCONFIG_METHOD_AUTO: case CONNMAN_IPCONFIG_METHOD_FIXED: case CONNMAN_IPCONFIG_METHOD_MANUAL: break; case CONNMAN_IPCONFIG_METHOD_DHCP: __connman_dhcp_stop(network); break; } /* * We only set the disconnect state if we were not in idle * or in failure. It does not make sense to go to disconnect * state if we were not connected. */ state = __connman_service_ipconfig_get_state(service, CONNMAN_IPCONFIG_TYPE_IPV4); if (state != CONNMAN_SERVICE_STATE_IDLE && state != CONNMAN_SERVICE_STATE_FAILURE) __connman_service_ipconfig_indicate_state(service, CONNMAN_SERVICE_STATE_DISCONNECT, CONNMAN_IPCONFIG_TYPE_IPV4); state = __connman_service_ipconfig_get_state(service, CONNMAN_IPCONFIG_TYPE_IPV6); if (state != CONNMAN_SERVICE_STATE_IDLE && state != CONNMAN_SERVICE_STATE_FAILURE) __connman_service_ipconfig_indicate_state(service, CONNMAN_SERVICE_STATE_DISCONNECT, CONNMAN_IPCONFIG_TYPE_IPV6); __connman_connection_gateway_remove(service, CONNMAN_IPCONFIG_TYPE_ALL); __connman_ipconfig_address_unset(ipconfig_ipv4); __connman_ipconfig_address_unset(ipconfig_ipv6); /* * Special handling for IPv6 autoconfigured address. * The simplest way to remove autoconfigured routes is to * disable IPv6 temporarily so that kernel will do the cleanup * automagically. */ if (ipv6_method == CONNMAN_IPCONFIG_METHOD_AUTO) { __connman_ipconfig_disable_ipv6(ipconfig_ipv6); __connman_ipconfig_enable_ipv6(ipconfig_ipv6); } #if defined TIZEN_EXT if (connman_service_get_type(service) == CONNMAN_SERVICE_TYPE_CELLULAR) { network->connecting = FALSE; connman_network_set_associating(network, FALSE); } #endif __connman_service_ipconfig_indicate_state(service, CONNMAN_SERVICE_STATE_IDLE, CONNMAN_IPCONFIG_TYPE_IPV4); __connman_service_ipconfig_indicate_state(service, CONNMAN_SERVICE_STATE_IDLE, CONNMAN_IPCONFIG_TYPE_IPV6); #if defined TIZEN_EXT if (connman_service_get_type(service) == CONNMAN_SERVICE_TYPE_CELLULAR) return FALSE; #endif } network->connecting = FALSE; connman_network_set_associating(network, FALSE); return FALSE; }
static void set_vpn_routes(struct gateway_data *new_gateway, struct connman_service *service, const char *gateway, enum connman_ipconfig_type type, const char *peer, struct gateway_data *active_gateway) { struct gateway_config *config; struct connman_ipconfig *ipconfig; char *dest; DBG("new %p service %p gw %s type %d peer %s active %p", new_gateway, service, gateway, type, peer, active_gateway); if (type == CONNMAN_IPCONFIG_TYPE_IPV4) { ipconfig = __connman_service_get_ip4config(service); config = new_gateway->ipv4_gateway; } else if (type == CONNMAN_IPCONFIG_TYPE_IPV6) { ipconfig = __connman_service_get_ip6config(service); config = new_gateway->ipv6_gateway; } else return; if (config) { int index = __connman_ipconfig_get_index(ipconfig); struct get_gateway_params *params; config->vpn = true; if (peer) config->vpn_ip = g_strdup(peer); else if (gateway) config->vpn_ip = g_strdup(gateway); params = g_try_malloc(sizeof(struct get_gateway_params)); if (!params) return; params->vpn_index = index; params->vpn_gateway = g_strdup(gateway); /* * Find the gateway that is serving the VPN link */ __connman_inet_get_route(gateway, get_gateway_cb, params); } if (!active_gateway) return; if (type == CONNMAN_IPCONFIG_TYPE_IPV4) { /* * Special route to VPN server via gateway. This * is needed so that we can access hosts behind * the VPN. The route might already exist depending * on network topology. */ if (!active_gateway->ipv4_gateway) return; DBG("active gw %s", active_gateway->ipv4_gateway->gateway); if (g_strcmp0(active_gateway->ipv4_gateway->gateway, "0.0.0.0") != 0) dest = active_gateway->ipv4_gateway->gateway; else dest = NULL; connman_inet_add_host_route(active_gateway->index, gateway, dest); } else if (type == CONNMAN_IPCONFIG_TYPE_IPV6) { if (!active_gateway->ipv6_gateway) return; DBG("active gw %s", active_gateway->ipv6_gateway->gateway); if (g_strcmp0(active_gateway->ipv6_gateway->gateway, "::") != 0) dest = active_gateway->ipv6_gateway->gateway; else dest = NULL; connman_inet_add_ipv6_host_route(active_gateway->index, gateway, dest); } }
static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data) { struct connman_dhcp *dhcp = user_data; GList *list, *option = NULL; char *address, *netmask = NULL, *gateway = NULL; const char *c_address, *c_gateway; char *domainname = NULL, *hostname = NULL; char **nameservers, *timeserver = NULL, *pac = NULL; int ns_entries; struct connman_ipconfig *ipconfig; struct connman_service *service; unsigned char prefixlen, c_prefixlen; gboolean ip_change; int i; DBG("Lease available"); service = __connman_service_lookup_from_network(dhcp->network); if (service == NULL) { connman_error("Can not lookup service"); return; } ipconfig = __connman_service_get_ip4config(service); if (ipconfig == NULL) { connman_error("Could not lookup ipconfig"); return; } c_address = __connman_ipconfig_get_local(ipconfig); c_gateway = __connman_ipconfig_get_gateway(ipconfig); c_prefixlen = __connman_ipconfig_get_prefixlen(ipconfig); address = g_dhcp_client_get_address(dhcp_client); __connman_ipconfig_set_dhcp_address(ipconfig, address); DBG("last address %s", address); option = g_dhcp_client_get_option(dhcp_client, G_DHCP_SUBNET); if (option != NULL) netmask = g_strdup(option->data); option = g_dhcp_client_get_option(dhcp_client, G_DHCP_ROUTER); if (option != NULL) gateway = g_strdup(option->data); prefixlen = __connman_ipconfig_netmask_prefix_len(netmask); DBG("c_address %s", c_address); if (address != NULL && c_address != NULL && g_strcmp0(address, c_address) != 0) ip_change = TRUE; else if (gateway != NULL && c_gateway != NULL && g_strcmp0(gateway, c_gateway) != 0) ip_change = TRUE; else if (prefixlen != c_prefixlen) ip_change = TRUE; else if (c_address == NULL || c_gateway == NULL) ip_change = TRUE; else ip_change = FALSE; option = g_dhcp_client_get_option(dhcp_client, G_DHCP_DNS_SERVER); for (ns_entries = 0, list = option; list; list = list->next) ns_entries += 1; nameservers = g_try_new0(char *, ns_entries + 1); if (nameservers != NULL) { for (i = 0, list = option; list; list = list->next, i++) nameservers[i] = g_strdup(list->data); nameservers[ns_entries] = NULL; } option = g_dhcp_client_get_option(dhcp_client, G_DHCP_DOMAIN_NAME); if (option != NULL) domainname = g_strdup(option->data); option = g_dhcp_client_get_option(dhcp_client, G_DHCP_HOST_NAME); if (option != NULL) hostname = g_strdup(option->data); option = g_dhcp_client_get_option(dhcp_client, G_DHCP_NTP_SERVER); if (option != NULL) timeserver = g_strdup(option->data); option = g_dhcp_client_get_option(dhcp_client, 252); if (option != NULL) pac = g_strdup(option->data); connman_ipconfig_set_method(ipconfig, CONNMAN_IPCONFIG_METHOD_DHCP); if (ip_change == TRUE) { __connman_ipconfig_set_local(ipconfig, address); __connman_ipconfig_set_prefixlen(ipconfig, prefixlen); __connman_ipconfig_set_gateway(ipconfig, gateway); } if (compare_string_arrays(nameservers, dhcp->nameservers) == FALSE) { if (dhcp->nameservers != NULL) { for (i = 0; dhcp->nameservers[i] != NULL; i++) { __connman_service_nameserver_remove(service, dhcp->nameservers[i]); } g_strfreev(dhcp->nameservers); } dhcp->nameservers = nameservers; for (i = 0; dhcp->nameservers[i] != NULL; i++) { __connman_service_nameserver_append(service, dhcp->nameservers[i]); } } else { g_strfreev(nameservers); } if (g_strcmp0(timeserver, dhcp->timeserver) != 0) { if (dhcp->timeserver != NULL) { __connman_service_timeserver_remove(service, dhcp->timeserver); g_free(dhcp->timeserver); } dhcp->timeserver = timeserver; if (dhcp->timeserver != NULL) __connman_service_timeserver_append(service, dhcp->timeserver); } if (g_strcmp0(pac, dhcp->pac) != 0) { g_free(dhcp->pac); dhcp->pac = pac; __connman_service_set_pac(service, dhcp->pac); } __connman_service_set_domainname(service, domainname); if (domainname != NULL) __connman_utsname_set_domainname(domainname); if (hostname != NULL) __connman_utsname_set_hostname(hostname); if (ip_change == TRUE) dhcp_valid(dhcp); __connman_6to4_probe(service); g_free(address); g_free(netmask); g_free(gateway); g_free(domainname); g_free(hostname); }