]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Clean up debug prints
authorJouni Malinen <j@w1.fi>
Sat, 18 May 2013 15:47:36 +0000 (18:47 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 18 May 2013 15:47:36 +0000 (18:47 +0300)
Replace direct wpa_msg() calls with p2p_dbg(), p2p_info(), and p2p_err()
calls that use a new debug_print() callback to handle actual debug
printing outside the P2P module.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/drivers/driver_test.c
src/p2p/p2p.c
src/p2p/p2p.h
src/p2p/p2p_dev_disc.c
src/p2p/p2p_go_neg.c
src/p2p/p2p_group.c
src/p2p/p2p_i.h
src/p2p/p2p_invitation.c
src/p2p/p2p_pd.c
src/p2p/p2p_sd.c
wpa_supplicant/p2p_supplicant.c

index c99802a87d922adfba9ebf93ab0d30dd18fc34db..541ebcced8ae4f0391e4eb3ed498c84341aafe86 100644 (file)
@@ -3195,6 +3195,12 @@ static void test_prov_disc_resp(void *ctx, const u8 *peer, u16 config_methods)
        /* TODO */
 }
 
+
+static void test_p2p_debug_print(void *ctx, int level, const char *msg)
+{
+       wpa_printf(level, "P2P: %s", msg);
+}
+
 #endif /* CONFIG_P2P */
 
 
@@ -3206,8 +3212,8 @@ static int wpa_driver_test_init_p2p(struct wpa_driver_test_data *drv)
        int i;
 
        os_memset(&p2p, 0, sizeof(p2p));
-       p2p.msg_ctx = drv->ctx;
        p2p.cb_ctx = drv;
+       p2p.debug_print = test_p2p_debug_print;
        p2p.p2p_scan = test_p2p_scan;
        p2p.send_action = test_send_action;
        p2p.send_action_done = test_send_action_done;
index a0b21b025a9cd89b525f585998b6f33f5819f70d..1295be54e02aef8145abd25d2e824fe6f2fe2105 100644 (file)
@@ -81,8 +81,8 @@ static void p2p_expire_peers(struct p2p_data *p2p)
                        continue;
                }
 
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Expiring old peer "
-                       "entry " MACSTR, MAC2STR(dev->info.p2p_device_addr));
+               p2p_dbg(p2p, "Expiring old peer entry " MACSTR,
+                       MAC2STR(dev->info.p2p_device_addr));
                dl_list_del(&dev->list);
                p2p_device_free(p2p, dev);
        }
@@ -167,7 +167,7 @@ void p2p_clear_provisioning_info(struct p2p_data *p2p, const u8 *addr)
 
 void p2p_set_state(struct p2p_data *p2p, int new_state)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: State %s -> %s",
+       p2p_dbg(p2p, "State %s -> %s",
                p2p_state_txt(p2p->state), p2p_state_txt(new_state));
        p2p->state = new_state;
 }
@@ -175,8 +175,7 @@ void p2p_set_state(struct p2p_data *p2p, int new_state)
 
 void p2p_set_timeout(struct p2p_data *p2p, unsigned int sec, unsigned int usec)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Set timeout (state=%s): %u.%06u sec",
+       p2p_dbg(p2p, "Set timeout (state=%s): %u.%06u sec",
                p2p_state_txt(p2p->state), sec, usec);
        eloop_cancel_timeout(p2p_state_timeout, p2p, NULL);
        eloop_register_timeout(sec, usec, p2p_state_timeout, p2p, NULL);
@@ -185,8 +184,7 @@ void p2p_set_timeout(struct p2p_data *p2p, unsigned int sec, unsigned int usec)
 
 void p2p_clear_timeout(struct p2p_data *p2p)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Clear timeout (state=%s)",
-               p2p_state_txt(p2p->state));
+       p2p_dbg(p2p, "Clear timeout (state=%s)", p2p_state_txt(p2p->state));
        eloop_cancel_timeout(p2p_state_timeout, p2p, NULL);
 }
 
@@ -221,14 +219,12 @@ static void p2p_listen_in_find(struct p2p_data *p2p, int dev_disc)
        int freq;
        struct wpabuf *ies;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Starting short listen state (state=%s)",
+       p2p_dbg(p2p, "Starting short listen state (state=%s)",
                p2p_state_txt(p2p->state));
 
        freq = p2p_channel_to_freq(p2p->cfg->reg_class, p2p->cfg->channel);
        if (freq < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unknown regulatory class/channel");
+               p2p_dbg(p2p, "Unknown regulatory class/channel");
                return;
        }
 
@@ -243,8 +239,7 @@ static void p2p_listen_in_find(struct p2p_data *p2p, int dev_disc)
                tu = p2p->cfg->max_listen * 1000 / 1024;
 
        if (tu == 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Skip listen state "
-                       "since duration was 0 TU");
+               p2p_dbg(p2p, "Skip listen state since duration was 0 TU");
                p2p_set_timeout(p2p, 0, 0);
                return;
        }
@@ -259,8 +254,7 @@ static void p2p_listen_in_find(struct p2p_data *p2p, int dev_disc)
 
        if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, freq, 1024 * tu / 1000,
                    ies) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to start listen mode");
+               p2p_dbg(p2p, "Failed to start listen mode");
                p2p->pending_listen_freq = 0;
        }
        wpabuf_free(ies);
@@ -272,13 +266,11 @@ int p2p_listen(struct p2p_data *p2p, unsigned int timeout)
        int freq;
        struct wpabuf *ies;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Going to listen(only) state");
+       p2p_dbg(p2p, "Going to listen(only) state");
 
        freq = p2p_channel_to_freq(p2p->cfg->reg_class, p2p->cfg->channel);
        if (freq < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unknown regulatory class/channel");
+               p2p_dbg(p2p, "Unknown regulatory class/channel");
                return -1;
        }
 
@@ -288,13 +280,10 @@ int p2p_listen(struct p2p_data *p2p, unsigned int timeout)
 
        if (p2p->p2p_scan_running) {
                if (p2p->start_after_scan == P2P_AFTER_SCAN_CONNECT) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: p2p_scan running - connect is already "
-                               "pending - skip listen");
+                       p2p_dbg(p2p, "p2p_scan running - connect is already pending - skip listen");
                        return 0;
                }
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: p2p_scan running - delay start of listen state");
+               p2p_dbg(p2p, "p2p_scan running - delay start of listen state");
                p2p->start_after_scan = P2P_AFTER_SCAN_LISTEN;
                return 0;
        }
@@ -304,8 +293,7 @@ int p2p_listen(struct p2p_data *p2p, unsigned int timeout)
                return -1;
 
        if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, freq, timeout, ies) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to start listen mode");
+               p2p_dbg(p2p, "Failed to start listen mode");
                p2p->pending_listen_freq = 0;
                wpabuf_free(ies);
                return -1;
@@ -387,9 +375,7 @@ static struct p2p_device * p2p_create_device(struct p2p_data *p2p,
                        oldest = dev;
        }
        if (count + 1 > p2p->cfg->max_peers && oldest) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Remove oldest peer entry to make room for a new "
-                       "peer");
+               p2p_dbg(p2p, "Remove oldest peer entry to make room for a new peer");
                dl_list_del(&oldest->list);
                p2p_device_free(p2p, oldest);
        }
@@ -498,8 +484,8 @@ static int p2p_add_group_clients(struct p2p_data *p2p, const u8 *go_dev_addr,
 }
 
 
-static void p2p_copy_wps_info(struct p2p_device *dev, int probe_req,
-                             const struct p2p_message *msg)
+static void p2p_copy_wps_info(struct p2p_data *p2p, struct p2p_device *dev,
+                             int probe_req, const struct p2p_message *msg)
 {
        os_memcpy(dev->info.device_name, msg->device_name,
                  sizeof(dev->info.device_name));
@@ -574,11 +560,11 @@ static void p2p_copy_wps_info(struct p2p_device *dev, int probe_req,
                        msg->config_methods : msg->wps_config_methods;
                if (new_config_methods &&
                    dev->info.config_methods != new_config_methods) {
-                       wpa_printf(MSG_DEBUG, "P2P: Update peer " MACSTR
-                                  " config_methods 0x%x -> 0x%x",
-                                  MAC2STR(dev->info.p2p_device_addr),
-                                  dev->info.config_methods,
-                                  new_config_methods);
+                       p2p_dbg(p2p, "Update peer " MACSTR
+                               " config_methods 0x%x -> 0x%x",
+                               MAC2STR(dev->info.p2p_device_addr),
+                               dev->info.config_methods,
+                               new_config_methods);
                        dev->info.config_methods = new_config_methods;
                }
        }
@@ -615,8 +601,7 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
 
        os_memset(&msg, 0, sizeof(msg));
        if (p2p_parse_ies(ies, ies_len, &msg)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to parse P2P IE for a device entry");
+               p2p_dbg(p2p, "Failed to parse P2P IE for a device entry");
                p2p_parse_free(&msg);
                return -1;
        }
@@ -626,18 +611,15 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
        else if (msg.device_id)
                p2p_dev_addr = msg.device_id;
        else {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Ignore scan data without P2P Device Info or "
-                       "P2P Device Id");
+               p2p_dbg(p2p, "Ignore scan data without P2P Device Info or P2P Device Id");
                p2p_parse_free(&msg);
                return -1;
        }
 
        if (!is_zero_ether_addr(p2p->peer_filter) &&
            os_memcmp(p2p_dev_addr, p2p->peer_filter, ETH_ALEN) != 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Do not add peer "
-                       "filter for " MACSTR " due to peer filter",
-                       MAC2STR(p2p_dev_addr));
+               p2p_dbg(p2p, "Do not add peer filter for " MACSTR
+                       " due to peer filter", MAC2STR(p2p_dev_addr));
                p2p_parse_free(&msg);
                return 0;
        }
@@ -659,9 +641,7 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
         */
        if (dev->last_seen.sec > 0 &&
            os_time_before(rx_time, &dev->last_seen)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Do not update peer "
-                       "entry based on old frame (rx_time=%u.%06u "
-                       "last_seen=%u.%06u)",
+               p2p_dbg(p2p, "Do not update peer entry based on old frame (rx_time=%u.%06u last_seen=%u.%06u)",
                        (unsigned int) rx_time->sec,
                        (unsigned int) rx_time->usec,
                        (unsigned int) dev->last_seen.sec,
@@ -692,18 +672,15 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
                else
                        ds_freq = 2407 + *msg.ds_params * 5;
                if (freq != ds_freq) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Update Listen frequency based on DS "
-                               "Parameter Set IE: %d -> %d MHz",
+                       p2p_dbg(p2p, "Update Listen frequency based on DS Parameter Set IE: %d -> %d MHz",
                                freq, ds_freq);
                        freq = ds_freq;
                }
        }
 
        if (dev->listen_freq && dev->listen_freq != freq && scan_res) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Update Listen frequency based on scan "
-                       "results (" MACSTR " %d -> %d MHz (DS param %d)",
+               p2p_dbg(p2p, "Update Listen frequency based on scan results ("
+                       MACSTR " %d -> %d MHz (DS param %d)",
                        MAC2STR(dev->info.p2p_device_addr), dev->listen_freq,
                        freq, msg.ds_params ? *msg.ds_params : -1);
        }
@@ -714,7 +691,7 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
        }
        dev->info.level = level;
 
-       p2p_copy_wps_info(dev, 0, &msg);
+       p2p_copy_wps_info(p2p, dev, 0, &msg);
 
        for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
                wpabuf_free(dev->info.wps_vendor_ext[i]);
@@ -748,13 +725,11 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
        if (dev->flags & P2P_DEV_REPORTED)
                return 0;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Peer found with Listen frequency %d MHz "
-               "(rx_time=%u.%06u)", freq, (unsigned int) rx_time->sec,
+       p2p_dbg(p2p, "Peer found with Listen frequency %d MHz (rx_time=%u.%06u)",
+               freq, (unsigned int) rx_time->sec,
                (unsigned int) rx_time->usec);
        if (dev->flags & P2P_DEV_USER_REJECTED) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Do not report rejected device");
+               p2p_dbg(p2p, "Do not report rejected device");
                return 0;
        }
 
@@ -774,9 +749,8 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
                 * Probe Response frame that includes the config_methods
                 * information.
                 */
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Do not report peer " MACSTR " with unknown "
-                       "config methods", MAC2STR(addr));
+               p2p_dbg(p2p, "Do not report peer " MACSTR
+                       " with unknown config methods", MAC2STR(addr));
                return 0;
        }
 
@@ -865,8 +839,7 @@ static int p2p_get_next_prog_freq(struct p2p_data *p2p)
        }
 
        freq = p2p_channel_to_freq(reg_class, channel);
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Next progressive search "
-               "channel: reg_class %u channel %u -> %d MHz",
+       p2p_dbg(p2p, "Next progressive search channel: reg_class %u channel %u -> %d MHz",
                reg_class, channel, freq);
        p2p->last_prog_scan_class = reg_class;
        p2p->last_prog_scan_chan = channel;
@@ -885,9 +858,7 @@ static void p2p_search(struct p2p_data *p2p)
        int res;
 
        if (p2p->drv_in_listen) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Driver is still "
-                       "in Listen state - wait for it to end before "
-                       "continuing");
+               p2p_dbg(p2p, "Driver is still in Listen state - wait for it to end before continuing");
                return;
        }
        p2p->cfg->stop_listen(p2p->cfg->cb_ctx);
@@ -895,27 +866,23 @@ static void p2p_search(struct p2p_data *p2p)
        if (p2p->find_type == P2P_FIND_PROGRESSIVE &&
            (freq = p2p_get_next_prog_freq(p2p)) > 0) {
                type = P2P_SCAN_SOCIAL_PLUS_ONE;
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Starting search "
-                       "(+ freq %u)", freq);
+               p2p_dbg(p2p, "Starting search (+ freq %u)", freq);
        } else {
                type = P2P_SCAN_SOCIAL;
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Starting search");
+               p2p_dbg(p2p, "Starting search");
        }
 
        res = p2p->cfg->p2p_scan(p2p->cfg->cb_ctx, type, freq,
                                 p2p->num_req_dev_types, p2p->req_dev_types,
                                 p2p->find_dev_id, pw_id);
        if (res < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Scan request failed");
+               p2p_dbg(p2p, "Scan request failed");
                p2p_continue_find(p2p);
        } else if (res == 1) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Could not start "
-                       "p2p_scan at this point - will try again after "
-                       "previous scan completes");
+               p2p_dbg(p2p, "Could not start p2p_scan at this point - will try again after previous scan completes");
                p2p_set_state(p2p, P2P_CONTINUE_SEARCH_WHEN_READY);
        } else {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Running p2p_scan");
+               p2p_dbg(p2p, "Running p2p_scan");
                p2p->p2p_scan_running = 1;
                eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL);
                eloop_register_timeout(P2P_SCAN_TIMEOUT, 0, p2p_scan_timeout,
@@ -927,7 +894,7 @@ static void p2p_search(struct p2p_data *p2p)
 static void p2p_find_timeout(void *eloop_ctx, void *timeout_ctx)
 {
        struct p2p_data *p2p = eloop_ctx;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Find timeout -> stop");
+       p2p_dbg(p2p, "Find timeout -> stop");
        p2p_stop_find(p2p);
 }
 
@@ -939,8 +906,7 @@ static int p2p_run_after_scan(struct p2p_data *p2p)
 
        if (p2p->after_scan_tx) {
                p2p->after_scan_tx_in_progress = 1;
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Send pending "
-                       "Action frame at p2p_scan completion");
+               p2p_dbg(p2p, "Send pending Action frame at p2p_scan completion");
                p2p->cfg->send_action(p2p->cfg->cb_ctx,
                                      p2p->after_scan_tx->freq,
                                      p2p->after_scan_tx->dst,
@@ -960,19 +926,16 @@ static int p2p_run_after_scan(struct p2p_data *p2p)
        case P2P_AFTER_SCAN_NOTHING:
                break;
        case P2P_AFTER_SCAN_LISTEN:
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Start previously "
-                       "requested Listen state");
+               p2p_dbg(p2p, "Start previously requested Listen state");
                p2p_listen(p2p, p2p->pending_listen_sec * 1000 +
                           p2p->pending_listen_usec / 1000);
                return 1;
        case P2P_AFTER_SCAN_CONNECT:
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Start previously "
-                       "requested connect with " MACSTR,
+               p2p_dbg(p2p, "Start previously requested connect with " MACSTR,
                        MAC2STR(p2p->after_scan_peer));
                dev = p2p_get_device(p2p, p2p->after_scan_peer);
                if (dev == NULL) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer not "
-                               "known anymore");
+                       p2p_dbg(p2p, "Peer not known anymore");
                        break;
                }
                p2p_connect_send(p2p, dev);
@@ -987,8 +950,7 @@ static void p2p_scan_timeout(void *eloop_ctx, void *timeout_ctx)
 {
        struct p2p_data *p2p = eloop_ctx;
        int running;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: p2p_scan timeout "
-               "(running=%d)", p2p->p2p_scan_running);
+       p2p_dbg(p2p, "p2p_scan timeout (running=%d)", p2p->p2p_scan_running);
        running = p2p->p2p_scan_running;
        /* Make sure we recover from missed scan results callback */
        p2p->p2p_scan_running = 0;
@@ -1013,12 +975,10 @@ int p2p_find(struct p2p_data *p2p, unsigned int timeout,
 {
        int res;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Starting find (type=%d)",
-               type);
+       p2p_dbg(p2p, "Starting find (type=%d)", type);
        os_get_time(&p2p->find_start);
        if (p2p->p2p_scan_running) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: p2p_scan is "
-                       "already running");
+               p2p_dbg(p2p, "p2p_scan is already running");
        }
 
        p2p_free_req_dev_types(p2p);
@@ -1070,21 +1030,18 @@ int p2p_find(struct p2p_data *p2p, unsigned int timeout,
        }
 
        if (res == 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Running p2p_scan");
+               p2p_dbg(p2p, "Running p2p_scan");
                p2p->p2p_scan_running = 1;
                eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL);
                eloop_register_timeout(P2P_SCAN_TIMEOUT, 0, p2p_scan_timeout,
                                       p2p, NULL);
        } else if (res == 1) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Could not start "
-                       "p2p_scan at this point - will try again after "
-                       "previous scan completes");
+               p2p_dbg(p2p, "Could not start p2p_scan at this point - will try again after previous scan completes");
                res = 0;
                p2p_set_state(p2p, P2P_SEARCH_WHEN_READY);
                eloop_cancel_timeout(p2p_find_timeout, p2p, NULL);
        } else {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Failed to start "
-                       "p2p_scan");
+               p2p_dbg(p2p, "Failed to start p2p_scan");
                p2p_set_state(p2p, P2P_IDLE);
                eloop_cancel_timeout(p2p_find_timeout, p2p, NULL);
        }
@@ -1102,8 +1059,7 @@ int p2p_other_scan_completed(struct p2p_data *p2p)
        }
        if (p2p->state != P2P_SEARCH_WHEN_READY)
                return 0;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Starting pending P2P find "
-               "now that previous scan was completed");
+       p2p_dbg(p2p, "Starting pending P2P find now that previous scan was completed");
        if (p2p_find(p2p, p2p->last_p2p_find_timeout, p2p->find_type,
                     p2p->num_req_dev_types, p2p->req_dev_types,
                     p2p->find_dev_id, p2p->search_delay) < 0) {
@@ -1116,7 +1072,7 @@ int p2p_other_scan_completed(struct p2p_data *p2p)
 
 void p2p_stop_find_for_freq(struct p2p_data *p2p, int freq)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Stopping find");
+       p2p_dbg(p2p, "Stopping find");
        eloop_cancel_timeout(p2p_find_timeout, p2p, NULL);
        p2p_clear_timeout(p2p);
        if (p2p->state == P2P_SEARCH ||
@@ -1138,8 +1094,7 @@ void p2p_stop_find_for_freq(struct p2p_data *p2p, int freq)
 void p2p_stop_listen_for_freq(struct p2p_data *p2p, int freq)
 {
        if (freq > 0 && p2p->drv_in_listen == freq && p2p->in_listen) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Skip stop_listen "
-                       "since we are on correct channel for response");
+               p2p_dbg(p2p, "Skip stop_listen since we are on correct channel for response");
                return;
        }
        if (p2p->in_listen) {
@@ -1152,8 +1107,7 @@ void p2p_stop_listen_for_freq(struct p2p_data *p2p, int freq)
                 * when the operation gets canceled, so clear the internal
                 * variable that is tracking driver state.
                 */
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Clear "
-                       "drv_in_listen (%d)", p2p->drv_in_listen);
+               p2p_dbg(p2p, "Clear drv_in_listen (%d)", p2p->drv_in_listen);
                p2p->drv_in_listen = 0;
        }
        p2p->cfg->stop_listen(p2p->cfg->cb_ctx);
