From 4d29f0d12afde09b0f84b8220c5ebeadefde9a8d Mon Sep 17 00:00:00 2001 From: Bruno Randolf Date: Thu, 28 Feb 2013 23:20:24 +0000 Subject: Add capability flag for IBSS and get_capabiliy modes Add a driver capability flag for drivers which support IBSS mode and set it for nl80211 drivers which have set the NL80211_IFTYPE_ADHOC. Add a new option "modes" to "get_capability" which will return "AP" and "IBSS" if the corresponding capability flags are set. Change-Id: I7991ae49b6ac6bc154d4edb0b01af774f4e8522c --- src/drivers/driver.h | 3 +++ src/drivers/driver_nl80211.c | 3 +++ wpa_supplicant/ctrl_iface.c | 43 +++++++++++++++++++++++++++++++++++++++++++ wpa_supplicant/wpa_cli.c | 2 +- 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index e9f926fd..fc1b06f1 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -834,6 +834,9 @@ struct wpa_driver_capa { #define WPA_DRIVER_FLAGS_INACTIVITY_TIMER 0x00800000 /* Driver expects user space implementation of MLME in AP mode */ #define WPA_DRIVER_FLAGS_AP_MLME 0x01000000 +/* Driver supports IBSS (Ad-hoc) mode */ +#define WPA_DRIVER_FLAGS_IBSS 0x02000000 + unsigned int flags; int max_scan_ssids; diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index b085e3b4..760e55b7 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -2470,6 +2470,9 @@ static int wiphy_info_handler(struct nl_msg *msg, void *arg) case NL80211_IFTYPE_AP: capa->flags |= WPA_DRIVER_FLAGS_AP; break; + case NL80211_IFTYPE_ADHOC: + capa->flags |= WPA_DRIVER_FLAGS_IBSS; + break; case NL80211_IFTYPE_P2P_GO: p2p_go_supported = 1; break; diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index bcf27beb..53393d17 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -2432,6 +2432,45 @@ static int ctrl_iface_get_capability_auth_alg(int res, char *strict, return pos - buf; } +static int ctrl_iface_get_capability_modes(int res, char *strict, + struct wpa_driver_capa *capa, + char *buf, size_t buflen) +{ + int ret, first = 1; + char *pos, *end; + size_t len; + + pos = buf; + end = pos + buflen; + + if (res < 0) { + if (strict) + return 0; + len = os_strlcpy(buf, "IBSS AP", buflen); + if (len >= buflen) + return -1; + return len; + } + + if (capa->flags & (WPA_DRIVER_FLAGS_IBSS)) { + ret = os_snprintf(pos, end - pos, "%sIBSS", first ? "" : " "); + if (ret < 0 || ret >= end - pos) + return pos - buf; + pos += ret; + first = 0; + } + + if (capa->flags & (WPA_DRIVER_FLAGS_AP)) { + ret = os_snprintf(pos, end - pos, "%sAP", + first ? "" : " "); + if (ret < 0 || ret >= end - pos) + return pos - buf; + pos += ret; + first = 0; + } + + return pos - buf; +} static int ctrl_iface_get_capability_channels(struct wpa_supplicant *wpa_s, char *buf, size_t buflen) @@ -2530,6 +2569,10 @@ static int wpa_supplicant_ctrl_iface_get_capability( return ctrl_iface_get_capability_auth_alg(res, strict, &capa, buf, buflen); + if (os_strcmp(field, "modes") == 0) + return ctrl_iface_get_capability_modes(res, strict, &capa, + buf, buflen); + if (os_strcmp(field, "channels") == 0) return ctrl_iface_get_capability_channels(wpa_s, buf, buflen); diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 3986b9be..97e11bbe 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -2417,7 +2417,7 @@ static struct wpa_cli_cmd wpa_cli_commands[] = { "< | > = get detailed scan result info" }, { "get_capability", wpa_cli_cmd_get_capability, NULL, cli_cmd_flag_none, - " " + " " "= get capabilies" }, { "reconfigure", wpa_cli_cmd_reconfigure, NULL, cli_cmd_flag_none, -- cgit v1.2.3