The branch main has been updated by bz:

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

commit e277735ce05911aaee336cd61ec3a12435f46d8d
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-09 21:44:25 +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
    MFC after;      3 days
    Reviewed by:    adrian
    Differential Revision: https://reviews.freebsd.org/D50554
---
 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 0236bb5802e7..9ece44960378 100644
--- a/sbin/ifconfig/ifieee80211.c
+++ b/sbin/ifconfig/ifieee80211.c
@@ -4898,6 +4898,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];
@@ -4948,10 +4949,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) {
@@ -5107,6 +5108,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