@@ -1174,15 +1128,13 @@ static int p2p_prepare_channel_pref(struct p2p_data *p2p,
        unsigned int freq = force_freq ? force_freq : pref_freq;
 
        if (p2p_freq_to_channel(freq, &op_class, &op_channel) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unsupported frequency %u MHz", freq);
+               p2p_dbg(p2p, "Unsupported frequency %u MHz", freq);
                return -1;
        }
 
        if (!p2p_channels_includes(&p2p->cfg->channels, op_class, op_channel)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Frequency %u MHz (oper_class %u channel %u) not "
-                       "allowed for P2P", freq, op_class, op_channel);
+               p2p_dbg(p2p, "Frequency %u MHz (oper_class %u channel %u) not allowed for P2P",
+                       freq, op_class, op_channel);
                return -1;
        }
 
@@ -1211,24 +1163,21 @@ static void p2p_prepare_channel_best(struct p2p_data *p2p)
            p2p_supported_freq(p2p, p2p->best_freq_overall) &&
            p2p_freq_to_channel(p2p->best_freq_overall, &op_class, &op_channel)
            == 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Select best "
-                       "overall channel as operating channel preference");
+               p2p_dbg(p2p, "Select best overall channel as operating channel preference");
                p2p->op_reg_class = op_class;
                p2p->op_channel = op_channel;
        } else if (!p2p->cfg->cfg_op_channel && p2p->best_freq_5 > 0 &&
                   p2p_supported_freq(p2p, p2p->best_freq_5) &&
                   p2p_freq_to_channel(p2p->best_freq_5, &op_class, &op_channel)
                   == 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Select best 5 GHz "
-                       "channel as operating channel preference");
+               p2p_dbg(p2p, "Select best 5 GHz channel as operating channel preference");
                p2p->op_reg_class = op_class;
                p2p->op_channel = op_channel;
        } else if (!p2p->cfg->cfg_op_channel && p2p->best_freq_24 > 0 &&
                   p2p_supported_freq(p2p, p2p->best_freq_24) &&
                   p2p_freq_to_channel(p2p->best_freq_24, &op_class,
                                       &op_channel) == 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Select best 2.4 "
-                       "GHz channel as operating channel preference");
+               p2p_dbg(p2p, "Select best 2.4 GHz channel as operating channel preference");
                p2p->op_reg_class = op_class;
                p2p->op_channel = op_channel;
        } else {
@@ -1263,9 +1212,7 @@ int p2p_prepare_channel(struct p2p_data *p2p, struct p2p_device *dev,
        } else {
                p2p_prepare_channel_best(p2p);
        }
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Own preference for operation channel: "
-               "Operating Class %u Channel %u%s",
+       p2p_dbg(p2p, "Own preference for operation channel: Operating Class %u Channel %u%s",
                p2p->op_reg_class, p2p->op_channel,
                force_freq ? " (forced)" : "");
 
@@ -1307,8 +1254,7 @@ int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr,
 {
        struct p2p_device *dev;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Request to start group negotiation - peer=" MACSTR
+       p2p_dbg(p2p, "Request to start group negotiation - peer=" MACSTR
                "  GO Intent=%d  Intended Interface Address=" MACSTR
                " wps_method=%d persistent_group=%d pd_before_go_neg=%d",
                MAC2STR(peer_addr), go_intent, MAC2STR(own_interface_addr),
@@ -1316,8 +1262,7 @@ int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr,
 
        dev = p2p_get_device(p2p, peer_addr);
        if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Cannot connect to unknown P2P Device " MACSTR,
+               p2p_dbg(p2p, "Cannot connect to unknown P2P Device " MACSTR,
                        MAC2STR(peer_addr));
                return -1;
        }
@@ -1328,15 +1273,13 @@ int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr,
        if (dev->flags & P2P_DEV_GROUP_CLIENT_ONLY) {
                if (!(dev->info.dev_capab &
                      P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Cannot connect to P2P Device " MACSTR
+                       p2p_dbg(p2p, "Cannot connect to P2P Device " MACSTR
                                " that is in a group and is not discoverable",
                                MAC2STR(peer_addr));
                        return -1;
                }
                if (dev->oper_freq <= 0) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Cannot connect to P2P Device " MACSTR
+                       p2p_dbg(p2p, "Cannot connect to P2P Device " MACSTR
                                " with incomplete information",
                                MAC2STR(peer_addr));
                        return -1;
@@ -1392,9 +1335,7 @@ int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr,
                 * new GO Negotiation, e.g., when the pending frame was from a
                 * previous attempt at starting a GO Negotiation.
                 */
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Dropped "
-                       "previous pending Action frame TX that was waiting "
-                       "for p2p_scan completion");
+               p2p_dbg(p2p, "Dropped previous pending Action frame TX that was waiting for p2p_scan completion");
                os_free(p2p->after_scan_tx);
                p2p->after_scan_tx = NULL;
        }
@@ -1403,8 +1344,7 @@ int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr,
        dev->status = P2P_SC_SUCCESS;
 
        if (p2p->p2p_scan_running) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: p2p_scan running - delay connect send");
+               p2p_dbg(p2p, "p2p_scan running - delay connect send");
                p2p->start_after_scan = P2P_AFTER_SCAN_CONNECT;
                os_memcpy(p2p->after_scan_peer, peer_addr, ETH_ALEN);
                return 0;
@@ -1424,8 +1364,7 @@ int p2p_authorize(struct p2p_data *p2p, const u8 *peer_addr,
 {
        struct p2p_device *dev;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Request to authorize group negotiation - peer=" MACSTR
+       p2p_dbg(p2p, "Request to authorize group negotiation - peer=" MACSTR
                "  GO Intent=%d  Intended Interface Address=" MACSTR
                " wps_method=%d  persistent_group=%d",
                MAC2STR(peer_addr), go_intent, MAC2STR(own_interface_addr),
@@ -1433,8 +1372,7 @@ int p2p_authorize(struct p2p_data *p2p, const u8 *peer_addr,
 
        dev = p2p_get_device(p2p, peer_addr);
        if (dev == NULL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Cannot authorize unknown P2P Device " MACSTR,
+               p2p_dbg(p2p, "Cannot authorize unknown P2P Device " MACSTR,
                        MAC2STR(peer_addr));
                return -1;
        }
@@ -1471,15 +1409,14 @@ void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr,
 {
        os_get_time(&dev->last_seen);
 
-       p2p_copy_wps_info(dev, 0, msg);
+       p2p_copy_wps_info(p2p, dev, 0, msg);
 
        if (msg->listen_channel) {
                int freq;
                freq = p2p_channel_to_freq(msg->listen_channel[3],
                                           msg->listen_channel[4]);
                if (freq < 0) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Unknown peer Listen channel: "
+                       p2p_dbg(p2p, "Unknown peer Listen channel: "
                                "country=%c%c(0x%02x) reg_class=%u channel=%u",
                                msg->listen_channel[0],
                                msg->listen_channel[1],
@@ -1487,8 +1424,8 @@ void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr,
                                msg->listen_channel[3],
                                msg->listen_channel[4]);
                } else {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Update "
-                               "peer " MACSTR " Listen channel: %u -> %u MHz",
+                       p2p_dbg(p2p, "Update peer " MACSTR
+                               " Listen channel: %u -> %u MHz",
                                MAC2STR(dev->info.p2p_device_addr),
                                dev->listen_freq, freq);
                        dev->listen_freq = freq;
@@ -1502,12 +1439,9 @@ void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr,
 
        if (dev->flags & P2P_DEV_PROBE_REQ_ONLY) {
                dev->flags &= ~P2P_DEV_PROBE_REQ_ONLY;
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Completed device entry based on data from "
-                       "GO Negotiation Request");
+               p2p_dbg(p2p, "Completed device entry based on data from GO Negotiation Request");
        } else {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Created device entry based on GO Neg Req: "
+               p2p_dbg(p2p, "Created device entry based on GO Neg Req: "
                        MACSTR " dev_capab=0x%x group_capab=0x%x name='%s' "
                        "listen_freq=%d",
                        MAC2STR(dev->info.p2p_device_addr),
@@ -1518,8 +1452,7 @@ void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr,
        dev->flags &= ~P2P_DEV_GROUP_CLIENT_ONLY;
 
        if (dev->flags & P2P_DEV_USER_REJECTED) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Do not report rejected device");
+               p2p_dbg(p2p, "Do not report rejected device");
                return;
        }
 
@@ -1555,10 +1488,8 @@ void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer)
        int freqs;
        size_t i, j;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: GO Negotiation with " MACSTR " completed (%s will be "
-               "GO)", MAC2STR(peer->info.p2p_device_addr),
-               go ? "local end" : "peer");
+       p2p_dbg(p2p, "GO Negotiation with " MACSTR " completed (%s will be GO)",
+               MAC2STR(peer->info.p2p_device_addr), go ? "local end" : "peer");
 
        os_memset(&res, 0, sizeof(res));
        res.role_go = go;
@@ -1620,8 +1551,7 @@ void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer)
 static void p2p_rx_p2p_action(struct p2p_data *p2p, const u8 *sa,
                              const u8 *data, size_t len, int rx_freq)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: RX P2P Public Action from " MACSTR, MAC2STR(sa));
+       p2p_dbg(p2p, "RX P2P Public Action from " MACSTR, MAC2STR(sa));
        wpa_hexdump(MSG_MSGDUMP, "P2P: P2P Public Action contents", data, len);
 
        if (len < 1)
@@ -1657,8 +1587,7 @@ static void p2p_rx_p2p_action(struct p2p_data *p2p, const u8 *sa,
                p2p_process_dev_disc_resp(p2p, sa, data + 1, len - 1);
                break;
        default:
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unsupported P2P Public Action frame type %d",
+               p2p_dbg(p2p, "Unsupported P2P Public Action frame type %d",
                        data[0]);
                break;
        }
@@ -1733,16 +1662,14 @@ void p2p_rx_action(struct p2p_data *p2p, const u8 *da, const u8 *sa,
        len--;
 
        /* P2P action frame */
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: RX P2P Action from " MACSTR, MAC2STR(sa));
+       p2p_dbg(p2p, "RX P2P Action from " MACSTR, MAC2STR(sa));
        wpa_hexdump(MSG_MSGDUMP, "P2P: P2P Action contents", data, len);
 
        if (len < 1)
                return;
        switch (data[0]) {
        case P2P_NOA:
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Received P2P Action - Notice of Absence");
+               p2p_dbg(p2p, "Received P2P Action - Notice of Absence");
                /* TODO */
                break;
        case P2P_PRESENCE_REQ:
@@ -1755,8 +1682,7 @@ void p2p_rx_action(struct p2p_data *p2p, const u8 *da, const u8 *sa,
                p2p_process_go_disc_req(p2p, da, sa, data + 1, len - 1, freq);
                break;
        default:
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Received P2P Action - unknown type %u", data[0]);
+               p2p_dbg(p2p, "Received P2P Action - unknown type %u", data[0]);
                break;
        }
 }
@@ -1832,7 +1758,7 @@ static void p2p_add_dev_from_probe_req(struct p2p_data *p2p, const u8 *addr,
                                                       msg.listen_channel[4]);
        }
 
-       p2p_copy_wps_info(dev, 1, &msg);
+       p2p_copy_wps_info(p2p, dev, 1, &msg);
 
        if (msg.wfd_subelems) {
                wpabuf_free(dev->info.wfd_subelems);
@@ -1841,8 +1767,7 @@ static void p2p_add_dev_from_probe_req(struct p2p_data *p2p, const u8 *addr,
 
        p2p_parse_free(&msg);
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Created device entry based on Probe Req: " MACSTR
+       p2p_dbg(p2p, "Created device entry based on Probe Req: " MACSTR
                " dev_capab=0x%x group_capab=0x%x name='%s' listen_freq=%d",
                MAC2STR(dev->info.p2p_device_addr), dev->info.dev_capab,
                dev->info.group_capab, dev->info.device_name,
@@ -2084,8 +2009,7 @@ p2p_reply_probe(struct p2p_data *p2p, const u8 *addr, const u8 *dst,
                return P2P_PREQ_NOT_PROCESSED;
        }
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Reply to P2P Probe Request in Listen state");
+       p2p_dbg(p2p, "Reply to P2P Probe Request in Listen state");
 
        /*
         * We do not really have a specific BSS that this frame is advertising,
@@ -2164,9 +2088,7 @@ p2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *dst,
            == 0 &&
            !(p2p->go_neg_peer->flags & P2P_DEV_WAIT_GO_NEG_CONFIRM)) {
                /* Received a Probe Request from GO Negotiation peer */
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Found GO Negotiation peer - try to start GO "
-                       "negotiation from timeout");
+               p2p_dbg(p2p, "Found GO Negotiation peer - try to start GO negotiation from timeout");
                eloop_cancel_timeout(p2p_go_neg_start, p2p, NULL);
                eloop_register_timeout(0, 0, p2p_go_neg_start, p2p, NULL);
                return P2P_PREQ_PROCESSED;
@@ -2177,9 +2099,7 @@ p2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *dst,
            os_memcmp(addr, p2p->invite_peer->info.p2p_device_addr, ETH_ALEN)
            == 0) {
                /* Received a Probe Request from Invite peer */
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Found Invite peer - try to start Invite from "
-                       "timeout");
+               p2p_dbg(p2p, "Found Invite peer - try to start Invite from timeout");
                eloop_register_timeout(0, 0, p2p_invite_start, p2p, NULL);
                return P2P_PREQ_PROCESSED;
        }
@@ -2354,24 +2274,20 @@ static void p2p_clear_go_neg(struct p2p_data *p2p)
 void p2p_wps_success_cb(struct p2p_data *p2p, const u8 *mac_addr)
 {
        if (p2p->go_neg_peer == NULL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No pending Group Formation - "
-                       "ignore WPS registration success notification");
+               p2p_dbg(p2p, "No pending Group Formation - ignore WPS registration success notification");
                return; /* No pending Group Formation */
        }
 
        if (os_memcmp(mac_addr, p2p->go_neg_peer->intended_addr, ETH_ALEN) !=
            0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Ignore WPS registration success notification "
-                       "for " MACSTR " (GO Negotiation peer " MACSTR ")",
+               p2p_dbg(p2p, "Ignore WPS registration success notification for "
+                       MACSTR " (GO Negotiation peer " MACSTR ")",
                        MAC2STR(mac_addr),
                        MAC2STR(p2p->go_neg_peer->intended_addr));
                return; /* Ignore unexpected peer address */
        }
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Group Formation completed successfully with " MACSTR,
+       p2p_dbg(p2p, "Group Formation completed successfully with " MACSTR,
                MAC2STR(mac_addr));
 
        p2p_clear_go_neg(p2p);
@@ -2381,14 +2297,11 @@ void p2p_wps_success_cb(struct p2p_data *p2p, const u8 *mac_addr)
 void p2p_group_formation_failed(struct p2p_data *p2p)
 {
        if (p2p->go_neg_peer == NULL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No pending Group Formation - "
-                       "ignore group formation failure notification");
+               p2p_dbg(p2p, "No pending Group Formation - ignore group formation failure notification");
                return; /* No pending Group Formation */
        }
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Group Formation failed with " MACSTR,
+       p2p_dbg(p2p, "Group Formation failed with " MACSTR,
                MAC2STR(p2p->go_neg_peer->intended_addr));
 
        p2p_clear_go_neg(p2p);
@@ -2512,8 +2425,7 @@ int p2p_unauthorize(struct p2p_data *p2p, const u8 *addr)
        if (dev == NULL)
                return -1;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Unauthorizing " MACSTR,
-               MAC2STR(addr));
+       p2p_dbg(p2p, "Unauthorizing " MACSTR, MAC2STR(addr));
 
        if (p2p->go_neg_peer == dev)
                p2p->go_neg_peer = NULL;
@@ -2685,8 +2597,7 @@ void p2p_continue_find(struct p2p_data *p2p)
                                break;
                } else if (dev->req_config_methods &&
                           !(dev->flags & P2P_DEV_PD_FOR_JOIN)) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Send "
-                               "pending Provision Discovery Request to "
+                       p2p_dbg(p2p, "Send pending Provision Discovery Request to "
                                MACSTR " (config methods 0x%x)",
                                MAC2STR(dev->info.p2p_device_addr),
                                dev->req_config_methods);
@@ -2701,8 +2612,7 @@ void p2p_continue_find(struct p2p_data *p2p)
 
 static void p2p_sd_cb(struct p2p_data *p2p, int success)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Service Discovery Query TX callback: success=%d",
+       p2p_dbg(p2p, "Service Discovery Query TX callback: success=%d",
                success);
        p2p->pending_action_state = P2P_NO_PENDING_ACTION;
 
@@ -2716,8 +2626,7 @@ static void p2p_sd_cb(struct p2p_data *p2p, int success)
        }
 
        if (p2p->sd_peer == NULL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No SD peer entry known");
+               p2p_dbg(p2p, "No SD peer entry known");
                p2p_continue_find(p2p);
                return;
        }
@@ -2751,8 +2660,7 @@ static void p2p_retry_pd(struct p2p_data *p2p)
                if (!dev->req_config_methods)
                        continue;
 
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Send "
-                       "pending Provision Discovery Request to "
+               p2p_dbg(p2p, "Send pending Provision Discovery Request to "
                        MACSTR " (config methods 0x%x)",
                        MAC2STR(dev->info.p2p_device_addr),
                        dev->req_config_methods);
@@ -2765,8 +2673,7 @@ static void p2p_retry_pd(struct p2p_data *p2p)
 
 static void p2p_prov_disc_cb(struct p2p_data *p2p, int success)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Provision Discovery Request TX callback: success=%d",
+       p2p_dbg(p2p, "Provision Discovery Request TX callback: success=%d",
                success);
 
        /*
@@ -2825,8 +2732,8 @@ int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq,
                 * that have based on frames received after the last p2p_find
                 * operation was started.
                 */
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Ignore old scan "
-                       "result for " MACSTR " (rx_time=%u.%06u)",
+               p2p_dbg(p2p, "Ignore old scan result for " MACSTR
+                       " (rx_time=%u.%06u)",
                        MAC2STR(bssid), (unsigned int) rx_time->sec,
                        (unsigned int) rx_time->usec);
                return 0;
@@ -2841,8 +2748,7 @@ int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq,
 void p2p_scan_res_handled(struct p2p_data *p2p)
 {
        if (!p2p->p2p_scan_running) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: p2p_scan was not "
-                       "running, but scan results received");
+               p2p_dbg(p2p, "p2p_scan was not running, but scan results received");
        }
        p2p->p2p_scan_running = 0;
        eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL);
@@ -2904,13 +2810,10 @@ static void p2p_go_neg_req_cb(struct p2p_data *p2p, int success)
        struct p2p_device *dev = p2p->go_neg_peer;
        int timeout;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: GO Negotiation Request TX callback: success=%d",
-               success);
+       p2p_dbg(p2p, "GO Negotiation Request TX callback: success=%d", success);
 
        if (dev == NULL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No pending GO Negotiation");
+               p2p_dbg(p2p, "No pending GO Negotiation");
                return;
        }
 
@@ -2927,9 +2830,7 @@ static void p2p_go_neg_req_cb(struct p2p_data *p2p, int success)
        if (!success &&
            (dev->info.dev_capab & P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY) &&
            !is_zero_ether_addr(dev->member_in_go_dev)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Peer " MACSTR " did not acknowledge request - "
-                       "try to use device discoverability through its GO",
+               p2p_dbg(p2p, "Peer " MACSTR " did not acknowledge request - try to use device discoverability through its GO",
                        MAC2STR(dev->info.p2p_device_addr));
                p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
                p2p_send_dev_disc_req(p2p, dev);
@@ -2960,13 +2861,10 @@ static void p2p_go_neg_req_cb(struct p2p_data *p2p, int success)
 
 static void p2p_go_neg_resp_cb(struct p2p_data *p2p, int success)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: GO Negotiation Response TX callback: success=%d",
+       p2p_dbg(p2p, "GO Negotiation Response TX callback: success=%d",
                success);
        if (!p2p->go_neg_peer && p2p->state == P2P_PROVISIONING) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Ignore TX callback event - GO Negotiation is "
-                       "not running anymore");
+               p2p_dbg(p2p, "Ignore TX callback event - GO Negotiation is not running anymore");
                return;
        }
        p2p_set_state(p2p, P2P_CONNECT);
