nl80211: Clean up nl80211_send_frame_cmd() callers

Replace a separate cookie_out pointer argument with save_cookie boolean
since drv->send_action_cookie is the only longer term storage place for
the cookies. Merge all nl80211_send_frame_cmd() callers within
wpa_driver_nl80211_send_mlme() to use a single shared call to simplify
the function.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2020-01-03 15:18:46 +02:00
parent 0dae4354f7
commit 5ad372cc3f

View file

@ -165,7 +165,8 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv,
const char *driver_params);
static int nl80211_send_frame_cmd(struct i802_bss *bss,
unsigned int freq, unsigned int wait,
const u8 *buf, size_t buf_len, u64 *cookie,
const u8 *buf, size_t buf_len,
int save_cookie,
int no_cck, int no_ack, int offchanok,
const u16 *csa_offs, size_t csa_offs_len);
static int wpa_driver_nl80211_probe_req_report(struct i802_bss *bss,
@ -3666,7 +3667,7 @@ static int wpa_driver_nl80211_send_mlme(struct i802_bss *bss, const u8 *data,
struct ieee80211_mgmt *mgmt;
int encrypt = !no_encrypt;
u16 fc;
u64 cookie;
int use_cookie = 1;
int res;
mgmt = (struct ieee80211_mgmt *) data;
@ -3690,9 +3691,11 @@ static int wpa_driver_nl80211_send_mlme(struct i802_bss *bss, const u8 *data,
drv->last_mgmt_freq);
freq = drv->last_mgmt_freq;
}
return nl80211_send_frame_cmd(bss, freq, 0,
data, data_len, NULL, 1, noack,
1, csa_offs, csa_offs_len);
wait_time = 0;
use_cookie = 0;
no_cck = 1;
offchanok = 1;
goto send_frame_cmd;
}
if (drv->device_ap_sme && is_ap_interface(drv->nlmode)) {
@ -3701,13 +3704,9 @@ static int wpa_driver_nl80211_send_mlme(struct i802_bss *bss, const u8 *data,
bss->freq);
freq = bss->freq;
}
return nl80211_send_frame_cmd(bss, freq,
(int) freq == bss->freq ? 0 :
wait_time,
data, data_len,
&drv->send_action_cookie,
no_cck, noack, offchanok,
csa_offs, csa_offs_len);
if ((int) freq == bss->freq)
wait_time = 0;
goto send_frame_cmd;
}
if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
@ -3744,19 +3743,14 @@ static int wpa_driver_nl80211_send_mlme(struct i802_bss *bss, const u8 *data,
noack);
}
if (noack || WLAN_FC_GET_TYPE(fc) != WLAN_FC_TYPE_MGMT ||
WLAN_FC_GET_STYPE(fc) != WLAN_FC_STYPE_ACTION)
use_cookie = 0;
send_frame_cmd:
wpa_printf(MSG_DEBUG, "nl80211: send_mlme -> send_frame_cmd");
res = nl80211_send_frame_cmd(bss, freq, wait_time, data, data_len,
&cookie, no_cck, noack, offchanok,
use_cookie, no_cck, noack, offchanok,
csa_offs, csa_offs_len);
if (res == 0 && !noack &&
WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_ACTION) {
wpa_printf(MSG_MSGDUMP,
"nl80211: Update send_action_cookie from 0x%llx to 0x%llx",
(long long unsigned int) drv->send_action_cookie,
(long long unsigned int) cookie);
drv->send_action_cookie = cookie;
}
return res;
}
@ -7446,7 +7440,7 @@ static int cookie_handler(struct nl_msg *msg, void *arg)
static int nl80211_send_frame_cmd(struct i802_bss *bss,
unsigned int freq, unsigned int wait,
const u8 *buf, size_t buf_len,
u64 *cookie_out, int no_cck, int no_ack,
int save_cookie, int no_cck, int no_ack,
int offchanok, const u16 *csa_offs,
size_t csa_offs_len)
{
@ -7485,8 +7479,8 @@ static int nl80211_send_frame_cmd(struct i802_bss *bss,
"cookie 0x%llx", no_ack ? " (no ACK)" : "",
(long long unsigned int) cookie);
if (cookie_out)
*cookie_out = no_ack ? (u64) -1 : cookie;
if (save_cookie)
drv->send_action_cookie = no_ack ? (u64) -1 : cookie;
if (drv->num_send_action_cookies == MAX_SEND_ACTION_COOKIES) {
wpa_printf(MSG_DEBUG,
@ -7555,8 +7549,7 @@ static int wpa_driver_nl80211_send_action(struct i802_bss *bss,
else
ret = nl80211_send_frame_cmd(bss, freq, wait_time, buf,
24 + data_len,
&drv->send_action_cookie,
no_cck, 0, 1, NULL, 0);
1, no_cck, 0, 1, NULL, 0);
os_free(buf);
return ret;