]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Move some P2P offchannel operations to offchannel.c
authorJouni Malinen <j@w1.fi>
Sat, 22 Dec 2012 09:22:12 +0000 (11:22 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 22 Dec 2012 09:22:12 +0000 (11:22 +0200)
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>

wpa_supplicant/offchannel.c
wpa_supplicant/offchannel.h
wpa_supplicant/p2p_supplicant.c

index 7ec7656d13c7ace3f985cd04eb36984546c191aa..856eca708e80053b5f888f1f02867818ce1b5dba 100644 (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);
 }
index 1d3948c0e89b4c7aba0b39876fde0ce8ab72db00..0ad7e18fae882c8250a24b50207523a535ebd67e 100644 (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 */
index dc4d99a549e4bfbf509e1fc00efb1d426e6fa65d..eefeac60ce8cb62e4c5aa6806c4521d06a06c401 100644 (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);
 }