Send connman mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."
Today's Topics:
1. [PATCH] Store passphrase(PSK) after WPS provisioning has
successfully completed (Jose Blanquicet)
2. [PATCH] Store passphrase(PSK) after WPS provisioning has
successfully completed (Jose Blanquicet)
3. [PATCH 0/2] Extend NTP for exotic use cases (Zolt?n B?sz?rm?nyi)
4. [PATCH 1/2] ntp: Add option TimeUpdateThreshold
(Zolt?n B?sz?rm?nyi)
5. [PATCH 2/2] ntp: Add option TimeserversFromDHCP
(Zolt?n B?sz?rm?nyi)
----------------------------------------------------------------------
Message: 1
Date: Mon, 7 Mar 2016 10:32:39 +0100
From: Jose Blanquicet <[email protected]>
To: [email protected]
Subject: [PATCH] Store passphrase(PSK) after WPS provisioning has
successfully completed
Message-ID: <[email protected]>
When WPS Provisioning finished successfully, the passphrase gotten from
the WPS Credentials is stored first in the network structure in the
function handle_wps_completion() and then in the service structure
in the function service_indicate_state(). The problems is that the
service's settings file is created/updated through the function service_save()
BEFORE updating the service structure with the new passphrase. Therefore,
the passphrase is not actually written in the file.
This patch is simple, it only moves the updating of the
passphrase before storing the information in the setting file.
Jose Blanquicet (1):
Store passphrase(PSK) after WPS provisioning has successfully
completed
src/service.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
--
1.9.1
------------------------------
Message: 2
Date: Mon, 7 Mar 2016 10:33:48 +0100
From: Jose Blanquicet <[email protected]>
To: [email protected]
Subject: [PATCH] Store passphrase(PSK) after WPS provisioning has
successfully completed
Message-ID: <[email protected]>
---
src/service.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/service.c b/src/service.c
index 8e07337..2563e9a 100644
--- a/src/service.c
+++ b/src/service.c
@@ -5405,16 +5405,6 @@ static int service_indicate_state(struct connman_service
*service)
reply_pending(service, 0);
- g_get_current_time(&service->modified);
- service_save(service);
-
- dns_changed(service);
- domain_changed(service);
- proxy_changed(service);
-
- if (old_state != CONNMAN_SERVICE_STATE_ONLINE)
- __connman_notifier_connect(service->type);
-
if (service->type == CONNMAN_SERVICE_TYPE_WIFI &&
connman_network_get_bool(service->network,
"WiFi.UseWPS")) {
@@ -5428,6 +5418,16 @@ static int service_indicate_state(struct connman_service
*service)
connman_network_set_bool(service->network,
"WiFi.UseWPS", false);
}
+
+ g_get_current_time(&service->modified);
+ service_save(service);
+
+ dns_changed(service);
+ domain_changed(service);
+ proxy_changed(service);
+
+ if (old_state != CONNMAN_SERVICE_STATE_ONLINE)
+ __connman_notifier_connect(service->type);
method = __connman_ipconfig_get_method(service->ipconfig_ipv6);
if (method == CONNMAN_IPCONFIG_METHOD_OFF)
--
1.9.1
------------------------------
Message: 3
Date: Mon, 7 Mar 2016 18:13:30 +0100
From: Zolt?n B?sz?rm?nyi <[email protected]>
To: [email protected]
Subject: [PATCH 0/2] Extend NTP for exotic use cases
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
Hi,
we are using Connman with a Yocto-derived custom OS.
However, we also found some problems caused by hardwired parameters
in the NTP functionality.
These problems are:
1. The 0.128 seconds threshold for using settimeofday() instead of
adjtime() is too small. We found that some machines have bad
RTCs that shift time more than the hardcoded value under the NTP
polling period. Let's make it configurable.
2. The appliances we ship use our own company NTP server but are placed
on clients' site where the DHCP server is not under our control and
do not trust the clients' NTP server. Because of this, another knob
is added to disable adding NTP servers from DHCP info. Also, this
knob also controls adding the network gateway as an NTP server,
which is identical to the DHCP server in some cases.
Please, review and consider including these patches into 1.32.
doc/clock-api.txt | 10 ++++++++++
src/clock.c | 84
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/connman.h | 2 ++
src/dbus.c | 3 +++
src/dhcp.c | 47 +++++++++++++++++++++++++----------------------
src/dhcpv6.c | 44 ++++++++++++++++++++++----------------------
src/ntp.c | 6 +++---
src/timeserver.c | 2 +-
8 files changed, 149 insertions(+), 49 deletions(-)
Best regards,
Zolt?n B?sz?rm?nyi
------------------------------
Message: 4
Date: Mon, 7 Mar 2016 18:13:31 +0100
From: Zolt?n B?sz?rm?nyi <[email protected]>
To: [email protected]
Subject: [PATCH 1/2] ntp: Add option TimeUpdateThreshold
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
From: B?sz?rm?nyi Zolt?n <[email protected]>
Add option TimeUpdateThreshold (type: double units: seconds)
to make the threshold for using settimeofday() vs adjtime()
configurable. The RTC in some machines is so bad that with the
current hardcoded 0.128 seconds, connman occasionally decides
to use settimeofday() instead of adjtime().
Signed-off-by: Zolt?n B?sz?rm?nyi <[email protected]>
---
doc/clock-api.txt | 5 +++++
src/clock.c | 39 ++++++++++++++++++++++++++++++++++++++-
src/connman.h | 1 +
src/dbus.c | 3 +++
src/ntp.c | 6 +++---
5 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/doc/clock-api.txt b/doc/clock-api.txt
index 6818f5a..06e14f0 100644
--- a/doc/clock-api.txt
+++ b/doc/clock-api.txt
@@ -46,20 +46,25 @@ Properties uint64 Time [readonly or readwrite]
[experimental]
string TimeUpdates [readwrite] [experimental]
Possible values are "manual" and "auto" to indicate
time update policy.
With the "auto" setting the system tries to use as
many sources as possible to determine the correct
and updated time.
+ double TimeUpdateThreshold [readwrite] [experimental]
+
+ Threshold value in milliseconds for settimeofday()
+ versus adjtime(). Default 0.128.
+
string Timezone [readonly or readwrite] [experimental]
Current system timezone string. Allowed values
are from the standard timezone data (tzdata)
package under /usr/share/zoneinfo. For example
strings like "America/Vancouver" or "Europe/Berlin".
This value is present for changing the timezone
if TimezoneUpdates is set to manual.
diff --git a/src/clock.c b/src/clock.c
index 0fde2c3..14b8dde 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -30,21 +30,22 @@
#include "connman.h"
enum timezone_updates {
TIMEZONE_UPDATES_UNKNOWN = 0,
TIMEZONE_UPDATES_MANUAL = 1,
TIMEZONE_UPDATES_AUTO = 2,
};
static enum time_updates time_updates_config = TIME_UPDATES_AUTO;
static enum timezone_updates timezone_updates_config = TIMEZONE_UPDATES_AUTO;
-
+#define TIME_UPDATE_DEFAULT_THRESHOLD (0.128)
+static double time_update_threshold_config = TIME_UPDATE_DEFAULT_THRESHOLD;
static char *timezone_config = NULL;
static const char *time_updates2string(enum time_updates value)
{
switch (value) {
case TIME_UPDATES_UNKNOWN:
break;
case TIME_UPDATES_MANUAL:
return "manual";
case TIME_UPDATES_AUTO:
@@ -87,20 +88,21 @@ static enum timezone_updates string2timezone_updates(const
char *value)
return TIMEZONE_UPDATES_UNKNOWN;
}
static void clock_properties_load(void)
{
GKeyFile *keyfile;
char *str;
enum time_updates time_value;
enum timezone_updates timezone_value;
+ double time_update_threshold;
keyfile = __connman_storage_load_global();
if (!keyfile)
return;
str = g_key_file_get_string(keyfile, "global", "TimeUpdates", NULL);
time_value = string2time_updates(str);
if (time_value != TIME_UPDATES_UNKNOWN)
time_updates_config = time_value;
@@ -109,20 +111,24 @@ static void clock_properties_load(void)
str = g_key_file_get_string(keyfile, "global", "TimezoneUpdates",
NULL);
timezone_value = string2timezone_updates(str);
if (timezone_value != TIMEZONE_UPDATES_UNKNOWN)
timezone_updates_config = timezone_value;
g_free(str);
+ time_update_threshold = g_key_file_get_double(keyfile, "global",
"TimeUpdateThreshold", NULL);
+ if (time_update_threshold > 0.001 && time_update_threshold !=
TIME_UPDATE_DEFAULT_THRESHOLD)
+ time_update_threshold_config = time_update_threshold;
+
g_key_file_free(keyfile);
}
static void clock_properties_save(void)
{
GKeyFile *keyfile;
const char *str;
keyfile = __connman_storage_load_global();
if (!keyfile)
@@ -135,30 +141,42 @@ static void clock_properties_save(void)
g_key_file_remove_key(keyfile, "global", "TimeUpdates", NULL);
str = timezone_updates2string(timezone_updates_config);
if (str)
g_key_file_set_string(keyfile, "global", "TimezoneUpdates",
str);
else
g_key_file_remove_key(keyfile, "global", "TimezoneUpdates",
NULL);
+ if (time_update_threshold_config != TIME_UPDATE_DEFAULT_THRESHOLD)
+ g_key_file_set_double(keyfile, "global", "TimeUpdateThreshold",
+ time_update_threshold_config);
+ else
+ g_key_file_remove_key(keyfile, "global", "TimeUpdateThreshold",
+ NULL);
+
__connman_storage_save_global(keyfile);
g_key_file_free(keyfile);
}
enum time_updates __connman_clock_timeupdates(void)
{
return time_updates_config;
}
+double __connman_clock_timeupdate_threshold(void)
+{
+ return time_update_threshold_config;
+}
+
static void append_timeservers(DBusMessageIter *iter, void *user_data)
{
int i;
char **timeservers = __connman_timeserver_system_get();
if (!timeservers)
return;
for (i = 0; timeservers[i]; i++) {
dbus_message_iter_append_basic(iter,
@@ -203,20 +221,23 @@ static DBusMessage *get_properties(DBusConnection *conn,
DBUS_TYPE_STRING, &timezone_config);
str = timezone_updates2string(timezone_updates_config);
if (str)
connman_dbus_dict_append_basic(&dict, "TimezoneUpdates",
DBUS_TYPE_STRING, &str);
connman_dbus_dict_append_array(&dict, "Timeservers",
DBUS_TYPE_STRING, append_timeservers, NULL);
+ connman_dbus_dict_append_basic(&dict, "TimeUpdateThreshold",
+ DBUS_TYPE_DOUBLE,
&time_update_threshold_config);
+
connman_dbus_dict_close(&array, &dict);
return reply;
}
static DBusMessage *set_property(DBusConnection *conn,
DBusMessage *msg, void *data)
{
DBusMessageIter iter, value;
const char *name;
@@ -355,20 +376,36 @@ static DBusMessage *set_property(DBusConnection *conn,
}
__connman_timeserver_system_set(str);
if (str)
g_strfreev(str);
connman_dbus_property_changed_array(CONNMAN_MANAGER_PATH,
CONNMAN_CLOCK_INTERFACE, "Timeservers",
DBUS_TYPE_STRING, append_timeservers, NULL);
+ } else if (g_str_equal(name, "TimeUpdateThreshold")) {
+ double newval;
+
+ if (type != DBUS_TYPE_DOUBLE)
+ return __connman_error_invalid_arguments(msg);
+
+ dbus_message_iter_get_basic(&value, &newval);
+
+ if (newval <= 0.001)
+ return __connman_error_invalid_arguments(msg);
+
+ time_update_threshold_config = newval;
+
+ connman_dbus_property_changed_basic(CONNMAN_MANAGER_PATH,
+ CONNMAN_CLOCK_INTERFACE, "TimeUpdateThreshold",
+ DBUS_TYPE_DOUBLE, &newval);
} else
return __connman_error_invalid_property(msg);
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
static const GDBusMethodTable clock_methods[] = {
{ GDBUS_METHOD("GetProperties",
NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
get_properties) },
diff --git a/src/connman.h b/src/connman.h
index 447bdd7..93b2baf 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -58,20 +58,21 @@ DBusMessage *__connman_error_invalid_property(DBusMessage
*msg);
int __connman_manager_init(void);
void __connman_manager_cleanup(void);
enum time_updates {
TIME_UPDATES_UNKNOWN = 0,
TIME_UPDATES_MANUAL = 1,
TIME_UPDATES_AUTO = 2,
};
enum time_updates __connman_clock_timeupdates(void);
+double __connman_clock_timeupdate_threshold(void);
int __connman_clock_init(void);
void __connman_clock_cleanup(void);
void __connman_clock_update_timezone(void);
int __connman_timezone_init(void);
void __connman_timezone_cleanup(void);
char *__connman_timezone_lookup(void);
int __connman_timezone_change(const char *zone);
diff --git a/src/dbus.c b/src/dbus.c
index d80a46c..88a34fe 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -104,20 +104,23 @@ void connman_dbus_property_append_basic(DBusMessageIter
*iter,
break;
case DBUS_TYPE_INT32:
signature = DBUS_TYPE_INT32_AS_STRING;
break;
case DBUS_TYPE_UINT64:
signature = DBUS_TYPE_UINT64_AS_STRING;
break;
case DBUS_TYPE_INT64:
signature = DBUS_TYPE_INT64_AS_STRING;
break;
+ case DBUS_TYPE_DOUBLE:
+ signature = DBUS_TYPE_DOUBLE_AS_STRING;
+ break;
case DBUS_TYPE_OBJECT_PATH:
signature = DBUS_TYPE_OBJECT_PATH_AS_STRING;
break;
default:
signature = DBUS_TYPE_VARIANT_AS_STRING;
break;
}
dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
signature, &value);
diff --git a/src/ntp.c b/src/ntp.c
index dd246eb..f61e803 100644
--- a/src/ntp.c
+++ b/src/ntp.c
@@ -59,22 +59,20 @@ struct ntp_msg {
struct ntp_short rootdisp; /* Root dispersion */
uint32_t refid; /* Reference ID */
struct ntp_time reftime; /* Reference timestamp */
struct ntp_time orgtime; /* Origin timestamp */
struct ntp_time rectime; /* Receive timestamp */
struct ntp_time xmttime; /* Transmit timestamp */
} __attribute__ ((packed));
#define OFFSET_1900_1970 2208988800UL /* 1970 - 1900 in seconds */
-#define STEPTIME_MIN_OFFSET 0.128
-
#define LOGTOD(a) ((a) < 0 ? 1. / (1L << -(a)) : 1L << (int)(a))
#define NTP_SEND_TIMEOUT 2
#define NTP_SEND_RETRIES 3
#define NTP_FLAG_LI_SHIFT 6
#define NTP_FLAG_LI_MASK 0x3
#define NTP_FLAG_LI_NOWARNING 0x0
#define NTP_FLAG_LI_ADDSECOND 0x1
#define NTP_FLAG_LI_DELSECOND 0x2
@@ -239,20 +237,21 @@ static void reset_timeout(void)
retries = 0;
}
static void decode_msg(void *base, size_t len, struct timeval *tv,
struct timespec *mrx_time)
{
struct ntp_msg *msg = base;
double m_delta, org, rec, xmt, dst;
double delay, offset;
+ double threshold;
static guint transmit_delay;
if (len < sizeof(*msg)) {
connman_error("Invalid response from time server");
return;
}
if (!tv) {
connman_error("Invalid packet timestamp from time server");
return;
@@ -331,21 +330,22 @@ static void decode_msg(void *base, size_t len, struct
timeval *tv,
*/
if (poll_id > 0)
g_source_remove(poll_id);
DBG("Timeserver %s, next sync in %d seconds", timeserver,
transmit_delay);
poll_id = g_timeout_add_seconds(transmit_delay, next_poll, NULL);
connman_info("ntp: time slew %+.6f s", offset);
- if (offset < STEPTIME_MIN_OFFSET && offset > -STEPTIME_MIN_OFFSET) {
+ threshold = __connman_clock_timeupdate_threshold();
+ if (offset < threshold && offset > -threshold) {
struct timeval adj;
adj.tv_sec = (long) offset;
adj.tv_usec = (offset - adj.tv_sec) * 1000000;
DBG("adjusting time %ld seconds, %ld msecs", adj.tv_sec,
adj.tv_usec);
if (adjtime(&adj, &adj) < 0) {
connman_error("Failed to adjust time");
return;
--
2.5.0
------------------------------
Message: 5
Date: Mon, 7 Mar 2016 18:13:32 +0100
From: Zolt?n B?sz?rm?nyi <[email protected]>
To: [email protected]
Subject: [PATCH 2/2] ntp: Add option TimeserversFromDHCP
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
From: B?sz?rm?nyi Zolt?n <[email protected]>
Add option TimeserversFromDHCP (type boolean) to be able to disable
the NTP servers published by the DHCP server. In some use cases the
DHCP server is not under your control and you have to use a specific
NTP server, not the DHCP-provided one.
Adding the gateway as a timeserver now also depends on this option.
Signed-off-by: Zolt?n B?sz?rm?nyi <[email protected]>
---
doc/clock-api.txt | 5 +++++
src/clock.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
src/connman.h | 1 +
src/dhcp.c | 47 +++++++++++++++++++++++++----------------------
src/dhcpv6.c | 44 ++++++++++++++++++++++----------------------
src/timeserver.c | 2 +-
6 files changed, 99 insertions(+), 45 deletions(-)
diff --git a/doc/clock-api.txt b/doc/clock-api.txt
index 06e14f0..be174f4 100644
--- a/doc/clock-api.txt
+++ b/doc/clock-api.txt
@@ -83,10 +83,15 @@ Properties uint64 Time [readonly or readwrite]
[experimental]
array{string} Timeservers [readwrite] [experimental]
List of global default NTP servers. The list should
be sorted in order of preference.
If a service configuration provides NTP servers,
then they are preferred over the global ones.
This list of servers is used when TimeUpdates is set
to auto.
+
+ boolean TimeserversFromDHCP [readwrite] [experimental]
+
+ Whether the time server(s) provided by DHCP should
+ be used. Default true.
diff --git a/src/clock.c b/src/clock.c
index 14b8dde..24c2942 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -32,20 +32,22 @@
enum timezone_updates {
TIMEZONE_UPDATES_UNKNOWN = 0,
TIMEZONE_UPDATES_MANUAL = 1,
TIMEZONE_UPDATES_AUTO = 2,
};
static enum time_updates time_updates_config = TIME_UPDATES_AUTO;
static enum timezone_updates timezone_updates_config = TIMEZONE_UPDATES_AUTO;
#define TIME_UPDATE_DEFAULT_THRESHOLD (0.128)
static double time_update_threshold_config = TIME_UPDATE_DEFAULT_THRESHOLD;
+#define TIMESERVERS_FROM_DHCP_DEFAULT (TRUE)
+static gboolean timeservers_from_dhcp_config = TIMESERVERS_FROM_DHCP_DEFAULT;
static char *timezone_config = NULL;
static const char *time_updates2string(enum time_updates value)
{
switch (value) {
case TIME_UPDATES_UNKNOWN:
break;
case TIME_UPDATES_MANUAL:
return "manual";
case TIME_UPDATES_AUTO:
@@ -85,24 +87,26 @@ static enum timezone_updates string2timezone_updates(const
char *value)
return TIMEZONE_UPDATES_MANUAL;
else if (g_strcmp0(value, "auto") == 0)
return TIMEZONE_UPDATES_AUTO;
return TIMEZONE_UPDATES_UNKNOWN;
}
static void clock_properties_load(void)
{
GKeyFile *keyfile;
+ GError *err;
char *str;
enum time_updates time_value;
enum timezone_updates timezone_value;
double time_update_threshold;
+ gboolean timeservers_from_dhcp;
keyfile = __connman_storage_load_global();
if (!keyfile)
return;
str = g_key_file_get_string(keyfile, "global", "TimeUpdates", NULL);
time_value = string2time_updates(str);
if (time_value != TIME_UPDATES_UNKNOWN)
time_updates_config = time_value;
@@ -115,20 +119,35 @@ static void clock_properties_load(void)
timezone_value = string2timezone_updates(str);
if (timezone_value != TIMEZONE_UPDATES_UNKNOWN)
timezone_updates_config = timezone_value;
g_free(str);
time_update_threshold = g_key_file_get_double(keyfile, "global",
"TimeUpdateThreshold", NULL);
if (time_update_threshold > 0.001 && time_update_threshold !=
TIME_UPDATE_DEFAULT_THRESHOLD)
time_update_threshold_config = time_update_threshold;
+ err = NULL;
+ timeservers_from_dhcp = g_key_file_get_boolean(keyfile, "global",
"TimeserversFromDHCP", &err);
+ if (err) {
+ switch (err->code) {
+ case G_KEY_FILE_ERROR_KEY_NOT_FOUND:
+ case G_KEY_FILE_ERROR_INVALID_VALUE:
+ timeservers_from_dhcp = TIMESERVERS_FROM_DHCP_DEFAULT;
+ break;
+ default:
+ break;
+ }
+ g_error_free(err);
+ }
+ timeservers_from_dhcp_config = timeservers_from_dhcp;
+
g_key_file_free(keyfile);
}
static void clock_properties_save(void)
{
GKeyFile *keyfile;
const char *str;
keyfile = __connman_storage_load_global();
if (!keyfile)
@@ -148,35 +167,47 @@ static void clock_properties_save(void)
g_key_file_remove_key(keyfile, "global", "TimezoneUpdates",
NULL);
if (time_update_threshold_config != TIME_UPDATE_DEFAULT_THRESHOLD)
g_key_file_set_double(keyfile, "global", "TimeUpdateThreshold",
time_update_threshold_config);
else
g_key_file_remove_key(keyfile, "global", "TimeUpdateThreshold",
NULL);
+ if (timeservers_from_dhcp_config != TIMESERVERS_FROM_DHCP_DEFAULT)
+ g_key_file_set_boolean(keyfile, "global", "TimeserversFromDHCP",
+ timeservers_from_dhcp_config);
+ else
+ g_key_file_remove_key(keyfile, "global", "TimeserversFromDHCP",
+ NULL);
+
__connman_storage_save_global(keyfile);
g_key_file_free(keyfile);
}
enum time_updates __connman_clock_timeupdates(void)
{
return time_updates_config;
}
double __connman_clock_timeupdate_threshold(void)
{
return time_update_threshold_config;
}
+gboolean __connman_clock_timeservers_from_dhcp(void)
+{
+ return timeservers_from_dhcp_config;
+}
+
static void append_timeservers(DBusMessageIter *iter, void *user_data)
{
int i;
char **timeservers = __connman_timeserver_system_get();
if (!timeservers)
return;
for (i = 0; timeservers[i]; i++) {
dbus_message_iter_append_basic(iter,
@@ -221,20 +252,23 @@ static DBusMessage *get_properties(DBusConnection *conn,
DBUS_TYPE_STRING, &timezone_config);
str = timezone_updates2string(timezone_updates_config);
if (str)
connman_dbus_dict_append_basic(&dict, "TimezoneUpdates",
DBUS_TYPE_STRING, &str);
connman_dbus_dict_append_array(&dict, "Timeservers",
DBUS_TYPE_STRING, append_timeservers, NULL);
+ connman_dbus_dict_append_basic(&dict, "TimeserversFromDHCP",
+ DBUS_TYPE_BOOLEAN,
×ervers_from_dhcp_config);
+
connman_dbus_dict_append_basic(&dict, "TimeUpdateThreshold",
DBUS_TYPE_DOUBLE,
&time_update_threshold_config);
connman_dbus_dict_close(&array, &dict);
return reply;
}
static DBusMessage *set_property(DBusConnection *conn,
DBusMessage *msg, void *data)
@@ -376,20 +410,31 @@ static DBusMessage *set_property(DBusConnection *conn,
}
__connman_timeserver_system_set(str);
if (str)
g_strfreev(str);
connman_dbus_property_changed_array(CONNMAN_MANAGER_PATH,
CONNMAN_CLOCK_INTERFACE, "Timeservers",
DBUS_TYPE_STRING, append_timeservers, NULL);
+ } else if (g_str_equal(name, "TimeserversFromDHCP")) {
+ gboolean newval;
+
+ if (type != DBUS_TYPE_BOOLEAN)
+ return __connman_error_invalid_arguments(msg);
+
+ dbus_message_iter_get_basic(&value, &newval);
+
+ connman_dbus_property_changed_basic(CONNMAN_MANAGER_PATH,
+ CONNMAN_CLOCK_INTERFACE, "TimeserversFromDHCP",
+ DBUS_TYPE_BOOLEAN, &newval);
} else if (g_str_equal(name, "TimeUpdateThreshold")) {
double newval;
if (type != DBUS_TYPE_DOUBLE)
return __connman_error_invalid_arguments(msg);
dbus_message_iter_get_basic(&value, &newval);
if (newval <= 0.001)
return __connman_error_invalid_arguments(msg);
diff --git a/src/connman.h b/src/connman.h
index 93b2baf..51cfbed 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -59,20 +59,21 @@ int __connman_manager_init(void);
void __connman_manager_cleanup(void);
enum time_updates {
TIME_UPDATES_UNKNOWN = 0,
TIME_UPDATES_MANUAL = 1,
TIME_UPDATES_AUTO = 2,
};
enum time_updates __connman_clock_timeupdates(void);
double __connman_clock_timeupdate_threshold(void);
+gboolean __connman_clock_timeservers_from_dhcp(void);
int __connman_clock_init(void);
void __connman_clock_cleanup(void);
void __connman_clock_update_timezone(void);
int __connman_timezone_init(void);
void __connman_timezone_cleanup(void);
char *__connman_timezone_lookup(void);
int __connman_timezone_change(const char *zone);
diff --git a/src/dhcp.c b/src/dhcp.c
index 4040ad1..0033b7b 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -341,65 +341,68 @@ static bool apply_lease_available_on_network(GDHCPClient
*dhcp_client,
}
option = g_dhcp_client_get_option(dhcp_client, G_DHCP_DOMAIN_NAME);
if (option)
__connman_service_set_domainname(service, option->data);
option = g_dhcp_client_get_option(dhcp_client, G_DHCP_HOST_NAME);
if (option)
__connman_service_set_hostname(service, option->data);
- option = g_dhcp_client_get_option(dhcp_client, G_DHCP_NTP_SERVER);
- ns_entries = g_list_length(option);
- timeservers = g_try_new0(char *, ns_entries + 1);
- if (timeservers) {
- for (i = 0, list = option; list; list = list->next, i++)
- timeservers[i] = g_strdup(list->data);
- timeservers[ns_entries] = NULL;
- }
-
if (!compare_string_arrays(nameservers, dhcp->nameservers)) {
if (dhcp->nameservers) {
for (i = 0; dhcp->nameservers[i]; i++) {
__connman_service_nameserver_remove(service,
dhcp->nameservers[i], false);
}
g_strfreev(dhcp->nameservers);
}
dhcp->nameservers = nameservers;
for (i = 0; dhcp->nameservers && dhcp->nameservers[i]; i++) {
__connman_service_nameserver_append(service,
dhcp->nameservers[i], false);
}
} else {
g_strfreev(nameservers);
}
- if (!compare_string_arrays(timeservers, dhcp->timeservers)) {
- if (dhcp->timeservers) {
- for (i = 0; dhcp->timeservers[i]; i++) {
- __connman_service_timeserver_remove(service,
- dhcp->timeservers[i]);
- }
- g_strfreev(dhcp->timeservers);
+ if (__connman_clock_timeservers_from_dhcp()) {
+ option = g_dhcp_client_get_option(dhcp_client,
G_DHCP_NTP_SERVER);
+ ns_entries = g_list_length(option);
+
+ timeservers = g_try_new0(char *, ns_entries + 1);
+ if (timeservers) {
+ for (i = 0, list = option; list; list = list->next, i++)
+ timeservers[i] = g_strdup(list->data);
+ timeservers[ns_entries] = NULL;
}
- dhcp->timeservers = timeservers;
+ if (!compare_string_arrays(timeservers, dhcp->timeservers)) {
+ if (dhcp->timeservers) {
+ for (i = 0; dhcp->timeservers[i]; i++) {
+
__connman_service_timeserver_remove(service,
+
dhcp->timeservers[i]);
+ }
+ g_strfreev(dhcp->timeservers);
+ }
- for (i = 0; dhcp->timeservers && dhcp->timeservers[i]; i++) {
- __connman_service_timeserver_append(service,
- dhcp->timeservers[i]);
+ dhcp->timeservers = timeservers;
+
+ for (i = 0; dhcp->timeservers && dhcp->timeservers[i];
i++) {
+ __connman_service_timeserver_append(service,
+
dhcp->timeservers[i]);
+ }
+ } else {
+ g_strfreev(timeservers);
}
- } else {
- g_strfreev(timeservers);
}
if (g_strcmp0(pac, dhcp->pac) != 0) {
g_free(dhcp->pac);
dhcp->pac = pac;
__connman_ipconfig_set_proxy_autoconfig(dhcp->ipconfig,
dhcp->pac);
}
diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index 9e21040..0d9da40 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -337,47 +337,47 @@ static void info_req_cb(GDHCPClient *dhcp_client,
gpointer user_data)
dhcp->nameservers = nameservers;
for (i = 0; dhcp->nameservers &&
dhcp->nameservers[i]; i++)
__connman_service_nameserver_append(service,
dhcp->nameservers[i],
false);
} else
g_strfreev(nameservers);
+ if (__connman_clock_timeservers_from_dhcp()) {
+ option = g_dhcp_client_get_option(dhcp_client,
G_DHCPV6_SNTP_SERVERS);
+ entries = g_list_length(option);
+
+ timeservers = g_try_new0(char *, entries + 1);
+ if (timeservers) {
+ for (i = 0, list = option; list; list = list->next, i++)
+ timeservers[i] = g_strdup(list->data);
+ }
- option = g_dhcp_client_get_option(dhcp_client, G_DHCPV6_SNTP_SERVERS);
- entries = g_list_length(option);
-
- timeservers = g_try_new0(char *, entries + 1);
- if (timeservers) {
- for (i = 0, list = option; list; list = list->next, i++)
- timeservers[i] = g_strdup(list->data);
- }
-
- if (!compare_string_arrays(timeservers, dhcp->timeservers)) {
- if (dhcp->timeservers) {
- for (i = 0; dhcp->timeservers[i]; i++)
- __connman_service_timeserver_remove(service,
+ if (!compare_string_arrays(timeservers, dhcp->timeservers)) {
+ if (dhcp->timeservers) {
+ for (i = 0; dhcp->timeservers[i]; i++)
+
__connman_service_timeserver_remove(service,
dhcp->timeservers[i]);
- g_strfreev(dhcp->timeservers);
- }
+ g_strfreev(dhcp->timeservers);
+ }
- dhcp->timeservers = timeservers;
+ dhcp->timeservers = timeservers;
- for (i = 0; dhcp->timeservers &&
- dhcp->timeservers[i]; i++)
- __connman_service_timeserver_append(service,
+ for (i = 0; dhcp->timeservers &&
+ dhcp->timeservers[i]; i++)
+ __connman_service_timeserver_append(service,
dhcp->timeservers[i]);
- } else
- g_strfreev(timeservers);
-
+ } else
+ g_strfreev(timeservers);
+ }
if (dhcp->callback) {
uint16_t status = g_dhcpv6_client_get_status(dhcp_client);
dhcp->callback(dhcp->network, status == 0 ?
CONNMAN_DHCPV6_STATUS_SUCCEED :
CONNMAN_DHCPV6_STATUS_FAIL,
NULL);
}
}
diff --git a/src/timeserver.c b/src/timeserver.c
index f0d33e5..aa0425d 100644
--- a/src/timeserver.c
+++ b/src/timeserver.c
@@ -198,21 +198,21 @@ GSList *__connman_timeserver_get_all(struct
connman_service *service)
list = __connman_timeserver_add_list(list,
service_ts_config[i]);
service_ts = connman_service_get_timeservers(service);
/* Then add Service Timeservers via DHCP to the list */
for (i = 0; service_ts && service_ts[i]; i++)
list = __connman_timeserver_add_list(list, service_ts[i]);
network = __connman_service_get_network(service);
- if (network) {
+ if (__connman_clock_timeservers_from_dhcp() && network) {
index = connman_network_get_index(network);
service_gw = __connman_ipconfig_get_gateway_from_index(index,
CONNMAN_IPCONFIG_TYPE_ALL);
/* Then add Service Gateway to the list */
if (service_gw)
list = __connman_timeserver_add_list(list, service_gw);
}
/* Then add Global Timeservers to the list */
--
2.5.0
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 5, Issue 6
*************************************