]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
PAE: Make KaY specific details available via control interface
authorBadrish Adiga H R <badrish.adigahr@gmail.com>
Thu, 15 Dec 2016 20:10:53 +0000 (01:40 +0530)
committerJouni Malinen <j@w1.fi>
Sun, 18 Dec 2016 15:47:05 +0000 (17:47 +0200)
Add KaY details to the STATUS command output.

Signed-off-by: Badrish Adiga H R <badrish.adigahr@hpe.com>
src/pae/ieee802_1x_kay.c
src/pae/ieee802_1x_kay.h
wpa_supplicant/ctrl_iface.c

index 1d6d9a9f12705f9b354df4a424900f43767a747c..cf5782a21e45de6beef1646fb9194fe9fb3165d3 100644 (file)
@@ -1641,6 +1641,7 @@ ieee802_1x_mka_decode_dist_sak_body(
        ieee802_1x_cp_signal_newsak(kay->cp);
        ieee802_1x_cp_sm_step(kay->cp);
 
+       kay->rcvd_keys++;
        participant->to_use_sak = TRUE;
 
        return 0;
@@ -3519,3 +3520,51 @@ ieee802_1x_kay_change_cipher_suite(struct ieee802_1x_kay *kay,
 
        return 0;
 }
+
+
+#ifdef CONFIG_CTRL_IFACE
+/**
+ * ieee802_1x_kay_get_status - Get IEEE 802.1X KaY status details
+ * @sm: Pointer to KaY allocated with ieee802_1x_kay_init()
+ * @buf: Buffer for status information
+ * @buflen: Maximum buffer length
+ * @verbose: Whether to include verbose status information
+ * Returns: Number of bytes written to buf.
+ *
+ * Query KAY status information. This function fills in a text area with current
+ * status information. If the buffer (buf) is not large enough, status
+ * information will be truncated to fit the buffer.
+ */
+int ieee802_1x_kay_get_status(struct ieee802_1x_kay *kay, char *buf,
+                             size_t buflen)
+{
+       int len;
+
+       if (!kay)
+               return 0;
+
+       len = os_snprintf(buf, buflen,
+                         "PAE KaY status=%s\n"
+                         "Authenticated=%s\n"
+                         "Secured=%s\n"
+                         "Failed=%s\n"
+                         "Actor Priority=%u\n"
+                         "Key Server Priority=%u\n"
+                         "Is Key Server=%s\n"
+                         "Number of Keys Distributed=%u\n"
+                         "Number of Keys Received=%u\n",
+                         kay->active ? "Active" : "Not-Active",
+                         kay->authenticated ? "Yes" : "No",
+                         kay->secured ? "Yes" : "No",
+                         kay->failed ? "Yes" : "No",
+                         kay->actor_priority,
+                         kay->key_server_priority,
+                         kay->is_key_server ? "Yes" : "No",
+                         kay->dist_kn - 1,
+                         kay->rcvd_keys);
+       if (os_snprintf_error(buflen, len))
+               return 0;
+
+       return len;
+}
+#endif /* CONFIG_CTRL_IFACE */
index 9a92d1c029c1fd189334aa24e96401656c12f5f2..b38e8146675fd94154775f15d6eef4fa82d010e6 100644 (file)
@@ -208,6 +208,7 @@ struct ieee802_1x_kay {
        int mka_algindex;  /* MKA alg table index */
 
        u32 dist_kn;
+       u32 rcvd_keys;
        u8 dist_an;
        time_t dist_time;
 
@@ -267,5 +268,7 @@ int ieee802_1x_kay_enable_tx_sas(struct ieee802_1x_kay *kay,
 int ieee802_1x_kay_enable_rx_sas(struct ieee802_1x_kay *kay,
                                 struct ieee802_1x_mka_ki *lki);
 int ieee802_1x_kay_enable_new_info(struct ieee802_1x_kay *kay);
+int ieee802_1x_kay_get_status(struct ieee802_1x_kay *kay, char *buf,
+                             size_t buflen);
 
 #endif /* IEEE802_1X_KAY_H */
index c943deeedc545f8176efbc0b2cc74a568e945f3f..624e894cfe70f37e4d60c1b18a3da410c2b8a8a9 100644 (file)
@@ -2050,6 +2050,12 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
                        pos += res;
        }
 
+#ifdef CONFIG_MACSEC
+       res = ieee802_1x_kay_get_status(wpa_s->kay, pos, end - pos);
+       if (res > 0)
+               pos += res;
+#endif /* CONFIG_MACSEC */
+
        sess_id = eapol_sm_get_session_id(wpa_s->eapol, &sess_id_len);
        if (sess_id) {
                char *start = pos;