From 5275d5ef08eec928ebbb1fd17f2fdcb4d8e9579a Mon Sep 17 00:00:00 2001 From: Sarvesh Bodakhe Date: Wed, 1 Jul 2026 16:05:36 +0530 Subject: [PATCH] refactor(nan): put RSN KDE OUI in one array, drop dead OUI byte macros Replace the three NAN_KDE_OUI_RSN_* byte writes in nan_kde_put_hdr() with a single nan_kde_rsn_oui[] array, and remove the now-unused NAN_KDE_OUI_RSN_* byte macros and the never-used NAN_KDE_OUI_WFA_* byte macros. The combined NAN_KDE_OUI_RSN / NAN_KDE_OUI_WFA (used by the KDE parser) are kept. --- components/esp_wifi/wifi_apps/nan_app/src/nan_i.h | 6 ------ components/esp_wifi/wifi_apps/nan_app/src/nan_security.c | 8 +++++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/components/esp_wifi/wifi_apps/nan_app/src/nan_i.h b/components/esp_wifi/wifi_apps/nan_app/src/nan_i.h index f0e15d4658e..c083497eaf6 100644 --- a/components/esp_wifi/wifi_apps/nan_app/src/nan_i.h +++ b/components/esp_wifi/wifi_apps/nan_app/src/nan_i.h @@ -132,12 +132,6 @@ extern void *s_nan_data_lock; /* NAN KDE OUIs and Data Types carried in the Key Data field (Wi-Fi Aware * v4.0 ยง9.5.21.5 Table 126; formats per 802.11 Fig 12-36/12-42/12-47). */ -#define NAN_KDE_OUI_RSN_0 0x00 -#define NAN_KDE_OUI_RSN_1 0x0F -#define NAN_KDE_OUI_RSN_2 0xAC -#define NAN_KDE_OUI_WFA_0 0x50 -#define NAN_KDE_OUI_WFA_1 0x6F -#define NAN_KDE_OUI_WFA_2 0x9A #define NAN_KDE_OUI_RSN 0x000FACUL #define NAN_KDE_OUI_WFA 0x506F9AUL #define NAN_KDE_TYPE_GTK 1 /* 00-0F-AC GTK KDE */ diff --git a/components/esp_wifi/wifi_apps/nan_app/src/nan_security.c b/components/esp_wifi/wifi_apps/nan_app/src/nan_security.c index 7c5c0ff81e6..8ad56e5d256 100644 --- a/components/esp_wifi/wifi_apps/nan_app/src/nan_security.c +++ b/components/esp_wifi/wifi_apps/nan_app/src/nan_security.c @@ -778,15 +778,17 @@ void nan_security_reset_own_group_keys(void) s_nan_ctx.own_bigtk_set = false; } +/* 00-0F-AC RSN OUI written into every NAN KDE header. */ +static const uint8_t nan_kde_rsn_oui[3] = {0x00, 0x0f, 0xac}; + /* NAN KDE header (802.11 Fig 12-34: DD len OUI(3) DataType(1)); mirrors hostap * nan_add_kde_hdr(). data_len excludes the DD/len/OUI/type bytes. */ static uint8_t *nan_kde_put_hdr(uint8_t *p, uint8_t data_type, uint8_t data_len) { *p++ = 0xDD; *p++ = (uint8_t)(4 + data_len); /* OUI(3) + DataType(1) + data */ - *p++ = NAN_KDE_OUI_RSN_0; - *p++ = NAN_KDE_OUI_RSN_1; - *p++ = NAN_KDE_OUI_RSN_2; + memcpy(p, nan_kde_rsn_oui, sizeof(nan_kde_rsn_oui)); + p += sizeof(nan_kde_rsn_oui); *p++ = data_type; return p; }