@@ -2977,9 +2875,7 @@ static void p2p_go_neg_resp_cb(struct p2p_data *p2p, int success)
 static void p2p_go_neg_resp_failure_cb(struct p2p_data *p2p, int success,
                                       const u8 *addr)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: GO Negotiation Response (failure) TX callback: "
-               "success=%d", success);
+       p2p_dbg(p2p, "GO Negotiation Response (failure) TX callback: success=%d", success);
        if (p2p->go_neg_peer && p2p->go_neg_peer->status != P2P_SC_SUCCESS) {
                p2p_go_neg_failed(p2p, p2p->go_neg_peer,
                                  p2p->go_neg_peer->status);
@@ -2998,9 +2894,7 @@ static void p2p_go_neg_conf_cb(struct p2p_data *p2p,
 {
        struct p2p_device *dev;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: GO Negotiation Confirm TX callback: result=%d",
-               result);
+       p2p_dbg(p2p, "GO Negotiation Confirm TX callback: result=%d", result);
        p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
        if (result == P2P_SEND_ACTION_FAILED) {
                p2p_go_neg_failed(p2p, p2p->go_neg_peer, -1);
@@ -3017,10 +2911,7 @@ static void p2p_go_neg_conf_cb(struct p2p_data *p2p,
                 * peer did indeed receive the frame, continue regardless of
                 * the TX status.
                 */
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Assume GO Negotiation Confirm TX was actually "
-                       "received by the peer even though Ack was not "
-                       "reported");
+               p2p_dbg(p2p, "Assume GO Negotiation Confirm TX was actually received by the peer even though Ack was not reported");
        }
 
        dev = p2p->go_neg_peer;
@@ -3038,8 +2929,7 @@ void p2p_send_action_cb(struct p2p_data *p2p, unsigned int freq, const u8 *dst,
        enum p2p_pending_action_state state;
        int success;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Action frame TX callback (state=%d freq=%u dst=" MACSTR
+       p2p_dbg(p2p, "Action frame TX callback (state=%d freq=%u dst=" MACSTR
                " src=" MACSTR " bssid=" MACSTR " result=%d",
                p2p->pending_action_state, freq, MAC2STR(dst), MAC2STR(src),
                MAC2STR(bssid), result);
@@ -3054,9 +2944,7 @@ void p2p_send_action_cb(struct p2p_data *p2p, unsigned int freq, const u8 *dst,
                            p2p_run_after_scan(p2p))
                                break;
                        if (p2p->state == P2P_SEARCH) {
-                               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                                       "P2P: Continue find after "
-                                       "after_scan_tx completion");
+                               p2p_dbg(p2p, "Continue find after after_scan_tx completion");
                                p2p_continue_find(p2p);
                        }
                }
@@ -3104,23 +2992,18 @@ void p2p_listen_cb(struct p2p_data *p2p, unsigned int freq,
                   unsigned int duration)
 {
        if (freq == p2p->pending_client_disc_freq) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Client discoverability remain-awake completed");
+               p2p_dbg(p2p, "Client discoverability remain-awake completed");
                p2p->pending_client_disc_freq = 0;
                return;
        }
 
        if (freq != p2p->pending_listen_freq) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unexpected listen callback for freq=%u "
-                       "duration=%u (pending_listen_freq=%u)",
+               p2p_dbg(p2p, "Unexpected listen callback for freq=%u duration=%u (pending_listen_freq=%u)",
                        freq, duration, p2p->pending_listen_freq);
                return;
        }
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Starting Listen timeout(%u,%u) on freq=%u based on "
-               "callback",
+       p2p_dbg(p2p, "Starting Listen timeout(%u,%u) on freq=%u based on callback",
                p2p->pending_listen_sec, p2p->pending_listen_usec,
                p2p->pending_listen_freq);
        p2p->in_listen = 1;
@@ -3141,17 +3024,14 @@ void p2p_listen_cb(struct p2p_data *p2p, unsigned int freq,
 
 int p2p_listen_end(struct p2p_data *p2p, unsigned int freq)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Driver ended Listen "
-               "state (freq=%u)", freq);
+       p2p_dbg(p2p, "Driver ended Listen state (freq=%u)", freq);
        p2p->drv_in_listen = 0;
        if (p2p->in_listen)
                return 0; /* Internal timeout will trigger the next step */
 
        if (p2p->state == P2P_CONNECT_LISTEN && p2p->go_neg_peer) {
                if (p2p->go_neg_peer->connect_reqs >= 120) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Timeout on sending GO Negotiation "
-                               "Request without getting response");
+                       p2p_dbg(p2p, "Timeout on sending GO Negotiation Request without getting response");
                        p2p_go_neg_failed(p2p, p2p->go_neg_peer, -1);
                        return 0;
                }
@@ -3169,9 +3049,7 @@ int p2p_listen_end(struct p2p_data *p2p, unsigned int freq)
                          * operation while in p2p_find. Avoid an attempt to
                          * restart a scan here.
                          */
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: p2p_scan "
-                               "already in progress - do not try to start a "
-                               "new one");
+                       p2p_dbg(p2p, "p2p_scan already in progress - do not try to start a new one");
                        return 1;
                }
                if (p2p->pending_listen_freq) {
@@ -3180,15 +3058,12 @@ int p2p_listen_end(struct p2p_data *p2p, unsigned int freq)
                         * offchannel operation for some reason. p2p_search()
                         * will be started from internal timeout.
                         */
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Listen "
-                               "operation did not seem to start - delay "
-                               "search phase to avoid busy loop");
+                       p2p_dbg(p2p, "Listen operation did not seem to start - delay search phase to avoid busy loop");
                        p2p_set_timeout(p2p, 0, 100000);
                        return 1;
                }
                if (p2p->search_delay) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Delay "
-                               "search operation by %u ms",
+                       p2p_dbg(p2p, "Delay search operation by %u ms",
                                p2p->search_delay);
                        p2p_set_timeout(p2p, p2p->search_delay / 1000,
                                        (p2p->search_delay % 1000) * 1000);
@@ -3207,17 +3082,14 @@ static void p2p_timeout_connect(struct p2p_data *p2p)
        p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
        if (p2p->go_neg_peer &&
            (p2p->go_neg_peer->flags & P2P_DEV_WAIT_GO_NEG_CONFIRM)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Wait for GO "
-                       "Negotiation Confirm timed out - assume GO "
-                       "Negotiation failed");
+               p2p_dbg(p2p, "Wait for GO Negotiation Confirm timed out - assume GO Negotiation failed");
                p2p_go_neg_failed(p2p, p2p->go_neg_peer, -1);
                return;
        }
        if (p2p->go_neg_peer &&
            (p2p->go_neg_peer->flags & P2P_DEV_PEER_WAITING_RESPONSE) &&
            p2p->go_neg_peer->connect_reqs < 120) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer expected to "
-                       "wait our response - skip listen");
+               p2p_dbg(p2p, "Peer expected to wait our response - skip listen");
                p2p_connect_send(p2p, p2p->go_neg_peer);
                return;
        }
@@ -3231,16 +3103,12 @@ static void p2p_timeout_connect_listen(struct p2p_data *p2p)
 {
        if (p2p->go_neg_peer) {
                if (p2p->drv_in_listen) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Driver is "
-                               "still in Listen state; wait for it to "
-                               "complete");
+                       p2p_dbg(p2p, "Driver is still in Listen state; wait for it to complete");
                        return;
                }
 
                if (p2p->go_neg_peer->connect_reqs >= 120) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Timeout on sending GO Negotiation "
-                               "Request without getting response");
+                       p2p_dbg(p2p, "Timeout on sending GO Negotiation Request without getting response");
                        p2p_go_neg_failed(p2p, p2p->go_neg_peer, -1);
                        return;
                }
@@ -3269,23 +3137,18 @@ static void p2p_timeout_wait_peer_idle(struct p2p_data *p2p)
        struct p2p_device *dev = p2p->go_neg_peer;
 
        if (dev == NULL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unknown GO Neg peer - stop GO Neg wait");
+               p2p_dbg(p2p, "Unknown GO Neg peer - stop GO Neg wait");
                return;
        }
 
        dev->wait_count++;
        if (dev->wait_count >= 120) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Timeout on waiting peer to become ready for GO "
-                       "Negotiation");
+               p2p_dbg(p2p, "Timeout on waiting peer to become ready for GO Negotiation");
                p2p_go_neg_failed(p2p, dev, -1);
                return;
        }
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Go to Listen state while waiting for the peer to become "
-               "ready for GO Negotiation");
+       p2p_dbg(p2p, "Go to Listen state while waiting for the peer to become ready for GO Negotiation");
        p2p_set_state(p2p, P2P_WAIT_PEER_CONNECT);
        p2p_listen_in_find(p2p, 0);
 }
@@ -3293,8 +3156,7 @@ static void p2p_timeout_wait_peer_idle(struct p2p_data *p2p)
 
 static void p2p_timeout_sd_during_find(struct p2p_data *p2p)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Service Discovery Query timeout");
+       p2p_dbg(p2p, "Service Discovery Query timeout");
        if (p2p->sd_peer) {
                p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
                p2p->sd_peer->flags &= ~P2P_DEV_SD_SCHEDULE;
@@ -3306,8 +3168,7 @@ static void p2p_timeout_sd_during_find(struct p2p_data *p2p)
 
 static void p2p_timeout_prov_disc_during_find(struct p2p_data *p2p)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Provision Discovery Request timeout");
+       p2p_dbg(p2p, "Provision Discovery Request timeout");
        p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
        p2p_continue_find(p2p);
 }
@@ -3325,8 +3186,7 @@ static void p2p_timeout_prov_disc_req(struct p2p_data *p2p)
        if (!p2p->user_initiated_pd)
                return;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: User initiated Provision Discovery Request timeout");
+       p2p_dbg(p2p, "User initiated Provision Discovery Request timeout");
 
        if (p2p->pd_retries) {
                p2p->pd_retries--;
@@ -3364,8 +3224,7 @@ static void p2p_timeout_invite(struct p2p_data *p2p)
                 * Better remain on operating channel instead of listen channel
                 * when running a group.
                 */
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Inviting in "
-                       "active GO role - wait on operating channel");
+               p2p_dbg(p2p, "Inviting in active GO role - wait on operating channel");
                p2p_set_timeout(p2p, 0, 100000);
                return;
        }
@@ -3381,8 +3240,7 @@ static void p2p_timeout_invite_listen(struct p2p_data *p2p)
                                p2p->invite_go_dev_addr);
        } else {
                if (p2p->invite_peer) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Invitation Request retry limit reached");
+                       p2p_dbg(p2p, "Invitation Request retry limit reached");
                        if (p2p->cfg->invitation_result)
                                p2p->cfg->invitation_result(
                                        p2p->cfg->cb_ctx, -1, NULL, NULL,
@@ -3397,8 +3255,7 @@ static void p2p_state_timeout(void *eloop_ctx, void *timeout_ctx)
 {
        struct p2p_data *p2p = eloop_ctx;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Timeout (state=%s)",
-               p2p_state_txt(p2p->state));
+       p2p_dbg(p2p, "Timeout (state=%s)", p2p_state_txt(p2p->state));
 
        p2p->in_listen = 0;
 
@@ -3413,8 +3270,7 @@ static void p2p_state_timeout(void *eloop_ctx, void *timeout_ctx)
                if (p2p->pending_action_state == P2P_PENDING_PD)
                        p2p_timeout_prov_disc_req(p2p);
                if (p2p->search_delay && !p2p->in_search_delay) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Delay "
-                               "search operation by %u ms",
+                       p2p_dbg(p2p, "Delay search operation by %u ms",
                                p2p->search_delay);
                        p2p->in_search_delay = 1;
                        p2p_set_timeout(p2p, p2p->search_delay / 1000,
@@ -3438,9 +3294,7 @@ static void p2p_state_timeout(void *eloop_ctx, void *timeout_ctx)
                        p2p_timeout_prov_disc_req(p2p);
 
                if (p2p->ext_listen_only) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Extended Listen Timing - Listen State "
-                               "completed");
+                       p2p_dbg(p2p, "Extended Listen Timing - Listen State completed");
                        p2p->ext_listen_only = 0;
                        p2p_set_state(p2p, P2P_IDLE);
                }
@@ -3478,11 +3332,10 @@ int p2p_reject(struct p2p_data *p2p, const u8 *peer_addr)
        struct p2p_device *dev;
 
        dev = p2p_get_device(p2p, peer_addr);
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Local request to reject "
-               "connection attempts by peer " MACSTR, MAC2STR(peer_addr));
+       p2p_dbg(p2p, "Local request to reject connection attempts by peer "
+               MACSTR, MAC2STR(peer_addr));
        if (dev == NULL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer " MACSTR
-                       " unknown", MAC2STR(peer_addr));
+               p2p_dbg(p2p, "Peer " MACSTR " unknown", MAC2STR(peer_addr));
                return -1;
        }
        dev->status = P2P_SC_FAIL_REJECTED_BY_USER;
@@ -3683,12 +3536,10 @@ int p2p_peer_known(struct p2p_data *p2p, const u8 *addr)
 void p2p_set_client_discoverability(struct p2p_data *p2p, int enabled)
 {
        if (enabled) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Client "
-                       "discoverability enabled");
+               p2p_dbg(p2p, "Client discoverability enabled");
                p2p->dev_capab |= P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY;
        } else {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Client "
-                       "discoverability disabled");
+               p2p_dbg(p2p, "Client discoverability disabled");
                p2p->dev_capab &= ~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY;
        }
 }
@@ -3737,9 +3588,9 @@ int p2p_presence_req(struct p2p_data *p2p, const u8 *go_interface_addr,
 {
        struct wpabuf *req;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Send Presence Request to "
-               "GO " MACSTR " (own interface " MACSTR ") freq=%u dur1=%u "
-               "int1=%u dur2=%u int2=%u",
+       p2p_dbg(p2p, "Send Presence Request to GO " MACSTR
+               " (own interface " MACSTR ") freq=%u dur1=%u int1=%u "
+               "dur2=%u int2=%u",
                MAC2STR(go_interface_addr), MAC2STR(own_interface_addr),
                freq, duration1, interval1, duration2, interval2);
 
@@ -3752,8 +3603,7 @@ int p2p_presence_req(struct p2p_data *p2p, const u8 *go_interface_addr,
        if (p2p_send_action(p2p, freq, go_interface_addr, own_interface_addr,
                            go_interface_addr,
                            wpabuf_head(req), wpabuf_len(req), 200) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
        }
        wpabuf_free(req);
 
@@ -3799,8 +3649,7 @@ static void p2p_process_presence_req(struct p2p_data *p2p, const u8 *da,
        u8 noa[50];
        int noa_len;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Received P2P Action - P2P Presence Request");
+       p2p_dbg(p2p, "Received P2P Action - P2P Presence Request");
 
        for (g = 0; g < p2p->num_groups; g++) {
                if (os_memcmp(da, p2p_group_get_interface_addr(p2p->groups[g]),
@@ -3810,23 +3659,20 @@ static void p2p_process_presence_req(struct p2p_data *p2p, const u8 *da,
                }
        }
        if (group == NULL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Ignore P2P Presence Request for unknown group "
+               p2p_dbg(p2p, "Ignore P2P Presence Request for unknown group "
                        MACSTR, MAC2STR(da));
                return;
        }
 
        if (p2p_parse(data, len, &msg) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to parse P2P Presence Request");
+               p2p_dbg(p2p, "Failed to parse P2P Presence Request");
                status = P2P_SC_FAIL_INVALID_PARAMS;
                goto fail;
        }
        parsed = 1;
 
        if (msg.noa == NULL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No NoA attribute in P2P Presence Request");
+               p2p_dbg(p2p, "No NoA attribute in P2P Presence Request");
                status = P2P_SC_FAIL_INVALID_PARAMS;
                goto fail;
        }
@@ -3850,8 +3696,7 @@ fail:
        p2p->pending_action_state = P2P_NO_PENDING_ACTION;
        if (p2p_send_action(p2p, rx_freq, sa, da, da,
                            wpabuf_head(resp), wpabuf_len(resp), 200) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
        }
        wpabuf_free(resp);
 }
@@ -3862,33 +3707,27 @@ static void p2p_process_presence_resp(struct p2p_data *p2p, const u8 *da,
 {
        struct p2p_message msg;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Received P2P Action - P2P Presence Response");
+       p2p_dbg(p2p, "Received P2P Action - P2P Presence Response");
 
        if (p2p_parse(data, len, &msg) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to parse P2P Presence Response");
+               p2p_dbg(p2p, "Failed to parse P2P Presence Response");
                return;
        }
 
        if (msg.status == NULL || msg.noa == NULL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No Status or NoA attribute in P2P Presence "
-                       "Response");
+               p2p_dbg(p2p, "No Status or NoA attribute in P2P Presence Response");
                p2p_parse_free(&msg);
                return;
        }
 
        if (*msg.status) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: P2P Presence Request was rejected: status %u",
+               p2p_dbg(p2p, "P2P Presence Request was rejected: status %u",
                        *msg.status);
                p2p_parse_free(&msg);
                return;
        }
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: P2P Presence Request was accepted");
+       p2p_dbg(p2p, "P2P Presence Request was accepted");
        wpa_hexdump(MSG_DEBUG, "P2P: P2P Presence Response - NoA",
                    msg.noa, msg.noa_len);
        /* TODO: process NoA */
@@ -3914,25 +3753,20 @@ static void p2p_ext_listen_timeout(void *eloop_ctx, void *timeout_ctx)
                 * running at an inconvenient time. As a workaround, allow new
                 * Extended Listen operation to be started.
                 */
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Previous "
-                       "Extended Listen operation had not been completed - "
-                       "try again");
+               p2p_dbg(p2p, "Previous Extended Listen operation had not been completed - try again");
                p2p->ext_listen_only = 0;
                p2p_set_state(p2p, P2P_IDLE);
        }
 
        if (p2p->state != P2P_IDLE) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Skip Extended "
-                       "Listen timeout in active state (%s)",
-                       p2p_state_txt(p2p->state));
+               p2p_dbg(p2p, "Skip Extended Listen timeout in active state (%s)", p2p_state_txt(p2p->state));
                return;
        }
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Extended Listen timeout");
+       p2p_dbg(p2p, "Extended Listen timeout");
        p2p->ext_listen_only = 1;
        if (p2p_listen(p2p, p2p->ext_listen_period) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Failed to start "
-                       "Listen state for Extended Listen Timing");
+               p2p_dbg(p2p, "Failed to start Listen state for Extended Listen Timing");
                p2p->ext_listen_only = 0;
        }
 }
@@ -3943,25 +3777,22 @@ int p2p_ext_listen(struct p2p_data *p2p, unsigned int period,
 {
        if (period > 65535 || interval > 65535 || period > interval ||
            (period == 0 && interval > 0) || (period > 0 && interval == 0)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Invalid Extended Listen Timing request: "
-                       "period=%u interval=%u", period, interval);
+               p2p_dbg(p2p, "Invalid Extended Listen Timing request: period=%u interval=%u",
+                       period, interval);
                return -1;
        }
 
        eloop_cancel_timeout(p2p_ext_listen_timeout, p2p, NULL);
 
        if (interval == 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Disabling Extended Listen Timing");
+               p2p_dbg(p2p, "Disabling Extended Listen Timing");
                p2p->ext_listen_period = 0;
                p2p->ext_listen_interval = 0;
                return 0;
        }
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Enabling Extended Listen Timing: period %u msec, "
-               "interval %u msec", period, interval);
+       p2p_dbg(p2p, "Enabling Extended Listen Timing: period %u msec, interval %u msec",
+               period, interval);
        p2p->ext_listen_period = period;
        p2p->ext_listen_interval = interval;
        p2p->ext_listen_interval_sec = interval / 1000;
@@ -3989,8 +3820,7 @@ void p2p_deauth_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code,
        if (msg.minor_reason_code == NULL)
                return;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_INFO,
-               "P2P: Deauthentication notification BSSID " MACSTR
+       p2p_dbg(p2p, "Deauthentication notification BSSID " MACSTR
                " reason_code=%u minor_reason_code=%u",
                MAC2STR(bssid), reason_code, *msg.minor_reason_code);
 
@@ -4012,8 +3842,7 @@ void p2p_disassoc_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code,
        if (msg.minor_reason_code == NULL)
                return;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_INFO,
-               "P2P: Disassociation notification BSSID " MACSTR
+       p2p_dbg(p2p, "Disassociation notification BSSID " MACSTR
                " reason_code=%u minor_reason_code=%u",
                MAC2STR(bssid), reason_code, *msg.minor_reason_code);
 
