Move some P2P offchannel operations to offchannel.c

There is no need for p2p_supplicant.c to access wpa_s->pending_action_tx
so move these references to offchannel.c to get a bit cleaner interface
between the components.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2012-12-22 11:22:12 +02:00
parent b4419c62ad
commit 2f3101d8df
3 changed files with 34 additions and 7 deletions

View file

@ -356,6 +356,33 @@ void offchannel_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
}
/**
* offchannel_pending_action_tx - Check whether there is a pending Action TX
* @wpa_s: Pointer to wpa_supplicant data
* Returns: Pointer to pending frame or %NULL if no pending operation
*
* This function can be used to check whether there is a pending Action frame TX
* operation. The returned pointer should be used only for checking whether it
* is %NULL (no pending frame) or to print the pointer value in debug
* information (i.e., the pointer should not be dereferenced).
*/
const void * offchannel_pending_action_tx(struct wpa_supplicant *wpa_s)
{
return wpa_s->pending_action_tx;
}
/**
* offchannel_clear_pending_action_tx - Clear pending Action frame TX
* @wpa_s: Pointer to wpa_supplicant data
*/
void offchannel_clear_pending_action_tx(struct wpa_supplicant *wpa_s)
{
wpabuf_free(wpa_s->pending_action_tx);
wpa_s->pending_action_tx = NULL;
}
/**
* offchannel_deinit - Deinit off-channel operations
* @wpa_s: Pointer to wpa_supplicant data
@ -365,7 +392,6 @@ void offchannel_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
*/
void offchannel_deinit(struct wpa_supplicant *wpa_s)
{
wpabuf_free(wpa_s->pending_action_tx);
wpa_s->pending_action_tx = NULL;
offchannel_clear_pending_action_tx(wpa_s);
eloop_cancel_timeout(wpas_send_action_cb, wpa_s, NULL);
}

View file

@ -29,5 +29,7 @@ void offchannel_deinit(struct wpa_supplicant *wpa_s);
void offchannel_send_action_tx_status(
struct wpa_supplicant *wpa_s, const u8 *dst, const u8 *data,
size_t data_len, enum offchannel_send_action_result result);
const void * offchannel_pending_action_tx(struct wpa_supplicant *wpa_s);
void offchannel_clear_pending_action_tx(struct wpa_supplicant *wpa_s);
#endif /* OFFCHANNEL_H */

View file

@ -3758,12 +3758,12 @@ void wpas_p2p_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
{
wpa_printf(MSG_DEBUG, "P2P: Cancel remain-on-channel callback "
"(p2p_long_listen=%d ms pending_action_tx=%p)",
wpa_s->p2p_long_listen, wpa_s->pending_action_tx);
wpa_s->p2p_long_listen, offchannel_pending_action_tx(wpa_s));
if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
return;
if (p2p_listen_end(wpa_s->global->p2p, freq) > 0)
return; /* P2P module started a new operation */
if (wpa_s->pending_action_tx)
if (offchannel_pending_action_tx(wpa_s))
return;
if (wpa_s->p2p_long_listen > 0)
wpa_s->p2p_long_listen -= wpa_s->max_remain_on_chan;
@ -4321,13 +4321,12 @@ int wpas_p2p_scan_result_text(const u8 *ies, size_t ies_len, char *buf,
static void wpas_p2p_clear_pending_action_tx(struct wpa_supplicant *wpa_s)
{
if (!wpa_s->pending_action_tx)
if (!offchannel_pending_action_tx(wpa_s))
return;
wpa_printf(MSG_DEBUG, "P2P: Drop pending Action TX due to new "
"operation request");
wpabuf_free(wpa_s->pending_action_tx);
wpa_s->pending_action_tx = NULL;
offchannel_clear_pending_action_tx(wpa_s);
}