@@ -2168,7 +2168,7 @@ wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
break;
wpa_s->interface_removed = 0;
wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was added");
- if (wpa_supplicant_driver_init(wpa_s, 1) < 0) {
+ if (wpa_supplicant_driver_init(wpa_s) < 0) {
wpa_msg(wpa_s, MSG_INFO, "Failed to initialize the "
"driver after interface was added");
}
@@ -2909,7 +2909,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
case EVENT_INTERFACE_ENABLED:
wpa_dbg(wpa_s, MSG_DEBUG, "Interface was enabled");
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
- wpa_supplicant_update_mac_addr(wpa_s, 1);
+ wpa_supplicant_update_mac_addr(wpa_s);
#ifdef CONFIG_AP
if (!wpa_s->ap_iface) {
wpa_supplicant_set_state(wpa_s,
@@ -14,6 +14,7 @@
#include "common.h"
#include "wpa_supplicant_i.h"
#include "driver_i.h"
+#include "p2p_supplicant.h"
extern struct wpa_driver_ops *wpa_drivers[];
@@ -262,7 +263,7 @@ int main(int argc, char *argv[])
if (iface == NULL)
goto out;
ifaces = iface;
- iface = &ifaces[iface_count - 1];
+ iface = &ifaces[iface_count - 1];
os_memset(iface, 0, sizeof(*iface));
break;
default:
@@ -284,6 +285,8 @@ int main(int argc, char *argv[])
}
for (i = 0; exitcode == 0 && i < iface_count; i++) {
+ struct wpa_supplicant *wpa_s;
+
if ((ifaces[i].confname == NULL &&
ifaces[i].ctrl_interface == NULL) ||
ifaces[i].ifname == NULL) {
@@ -294,8 +297,16 @@ int main(int argc, char *argv[])
exitcode = -1;
break;
}
- if (wpa_supplicant_add_iface(global, &ifaces[i]) == NULL)
+ wpa_s = wpa_supplicant_add_iface(global, &ifaces[i]);
+ if (wpa_s == NULL) {
exitcode = -1;
+ break;
+ }
+ if (wpa_s->global->p2p == NULL &&
+ (wpa_s->drv_flags & WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE)) {
+ if (wpas_p2p_add_p2pdev_interface(wpa_s) < 0)
+ exitcode = -1;
+ }
}
if (exitcode == 0)
@@ -14,6 +14,7 @@ struct p2p_go_neg_results;
enum p2p_send_action_result;
struct p2p_peer_info;
struct p2p_channels;
+struct wps_event_fail;
int wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s);
void wpas_p2p_deinit(struct wpa_supplicant *wpa_s);
@@ -2316,14 +2316,14 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
}
-int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s, int l2_needed)
+int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s)
{
if (wpa_s->driver->send_eapol) {
const u8 *addr = wpa_drv_get_mac_addr(wpa_s);
if (addr)
os_memcpy(wpa_s->own_addr, addr, ETH_ALEN);
- } else if (l2_needed && !(wpa_s->drv_flags &
- WPA_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE)) {
+ } else if (!wpa_s->p2p_mgmt &&
+ !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE)) {
l2_packet_deinit(wpa_s->l2);
wpa_s->l2 = l2_packet_init(wpa_s->ifname,
wpa_drv_get_mac_addr(wpa_s),
@@ -2374,18 +2374,17 @@ static void wpa_supplicant_rx_eapol_bridge(void *ctx, const u8 *src_addr,
/**
* wpa_supplicant_driver_init - Initialize driver interface parameters
* @wpa_s: Pointer to wpa_supplicant data
- * @l2_needed: need call l2_packet_init() for this interface
* Returns: 0 on success, -1 on failure
*
* This function is called to initialize driver interface parameters.
* wpa_drv_init() must have been called before this function to initialize the
* driver interface.
*/
-int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s, int l2_needed)
+int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s)
{
static int interface_count = 0;
- if (wpa_supplicant_update_mac_addr(wpa_s, l2_needed) < 0)
+ if (wpa_supplicant_update_mac_addr(wpa_s) < 0)
return -1;
wpa_dbg(wpa_s, MSG_DEBUG, "Own MAC address: " MACSTR,
@@ -2955,7 +2954,16 @@ next_driver:
if (wpa_s->max_remain_on_chan == 0)
wpa_s->max_remain_on_chan = 1000;
- if (wpa_supplicant_driver_init(wpa_s, !iface->p2p_mgmt) < 0)
+ /* only take p2p_mgmt parameters when P2P Device is supported.
+ * doing it here as it determines whether l2_packet_init()
+ * will be done during wpa_supplicant_driver_init().
+ */
+ if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE)
+ wpa_s->p2p_mgmt = iface->p2p_mgmt;
+ else
+ iface->p2p_mgmt = 1;
+
+ if (wpa_supplicant_driver_init(wpa_s) < 0)
return -1;
#ifdef CONFIG_TDLS
@@ -2997,13 +3005,7 @@ next_driver:
}
#ifdef CONFIG_P2P
- if (iface->p2p_mgmt == 0 && wpa_s->global->p2p == NULL &&
- (wpa_s->drv_flags & WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE)) {
- if (wpas_p2p_add_p2pdev_interface(wpa_s) < 0) {
- wpa_msg(wpa_s, MSG_ERROR, "Failed to create P2P Device");
- return -1;
- }
- } else if (wpas_p2p_init(wpa_s->global, wpa_s) < 0) {
+ if (iface->p2p_mgmt && wpas_p2p_init(wpa_s->global, wpa_s) < 0) {
wpa_msg(wpa_s, MSG_ERROR, "Failed to init P2P");
return -1;
}
@@ -568,6 +568,8 @@ struct wpa_supplicant {
unsigned int roc_waiting_drv_freq;
int action_tx_wait_time;
+ int p2p_mgmt;
+
#ifdef CONFIG_P2P
struct p2p_go_neg_results *go_params;
int create_p2p_iface;
@@ -715,8 +717,8 @@ int wpa_supplicant_set_wpa_none_key(struct wpa_supplicant *wpa_s,
int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
const char * wpa_supplicant_state_txt(enum wpa_states state);
-int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s, int l2_needed);
-int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s, int l2_needed);
+int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s);
+int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
struct wpa_bss *bss, struct wpa_ssid *ssid,
u8 *wpa_ie, size_t *wpa_ie_len);