@@ -4024,12 +3853,10 @@ void p2p_disassoc_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code,
 void p2p_set_managed_oper(struct p2p_data *p2p, int enabled)
 {
        if (enabled) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Managed P2P "
-                       "Device operations enabled");
+               p2p_dbg(p2p, "Managed P2P Device operations enabled");
                p2p->dev_capab |= P2P_DEV_CAPAB_INFRA_MANAGED;
        } else {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Managed P2P "
-                       "Device operations disabled");
+               p2p_dbg(p2p, "Managed P2P Device operations disabled");
                p2p->dev_capab &= ~P2P_DEV_CAPAB_INFRA_MANAGED;
        }
 }
@@ -4040,8 +3867,8 @@ int p2p_set_listen_channel(struct p2p_data *p2p, u8 reg_class, u8 channel)
        if (p2p_channel_to_freq(reg_class, channel) < 0)
                return -1;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Set Listen channel: "
-               "reg_class %u channel %u", reg_class, channel);
+       p2p_dbg(p2p, "Set Listen channel: reg_class %u channel %u",
+               reg_class, channel);
        p2p->cfg->reg_class = reg_class;
        p2p->cfg->channel = channel;
 
@@ -4051,7 +3878,7 @@ int p2p_set_listen_channel(struct p2p_data *p2p, u8 reg_class, u8 channel)
 
 int p2p_set_ssid_postfix(struct p2p_data *p2p, const u8 *postfix, size_t len)
 {
-       wpa_hexdump_ascii(MSG_DEBUG, "P2P: New SSID postfix", postfix, len);
+       p2p_dbg(p2p, "New SSID postfix: %s", wpa_ssid_txt(postfix, len));
        if (postfix == NULL) {
                p2p->cfg->ssid_postfix_len = 0;
                return 0;
@@ -4070,8 +3897,8 @@ int p2p_set_oper_channel(struct p2p_data *p2p, u8 op_reg_class, u8 op_channel,
        if (p2p_channel_to_freq(op_reg_class, op_channel) < 0)
                return -1;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_INFO, "P2P: Set Operating channel: "
-               "reg_class %u channel %u", op_reg_class, op_channel);
+       p2p_dbg(p2p, "Set Operating channel: reg_class %u channel %u",
+               op_reg_class, op_channel);
        p2p->cfg->op_reg_class = op_reg_class;
        p2p->cfg->op_channel = op_channel;
        p2p->cfg->cfg_op_channel = cfg_op_channel;
@@ -4127,18 +3954,16 @@ void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr)
 {
        os_memcpy(p2p->peer_filter, addr, ETH_ALEN);
        if (is_zero_ether_addr(p2p->peer_filter))
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Disable peer "
-                       "filter");
+               p2p_dbg(p2p, "Disable peer filter");
        else
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Enable peer "
-                       "filter for " MACSTR, MAC2STR(p2p->peer_filter));
+               p2p_dbg(p2p, "Enable peer filter for " MACSTR,
+                       MAC2STR(p2p->peer_filter));
 }
 
 
 void p2p_set_cross_connect(struct p2p_data *p2p, int enabled)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Cross connection %s",
-               enabled ? "enabled" : "disabled");
+       p2p_dbg(p2p, "Cross connection %s", enabled ? "enabled" : "disabled");
        if (p2p->cross_connect == enabled)
                return;
        p2p->cross_connect = enabled;
@@ -4159,7 +3984,7 @@ int p2p_get_oper_freq(struct p2p_data *p2p, const u8 *iface_addr)
 
 void p2p_set_intra_bss_dist(struct p2p_data *p2p, int enabled)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Intra BSS distribution %s",
+       p2p_dbg(p2p, "Intra BSS distribution %s",
                enabled ? "enabled" : "disabled");
        p2p->cfg->p2p_intra_bss = enabled;
 }
@@ -4167,7 +3992,7 @@ void p2p_set_intra_bss_dist(struct p2p_data *p2p, int enabled)
 
 void p2p_update_channel_list(struct p2p_data *p2p, struct p2p_channels *chan)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Update channel list");
+       p2p_dbg(p2p, "Update channel list");
        os_memcpy(&p2p->cfg->channels, chan, sizeof(struct p2p_channels));
 }
 
@@ -4177,11 +4002,9 @@ int p2p_send_action(struct p2p_data *p2p, unsigned int freq, const u8 *dst,
                    size_t len, unsigned int wait_time)
 {
        if (p2p->p2p_scan_running) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Delay Action "
-                       "frame TX until p2p_scan completes");
+               p2p_dbg(p2p, "Delay Action frame TX until p2p_scan completes");
                if (p2p->after_scan_tx) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Dropped "
-                               "previous pending Action frame TX");
+                       p2p_dbg(p2p, "Dropped previous pending Action frame TX");
                        os_free(p2p->after_scan_tx);
                }
                p2p->after_scan_tx = os_malloc(sizeof(*p2p->after_scan_tx) +
@@ -4206,8 +4029,8 @@ int p2p_send_action(struct p2p_data *p2p, unsigned int freq, const u8 *dst,
 void p2p_set_best_channels(struct p2p_data *p2p, int freq_24, int freq_5,
                           int freq_overall)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Best channel: 2.4 GHz: %d,"
-               "  5 GHz: %d,  overall: %d", freq_24, freq_5, freq_overall);
+       p2p_dbg(p2p, "Best channel: 2.4 GHz: %d,  5 GHz: %d,  overall: %d",
+               freq_24, freq_5, freq_overall);
        p2p->best_freq_24 = freq_24;
        p2p->best_freq_5 = freq_5;
        p2p->best_freq_overall = freq_overall;
@@ -4216,8 +4039,7 @@ void p2p_set_best_channels(struct p2p_data *p2p, int freq_24, int freq_5,
 
 void p2p_set_own_freq_preference(struct p2p_data *p2p, int freq)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Own frequency preference: "
-               "%d MHz", freq);
+       p2p_dbg(p2p, "Own frequency preference: %d MHz", freq);
        p2p->own_freq_preference = freq;
 }
 
@@ -4433,9 +4255,56 @@ int p2p_set_disc_int(struct p2p_data *p2p, int min_disc_int, int max_disc_int,
        p2p->min_disc_int = min_disc_int;
        p2p->max_disc_int = max_disc_int;
        p2p->max_disc_tu = max_disc_tu;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Set discoverable interval: "
-               "min=%d max=%d max_tu=%d", min_disc_int, max_disc_int,
-               max_disc_tu);
+       p2p_dbg(p2p, "Set discoverable interval: min=%d max=%d max_tu=%d",
+               min_disc_int, max_disc_int, max_disc_tu);
 
        return 0;
 }
+
+
+void p2p_dbg(struct p2p_data *p2p, const char *fmt, ...)
+{
+       va_list ap;
+       char buf[500];
+
+       if (!p2p->cfg->debug_print)
+               return;
+
+       va_start(ap, fmt);
+       vsnprintf(buf, sizeof(buf), fmt, ap);
+       buf[sizeof(buf) - 1] = '\0';
+       va_end(ap);
+       p2p->cfg->debug_print(p2p->cfg->cb_ctx, MSG_DEBUG, buf);
+}
+
+
+void p2p_info(struct p2p_data *p2p, const char *fmt, ...)
+{
+       va_list ap;
+       char buf[500];
+
+       if (!p2p->cfg->debug_print)
+               return;
+
+       va_start(ap, fmt);
+       vsnprintf(buf, sizeof(buf), fmt, ap);
+       buf[sizeof(buf) - 1] = '\0';
+       va_end(ap);
+       p2p->cfg->debug_print(p2p->cfg->cb_ctx, MSG_INFO, buf);
+}
+
+
+void p2p_err(struct p2p_data *p2p, const char *fmt, ...)
+{
+       va_list ap;
+       char buf[500];
+
+       if (!p2p->cfg->debug_print)
+               return;
+
+       va_start(ap, fmt);
+       vsnprintf(buf, sizeof(buf), fmt, ap);
+       buf[sizeof(buf) - 1] = '\0';
+       va_end(ap);
+       p2p->cfg->debug_print(p2p->cfg->cb_ctx, MSG_ERROR, buf);
+}
index 2673bfdaaad778b90b85dacd88f5d7564a4676da..fc48e6b8ccb32ef949918615be2b6e99a6d5665d 100644 (file)
@@ -371,14 +371,17 @@ struct p2p_config {
        unsigned int max_listen;
 
        /**
-        * msg_ctx - Context to use with wpa_msg() calls
+        * cb_ctx - Context to use with callback functions
         */
-       void *msg_ctx;
+       void *cb_ctx;
 
        /**
-        * cb_ctx - Context to use with callback functions
+        * debug_print - Debug print
+        * @ctx: Callback context from cb_ctx
+        * @level: Debug verbosity level (MSG_*)
+        * @msg: Debug message
         */
-       void *cb_ctx;
+       void (*debug_print)(void *ctx, int level, const char *msg);
 
 
        /* Callbacks to request lower layer driver operations */
index c976b7c6d62b29e1ed673964eb201f92931fa282..76d01cfc6147391b0160fe90ccb30edf29bebfa0 100644 (file)
@@ -42,8 +42,7 @@ static struct wpabuf * p2p_build_dev_disc_req(struct p2p_data *p2p,
 
 void p2p_dev_disc_req_cb(struct p2p_data *p2p, int success)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Device Discoverability Request TX callback: success=%d",
+       p2p_dbg(p2p, "Device Discoverability Request TX callback: success=%d",
                success);
 
        if (!success) {
@@ -56,9 +55,7 @@ void p2p_dev_disc_req_cb(struct p2p_data *p2p, int success)
                return;
        }
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: GO acknowledged Device Discoverability Request - wait "
-               "for response");
+       p2p_dbg(p2p, "GO acknowledged Device Discoverability Request - wait for response");
        /*
         * TODO: is the remain-on-channel from Action frame TX long enough for
         * most cases or should we try to increase its duration and/or start
@@ -74,9 +71,7 @@ int p2p_send_dev_disc_req(struct p2p_data *p2p, struct p2p_device *dev)
 
        go = p2p_get_device(p2p, dev->member_in_go_dev);
        if (go == NULL || dev->oper_freq <= 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Could not find peer entry for GO and frequency "
-                       "to send Device Discoverability Request");
+               p2p_dbg(p2p, "Could not find peer entry for GO and frequency to send Device Discoverability Request");
                return -1;
        }
 
@@ -84,8 +79,7 @@ int p2p_send_dev_disc_req(struct p2p_data *p2p, struct p2p_device *dev)
        if (req == NULL)
                return -1;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Sending Device Discoverability Request to GO " MACSTR
+       p2p_dbg(p2p, "Sending Device Discoverability Request to GO " MACSTR
                " for client " MACSTR,
                MAC2STR(go->info.p2p_device_addr),
                MAC2STR(dev->info.p2p_device_addr));
@@ -97,8 +91,7 @@ int p2p_send_dev_disc_req(struct p2p_data *p2p, struct p2p_device *dev)
        if (p2p_send_action(p2p, dev->oper_freq, go->info.p2p_device_addr,
                            p2p->cfg->dev_addr, go->info.p2p_device_addr,
                            wpabuf_head(req), wpabuf_len(req), 1000) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
                wpabuf_free(req);
                /* TODO: how to recover from failure? */
                return -1;
@@ -131,8 +124,7 @@ static struct wpabuf * p2p_build_dev_disc_resp(u8 dialog_token, u8 status)
 
 void p2p_dev_disc_resp_cb(struct p2p_data *p2p, int success)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Device Discoverability Response TX callback: success=%d",
+       p2p_dbg(p2p, "Device Discoverability Response TX callback: success=%d",
                success);
        p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
 }
@@ -147,8 +139,7 @@ static void p2p_send_dev_disc_resp(struct p2p_data *p2p, u8 dialog_token,
        if (resp == NULL)
                return;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Sending Device Discoverability Response to " MACSTR
+       p2p_dbg(p2p, "Sending Device Discoverability Response to " MACSTR
                " (status %u freq %d)",
                MAC2STR(addr), status, freq);
 
@@ -156,8 +147,7 @@ static void p2p_send_dev_disc_resp(struct p2p_data *p2p, u8 dialog_token,
        if (p2p_send_action(p2p, freq, addr, p2p->cfg->dev_addr,
                            p2p->cfg->dev_addr,
                            wpabuf_head(resp), wpabuf_len(resp), 200) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
        }
 
        wpabuf_free(resp);
@@ -170,17 +160,14 @@ void p2p_process_dev_disc_req(struct p2p_data *p2p, const u8 *sa,
        struct p2p_message msg;
        size_t g;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Received Device Discoverability Request from " MACSTR
+       p2p_dbg(p2p, "Received Device Discoverability Request from " MACSTR
                " (freq=%d)", MAC2STR(sa), rx_freq);
 
        if (p2p_parse(data, len, &msg))
                return;
 
        if (msg.dialog_token == 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Invalid Dialog Token 0 (must be nonzero) in "
-                       "Device Discoverability Request");
+               p2p_dbg(p2p, "Invalid Dialog Token 0 (must be nonzero) in Device Discoverability Request");
                p2p_send_dev_disc_resp(p2p, msg.dialog_token, sa, rx_freq,
                                       P2P_SC_FAIL_INVALID_PARAMS);
                p2p_parse_free(&msg);
@@ -188,9 +175,7 @@ void p2p_process_dev_disc_req(struct p2p_data *p2p, const u8 *sa,
        }
 
        if (msg.device_id == NULL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: P2P Device ID attribute missing from Device "
-                       "Discoverability Request");
+               p2p_dbg(p2p, "P2P Device ID attribute missing from Device Discoverability Request");
                p2p_send_dev_disc_resp(p2p, msg.dialog_token, sa, rx_freq,
                                       P2P_SC_FAIL_INVALID_PARAMS);
                p2p_parse_free(&msg);
@@ -200,9 +185,7 @@ void p2p_process_dev_disc_req(struct p2p_data *p2p, const u8 *sa,
        for (g = 0; g < p2p->num_groups; g++) {
                if (p2p_group_go_discover(p2p->groups[g], msg.device_id, sa,
                                          rx_freq) == 0) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Scheduled "
-                               "GO Discoverability Request for the target "
-                               "device");
+                       p2p_dbg(p2p, "Scheduled GO Discoverability Request for the target device");
                        /*
                         * P2P group code will use a callback to indicate TX
                         * status, so that we can reply to the request once the
@@ -217,9 +200,7 @@ void p2p_process_dev_disc_req(struct p2p_data *p2p, const u8 *sa,
                }
        }
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Requested client "
-               "was not found in any group or did not support client "
-               "discoverability");
+       p2p_dbg(p2p, "Requested client was not found in any group or did not support client discoverability");
        p2p_send_dev_disc_resp(p2p, msg.dialog_token, sa, rx_freq,
                               P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE);
        p2p_parse_free(&msg);
@@ -233,15 +214,13 @@ void p2p_process_dev_disc_resp(struct p2p_data *p2p, const u8 *sa,
        struct p2p_device *go;
        u8 status;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Received Device Discoverability Response from " MACSTR,
+       p2p_dbg(p2p, "Received Device Discoverability Response from " MACSTR,
                MAC2STR(sa));
 
        go = p2p->pending_client_disc_go;
        if (go == NULL ||
            os_memcmp(sa, go->info.p2p_device_addr, ETH_ALEN) != 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Ignore unexpected "
-                       "Device Discoverability Response");
+               p2p_dbg(p2p, "Ignore unexpected Device Discoverability Response");
                return;
        }
 
@@ -254,9 +233,7 @@ void p2p_process_dev_disc_resp(struct p2p_data *p2p, const u8 *sa,
        }
 
        if (msg.dialog_token != go->dialog_token) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Ignore Device "
-                       "Discoverability Response with unexpected dialog "
-                       "token %u (expected %u)",
+               p2p_dbg(p2p, "Ignore Device Discoverability Response with unexpected dialog token %u (expected %u)",
                        msg.dialog_token, go->dialog_token);
                p2p_parse_free(&msg);
                return;
@@ -265,17 +242,14 @@ void p2p_process_dev_disc_resp(struct p2p_data *p2p, const u8 *sa,
        status = *msg.status;
        p2p_parse_free(&msg);
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Device Discoverability Response status %u", status);
+       p2p_dbg(p2p, "Device Discoverability Response status %u", status);
 
        if (p2p->go_neg_peer == NULL ||
            os_memcmp(p2p->pending_client_disc_addr,
                      p2p->go_neg_peer->info.p2p_device_addr, ETH_ALEN) != 0 ||
            os_memcmp(p2p->go_neg_peer->member_in_go_dev,
                      go->info.p2p_device_addr, ETH_ALEN) != 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No pending "
-                       "operation with the client discoverability peer "
-                       "anymore");
+               p2p_dbg(p2p, "No pending operation with the client discoverability peer anymore");
                return;
        }
 
@@ -284,8 +258,7 @@ void p2p_process_dev_disc_resp(struct p2p_data *p2p, const u8 *sa,
                 * Peer is expected to be awake for at least 100 TU; try to
                 * connect immediately.
                 */
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Client discoverability request succeeded");
+               p2p_dbg(p2p, "Client discoverability request succeeded");
                if (p2p->state == P2P_CONNECT) {
                        /*
                         * Change state to force the timeout to start in
@@ -301,8 +274,7 @@ void p2p_process_dev_disc_resp(struct p2p_data *p2p, const u8 *sa,
                 * Client discoverability request failed; try to connect from
                 * timeout.
                 */
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Client discoverability request failed");
+               p2p_dbg(p2p, "Client discoverability request failed");
                p2p_set_timeout(p2p, 0, 500000);
        }
 
@@ -311,14 +283,12 @@ void p2p_process_dev_disc_resp(struct p2p_data *p2p, const u8 *sa,
 
 void p2p_go_disc_req_cb(struct p2p_data *p2p, int success)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: GO Discoverability Request TX callback: success=%d",
+       p2p_dbg(p2p, "GO Discoverability Request TX callback: success=%d",
                success);
        p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
 
        if (p2p->pending_dev_disc_dialog_token == 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No pending Device "
-                       "Discoverability Request");
+               p2p_dbg(p2p, "No pending Device Discoverability Request");
                return;
        }
 
@@ -338,9 +308,7 @@ void p2p_process_go_disc_req(struct p2p_data *p2p, const u8 *da, const u8 *sa,
        unsigned int tu;
        struct wpabuf *ies;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Received GO Discoverability Request - remain awake for "
-               "100 TU");
+       p2p_dbg(p2p, "Received GO Discoverability Request - remain awake for 100 TU");
 
        ies = p2p_build_probe_resp_ies(p2p);
        if (ies == NULL)
@@ -351,9 +319,7 @@ void p2p_process_go_disc_req(struct p2p_data *p2p, const u8 *da, const u8 *sa,
        tu = 100;
        if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, rx_freq, 1024 * tu / 1000,
                    ies) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to start listen mode for client "
-                       "discoverability");
+               p2p_dbg(p2p, "Failed to start listen mode for client discoverability");
        }
        wpabuf_free(ies);
 }
index aef0dfa13f44e686ca7af90336933a4f13758211..861d8fcf61549cf9f24f7c8b7f977a6573ad4420 100644 (file)
@@ -49,8 +49,7 @@ int p2p_peer_channels_check(struct p2p_data *p2p, struct p2p_channels *own,
        os_memcpy(dev->country, pos, 3);
        wpa_hexdump_ascii(MSG_DEBUG, "P2P: Peer country", pos, 3);
        if (pos[2] != 0x04 && os_memcmp(pos, p2p->cfg->country, 2) != 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_INFO,
-                       "P2P: Mismatching country (ours=%c%c peer's=%c%c)",
+               p2p_info(p2p, "Mismatching country (ours=%c%c peer's=%c%c)",
                        p2p->cfg->country[0], p2p->cfg->country[1],
                        pos[0], pos[1]);
                return -1;
@@ -61,8 +60,7 @@ int p2p_peer_channels_check(struct p2p_data *p2p, struct p2p_channels *own,
                struct p2p_reg_class *cl = &ch->reg_class[ch->reg_classes];
                cl->reg_class = *pos++;
                if (pos + 1 + pos[0] > end) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_INFO,
-                               "P2P: Invalid peer Channel List");
+                       p2p_info(p2p, "Invalid peer Channel List");
                        return -1;
                }
                channels = *pos++;
@@ -76,14 +74,12 @@ int p2p_peer_channels_check(struct p2p_data *p2p, struct p2p_channels *own,
        }
 
        p2p_channels_intersect(own, &dev->channels, &intersection);
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Own reg_classes %d "
-               "peer reg_classes %d intersection reg_classes %d",
+       p2p_dbg(p2p, "Own reg_classes %d peer reg_classes %d intersection reg_classes %d",
                (int) own->reg_classes,
                (int) dev->channels.reg_classes,
                (int) intersection.reg_classes);
        if (intersection.reg_classes == 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_INFO,
-                       "P2P: No common channels found");
+               p2p_info(p2p, "No common channels found");
                return -1;
        }
        return 0;
@@ -194,8 +190,7 @@ int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev)
 
        if (dev->flags & P2P_DEV_PD_BEFORE_GO_NEG) {
                u16 config_method;
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Use PD-before-GO-Neg workaround for " MACSTR,
+               p2p_dbg(p2p, "Use PD-before-GO-Neg workaround for " MACSTR,
                        MAC2STR(dev->info.p2p_device_addr));
                if (dev->wps_method == WPS_PIN_DISPLAY)
                        config_method = WPS_CONFIG_KEYPAD;
@@ -211,9 +206,8 @@ int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev)
 
        freq = dev->listen_freq > 0 ? dev->listen_freq : dev->oper_freq;
        if (freq <= 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No Listen/Operating frequency known for the "
-                       "peer " MACSTR " to send GO Negotiation Request",
+               p2p_dbg(p2p, "No Listen/Operating frequency known for the peer "
+                       MACSTR " to send GO Negotiation Request",
                        MAC2STR(dev->info.p2p_device_addr));
                return -1;
        }
@@ -221,8 +215,7 @@ int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev)
        req = p2p_build_go_neg_req(p2p, dev);
        if (req == NULL)
                return -1;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Sending GO Negotiation Request");
+       p2p_dbg(p2p, "Sending GO Negotiation Request");
        p2p_set_state(p2p, P2P_CONNECT);
        p2p->pending_action_state = P2P_PENDING_GO_NEG_REQUEST;
        p2p->go_neg_peer = dev;
@@ -231,8 +224,7 @@ int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev)
        if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
                            p2p->cfg->dev_addr, dev->info.p2p_device_addr,
                            wpabuf_head(req), wpabuf_len(req), 500) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
                /* Use P2P find to recover and retry */
                p2p_set_timeout(p2p, 0, 0);
        } else
@@ -254,8 +246,7 @@ static struct wpabuf * p2p_build_go_neg_resp(struct p2p_data *p2p,
        u8 group_capab;
        size_t extra = 0;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Building GO Negotiation Response");
+       p2p_dbg(p2p, "Building GO Negotiation Response");
 
 #ifdef CONFIG_WIFI_DISPLAY
        if (p2p->wfd_ie_go_neg)
@@ -289,8 +280,7 @@ static struct wpabuf * p2p_build_go_neg_resp(struct p2p_data *p2p,
        p2p_buf_add_go_intent(buf, (p2p->go_intent << 1) | tie_breaker);
        p2p_buf_add_config_timeout(buf, p2p->go_timeout, p2p->client_timeout);
        if (peer && peer->go_state == REMOTE_GO) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Omit Operating "
-                       "Channel attribute");
+               p2p_dbg(p2p, "Omit Operating Channel attribute");
        } else {
                p2p_buf_add_operating_channel(buf, p2p->cfg->country,
                                              p2p->op_reg_class,
@@ -354,9 +344,8 @@ void p2p_reselect_channel(struct p2p_data *p2p,
            p2p_freq_to_channel(p2p->own_freq_preference,
                                &op_reg_class, &op_channel) == 0 &&
            p2p_channels_includes(intersection, op_reg_class, op_channel)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Pick own channel "
-                       "preference (reg_class %u channel %u) from "
-                       "intersection", op_reg_class, op_channel);
+               p2p_dbg(p2p, "Pick own channel preference (reg_class %u channel %u) from intersection",
+                       op_reg_class, op_channel);
                p2p->op_reg_class = op_reg_class;
                p2p->op_channel = op_channel;
                return;
@@ -366,8 +355,7 @@ void p2p_reselect_channel(struct p2p_data *p2p,
            p2p_freq_to_channel(p2p->best_freq_overall,
                                &op_reg_class, &op_channel) == 0 &&
            p2p_channels_includes(intersection, op_reg_class, op_channel)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Pick best overall "
-                       "channel (reg_class %u channel %u) from intersection",
+               p2p_dbg(p2p, "Pick best overall channel (reg_class %u channel %u) from intersection",
                        op_reg_class, op_channel);
                p2p->op_reg_class = op_reg_class;
                p2p->op_channel = op_channel;
@@ -382,8 +370,7 @@ void p2p_reselect_channel(struct p2p_data *p2p,
            p2p_freq_to_channel(p2p->best_freq_5,
                                &op_reg_class, &op_channel) == 0 &&
            p2p_channels_includes(intersection, op_reg_class, op_channel)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Pick best 5 GHz "
-                       "channel (reg_class %u channel %u) from intersection",
+               p2p_dbg(p2p, "Pick best 5 GHz channel (reg_class %u channel %u) from intersection",
                        op_reg_class, op_channel);
                p2p->op_reg_class = op_reg_class;
                p2p->op_channel = op_channel;
@@ -396,8 +383,7 @@ void p2p_reselect_channel(struct p2p_data *p2p,
            p2p_freq_to_channel(p2p->best_freq_24,
                                &op_reg_class, &op_channel) == 0 &&
            p2p_channels_includes(intersection, op_reg_class, op_channel)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Pick best 2.4 GHz "
-                       "channel (reg_class %u channel %u) from intersection",
+               p2p_dbg(p2p, "Pick best 2.4 GHz channel (reg_class %u channel %u) from intersection",
                        op_reg_class, op_channel);
                p2p->op_reg_class = op_reg_class;
                p2p->op_channel = op_channel;
@@ -411,9 +397,7 @@ void p2p_reselect_channel(struct p2p_data *p2p,
                                          p2p->cfg->pref_chan[i].chan)) {
                        p2p->op_reg_class = p2p->cfg->pref_chan[i].op_class;
                        p2p->op_channel = p2p->cfg->pref_chan[i].chan;
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Pick "
-                               "highest preferred chnnel (op_class %u "
-                               "channel %u) from intersection",
+                       p2p_dbg(p2p, "Pick highest preferred channel (op_class %u channel %u) from intersection",
                                p2p->op_reg_class, p2p->op_channel);
                        return;
                }
@@ -424,9 +408,7 @@ void p2p_reselect_channel(struct p2p_data *p2p,
                struct p2p_reg_class *c = &intersection->reg_class[i];
                if (c->reg_class == 116 || c->reg_class == 117 ||
                    c->reg_class == 126 || c->reg_class == 127) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Pick possible HT40 channel (reg_class "
-                               "%u channel %u) from intersection",
+                       p2p_dbg(p2p, "Pick possible HT40 channel (reg_class %u channel %u) from intersection",
                                c->reg_class, c->channel[0]);
                        p2p->op_reg_class = c->reg_class;
                        p2p->op_channel = c->channel[0];
@@ -441,9 +423,7 @@ void p2p_reselect_channel(struct p2p_data *p2p,
         */
        if (p2p_channels_includes(intersection, p2p->op_reg_class,
                                  p2p->op_channel)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Using original operating class and channel "
-                       "(op_class %u channel %u) from intersection",
+               p2p_dbg(p2p, "Using original operating class and channel (op_class %u channel %u) from intersection",
                        p2p->op_reg_class, p2p->op_channel);
                return;
        }
@@ -453,8 +433,7 @@ void p2p_reselect_channel(struct p2p_data *p2p,
         * no better options seems to be available.
         */
        cl = &intersection->reg_class[0];
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Pick another channel "
-               "(reg_class %u channel %u) from intersection",
+       p2p_dbg(p2p, "Pick another channel (reg_class %u channel %u) from intersection",
                cl->reg_class, cl->channel[0]);
        p2p->op_reg_class = cl->reg_class;
        p2p->op_channel = cl->channel[0];
@@ -471,15 +450,14 @@ static int p2p_go_select_channel(struct p2p_data *p2p, struct p2p_device *dev,
        if (intersection.reg_classes == 0 ||
            intersection.reg_class[0].channels == 0) {
                *status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No common channels found");
+               p2p_dbg(p2p, "No common channels found");
                return -1;
        }
 
        for (i = 0; i < intersection.reg_classes; i++) {
                struct p2p_reg_class *c;
                c = &intersection.reg_class[i];
-               wpa_printf(MSG_DEBUG, "P2P: reg_class %u", c->reg_class);
+               p2p_dbg(p2p, "reg_class %u", c->reg_class);
                wpa_hexdump(MSG_DEBUG, "P2P: channels",
                            c->channel, c->channels);
        }
@@ -488,20 +466,16 @@ static int p2p_go_select_channel(struct p2p_data *p2p, struct p2p_device *dev,
                                   p2p->op_channel)) {
                if (dev->flags & P2P_DEV_FORCE_FREQ) {
                        *status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer does "
-                               "not support the forced channel");
+                       p2p_dbg(p2p, "Peer does not support the forced channel");
                        return -1;
                }
 
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Selected operating "
-                       "channel (op_class %u channel %u) not acceptable to "
-                       "the peer", p2p->op_reg_class, p2p->op_channel);
+               p2p_dbg(p2p, "Selected operating channel (op_class %u channel %u) not acceptable to the peer",
+                       p2p->op_reg_class, p2p->op_channel);
                p2p_reselect_channel(p2p, &intersection);
        } else if (!(dev->flags & P2P_DEV_FORCE_FREQ) &&
                   !p2p->cfg->cfg_op_channel) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Try to optimize "
-                       "channel selection with peer information received; "
-                       "previously selected op_class %u channel %u",
+               p2p_dbg(p2p, "Try to optimize channel selection with peer information received; previously selected op_class %u channel %u",
                        p2p->op_reg_class, p2p->op_channel);
                p2p_reselect_channel(p2p, &intersection);
        }
@@ -525,17 +499,14 @@ void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
        int tie_breaker = 0;
        int freq;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Received GO Negotiation Request from " MACSTR
-               "(freq=%d)", MAC2STR(sa), rx_freq);
+       p2p_dbg(p2p, "Received GO Negotiation Request from " MACSTR "(freq=%d)",
+               MAC2STR(sa), rx_freq);
 
        if (p2p_parse(data, len, &msg))
                return;
 
        if (!msg.capability) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Mandatory Capability attribute missing from GO "
-                       "Negotiation Request");
+               p2p_dbg(p2p, "Mandatory Capability attribute missing from GO Negotiation Request");
 #ifdef CONFIG_P2P_STRICT
                goto fail;
 #endif /* CONFIG_P2P_STRICT */
@@ -544,53 +515,42 @@ void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
        if (msg.go_intent)
                tie_breaker = *msg.go_intent & 0x01;
        else {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Mandatory GO Intent attribute missing from GO "
-                       "Negotiation Request");
+               p2p_dbg(p2p, "Mandatory GO Intent attribute missing from GO Negotiation Request");
 #ifdef CONFIG_P2P_STRICT
                goto fail;
 #endif /* CONFIG_P2P_STRICT */
        }
 
        if (!msg.config_timeout) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Mandatory Configuration Timeout attribute "
-                       "missing from GO Negotiation Request");
+               p2p_dbg(p2p, "Mandatory Configuration Timeout attribute missing from GO Negotiation Request");
 #ifdef CONFIG_P2P_STRICT
                goto fail;
 #endif /* CONFIG_P2P_STRICT */
        }
 
        if (!msg.listen_channel) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No Listen Channel attribute received");
+               p2p_dbg(p2p, "No Listen Channel attribute received");
                goto fail;
        }
        if (!msg.operating_channel) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No Operating Channel attribute received");
+               p2p_dbg(p2p, "No Operating Channel attribute received");
                goto fail;
        }
        if (!msg.channel_list) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No Channel List attribute received");
+               p2p_dbg(p2p, "No Channel List attribute received");
                goto fail;
        }
        if (!msg.intended_addr) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No Intended P2P Interface Address attribute "
-                       "received");
+               p2p_dbg(p2p, "No Intended P2P Interface Address attribute received");
                goto fail;
        }
        if (!msg.p2p_device_info) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No P2P Device Info attribute received");
+               p2p_dbg(p2p, "No P2P Device Info attribute received");
                goto fail;
        }
 
        if (os_memcmp(msg.p2p_device_addr, sa, ETH_ALEN) != 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unexpected GO Negotiation Request SA=" MACSTR
+               p2p_dbg(p2p, "Unexpected GO Negotiation Request SA=" MACSTR
                        " != dev_addr=" MACSTR,
                        MAC2STR(sa), MAC2STR(msg.p2p_device_addr));
                goto fail;
@@ -599,9 +559,8 @@ void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
        dev = p2p_get_device(p2p, sa);
 
        if (msg.status && *msg.status) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unexpected Status attribute (%d) in GO "
-                       "Negotiation Request", *msg.status);
+               p2p_dbg(p2p, "Unexpected Status attribute (%d) in GO Negotiation Request",
+                       *msg.status);
                goto fail;
        }
 
@@ -610,120 +569,96 @@ void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
        else if (dev->flags & P2P_DEV_PROBE_REQ_ONLY)
                p2p_add_dev_info(p2p, sa, dev, &msg);
        if (dev && dev->flags & P2P_DEV_USER_REJECTED) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: User has rejected this peer");
+               p2p_dbg(p2p, "User has rejected this peer");
                status = P2P_SC_FAIL_REJECTED_BY_USER;
        } else if (dev == NULL || dev->wps_method == WPS_NOT_READY) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Not ready for GO negotiation with " MACSTR,
+               p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
                        MAC2STR(sa));
                status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
                p2p->cfg->go_neg_req_rx(p2p->cfg->cb_ctx, sa,
                                        msg.dev_password_id);
        } else if (p2p->go_neg_peer && p2p->go_neg_peer != dev) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Already in Group Formation with another peer");
+               p2p_dbg(p2p, "Already in Group Formation with another peer");
                status = P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE;
        } else {
                int go;
 
                if (!p2p->go_neg_peer) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Starting "
-                               "GO Negotiation with previously authorized "
-                               "peer");
+                       p2p_dbg(p2p, "Starting GO Negotiation with previously authorized peer");
                        if (!(dev->flags & P2P_DEV_FORCE_FREQ)) {
-                               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                                       "P2P: Use default channel settings");
+                               p2p_dbg(p2p, "Use default channel settings");
                                p2p->op_reg_class = p2p->cfg->op_reg_class;
                                p2p->op_channel = p2p->cfg->op_channel;
                                os_memcpy(&p2p->channels, &p2p->cfg->channels,
                                          sizeof(struct p2p_channels));
                        } else {
-                               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                                       "P2P: Use previously configured "
-                                       "forced channel settings");
+                               p2p_dbg(p2p, "Use previously configured forced channel settings");
                        }
                }
 
                dev->flags &= ~P2P_DEV_NOT_YET_READY;
 
                if (!msg.go_intent) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: No GO Intent attribute received");
+                       p2p_dbg(p2p, "No GO Intent attribute received");
                        goto fail;
                }
                if ((*msg.go_intent >> 1) > P2P_MAX_GO_INTENT) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Invalid GO Intent value (%u) received",
+                       p2p_dbg(p2p, "Invalid GO Intent value (%u) received",
                                *msg.go_intent >> 1);
                        goto fail;
                }
 
                if (dev->go_neg_req_sent &&
                    os_memcmp(sa, p2p->cfg->dev_addr, ETH_ALEN) > 0) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Do not reply since peer has higher "
-                               "address and GO Neg Request already sent");
+                       p2p_dbg(p2p, "Do not reply since peer has higher address and GO Neg Request already sent");
                        p2p_parse_free(&msg);
                        return;
                }
 
                go = p2p_go_det(p2p->go_intent, *msg.go_intent);
                if (go < 0) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Incompatible GO Intent");
+                       p2p_dbg(p2p, "Incompatible GO Intent");
                        status = P2P_SC_FAIL_BOTH_GO_INTENT_15;
                        goto fail;
                }
 
                if (p2p_peer_channels(p2p, dev, msg.channel_list,
                                      msg.channel_list_len) < 0) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: No common channels found");
+                       p2p_dbg(p2p, "No common channels found");
                        status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
                        goto fail;
                }
 
                switch (msg.dev_password_id) {
                case DEV_PW_REGISTRAR_SPECIFIED:
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: PIN from peer Display");
+                       p2p_dbg(p2p, "PIN from peer Display");
                        if (dev->wps_method != WPS_PIN_KEYPAD) {
-                               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                                       "P2P: We have wps_method=%s -> "
-                                       "incompatible",
+                               p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
                                        p2p_wps_method_str(dev->wps_method));
                                status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
                                goto fail;
                        }
                        break;
                case DEV_PW_USER_SPECIFIED:
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Peer entered PIN on Keypad");
+                       p2p_dbg(p2p, "Peer entered PIN on Keypad");
                        if (dev->wps_method != WPS_PIN_DISPLAY) {
-                               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                                       "P2P: We have wps_method=%s -> "
-                                       "incompatible",
+                               p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
                                        p2p_wps_method_str(dev->wps_method));
                                status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
                                goto fail;
                        }
                        break;
                case DEV_PW_PUSHBUTTON:
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Peer using pushbutton");
+                       p2p_dbg(p2p, "Peer using pushbutton");
                        if (dev->wps_method != WPS_PBC) {
-                               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                                       "P2P: We have wps_method=%s -> "
-                                       "incompatible",
+                               p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
                                        p2p_wps_method_str(dev->wps_method));
                                status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
                                goto fail;
                        }
                        break;
                default:
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Unsupported Device Password ID %d",
+                       p2p_dbg(p2p, "Unsupported Device Password ID %d",
                                msg.dev_password_id);
                        status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
                        goto fail;
@@ -735,16 +670,15 @@ void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
                dev->go_state = go ? LOCAL_GO : REMOTE_GO;
                dev->oper_freq = p2p_channel_to_freq(msg.operating_channel[3],
                                                     msg.operating_channel[4]);
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer operating "
-                       "channel preference: %d MHz", dev->oper_freq);
+               p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
+                       dev->oper_freq);
 
                if (msg.config_timeout) {
                        dev->go_timeout = msg.config_timeout[0];
                        dev->client_timeout = msg.config_timeout[1];
                }
 
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: GO Negotiation with " MACSTR, MAC2STR(sa));
+               p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa));
                if (p2p->state != P2P_IDLE)
                        p2p_stop_find_for_freq(p2p, rx_freq);
                p2p_set_state(p2p, P2P_GO_NEG);
@@ -763,16 +697,14 @@ fail:
        p2p_parse_free(&msg);
        if (resp == NULL)
                return;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Sending GO Negotiation Response");
+       p2p_dbg(p2p, "Sending GO Negotiation Response");
        if (rx_freq > 0)
                freq = rx_freq;
        else
                freq = p2p_channel_to_freq(p2p->cfg->reg_class,
                                           p2p->cfg->channel);
        if (freq < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unknown regulatory class/channel");
+               p2p_dbg(p2p, "Unknown regulatory class/channel");
                wpabuf_free(resp);
                return;
        }
@@ -796,8 +728,7 @@ fail:
        if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
                            p2p->cfg->dev_addr,
                            wpabuf_head(resp), wpabuf_len(resp), 500) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
        }
 
        wpabuf_free(resp);
@@ -815,8 +746,7 @@ static struct wpabuf * p2p_build_go_neg_conf(struct p2p_data *p2p,
        u8 group_capab;
        size_t extra = 0;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Building GO Negotiation Confirm");
+       p2p_dbg(p2p, "Building GO Negotiation Confirm");
 
 #ifdef CONFIG_WIFI_DISPLAY
        if (p2p->wfd_ie_go_neg)
@@ -881,14 +811,12 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
        u8 status = P2P_SC_SUCCESS;
        int freq;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Received GO Negotiation Response from " MACSTR
+       p2p_dbg(p2p, "Received GO Negotiation Response from " MACSTR
                " (freq=%d)", MAC2STR(sa), rx_freq);
        dev = p2p_get_device(p2p, sa);
        if (dev == NULL || dev->wps_method == WPS_NOT_READY ||
            dev != p2p->go_neg_peer) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Not ready for GO negotiation with " MACSTR,
+               p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
                        MAC2STR(sa));
                return;
        }
@@ -897,44 +825,35 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
                return;
 
        if (!(dev->flags & P2P_DEV_WAIT_GO_NEG_RESPONSE)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Was not expecting GO Negotiation Response - "
-                       "ignore");
+               p2p_dbg(p2p, "Was not expecting GO Negotiation Response - ignore");
                p2p_parse_free(&msg);
                return;
        }
        dev->flags &= ~P2P_DEV_WAIT_GO_NEG_RESPONSE;
 
        if (msg.dialog_token != dev->dialog_token) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unexpected Dialog Token %u (expected %u)",
