[PATCH] Adding new mode - WPAS_MODE_P2P_CLIENT for P2P client.
Jouni Malinen
j
Mon Apr 11 12:15:21 PDT 2011
On Fri, Apr 08, 2011 at 10:05:37PM +0300, Janusz Dziedzic wrote:
> New mode added for p2p_client. Now we know if we are p2p_client or
> legacy station.
Thanks! I did not originally want to add a separate mode for P2P Client,
but there is starting to be enough justification to do this. However,
your patch does not seem to cover all paths that can create a P2P Client
connection and it does not change all places where ssid->mode is being
checked against WPAS_MODE_INFRA.
While going through the places, I filled in some of the missing areas,
but I'm not sure that even this is complete yet, so I have not committed
this. Some more review for this is still needed, especially from the
view point of what gets exposed to src/drivers/driver_*.c. In addition,
it could be nice to get rid of the WPAS_MODE_INFRA within the P2P use
cases completely, but I did not want to do that without much more
thorough review of wpa_supplicant/p2p_supplicant.c and related code
areas.
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index 95279d3..ec61d99 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -328,6 +328,7 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
params.ssid_len = ssid->ssid_len;
switch (ssid->mode) {
case WPAS_MODE_INFRA:
+ case WPAS_MODE_P2P_CLIENT:
params.mode = IEEE80211_MODE_INFRA;
break;
case WPAS_MODE_IBSS:
diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h
index 8419f43..3c34fe1 100644
--- a/wpa_supplicant/config_ssid.h
+++ b/wpa_supplicant/config_ssid.h
@@ -281,6 +281,8 @@ struct wpa_ssid {
* 4 = P2P Group Formation (used internally; not in configuration
* files)
*
+ * 5 = P2P Client (used internally)
+ *
* Note: IBSS can only be used with key_mgmt NONE (plaintext and
* static WEP) and key_mgmt=WPA-NONE (fixed group key TKIP/CCMP). In
* addition, ap_scan has to be set to 2 for IBSS. WPA-None requires
@@ -294,6 +296,7 @@ struct wpa_ssid {
WPAS_MODE_AP = 2,
WPAS_MODE_P2P_GO = 3,
WPAS_MODE_P2P_GROUP_FORMATION = 4,
+ WPAS_MODE_P2P_CLIENT = 5,
} mode;
/**
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 5488ea4..113d450 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -812,6 +812,11 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
"mode=P2P GO - group "
"formation\n");
break;
+
+ case WPAS_MODE_P2P_CLIENT:
+ ret = os_snprintf(pos, end - pos,
+ "mode=P2P Client\n");
+ break;
default:
ret = 0;
break;
diff --git a/wpa_supplicant/mlme.c b/wpa_supplicant/mlme.c
index 49713f5..e66435d 100644
--- a/wpa_supplicant/mlme.c
+++ b/wpa_supplicant/mlme.c
@@ -2162,7 +2162,8 @@ static void ieee80211_sta_timer(void *eloop_ctx, void *timeout_ctx)
static void ieee80211_sta_new_auth(struct wpa_supplicant *wpa_s)
{
struct wpa_ssid *ssid = wpa_s->current_ssid;
- if (ssid && ssid->mode != WPAS_MODE_INFRA)
+ if (ssid && ssid->mode != WPAS_MODE_INFRA &&
+ ssid->mode != WPAS_MODE_P2P_CLIENT)
return;
#if 0 /* FIX */
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index cfa6510..0b34b6c 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -237,7 +237,8 @@ static void wpas_p2p_group_delete(struct wpa_supplicant *wpa_s)
if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_GO)
gtype = "GO";
else if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT ||
- (ssid && ssid->mode == WPAS_MODE_INFRA)) {
+ (ssid && (ssid->mode == WPAS_MODE_INFRA ||
+ ssid->mode == WPAS_MODE_P2P_CLIENT))) {
wpa_s->reassociate = 0;
wpa_s->disconnected = 1;
wpa_supplicant_deauthenticate(wpa_s,
@@ -480,7 +481,8 @@ static void wpas_group_formation_completed(struct wpa_supplicant *wpa_s,
persistent = 0;
if (ssid) {
ssid_txt = wpa_ssid_txt(ssid->ssid, ssid->ssid_len);
- client = ssid->mode == WPAS_MODE_INFRA;
+ client = ssid->mode == WPAS_MODE_INFRA ||
+ ssid->mode == WPAS_MODE_P2P_CLIENT;
if (ssid->mode == WPAS_MODE_P2P_GO) {
persistent = ssid->p2p_persistent_group;
os_memcpy(go_dev_addr, wpa_s->parent->own_addr,
@@ -3272,6 +3274,7 @@ static int wpas_start_p2p_client(struct wpa_supplicant *wpa_s,
wpas_notify_network_added(wpa_s, ssid);
wpa_config_set_network_defaults(ssid);
ssid->temporary = 1;
+ ssid->mode = WPAS_MODE_P2P_CLIENT;
ssid->proto = WPA_PROTO_RSN;
ssid->pairwise_cipher = WPA_CIPHER_CCMP;
ssid->group_cipher = WPA_CIPHER_CCMP;
@@ -3321,7 +3324,8 @@ int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s,
/* Make sure we are not running find during connection establishment */
wpas_p2p_stop_find(wpa_s);
- if (ssid->mode == WPAS_MODE_INFRA)
+ if (ssid->mode == WPAS_MODE_INFRA ||
+ ssid->mode == WPAS_MODE_P2P_CLIENT)
return wpas_start_p2p_client(wpa_s, ssid, addr_allocated);
if (ssid->mode != WPAS_MODE_P2P_GO)
@@ -3769,6 +3773,9 @@ void wpas_p2p_completed(struct wpa_supplicant *wpa_s)
if (wpa_s->global->p2p_group_formation == wpa_s)
wpa_s->global->p2p_group_formation = NULL;
+ if (ssid->mode == WPAS_MODE_INFRA)
+ ssid->mode = WPAS_MODE_P2P_CLIENT;
+
if (ssid->passphrase == NULL && ssid->psk_set) {
char psk[65];
wpa_snprintf_hex(psk, sizeof(psk), ssid->psk, 32);
@@ -3804,7 +3811,8 @@ int wpas_p2p_presence_req(struct wpa_supplicant *wpa_s, u32 duration1,
if (wpa_s->wpa_state < WPA_ASSOCIATED ||
wpa_s->current_ssid == NULL ||
- wpa_s->current_ssid->mode != WPAS_MODE_INFRA)
+ (wpa_s->current_ssid->mode != WPAS_MODE_INFRA &&
+ wpa_s->current_ssid->mode != WPAS_MODE_P2P_CLIENT))
return -1;
return p2p_presence_req(wpa_s->global->p2p, wpa_s->bssid,
@@ -4040,7 +4048,8 @@ static void wpas_p2p_disable_cross_connect(struct wpa_supplicant *uplink)
void wpas_p2p_notif_connected(struct wpa_supplicant *wpa_s)
{
if (wpa_s->ap_iface || wpa_s->current_ssid == NULL ||
- wpa_s->current_ssid->mode != WPAS_MODE_INFRA ||
+ (wpa_s->current_ssid->mode != WPAS_MODE_INFRA &&
+ wpa_s->current_ssid->mode != WPAS_MODE_P2P_CLIENT) ||
wpa_s->cross_connect_disallowed)
wpas_p2p_disable_cross_connect(wpa_s);
else
@@ -4082,7 +4091,8 @@ static void wpas_p2p_cross_connect_setup(struct wpa_supplicant *wpa_s)
wpa_s->ifname, wpa_s->cross_connect_uplink);
if (iface->ap_iface || iface->current_ssid == NULL ||
- iface->current_ssid->mode != WPAS_MODE_INFRA ||
+ (iface->current_ssid->mode != WPAS_MODE_INFRA &&
+ iface->current_ssid->mode != WPAS_MODE_P2P_CLIENT) ||
iface->cross_connect_disallowed ||
iface->wpa_state != WPA_COMPLETED)
break;
--
Jouni Malinen PGP id EFC895FA
More information about the Hostap
mailing list