Add more wpa_supplicant AP mode parameters for the driver wrapper
authorJouni Malinen <jouni.malinen@atheros.com>
Sun, 11 Apr 2010 17:02:01 +0000 (20:02 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 11 Apr 2010 17:02:01 +0000 (20:02 +0300)
This makes it easier to configure AP mode for drivers that take care
of WPA/RSN IE generation.

wpa_supplicant/ap.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index fe26305..7023a56 100644 (file)
@@ -169,6 +169,26 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
        }
        params.freq = ssid->frequency;
 
+       if (ssid->key_mgmt & WPA_KEY_MGMT_PSK)
+               wpa_s->key_mgmt = WPA_KEY_MGMT_PSK;
+       else
+               wpa_s->key_mgmt = WPA_KEY_MGMT_NONE;
+       params.key_mgmt_suite = key_mgmt2driver(wpa_s->key_mgmt);
+
+       if (ssid->pairwise_cipher & WPA_CIPHER_CCMP)
+               wpa_s->pairwise_cipher = WPA_CIPHER_CCMP;
+       else if (ssid->pairwise_cipher & WPA_CIPHER_TKIP)
+               wpa_s->pairwise_cipher = WPA_CIPHER_TKIP;
+       else if (ssid->pairwise_cipher & WPA_CIPHER_NONE)
+               wpa_s->pairwise_cipher = WPA_CIPHER_NONE;
+       else {
+               wpa_printf(MSG_WARNING, "WPA: Failed to select pairwise "
+                          "cipher.");
+               return -1;
+       }
+       params.pairwise_suite = cipher_suite2driver(wpa_s->pairwise_cipher);
+       params.group_suite = params.pairwise_suite;
+
        if (wpa_drv_associate(wpa_s, &params) < 0) {
                wpa_msg(wpa_s, MSG_INFO, "Failed to start AP functionality");
                return -1;
index 2ad0309..9b6efdb 100644 (file)
@@ -688,7 +688,7 @@ static void wpa_supplicant_reconfig(int sig, void *signal_ctx)
 }
 
 
-static enum wpa_cipher cipher_suite2driver(int cipher)
+enum wpa_cipher cipher_suite2driver(int cipher)
 {
        switch (cipher) {
        case WPA_CIPHER_NONE:
@@ -706,7 +706,7 @@ static enum wpa_cipher cipher_suite2driver(int cipher)
 }
 
 
-static enum wpa_key_mgmt key_mgmt2driver(int key_mgmt)
+enum wpa_key_mgmt key_mgmt2driver(int key_mgmt)
 {
        switch (key_mgmt) {
        case WPA_KEY_MGMT_NONE:
index e6b2883..f5582c9 100644 (file)
@@ -497,6 +497,8 @@ int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
 void wpa_supplicant_terminate_proc(struct wpa_global *global);
 void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
                             const u8 *buf, size_t len);
+enum wpa_key_mgmt key_mgmt2driver(int key_mgmt);
+enum wpa_cipher cipher_suite2driver(int cipher);
 
 /* events.c */
 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);