Cumulative patch from commit 594516b4c28a94ca686b17f1e463dfd6712b75a7
594516b Use monotonic clock for relative time for eloop if available
461e3eb Fix and work around some MinGW compilation issues
81cbc04 Fix compiler warning for OpenSSL without HAVE_OCSP
68d628a hostapd: Fix interface enabling/disabling and DFS
1cba9be STA: Cancel sched_scan while initiating wps_reassoc
215a02f Add Wi-Fi Direct to the build configuration example
ca9c14f dbus_new: Add documentation for D-Bus TDLS methods
6fc4848 P2P: Short scan wait to speed up the group re-invocation
93a06fe Fix QoS Map Configure frame use
Change-Id: Id76002ca7fa742b6533e7e592ffd3867886dc50e
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 51b1035..69e8956 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -243,6 +243,13 @@
static void hostapd_free_hapd_data(struct hostapd_data *hapd)
{
+ if (!hapd->started) {
+ wpa_printf(MSG_ERROR, "%s: Interface %s wasn't started",
+ __func__, hapd->conf->iface);
+ return;
+ }
+ hapd->started = 0;
+
wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
iapp_deinit(hapd->iapp);
hapd->iapp = NULL;
@@ -306,7 +313,6 @@
hapd->iface->interfaces->ctrl_iface_deinit)
hapd->iface->interfaces->ctrl_iface_deinit(hapd);
hostapd_free_hapd_data(hapd);
- hapd->started = 0;
}
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index 3dac6ea..c25917d 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -44,7 +44,9 @@
int global_ctrl_sock;
char *global_iface_path;
char *global_iface_name;
+#ifndef CONFIG_NATIVE_WINDOWS
gid_t ctrl_iface_group;
+#endif /* CONFIG_NATIVE_WINDOWS */
struct hostapd_iface **iface;
struct hostapd_dynamic_iface **dynamic_iface;
diff --git a/src/crypto/tls_openssl.c b/src/crypto/tls_openssl.c
index b98d662..eeaf859 100644
--- a/src/crypto/tls_openssl.c
+++ b/src/crypto/tls_openssl.c
@@ -1141,6 +1141,7 @@
}
+#ifndef CONFIG_NATIVE_WINDOWS
static int domain_suffix_match(const u8 *val, size_t len, const char *match)
{
size_t i, match_len;
@@ -1170,10 +1171,15 @@
wpa_printf(MSG_DEBUG, "TLS: Reject due to incomplete label match");
return 0;
}
+#endif /* CONFIG_NATIVE_WINDOWS */
static int tls_match_suffix(X509 *cert, const char *match)
{
+#ifdef CONFIG_NATIVE_WINDOWS
+ /* wincrypt.h has conflicting X509_NAME definition */
+ return -1;
+#else /* CONFIG_NATIVE_WINDOWS */
GENERAL_NAME *gen;
void *ext;
int i;
@@ -1229,6 +1235,7 @@
wpa_printf(MSG_DEBUG, "TLS: No CommonName suffix match found");
return 0;
+#endif /* CONFIG_NATIVE_WINDOWS */
}
@@ -3065,7 +3072,6 @@
{
int ret;
unsigned long err;
- SSL_CTX *ssl_ctx = tls_ctx;
if (conn == NULL)
return -1;
@@ -3138,6 +3144,7 @@
#ifdef HAVE_OCSP
if (params->flags & TLS_CONN_REQUEST_OCSP) {
+ SSL_CTX *ssl_ctx = tls_ctx;
SSL_set_tlsext_status_type(conn->ssl, TLSEXT_STATUSTYPE_ocsp);
SSL_CTX_set_tlsext_status_cb(ssl_ctx, ocsp_resp_cb);
SSL_CTX_set_tlsext_status_arg(ssl_ctx, conn);
diff --git a/src/utils/eloop.c b/src/utils/eloop.c
index 2d6aac7..e983edc 100644
--- a/src/utils/eloop.c
+++ b/src/utils/eloop.c
@@ -31,7 +31,7 @@
struct eloop_timeout {
struct dl_list list;
- struct os_time time;
+ struct os_reltime time;
void *eloop_data;
void *user_data;
eloop_timeout_handler handler;
@@ -484,7 +484,7 @@
timeout = os_zalloc(sizeof(*timeout));
if (timeout == NULL)
return -1;
- if (os_get_time(&timeout->time) < 0) {
+ if (os_get_reltime(&timeout->time) < 0) {
os_free(timeout);
return -1;
}
@@ -514,7 +514,7 @@
/* Maintain timeouts in order of increasing time */
dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
- if (os_time_before(&timeout->time, &tmp->time)) {
+ if (os_reltime_before(&timeout->time, &tmp->time)) {
dl_list_add(tmp->list.prev, &timeout->list);
return 0;
}
@@ -558,13 +558,13 @@
int eloop_cancel_timeout_one(eloop_timeout_handler handler,
void *eloop_data, void *user_data,
- struct os_time *remaining)
+ struct os_reltime *remaining)
{
struct eloop_timeout *timeout, *prev;
int removed = 0;
- struct os_time now;
+ struct os_reltime now;
- os_get_time(&now);
+ os_get_reltime(&now);
remaining->sec = remaining->usec = 0;
dl_list_for_each_safe(timeout, prev, &eloop.timeout,
@@ -573,8 +573,8 @@
(timeout->eloop_data == eloop_data) &&
(timeout->user_data == user_data)) {
removed = 1;
- if (os_time_before(&now, &timeout->time))
- os_time_sub(&timeout->time, &now, remaining);
+ if (os_reltime_before(&now, &timeout->time))
+ os_reltime_sub(&timeout->time, &now, remaining);
eloop_remove_timeout(timeout);
break;
}
@@ -603,7 +603,7 @@
eloop_timeout_handler handler, void *eloop_data,
void *user_data)
{
- struct os_time now, requested, remaining;
+ struct os_reltime now, requested, remaining;
struct eloop_timeout *tmp;
dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
@@ -612,9 +612,9 @@
tmp->user_data == user_data) {
requested.sec = req_secs;
requested.usec = req_usecs;
- os_get_time(&now);
- os_time_sub(&tmp->time, &now, &remaining);
- if (os_time_before(&requested, &remaining)) {
+ os_get_reltime(&now);
+ os_reltime_sub(&tmp->time, &now, &remaining);
+ if (os_reltime_before(&requested, &remaining)) {
eloop_cancel_timeout(handler, eloop_data,
user_data);
eloop_register_timeout(requested.sec,
@@ -634,7 +634,7 @@
eloop_timeout_handler handler, void *eloop_data,
void *user_data)
{
- struct os_time now, requested, remaining;
+ struct os_reltime now, requested, remaining;
struct eloop_timeout *tmp;
dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
@@ -643,9 +643,9 @@
tmp->user_data == user_data) {
requested.sec = req_secs;
requested.usec = req_usecs;
- os_get_time(&now);
- os_time_sub(&tmp->time, &now, &remaining);
- if (os_time_before(&remaining, &requested)) {
+ os_get_reltime(&now);
+ os_reltime_sub(&tmp->time, &now, &remaining);
+ if (os_reltime_before(&remaining, &requested)) {
eloop_cancel_timeout(handler, eloop_data,
user_data);
eloop_register_timeout(requested.sec,
@@ -776,7 +776,7 @@
struct timeval _tv;
#endif /* CONFIG_ELOOP_POLL */
int res;
- struct os_time tv, now;
+ struct os_reltime tv, now;
#ifndef CONFIG_ELOOP_POLL
rfds = os_malloc(sizeof(*rfds));
@@ -793,9 +793,9 @@
timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
list);
if (timeout) {
- os_get_time(&now);
- if (os_time_before(&now, &timeout->time))
- os_time_sub(&timeout->time, &now, &tv);
+ os_get_reltime(&now);
+ if (os_reltime_before(&now, &timeout->time))
+ os_reltime_sub(&timeout->time, &now, &tv);
else
tv.sec = tv.usec = 0;
#ifdef CONFIG_ELOOP_POLL
@@ -837,8 +837,8 @@
timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
list);
if (timeout) {
- os_get_time(&now);
- if (!os_time_before(&now, &timeout->time)) {
+ os_get_reltime(&now);
+ if (!os_reltime_before(&now, &timeout->time)) {
void *eloop_data = timeout->eloop_data;
void *user_data = timeout->user_data;
eloop_timeout_handler handler =
@@ -883,9 +883,9 @@
void eloop_destroy(void)
{
struct eloop_timeout *timeout, *prev;
- struct os_time now;
+ struct os_reltime now;
- os_get_time(&now);
+ os_get_reltime(&now);
dl_list_for_each_safe(timeout, prev, &eloop.timeout,
struct eloop_timeout, list) {
int sec, usec;
diff --git a/src/utils/eloop.h b/src/utils/eloop.h
index 274714f..d3980fa 100644
--- a/src/utils/eloop.h
+++ b/src/utils/eloop.h
@@ -207,7 +207,7 @@
*/
int eloop_cancel_timeout_one(eloop_timeout_handler handler,
void *eloop_data, void *user_data,
- struct os_time *remaining);
+ struct os_reltime *remaining);
/**
* eloop_is_timeout_registered - Check if a timeout is already registered
diff --git a/src/utils/eloop_win.c b/src/utils/eloop_win.c
index e87d82a..a1f9996 100644
--- a/src/utils/eloop_win.c
+++ b/src/utils/eloop_win.c
@@ -31,7 +31,7 @@
struct eloop_timeout {
struct dl_list list;
- struct os_time time;
+ struct os_reltime time;
void *eloop_data;
void *user_data;
eloop_timeout_handler handler;
@@ -244,7 +244,7 @@
timeout = os_zalloc(sizeof(*timeout));
if (timeout == NULL)
return -1;
- if (os_get_time(&timeout->time) < 0) {
+ if (os_get_reltime(&timeout->time) < 0) {
os_free(timeout);
return -1;
}
@@ -271,7 +271,7 @@
/* Maintain timeouts in order of increasing time */
dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
- if (os_time_before(&timeout->time, &tmp->time)) {
+ if (os_reltime_before(&timeout->time, &tmp->time)) {
dl_list_add(tmp->list.prev, &timeout->list);
return 0;
}
@@ -313,13 +313,13 @@
int eloop_cancel_timeout_one(eloop_timeout_handler handler,
void *eloop_data, void *user_data,
- struct os_time *remaining)
+ struct os_reltime *remaining)
{
struct eloop_timeout *timeout, *prev;
int removed = 0;
- struct os_time now;
+ struct os_reltime now;
- os_get_time(&now);
+ os_get_reltime(&now);
remaining->sec = remaining->usec = 0;
dl_list_for_each_safe(timeout, prev, &eloop.timeout,
@@ -328,8 +328,8 @@
(timeout->eloop_data == eloop_data) &&
(timeout->user_data == user_data)) {
removed = 1;
- if (os_time_before(&now, &timeout->time))
- os_time_sub(&timeout->time, &now, remaining);
+ if (os_reltime_before(&now, &timeout->time))
+ os_reltime_sub(&timeout->time, &now, remaining);
eloop_remove_timeout(timeout);
break;
}
@@ -358,7 +358,7 @@
eloop_timeout_handler handler, void *eloop_data,
void *user_data)
{
- struct os_time now, requested, remaining;
+ struct os_reltime now, requested, remaining;
struct eloop_timeout *tmp;
dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
@@ -367,9 +367,9 @@
tmp->user_data == user_data) {
requested.sec = req_secs;
requested.usec = req_usecs;
- os_get_time(&now);
- os_time_sub(&tmp->time, &now, &remaining);
- if (os_time_before(&requested, &remaining)) {
+ os_get_reltime(&now);
+ os_reltime_sub(&tmp->time, &now, &remaining);
+ if (os_reltime_before(&requested, &remaining)) {
eloop_cancel_timeout(handler, eloop_data,
user_data);
eloop_register_timeout(requested.sec,
@@ -389,7 +389,7 @@
eloop_timeout_handler handler, void *eloop_data,
void *user_data)
{
- struct os_time now, requested, remaining;
+ struct os_reltime now, requested, remaining;
struct eloop_timeout *tmp;
dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
@@ -398,9 +398,9 @@
tmp->user_data == user_data) {
requested.sec = req_secs;
requested.usec = req_usecs;
- os_get_time(&now);
- os_time_sub(&tmp->time, &now, &remaining);
- if (os_time_before(&remaining, &requested)) {
+ os_get_reltime(&now);
+ os_reltime_sub(&tmp->time, &now, &remaining);
+ if (os_reltime_before(&remaining, &requested)) {
eloop_cancel_timeout(handler, eloop_data,
user_data);
eloop_register_timeout(requested.sec,
@@ -530,7 +530,7 @@
void eloop_run(void)
{
- struct os_time tv, now;
+ struct os_reltime tv, now;
DWORD count, ret, timeout_val, err;
size_t i;
@@ -542,9 +542,9 @@
timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
list);
if (timeout) {
- os_get_time(&now);
- if (os_time_before(&now, &timeout->time))
- os_time_sub(&timeout->time, &now, &tv);
+ os_get_reltime(&now);
+ if (os_reltime_before(&now, &timeout->time))
+ os_reltime_sub(&timeout->time, &now, &tv);
}
count = 0;
@@ -583,8 +583,8 @@
timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
list);
if (timeout) {
- os_get_time(&now);
- if (!os_time_before(&now, &timeout->time)) {
+ os_get_reltime(&now);
+ if (!os_reltime_before(&now, &timeout->time)) {
void *eloop_data = timeout->eloop_data;
void *user_data = timeout->user_data;
eloop_timeout_handler handler =
diff --git a/src/utils/os.h b/src/utils/os.h
index 2aab13a..77dc6e3 100644
--- a/src/utils/os.h
+++ b/src/utils/os.h
@@ -23,6 +23,11 @@
os_time_t usec;
};
+struct os_reltime {
+ os_time_t sec;
+ os_time_t usec;
+};
+
/**
* os_get_time - Get current time (sec, usec)
* @t: Pointer to buffer for the time
@@ -30,21 +35,56 @@
*/
int os_get_time(struct os_time *t);
+/**
+ * os_get_reltime - Get relative time (sec, usec)
+ * @t: Pointer to buffer for the time
+ * Returns: 0 on success, -1 on failure
+ */
+int os_get_reltime(struct os_reltime *t);
-/* Helper macros for handling struct os_time */
-#define os_time_before(a, b) \
- ((a)->sec < (b)->sec || \
- ((a)->sec == (b)->sec && (a)->usec < (b)->usec))
+/* Helpers for handling struct os_time */
-#define os_time_sub(a, b, res) do { \
- (res)->sec = (a)->sec - (b)->sec; \
- (res)->usec = (a)->usec - (b)->usec; \
- if ((res)->usec < 0) { \
- (res)->sec--; \
- (res)->usec += 1000000; \
- } \
-} while (0)
+static inline int os_time_before(struct os_time *a, struct os_time *b)
+{
+ return (a->sec < b->sec) ||
+ (a->sec == b->sec && a->usec < b->usec);
+}
+
+
+static inline void os_time_sub(struct os_time *a, struct os_time *b,
+ struct os_time *res)
+{
+ res->sec = a->sec - b->sec;
+ res->usec = a->usec - b->usec;
+ if (res->usec < 0) {
+ res->sec--;
+ res->usec += 1000000;
+ }
+}
+
+
+/* Helpers for handling struct os_reltime */
+
+static inline int os_reltime_before(struct os_reltime *a,
+ struct os_reltime *b)
+{
+ return (a->sec < b->sec) ||
+ (a->sec == b->sec && a->usec < b->usec);
+}
+
+
+static inline void os_reltime_sub(struct os_reltime *a, struct os_reltime *b,
+ struct os_reltime *res)
+{
+ res->sec = a->sec - b->sec;
+ res->usec = a->usec - b->usec;
+ if (res->usec < 0) {
+ res->sec--;
+ res->usec += 1000000;
+ }
+}
+
/**
* os_mktime - Convert broken-down time into seconds since 1970-01-01
diff --git a/src/utils/os_internal.c b/src/utils/os_internal.c
index e4b7fdb..2cb0d12 100644
--- a/src/utils/os_internal.c
+++ b/src/utils/os_internal.c
@@ -41,6 +41,17 @@
}
+int os_get_reltime(struct os_reltime *t)
+{
+ int res;
+ struct timeval tv;
+ res = gettimeofday(&tv, NULL);
+ t->sec = tv.tv_sec;
+ t->usec = tv.tv_usec;
+ return res;
+}
+
+
int os_mktime(int year, int month, int day, int hour, int min, int sec,
os_time_t *t)
{
diff --git a/src/utils/os_none.c b/src/utils/os_none.c
index cabf73b..228c472 100644
--- a/src/utils/os_none.c
+++ b/src/utils/os_none.c
@@ -26,6 +26,12 @@
}
+int os_get_reltime(struct os_reltime *t)
+{
+ return -1;
+}
+
+
int os_mktime(int year, int month, int day, int hour, int min, int sec,
os_time_t *t)
{
diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c
index 960073a..fa67fdf 100644
--- a/src/utils/os_unix.c
+++ b/src/utils/os_unix.c
@@ -60,6 +60,43 @@
}
+int os_get_reltime(struct os_reltime *t)
+{
+#if defined(CLOCK_BOOTTIME)
+ static clockid_t clock_id = CLOCK_BOOTTIME;
+#elif defined(CLOCK_MONOTONIC)
+ static clockid_t clock_id = CLOCK_MONOTONIC;
+#else
+ static clockid_t clock_id = CLOCK_REALTIME;
+#endif
+ struct timespec ts;
+ int res;
+
+ while (1) {
+ res = clock_gettime(clock_id, &ts);
+ if (res == 0) {
+ t->sec = ts.tv_sec;
+ t->usec = ts.tv_nsec / 1000;
+ return 0;
+ }
+ switch (clock_id) {
+#ifdef CLOCK_BOOTTIME
+ case CLOCK_BOOTTIME:
+ clock_id = CLOCK_MONOTONIC;
+ break;
+#endif
+#ifdef CLOCK_MONOTONIC
+ case CLOCK_MONOTONIC:
+ clock_id = CLOCK_REALTIME;
+ break;
+#endif
+ case CLOCK_REALTIME:
+ return -1;
+ }
+ }
+}
+
+
int os_mktime(int year, int month, int day, int hour, int min, int sec,
os_time_t *t)
{
diff --git a/src/utils/os_win32.c b/src/utils/os_win32.c
index 163cebe..1cfa7a5 100644
--- a/src/utils/os_win32.c
+++ b/src/utils/os_win32.c
@@ -47,6 +47,17 @@
}
+int os_get_reltime(struct os_reltime *t)
+{
+ /* consider using performance counters or so instead */
+ struct os_time now;
+ int res = os_get_time(&now);
+ t->sec = now.sec;
+ t->usec = now.usec;
+ return res;
+}
+
+
int os_mktime(int year, int month, int day, int hour, int min, int sec,
os_time_t *t)
{