+               p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)",
                        msg.dialog_token, dev->dialog_token);
                p2p_parse_free(&msg);
                return;
        }
 
        if (!msg.status) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No Status attribute received");
+               p2p_dbg(p2p, "No Status attribute received");
                status = P2P_SC_FAIL_INVALID_PARAMS;
                goto fail;
        }
        if (*msg.status) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: GO Negotiation rejected: status %d",
-                       *msg.status);
+               p2p_dbg(p2p, "GO Negotiation rejected: status %d", *msg.status);
                dev->go_neg_req_sent = 0;
                if (*msg.status == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Wait for the peer to become ready for "
-                               "GO Negotiation");
+                       p2p_dbg(p2p, "Wait for the peer to become ready for GO Negotiation");
                        dev->flags |= P2P_DEV_NOT_YET_READY;
                        dev->wait_count = 0;
                        p2p_set_state(p2p, P2P_WAIT_PEER_IDLE);
                        p2p_set_timeout(p2p, 0, 0);
                } else {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Stop GO Negotiation attempt");
+                       p2p_dbg(p2p, "Stop GO Negotiation attempt");
                        p2p_go_neg_failed(p2p, dev, *msg.status);
                }
                p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
@@ -943,9 +862,7 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
        }
 
        if (!msg.capability) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Mandatory Capability attribute missing from GO "
-                       "Negotiation Response");
+               p2p_dbg(p2p, "Mandatory Capability attribute missing from GO Negotiation Response");
 #ifdef CONFIG_P2P_STRICT
                status = P2P_SC_FAIL_INVALID_PARAMS;
                goto fail;
@@ -953,9 +870,7 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
        }
 
        if (!msg.p2p_device_info) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Mandatory P2P Device Info attribute missing "
-                       "from GO Negotiation Response");
+               p2p_dbg(p2p, "Mandatory P2P Device Info attribute missing from GO Negotiation Response");
 #ifdef CONFIG_P2P_STRICT
                status = P2P_SC_FAIL_INVALID_PARAMS;
                goto fail;
@@ -963,22 +878,18 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
        }
 
        if (!msg.intended_addr) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No Intended P2P Interface Address attribute "
-                       "received");
+               p2p_dbg(p2p, "No Intended P2P Interface Address attribute received");
                status = P2P_SC_FAIL_INVALID_PARAMS;
                goto fail;
        }
 
        if (!msg.go_intent) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No GO Intent attribute received");
+               p2p_dbg(p2p, "No GO Intent attribute received");
                status = P2P_SC_FAIL_INVALID_PARAMS;
                goto fail;
        }
        if ((*msg.go_intent >> 1) > P2P_MAX_GO_INTENT) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Invalid GO Intent value (%u) received",
+               p2p_dbg(p2p, "Invalid GO Intent value (%u) received",
                        *msg.go_intent >> 1);
                status = P2P_SC_FAIL_INVALID_PARAMS;
                goto fail;
@@ -986,8 +897,7 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
 
        go = p2p_go_det(p2p->go_intent, *msg.go_intent);
        if (go < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Incompatible GO Intent");
+               p2p_dbg(p2p, "Incompatible GO Intent");
                status = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
                goto fail;
        }
@@ -997,18 +907,14 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
                p2p->ssid_len = msg.group_id_len - ETH_ALEN;
                os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len);
        } else if (!go) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Mandatory P2P Group ID attribute missing from "
-                       "GO Negotiation Response");
+               p2p_dbg(p2p, "Mandatory P2P Group ID attribute missing from GO Negotiation Response");
                p2p->ssid_len = 0;
                status = P2P_SC_FAIL_INVALID_PARAMS;
                goto fail;
        }
 
        if (!msg.config_timeout) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Mandatory Configuration Timeout attribute "
-                       "missing from GO Negotiation Response");
+               p2p_dbg(p2p, "Mandatory Configuration Timeout attribute missing from GO Negotiation Response");
 #ifdef CONFIG_P2P_STRICT
                status = P2P_SC_FAIL_INVALID_PARAMS;
                goto fail;
@@ -1023,22 +929,19 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
                 * Note: P2P Client may omit Operating Channel attribute to
                 * indicate it does not have a preference.
                 */
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No Operating Channel attribute received");
+               p2p_dbg(p2p, "No Operating Channel attribute received");
                status = P2P_SC_FAIL_INVALID_PARAMS;
                goto fail;
        }
        if (!msg.channel_list) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No Channel List attribute received");
+               p2p_dbg(p2p, "No Channel List attribute received");
                status = P2P_SC_FAIL_INVALID_PARAMS;
                goto fail;
        }
 
        if (p2p_peer_channels(p2p, dev, msg.channel_list,
                              msg.channel_list_len) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No common channels found");
+               p2p_dbg(p2p, "No common channels found");
                status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
                goto fail;
        }
@@ -1046,51 +949,41 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
        if (msg.operating_channel) {
                dev->oper_freq = p2p_channel_to_freq(msg.operating_channel[3],
                                                     msg.operating_channel[4]);
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer operating "
-                       "channel preference: %d MHz", dev->oper_freq);
+               p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
+                       dev->oper_freq);
        } else
                dev->oper_freq = 0;
 
        switch (msg.dev_password_id) {
        case DEV_PW_REGISTRAR_SPECIFIED:
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: PIN from peer Display");
+               p2p_dbg(p2p, "PIN from peer Display");
                if (dev->wps_method != WPS_PIN_KEYPAD) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: We have wps_method=%s -> "
-                               "incompatible",
+                       p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
                                p2p_wps_method_str(dev->wps_method));
                        status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
                        goto fail;
                }
                break;
        case DEV_PW_USER_SPECIFIED:
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Peer entered PIN on Keypad");
+               p2p_dbg(p2p, "Peer entered PIN on Keypad");
                if (dev->wps_method != WPS_PIN_DISPLAY) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: We have wps_method=%s -> "
-                               "incompatible",
+                       p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
                                p2p_wps_method_str(dev->wps_method));
                        status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
                        goto fail;
                }
                break;
        case DEV_PW_PUSHBUTTON:
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Peer using pushbutton");
+               p2p_dbg(p2p, "Peer using pushbutton");
                if (dev->wps_method != WPS_PBC) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: We have wps_method=%s -> "
-                               "incompatible",
+                       p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
                                p2p_wps_method_str(dev->wps_method));
                        status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
                        goto fail;
                }
                break;
        default:
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unsupported Device Password ID %d",
+               p2p_dbg(p2p, "Unsupported Device Password ID %d",
                        msg.dev_password_id);
                status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
                goto fail;
@@ -1102,8 +995,7 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
        p2p_set_state(p2p, P2P_GO_NEG);
        p2p_clear_timeout(p2p);
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: GO Negotiation with " MACSTR, MAC2STR(sa));
+       p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa));
        os_memcpy(dev->intended_addr, msg.intended_addr, ETH_ALEN);
 
 fail:
@@ -1112,8 +1004,7 @@ fail:
        p2p_parse_free(&msg);
        if (conf == NULL)
                return;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Sending GO Negotiation Confirm");
+       p2p_dbg(p2p, "Sending GO Negotiation Confirm");
        if (status == P2P_SC_SUCCESS) {
                p2p->pending_action_state = P2P_PENDING_GO_NEG_CONFIRM;
                dev->go_state = go ? LOCAL_GO : REMOTE_GO;
@@ -1125,14 +1016,12 @@ fail:
                freq = dev->listen_freq;
        if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr, sa,
                            wpabuf_head(conf), wpabuf_len(conf), 0) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
                p2p_go_neg_failed(p2p, dev, -1);
        }
        wpabuf_free(conf);
        if (status != P2P_SC_SUCCESS) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: GO Negotiation failed");
+               p2p_dbg(p2p, "GO Negotiation failed");
                p2p_go_neg_failed(p2p, dev, status);
        }
 }
@@ -1144,22 +1033,18 @@ void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
        struct p2p_device *dev;
        struct p2p_message msg;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Received GO Negotiation Confirm from " MACSTR,
+       p2p_dbg(p2p, "Received GO Negotiation Confirm from " MACSTR,
                MAC2STR(sa));
        dev = p2p_get_device(p2p, sa);
        if (dev == NULL || dev->wps_method == WPS_NOT_READY ||
            dev != p2p->go_neg_peer) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Not ready for GO negotiation with " MACSTR,
+               p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
                        MAC2STR(sa));
                return;
        }
 
        if (p2p->pending_action_state == P2P_PENDING_GO_NEG_RESPONSE) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Stopped waiting "
-                       "for TX status on GO Negotiation Response since we "
-                       "already received Confirmation");
+               p2p_dbg(p2p, "Stopped waiting for TX status on GO Negotiation Response since we already received Confirmation");
                p2p->pending_action_state = P2P_NO_PENDING_ACTION;
        }
 
@@ -1167,31 +1052,25 @@ void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
                return;
 
        if (!(dev->flags & P2P_DEV_WAIT_GO_NEG_CONFIRM)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Was not expecting GO Negotiation Confirm - "
-                       "ignore");
+               p2p_dbg(p2p, "Was not expecting GO Negotiation Confirm - ignore");
                return;
        }
        dev->flags &= ~P2P_DEV_WAIT_GO_NEG_CONFIRM;
 
        if (msg.dialog_token != dev->dialog_token) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unexpected Dialog Token %u (expected %u)",
+               p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)",
                        msg.dialog_token, dev->dialog_token);
                p2p_parse_free(&msg);
                return;
        }
 
        if (!msg.status) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No Status attribute received");
+               p2p_dbg(p2p, "No Status attribute received");
                p2p_parse_free(&msg);
                return;
        }
        if (*msg.status) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: GO Negotiation rejected: status %d",
-                       *msg.status);
+               p2p_dbg(p2p, "GO Negotiation rejected: status %d", *msg.status);
                p2p_go_neg_failed(p2p, dev, *msg.status);
                p2p_parse_free(&msg);
                return;
@@ -1202,9 +1081,7 @@ void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
                p2p->ssid_len = msg.group_id_len - ETH_ALEN;
                os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len);
        } else if (dev->go_state == REMOTE_GO) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Mandatory P2P Group ID attribute missing from "
-                       "GO Negotiation Confirmation");
+               p2p_dbg(p2p, "Mandatory P2P Group ID attribute missing from GO Negotiation Confirmation");
                p2p->ssid_len = 0;
                p2p_go_neg_failed(p2p, dev, P2P_SC_FAIL_INVALID_PARAMS);
                p2p_parse_free(&msg);
@@ -1212,9 +1089,7 @@ void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
        }
 
        if (!msg.operating_channel) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Mandatory Operating Channel attribute missing "
-                       "from GO Negotiation Confirmation");
+               p2p_dbg(p2p, "Mandatory Operating Channel attribute missing from GO Negotiation Confirmation");
 #ifdef CONFIG_P2P_STRICT
                p2p_parse_free(&msg);
                return;
@@ -1222,9 +1097,7 @@ void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
        }
 
        if (!msg.channel_list) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Mandatory Operating Channel attribute missing "
-                       "from GO Negotiation Confirmation");
+               p2p_dbg(p2p, "Mandatory Operating Channel attribute missing from GO Negotiation Confirmation");
 #ifdef CONFIG_P2P_STRICT
                p2p_parse_free(&msg);
                return;
@@ -1238,9 +1111,7 @@ void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
                 * This should not happen since GO negotiation has already
                 * been completed.
                 */
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unexpected GO Neg state - do not know which end "
-                       "becomes GO");
+               p2p_dbg(p2p, "Unexpected GO Neg state - do not know which end becomes GO");
                return;
        }
 
@@ -1252,8 +1123,7 @@ void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
         * the group so that we will remain on the current channel to
         * acknowledge any possible retransmission from the peer.
         */
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: 20 ms wait on current "
-               "channel before starting group");
+       p2p_dbg(p2p, "20 ms wait on current channel before starting group");
        os_sleep(0, 20000);
 
        p2p_go_complete(p2p, dev);
index 852ddf5fca5bf2fd53fd3ce3f7e5b1cba87a14e9..15e76226aafa9366bdc21a179d92960c50a2e2cd 100644 (file)
@@ -378,8 +378,8 @@ wifi_display_build_go_ie(struct p2p_group *group)
        } else {
                WPA_PUT_BE16(len, (u8 *) wpabuf_put(wfd_subelems, 0) - len -
                             2);
-               wpa_printf(MSG_DEBUG, "WFD: WFD Session Info: %u descriptors",
-                          count);
+               p2p_dbg(group->p2p, "WFD: WFD Session Info: %u descriptors",
+                       count);
        }
 
        wfd_ie = wifi_display_encaps(wfd_subelems);
@@ -588,7 +588,7 @@ int p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr,
        m->next = group->members;
        group->members = m;
        group->num_members++;
-       wpa_msg(group->p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Add client " MACSTR
+       p2p_dbg(group->p2p,  "Add client " MACSTR
                " to group (p2p=%d wfd=%d client_info=%d); num_members=%u/%u",
                MAC2STR(addr), m->p2p_ie ? 1 : 0, m->wfd_ie ? 1 : 0,
                m->client_info ? 1 : 0,
@@ -641,8 +641,8 @@ struct wpabuf * p2p_group_assoc_resp_ie(struct p2p_group *group, u8 status)
 void p2p_group_notif_disassoc(struct p2p_group *group, const u8 *addr)
 {
        if (p2p_group_remove_member(group, addr)) {
-               wpa_msg(group->p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Remove "
-                       "client " MACSTR " from group; num_members=%u/%u",
+               p2p_dbg(group->p2p, "Remove client " MACSTR
+                       " from group; num_members=%u/%u",
                        MAC2STR(addr), group->num_members,
                        group->cfg->max_clients);
                if (group->num_members == group->cfg->max_clients - 1)
@@ -854,20 +854,18 @@ int p2p_group_go_discover(struct p2p_group *group, const u8 *dev_id,
 
        m = p2p_group_get_client(group, dev_id);
        if (m == NULL || m->client_info == NULL) {
-               wpa_printf(MSG_DEBUG, "P2P: Requested client was not in this "
-                          "group " MACSTR,
-                          MAC2STR(group->cfg->interface_addr));
+               p2p_dbg(group->p2p, "Requested client was not in this group "
+                       MACSTR, MAC2STR(group->cfg->interface_addr));
                return -1;
        }
 
        if (!(m->dev_capab & P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) {
-               wpa_printf(MSG_DEBUG, "P2P: Requested client does not support "
-                          "client discoverability");
+               p2p_dbg(group->p2p, "Requested client does not support client discoverability");
                return -1;
        }
 
-       wpa_printf(MSG_DEBUG, "P2P: Schedule GO Discoverability Request to be "
-                  "sent to " MACSTR, MAC2STR(dev_id));
+       p2p_dbg(group->p2p, "Schedule GO Discoverability Request to be sent to "
+               MACSTR, MAC2STR(dev_id));
 
        req = p2p_build_go_disc_req();
        if (req == NULL)
@@ -882,8 +880,7 @@ int p2p_group_go_discover(struct p2p_group *group, const u8 *dev_id,
                                  group->cfg->interface_addr,
                                  wpabuf_head(req), wpabuf_len(req), 200) < 0)
        {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
        }
 
        wpabuf_free(req);
@@ -908,7 +905,7 @@ u8 p2p_group_presence_req(struct p2p_group *group,
 
        m = p2p_group_get_client_iface(group, client_interface_addr);
        if (m == NULL || m->client_info == NULL) {
-               wpa_printf(MSG_DEBUG, "P2P: Client was not in this group");
+               p2p_dbg(group->p2p, "Client was not in this group");
                return P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE;
        }
 
@@ -921,9 +918,9 @@ u8 p2p_group_presence_req(struct p2p_group *group,
        else
                curr_noa_len = -1;
        if (curr_noa_len < 0)
-               wpa_printf(MSG_DEBUG, "P2P: Failed to fetch current NoA");
+               p2p_dbg(group->p2p, "Failed to fetch current NoA");
        else if (curr_noa_len == 0)
-               wpa_printf(MSG_DEBUG, "P2P: No NoA being advertized");
+               p2p_dbg(group->p2p, "No NoA being advertized");
        else
                wpa_hexdump(MSG_DEBUG, "P2P: Current NoA", curr_noa,
                            curr_noa_len);
index ea6c146ad6eee0585023536dfc9f11ade838ac00..6e57f45a8c4a02a9ba25768d25c822d1d9f316fa 100644 (file)
@@ -717,5 +717,11 @@ int p2p_send_action(struct p2p_data *p2p, unsigned int freq, const u8 *dst,
 void p2p_stop_listen_for_freq(struct p2p_data *p2p, int freq);
 int p2p_prepare_channel(struct p2p_data *p2p, struct p2p_device *dev,
                        unsigned int force_freq, unsigned int pref_freq);
+void p2p_dbg(struct p2p_data *p2p, const char *fmt, ...)
+PRINTF_FORMAT(2, 3);
+void p2p_info(struct p2p_data *p2p, const char *fmt, ...)
+PRINTF_FORMAT(2, 3);
+void p2p_err(struct p2p_data *p2p, const char *fmt, ...)
+PRINTF_FORMAT(2, 3);
 
 #endif /* P2P_I_H */
index fe8408cfb740f4e941a95e5148b94d8de5b79c2c..a3d013f79b671e40993cfe1b152ae7f429e77e5d 100644 (file)
@@ -166,8 +166,7 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
 
        os_memset(group_bssid, 0, sizeof(group_bssid));
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Received Invitation Request from " MACSTR " (freq=%d)",
+       p2p_dbg(p2p, "Received Invitation Request from " MACSTR " (freq=%d)",
                MAC2STR(sa), rx_freq);
 
        if (p2p_parse(data, len, &msg))
@@ -175,14 +174,12 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
 
        dev = p2p_get_device(p2p, sa);
        if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Invitation Request from unknown peer "
-                       MACSTR, MAC2STR(sa));
+               p2p_dbg(p2p, "Invitation Request from unknown peer " MACSTR,
+                       MAC2STR(sa));
 
                if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data + 1, len - 1,
                                   0)) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Invitation Request add device failed "
+                       p2p_dbg(p2p, "Invitation Request add device failed "
                                MACSTR, MAC2STR(sa));
                        status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
                        goto fail;
@@ -190,18 +187,16 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
 
                dev = p2p_get_device(p2p, sa);
                if (dev == NULL) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Reject Invitation Request from unknown "
-                               "peer " MACSTR, MAC2STR(sa));
+                       p2p_dbg(p2p, "Reject Invitation Request from unknown peer "
+                               MACSTR, MAC2STR(sa));
                        status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
                        goto fail;
                }
        }
 
        if (!msg.group_id || !msg.channel_list) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Mandatory attribute missing in Invitation "
-                       "Request from " MACSTR, MAC2STR(sa));
+               p2p_dbg(p2p, "Mandatory attribute missing in Invitation Request from "
+                       MACSTR, MAC2STR(sa));
                status = P2P_SC_FAIL_INVALID_PARAMS;
                goto fail;
        }
@@ -214,16 +209,14 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
                 * the request was for a persistent group if the attribute is
                 * missing.
                 */
-               wpa_printf(MSG_DEBUG, "P2P: Mandatory Invitation Flags "
-                          "attribute missing from Invitation Request");
+               p2p_dbg(p2p, "Mandatory Invitation Flags attribute missing from Invitation Request");
                persistent = 1;
        }
 
        if (p2p_peer_channels_check(p2p, &p2p->cfg->channels, dev,
                                    msg.channel_list, msg.channel_list_len) <
            0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No common channels found");
+               p2p_dbg(p2p, "No common channels found");
                status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
                goto fail;
        }
@@ -236,12 +229,11 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
        }
 
        if (op_freq) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Invitation "
-                       "processing forced frequency %d MHz", op_freq);
+               p2p_dbg(p2p, "Invitation processing forced frequency %d MHz",
+                       op_freq);
                if (p2p_freq_to_channel(op_freq, &reg_class, &channel) < 0) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Unknown forced freq %d MHz from "
-                               "invitation_process()", op_freq);
+                       p2p_dbg(p2p, "Unknown forced freq %d MHz from invitation_process()",
+                               op_freq);
                        status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
                        goto fail;
                }
@@ -250,9 +242,8 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
                                       &intersection);
                if (!p2p_channels_includes(&intersection, reg_class, channel))
                {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: forced freq %d MHz not in the supported "
-                               "channels interaction", op_freq);
+                       p2p_dbg(p2p, "forced freq %d MHz not in the supported channels interaction",
+                               op_freq);
                        status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
                        goto fail;
                }
