docs(wifi): add Chinese translation for MAC randomization

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jack
2026-05-21 12:06:34 +08:00
committed by BOT
parent 18cbdbf2b1
commit 4786ab4d14
6 changed files with 50 additions and 10 deletions

View File

@@ -42,7 +42,7 @@ static bool roaming_ongoing = false;
*/
static void wifi_start(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data)
{
uint8_t mac[6];
uint8_t mac[WIFI_MAC_ADDR_LEN];
esp_err_t ret;
ESP_LOGD(TAG, "%s esp-netif:%p event-id%" PRId32 "", __func__, esp_netif, event_id);
@@ -53,7 +53,7 @@ static void wifi_start(void *esp_netif, esp_event_base_t base, int32_t event_id,
ESP_LOGE(TAG, "esp_wifi_get_mac failed with %d", ret);
return;
}
ESP_LOGD(TAG, "WIFI mac address: %x %x %x %x %x %x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
ESP_LOGD(TAG, "WIFI mac address: " MACSTR, MAC2STR(mac));
if (esp_wifi_is_if_ready_when_started(driver)) {
if ((ret = esp_wifi_register_if_rxcb(driver, esp_netif_receive, esp_netif)) != ESP_OK) {
@@ -121,7 +121,7 @@ static void wifi_default_action_sta_connected(void *arg, esp_event_base_t base,
#if CONFIG_ESP_WIFI_STA_RANDOM_MAC_ENABLED
/* Sync netif MAC when STA random MAC was set internally by the Wi-Fi driver */
uint8_t mac[6];
uint8_t mac[WIFI_MAC_ADDR_LEN];
esp_wifi_get_mac(WIFI_IF_STA, mac);
esp_netif_set_mac(esp_netif, mac);
#endif

View File

@@ -621,13 +621,14 @@ static void esp_dpp_rx_action(void *data, void *user_ctx)
public_action->v.pa_gas_resp.status_code == 0) {
if (!s_dpp_ctx.dpp_auth ||
s_dpp_ctx.dpp_auth->gas_dialog_token < 0 ||
public_action->v.pa_gas_resp.diag_token !=
s_dpp_ctx.dpp_auth->gas_dialog_token) {
wpa_printf(MSG_DEBUG,
"DPP: GAS dialog token mismatch (rx=%u exp=%u) - drop",
"DPP: GAS dialog token mismatch (rx=%u exp=%d) - drop",
public_action->v.pa_gas_resp.diag_token,
s_dpp_ctx.dpp_auth ?
s_dpp_ctx.dpp_auth->gas_dialog_token : 0);
s_dpp_ctx.dpp_auth->gas_dialog_token : -1);
os_free(rx_param);
return;
}

View File

@@ -1120,6 +1120,7 @@ struct dpp_authentication * dpp_auth_init(void *msg_ctx,
auth = os_zalloc(sizeof(*auth));
if (!auth)
return NULL;
auth->gas_dialog_token = -1;
auth->msg_ctx = msg_ctx;
auth->initiator = 1;
auth->waiting_auth_resp = 1;
@@ -1377,9 +1378,7 @@ struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth,
return NULL;
}
do {
dialog_token = os_random() & 0xff;
} while (!dialog_token);
dialog_token = os_random() & 0xff;
auth->gas_dialog_token = dialog_token;
buf = gas_build_initial_req(dialog_token, 10 + 2 + wpabuf_len(conf_req));
@@ -1769,6 +1768,7 @@ dpp_auth_req_rx(void *msg_ctx, u8 dpp_allowed_roles, int qr_mutual,
auth = os_zalloc(sizeof(*auth));
if (!auth)
goto fail;
auth->gas_dialog_token = -1;
auth->msg_ctx = msg_ctx;
auth->peer_bi = peer_bi;
auth->own_bi = own_bi;

View File

@@ -311,7 +311,7 @@ struct dpp_authentication {
int send_conn_status;
int conn_status_requested;
int akm_use_selector;
u8 gas_dialog_token; /* Dialog Token used in GAS Initial Request */
int gas_dialog_token; /* Dialog Token used in GAS Initial Request */
#ifdef CONFIG_TESTING_OPTIONS
char *config_obj_override;

View File

@@ -183,12 +183,14 @@ To use this feature, enable configuration option :ref:`CONFIG_ESP_WIFI_STA_RANDO
.. note::
The `CONFIG_ESP_WIFI_STA_RANDOM_MAC_AUTO_RESET_INTERVAL` will only generate and set new random mac address when station is not connected to any AP. If the station is connected to any AP, the connection will not be interrupted and same random mac will be used.
The `CONFIG_ESP_WIFI_STA_RANDOM_MAC_AUTO_RESET_INTERVAL` will only generate and set new random mac address when station is not connected to any AP. If the station is connected to any AP, the connection will not be interrupted and same random mac will be used. If the periodic auto-reset timer expires while the station is in the connected state, the timer will be armed/triggered at the next disconnect.
For every new connection request, new random mac will be generated and auto reset time interval will be reset if `CONFIG_ESP_WIFI_STA_RANDOM_MAC_ENABLED` is enabled.
PMK caching is not supported when MAC randomization is enabled, as the device's identity changes with each connection attempt.
MAC Address Randomization is not supported and will not work when Wi-Fi Mesh or ESP-NOW is enabled/used.
{IDF_TARGET_NAME} supports MAC randomization while scanning when

View File

@@ -165,3 +165,40 @@ API 及用法
++++++++++++++++++++++++++++++++++++++
配置选项 :ref:`CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA`:cpp:type:`wifi_sta_config_t` 中的配置参数 :cpp:type:`owe_enabled` 可以为 station 模式启用 OWE 支持。除上述配置外,请将 :cpp:type:`wifi_scan_threshold_t` 中的 `authmode` 设置为 ``WIFI_AUTH_OPEN`` 以使用 OWE 过渡模式。
MAC 地址随机化
--------------------------
MAC 地址用于设备连接 Wi-Fi 网络。由于 MAC 地址具有唯一且静态的特点,并且在传输时未加密,因此可能会被捕获和追踪。{IDF_TARGET_NAME} 支持 MAC 地址随机化功能,通过使用随机 MAC 地址增强隐私保护,避免设备在扫描或连接网络时被持续追踪。
要使用此功能,请在 menuconfig 中启用配置选项 :ref:`CONFIG_ESP_WIFI_STA_RANDOM_MAC_ENABLED`
{IDF_TARGET_NAME} 还支持通过 menuconfig 选项 :ref:`CONFIG_ESP_WIFI_STA_RANDOM_MAC_AUTO_RESET_INTERVAL` 在一段时间后自动重置随机 MAC 地址。
如果间隔时间 = 0则禁用自动重置功能同一随机 MAC 地址会一直使用到下次重启)。
如果间隔时间 > 24则使用默认的 12 小时间隔。
.. note::
仅当 station 未连接到任何 AP 时,`CONFIG_ESP_WIFI_STA_RANDOM_MAC_AUTO_RESET_INTERVAL` 才会生成并设置新的随机 MAC 地址。如果 station 已连接到 AP则不会中断连接并会继续使用相同的随机 MAC 地址。如果定期自动重置定时器在 station 处于连接状态时超时,定时器将在下一次断开连接时被重新装载/触发。
如果启用了 `CONFIG_ESP_WIFI_STA_RANDOM_MAC_ENABLED`,每次发起新的连接请求时都会生成新的随机 MAC 地址,并重置自动重置时间间隔。
启用 MAC 地址随机化后,不支持 PMK 缓存,因为设备身份会随每次连接尝试而变化。
在使用或启用 Wi-Fi Mesh 或 ESP-NOW 时,不支持且无法使用 MAC 地址随机化功能。
{IDF_TARGET_NAME} 在满足以下条件时支持扫描过程中的 MAC 地址随机化:
- 在 menuconfig 中启用配置选项 :ref:`CONFIG_ESP_WIFI_STA_RANDOM_MAC_ENABLED`
- scan_type 为 :cpp:enumerator:`WIFI_SCAN_TYPE_ACTIVE`
- station 未连接到任何 AP
{IDF_TARGET_NAME} 在满足以下条件时支持连接过程中的 MAC 地址随机化:
- 在 menuconfig 中启用配置选项 :ref:`CONFIG_ESP_WIFI_STA_RANDOM_MAC_ENABLED`
- 使用 :cpp:func:`esp_wifi_set_config` 设置新的 Wi-Fi 配置
要获取 MAC 地址,请使用 API :cpp:func:`esp_wifi_get_mac`