From d1723c5566d0b582cf4309e725e22970fa1ce0a1 Mon Sep 17 00:00:00 2001 From: Lior David Date: Wed, 3 Aug 2016 17:53:21 +0300 Subject: [PATCH] wpa_supplicant: Allow FTM functionality to be published Add configuration options that control publishing of fine timing measurement (FTM) responder and initiator functionality via bits 70, 71 of Extended Capabilities element. Typically, FTM functionality is controlled by a location framework outside wpa_supplicant. When framework is activated, it will use wpa_supplicant to configure the STA/AP to publish the FTM functionality. See IEEE P802.11-REVmc/D7.0, 9.4.2.27. Signed-off-by: Lior David --- wpa_supplicant/ap.c | 3 +++ wpa_supplicant/config.c | 2 ++ wpa_supplicant/config.h | 26 ++++++++++++++++++++++++++ wpa_supplicant/config_file.c | 5 +++++ wpa_supplicant/wpa_supplicant.c | 11 +++++++++++ wpa_supplicant/wpa_supplicant.conf | 16 ++++++++++++++++ 6 files changed, 63 insertions(+) diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c index 7710a8df3..356784ab9 100644 --- a/wpa_supplicant/ap.c +++ b/wpa_supplicant/ap.c @@ -468,6 +468,9 @@ no_wps: wpabuf_dup(wpa_s->conf->ap_vendor_elements); } + bss->ftm_responder = wpa_s->conf->ftm_responder; + bss->ftm_initiator = wpa_s->conf->ftm_initiator; + return 0; } diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 3f69936d1..dd922caf8 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -4369,6 +4369,8 @@ static const struct global_parse_data global_fields[] = { MBO_CELL_CAPA_NOT_SUPPORTED), 0 }, #endif /*CONFIG_MBO */ { INT(gas_address3), 0 }, + { INT_RANGE(ftm_responder, 0, 1), 0 }, + { INT_RANGE(ftm_initiator, 0, 1), 0 }, }; #undef FUNC diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index 153573897..48e64be5d 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -1302,6 +1302,32 @@ struct wpa_config { * sent to not-associated AP; if associated, AP BSSID) */ int gas_address3; + + /** + * ftm_responder - Publish FTM (fine timing measurement) + * responder functionality + * + * Values: + * 0 - do not publish FTM responder functionality (Default) + * 1 - publish FTM responder functionality in + * bit 70 of Extended Capabilities element + * Note, actual FTM responder operation is managed outside + * wpa_supplicant. + */ + int ftm_responder; + + /** + * ftm_initiator - Publish FTM (fine timing measurement) + * initiator functionality + * + * Values: + * 0 - do not publish FTM initiator functionality (Default) + * 1 - publish FTM initiator functionality in + * bit 71 of Extended Capabilities element + * Note, actual FTM initiator operation is managed outside + * wpa_supplicant. + */ + int ftm_initiator; }; diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index 994d5ea6e..7ae16545b 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -1339,6 +1339,11 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config) if (config->gas_address3) fprintf(f, "gas_address3=%d\n", config->gas_address3); + + if (config->ftm_responder) + fprintf(f, "ftm_responder=%d\n", config->ftm_responder); + if (config->ftm_initiator) + fprintf(f, "ftm_initiator=%d\n", config->ftm_initiator); } #endif /* CONFIG_NO_CONFIG_WRITE */ diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 5bb1f72c8..07855764a 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -1456,6 +1456,14 @@ static void wpas_ext_capab_byte(struct wpa_supplicant *wpa_s, u8 *pos, int idx) break; case 6: /* Bits 48-55 */ break; + case 7: /* Bits 56-63 */ + break; + case 8: /* Bits 64-71 */ + if (wpa_s->conf->ftm_responder) + *pos |= 0x40; /* Bit 70 - FTM responder */ + if (wpa_s->conf->ftm_initiator) + *pos |= 0x80; /* Bit 71 - FTM initiator */ + break; } } @@ -1465,6 +1473,9 @@ int wpas_build_ext_capab(struct wpa_supplicant *wpa_s, u8 *buf, size_t buflen) u8 *pos = buf; u8 len = 6, i; + if (len < 9 && + (wpa_s->conf->ftm_initiator || wpa_s->conf->ftm_responder)) + len = 9; if (len < wpa_s->extended_capa_len) len = wpa_s->extended_capa_len; if (buflen < (size_t) len + 2) { diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf index 6ece942d9..c3d52724f 100644 --- a/wpa_supplicant/wpa_supplicant.conf +++ b/wpa_supplicant/wpa_supplicant.conf @@ -449,6 +449,22 @@ fast_reauth=1 # sent to not-associated AP; if associated, AP BSSID) #gas_address3=0 +# Publish fine timing measurement (FTM) responder functionality in +# the Extended Capabilities element bit 70. +# Controls whether FTM responder functionality will be published by AP/STA. +# Note that actual FTM responder operation is managed outside wpa_supplicant. +# 0 = Do not publish; default +# 1 = Publish +#ftm_responder=0 + +# Publish fine timing measurement (FTM) initiator functionality in +# the Extended Capabilities element bit 71. +# Controls whether FTM initiator functionality will be published by AP/STA. +# Note that actual FTM initiator operation is managed outside wpa_supplicant. +# 0 = Do not publish; default +# 1 = Publish +#ftm_initiator=0 + # credential block # # Each credential used for automatic network selection is configured as a set