@@ -260,17 +251,14 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
                if (status == P2P_SC_SUCCESS)
                        channels = &intersection;
        } else {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No forced channel from invitation processing - "
-                       "figure out best one to use");
+               p2p_dbg(p2p, "No forced channel from invitation processing - figure out best one to use");
 
                p2p_channels_intersect(&p2p->cfg->channels, &dev->channels,
                                       &intersection);
                /* Default to own configuration as a starting point */
                p2p->op_reg_class = p2p->cfg->op_reg_class;
                p2p->op_channel = p2p->cfg->op_channel;
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Own default "
-                       "op_class %d channel %d",
+               p2p_dbg(p2p, "Own default op_class %d channel %d",
                        p2p->op_reg_class, p2p->op_channel);
 
                /* Use peer preference if specified and compatible */
@@ -279,8 +267,7 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
                        req_freq = p2p_channel_to_freq(
                                msg.operating_channel[3],
                                msg.operating_channel[4]);
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer "
-                               "operating channel preference: %d MHz",
+                       p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
                                req_freq);
                        if (req_freq > 0 &&
                            p2p_channels_includes(&intersection,
@@ -288,46 +275,31 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
                                                  msg.operating_channel[4])) {
                                p2p->op_reg_class = msg.operating_channel[3];
                                p2p->op_channel = msg.operating_channel[4];
-                               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                                       "P2P: Use peer preference op_class %d "
-                                       "channel %d",
+                               p2p_dbg(p2p, "Use peer preference op_class %d channel %d",
                                        p2p->op_reg_class, p2p->op_channel);
                        } else {
-                               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                                       "P2P: Cannot use peer channel "
-                                       "preference");
+                               p2p_dbg(p2p, "Cannot use peer channel preference");
                        }
                }
 
                if (!p2p_channels_includes(&intersection, p2p->op_reg_class,
                                           p2p->op_channel)) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Initially selected channel (op_class %d "
-                               "channel %d) not in channel intersection - try "
-                               "to reselect",
+                       p2p_dbg(p2p, "Initially selected channel (op_class %d channel %d) not in channel intersection - try to reselect",
                                p2p->op_reg_class, p2p->op_channel);
                        p2p_reselect_channel(p2p, &intersection);
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Re-selection result: op_class %d "
-                               "channel %d",
+                       p2p_dbg(p2p, "Re-selection result: op_class %d channel %d",
                                p2p->op_reg_class, p2p->op_channel);
                        if (!p2p_channels_includes(&intersection,
                                                   p2p->op_reg_class,
                                                   p2p->op_channel)) {
-                               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                                       "P2P: Peer does not support selected "
-                                       "operating channel (reg_class=%u "
-                                       "channel=%u)",
+                               p2p_dbg(p2p, "Peer does not support selected operating channel (reg_class=%u channel=%u)",
                                        p2p->op_reg_class, p2p->op_channel);
                                status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
                                goto fail;
                        }
                } else if (!(dev->flags & P2P_DEV_FORCE_FREQ) &&
                           !p2p->cfg->cfg_op_channel) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Try to reselect channel selection with "
-                               "peer information received; "
-                               "previously selected op_class %u channel %u",
+                       p2p_dbg(p2p, "Try to reselect channel selection with peer information received; previously selected op_class %u channel %u",
                                p2p->op_reg_class, p2p->op_channel);
                        p2p_reselect_channel(p2p, &intersection);
                }
@@ -335,16 +307,13 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
                op_freq = p2p_channel_to_freq(p2p->op_reg_class,
                                              p2p->op_channel);
                if (op_freq < 0) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Unknown operational channel "
-                               "(country=%c%c reg_class=%u channel=%u)",
+                       p2p_dbg(p2p, "Unknown operational channel (country=%c%c reg_class=%u channel=%u)",
                                p2p->cfg->country[0], p2p->cfg->country[1],
                                p2p->op_reg_class, p2p->op_channel);
                        status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
                        goto fail;
                }
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Selected operating "
-                       "channel - %d MHz", op_freq);
+               p2p_dbg(p2p, "Selected operating channel - %d MHz", op_freq);
 
                if (status == P2P_SC_SUCCESS) {
                        reg_class = p2p->op_reg_class;
@@ -370,8 +339,7 @@ fail:
                freq = p2p_channel_to_freq(p2p->cfg->reg_class,
                                           p2p->cfg->channel);
        if (freq < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unknown regulatory class/channel");
+               p2p_dbg(p2p, "Unknown regulatory class/channel");
                goto out;
        }
 
@@ -398,8 +366,7 @@ fail:
        if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
                            p2p->cfg->dev_addr,
                            wpabuf_head(resp), wpabuf_len(resp), 200) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
        }
 
 out:
@@ -415,21 +382,18 @@ void p2p_process_invitation_resp(struct p2p_data *p2p, const u8 *sa,
        struct p2p_message msg;
        struct p2p_channels intersection, *channels = NULL;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Received Invitation Response from " MACSTR,
+       p2p_dbg(p2p, "Received Invitation Response from " MACSTR,
                MAC2STR(sa));
 
        dev = p2p_get_device(p2p, sa);
        if (dev == NULL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Ignore Invitation Response from unknown peer "
+               p2p_dbg(p2p, "Ignore Invitation Response from unknown peer "
                        MACSTR, MAC2STR(sa));
                return;
        }
 
        if (dev != p2p->invite_peer) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Ignore unexpected Invitation Response from peer "
+               p2p_dbg(p2p, "Ignore unexpected Invitation Response from peer "
                        MACSTR, MAC2STR(sa));
                return;
        }
@@ -438,17 +402,15 @@ void p2p_process_invitation_resp(struct p2p_data *p2p, const u8 *sa,
                return;
 
        if (!msg.status) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Mandatory Status attribute missing in "
-                       "Invitation Response from " MACSTR, MAC2STR(sa));
+               p2p_dbg(p2p, "Mandatory Status attribute missing in Invitation Response from "
+                       MACSTR, MAC2STR(sa));
                p2p_parse_free(&msg);
                return;
        }
 
        if (!msg.channel_list) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Mandatory Channel List attribute missing in "
-                       "Invitation Response from " MACSTR, MAC2STR(sa));
+               p2p_dbg(p2p, "Mandatory Channel List attribute missing in Invitation Response from "
+                       MACSTR, MAC2STR(sa));
 #ifdef CONFIG_P2P_STRICT
                p2p_parse_free(&msg);
                return;
@@ -458,8 +420,7 @@ void p2p_process_invitation_resp(struct p2p_data *p2p, const u8 *sa,
        } else if (p2p_peer_channels_check(p2p, &p2p->channels, dev,
                                           msg.channel_list,
                                           msg.channel_list_len) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No common channels found");
+               p2p_dbg(p2p, "No common channels found");
                p2p_parse_free(&msg);
                return;
        } else {
@@ -488,9 +449,8 @@ int p2p_invite_send(struct p2p_data *p2p, struct p2p_device *dev,
 
        freq = dev->listen_freq > 0 ? dev->listen_freq : dev->oper_freq;
        if (freq <= 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No Listen/Operating frequency known for the "
-                       "peer " MACSTR " to send Invitation Request",
+               p2p_dbg(p2p, "No Listen/Operating frequency known for the peer "
+                       MACSTR " to send Invitation Request",
                        MAC2STR(dev->info.p2p_device_addr));
                return -1;
        }
@@ -500,8 +460,7 @@ int p2p_invite_send(struct p2p_data *p2p, struct p2p_device *dev,
                return -1;
        if (p2p->state != P2P_IDLE)
                p2p_stop_listen_for_freq(p2p, freq);
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Sending Invitation Request");
+       p2p_dbg(p2p, "Sending Invitation Request");
        p2p_set_state(p2p, P2P_INVITE);
        p2p->pending_action_state = P2P_PENDING_INVITATION_REQUEST;
        p2p->invite_peer = dev;
@@ -509,8 +468,7 @@ int p2p_invite_send(struct p2p_data *p2p, struct p2p_device *dev,
        if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
                            p2p->cfg->dev_addr, dev->info.p2p_device_addr,
                            wpabuf_head(req), wpabuf_len(req), 200) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
                /* Use P2P find to recover and retry */
                p2p_set_timeout(p2p, 0, 0);
        }
@@ -523,12 +481,10 @@ int p2p_invite_send(struct p2p_data *p2p, struct p2p_device *dev,
 
 void p2p_invitation_req_cb(struct p2p_data *p2p, int success)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Invitation Request TX callback: success=%d", success);
+       p2p_dbg(p2p, "Invitation Request TX callback: success=%d", success);
 
        if (p2p->invite_peer == NULL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No pending Invite");
+               p2p_dbg(p2p, "No pending Invite");
                return;
        }
 
@@ -543,15 +499,11 @@ void p2p_invitation_req_cb(struct p2p_data *p2p, int success)
 
 void p2p_invitation_resp_cb(struct p2p_data *p2p, int success)
 {
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Invitation Response TX callback: success=%d", success);
+       p2p_dbg(p2p, "Invitation Response TX callback: success=%d", success);
        p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
 
        if (!success)
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Assume Invitation Response was actually "
-                       "received by the peer even though Ack was not "
-                       "reported");
+               p2p_dbg(p2p, "Assume Invitation Response was actually received by the peer even though Ack was not reported");
 
        if (p2p->cfg->invitation_received) {
                p2p->cfg->invitation_received(p2p->cfg->cb_ctx,
@@ -572,28 +524,24 @@ int p2p_invite(struct p2p_data *p2p, const u8 *peer, enum p2p_invite_role role,
 {
        struct p2p_device *dev;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Request to invite peer " MACSTR " role=%d persistent=%d "
+       p2p_dbg(p2p, "Request to invite peer " MACSTR " role=%d persistent=%d "
                "force_freq=%u",
                MAC2STR(peer), role, persistent_group, force_freq);
        if (bssid)
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Invitation for BSSID " MACSTR, MAC2STR(bssid));
+               p2p_dbg(p2p, "Invitation for BSSID " MACSTR, MAC2STR(bssid));
        if (go_dev_addr) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Invitation for GO Device Address " MACSTR,
+               p2p_dbg(p2p, "Invitation for GO Device Address " MACSTR,
                        MAC2STR(go_dev_addr));
                os_memcpy(p2p->invite_go_dev_addr_buf, go_dev_addr, ETH_ALEN);
                p2p->invite_go_dev_addr = p2p->invite_go_dev_addr_buf;
        } else
                p2p->invite_go_dev_addr = NULL;
-       wpa_hexdump_ascii(MSG_DEBUG, "P2P: Invitation for SSID",
+       wpa_hexdump_ascii(MSG_DEBUG, "Invitation for SSID",
                          ssid, ssid_len);
 
        dev = p2p_get_device(p2p, peer);
        if (dev == NULL || (dev->listen_freq <= 0 && dev->oper_freq <= 0)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Cannot invite unknown P2P Device " MACSTR,
+               p2p_dbg(p2p, "Cannot invite unknown P2P Device " MACSTR,
                        MAC2STR(peer));
                return -1;
        }
@@ -610,8 +558,7 @@ int p2p_invite(struct p2p_data *p2p, const u8 *peer, enum p2p_invite_role role,
        if (dev->flags & P2P_DEV_GROUP_CLIENT_ONLY) {
                if (!(dev->info.dev_capab &
                      P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Cannot invite a P2P Device " MACSTR
+                       p2p_dbg(p2p, "Cannot invite a P2P Device " MACSTR
                                " that is in a group and is not discoverable",
                                MAC2STR(peer));
                }
index 3bbce164514c46fba7c9ac2aa2e8be15a076a83a..54aa4282812d4e02e450f6a78ddafa6500ec72fe 100644 (file)
@@ -141,22 +141,19 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa,
        if (p2p_parse(data, len, &msg))
                return;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Received Provision Discovery Request from " MACSTR
+       p2p_dbg(p2p, "Received Provision Discovery Request from " MACSTR
                " with config methods 0x%x (freq=%d)",
                MAC2STR(sa), msg.wps_config_methods, rx_freq);
 
        dev = p2p_get_device(p2p, sa);
        if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Provision Discovery Request from "
-                       "unknown peer " MACSTR, MAC2STR(sa));
+               p2p_dbg(p2p, "Provision Discovery Request from unknown peer "
+                       MACSTR, MAC2STR(sa));
 
                if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data + 1, len - 1,
                                   0)) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Provision Discovery Request add device "
-                               "failed " MACSTR, MAC2STR(sa));
+                       p2p_dbg(p2p, "Provision Discovery Request add device failed "
+                               MACSTR, MAC2STR(sa));
                }
        } else if (msg.wfd_subelems) {
                wpabuf_free(dev->info.wfd_subelems);
@@ -166,8 +163,7 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa,
        if (!(msg.wps_config_methods &
              (WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD |
               WPS_CONFIG_PUSHBUTTON))) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Unsupported "
-                       "Config Methods in Provision Discovery Request");
+               p2p_dbg(p2p, "Unsupported Config Methods in Provision Discovery Request");
                goto out;
        }
 
@@ -180,8 +176,7 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa,
                                break;
                }
                if (i == p2p->num_groups) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: PD "
-                               "request for unknown P2P Group ID - reject");
+                       p2p_dbg(p2p, "PD request for unknown P2P Group ID - reject");
                        goto out;
                }
        }
@@ -190,12 +185,12 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa,
                dev->flags &= ~(P2P_DEV_PD_PEER_DISPLAY |
                                P2P_DEV_PD_PEER_KEYPAD);
        if (msg.wps_config_methods & WPS_CONFIG_DISPLAY) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer " MACSTR
+               p2p_dbg(p2p, "Peer " MACSTR
                        " requested us to show a PIN on display", MAC2STR(sa));
                if (dev)
                        dev->flags |= P2P_DEV_PD_PEER_KEYPAD;
        } else if (msg.wps_config_methods & WPS_CONFIG_KEYPAD) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer " MACSTR
+               p2p_dbg(p2p, "Peer " MACSTR
                        " requested us to write its PIN using keypad",
                        MAC2STR(sa));
                if (dev)
@@ -212,16 +207,14 @@ out:
                p2p_parse_free(&msg);
                return;
        }
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Sending Provision Discovery Response");
+       p2p_dbg(p2p, "Sending Provision Discovery Response");
        if (rx_freq > 0)
                freq = rx_freq;
        else
                freq = p2p_channel_to_freq(p2p->cfg->reg_class,
                                           p2p->cfg->channel);
        if (freq < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unknown regulatory class/channel");
+               p2p_dbg(p2p, "Unknown regulatory class/channel");
                wpabuf_free(resp);
                p2p_parse_free(&msg);
                return;
@@ -230,8 +223,7 @@ out:
        if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
                            p2p->cfg->dev_addr,
                            wpabuf_head(resp), wpabuf_len(resp), 200) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
        }
 
        wpabuf_free(resp);
@@ -264,24 +256,20 @@ void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa,
        if (p2p_parse(data, len, &msg))
                return;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Received Provision Discovery Response from " MACSTR
+       p2p_dbg(p2p, "Received Provision Discovery Response from " MACSTR
                " with config methods 0x%x",
                MAC2STR(sa), msg.wps_config_methods);
 
        dev = p2p_get_device(p2p, sa);
        if (dev == NULL || !dev->req_config_methods) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Ignore Provision Discovery Response from "
-                       MACSTR " with no pending request", MAC2STR(sa));
+               p2p_dbg(p2p, "Ignore Provision Discovery Response from " MACSTR
+                       " with no pending request", MAC2STR(sa));
                p2p_parse_free(&msg);
                return;
        }
 
        if (dev->dialog_token != msg.dialog_token) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Ignore Provision Discovery Response with "
-                       "unexpected Dialog Token %u (expected %u)",
+               p2p_dbg(p2p, "Ignore Provision Discovery Response with unexpected Dialog Token %u (expected %u)",
                        msg.dialog_token, dev->dialog_token);
                p2p_parse_free(&msg);
                return;
@@ -307,9 +295,7 @@ void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa,
                p2p_reset_pending_pd(p2p);
 
        if (msg.wps_config_methods != req_config_methods) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer rejected "
-                       "our Provision Discovery Request (received "
-                       "config_methods 0x%x expected 0x%x",
+               p2p_dbg(p2p, "Peer rejected our Provision Discovery Request (received config_methods 0x%x expected 0x%x",
                        msg.wps_config_methods, req_config_methods);
                if (p2p->cfg->prov_disc_fail)
                        p2p->cfg->prov_disc_fail(p2p->cfg->cb_ctx, sa,
@@ -322,11 +308,11 @@ void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa,
        dev->flags &= ~(P2P_DEV_PD_PEER_DISPLAY |
                        P2P_DEV_PD_PEER_KEYPAD);
        if (req_config_methods & WPS_CONFIG_DISPLAY) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer " MACSTR
+               p2p_dbg(p2p, "Peer " MACSTR
                        " accepted to show a PIN on display", MAC2STR(sa));
                dev->flags |= P2P_DEV_PD_PEER_DISPLAY;
        } else if (msg.wps_config_methods & WPS_CONFIG_KEYPAD) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer " MACSTR
+               p2p_dbg(p2p, "Peer " MACSTR
                        " accepted to write our PIN using keypad",
                        MAC2STR(sa));
                dev->flags |= P2P_DEV_PD_PEER_KEYPAD;
@@ -342,10 +328,8 @@ out:
        dev->req_config_methods = 0;
        p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
        if (dev->flags & P2P_DEV_PD_BEFORE_GO_NEG) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Start GO Neg after the PD-before-GO-Neg "
-                       "workaround with " MACSTR,
-                       MAC2STR(dev->info.p2p_device_addr));
+               p2p_dbg(p2p, "Start GO Neg after the PD-before-GO-Neg workaround with "
+                       MACSTR, MAC2STR(dev->info.p2p_device_addr));
                dev->flags &= ~P2P_DEV_PD_BEFORE_GO_NEG;
                p2p_connect_send(p2p, dev);
                return;
@@ -373,9 +357,8 @@ int p2p_send_prov_disc_req(struct p2p_data *p2p, struct p2p_device *dev,
                freq = dev->listen_freq > 0 ? dev->listen_freq :
                        dev->oper_freq;
        if (freq <= 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No Listen/Operating frequency known for the "
-                       "peer " MACSTR " to send Provision Discovery Request",
+               p2p_dbg(p2p, "No Listen/Operating frequency known for the peer "
+                       MACSTR " to send Provision Discovery Request",
                        MAC2STR(dev->info.p2p_device_addr));
                return -1;
        }
@@ -383,8 +366,7 @@ int p2p_send_prov_disc_req(struct p2p_data *p2p, struct p2p_device *dev,
        if (dev->flags & P2P_DEV_GROUP_CLIENT_ONLY) {
                if (!(dev->info.dev_capab &
                      P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Cannot use PD with P2P Device " MACSTR
+                       p2p_dbg(p2p, "Cannot use PD with P2P Device " MACSTR
                                " that is in a group and is not discoverable",
                                MAC2STR(dev->info.p2p_device_addr));
                        return -1;
@@ -404,8 +386,7 @@ int p2p_send_prov_disc_req(struct p2p_data *p2p, struct p2p_device *dev,
        if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
                            p2p->cfg->dev_addr, dev->info.p2p_device_addr,
                            wpabuf_head(req), wpabuf_len(req), 200) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
                wpabuf_free(req);
                return -1;
        }
@@ -427,14 +408,13 @@ int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr,
        if (dev == NULL)
                dev = p2p_get_device_interface(p2p, peer_addr);
        if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Provision "
-                       "Discovery Request destination " MACSTR
+               p2p_dbg(p2p, "Provision Discovery Request destination " MACSTR
                        " not yet known", MAC2STR(peer_addr));
                return -1;
        }
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Provision Discovery "
-               "Request with " MACSTR " (config methods 0x%x)",
+       p2p_dbg(p2p, "Provision Discovery Request with " MACSTR
+               " (config methods 0x%x)",
                MAC2STR(peer_addr), config_methods);
        if (config_methods == 0)
                return -1;
@@ -450,9 +430,8 @@ int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr,
 
        if (p2p->state != P2P_IDLE && p2p->state != P2P_SEARCH &&
            p2p->state != P2P_LISTEN_ONLY) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Busy with other "
-                       "operations; postpone Provision Discovery Request "
-                       "with " MACSTR " (config methods 0x%x)",
+               p2p_dbg(p2p, "Busy with other operations; postpone Provision Discovery Request with "
+                       MACSTR " (config methods 0x%x)",
                        MAC2STR(peer_addr), config_methods);
                return 0;
        }
index cf074d718dba5ada5a44ee72c1650acf41339c22..0e0c7f121e2f3b97943485a9225581bbe47a4ab8 100644 (file)
@@ -157,8 +157,7 @@ static void p2p_send_gas_comeback_req(struct p2p_data *p2p, const u8 *dst,
        p2p->pending_action_state = P2P_NO_PENDING_ACTION;
        if (p2p_send_action(p2p, freq, dst, p2p->cfg->dev_addr, dst,
                            wpabuf_head(req), wpabuf_len(req), 200) < 0)
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
 
        wpabuf_free(req);
 }
@@ -235,9 +234,8 @@ int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev)
 
        freq = dev->listen_freq > 0 ? dev->listen_freq : dev->oper_freq;
        if (freq <= 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: No Listen/Operating frequency known for the "
-                       "peer " MACSTR " to send SD Request",
+               p2p_dbg(p2p, "No Listen/Operating frequency known for the peer "
+                       MACSTR " to send SD Request",
                        MAC2STR(dev->info.p2p_device_addr));
                return -1;
        }
@@ -246,8 +244,7 @@ int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev)
        if (query == NULL)
                return -1;
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Start Service Discovery with " MACSTR,
+       p2p_dbg(p2p, "Start Service Discovery with " MACSTR,
                MAC2STR(dev->info.p2p_device_addr));
 
        req = p2p_build_sd_query(p2p->srv_update_indic, query->tlvs);
