Thus dhcp code will be usable in peer, where there is no service nor
network objects.
---
src/connman.h | 8 +-
src/dhcp.c | 368 ++++++++++++++++++++++++++++++----------------------------
src/network.c | 19 ++-
3 files changed, 208 insertions(+), 187 deletions(-)
diff --git a/src/connman.h b/src/connman.h
index f286b12..111eea0 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -433,10 +433,12 @@ enum __connman_dhcpv6_status {
typedef void (* dhcpv6_cb) (struct connman_network *network,
enum __connman_dhcpv6_status status, gpointer data);
-typedef void (* dhcp_cb) (struct connman_network *network,
+typedef void (* dhcp_cb) (struct connman_ipconfig *ipconfig,
+ struct connman_network *opt_network,
bool success, gpointer data);
-int __connman_dhcp_start(struct connman_network *network, dhcp_cb callback);
-void __connman_dhcp_stop(struct connman_network *network);
+int __connman_dhcp_start(struct connman_ipconfig *ipconfig,
+ struct connman_network *network, dhcp_cb callback);
+void __connman_dhcp_stop(struct connman_ipconfig *ipconfig);
int __connman_dhcp_init(void);
void __connman_dhcp_cleanup(void);
int __connman_dhcpv6_init(void);
diff --git a/src/dhcp.c b/src/dhcp.c
index 3cacb6a..bfaae75 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -39,6 +39,7 @@
#define RATE_LIMIT_INTERVAL 60 /* delay between successive attempts */
struct connman_dhcp {
+ struct connman_ipconfig *ipconfig;
struct connman_network *network;
dhcp_cb callback;
@@ -54,7 +55,7 @@ struct connman_dhcp {
char *dhcp_debug_prefix;
};
-static GHashTable *network_table;
+static GHashTable *ipconfig_table;
static bool ipv4ll_running;
static void dhcp_free(struct connman_dhcp *dhcp)
@@ -84,41 +85,22 @@ static void ipv4ll_stop_client(struct connman_dhcp *dhcp)
dhcp->ipv4ll_debug_prefix = NULL;
}
-/**
- * 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, bool callback)
+static bool apply_dhcp_invalidate_on_network(struct connman_dhcp *dhcp)
{
struct connman_service *service;
- struct connman_ipconfig *ipconfig;
int i;
- DBG("dhcp %p callback %u", dhcp, callback);
-
- if (!dhcp)
- return;
+ if (!dhcp->network)
+ return true;
service = connman_service_lookup_from_network(dhcp->network);
- if (!service)
- return;
-
- ipconfig = __connman_service_get_ip4config(service);
- if (!ipconfig)
- return;
-
- __connman_6to4_remove(ipconfig);
+ if (!service) {
+ connman_error("Can not lookup service");
+ return false;
+ }
__connman_service_set_domainname(service, NULL);
- __connman_ipconfig_set_proxy_autoconfig(ipconfig, NULL);
+ __connman_ipconfig_set_proxy_autoconfig(dhcp->ipconfig, NULL);
if (dhcp->timeservers) {
for (i = 0; dhcp->timeservers[i]; i++) {
@@ -126,7 +108,6 @@ static void dhcp_invalidate(struct connman_dhcp *dhcp, bool
callback)
dhcp->timeservers[i]);
}
}
-
if (dhcp->nameservers) {
for (i = 0; dhcp->nameservers[i]; i++) {
__connman_service_nameserver_remove(service,
@@ -134,25 +115,53 @@ static void dhcp_invalidate(struct connman_dhcp *dhcp,
bool callback)
}
}
- __connman_ipconfig_set_dhcp_address(ipconfig,
- __connman_ipconfig_get_local(ipconfig));
- DBG("last address %s", __connman_ipconfig_get_dhcp_address(ipconfig));
+ return true;
+}
+
+/**
+ * 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, bool callback)
+{
+ DBG("dhcp %p callback %u", dhcp, callback);
+
+ if (!dhcp)
+ return;
+
+ __connman_6to4_remove(dhcp->ipconfig);
- __connman_ipconfig_address_remove(ipconfig);
+ if (!apply_dhcp_invalidate_on_network(dhcp))
+ return;
+
+ __connman_ipconfig_set_dhcp_address(dhcp->ipconfig,
+ __connman_ipconfig_get_local(dhcp->ipconfig));
+ DBG("last address %s",
+ __connman_ipconfig_get_dhcp_address(dhcp->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);
+ __connman_ipconfig_address_remove(dhcp->ipconfig);
+
+ __connman_ipconfig_set_local(dhcp->ipconfig, NULL);
+ __connman_ipconfig_set_broadcast(dhcp->ipconfig, NULL);
+ __connman_ipconfig_set_gateway(dhcp->ipconfig, NULL);
+ __connman_ipconfig_set_prefixlen(dhcp->ipconfig, 0);
if (dhcp->callback && callback)
- dhcp->callback(dhcp->network, false, NULL);
+ dhcp->callback(dhcp->ipconfig, dhcp->network, false, NULL);
}
static void dhcp_valid(struct connman_dhcp *dhcp)
{
if (dhcp->callback)
- dhcp->callback(dhcp->network, true, NULL);
+ dhcp->callback(dhcp->ipconfig, dhcp->network, true, NULL);
}
static void dhcp_debug(const char *str, void *data)
@@ -174,7 +183,7 @@ static int ipv4ll_start_client(struct connman_dhcp *dhcp)
if (dhcp->ipv4ll_client)
return -EALREADY;
- index = connman_network_get_index(dhcp->network);
+ index = __connman_ipconfig_get_index(dhcp->ipconfig);
ipv4ll_client = g_dhcp_client_new(G_DHCP_IPV4LL, index, &error);
if (error != G_DHCP_CLIENT_ERROR_NONE)
@@ -189,10 +198,12 @@ static int ipv4ll_start_client(struct connman_dhcp *dhcp)
g_dhcp_client_set_id(ipv4ll_client);
- hostname = connman_utsname_get_hostname();
- if (hostname)
- g_dhcp_client_set_send(ipv4ll_client, G_DHCP_HOST_NAME,
- hostname);
+ if (dhcp->network) {
+ hostname = connman_utsname_get_hostname();
+ if (hostname)
+ g_dhcp_client_set_send(ipv4ll_client,
+ G_DHCP_HOST_NAME, hostname);
+ }
g_dhcp_client_register_event(ipv4ll_client,
G_DHCP_CLIENT_EVENT_IPV4LL_LOST, ipv4ll_lost_cb, dhcp);
@@ -216,19 +227,11 @@ static int ipv4ll_start_client(struct connman_dhcp *dhcp)
static gboolean dhcp_retry_cb(gpointer user_data)
{
struct connman_dhcp *dhcp = user_data;
- struct connman_service *service;
- struct connman_ipconfig *ipconfig;
dhcp->timeout = 0;
- service = connman_service_lookup_from_network(dhcp->network);
- if (!service)
- return FALSE;
-
- ipconfig = __connman_service_get_ip4config(service);
-
g_dhcp_client_start(dhcp->dhcp_client,
- __connman_ipconfig_get_dhcp_address(ipconfig));
+ __connman_ipconfig_get_dhcp_address(dhcp->ipconfig));
return FALSE;
}
@@ -299,78 +302,30 @@ static bool compare_string_arrays(char **array_a, char
**array_b)
return true;
}
-static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data)
+static bool apply_lease_available_on_network(GDHCPClient *dhcp_client,
+ struct connman_dhcp *dhcp)
{
- struct connman_dhcp *dhcp = user_data;
- GList *list, *option = NULL;
- char *address, *netmask = NULL, *gateway = NULL;
- const char *c_address, *c_gateway;
char **nameservers, **timeservers, *pac = NULL;
- int ns_entries;
- struct connman_ipconfig *ipconfig;
struct connman_service *service;
- unsigned char prefixlen, c_prefixlen;
- bool ip_change;
+ GList *list, *option = NULL;
+ int ns_entries;
int i;
- DBG("Lease available");
-
- if (dhcp->ipv4ll_client) {
- ipv4ll_stop_client(dhcp);
- dhcp_invalidate(dhcp, false);
- }
-
service = connman_service_lookup_from_network(dhcp->network);
if (!service) {
connman_error("Can not lookup service");
- return;
- }
-
- ipconfig = __connman_service_get_ip4config(service);
- if (!ipconfig) {
- connman_error("Could not lookup ipconfig");
- return;
+ return false;
}
- 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)
- netmask = g_strdup(option->data);
-
- option = g_dhcp_client_get_option(dhcp_client, G_DHCP_ROUTER);
+ option = g_dhcp_client_get_option(dhcp_client, 252);
if (option)
- gateway = g_strdup(option->data);
-
- prefixlen = connman_ipaddress_calc_netmask_len(netmask);
- if (prefixlen == 255)
- connman_warn("netmask: %s is invalid", netmask);
-
- DBG("c_address %s", c_address);
-
- if (address && c_address && g_strcmp0(address, c_address) != 0)
- ip_change = true;
- else if (gateway && c_gateway && g_strcmp0(gateway, c_gateway) != 0)
- ip_change = true;
- else if (prefixlen != c_prefixlen)
- ip_change = true;
- else if (!c_address || !c_gateway)
- ip_change = true;
- else
- ip_change = false;
+ pac = g_strdup(option->data);
option = g_dhcp_client_get_option(dhcp_client, G_DHCP_DNS_SERVER);
ns_entries = g_list_length(option);
nameservers = g_try_new0(char *, ns_entries + 1);
if (nameservers) {
- for (i = 0, list = option; list; list = list->next, i++)
+ for (i = 0, list = option;list; list = list->next, i++)
nameservers[i] = g_strdup(list->data);
nameservers[ns_entries] = NULL;
}
@@ -392,18 +347,6 @@ static void lease_available_cb(GDHCPClient *dhcp_client,
gpointer user_data)
timeservers[ns_entries] = NULL;
}
- option = g_dhcp_client_get_option(dhcp_client, 252);
- if (option)
- pac = g_strdup(option->data);
-
- __connman_ipconfig_set_method(ipconfig, CONNMAN_IPCONFIG_METHOD_DHCP);
-
- if (ip_change) {
- __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)) {
if (dhcp->nameservers) {
for (i = 0; dhcp->nameservers[i]; i++) {
@@ -415,8 +358,7 @@ static void lease_available_cb(GDHCPClient *dhcp_client,
gpointer user_data)
dhcp->nameservers = nameservers;
- for (i = 0; dhcp->nameservers &&
- dhcp->nameservers[i]; i++) {
+ for (i = 0; dhcp->nameservers && dhcp->nameservers[i]; i++) {
__connman_service_nameserver_append(service,
dhcp->nameservers[i], false);
}
@@ -435,8 +377,7 @@ static void lease_available_cb(GDHCPClient *dhcp_client,
gpointer user_data)
dhcp->timeservers = timeservers;
- for (i = 0; dhcp->timeservers &&
- dhcp->timeservers[i]; i++) {
+ for (i = 0; dhcp->timeservers && dhcp->timeservers[i]; i++) {
__connman_service_timeserver_append(service,
dhcp->timeservers[i]);
}
@@ -448,14 +389,79 @@ static void lease_available_cb(GDHCPClient *dhcp_client,
gpointer user_data)
g_free(dhcp->pac);
dhcp->pac = pac;
- __connman_ipconfig_set_proxy_autoconfig(ipconfig, dhcp->pac);
+ __connman_ipconfig_set_proxy_autoconfig(dhcp->ipconfig,
+ dhcp->pac);
+ }
+
+ __connman_6to4_probe(service);
+
+ return true;
+}
+
+static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data)
+{
+ struct connman_dhcp *dhcp = user_data;
+ GList *option = NULL;
+ char *address, *netmask = NULL, *gateway = NULL;
+ const char *c_address, *c_gateway;
+ unsigned char prefixlen, c_prefixlen;
+ bool ip_change;
+
+ DBG("Lease available");
+
+ if (dhcp->ipv4ll_client) {
+ ipv4ll_stop_client(dhcp);
+ dhcp_invalidate(dhcp, false);
+ }
+
+ c_address = __connman_ipconfig_get_local(dhcp->ipconfig);
+ c_gateway = __connman_ipconfig_get_gateway(dhcp->ipconfig);
+ c_prefixlen = __connman_ipconfig_get_prefixlen(dhcp->ipconfig);
+
+ address = g_dhcp_client_get_address(dhcp_client);
+
+ __connman_ipconfig_set_dhcp_address(dhcp->ipconfig, address);
+ DBG("last address %s", address);
+
+ option = g_dhcp_client_get_option(dhcp_client, G_DHCP_SUBNET);
+ if (option)
+ netmask = g_strdup(option->data);
+
+ option = g_dhcp_client_get_option(dhcp_client, G_DHCP_ROUTER);
+ if (option)
+ gateway = g_strdup(option->data);
+
+ prefixlen = connman_ipaddress_calc_netmask_len(netmask);
+ if (prefixlen == 255)
+ connman_warn("netmask: %s is invalid", netmask);
+
+ DBG("c_address %s", c_address);
+
+ if (address && c_address && g_strcmp0(address, c_address) != 0)
+ ip_change = true;
+ else if (gateway && c_gateway && g_strcmp0(gateway, c_gateway) != 0)
+ ip_change = true;
+ else if (prefixlen != c_prefixlen)
+ ip_change = true;
+ else if (!c_address || !c_gateway)
+ ip_change = true;
+ else
+ ip_change = false;
+
+ __connman_ipconfig_set_method(dhcp->ipconfig,
+ CONNMAN_IPCONFIG_METHOD_DHCP);
+ if (ip_change) {
+ __connman_ipconfig_set_local(dhcp->ipconfig, address);
+ __connman_ipconfig_set_prefixlen(dhcp->ipconfig, prefixlen);
+ __connman_ipconfig_set_gateway(dhcp->ipconfig, gateway);
}
+ if (!apply_lease_available_on_network(dhcp_client, dhcp))
+ return;
+
if (ip_change)
dhcp_valid(dhcp);
- __connman_6to4_probe(service);
-
g_free(address);
g_free(netmask);
g_free(gateway);
@@ -465,29 +471,20 @@ static void ipv4ll_available_cb(GDHCPClient
*ipv4ll_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)
- return;
-
- ipconfig = __connman_service_get_ip4config(service);
- if (!ipconfig)
- return;
-
address = g_dhcp_client_get_address(ipv4ll_client);
netmask = g_dhcp_client_get_netmask(ipv4ll_client);
prefixlen = connman_ipaddress_calc_netmask_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);
+ __connman_ipconfig_set_method(dhcp->ipconfig,
+ CONNMAN_IPCONFIG_METHOD_DHCP);
+ __connman_ipconfig_set_local(dhcp->ipconfig, address);
+ __connman_ipconfig_set_prefixlen(dhcp->ipconfig, prefixlen);
+ __connman_ipconfig_set_gateway(dhcp->ipconfig, NULL);
dhcp_valid(dhcp);
@@ -497,15 +494,13 @@ static void ipv4ll_available_cb(GDHCPClient
*ipv4ll_client, gpointer user_data)
static int dhcp_initialize(struct connman_dhcp *dhcp)
{
- struct connman_service *service;
GDHCPClient *dhcp_client;
GDHCPClientError error;
- const char *hostname;
int index;
DBG("dhcp %p", dhcp);
- index = connman_network_get_index(dhcp->network);
+ index = __connman_ipconfig_get_index(dhcp->ipconfig);
dhcp_client = g_dhcp_client_new(G_DHCP_IPV4, index, &error);
if (error != G_DHCP_CLIENT_ERROR_NONE)
@@ -520,22 +515,29 @@ static int dhcp_initialize(struct connman_dhcp *dhcp)
g_dhcp_client_set_id(dhcp_client);
- service = connman_service_lookup_from_network(dhcp->network);
+ if (dhcp->network) {
+ struct connman_service *service;
+ const char *hostname;
- hostname = __connman_service_get_hostname(service);
- if (!hostname)
- hostname = connman_utsname_get_hostname();
+ service = connman_service_lookup_from_network(dhcp->network);
+
+ hostname = __connman_service_get_hostname(service);
+ if (!hostname)
+ hostname = connman_utsname_get_hostname();
- if (hostname)
- g_dhcp_client_set_send(dhcp_client, G_DHCP_HOST_NAME, hostname);
+ if (hostname)
+ 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_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, 252);
+ }
- 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,
@@ -576,34 +578,40 @@ static int dhcp_release(struct connman_dhcp *dhcp)
return 0;
}
-int __connman_dhcp_start(struct connman_network *network, dhcp_cb callback)
+int __connman_dhcp_start(struct connman_ipconfig *ipconfig,
+ struct connman_network *network, dhcp_cb callback)
{
- struct connman_service *service;
- struct connman_ipconfig *ipconfig;
const char *last_addr = NULL;
struct connman_dhcp *dhcp;
DBG("");
- service = connman_service_lookup_from_network(network);
- if (!service)
- return -EINVAL;
+ if (network) {
+ struct connman_service *service;
+
+ service = connman_service_lookup_from_network(network);
+ if (!service)
+ return -EINVAL;
+ }
- ipconfig = __connman_service_get_ip4config(service);
- if (ipconfig)
- last_addr = __connman_ipconfig_get_dhcp_address(ipconfig);
+ last_addr = __connman_ipconfig_get_dhcp_address(ipconfig);
- dhcp = g_hash_table_lookup(network_table, network);
+ dhcp = g_hash_table_lookup(ipconfig_table, ipconfig);
if (!dhcp) {
dhcp = g_try_new0(struct connman_dhcp, 1);
if (!dhcp)
return -ENOMEM;
- dhcp->network = network;
- connman_network_ref(network);
+ dhcp->ipconfig = ipconfig;
+ __connman_ipconfig_ref(ipconfig);
+
+ if (network) {
+ dhcp->network = network;
+ connman_network_ref(network);
+ }
- g_hash_table_insert(network_table, network, dhcp);
+ g_hash_table_insert(ipconfig_table, ipconfig, dhcp);
dhcp_initialize(dhcp);
}
@@ -613,19 +621,21 @@ int __connman_dhcp_start(struct connman_network *network,
dhcp_cb callback)
return g_dhcp_client_start(dhcp->dhcp_client, last_addr);
}
-void __connman_dhcp_stop(struct connman_network *network)
+void __connman_dhcp_stop(struct connman_ipconfig *ipconfig)
{
struct connman_dhcp *dhcp;
- DBG("network_table %p network %p", network_table, network);
+ DBG("ipconfig_table %p ipconfig %p", ipconfig_table, ipconfig);
- if (!network_table)
+ if (!ipconfig_table)
return;
- dhcp = g_hash_table_lookup(network_table, network);
+ dhcp = g_hash_table_lookup(ipconfig_table, ipconfig);
if (dhcp) {
- g_hash_table_remove(network_table, network);
- connman_network_unref(network);
+ g_hash_table_remove(ipconfig_table, ipconfig);
+ __connman_ipconfig_unref(ipconfig);
+ if (dhcp->network)
+ connman_network_unref(dhcp->network);
dhcp_release(dhcp);
dhcp_invalidate(dhcp, false);
dhcp_free(dhcp);
@@ -636,8 +646,8 @@ int __connman_dhcp_init(void)
{
DBG("");
- network_table = g_hash_table_new_full(g_direct_hash, g_direct_equal,
- NULL, NULL);
+ ipconfig_table = g_hash_table_new_full(g_direct_hash, g_direct_equal,
+ NULL, NULL);
return 0;
}
@@ -646,6 +656,6 @@ void __connman_dhcp_cleanup(void)
{
DBG("");
- g_hash_table_destroy(network_table);
- network_table = NULL;
+ g_hash_table_destroy(ipconfig_table);
+ ipconfig_table = NULL;
}
diff --git a/src/network.c b/src/network.c
index 37f807c..4b5fb27 100644
--- a/src/network.c
+++ b/src/network.c
@@ -202,7 +202,8 @@ static void dhcp_failure(struct connman_network *network)
__connman_ipconfig_gateway_remove(ipconfig_ipv4);
}
-static void dhcp_callback(struct connman_network *network,
+static void dhcp_callback(struct connman_ipconfig *ipconfig,
+ struct connman_network *network,
bool success, gpointer data)
{
if (success)
@@ -285,13 +286,18 @@ err:
static int set_connected_dhcp(struct connman_network *network)
{
+ struct connman_service *service;
+ struct connman_ipconfig *ipconfig_ipv4;
int err;
DBG("network %p", network);
set_configuration(network, CONNMAN_IPCONFIG_TYPE_IPV4);
- err = __connman_dhcp_start(network, dhcp_callback);
+ service = connman_service_lookup_from_network(network);
+ ipconfig_ipv4 = __connman_service_get_ip4config(service);
+
+ err = __connman_dhcp_start(ipconfig_ipv4, network, dhcp_callback);
if (err < 0) {
connman_error("Can not request DHCP lease");
return err;
@@ -717,7 +723,7 @@ static void set_disconnected(struct connman_network
*network)
case CONNMAN_IPCONFIG_METHOD_MANUAL:
break;
case CONNMAN_IPCONFIG_METHOD_DHCP:
- __connman_dhcp_stop(network);
+ __connman_dhcp_stop(ipconfig_ipv4);
break;
}
}
@@ -1607,6 +1613,7 @@ int __connman_network_clear_ipconfig(struct
connman_network *network,
struct connman_ipconfig *ipconfig)
{
struct connman_service *service;
+ struct connman_ipconfig *ipconfig_ipv4;
enum connman_ipconfig_method method;
enum connman_ipconfig_type type;
@@ -1614,6 +1621,7 @@ int __connman_network_clear_ipconfig(struct
connman_network *network,
if (!service)
return -EINVAL;
+ ipconfig_ipv4 = __connman_service_get_ip4config(service);
method = __connman_ipconfig_get_method(ipconfig);
type = __connman_ipconfig_get_config_type(ipconfig);
@@ -1629,7 +1637,7 @@ int __connman_network_clear_ipconfig(struct
connman_network *network,
__connman_ipconfig_address_remove(ipconfig);
break;
case CONNMAN_IPCONFIG_METHOD_DHCP:
- __connman_dhcp_stop(network);
+ __connman_dhcp_stop(ipconfig_ipv4);
break;
}
@@ -1691,7 +1699,8 @@ int __connman_network_set_ipconfig(struct connman_network
*network,
case CONNMAN_IPCONFIG_METHOD_MANUAL:
return manual_ipv4_set(network, ipconfig_ipv4);
case CONNMAN_IPCONFIG_METHOD_DHCP:
- return __connman_dhcp_start(network, dhcp_callback);
+ return __connman_dhcp_start(ipconfig_ipv4,
+ network, dhcp_callback);
}
}
--
1.8.5.5
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman