]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
IBSS RSN: Add IBSS-RSN-COMPLETED event message
authorJouni Malinen <j@w1.fi>
Sun, 25 Aug 2013 20:09:22 +0000 (23:09 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 25 Aug 2013 20:09:22 +0000 (23:09 +0300)
This new control interface event message is used to indicate when
both 4-way handshakes have been completed with a new IBSS peer.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/common/wpa_ctrl.h
wpa_supplicant/ibss_rsn.c
wpa_supplicant/ibss_rsn.h

index af716176dad52eda9552e6c251339021a5052912..6e7d11bcdc2fe8a56d83a130fa96c3fe4d5873a9 100644 (file)
@@ -63,6 +63,9 @@ extern "C" {
 /** A BSS entry was removed (followed by BSS entry id and BSSID) */
 #define WPA_EVENT_BSS_REMOVED "CTRL-EVENT-BSS-REMOVED "
 
+/** RSN IBSS 4-way handshakes completed with specified peer */
+#define IBSS_RSN_COMPLETED "IBSS-RSN-COMPLETED "
+
 /** WPS overlap detected in PBC mode */
 #define WPS_EVENT_OVERLAP "WPS-OVERLAP-DETECTED "
 /** Available WPS AP with active PBC found in scan results */
index 62d68b8bb4a82221f4ab3fbe1fb46d3a2099237c..b694bdec611882b033d7273e6a286ce2ddd7258a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * wpa_supplicant - IBSS RSN
- * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2009-2013, Jouni Malinen <j@w1.fi>
  *
  * This software may be distributed under the terms of the BSD license.
  * See README for more details.
@@ -9,6 +9,7 @@
 #include "includes.h"
 
 #include "common.h"
+#include "common/wpa_ctrl.h"
 #include "l2_packet/l2_packet.h"
 #include "rsn_supp/wpa.h"
 #include "rsn_supp/wpa_ie.h"
@@ -114,6 +115,22 @@ static int supp_get_beacon_ie(void *ctx)
 }
 
 
+static void ibss_check_rsn_completed(struct ibss_rsn_peer *peer)
+{
+       struct wpa_supplicant *wpa_s = peer->ibss_rsn->wpa_s;
+
+       if ((peer->authentication_status &
+            (IBSS_RSN_SET_PTK_SUPP | IBSS_RSN_SET_PTK_AUTH)) !=
+           (IBSS_RSN_SET_PTK_SUPP | IBSS_RSN_SET_PTK_AUTH))
+               return;
+       if (peer->authentication_status & IBSS_RSN_REPORTED_PTK)
+               return;
+       peer->authentication_status |= IBSS_RSN_REPORTED_PTK;
+       wpa_msg(wpa_s, MSG_INFO, IBSS_RSN_COMPLETED MACSTR,
+               MAC2STR(peer->addr));
+}
+
+
 static int supp_set_key(void *ctx, enum wpa_alg alg,
                        const u8 *addr, int key_idx, int set_tx,
                        const u8 *seq, size_t seq_len,
@@ -128,6 +145,8 @@ static int supp_set_key(void *ctx, enum wpa_alg alg,
        wpa_hexdump_key(MSG_DEBUG, "SUPP: set_key - key", key, key_len);
 
        if (key_idx == 0) {
+               peer->authentication_status |= IBSS_RSN_SET_PTK_SUPP;
+               ibss_check_rsn_completed(peer);
                /*
                 * In IBSS RSN, the pairwise key from the 4-way handshake
                 * initiated by the peer with highest MAC address is used.
@@ -281,6 +300,15 @@ static int auth_set_key(void *ctx, int vlan_id, enum wpa_alg alg,
        wpa_hexdump_key(MSG_DEBUG, "AUTH: set_key - key", key, key_len);
 
        if (idx == 0) {
+               if (addr) {
+                       struct ibss_rsn_peer *peer;
+                       peer = ibss_rsn_get_peer(ibss_rsn, addr);
+                       if (peer) {
+                               peer->authentication_status |=
+                                       IBSS_RSN_SET_PTK_AUTH;
+                               ibss_check_rsn_completed(peer);
+                       }
+               }
                /*
                 * In IBSS RSN, the pairwise key from the 4-way handshake
                 * initiated by the peer with highest MAC address is used.
index 5a8eda4b72f15ca13436b88f804e9c316ca6cfa0..6b89f7a95ff6f1b52eabf836e4c87d3c61f532d6 100644 (file)
@@ -19,6 +19,12 @@ struct ibss_rsn;
 #define IBSS_RSN_AUTH_BY_US            0x02
 /* we sent an EAPOL message */
 #define IBSS_RSN_AUTH_EAPOL_BY_US      0x04
+/* PTK derived as supplicant */
+#define IBSS_RSN_SET_PTK_SUPP          0x08
+/* PTK derived as authenticator */
+#define IBSS_RSN_SET_PTK_AUTH          0x10
+/* PTK completion reported */
+#define IBSS_RSN_REPORTED_PTK          0x20
 
 struct ibss_rsn_peer {
        struct ibss_rsn_peer *next;