The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=b0963bfc69b3975507143bda20df3ba13e6c230f

commit b0963bfc69b3975507143bda20df3ba13e6c230f
Author:     Bjoern A. Zeeb <b...@freebsd.org>
AuthorDate: 2025-05-27 19:44:42 +0000
Commit:     Bjoern A. Zeeb <b...@freebsd.org>
CommitDate: 2025-06-10 23:41:06 +0000

    ifconfig: 802.11: print node unicast key (PTK) if available in STA mode
    
    Add a variable when querying the BSSID so we can later use it rather
    than losing the "data" buffer.
    
    When printing key information also query the node unicast key if in
    STA mode (the key for the BSSID).  Do not error in case we fail.
    This is helpful for debugging mostly; was also useful when testing
    GCMP support.
    
    Sponsored by:   The FreeBSD Foundation
    Reviewed by:    adrian
    Differential Revision: https://reviews.freebsd.org/D50554
    
    (cherry picked from commit e277735ce05911aaee336cd61ec3a12435f46d8d)
---
 sbin/ifconfig/ifieee80211.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c
index 6964a68b6ba6..c2aa51f250a6 100644
--- a/sbin/ifconfig/ifieee80211.c
+++ b/sbin/ifconfig/ifieee80211.c
@@ -4888,6 +4888,7 @@ ieee80211_status(if_ctx *ctx)
 {
        int s = ctx->io_s;
        static const uint8_t zerobssid[IEEE80211_ADDR_LEN];
+       uint8_t bssid[IEEE80211_ADDR_LEN];
        enum ieee80211_opmode opmode = get80211opmode(ctx);
        int i, num, wpa, wme, bgscan, bgscaninterval, val, len, wepmode;
        uint8_t data[32];
@@ -4938,10 +4939,10 @@ ieee80211_status(if_ctx *ctx)
        } else if (verbose)
                printf(" channel UNDEF");
 
-       if (get80211(ctx, IEEE80211_IOC_BSSID, data, IEEE80211_ADDR_LEN) >= 0 &&
-           (memcmp(data, zerobssid, sizeof(zerobssid)) != 0 || verbose)) {
-               printf(" bssid %s", ether_ntoa((struct ether_addr *)data));
-               printbssidname((struct ether_addr *)data);
+       if (get80211(ctx, IEEE80211_IOC_BSSID, bssid, IEEE80211_ADDR_LEN) >= 0 
&&
+           (memcmp(bssid, zerobssid, sizeof(zerobssid)) != 0 || verbose)) {
+               printf(" bssid %s", ether_ntoa((struct ether_addr *)bssid));
+               printbssidname((struct ether_addr *)bssid);
        }
 
        if (get80211len(ctx, IEEE80211_IOC_STATIONNAME, data, sizeof(data), 
&len) != -1) {
@@ -5097,6 +5098,21 @@ ieee80211_status(if_ctx *ctx)
                                printkey(ctx, &ik);
                        }
                }
+               if (opmode == IEEE80211_M_STA && wpa >= 2) {
+                       struct ieee80211req_key ik;
+                       int error;
+
+                       memset(&ik, 0, sizeof(ik));
+                       ik.ik_keyix = IEEE80211_KEYIX_NONE;
+                       memcpy(ik.ik_macaddr, bssid, sizeof(ik.ik_macaddr));
+                       error = get80211(ctx, IEEE80211_IOC_WPAKEY, &ik, 
sizeof(ik));
+                       if (error == 0 && ik.ik_keylen != 0) {
+                               if (verbose)
+                                       LINE_BREAK();
+                               printkey(ctx, &ik);
+                               i++;
+                       }
+               }
                if (i > 0 && verbose)
                        LINE_BREAK();
 end:

Reply via email to