From 0f039e343273e89c0e9bd9e047d2191dd706099c Mon Sep 17 00:00:00 2001 From: Avraham Stern Date: Tue, 3 Nov 2015 16:30:10 +0200 Subject: [PATCH] Add an option to create interface of a certain type with INTERFACE_ADD Some drivers do not support having two station interfaces, so the fact that wpa_supplicant always creates a new interface in station mode, even if it will be used as another type of interface, may prevent wpa_supplicant from creating new interfaces. Allow setting the interface type when a new interface is created so that interfaces of supported types can be created. Currently supported types are station ("sta") and AP ("ap"). If the interface type is not specified, a station interface will be created. Signed-off-by: Avraham Stern --- wpa_supplicant/ctrl_iface.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 6113db648..598e76b58 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -8859,10 +8859,11 @@ static int wpa_supplicant_global_iface_add(struct wpa_global *global, struct wpa_supplicant *wpa_s; unsigned int create_iface = 0; u8 mac_addr[ETH_ALEN]; + enum wpa_driver_if_type type = WPA_IF_STATION; /* * TABTABTABTAB - * TAB[TAB] + * TAB[TAB[TAB]] */ wpa_printf(MSG_DEBUG, "CTRL_IFACE GLOBAL INTERFACE_ADD '%s'", cmd); @@ -8930,9 +8931,22 @@ static int wpa_supplicant_global_iface_add(struct wpa_global *global, if (!extra[0]) break; - if (os_strcmp(extra, "create") == 0) + if (os_strcmp(extra, "create") == 0) { create_iface = 1; - else { + if (!pos) + break; + + if (os_strcmp(pos, "sta") == 0) { + type = WPA_IF_STATION; + } else if (os_strcmp(pos, "ap") == 0) { + type = WPA_IF_AP_BSS; + } else { + wpa_printf(MSG_DEBUG, + "INTERFACE_ADD unsupported interface type: '%s'", + pos); + return -1; + } + } else { wpa_printf(MSG_DEBUG, "INTERFACE_ADD unsupported extra parameter: '%s'", extra); @@ -8945,7 +8959,7 @@ static int wpa_supplicant_global_iface_add(struct wpa_global *global, iface.ifname); if (!global->ifaces) return -1; - if (wpa_drv_if_add(global->ifaces, WPA_IF_STATION, iface.ifname, + if (wpa_drv_if_add(global->ifaces, type, iface.ifname, NULL, NULL, NULL, mac_addr, NULL) < 0) { wpa_printf(MSG_ERROR, "CTRL_IFACE interface creation failed");