projects
/
framework
/
connectivity
/
connman.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
main.conf: Add NetworkInterfaceBlacklist
[framework/connectivity/connman.git]
/
src
/
dhcpv6.c
diff --git
a/src/dhcpv6.c
b/src/dhcpv6.c
index
aab5868
..
574b19e
100644
(file)
--- a/
src/dhcpv6.c
+++ b/
src/dhcpv6.c
@@
-2,7
+2,7
@@
*
* Connection Manager
*
*
* Connection Manager
*
- * Copyright (C) 201
1
Intel Corporation. All rights reserved.
+ * Copyright (C) 201
2
Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@
-74,6
+74,14
@@
static GHashTable *network_table;
static int dhcpv6_request(struct connman_dhcpv6 *dhcp, gboolean add_addresses);
static int dhcpv6_request(struct connman_dhcpv6 *dhcp, gboolean add_addresses);
+static void clear_timer(struct connman_dhcpv6 *dhcp)
+{
+ if (dhcp->timeout > 0) {
+ g_source_remove(dhcp->timeout);
+ dhcp->timeout = 0;
+ }
+}
+
static inline float get_random()
{
return (rand() % 200 - 100) / 1000.0;
static inline float get_random()
{
return (rand() % 200 - 100) / 1000.0;
@@
-283,7
+291,8
@@
static void info_req_cb(GDHCPClient *dhcp_client, gpointer user_data)
dhcp->nameservers = nameservers;
dhcp->nameservers = nameservers;
- for (i = 0; dhcp->nameservers[i] != NULL; i++)
+ for (i = 0; dhcp->nameservers != NULL &&
+ dhcp->nameservers[i] != NULL; i++)
__connman_service_nameserver_append(service,
dhcp->nameservers[i],
FALSE);
__connman_service_nameserver_append(service,
dhcp->nameservers[i],
FALSE);
@@
-310,7
+319,8
@@
static void info_req_cb(GDHCPClient *dhcp_client, gpointer user_data)
dhcp->timeservers = timeservers;
dhcp->timeservers = timeservers;
- for (i = 0; dhcp->timeservers[i] != NULL; i++)
+ for (i = 0; dhcp->timeservers != NULL &&
+ dhcp->timeservers[i] != NULL; i++)
__connman_service_timeserver_append(service,
dhcp->timeservers[i]);
} else
__connman_service_timeserver_append(service,
dhcp->timeservers[i]);
} else
@@
-335,19
+345,27
@@
static int dhcpv6_info_request(struct connman_dhcpv6 *dhcp)
index = connman_network_get_index(dhcp->network);
dhcp_client = g_dhcp_client_new(G_DHCP_IPV6, index, &error);
index = connman_network_get_index(dhcp->network);
dhcp_client = g_dhcp_client_new(G_DHCP_IPV6, index, &error);
- if (error != G_DHCP_CLIENT_ERROR_NONE)
+ if (error != G_DHCP_CLIENT_ERROR_NONE) {
+ clear_timer(dhcp);
return -EINVAL;
return -EINVAL;
+ }
if (getenv("CONNMAN_DHCPV6_DEBUG"))
g_dhcp_client_set_debug(dhcp_client, dhcpv6_debug, "DHCPv6");
service = __connman_service_lookup_from_network(dhcp->network);
if (getenv("CONNMAN_DHCPV6_DEBUG"))
g_dhcp_client_set_debug(dhcp_client, dhcpv6_debug, "DHCPv6");
service = __connman_service_lookup_from_network(dhcp->network);
- if (service == NULL)
+ if (service == NULL) {
+ clear_timer(dhcp);
+ g_dhcp_client_unref(dhcp_client);
return -EINVAL;
return -EINVAL;
+ }
ret = set_duid(service, dhcp->network, dhcp_client, index);
ret = set_duid(service, dhcp->network, dhcp_client, index);
- if (ret < 0)
+ if (ret < 0) {
+ clear_timer(dhcp);
+ g_dhcp_client_unref(dhcp_client);
return ret;
return ret;
+ }
g_dhcp_client_set_request(dhcp_client, G_DHCPV6_CLIENTID);
g_dhcp_client_set_request(dhcp_client, G_DHCPV6_DNS_SERVERS);
g_dhcp_client_set_request(dhcp_client, G_DHCPV6_CLIENTID);
g_dhcp_client_set_request(dhcp_client, G_DHCPV6_DNS_SERVERS);
@@
-453,7
+471,8
@@
static int set_addresses(GDHCPClient *dhcp_client,
dhcp->nameservers = nameservers;
dhcp->nameservers = nameservers;
- for (i = 0; dhcp->nameservers[i] != NULL; i++)
+ for (i = 0; dhcp->nameservers != NULL &&
+ dhcp->nameservers[i] != NULL; i++)
__connman_service_nameserver_append(service,
dhcp->nameservers[i],
FALSE);
__connman_service_nameserver_append(service,
dhcp->nameservers[i],
FALSE);
@@
-480,7
+499,8
@@
static int set_addresses(GDHCPClient *dhcp_client,
dhcp->timeservers = timeservers;
dhcp->timeservers = timeservers;
- for (i = 0; dhcp->timeservers[i] != NULL; i++)
+ for (i = 0; dhcp->timeservers != NULL &&
+ dhcp->timeservers[i] != NULL; i++)
__connman_service_timeserver_append(service,
dhcp->timeservers[i]);
} else
__connman_service_timeserver_append(service,
dhcp->timeservers[i]);
} else
@@
-606,7
+626,7
@@
static int check_restart(struct connman_dhcpv6 *dhcp)
g_dhcpv6_client_get_timeouts(dhcp->dhcp_client, NULL, NULL,
NULL, NULL, &expired);
g_dhcpv6_client_get_timeouts(dhcp->dhcp_client, NULL, NULL,
NULL, NULL, &expired);
- current = time(
0
);
+ current = time(
NULL
);
if (current > expired) {
DBG("expired by %d secs", (int)(current - expired));
if (current > expired) {
DBG("expired by %d secs", (int)(current - expired));
@@
-808,15
+828,12
@@
int __connman_dhcpv6_start_renew(struct connman_network *network,
DBG("network %p dhcp %p", network, dhcp);
DBG("network %p dhcp %p", network, dhcp);
- if (dhcp->timeout > 0) {
- g_source_remove(dhcp->timeout);
- dhcp->timeout = 0;
- }
+ clear_timer(dhcp);
g_dhcpv6_client_get_timeouts(dhcp->dhcp_client, &T1, &T2,
&last_renew, &last_rebind, &expired);
g_dhcpv6_client_get_timeouts(dhcp->dhcp_client, &T1, &T2,
&last_renew, &last_rebind, &expired);
- current = time(
0
);
+ current = time(
NULL
);
DBG("T1 %u T2 %u expires %lu current %lu", T1, T2,
(unsigned long)expired, current);
DBG("T1 %u T2 %u expires %lu current %lu", T1, T2,
(unsigned long)expired, current);
@@
-882,10
+899,7
@@
int __connman_dhcpv6_start_release(struct connman_network *network,
if (dhcp->stateless == TRUE)
return -EINVAL;
if (dhcp->stateless == TRUE)
return -EINVAL;
- if (dhcp->timeout > 0) {
- g_source_remove(dhcp->timeout);
- dhcp->timeout = 0;
- }
+ clear_timer(dhcp);
dhcp_client = dhcp->dhcp_client;
if (dhcp_client == NULL) {
dhcp_client = dhcp->dhcp_client;
if (dhcp_client == NULL) {
@@
-929,10
+943,7
@@
static int dhcpv6_release(struct connman_dhcpv6 *dhcp)
{
DBG("dhcp %p", dhcp);
{
DBG("dhcp %p", dhcp);
- if (dhcp->timeout > 0) {
- g_source_remove(dhcp->timeout);
- dhcp->timeout = 0;
- }
+ clear_timer(dhcp);
dhcpv6_free(dhcp);
dhcpv6_free(dhcp);
@@
-1032,10
+1043,7
@@
static void advertise_cb(GDHCPClient *dhcp_client, gpointer user_data)
DBG("dhcpv6 advertise msg %p", dhcp);
DBG("dhcpv6 advertise msg %p", dhcp);
- if (dhcp->timeout > 0) {
- g_source_remove(dhcp->timeout);
- dhcp->timeout = 0;
- }
+ clear_timer(dhcp);
if (g_dhcpv6_client_get_status(dhcp_client) != 0) {
if (dhcp->callback != NULL)
if (g_dhcpv6_client_get_status(dhcp_client) != 0) {
if (dhcp->callback != NULL)
@@
-1059,10
+1067,7
@@
static void solicitation_cb(GDHCPClient *dhcp_client, gpointer user_data)
DBG("dhcpv6 solicitation msg %p", dhcp);
DBG("dhcpv6 solicitation msg %p", dhcp);
- if (dhcp->timeout > 0) {
- g_source_remove(dhcp->timeout);
- dhcp->timeout = 0;
- }
+ clear_timer(dhcp);
set_addresses(dhcp_client, dhcp);
}
set_addresses(dhcp_client, dhcp);
}
@@
-1095,19
+1100,27
@@
static int dhcpv6_solicitation(struct connman_dhcpv6 *dhcp)
index = connman_network_get_index(dhcp->network);
dhcp_client = g_dhcp_client_new(G_DHCP_IPV6, index, &error);
index = connman_network_get_index(dhcp->network);
dhcp_client = g_dhcp_client_new(G_DHCP_IPV6, index, &error);
- if (error != G_DHCP_CLIENT_ERROR_NONE)
+ if (error != G_DHCP_CLIENT_ERROR_NONE) {
+ clear_timer(dhcp);
return -EINVAL;
return -EINVAL;
+ }
if (getenv("CONNMAN_DHCPV6_DEBUG"))
g_dhcp_client_set_debug(dhcp_client, dhcpv6_debug, "DHCPv6");
service = __connman_service_lookup_from_network(dhcp->network);
if (getenv("CONNMAN_DHCPV6_DEBUG"))
g_dhcp_client_set_debug(dhcp_client, dhcpv6_debug, "DHCPv6");
service = __connman_service_lookup_from_network(dhcp->network);
- if (service == NULL)
+ if (service == NULL) {
+ clear_timer(dhcp);
+ g_dhcp_client_unref(dhcp_client);
return -EINVAL;
return -EINVAL;
+ }
ret = set_duid(service, dhcp->network, dhcp_client, index);
ret = set_duid(service, dhcp->network, dhcp_client, index);
- if (ret < 0)
+ if (ret < 0) {
+ clear_timer(dhcp);
+ g_dhcp_client_unref(dhcp_client);
return ret;
return ret;
+ }
g_dhcp_client_set_request(dhcp_client, G_DHCPV6_CLIENTID);
g_dhcp_client_set_request(dhcp_client, G_DHCPV6_RAPID_COMMIT);
g_dhcp_client_set_request(dhcp_client, G_DHCPV6_CLIENTID);
g_dhcp_client_set_request(dhcp_client, G_DHCPV6_RAPID_COMMIT);
@@
-1207,7
+1220,7
@@
int __connman_dhcpv6_init(void)
{
DBG("");
{
DBG("");
- srand(time(
0
));
+ srand(time(
NULL
));
network_table = g_hash_table_new_full(g_direct_hash, g_direct_equal,
NULL, remove_network);
network_table = g_hash_table_new_full(g_direct_hash, g_direct_equal,
NULL, remove_network);