@@ -261,8 +258,7 @@ int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev)
        if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
                            p2p->cfg->dev_addr, dev->info.p2p_device_addr,
                            wpabuf_head(req), wpabuf_len(req), 5000) < 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
                ret = -1;
        }
 
@@ -299,14 +295,12 @@ void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
                return;
 
        dialog_token = *pos++;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: GAS Initial Request from " MACSTR " (dialog token %u, "
-               "freq %d)",
+       p2p_dbg(p2p, "GAS Initial Request from " MACSTR
+               " (dialog token %u, freq %d)",
                MAC2STR(sa), dialog_token, rx_freq);
 
        if (*pos != WLAN_EID_ADV_PROTO) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unexpected IE in GAS Initial Request: %u", *pos);
+               p2p_dbg(p2p, "Unexpected IE in GAS Initial Request: %u", *pos);
                return;
        }
        pos++;
@@ -314,15 +308,13 @@ void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
        slen = *pos++;
        next = pos + slen;
        if (next > end || slen < 2) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Invalid IE in GAS Initial Request");
+               p2p_dbg(p2p, "Invalid IE in GAS Initial Request");
                return;
        }
        pos++; /* skip QueryRespLenLimit and PAME-BI */
 
        if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unsupported GAS advertisement protocol id %u",
+               p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
                        *pos);
                return;
        }
@@ -341,8 +333,7 @@ void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
        if (pos + 4 > end)
                return;
        if (WPA_GET_LE16(pos) != ANQP_VENDOR_SPECIFIC) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
+               p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
                return;
        }
        pos += 2;
@@ -350,21 +341,18 @@ void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
        slen = WPA_GET_LE16(pos);
        pos += 2;
        if (pos + slen > end || slen < 3 + 1) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Invalid ANQP Query Request length");
+               p2p_dbg(p2p, "Invalid ANQP Query Request length");
                return;
        }
 
        if (WPA_GET_BE24(pos) != OUI_WFA) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unsupported ANQP OUI %06x", WPA_GET_BE24(pos));
+               p2p_dbg(p2p, "Unsupported ANQP OUI %06x", WPA_GET_BE24(pos));
                return;
        }
        pos += 3;
 
        if (*pos != P2P_OUI_TYPE) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unsupported ANQP vendor type %u", *pos);
+               p2p_dbg(p2p, "Unsupported ANQP vendor type %u", *pos);
                return;
        }
        pos++;
@@ -372,8 +360,7 @@ void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
        if (pos + 2 > end)
                return;
        update_indic = WPA_GET_LE16(pos);
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Service Update Indicator: %u", update_indic);
+       p2p_dbg(p2p, "Service Update Indicator: %u", update_indic);
        pos += 2;
 
        p2p->cfg->sd_request(p2p->cfg->cb_ctx, freq, sa, dialog_token,
@@ -389,8 +376,7 @@ void p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst,
 
        /* TODO: fix the length limit to match with the maximum frame length */
        if (wpabuf_len(resp_tlvs) > 1400) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: SD response long "
-                       "enough to require fragmentation");
+               p2p_dbg(p2p, "SD response long enough to require fragmentation");
                if (p2p->sd_resp) {
                        /*
                         * TODO: Could consider storing the fragmented response
@@ -399,14 +385,12 @@ void p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst,
                         * Though, that would eat more memory, so there are
                         * also benefits to just using a single buffer.
                         */
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Drop "
-                               "previous SD response");
+                       p2p_dbg(p2p, "Drop previous SD response");
                        wpabuf_free(p2p->sd_resp);
                }
                p2p->sd_resp = wpabuf_dup(resp_tlvs);
                if (p2p->sd_resp == NULL) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_ERROR, "P2P: Failed to "
-                               "allocate SD response fragmentation area");
+                       p2p_err(p2p, "Failed to allocate SD response fragmentation area");
                        return;
                }
                os_memcpy(p2p->sd_resp_addr, dst, ETH_ALEN);
@@ -416,8 +400,7 @@ void p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst,
                resp = p2p_build_sd_response(dialog_token, WLAN_STATUS_SUCCESS,
                                             1, p2p->srv_update_indic, NULL);
        } else {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: SD response fits "
-                       "in initial response");
+               p2p_dbg(p2p, "SD response fits in initial response");
                resp = p2p_build_sd_response(dialog_token,
                                             WLAN_STATUS_SUCCESS, 0,
                                             p2p->srv_update_indic, resp_tlvs);
@@ -429,8 +412,7 @@ void p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst,
        if (p2p_send_action(p2p, freq, dst, p2p->cfg->dev_addr,
                            p2p->cfg->dev_addr,
                            wpabuf_head(resp), wpabuf_len(resp), 200) < 0)
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
 
        wpabuf_free(resp);
 }
@@ -450,21 +432,18 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
 
        if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
            os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Ignore unexpected GAS Initial Response from "
+               p2p_dbg(p2p, "Ignore unexpected GAS Initial Response from "
                        MACSTR, MAC2STR(sa));
                return;
        }
        p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
        p2p_clear_timeout(p2p);
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Received GAS Initial Response from " MACSTR " (len=%d)",
+       p2p_dbg(p2p, "Received GAS Initial Response from " MACSTR " (len=%d)",
                MAC2STR(sa), (int) len);
 
        if (len < 5 + 2) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Too short GAS Initial Response frame");
+               p2p_dbg(p2p, "Too short GAS Initial Response frame");
                return;
        }
 
@@ -474,20 +453,16 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
        pos += 2;
        comeback_delay = WPA_GET_LE16(pos);
        pos += 2;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: dialog_token=%u status_code=%u comeback_delay=%u",
+       p2p_dbg(p2p, "dialog_token=%u status_code=%u comeback_delay=%u",
                dialog_token, status_code, comeback_delay);
        if (status_code) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Service Discovery failed: status code %u",
+               p2p_dbg(p2p, "Service Discovery failed: status code %u",
                        status_code);
                return;
        }
 
        if (*pos != WLAN_EID_ADV_PROTO) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unexpected IE in GAS Initial Response: %u",
-                       *pos);
+               p2p_dbg(p2p, "Unexpected IE in GAS Initial Response: %u", *pos);
                return;
        }
        pos++;
@@ -495,15 +470,13 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
        slen = *pos++;
        next = pos + slen;
        if (next > end || slen < 2) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Invalid IE in GAS Initial Response");
+               p2p_dbg(p2p, "Invalid IE in GAS Initial Response");
                return;
        }
        pos++; /* skip QueryRespLenLimit and PAME-BI */
 
        if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unsupported GAS advertisement protocol id %u",
+               p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
                        *pos);
                return;
        }
@@ -511,27 +484,22 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
        pos = next;
        /* Query Response */
        if (pos + 2 > end) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Too short Query "
-                       "Response");
+               p2p_dbg(p2p, "Too short Query Response");
                return;
        }
        slen = WPA_GET_LE16(pos);
        pos += 2;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Query Response Length: %d",
-               slen);
+       p2p_dbg(p2p, "Query Response Length: %d", slen);
        if (pos + slen > end) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Not enough Query "
-                       "Response data");
+               p2p_dbg(p2p, "Not enough Query Response data");
                return;
        }
        end = pos + slen;
 
        if (comeback_delay) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Fragmented "
-                       "response - request fragments");
+               p2p_dbg(p2p, "Fragmented response - request fragments");
                if (p2p->sd_rx_resp) {
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Drop "
-                               "old SD reassembly buffer");
+                       p2p_dbg(p2p, "Drop old SD reassembly buffer");
                        wpabuf_free(p2p->sd_rx_resp);
                        p2p->sd_rx_resp = NULL;
                }
@@ -543,8 +511,7 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
        if (pos + 4 > end)
                return;
        if (WPA_GET_LE16(pos) != ANQP_VENDOR_SPECIFIC) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
+               p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
                return;
        }
        pos += 2;
@@ -552,21 +519,18 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
        slen = WPA_GET_LE16(pos);
        pos += 2;
        if (pos + slen > end || slen < 3 + 1) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Invalid ANQP Query Response length");
+               p2p_dbg(p2p, "Invalid ANQP Query Response length");
                return;
        }
 
        if (WPA_GET_BE24(pos) != OUI_WFA) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unsupported ANQP OUI %06x", WPA_GET_BE24(pos));
+               p2p_dbg(p2p, "Unsupported ANQP OUI %06x", WPA_GET_BE24(pos));
                return;
        }
        pos += 3;
 
        if (*pos != P2P_OUI_TYPE) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unsupported ANQP vendor type %u", *pos);
+               p2p_dbg(p2p, "Unsupported ANQP vendor type %u", *pos);
                return;
        }
        pos++;
@@ -574,8 +538,7 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
        if (pos + 2 > end)
                return;
        update_indic = WPA_GET_LE16(pos);
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Service Update Indicator: %u", update_indic);
+       p2p_dbg(p2p, "Service Update Indicator: %u", update_indic);
        pos += 2;
 
        p2p->sd_peer->flags |= P2P_DEV_SD_INFO;
@@ -585,8 +548,7 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
        if (p2p->sd_query) {
                if (!p2p->sd_query->for_all_peers) {
                        struct p2p_sd_query *q;
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Remove completed SD query %p",
+                       p2p_dbg(p2p, "Remove completed SD query %p",
                                p2p->sd_query);
                        q = p2p->sd_query;
                        p2p_unlink_sd_query(p2p, p2p->sd_query);
@@ -614,22 +576,20 @@ void p2p_rx_gas_comeback_req(struct p2p_data *p2p, const u8 *sa,
        if (len < 1)
                return;
        dialog_token = *data;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Dialog Token: %u",
-               dialog_token);
+       p2p_dbg(p2p, "Dialog Token: %u", dialog_token);
        if (dialog_token != p2p->sd_resp_dialog_token) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No pending SD "
-                       "response fragment for dialog token %u", dialog_token);
+               p2p_dbg(p2p, "No pending SD response fragment for dialog token %u",
+                       dialog_token);
                return;
        }
 
        if (p2p->sd_resp == NULL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No pending SD "
-                       "response fragment available");
+               p2p_dbg(p2p, "No pending SD response fragment available");
                return;
        }
        if (os_memcmp(sa, p2p->sd_resp_addr, ETH_ALEN) != 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No pending SD "
-                       "response fragment for " MACSTR, MAC2STR(sa));
+               p2p_dbg(p2p, "No pending SD response fragment for " MACSTR,
+                       MAC2STR(sa));
                return;
        }
 
@@ -646,19 +606,16 @@ void p2p_rx_gas_comeback_req(struct p2p_data *p2p, const u8 *sa,
                                           wpabuf_len(p2p->sd_resp));
        if (resp == NULL)
                return;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Send GAS Comeback "
-               "Response (frag_id %d more=%d frag_len=%d)",
+       p2p_dbg(p2p, "Send GAS Comeback Response (frag_id %d more=%d frag_len=%d)",
                p2p->sd_frag_id, more, (int) frag_len);
        p2p->sd_frag_id++;
        p2p->sd_resp_pos += frag_len;
 
        if (more) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: %d more bytes "
-                       "remain to be sent",
+               p2p_dbg(p2p, "%d more bytes remain to be sent",
                        (int) (wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos));
        } else {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: All fragments of "
-                       "SD response sent");
+               p2p_dbg(p2p, "All fragments of SD response sent");
                wpabuf_free(p2p->sd_resp);
                p2p->sd_resp = NULL;
        }
@@ -667,8 +624,7 @@ void p2p_rx_gas_comeback_req(struct p2p_data *p2p, const u8 *sa,
        if (p2p_send_action(p2p, rx_freq, sa, p2p->cfg->dev_addr,
                            p2p->cfg->dev_addr,
                            wpabuf_head(resp), wpabuf_len(resp), 200) < 0)
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Failed to send Action frame");
+               p2p_dbg(p2p, "Failed to send Action frame");
 
        wpabuf_free(resp);
 }
@@ -691,21 +647,18 @@ void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
 
        if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
            os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Ignore unexpected GAS Comeback Response from "
+               p2p_dbg(p2p, "Ignore unexpected GAS Comeback Response from "
                        MACSTR, MAC2STR(sa));
                return;
        }
        p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
        p2p_clear_timeout(p2p);
 
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Received GAS Comeback Response from " MACSTR " (len=%d)",
+       p2p_dbg(p2p, "Received GAS Comeback Response from " MACSTR " (len=%d)",
                MAC2STR(sa), (int) len);
 
        if (len < 6 + 2) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Too short GAS Comeback Response frame");
+               p2p_dbg(p2p, "Too short GAS Comeback Response frame");
                return;
        }
 
@@ -718,22 +671,19 @@ void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
        pos++;
        comeback_delay = WPA_GET_LE16(pos);
        pos += 2;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: dialog_token=%u status_code=%u frag_id=%d more_frags=%d "
+       p2p_dbg(p2p, "dialog_token=%u status_code=%u frag_id=%d more_frags=%d "
                "comeback_delay=%u",
                dialog_token, status_code, frag_id, more_frags,
                comeback_delay);
        /* TODO: check frag_id match */
        if (status_code) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Service Discovery failed: status code %u",
+               p2p_dbg(p2p, "Service Discovery failed: status code %u",
                        status_code);
                return;
        }
 
        if (*pos != WLAN_EID_ADV_PROTO) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unexpected IE in GAS Comeback Response: %u",
+               p2p_dbg(p2p, "Unexpected IE in GAS Comeback Response: %u",
                        *pos);
                return;
        }
@@ -742,15 +692,13 @@ void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
        slen = *pos++;
        next = pos + slen;
        if (next > end || slen < 2) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Invalid IE in GAS Comeback Response");
+               p2p_dbg(p2p, "Invalid IE in GAS Comeback Response");
                return;
        }
        pos++; /* skip QueryRespLenLimit and PAME-BI */
 
        if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unsupported GAS advertisement protocol id %u",
+               p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
                        *pos);
                return;
        }
@@ -758,22 +706,18 @@ void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
        pos = next;
        /* Query Response */
        if (pos + 2 > end) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Too short Query "
-                       "Response");
+               p2p_dbg(p2p, "Too short Query Response");
                return;
        }
        slen = WPA_GET_LE16(pos);
        pos += 2;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Query Response Length: %d",
-               slen);
+       p2p_dbg(p2p, "Query Response Length: %d", slen);
        if (pos + slen > end) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Not enough Query "
-                       "Response data");
+               p2p_dbg(p2p, "Not enough Query Response data");
                return;
        }
        if (slen == 0) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No Query Response "
-                       "data");
+               p2p_dbg(p2p, "No Query Response data");
                return;
        }
        end = pos + slen;
@@ -790,34 +734,29 @@ void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
        if (pos + 4 > end)
                return;
        if (WPA_GET_LE16(pos) != ANQP_VENDOR_SPECIFIC) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
+               p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
                return;
        }
        pos += 2;
 
        slen = WPA_GET_LE16(pos);
        pos += 2;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: ANQP Query Response "
-               "length: %u", slen);
+       p2p_dbg(p2p, "ANQP Query Response length: %u", slen);
        if (slen < 3 + 1) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Invalid ANQP Query Response length");
+               p2p_dbg(p2p, "Invalid ANQP Query Response length");
                return;
        }
        if (pos + 4 > end)
                return;
 
        if (WPA_GET_BE24(pos) != OUI_WFA) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unsupported ANQP OUI %06x", WPA_GET_BE24(pos));
+               p2p_dbg(p2p, "Unsupported ANQP OUI %06x", WPA_GET_BE24(pos));
                return;
        }
        pos += 3;
 
        if (*pos != P2P_OUI_TYPE) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Unsupported ANQP vendor type %u", *pos);
+               p2p_dbg(p2p, "Unsupported ANQP vendor type %u", *pos);
                return;
        }
        pos++;
@@ -825,27 +764,23 @@ void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
        if (pos + 2 > end)
                return;
        p2p->sd_rx_update_indic = WPA_GET_LE16(pos);
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-               "P2P: Service Update Indicator: %u", p2p->sd_rx_update_indic);
+       p2p_dbg(p2p, "Service Update Indicator: %u", p2p->sd_rx_update_indic);
        pos += 2;
 
 skip_nqp_header:
        if (wpabuf_resize(&p2p->sd_rx_resp, end - pos) < 0)
                return;
        wpabuf_put_data(p2p->sd_rx_resp, pos, end - pos);
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Current SD reassembly "
-               "buffer length: %u",
+       p2p_dbg(p2p, "Current SD reassembly buffer length: %u",
                (unsigned int) wpabuf_len(p2p->sd_rx_resp));
 
        if (more_frags) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: More fragments "
-                       "remains");
+               p2p_dbg(p2p, "More fragments remains");
                /* TODO: what would be a good size limit? */
                if (wpabuf_len(p2p->sd_rx_resp) > 64000) {
                        wpabuf_free(p2p->sd_rx_resp);
                        p2p->sd_rx_resp = NULL;
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Too long "
-                               "SD response - drop it");
+                       p2p_dbg(p2p, "Too long SD response - drop it");
                        return;
                }
                p2p_send_gas_comeback_req(p2p, sa, dialog_token, rx_freq);
@@ -859,8 +794,7 @@ skip_nqp_header:
        if (p2p->sd_query) {
                if (!p2p->sd_query->for_all_peers) {
                        struct p2p_sd_query *q;
-                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                               "P2P: Remove completed SD query %p",
+                       p2p_dbg(p2p, "Remove completed SD query %p",
                                p2p->sd_query);
                        q = p2p->sd_query;
                        p2p_unlink_sd_query(p2p, p2p->sd_query);
@@ -903,7 +837,7 @@ void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst,
 
        q->next = p2p->sd_queries;
        p2p->sd_queries = q;
-       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Added SD Query %p", q);
+       p2p_dbg(p2p, "Added SD Query %p", q);
 
        if (dst == NULL) {
                struct p2p_device *dev;
@@ -937,8 +871,7 @@ void p2p_sd_service_update(struct p2p_data *p2p)
 int p2p_sd_cancel_request(struct p2p_data *p2p, void *req)
 {
        if (p2p_unlink_sd_query(p2p, req)) {
-               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
-                       "P2P: Cancel pending SD query %p", req);
+               p2p_dbg(p2p, "Cancel pending SD query %p", req);
                p2p_free_sd_query(req);
                return 0;
        }
index 31c241ca8945fb2c0bf648fdade0a43c495d45a6..2de41d1aa03e8399d5bda20a51eb2e105cef5053 100644 (file)
@@ -2929,6 +2929,13 @@ static int wpas_go_connected(void *ctx, const u8 *dev_addr)
 }
 
 
+static void wpas_p2p_debug_print(void *ctx, int level, const char *msg)
+{
+       struct wpa_supplicant *wpa_s = ctx;
+       wpa_msg(wpa_s, level, "P2P: %s", msg);
+}
+
+
 /**
  * wpas_p2p_init - Initialize P2P module for %wpa_supplicant
  * @global: Pointer to global data from wpa_supplicant_init()
@@ -2967,8 +2974,8 @@ int wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s)
        }
 
        os_memset(&p2p, 0, sizeof(p2p));
-       p2p.msg_ctx = wpa_s;
        p2p.cb_ctx = wpa_s;
+       p2p.debug_print = wpas_p2p_debug_print;
        p2p.p2p_scan = wpas_p2p_scan;
        p2p.send_action = wpas_send_action;
        p2p.send_action_done = wpas_send_action_done;