P2P: Add dynamic network config block parameters for P2P
authorJouni Malinen <jouni.malinen@atheros.com>
Sun, 18 Jul 2010 21:30:24 +0000 (14:30 -0700)
committerJouni Malinen <j@w1.fi>
Thu, 9 Sep 2010 14:17:16 +0000 (07:17 -0700)
wpa_supplicant/ap.c
wpa_supplicant/config.c
wpa_supplicant/config_ssid.h
wpa_supplicant/ctrl_iface.c
wpa_supplicant/wpa_supplicant.c

index e2be10c..a1fe9c6 100644 (file)
@@ -182,6 +182,8 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
                params.mode = IEEE80211_MODE_IBSS;
                break;
        case WPAS_MODE_AP:
+       case WPAS_MODE_P2P_GO:
+       case WPAS_MODE_P2P_GROUP_FORMATION:
                params.mode = IEEE80211_MODE_AP;
                break;
        }
index dd6d229..427aa1c 100644 (file)
@@ -1493,7 +1493,7 @@ static const struct parse_data ssid_fields[] = {
        { STRe(pac_file) },
        { INTe(fragment_size) },
 #endif /* IEEE8021X_EAPOL */
-       { INT_RANGE(mode, 0, 2) },
+       { INT_RANGE(mode, 0, 4) },
        { INT_RANGE(proactive_key_caching, 0, 1) },
        { INT_RANGE(disabled, 0, 1) },
        { STR(id_str) },
index 25e87aa..38da3fc 100644 (file)
@@ -109,6 +109,9 @@ struct wpa_ssid {
         *
         * If set, this network block is used only when associating with the AP
         * using the configured BSSID
+        *
+        * If this is a persistent P2P group (disabled == 2), this is the GO
+        * Device Address.
         */
        u8 bssid[ETH_ALEN];
 
@@ -273,6 +276,11 @@ struct wpa_ssid {
         *
         * 2 = AP (access point)
         *
+        * 3 = P2P Group Owner (can be set in the configuration file)
+        *
+        * 4 = P2P Group Formation (used internally; not in configuration
+        * files)
+        *
         * 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
@@ -284,6 +292,8 @@ struct wpa_ssid {
                WPAS_MODE_INFRA = 0,
                WPAS_MODE_IBSS = 1,
                WPAS_MODE_AP = 2,
+               WPAS_MODE_P2P_GO = 3,
+               WPAS_MODE_P2P_GROUP_FORMATION = 4,
        } mode;
 
        /**
@@ -292,6 +302,8 @@ struct wpa_ssid {
         * 0 = this network can be used (default).
         * 1 = this network block is disabled (can be enabled through
         * ctrl_iface, e.g., with wpa_cli or wpa_gui).
+        * 2 = this network block includes parameters for a persistent P2P
+        * group (can be used with P2P ctrl_iface commands)
         */
        int disabled;
 
@@ -373,6 +385,21 @@ struct wpa_ssid {
         * considered when selecting a BSS.
         */
        int *freq_list;
+
+       /**
+        * p2p_group - Network generated as a P2P group (used internally)
+        */
+       int p2p_group;
+
+       /**
+        * p2p_persistent_group - Whether this is a persistent group
+        */
+       int p2p_persistent_group;
+
+       /**
+        * temporary - Whether this network is temporary and not to be saved
+        */
+       int temporary;
 };
 
 #endif /* CONFIG_SSID_H */
index 70c762b..e89efe2 100644 (file)
@@ -554,6 +554,15 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
                                ret = os_snprintf(pos, end - pos,
                                                  "mode=AP\n");
                                break;
+                       case WPAS_MODE_P2P_GO:
+                               ret = os_snprintf(pos, end - pos,
+                                                 "mode=P2P GO\n");
+                               break;
+                       case WPAS_MODE_P2P_GROUP_FORMATION:
+                               ret = os_snprintf(pos, end - pos,
+                                                 "mode=P2P GO - group "
+                                                 "formation\n");
+                               break;
                        default:
                                ret = 0;
                                break;
index b53609b..df11814 100644 (file)
@@ -1005,7 +1005,8 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
        int assoc_failed = 0;
        struct wpa_ssid *old_ssid;
 
-       if (ssid->mode == WPAS_MODE_AP) {
+       if (ssid->mode == WPAS_MODE_AP || ssid->mode == WPAS_MODE_P2P_GO ||
+           ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION) {
 #ifdef CONFIG_AP
                if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP)) {
                        wpa_printf(MSG_INFO, "Driver does not support AP "