wps_registrar: Use monotonic time for PBC session timeout
PBC sessions are just time-stamped when activated, and eventually time out, so should use monotonic time. While at it, make the code use os_reltime_expired(). Signed-hostap: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
3647e5a7cb
commit
61e98e9cf7
1 changed files with 10 additions and 9 deletions
|
@ -113,7 +113,7 @@ struct wps_pbc_session {
|
||||||
struct wps_pbc_session *next;
|
struct wps_pbc_session *next;
|
||||||
u8 addr[ETH_ALEN];
|
u8 addr[ETH_ALEN];
|
||||||
u8 uuid_e[WPS_UUID_LEN];
|
u8 uuid_e[WPS_UUID_LEN];
|
||||||
struct os_time timestamp;
|
struct os_reltime timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -311,9 +311,9 @@ static void wps_registrar_add_pbc_session(struct wps_registrar *reg,
|
||||||
const u8 *addr, const u8 *uuid_e)
|
const u8 *addr, const u8 *uuid_e)
|
||||||
{
|
{
|
||||||
struct wps_pbc_session *pbc, *prev = NULL;
|
struct wps_pbc_session *pbc, *prev = NULL;
|
||||||
struct os_time now;
|
struct os_reltime now;
|
||||||
|
|
||||||
os_get_time(&now);
|
os_get_reltime(&now);
|
||||||
|
|
||||||
pbc = reg->pbc_sessions;
|
pbc = reg->pbc_sessions;
|
||||||
while (pbc) {
|
while (pbc) {
|
||||||
|
@ -347,7 +347,8 @@ static void wps_registrar_add_pbc_session(struct wps_registrar *reg,
|
||||||
pbc = pbc->next;
|
pbc = pbc->next;
|
||||||
|
|
||||||
while (pbc) {
|
while (pbc) {
|
||||||
if (now.sec > pbc->timestamp.sec + WPS_PBC_WALK_TIME) {
|
if (os_reltime_expired(&now, &pbc->timestamp,
|
||||||
|
WPS_PBC_WALK_TIME)) {
|
||||||
prev->next = NULL;
|
prev->next = NULL;
|
||||||
wps_free_pbc_sessions(pbc);
|
wps_free_pbc_sessions(pbc);
|
||||||
break;
|
break;
|
||||||
|
@ -395,9 +396,9 @@ int wps_registrar_pbc_overlap(struct wps_registrar *reg,
|
||||||
int count = 0;
|
int count = 0;
|
||||||
struct wps_pbc_session *pbc;
|
struct wps_pbc_session *pbc;
|
||||||
struct wps_pbc_session *first = NULL;
|
struct wps_pbc_session *first = NULL;
|
||||||
struct os_time now;
|
struct os_reltime now;
|
||||||
|
|
||||||
os_get_time(&now);
|
os_get_reltime(&now);
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "WPS: Checking active PBC sessions for overlap");
|
wpa_printf(MSG_DEBUG, "WPS: Checking active PBC sessions for overlap");
|
||||||
|
|
||||||
|
@ -413,9 +414,9 @@ int wps_registrar_pbc_overlap(struct wps_registrar *reg,
|
||||||
MAC2STR(pbc->addr));
|
MAC2STR(pbc->addr));
|
||||||
wpa_hexdump(MSG_DEBUG, "WPS: UUID-E",
|
wpa_hexdump(MSG_DEBUG, "WPS: UUID-E",
|
||||||
pbc->uuid_e, WPS_UUID_LEN);
|
pbc->uuid_e, WPS_UUID_LEN);
|
||||||
if (now.sec > pbc->timestamp.sec + WPS_PBC_WALK_TIME) {
|
if (os_reltime_expired(&now, &pbc->timestamp,
|
||||||
wpa_printf(MSG_DEBUG, "WPS: PBC walk time has "
|
WPS_PBC_WALK_TIME)) {
|
||||||
"expired");
|
wpa_printf(MSG_DEBUG, "WPS: PBC walk time has expired");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (first &&
|
if (first &&
|
||||||
|
|
Loading…
Add table
Reference in a new issue