P2P: Clean up debug prints

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>
This commit is contained in:
Jouni Malinen 2013-05-18 18:47:36 +03:00
parent 710ae9ac1f
commit ed496f131f
11 changed files with 567 additions and 984 deletions

View file

@ -3195,6 +3195,12 @@ static void test_prov_disc_resp(void *ctx, const u8 *peer, u16 config_methods)
/* TODO */ /* TODO */
} }
static void test_p2p_debug_print(void *ctx, int level, const char *msg)
{
wpa_printf(level, "P2P: %s", msg);
}
#endif /* CONFIG_P2P */ #endif /* CONFIG_P2P */
@ -3206,8 +3212,8 @@ static int wpa_driver_test_init_p2p(struct wpa_driver_test_data *drv)
int i; int i;
os_memset(&p2p, 0, sizeof(p2p)); os_memset(&p2p, 0, sizeof(p2p));
p2p.msg_ctx = drv->ctx;
p2p.cb_ctx = drv; p2p.cb_ctx = drv;
p2p.debug_print = test_p2p_debug_print;
p2p.p2p_scan = test_p2p_scan; p2p.p2p_scan = test_p2p_scan;
p2p.send_action = test_send_action; p2p.send_action = test_send_action;
p2p.send_action_done = test_send_action_done; p2p.send_action_done = test_send_action_done;

File diff suppressed because it is too large Load diff

View file

@ -370,16 +370,19 @@ struct p2p_config {
*/ */
unsigned int max_listen; unsigned int max_listen;
/**
* msg_ctx - Context to use with wpa_msg() calls
*/
void *msg_ctx;
/** /**
* cb_ctx - Context to use with callback functions * cb_ctx - Context to use with callback functions
*/ */
void *cb_ctx; void *cb_ctx;
/**
* debug_print - Debug print
* @ctx: Callback context from cb_ctx
* @level: Debug verbosity level (MSG_*)
* @msg: Debug message
*/
void (*debug_print)(void *ctx, int level, const char *msg);
/* Callbacks to request lower layer driver operations */ /* Callbacks to request lower layer driver operations */

View 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) void p2p_dev_disc_req_cb(struct p2p_data *p2p, int success)
{ {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Device Discoverability Request TX callback: success=%d",
"P2P: Device Discoverability Request TX callback: success=%d",
success); success);
if (!success) { if (!success) {
@ -56,9 +55,7 @@ void p2p_dev_disc_req_cb(struct p2p_data *p2p, int success)
return; return;
} }
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "GO acknowledged Device Discoverability Request - wait for response");
"P2P: GO acknowledged Device Discoverability Request - wait "
"for response");
/* /*
* TODO: is the remain-on-channel from Action frame TX long enough for * 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 * 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); go = p2p_get_device(p2p, dev->member_in_go_dev);
if (go == NULL || dev->oper_freq <= 0) { if (go == NULL || dev->oper_freq <= 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Could not find peer entry for GO and frequency to send Device Discoverability Request");
"P2P: Could not find peer entry for GO and frequency "
"to send Device Discoverability Request");
return -1; return -1;
} }
@ -84,8 +79,7 @@ int p2p_send_dev_disc_req(struct p2p_data *p2p, struct p2p_device *dev)
if (req == NULL) if (req == NULL)
return -1; return -1;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Sending Device Discoverability Request to GO " MACSTR
"P2P: Sending Device Discoverability Request to GO " MACSTR
" for client " MACSTR, " for client " MACSTR,
MAC2STR(go->info.p2p_device_addr), MAC2STR(go->info.p2p_device_addr),
MAC2STR(dev->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, if (p2p_send_action(p2p, dev->oper_freq, go->info.p2p_device_addr,
p2p->cfg->dev_addr, go->info.p2p_device_addr, p2p->cfg->dev_addr, go->info.p2p_device_addr,
wpabuf_head(req), wpabuf_len(req), 1000) < 0) { wpabuf_head(req), wpabuf_len(req), 1000) < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Failed to send Action frame");
"P2P: Failed to send Action frame");
wpabuf_free(req); wpabuf_free(req);
/* TODO: how to recover from failure? */ /* TODO: how to recover from failure? */
return -1; 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) void p2p_dev_disc_resp_cb(struct p2p_data *p2p, int success)
{ {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Device Discoverability Response TX callback: success=%d",
"P2P: Device Discoverability Response TX callback: success=%d",
success); success);
p2p->cfg->send_action_done(p2p->cfg->cb_ctx); 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) if (resp == NULL)
return; return;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Sending Device Discoverability Response to " MACSTR
"P2P: Sending Device Discoverability Response to " MACSTR
" (status %u freq %d)", " (status %u freq %d)",
MAC2STR(addr), status, freq); 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, if (p2p_send_action(p2p, freq, addr, p2p->cfg->dev_addr,
p2p->cfg->dev_addr, p2p->cfg->dev_addr,
wpabuf_head(resp), wpabuf_len(resp), 200) < 0) { wpabuf_head(resp), wpabuf_len(resp), 200) < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Failed to send Action frame");
"P2P: Failed to send Action frame");
} }
wpabuf_free(resp); wpabuf_free(resp);
@ -170,17 +160,14 @@ void p2p_process_dev_disc_req(struct p2p_data *p2p, const u8 *sa,
struct p2p_message msg; struct p2p_message msg;
size_t g; size_t g;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Received Device Discoverability Request from " MACSTR
"P2P: Received Device Discoverability Request from " MACSTR
" (freq=%d)", MAC2STR(sa), rx_freq); " (freq=%d)", MAC2STR(sa), rx_freq);
if (p2p_parse(data, len, &msg)) if (p2p_parse(data, len, &msg))
return; return;
if (msg.dialog_token == 0) { if (msg.dialog_token == 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Invalid Dialog Token 0 (must be nonzero) in Device Discoverability Request");
"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_send_dev_disc_resp(p2p, msg.dialog_token, sa, rx_freq,
P2P_SC_FAIL_INVALID_PARAMS); P2P_SC_FAIL_INVALID_PARAMS);
p2p_parse_free(&msg); 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) { if (msg.device_id == NULL) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "P2P Device ID attribute missing from Device Discoverability Request");
"P2P: P2P Device ID attribute missing from Device "
"Discoverability Request");
p2p_send_dev_disc_resp(p2p, msg.dialog_token, sa, rx_freq, p2p_send_dev_disc_resp(p2p, msg.dialog_token, sa, rx_freq,
P2P_SC_FAIL_INVALID_PARAMS); P2P_SC_FAIL_INVALID_PARAMS);
p2p_parse_free(&msg); 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++) { for (g = 0; g < p2p->num_groups; g++) {
if (p2p_group_go_discover(p2p->groups[g], msg.device_id, sa, if (p2p_group_go_discover(p2p->groups[g], msg.device_id, sa,
rx_freq) == 0) { rx_freq) == 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Scheduled " p2p_dbg(p2p, "Scheduled GO Discoverability Request for the target device");
"GO Discoverability Request for the target "
"device");
/* /*
* P2P group code will use a callback to indicate TX * P2P group code will use a callback to indicate TX
* status, so that we can reply to the request once the * 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 " p2p_dbg(p2p, "Requested client was not found in any group or did not support client discoverability");
"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_send_dev_disc_resp(p2p, msg.dialog_token, sa, rx_freq,
P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE); P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE);
p2p_parse_free(&msg); 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; struct p2p_device *go;
u8 status; u8 status;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Received Device Discoverability Response from " MACSTR,
"P2P: Received Device Discoverability Response from " MACSTR,
MAC2STR(sa)); MAC2STR(sa));
go = p2p->pending_client_disc_go; go = p2p->pending_client_disc_go;
if (go == NULL || if (go == NULL ||
os_memcmp(sa, go->info.p2p_device_addr, ETH_ALEN) != 0) { os_memcmp(sa, go->info.p2p_device_addr, ETH_ALEN) != 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Ignore unexpected " p2p_dbg(p2p, "Ignore unexpected Device Discoverability Response");
"Device Discoverability Response");
return; 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) { if (msg.dialog_token != go->dialog_token) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Ignore Device " p2p_dbg(p2p, "Ignore Device Discoverability Response with unexpected dialog token %u (expected %u)",
"Discoverability Response with unexpected dialog "
"token %u (expected %u)",
msg.dialog_token, go->dialog_token); msg.dialog_token, go->dialog_token);
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; return;
@ -265,17 +242,14 @@ void p2p_process_dev_disc_resp(struct p2p_data *p2p, const u8 *sa,
status = *msg.status; status = *msg.status;
p2p_parse_free(&msg); p2p_parse_free(&msg);
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Device Discoverability Response status %u", status);
"P2P: Device Discoverability Response status %u", status);
if (p2p->go_neg_peer == NULL || if (p2p->go_neg_peer == NULL ||
os_memcmp(p2p->pending_client_disc_addr, os_memcmp(p2p->pending_client_disc_addr,
p2p->go_neg_peer->info.p2p_device_addr, ETH_ALEN) != 0 || p2p->go_neg_peer->info.p2p_device_addr, ETH_ALEN) != 0 ||
os_memcmp(p2p->go_neg_peer->member_in_go_dev, os_memcmp(p2p->go_neg_peer->member_in_go_dev,
go->info.p2p_device_addr, ETH_ALEN) != 0) { go->info.p2p_device_addr, ETH_ALEN) != 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No pending " p2p_dbg(p2p, "No pending operation with the client discoverability peer anymore");
"operation with the client discoverability peer "
"anymore");
return; 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 * Peer is expected to be awake for at least 100 TU; try to
* connect immediately. * connect immediately.
*/ */
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Client discoverability request succeeded");
"P2P: Client discoverability request succeeded");
if (p2p->state == P2P_CONNECT) { if (p2p->state == P2P_CONNECT) {
/* /*
* Change state to force the timeout to start in * 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 * Client discoverability request failed; try to connect from
* timeout. * timeout.
*/ */
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Client discoverability request failed");
"P2P: Client discoverability request failed");
p2p_set_timeout(p2p, 0, 500000); 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) void p2p_go_disc_req_cb(struct p2p_data *p2p, int success)
{ {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "GO Discoverability Request TX callback: success=%d",
"P2P: GO Discoverability Request TX callback: success=%d",
success); success);
p2p->cfg->send_action_done(p2p->cfg->cb_ctx); p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
if (p2p->pending_dev_disc_dialog_token == 0) { if (p2p->pending_dev_disc_dialog_token == 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No pending Device " p2p_dbg(p2p, "No pending Device Discoverability Request");
"Discoverability Request");
return; return;
} }
@ -338,9 +308,7 @@ void p2p_process_go_disc_req(struct p2p_data *p2p, const u8 *da, const u8 *sa,
unsigned int tu; unsigned int tu;
struct wpabuf *ies; struct wpabuf *ies;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Received GO Discoverability Request - remain awake for 100 TU");
"P2P: Received GO Discoverability Request - remain awake for "
"100 TU");
ies = p2p_build_probe_resp_ies(p2p); ies = p2p_build_probe_resp_ies(p2p);
if (ies == NULL) 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; tu = 100;
if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, rx_freq, 1024 * tu / 1000, if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, rx_freq, 1024 * tu / 1000,
ies) < 0) { ies) < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Failed to start listen mode for client discoverability");
"P2P: Failed to start listen mode for client "
"discoverability");
} }
wpabuf_free(ies); wpabuf_free(ies);
} }

View file

@ -49,8 +49,7 @@ int p2p_peer_channels_check(struct p2p_data *p2p, struct p2p_channels *own,
os_memcpy(dev->country, pos, 3); os_memcpy(dev->country, pos, 3);
wpa_hexdump_ascii(MSG_DEBUG, "P2P: Peer 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) { if (pos[2] != 0x04 && os_memcmp(pos, p2p->cfg->country, 2) != 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_INFO, p2p_info(p2p, "Mismatching country (ours=%c%c peer's=%c%c)",
"P2P: Mismatching country (ours=%c%c peer's=%c%c)",
p2p->cfg->country[0], p2p->cfg->country[1], p2p->cfg->country[0], p2p->cfg->country[1],
pos[0], pos[1]); pos[0], pos[1]);
return -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]; struct p2p_reg_class *cl = &ch->reg_class[ch->reg_classes];
cl->reg_class = *pos++; cl->reg_class = *pos++;
if (pos + 1 + pos[0] > end) { if (pos + 1 + pos[0] > end) {
wpa_msg(p2p->cfg->msg_ctx, MSG_INFO, p2p_info(p2p, "Invalid peer Channel List");
"P2P: Invalid peer Channel List");
return -1; return -1;
} }
channels = *pos++; 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); p2p_channels_intersect(own, &dev->channels, &intersection);
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Own reg_classes %d " p2p_dbg(p2p, "Own reg_classes %d peer reg_classes %d intersection reg_classes %d",
"peer reg_classes %d intersection reg_classes %d",
(int) own->reg_classes, (int) own->reg_classes,
(int) dev->channels.reg_classes, (int) dev->channels.reg_classes,
(int) intersection.reg_classes); (int) intersection.reg_classes);
if (intersection.reg_classes == 0) { if (intersection.reg_classes == 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_INFO, p2p_info(p2p, "No common channels found");
"P2P: No common channels found");
return -1; return -1;
} }
return 0; 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) { if (dev->flags & P2P_DEV_PD_BEFORE_GO_NEG) {
u16 config_method; u16 config_method;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Use PD-before-GO-Neg workaround for " MACSTR,
"P2P: Use PD-before-GO-Neg workaround for " MACSTR,
MAC2STR(dev->info.p2p_device_addr)); MAC2STR(dev->info.p2p_device_addr));
if (dev->wps_method == WPS_PIN_DISPLAY) if (dev->wps_method == WPS_PIN_DISPLAY)
config_method = WPS_CONFIG_KEYPAD; 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; freq = dev->listen_freq > 0 ? dev->listen_freq : dev->oper_freq;
if (freq <= 0) { if (freq <= 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No Listen/Operating frequency known for the peer "
"P2P: No Listen/Operating frequency known for the " MACSTR " to send GO Negotiation Request",
"peer " MACSTR " to send GO Negotiation Request",
MAC2STR(dev->info.p2p_device_addr)); MAC2STR(dev->info.p2p_device_addr));
return -1; 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); req = p2p_build_go_neg_req(p2p, dev);
if (req == NULL) if (req == NULL)
return -1; return -1;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Sending GO Negotiation Request");
"P2P: Sending GO Negotiation Request");
p2p_set_state(p2p, P2P_CONNECT); p2p_set_state(p2p, P2P_CONNECT);
p2p->pending_action_state = P2P_PENDING_GO_NEG_REQUEST; p2p->pending_action_state = P2P_PENDING_GO_NEG_REQUEST;
p2p->go_neg_peer = dev; 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, if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
p2p->cfg->dev_addr, dev->info.p2p_device_addr, p2p->cfg->dev_addr, dev->info.p2p_device_addr,
wpabuf_head(req), wpabuf_len(req), 500) < 0) { wpabuf_head(req), wpabuf_len(req), 500) < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Failed to send Action frame");
"P2P: Failed to send Action frame");
/* Use P2P find to recover and retry */ /* Use P2P find to recover and retry */
p2p_set_timeout(p2p, 0, 0); p2p_set_timeout(p2p, 0, 0);
} else } else
@ -254,8 +246,7 @@ static struct wpabuf * p2p_build_go_neg_resp(struct p2p_data *p2p,
u8 group_capab; u8 group_capab;
size_t extra = 0; size_t extra = 0;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Building GO Negotiation Response");
"P2P: Building GO Negotiation Response");
#ifdef CONFIG_WIFI_DISPLAY #ifdef CONFIG_WIFI_DISPLAY
if (p2p->wfd_ie_go_neg) 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_go_intent(buf, (p2p->go_intent << 1) | tie_breaker);
p2p_buf_add_config_timeout(buf, p2p->go_timeout, p2p->client_timeout); p2p_buf_add_config_timeout(buf, p2p->go_timeout, p2p->client_timeout);
if (peer && peer->go_state == REMOTE_GO) { if (peer && peer->go_state == REMOTE_GO) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Omit Operating " p2p_dbg(p2p, "Omit Operating Channel attribute");
"Channel attribute");
} else { } else {
p2p_buf_add_operating_channel(buf, p2p->cfg->country, p2p_buf_add_operating_channel(buf, p2p->cfg->country,
p2p->op_reg_class, p2p->op_reg_class,
@ -354,9 +344,8 @@ void p2p_reselect_channel(struct p2p_data *p2p,
p2p_freq_to_channel(p2p->own_freq_preference, p2p_freq_to_channel(p2p->own_freq_preference,
&op_reg_class, &op_channel) == 0 && &op_reg_class, &op_channel) == 0 &&
p2p_channels_includes(intersection, op_reg_class, op_channel)) { p2p_channels_includes(intersection, op_reg_class, op_channel)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Pick own channel " p2p_dbg(p2p, "Pick own channel preference (reg_class %u channel %u) from intersection",
"preference (reg_class %u channel %u) from " op_reg_class, op_channel);
"intersection", op_reg_class, op_channel);
p2p->op_reg_class = op_reg_class; p2p->op_reg_class = op_reg_class;
p2p->op_channel = op_channel; p2p->op_channel = op_channel;
return; return;
@ -366,8 +355,7 @@ void p2p_reselect_channel(struct p2p_data *p2p,
p2p_freq_to_channel(p2p->best_freq_overall, p2p_freq_to_channel(p2p->best_freq_overall,
&op_reg_class, &op_channel) == 0 && &op_reg_class, &op_channel) == 0 &&
p2p_channels_includes(intersection, op_reg_class, op_channel)) { p2p_channels_includes(intersection, op_reg_class, op_channel)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Pick best overall " p2p_dbg(p2p, "Pick best overall channel (reg_class %u channel %u) from intersection",
"channel (reg_class %u channel %u) from intersection",
op_reg_class, op_channel); op_reg_class, op_channel);
p2p->op_reg_class = op_reg_class; p2p->op_reg_class = op_reg_class;
p2p->op_channel = op_channel; 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, p2p_freq_to_channel(p2p->best_freq_5,
&op_reg_class, &op_channel) == 0 && &op_reg_class, &op_channel) == 0 &&
p2p_channels_includes(intersection, op_reg_class, op_channel)) { p2p_channels_includes(intersection, op_reg_class, op_channel)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Pick best 5 GHz " p2p_dbg(p2p, "Pick best 5 GHz channel (reg_class %u channel %u) from intersection",
"channel (reg_class %u channel %u) from intersection",
op_reg_class, op_channel); op_reg_class, op_channel);
p2p->op_reg_class = op_reg_class; p2p->op_reg_class = op_reg_class;
p2p->op_channel = op_channel; 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, p2p_freq_to_channel(p2p->best_freq_24,
&op_reg_class, &op_channel) == 0 && &op_reg_class, &op_channel) == 0 &&
p2p_channels_includes(intersection, op_reg_class, op_channel)) { p2p_channels_includes(intersection, op_reg_class, op_channel)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Pick best 2.4 GHz " p2p_dbg(p2p, "Pick best 2.4 GHz channel (reg_class %u channel %u) from intersection",
"channel (reg_class %u channel %u) from intersection",
op_reg_class, op_channel); op_reg_class, op_channel);
p2p->op_reg_class = op_reg_class; p2p->op_reg_class = op_reg_class;
p2p->op_channel = op_channel; p2p->op_channel = op_channel;
@ -411,9 +397,7 @@ void p2p_reselect_channel(struct p2p_data *p2p,
p2p->cfg->pref_chan[i].chan)) { p2p->cfg->pref_chan[i].chan)) {
p2p->op_reg_class = p2p->cfg->pref_chan[i].op_class; p2p->op_reg_class = p2p->cfg->pref_chan[i].op_class;
p2p->op_channel = p2p->cfg->pref_chan[i].chan; p2p->op_channel = p2p->cfg->pref_chan[i].chan;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Pick " p2p_dbg(p2p, "Pick highest preferred channel (op_class %u channel %u) from intersection",
"highest preferred chnnel (op_class %u "
"channel %u) from intersection",
p2p->op_reg_class, p2p->op_channel); p2p->op_reg_class, p2p->op_channel);
return; return;
} }
@ -424,9 +408,7 @@ void p2p_reselect_channel(struct p2p_data *p2p,
struct p2p_reg_class *c = &intersection->reg_class[i]; struct p2p_reg_class *c = &intersection->reg_class[i];
if (c->reg_class == 116 || c->reg_class == 117 || if (c->reg_class == 116 || c->reg_class == 117 ||
c->reg_class == 126 || c->reg_class == 127) { c->reg_class == 126 || c->reg_class == 127) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Pick possible HT40 channel (reg_class %u channel %u) from intersection",
"P2P: Pick possible HT40 channel (reg_class "
"%u channel %u) from intersection",
c->reg_class, c->channel[0]); c->reg_class, c->channel[0]);
p2p->op_reg_class = c->reg_class; p2p->op_reg_class = c->reg_class;
p2p->op_channel = c->channel[0]; 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, if (p2p_channels_includes(intersection, p2p->op_reg_class,
p2p->op_channel)) { p2p->op_channel)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Using original operating class and channel (op_class %u channel %u) from intersection",
"P2P: Using original operating class and channel "
"(op_class %u channel %u) from intersection",
p2p->op_reg_class, p2p->op_channel); p2p->op_reg_class, p2p->op_channel);
return; return;
} }
@ -453,8 +433,7 @@ void p2p_reselect_channel(struct p2p_data *p2p,
* no better options seems to be available. * no better options seems to be available.
*/ */
cl = &intersection->reg_class[0]; cl = &intersection->reg_class[0];
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Pick another channel " p2p_dbg(p2p, "Pick another channel (reg_class %u channel %u) from intersection",
"(reg_class %u channel %u) from intersection",
cl->reg_class, cl->channel[0]); cl->reg_class, cl->channel[0]);
p2p->op_reg_class = cl->reg_class; p2p->op_reg_class = cl->reg_class;
p2p->op_channel = cl->channel[0]; 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 || if (intersection.reg_classes == 0 ||
intersection.reg_class[0].channels == 0) { intersection.reg_class[0].channels == 0) {
*status = P2P_SC_FAIL_NO_COMMON_CHANNELS; *status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No common channels found");
"P2P: No common channels found");
return -1; return -1;
} }
for (i = 0; i < intersection.reg_classes; i++) { for (i = 0; i < intersection.reg_classes; i++) {
struct p2p_reg_class *c; struct p2p_reg_class *c;
c = &intersection.reg_class[i]; 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", wpa_hexdump(MSG_DEBUG, "P2P: channels",
c->channel, c->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)) { p2p->op_channel)) {
if (dev->flags & P2P_DEV_FORCE_FREQ) { if (dev->flags & P2P_DEV_FORCE_FREQ) {
*status = P2P_SC_FAIL_NO_COMMON_CHANNELS; *status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer does " p2p_dbg(p2p, "Peer does not support the forced channel");
"not support the forced channel");
return -1; return -1;
} }
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Selected operating " p2p_dbg(p2p, "Selected operating channel (op_class %u channel %u) not acceptable to the peer",
"channel (op_class %u channel %u) not acceptable to " p2p->op_reg_class, p2p->op_channel);
"the peer", p2p->op_reg_class, p2p->op_channel);
p2p_reselect_channel(p2p, &intersection); p2p_reselect_channel(p2p, &intersection);
} else if (!(dev->flags & P2P_DEV_FORCE_FREQ) && } else if (!(dev->flags & P2P_DEV_FORCE_FREQ) &&
!p2p->cfg->cfg_op_channel) { !p2p->cfg->cfg_op_channel) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Try to optimize " p2p_dbg(p2p, "Try to optimize channel selection with peer information received; previously selected op_class %u channel %u",
"channel selection with peer information received; "
"previously selected op_class %u channel %u",
p2p->op_reg_class, p2p->op_channel); p2p->op_reg_class, p2p->op_channel);
p2p_reselect_channel(p2p, &intersection); 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 tie_breaker = 0;
int freq; int freq;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Received GO Negotiation Request from " MACSTR "(freq=%d)",
"P2P: Received GO Negotiation Request from " MACSTR MAC2STR(sa), rx_freq);
"(freq=%d)", MAC2STR(sa), rx_freq);
if (p2p_parse(data, len, &msg)) if (p2p_parse(data, len, &msg))
return; return;
if (!msg.capability) { if (!msg.capability) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Mandatory Capability attribute missing from GO Negotiation Request");
"P2P: Mandatory Capability attribute missing from GO "
"Negotiation Request");
#ifdef CONFIG_P2P_STRICT #ifdef CONFIG_P2P_STRICT
goto fail; goto fail;
#endif /* CONFIG_P2P_STRICT */ #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) if (msg.go_intent)
tie_breaker = *msg.go_intent & 0x01; tie_breaker = *msg.go_intent & 0x01;
else { else {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Mandatory GO Intent attribute missing from GO Negotiation Request");
"P2P: Mandatory GO Intent attribute missing from GO "
"Negotiation Request");
#ifdef CONFIG_P2P_STRICT #ifdef CONFIG_P2P_STRICT
goto fail; goto fail;
#endif /* CONFIG_P2P_STRICT */ #endif /* CONFIG_P2P_STRICT */
} }
if (!msg.config_timeout) { if (!msg.config_timeout) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Mandatory Configuration Timeout attribute missing from GO Negotiation Request");
"P2P: Mandatory Configuration Timeout attribute "
"missing from GO Negotiation Request");
#ifdef CONFIG_P2P_STRICT #ifdef CONFIG_P2P_STRICT
goto fail; goto fail;
#endif /* CONFIG_P2P_STRICT */ #endif /* CONFIG_P2P_STRICT */
} }
if (!msg.listen_channel) { if (!msg.listen_channel) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No Listen Channel attribute received");
"P2P: No Listen Channel attribute received");
goto fail; goto fail;
} }
if (!msg.operating_channel) { if (!msg.operating_channel) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No Operating Channel attribute received");
"P2P: No Operating Channel attribute received");
goto fail; goto fail;
} }
if (!msg.channel_list) { if (!msg.channel_list) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No Channel List attribute received");
"P2P: No Channel List attribute received");
goto fail; goto fail;
} }
if (!msg.intended_addr) { if (!msg.intended_addr) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No Intended P2P Interface Address attribute received");
"P2P: No Intended P2P Interface Address attribute "
"received");
goto fail; goto fail;
} }
if (!msg.p2p_device_info) { if (!msg.p2p_device_info) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No P2P Device Info attribute received");
"P2P: No P2P Device Info attribute received");
goto fail; goto fail;
} }
if (os_memcmp(msg.p2p_device_addr, sa, ETH_ALEN) != 0) { if (os_memcmp(msg.p2p_device_addr, sa, ETH_ALEN) != 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unexpected GO Negotiation Request SA=" MACSTR
"P2P: Unexpected GO Negotiation Request SA=" MACSTR
" != dev_addr=" MACSTR, " != dev_addr=" MACSTR,
MAC2STR(sa), MAC2STR(msg.p2p_device_addr)); MAC2STR(sa), MAC2STR(msg.p2p_device_addr));
goto fail; 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); dev = p2p_get_device(p2p, sa);
if (msg.status && *msg.status) { if (msg.status && *msg.status) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unexpected Status attribute (%d) in GO Negotiation Request",
"P2P: Unexpected Status attribute (%d) in GO " *msg.status);
"Negotiation Request", *msg.status);
goto fail; 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) else if (dev->flags & P2P_DEV_PROBE_REQ_ONLY)
p2p_add_dev_info(p2p, sa, dev, &msg); p2p_add_dev_info(p2p, sa, dev, &msg);
if (dev && dev->flags & P2P_DEV_USER_REJECTED) { if (dev && dev->flags & P2P_DEV_USER_REJECTED) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "User has rejected this peer");
"P2P: User has rejected this peer");
status = P2P_SC_FAIL_REJECTED_BY_USER; status = P2P_SC_FAIL_REJECTED_BY_USER;
} else if (dev == NULL || dev->wps_method == WPS_NOT_READY) { } else if (dev == NULL || dev->wps_method == WPS_NOT_READY) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
"P2P: Not ready for GO negotiation with " MACSTR,
MAC2STR(sa)); MAC2STR(sa));
status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE; status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
p2p->cfg->go_neg_req_rx(p2p->cfg->cb_ctx, sa, p2p->cfg->go_neg_req_rx(p2p->cfg->cb_ctx, sa,
msg.dev_password_id); msg.dev_password_id);
} else if (p2p->go_neg_peer && p2p->go_neg_peer != dev) { } else if (p2p->go_neg_peer && p2p->go_neg_peer != dev) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Already in Group Formation with another peer");
"P2P: Already in Group Formation with another peer");
status = P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE; status = P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE;
} else { } else {
int go; int go;
if (!p2p->go_neg_peer) { if (!p2p->go_neg_peer) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Starting " p2p_dbg(p2p, "Starting GO Negotiation with previously authorized peer");
"GO Negotiation with previously authorized "
"peer");
if (!(dev->flags & P2P_DEV_FORCE_FREQ)) { if (!(dev->flags & P2P_DEV_FORCE_FREQ)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Use default channel settings");
"P2P: Use default channel settings");
p2p->op_reg_class = p2p->cfg->op_reg_class; p2p->op_reg_class = p2p->cfg->op_reg_class;
p2p->op_channel = p2p->cfg->op_channel; p2p->op_channel = p2p->cfg->op_channel;
os_memcpy(&p2p->channels, &p2p->cfg->channels, os_memcpy(&p2p->channels, &p2p->cfg->channels,
sizeof(struct p2p_channels)); sizeof(struct p2p_channels));
} else { } else {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Use previously configured forced channel settings");
"P2P: Use previously configured "
"forced channel settings");
} }
} }
dev->flags &= ~P2P_DEV_NOT_YET_READY; dev->flags &= ~P2P_DEV_NOT_YET_READY;
if (!msg.go_intent) { if (!msg.go_intent) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No GO Intent attribute received");
"P2P: No GO Intent attribute received");
goto fail; goto fail;
} }
if ((*msg.go_intent >> 1) > P2P_MAX_GO_INTENT) { if ((*msg.go_intent >> 1) > P2P_MAX_GO_INTENT) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Invalid GO Intent value (%u) received",
"P2P: Invalid GO Intent value (%u) received",
*msg.go_intent >> 1); *msg.go_intent >> 1);
goto fail; goto fail;
} }
if (dev->go_neg_req_sent && if (dev->go_neg_req_sent &&
os_memcmp(sa, p2p->cfg->dev_addr, ETH_ALEN) > 0) { os_memcmp(sa, p2p->cfg->dev_addr, ETH_ALEN) > 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Do not reply since peer has higher address and GO Neg Request already sent");
"P2P: Do not reply since peer has higher "
"address and GO Neg Request already sent");
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; return;
} }
go = p2p_go_det(p2p->go_intent, *msg.go_intent); go = p2p_go_det(p2p->go_intent, *msg.go_intent);
if (go < 0) { if (go < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Incompatible GO Intent");
"P2P: Incompatible GO Intent");
status = P2P_SC_FAIL_BOTH_GO_INTENT_15; status = P2P_SC_FAIL_BOTH_GO_INTENT_15;
goto fail; goto fail;
} }
if (p2p_peer_channels(p2p, dev, msg.channel_list, if (p2p_peer_channels(p2p, dev, msg.channel_list,
msg.channel_list_len) < 0) { msg.channel_list_len) < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No common channels found");
"P2P: No common channels found");
status = P2P_SC_FAIL_NO_COMMON_CHANNELS; status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
goto fail; goto fail;
} }
switch (msg.dev_password_id) { switch (msg.dev_password_id) {
case DEV_PW_REGISTRAR_SPECIFIED: case DEV_PW_REGISTRAR_SPECIFIED:
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "PIN from peer Display");
"P2P: PIN from peer Display");
if (dev->wps_method != WPS_PIN_KEYPAD) { if (dev->wps_method != WPS_PIN_KEYPAD) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
"P2P: We have wps_method=%s -> "
"incompatible",
p2p_wps_method_str(dev->wps_method)); p2p_wps_method_str(dev->wps_method));
status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
goto fail; goto fail;
} }
break; break;
case DEV_PW_USER_SPECIFIED: case DEV_PW_USER_SPECIFIED:
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Peer entered PIN on Keypad");
"P2P: Peer entered PIN on Keypad");
if (dev->wps_method != WPS_PIN_DISPLAY) { if (dev->wps_method != WPS_PIN_DISPLAY) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
"P2P: We have wps_method=%s -> "
"incompatible",
p2p_wps_method_str(dev->wps_method)); p2p_wps_method_str(dev->wps_method));
status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
goto fail; goto fail;
} }
break; break;
case DEV_PW_PUSHBUTTON: case DEV_PW_PUSHBUTTON:
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Peer using pushbutton");
"P2P: Peer using pushbutton");
if (dev->wps_method != WPS_PBC) { if (dev->wps_method != WPS_PBC) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
"P2P: We have wps_method=%s -> "
"incompatible",
p2p_wps_method_str(dev->wps_method)); p2p_wps_method_str(dev->wps_method));
status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
goto fail; goto fail;
} }
break; break;
default: default:
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unsupported Device Password ID %d",
"P2P: Unsupported Device Password ID %d",
msg.dev_password_id); msg.dev_password_id);
status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
goto fail; 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->go_state = go ? LOCAL_GO : REMOTE_GO;
dev->oper_freq = p2p_channel_to_freq(msg.operating_channel[3], dev->oper_freq = p2p_channel_to_freq(msg.operating_channel[3],
msg.operating_channel[4]); msg.operating_channel[4]);
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer operating " p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
"channel preference: %d MHz", dev->oper_freq); dev->oper_freq);
if (msg.config_timeout) { if (msg.config_timeout) {
dev->go_timeout = msg.config_timeout[0]; dev->go_timeout = msg.config_timeout[0];
dev->client_timeout = msg.config_timeout[1]; dev->client_timeout = msg.config_timeout[1];
} }
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa));
"P2P: GO Negotiation with " MACSTR, MAC2STR(sa));
if (p2p->state != P2P_IDLE) if (p2p->state != P2P_IDLE)
p2p_stop_find_for_freq(p2p, rx_freq); p2p_stop_find_for_freq(p2p, rx_freq);
p2p_set_state(p2p, P2P_GO_NEG); p2p_set_state(p2p, P2P_GO_NEG);
@ -763,16 +697,14 @@ fail:
p2p_parse_free(&msg); p2p_parse_free(&msg);
if (resp == NULL) if (resp == NULL)
return; return;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Sending GO Negotiation Response");
"P2P: Sending GO Negotiation Response");
if (rx_freq > 0) if (rx_freq > 0)
freq = rx_freq; freq = rx_freq;
else else
freq = p2p_channel_to_freq(p2p->cfg->reg_class, freq = p2p_channel_to_freq(p2p->cfg->reg_class,
p2p->cfg->channel); p2p->cfg->channel);
if (freq < 0) { if (freq < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unknown regulatory class/channel");
"P2P: Unknown regulatory class/channel");
wpabuf_free(resp); wpabuf_free(resp);
return; return;
} }
@ -796,8 +728,7 @@ fail:
if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr, if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
p2p->cfg->dev_addr, p2p->cfg->dev_addr,
wpabuf_head(resp), wpabuf_len(resp), 500) < 0) { wpabuf_head(resp), wpabuf_len(resp), 500) < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Failed to send Action frame");
"P2P: Failed to send Action frame");
} }
wpabuf_free(resp); wpabuf_free(resp);
@ -815,8 +746,7 @@ static struct wpabuf * p2p_build_go_neg_conf(struct p2p_data *p2p,
u8 group_capab; u8 group_capab;
size_t extra = 0; size_t extra = 0;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Building GO Negotiation Confirm");
"P2P: Building GO Negotiation Confirm");
#ifdef CONFIG_WIFI_DISPLAY #ifdef CONFIG_WIFI_DISPLAY
if (p2p->wfd_ie_go_neg) 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; u8 status = P2P_SC_SUCCESS;
int freq; int freq;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Received GO Negotiation Response from " MACSTR
"P2P: Received GO Negotiation Response from " MACSTR
" (freq=%d)", MAC2STR(sa), rx_freq); " (freq=%d)", MAC2STR(sa), rx_freq);
dev = p2p_get_device(p2p, sa); dev = p2p_get_device(p2p, sa);
if (dev == NULL || dev->wps_method == WPS_NOT_READY || if (dev == NULL || dev->wps_method == WPS_NOT_READY ||
dev != p2p->go_neg_peer) { dev != p2p->go_neg_peer) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
"P2P: Not ready for GO negotiation with " MACSTR,
MAC2STR(sa)); MAC2STR(sa));
return; return;
} }
@ -897,44 +825,35 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
return; return;
if (!(dev->flags & P2P_DEV_WAIT_GO_NEG_RESPONSE)) { if (!(dev->flags & P2P_DEV_WAIT_GO_NEG_RESPONSE)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Was not expecting GO Negotiation Response - ignore");
"P2P: Was not expecting GO Negotiation Response - "
"ignore");
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; return;
} }
dev->flags &= ~P2P_DEV_WAIT_GO_NEG_RESPONSE; dev->flags &= ~P2P_DEV_WAIT_GO_NEG_RESPONSE;
if (msg.dialog_token != dev->dialog_token) { if (msg.dialog_token != dev->dialog_token) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)",
"P2P: Unexpected Dialog Token %u (expected %u)",
msg.dialog_token, dev->dialog_token); msg.dialog_token, dev->dialog_token);
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; return;
} }
if (!msg.status) { if (!msg.status) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No Status attribute received");
"P2P: No Status attribute received");
status = P2P_SC_FAIL_INVALID_PARAMS; status = P2P_SC_FAIL_INVALID_PARAMS;
goto fail; goto fail;
} }
if (*msg.status) { if (*msg.status) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "GO Negotiation rejected: status %d", *msg.status);
"P2P: GO Negotiation rejected: status %d",
*msg.status);
dev->go_neg_req_sent = 0; dev->go_neg_req_sent = 0;
if (*msg.status == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE) { if (*msg.status == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Wait for the peer to become ready for GO Negotiation");
"P2P: Wait for the peer to become ready for "
"GO Negotiation");
dev->flags |= P2P_DEV_NOT_YET_READY; dev->flags |= P2P_DEV_NOT_YET_READY;
dev->wait_count = 0; dev->wait_count = 0;
p2p_set_state(p2p, P2P_WAIT_PEER_IDLE); p2p_set_state(p2p, P2P_WAIT_PEER_IDLE);
p2p_set_timeout(p2p, 0, 0); p2p_set_timeout(p2p, 0, 0);
} else { } else {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Stop GO Negotiation attempt");
"P2P: Stop GO Negotiation attempt");
p2p_go_neg_failed(p2p, dev, *msg.status); p2p_go_neg_failed(p2p, dev, *msg.status);
} }
p2p->cfg->send_action_done(p2p->cfg->cb_ctx); 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) { if (!msg.capability) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Mandatory Capability attribute missing from GO Negotiation Response");
"P2P: Mandatory Capability attribute missing from GO "
"Negotiation Response");
#ifdef CONFIG_P2P_STRICT #ifdef CONFIG_P2P_STRICT
status = P2P_SC_FAIL_INVALID_PARAMS; status = P2P_SC_FAIL_INVALID_PARAMS;
goto fail; goto fail;
@ -953,9 +870,7 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
} }
if (!msg.p2p_device_info) { if (!msg.p2p_device_info) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Mandatory P2P Device Info attribute missing from GO Negotiation Response");
"P2P: Mandatory P2P Device Info attribute missing "
"from GO Negotiation Response");
#ifdef CONFIG_P2P_STRICT #ifdef CONFIG_P2P_STRICT
status = P2P_SC_FAIL_INVALID_PARAMS; status = P2P_SC_FAIL_INVALID_PARAMS;
goto fail; goto fail;
@ -963,22 +878,18 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
} }
if (!msg.intended_addr) { if (!msg.intended_addr) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No Intended P2P Interface Address attribute received");
"P2P: No Intended P2P Interface Address attribute "
"received");
status = P2P_SC_FAIL_INVALID_PARAMS; status = P2P_SC_FAIL_INVALID_PARAMS;
goto fail; goto fail;
} }
if (!msg.go_intent) { if (!msg.go_intent) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No GO Intent attribute received");
"P2P: No GO Intent attribute received");
status = P2P_SC_FAIL_INVALID_PARAMS; status = P2P_SC_FAIL_INVALID_PARAMS;
goto fail; goto fail;
} }
if ((*msg.go_intent >> 1) > P2P_MAX_GO_INTENT) { if ((*msg.go_intent >> 1) > P2P_MAX_GO_INTENT) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Invalid GO Intent value (%u) received",
"P2P: Invalid GO Intent value (%u) received",
*msg.go_intent >> 1); *msg.go_intent >> 1);
status = P2P_SC_FAIL_INVALID_PARAMS; status = P2P_SC_FAIL_INVALID_PARAMS;
goto fail; 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); go = p2p_go_det(p2p->go_intent, *msg.go_intent);
if (go < 0) { if (go < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Incompatible GO Intent");
"P2P: Incompatible GO Intent");
status = P2P_SC_FAIL_INCOMPATIBLE_PARAMS; status = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
goto fail; 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; p2p->ssid_len = msg.group_id_len - ETH_ALEN;
os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len); os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len);
} else if (!go) { } else if (!go) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Mandatory P2P Group ID attribute missing from GO Negotiation Response");
"P2P: Mandatory P2P Group ID attribute missing from "
"GO Negotiation Response");
p2p->ssid_len = 0; p2p->ssid_len = 0;
status = P2P_SC_FAIL_INVALID_PARAMS; status = P2P_SC_FAIL_INVALID_PARAMS;
goto fail; goto fail;
} }
if (!msg.config_timeout) { if (!msg.config_timeout) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Mandatory Configuration Timeout attribute missing from GO Negotiation Response");
"P2P: Mandatory Configuration Timeout attribute "
"missing from GO Negotiation Response");
#ifdef CONFIG_P2P_STRICT #ifdef CONFIG_P2P_STRICT
status = P2P_SC_FAIL_INVALID_PARAMS; status = P2P_SC_FAIL_INVALID_PARAMS;
goto fail; 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 * Note: P2P Client may omit Operating Channel attribute to
* indicate it does not have a preference. * indicate it does not have a preference.
*/ */
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No Operating Channel attribute received");
"P2P: No Operating Channel attribute received");
status = P2P_SC_FAIL_INVALID_PARAMS; status = P2P_SC_FAIL_INVALID_PARAMS;
goto fail; goto fail;
} }
if (!msg.channel_list) { if (!msg.channel_list) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No Channel List attribute received");
"P2P: No Channel List attribute received");
status = P2P_SC_FAIL_INVALID_PARAMS; status = P2P_SC_FAIL_INVALID_PARAMS;
goto fail; goto fail;
} }
if (p2p_peer_channels(p2p, dev, msg.channel_list, if (p2p_peer_channels(p2p, dev, msg.channel_list,
msg.channel_list_len) < 0) { msg.channel_list_len) < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No common channels found");
"P2P: No common channels found");
status = P2P_SC_FAIL_NO_COMMON_CHANNELS; status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
goto fail; goto fail;
} }
@ -1046,51 +949,41 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
if (msg.operating_channel) { if (msg.operating_channel) {
dev->oper_freq = p2p_channel_to_freq(msg.operating_channel[3], dev->oper_freq = p2p_channel_to_freq(msg.operating_channel[3],
msg.operating_channel[4]); msg.operating_channel[4]);
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer operating " p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
"channel preference: %d MHz", dev->oper_freq); dev->oper_freq);
} else } else
dev->oper_freq = 0; dev->oper_freq = 0;
switch (msg.dev_password_id) { switch (msg.dev_password_id) {
case DEV_PW_REGISTRAR_SPECIFIED: case DEV_PW_REGISTRAR_SPECIFIED:
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "PIN from peer Display");
"P2P: PIN from peer Display");
if (dev->wps_method != WPS_PIN_KEYPAD) { if (dev->wps_method != WPS_PIN_KEYPAD) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
"P2P: We have wps_method=%s -> "
"incompatible",
p2p_wps_method_str(dev->wps_method)); p2p_wps_method_str(dev->wps_method));
status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
goto fail; goto fail;
} }
break; break;
case DEV_PW_USER_SPECIFIED: case DEV_PW_USER_SPECIFIED:
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Peer entered PIN on Keypad");
"P2P: Peer entered PIN on Keypad");
if (dev->wps_method != WPS_PIN_DISPLAY) { if (dev->wps_method != WPS_PIN_DISPLAY) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
"P2P: We have wps_method=%s -> "
"incompatible",
p2p_wps_method_str(dev->wps_method)); p2p_wps_method_str(dev->wps_method));
status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
goto fail; goto fail;
} }
break; break;
case DEV_PW_PUSHBUTTON: case DEV_PW_PUSHBUTTON:
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Peer using pushbutton");
"P2P: Peer using pushbutton");
if (dev->wps_method != WPS_PBC) { if (dev->wps_method != WPS_PBC) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
"P2P: We have wps_method=%s -> "
"incompatible",
p2p_wps_method_str(dev->wps_method)); p2p_wps_method_str(dev->wps_method));
status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
goto fail; goto fail;
} }
break; break;
default: default:
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unsupported Device Password ID %d",
"P2P: Unsupported Device Password ID %d",
msg.dev_password_id); msg.dev_password_id);
status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
goto fail; 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_set_state(p2p, P2P_GO_NEG);
p2p_clear_timeout(p2p); p2p_clear_timeout(p2p);
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa));
"P2P: GO Negotiation with " MACSTR, MAC2STR(sa));
os_memcpy(dev->intended_addr, msg.intended_addr, ETH_ALEN); os_memcpy(dev->intended_addr, msg.intended_addr, ETH_ALEN);
fail: fail:
@ -1112,8 +1004,7 @@ fail:
p2p_parse_free(&msg); p2p_parse_free(&msg);
if (conf == NULL) if (conf == NULL)
return; return;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Sending GO Negotiation Confirm");
"P2P: Sending GO Negotiation Confirm");
if (status == P2P_SC_SUCCESS) { if (status == P2P_SC_SUCCESS) {
p2p->pending_action_state = P2P_PENDING_GO_NEG_CONFIRM; p2p->pending_action_state = P2P_PENDING_GO_NEG_CONFIRM;
dev->go_state = go ? LOCAL_GO : REMOTE_GO; dev->go_state = go ? LOCAL_GO : REMOTE_GO;
@ -1125,14 +1016,12 @@ fail:
freq = dev->listen_freq; freq = dev->listen_freq;
if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr, sa, if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr, sa,
wpabuf_head(conf), wpabuf_len(conf), 0) < 0) { wpabuf_head(conf), wpabuf_len(conf), 0) < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Failed to send Action frame");
"P2P: Failed to send Action frame");
p2p_go_neg_failed(p2p, dev, -1); p2p_go_neg_failed(p2p, dev, -1);
} }
wpabuf_free(conf); wpabuf_free(conf);
if (status != P2P_SC_SUCCESS) { if (status != P2P_SC_SUCCESS) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "GO Negotiation failed");
"P2P: GO Negotiation failed");
p2p_go_neg_failed(p2p, dev, status); 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_device *dev;
struct p2p_message msg; struct p2p_message msg;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Received GO Negotiation Confirm from " MACSTR,
"P2P: Received GO Negotiation Confirm from " MACSTR,
MAC2STR(sa)); MAC2STR(sa));
dev = p2p_get_device(p2p, sa); dev = p2p_get_device(p2p, sa);
if (dev == NULL || dev->wps_method == WPS_NOT_READY || if (dev == NULL || dev->wps_method == WPS_NOT_READY ||
dev != p2p->go_neg_peer) { dev != p2p->go_neg_peer) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
"P2P: Not ready for GO negotiation with " MACSTR,
MAC2STR(sa)); MAC2STR(sa));
return; return;
} }
if (p2p->pending_action_state == P2P_PENDING_GO_NEG_RESPONSE) { if (p2p->pending_action_state == P2P_PENDING_GO_NEG_RESPONSE) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Stopped waiting " p2p_dbg(p2p, "Stopped waiting for TX status on GO Negotiation Response since we already received Confirmation");
"for TX status on GO Negotiation Response since we "
"already received Confirmation");
p2p->pending_action_state = P2P_NO_PENDING_ACTION; 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; return;
if (!(dev->flags & P2P_DEV_WAIT_GO_NEG_CONFIRM)) { if (!(dev->flags & P2P_DEV_WAIT_GO_NEG_CONFIRM)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Was not expecting GO Negotiation Confirm - ignore");
"P2P: Was not expecting GO Negotiation Confirm - "
"ignore");
return; return;
} }
dev->flags &= ~P2P_DEV_WAIT_GO_NEG_CONFIRM; dev->flags &= ~P2P_DEV_WAIT_GO_NEG_CONFIRM;
if (msg.dialog_token != dev->dialog_token) { if (msg.dialog_token != dev->dialog_token) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)",
"P2P: Unexpected Dialog Token %u (expected %u)",
msg.dialog_token, dev->dialog_token); msg.dialog_token, dev->dialog_token);
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; return;
} }
if (!msg.status) { if (!msg.status) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No Status attribute received");
"P2P: No Status attribute received");
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; return;
} }
if (*msg.status) { if (*msg.status) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "GO Negotiation rejected: status %d", *msg.status);
"P2P: GO Negotiation rejected: status %d",
*msg.status);
p2p_go_neg_failed(p2p, dev, *msg.status); p2p_go_neg_failed(p2p, dev, *msg.status);
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; 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; p2p->ssid_len = msg.group_id_len - ETH_ALEN;
os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len); os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len);
} else if (dev->go_state == REMOTE_GO) { } else if (dev->go_state == REMOTE_GO) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Mandatory P2P Group ID attribute missing from GO Negotiation Confirmation");
"P2P: Mandatory P2P Group ID attribute missing from "
"GO Negotiation Confirmation");
p2p->ssid_len = 0; p2p->ssid_len = 0;
p2p_go_neg_failed(p2p, dev, P2P_SC_FAIL_INVALID_PARAMS); p2p_go_neg_failed(p2p, dev, P2P_SC_FAIL_INVALID_PARAMS);
p2p_parse_free(&msg); 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) { if (!msg.operating_channel) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Mandatory Operating Channel attribute missing from GO Negotiation Confirmation");
"P2P: Mandatory Operating Channel attribute missing "
"from GO Negotiation Confirmation");
#ifdef CONFIG_P2P_STRICT #ifdef CONFIG_P2P_STRICT
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; return;
@ -1222,9 +1097,7 @@ void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
} }
if (!msg.channel_list) { if (!msg.channel_list) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Mandatory Operating Channel attribute missing from GO Negotiation Confirmation");
"P2P: Mandatory Operating Channel attribute missing "
"from GO Negotiation Confirmation");
#ifdef CONFIG_P2P_STRICT #ifdef CONFIG_P2P_STRICT
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; 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 * This should not happen since GO negotiation has already
* been completed. * been completed.
*/ */
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unexpected GO Neg state - do not know which end becomes GO");
"P2P: Unexpected GO Neg state - do not know which end "
"becomes GO");
return; 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 * the group so that we will remain on the current channel to
* acknowledge any possible retransmission from the peer. * acknowledge any possible retransmission from the peer.
*/ */
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: 20 ms wait on current " p2p_dbg(p2p, "20 ms wait on current channel before starting group");
"channel before starting group");
os_sleep(0, 20000); os_sleep(0, 20000);
p2p_go_complete(p2p, dev); p2p_go_complete(p2p, dev);

View file

@ -378,8 +378,8 @@ wifi_display_build_go_ie(struct p2p_group *group)
} else { } else {
WPA_PUT_BE16(len, (u8 *) wpabuf_put(wfd_subelems, 0) - len - WPA_PUT_BE16(len, (u8 *) wpabuf_put(wfd_subelems, 0) - len -
2); 2);
wpa_printf(MSG_DEBUG, "WFD: WFD Session Info: %u descriptors", p2p_dbg(group->p2p, "WFD: WFD Session Info: %u descriptors",
count); count);
} }
wfd_ie = wifi_display_encaps(wfd_subelems); 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; m->next = group->members;
group->members = m; group->members = m;
group->num_members++; 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", " 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, MAC2STR(addr), m->p2p_ie ? 1 : 0, m->wfd_ie ? 1 : 0,
m->client_info ? 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) void p2p_group_notif_disassoc(struct p2p_group *group, const u8 *addr)
{ {
if (p2p_group_remove_member(group, addr)) { if (p2p_group_remove_member(group, addr)) {
wpa_msg(group->p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Remove " p2p_dbg(group->p2p, "Remove client " MACSTR
"client " MACSTR " from group; num_members=%u/%u", " from group; num_members=%u/%u",
MAC2STR(addr), group->num_members, MAC2STR(addr), group->num_members,
group->cfg->max_clients); group->cfg->max_clients);
if (group->num_members == group->cfg->max_clients - 1) 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); m = p2p_group_get_client(group, dev_id);
if (m == NULL || m->client_info == NULL) { if (m == NULL || m->client_info == NULL) {
wpa_printf(MSG_DEBUG, "P2P: Requested client was not in this " p2p_dbg(group->p2p, "Requested client was not in this group "
"group " MACSTR, MACSTR, MAC2STR(group->cfg->interface_addr));
MAC2STR(group->cfg->interface_addr));
return -1; return -1;
} }
if (!(m->dev_capab & P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) { if (!(m->dev_capab & P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) {
wpa_printf(MSG_DEBUG, "P2P: Requested client does not support " p2p_dbg(group->p2p, "Requested client does not support client discoverability");
"client discoverability");
return -1; return -1;
} }
wpa_printf(MSG_DEBUG, "P2P: Schedule GO Discoverability Request to be " p2p_dbg(group->p2p, "Schedule GO Discoverability Request to be sent to "
"sent to " MACSTR, MAC2STR(dev_id)); MACSTR, MAC2STR(dev_id));
req = p2p_build_go_disc_req(); req = p2p_build_go_disc_req();
if (req == NULL) if (req == NULL)
@ -882,8 +880,7 @@ int p2p_group_go_discover(struct p2p_group *group, const u8 *dev_id,
group->cfg->interface_addr, group->cfg->interface_addr,
wpabuf_head(req), wpabuf_len(req), 200) < 0) wpabuf_head(req), wpabuf_len(req), 200) < 0)
{ {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Failed to send Action frame");
"P2P: Failed to send Action frame");
} }
wpabuf_free(req); 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); m = p2p_group_get_client_iface(group, client_interface_addr);
if (m == NULL || m->client_info == NULL) { 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; return P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE;
} }
@ -921,9 +918,9 @@ u8 p2p_group_presence_req(struct p2p_group *group,
else else
curr_noa_len = -1; curr_noa_len = -1;
if (curr_noa_len < 0) 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) else if (curr_noa_len == 0)
wpa_printf(MSG_DEBUG, "P2P: No NoA being advertized"); p2p_dbg(group->p2p, "No NoA being advertized");
else else
wpa_hexdump(MSG_DEBUG, "P2P: Current NoA", curr_noa, wpa_hexdump(MSG_DEBUG, "P2P: Current NoA", curr_noa,
curr_noa_len); curr_noa_len);

View 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); void p2p_stop_listen_for_freq(struct p2p_data *p2p, int freq);
int p2p_prepare_channel(struct p2p_data *p2p, struct p2p_device *dev, int p2p_prepare_channel(struct p2p_data *p2p, struct p2p_device *dev,
unsigned int force_freq, unsigned int pref_freq); 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 */ #endif /* P2P_I_H */

View 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)); os_memset(group_bssid, 0, sizeof(group_bssid));
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Received Invitation Request from " MACSTR " (freq=%d)",
"P2P: Received Invitation Request from " MACSTR " (freq=%d)",
MAC2STR(sa), rx_freq); MAC2STR(sa), rx_freq);
if (p2p_parse(data, len, &msg)) 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); dev = p2p_get_device(p2p, sa);
if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) { if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Invitation Request from unknown peer " MACSTR,
"P2P: Invitation Request from unknown peer " MAC2STR(sa));
MACSTR, MAC2STR(sa));
if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data + 1, len - 1, if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data + 1, len - 1,
0)) { 0)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Invitation Request add device failed "
"P2P: Invitation Request add device failed "
MACSTR, MAC2STR(sa)); MACSTR, MAC2STR(sa));
status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE; status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
goto fail; goto fail;
@ -190,18 +187,16 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
dev = p2p_get_device(p2p, sa); dev = p2p_get_device(p2p, sa);
if (dev == NULL) { if (dev == NULL) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Reject Invitation Request from unknown peer "
"P2P: Reject Invitation Request from unknown " MACSTR, MAC2STR(sa));
"peer " MACSTR, MAC2STR(sa));
status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE; status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
goto fail; goto fail;
} }
} }
if (!msg.group_id || !msg.channel_list) { if (!msg.group_id || !msg.channel_list) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Mandatory attribute missing in Invitation Request from "
"P2P: Mandatory attribute missing in Invitation " MACSTR, MAC2STR(sa));
"Request from " MACSTR, MAC2STR(sa));
status = P2P_SC_FAIL_INVALID_PARAMS; status = P2P_SC_FAIL_INVALID_PARAMS;
goto fail; 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 * the request was for a persistent group if the attribute is
* missing. * missing.
*/ */
wpa_printf(MSG_DEBUG, "P2P: Mandatory Invitation Flags " p2p_dbg(p2p, "Mandatory Invitation Flags attribute missing from Invitation Request");
"attribute missing from Invitation Request");
persistent = 1; persistent = 1;
} }
if (p2p_peer_channels_check(p2p, &p2p->cfg->channels, dev, if (p2p_peer_channels_check(p2p, &p2p->cfg->channels, dev,
msg.channel_list, msg.channel_list_len) < msg.channel_list, msg.channel_list_len) <
0) { 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No common channels found");
"P2P: No common channels found");
status = P2P_SC_FAIL_NO_COMMON_CHANNELS; status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
goto fail; goto fail;
} }
@ -236,12 +229,11 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
} }
if (op_freq) { if (op_freq) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Invitation " p2p_dbg(p2p, "Invitation processing forced frequency %d MHz",
"processing forced frequency %d MHz", op_freq); op_freq);
if (p2p_freq_to_channel(op_freq, &reg_class, &channel) < 0) { if (p2p_freq_to_channel(op_freq, &reg_class, &channel) < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unknown forced freq %d MHz from invitation_process()",
"P2P: Unknown forced freq %d MHz from " op_freq);
"invitation_process()", op_freq);
status = P2P_SC_FAIL_NO_COMMON_CHANNELS; status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
goto fail; goto fail;
} }
@ -250,9 +242,8 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
&intersection); &intersection);
if (!p2p_channels_includes(&intersection, reg_class, channel)) if (!p2p_channels_includes(&intersection, reg_class, channel))
{ {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "forced freq %d MHz not in the supported channels interaction",
"P2P: forced freq %d MHz not in the supported " op_freq);
"channels interaction", op_freq);
status = P2P_SC_FAIL_NO_COMMON_CHANNELS; status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
goto fail; goto fail;
} }
@ -260,17 +251,14 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
if (status == P2P_SC_SUCCESS) if (status == P2P_SC_SUCCESS)
channels = &intersection; channels = &intersection;
} else { } else {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No forced channel from invitation processing - figure out best one to use");
"P2P: No forced channel from invitation processing - "
"figure out best one to use");
p2p_channels_intersect(&p2p->cfg->channels, &dev->channels, p2p_channels_intersect(&p2p->cfg->channels, &dev->channels,
&intersection); &intersection);
/* Default to own configuration as a starting point */ /* Default to own configuration as a starting point */
p2p->op_reg_class = p2p->cfg->op_reg_class; p2p->op_reg_class = p2p->cfg->op_reg_class;
p2p->op_channel = p2p->cfg->op_channel; p2p->op_channel = p2p->cfg->op_channel;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Own default " p2p_dbg(p2p, "Own default op_class %d channel %d",
"op_class %d channel %d",
p2p->op_reg_class, p2p->op_channel); p2p->op_reg_class, p2p->op_channel);
/* Use peer preference if specified and compatible */ /* 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( req_freq = p2p_channel_to_freq(
msg.operating_channel[3], msg.operating_channel[3],
msg.operating_channel[4]); msg.operating_channel[4]);
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer " p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
"operating channel preference: %d MHz",
req_freq); req_freq);
if (req_freq > 0 && if (req_freq > 0 &&
p2p_channels_includes(&intersection, p2p_channels_includes(&intersection,
@ -288,46 +275,31 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
msg.operating_channel[4])) { msg.operating_channel[4])) {
p2p->op_reg_class = msg.operating_channel[3]; p2p->op_reg_class = msg.operating_channel[3];
p2p->op_channel = msg.operating_channel[4]; p2p->op_channel = msg.operating_channel[4];
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Use peer preference op_class %d channel %d",
"P2P: Use peer preference op_class %d "
"channel %d",
p2p->op_reg_class, p2p->op_channel); p2p->op_reg_class, p2p->op_channel);
} else { } else {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Cannot use peer channel preference");
"P2P: Cannot use peer channel "
"preference");
} }
} }
if (!p2p_channels_includes(&intersection, p2p->op_reg_class, if (!p2p_channels_includes(&intersection, p2p->op_reg_class,
p2p->op_channel)) { p2p->op_channel)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Initially selected channel (op_class %d channel %d) not in channel intersection - try to reselect",
"P2P: Initially selected channel (op_class %d "
"channel %d) not in channel intersection - try "
"to reselect",
p2p->op_reg_class, p2p->op_channel); p2p->op_reg_class, p2p->op_channel);
p2p_reselect_channel(p2p, &intersection); p2p_reselect_channel(p2p, &intersection);
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Re-selection result: op_class %d channel %d",
"P2P: Re-selection result: op_class %d "
"channel %d",
p2p->op_reg_class, p2p->op_channel); p2p->op_reg_class, p2p->op_channel);
if (!p2p_channels_includes(&intersection, if (!p2p_channels_includes(&intersection,
p2p->op_reg_class, p2p->op_reg_class,
p2p->op_channel)) { p2p->op_channel)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Peer does not support selected operating channel (reg_class=%u channel=%u)",
"P2P: Peer does not support selected "
"operating channel (reg_class=%u "
"channel=%u)",
p2p->op_reg_class, p2p->op_channel); p2p->op_reg_class, p2p->op_channel);
status = P2P_SC_FAIL_NO_COMMON_CHANNELS; status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
goto fail; goto fail;
} }
} else if (!(dev->flags & P2P_DEV_FORCE_FREQ) && } else if (!(dev->flags & P2P_DEV_FORCE_FREQ) &&
!p2p->cfg->cfg_op_channel) { !p2p->cfg->cfg_op_channel) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Try to reselect channel selection with peer information received; previously selected op_class %u channel %u",
"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->op_reg_class, p2p->op_channel);
p2p_reselect_channel(p2p, &intersection); 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, op_freq = p2p_channel_to_freq(p2p->op_reg_class,
p2p->op_channel); p2p->op_channel);
if (op_freq < 0) { if (op_freq < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unknown operational channel (country=%c%c reg_class=%u channel=%u)",
"P2P: Unknown operational channel "
"(country=%c%c reg_class=%u channel=%u)",
p2p->cfg->country[0], p2p->cfg->country[1], p2p->cfg->country[0], p2p->cfg->country[1],
p2p->op_reg_class, p2p->op_channel); p2p->op_reg_class, p2p->op_channel);
status = P2P_SC_FAIL_NO_COMMON_CHANNELS; status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
goto fail; goto fail;
} }
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Selected operating " p2p_dbg(p2p, "Selected operating channel - %d MHz", op_freq);
"channel - %d MHz", op_freq);
if (status == P2P_SC_SUCCESS) { if (status == P2P_SC_SUCCESS) {
reg_class = p2p->op_reg_class; reg_class = p2p->op_reg_class;
@ -370,8 +339,7 @@ fail:
freq = p2p_channel_to_freq(p2p->cfg->reg_class, freq = p2p_channel_to_freq(p2p->cfg->reg_class,
p2p->cfg->channel); p2p->cfg->channel);
if (freq < 0) { if (freq < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unknown regulatory class/channel");
"P2P: Unknown regulatory class/channel");
goto out; goto out;
} }
@ -398,8 +366,7 @@ fail:
if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr, if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
p2p->cfg->dev_addr, p2p->cfg->dev_addr,
wpabuf_head(resp), wpabuf_len(resp), 200) < 0) { wpabuf_head(resp), wpabuf_len(resp), 200) < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Failed to send Action frame");
"P2P: Failed to send Action frame");
} }
out: out:
@ -415,21 +382,18 @@ void p2p_process_invitation_resp(struct p2p_data *p2p, const u8 *sa,
struct p2p_message msg; struct p2p_message msg;
struct p2p_channels intersection, *channels = NULL; struct p2p_channels intersection, *channels = NULL;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Received Invitation Response from " MACSTR,
"P2P: Received Invitation Response from " MACSTR,
MAC2STR(sa)); MAC2STR(sa));
dev = p2p_get_device(p2p, sa); dev = p2p_get_device(p2p, sa);
if (dev == NULL) { if (dev == NULL) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Ignore Invitation Response from unknown peer "
"P2P: Ignore Invitation Response from unknown peer "
MACSTR, MAC2STR(sa)); MACSTR, MAC2STR(sa));
return; return;
} }
if (dev != p2p->invite_peer) { if (dev != p2p->invite_peer) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Ignore unexpected Invitation Response from peer "
"P2P: Ignore unexpected Invitation Response from peer "
MACSTR, MAC2STR(sa)); MACSTR, MAC2STR(sa));
return; return;
} }
@ -438,17 +402,15 @@ void p2p_process_invitation_resp(struct p2p_data *p2p, const u8 *sa,
return; return;
if (!msg.status) { if (!msg.status) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Mandatory Status attribute missing in Invitation Response from "
"P2P: Mandatory Status attribute missing in " MACSTR, MAC2STR(sa));
"Invitation Response from " MACSTR, MAC2STR(sa));
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; return;
} }
if (!msg.channel_list) { if (!msg.channel_list) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Mandatory Channel List attribute missing in Invitation Response from "
"P2P: Mandatory Channel List attribute missing in " MACSTR, MAC2STR(sa));
"Invitation Response from " MACSTR, MAC2STR(sa));
#ifdef CONFIG_P2P_STRICT #ifdef CONFIG_P2P_STRICT
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; 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, } else if (p2p_peer_channels_check(p2p, &p2p->channels, dev,
msg.channel_list, msg.channel_list,
msg.channel_list_len) < 0) { msg.channel_list_len) < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No common channels found");
"P2P: No common channels found");
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; return;
} else { } 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; freq = dev->listen_freq > 0 ? dev->listen_freq : dev->oper_freq;
if (freq <= 0) { if (freq <= 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No Listen/Operating frequency known for the peer "
"P2P: No Listen/Operating frequency known for the " MACSTR " to send Invitation Request",
"peer " MACSTR " to send Invitation Request",
MAC2STR(dev->info.p2p_device_addr)); MAC2STR(dev->info.p2p_device_addr));
return -1; return -1;
} }
@ -500,8 +460,7 @@ int p2p_invite_send(struct p2p_data *p2p, struct p2p_device *dev,
return -1; return -1;
if (p2p->state != P2P_IDLE) if (p2p->state != P2P_IDLE)
p2p_stop_listen_for_freq(p2p, freq); p2p_stop_listen_for_freq(p2p, freq);
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Sending Invitation Request");
"P2P: Sending Invitation Request");
p2p_set_state(p2p, P2P_INVITE); p2p_set_state(p2p, P2P_INVITE);
p2p->pending_action_state = P2P_PENDING_INVITATION_REQUEST; p2p->pending_action_state = P2P_PENDING_INVITATION_REQUEST;
p2p->invite_peer = dev; 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, if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
p2p->cfg->dev_addr, dev->info.p2p_device_addr, p2p->cfg->dev_addr, dev->info.p2p_device_addr,
wpabuf_head(req), wpabuf_len(req), 200) < 0) { wpabuf_head(req), wpabuf_len(req), 200) < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Failed to send Action frame");
"P2P: Failed to send Action frame");
/* Use P2P find to recover and retry */ /* Use P2P find to recover and retry */
p2p_set_timeout(p2p, 0, 0); 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) void p2p_invitation_req_cb(struct p2p_data *p2p, int success)
{ {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Invitation Request TX callback: success=%d", success);
"P2P: Invitation Request TX callback: success=%d", success);
if (p2p->invite_peer == NULL) { if (p2p->invite_peer == NULL) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No pending Invite");
"P2P: No pending Invite");
return; 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) void p2p_invitation_resp_cb(struct p2p_data *p2p, int success)
{ {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Invitation Response TX callback: success=%d", success);
"P2P: Invitation Response TX callback: success=%d", success);
p2p->cfg->send_action_done(p2p->cfg->cb_ctx); p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
if (!success) if (!success)
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Assume Invitation Response was actually received by the peer even though Ack was not reported");
"P2P: Assume Invitation Response was actually "
"received by the peer even though Ack was not "
"reported");
if (p2p->cfg->invitation_received) { if (p2p->cfg->invitation_received) {
p2p->cfg->invitation_received(p2p->cfg->cb_ctx, 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; struct p2p_device *dev;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Request to invite peer " MACSTR " role=%d persistent=%d "
"P2P: Request to invite peer " MACSTR " role=%d persistent=%d "
"force_freq=%u", "force_freq=%u",
MAC2STR(peer), role, persistent_group, force_freq); MAC2STR(peer), role, persistent_group, force_freq);
if (bssid) if (bssid)
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Invitation for BSSID " MACSTR, MAC2STR(bssid));
"P2P: Invitation for BSSID " MACSTR, MAC2STR(bssid));
if (go_dev_addr) { if (go_dev_addr) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Invitation for GO Device Address " MACSTR,
"P2P: Invitation for GO Device Address " MACSTR,
MAC2STR(go_dev_addr)); MAC2STR(go_dev_addr));
os_memcpy(p2p->invite_go_dev_addr_buf, go_dev_addr, ETH_ALEN); os_memcpy(p2p->invite_go_dev_addr_buf, go_dev_addr, ETH_ALEN);
p2p->invite_go_dev_addr = p2p->invite_go_dev_addr_buf; p2p->invite_go_dev_addr = p2p->invite_go_dev_addr_buf;
} else } else
p2p->invite_go_dev_addr = NULL; 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); ssid, ssid_len);
dev = p2p_get_device(p2p, peer); dev = p2p_get_device(p2p, peer);
if (dev == NULL || (dev->listen_freq <= 0 && dev->oper_freq <= 0)) { if (dev == NULL || (dev->listen_freq <= 0 && dev->oper_freq <= 0)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Cannot invite unknown P2P Device " MACSTR,
"P2P: Cannot invite unknown P2P Device " MACSTR,
MAC2STR(peer)); MAC2STR(peer));
return -1; 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->flags & P2P_DEV_GROUP_CLIENT_ONLY) {
if (!(dev->info.dev_capab & if (!(dev->info.dev_capab &
P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) { P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Cannot invite a P2P Device " MACSTR
"P2P: Cannot invite a P2P Device " MACSTR
" that is in a group and is not discoverable", " that is in a group and is not discoverable",
MAC2STR(peer)); MAC2STR(peer));
} }

View file

@ -141,22 +141,19 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa,
if (p2p_parse(data, len, &msg)) if (p2p_parse(data, len, &msg))
return; return;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Received Provision Discovery Request from " MACSTR
"P2P: Received Provision Discovery Request from " MACSTR
" with config methods 0x%x (freq=%d)", " with config methods 0x%x (freq=%d)",
MAC2STR(sa), msg.wps_config_methods, rx_freq); MAC2STR(sa), msg.wps_config_methods, rx_freq);
dev = p2p_get_device(p2p, sa); dev = p2p_get_device(p2p, sa);
if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) { if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Provision Discovery Request from unknown peer "
"P2P: Provision Discovery Request from " MACSTR, MAC2STR(sa));
"unknown peer " MACSTR, MAC2STR(sa));
if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data + 1, len - 1, if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data + 1, len - 1,
0)) { 0)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Provision Discovery Request add device failed "
"P2P: Provision Discovery Request add device " MACSTR, MAC2STR(sa));
"failed " MACSTR, MAC2STR(sa));
} }
} else if (msg.wfd_subelems) { } else if (msg.wfd_subelems) {
wpabuf_free(dev->info.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 & if (!(msg.wps_config_methods &
(WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD | (WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD |
WPS_CONFIG_PUSHBUTTON))) { WPS_CONFIG_PUSHBUTTON))) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Unsupported " p2p_dbg(p2p, "Unsupported Config Methods in Provision Discovery Request");
"Config Methods in Provision Discovery Request");
goto out; goto out;
} }
@ -180,8 +176,7 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa,
break; break;
} }
if (i == p2p->num_groups) { if (i == p2p->num_groups) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: PD " p2p_dbg(p2p, "PD request for unknown P2P Group ID - reject");
"request for unknown P2P Group ID - reject");
goto out; 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 | dev->flags &= ~(P2P_DEV_PD_PEER_DISPLAY |
P2P_DEV_PD_PEER_KEYPAD); P2P_DEV_PD_PEER_KEYPAD);
if (msg.wps_config_methods & WPS_CONFIG_DISPLAY) { 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)); " requested us to show a PIN on display", MAC2STR(sa));
if (dev) if (dev)
dev->flags |= P2P_DEV_PD_PEER_KEYPAD; dev->flags |= P2P_DEV_PD_PEER_KEYPAD;
} else if (msg.wps_config_methods & WPS_CONFIG_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", " requested us to write its PIN using keypad",
MAC2STR(sa)); MAC2STR(sa));
if (dev) if (dev)
@ -212,16 +207,14 @@ out:
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; return;
} }
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Sending Provision Discovery Response");
"P2P: Sending Provision Discovery Response");
if (rx_freq > 0) if (rx_freq > 0)
freq = rx_freq; freq = rx_freq;
else else
freq = p2p_channel_to_freq(p2p->cfg->reg_class, freq = p2p_channel_to_freq(p2p->cfg->reg_class,
p2p->cfg->channel); p2p->cfg->channel);
if (freq < 0) { if (freq < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unknown regulatory class/channel");
"P2P: Unknown regulatory class/channel");
wpabuf_free(resp); wpabuf_free(resp);
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; return;
@ -230,8 +223,7 @@ out:
if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr, if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
p2p->cfg->dev_addr, p2p->cfg->dev_addr,
wpabuf_head(resp), wpabuf_len(resp), 200) < 0) { wpabuf_head(resp), wpabuf_len(resp), 200) < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Failed to send Action frame");
"P2P: Failed to send Action frame");
} }
wpabuf_free(resp); 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)) if (p2p_parse(data, len, &msg))
return; return;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Received Provision Discovery Response from " MACSTR
"P2P: Received Provision Discovery Response from " MACSTR
" with config methods 0x%x", " with config methods 0x%x",
MAC2STR(sa), msg.wps_config_methods); MAC2STR(sa), msg.wps_config_methods);
dev = p2p_get_device(p2p, sa); dev = p2p_get_device(p2p, sa);
if (dev == NULL || !dev->req_config_methods) { if (dev == NULL || !dev->req_config_methods) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Ignore Provision Discovery Response from " MACSTR
"P2P: Ignore Provision Discovery Response from " " with no pending request", MAC2STR(sa));
MACSTR " with no pending request", MAC2STR(sa));
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; return;
} }
if (dev->dialog_token != msg.dialog_token) { if (dev->dialog_token != msg.dialog_token) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Ignore Provision Discovery Response with unexpected Dialog Token %u (expected %u)",
"P2P: Ignore Provision Discovery Response with "
"unexpected Dialog Token %u (expected %u)",
msg.dialog_token, dev->dialog_token); msg.dialog_token, dev->dialog_token);
p2p_parse_free(&msg); p2p_parse_free(&msg);
return; return;
@ -307,9 +295,7 @@ void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa,
p2p_reset_pending_pd(p2p); p2p_reset_pending_pd(p2p);
if (msg.wps_config_methods != req_config_methods) { if (msg.wps_config_methods != req_config_methods) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer rejected " p2p_dbg(p2p, "Peer rejected our Provision Discovery Request (received config_methods 0x%x expected 0x%x",
"our Provision Discovery Request (received "
"config_methods 0x%x expected 0x%x",
msg.wps_config_methods, req_config_methods); msg.wps_config_methods, req_config_methods);
if (p2p->cfg->prov_disc_fail) if (p2p->cfg->prov_disc_fail)
p2p->cfg->prov_disc_fail(p2p->cfg->cb_ctx, sa, 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 | dev->flags &= ~(P2P_DEV_PD_PEER_DISPLAY |
P2P_DEV_PD_PEER_KEYPAD); P2P_DEV_PD_PEER_KEYPAD);
if (req_config_methods & WPS_CONFIG_DISPLAY) { 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)); " accepted to show a PIN on display", MAC2STR(sa));
dev->flags |= P2P_DEV_PD_PEER_DISPLAY; dev->flags |= P2P_DEV_PD_PEER_DISPLAY;
} else if (msg.wps_config_methods & WPS_CONFIG_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
" accepted to write our PIN using keypad", " accepted to write our PIN using keypad",
MAC2STR(sa)); MAC2STR(sa));
dev->flags |= P2P_DEV_PD_PEER_KEYPAD; dev->flags |= P2P_DEV_PD_PEER_KEYPAD;
@ -342,10 +328,8 @@ out:
dev->req_config_methods = 0; dev->req_config_methods = 0;
p2p->cfg->send_action_done(p2p->cfg->cb_ctx); p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
if (dev->flags & P2P_DEV_PD_BEFORE_GO_NEG) { if (dev->flags & P2P_DEV_PD_BEFORE_GO_NEG) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Start GO Neg after the PD-before-GO-Neg workaround with "
"P2P: Start GO Neg after the PD-before-GO-Neg " MACSTR, MAC2STR(dev->info.p2p_device_addr));
"workaround with " MACSTR,
MAC2STR(dev->info.p2p_device_addr));
dev->flags &= ~P2P_DEV_PD_BEFORE_GO_NEG; dev->flags &= ~P2P_DEV_PD_BEFORE_GO_NEG;
p2p_connect_send(p2p, dev); p2p_connect_send(p2p, dev);
return; 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 : freq = dev->listen_freq > 0 ? dev->listen_freq :
dev->oper_freq; dev->oper_freq;
if (freq <= 0) { if (freq <= 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No Listen/Operating frequency known for the peer "
"P2P: No Listen/Operating frequency known for the " MACSTR " to send Provision Discovery Request",
"peer " MACSTR " to send Provision Discovery Request",
MAC2STR(dev->info.p2p_device_addr)); MAC2STR(dev->info.p2p_device_addr));
return -1; 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->flags & P2P_DEV_GROUP_CLIENT_ONLY) {
if (!(dev->info.dev_capab & if (!(dev->info.dev_capab &
P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) { P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Cannot use PD with P2P Device " MACSTR
"P2P: Cannot use PD with P2P Device " MACSTR
" that is in a group and is not discoverable", " that is in a group and is not discoverable",
MAC2STR(dev->info.p2p_device_addr)); MAC2STR(dev->info.p2p_device_addr));
return -1; 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, if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
p2p->cfg->dev_addr, dev->info.p2p_device_addr, p2p->cfg->dev_addr, dev->info.p2p_device_addr,
wpabuf_head(req), wpabuf_len(req), 200) < 0) { wpabuf_head(req), wpabuf_len(req), 200) < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Failed to send Action frame");
"P2P: Failed to send Action frame");
wpabuf_free(req); wpabuf_free(req);
return -1; return -1;
} }
@ -427,14 +408,13 @@ int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr,
if (dev == NULL) if (dev == NULL)
dev = p2p_get_device_interface(p2p, peer_addr); dev = p2p_get_device_interface(p2p, peer_addr);
if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) { if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Provision " p2p_dbg(p2p, "Provision Discovery Request destination " MACSTR
"Discovery Request destination " MACSTR
" not yet known", MAC2STR(peer_addr)); " not yet known", MAC2STR(peer_addr));
return -1; return -1;
} }
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Provision Discovery " p2p_dbg(p2p, "Provision Discovery Request with " MACSTR
"Request with " MACSTR " (config methods 0x%x)", " (config methods 0x%x)",
MAC2STR(peer_addr), config_methods); MAC2STR(peer_addr), config_methods);
if (config_methods == 0) if (config_methods == 0)
return -1; 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 && if (p2p->state != P2P_IDLE && p2p->state != P2P_SEARCH &&
p2p->state != P2P_LISTEN_ONLY) { p2p->state != P2P_LISTEN_ONLY) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Busy with other " p2p_dbg(p2p, "Busy with other operations; postpone Provision Discovery Request with "
"operations; postpone Provision Discovery Request " MACSTR " (config methods 0x%x)",
"with " MACSTR " (config methods 0x%x)",
MAC2STR(peer_addr), config_methods); MAC2STR(peer_addr), config_methods);
return 0; return 0;
} }

View 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; p2p->pending_action_state = P2P_NO_PENDING_ACTION;
if (p2p_send_action(p2p, freq, dst, p2p->cfg->dev_addr, dst, if (p2p_send_action(p2p, freq, dst, p2p->cfg->dev_addr, dst,
wpabuf_head(req), wpabuf_len(req), 200) < 0) wpabuf_head(req), wpabuf_len(req), 200) < 0)
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Failed to send Action frame");
"P2P: Failed to send Action frame");
wpabuf_free(req); 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; freq = dev->listen_freq > 0 ? dev->listen_freq : dev->oper_freq;
if (freq <= 0) { if (freq <= 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "No Listen/Operating frequency known for the peer "
"P2P: No Listen/Operating frequency known for the " MACSTR " to send SD Request",
"peer " MACSTR " to send SD Request",
MAC2STR(dev->info.p2p_device_addr)); MAC2STR(dev->info.p2p_device_addr));
return -1; return -1;
} }
@ -246,8 +244,7 @@ int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev)
if (query == NULL) if (query == NULL)
return -1; return -1;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Start Service Discovery with " MACSTR,
"P2P: Start Service Discovery with " MACSTR,
MAC2STR(dev->info.p2p_device_addr)); MAC2STR(dev->info.p2p_device_addr));
req = p2p_build_sd_query(p2p->srv_update_indic, query->tlvs); 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, if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
p2p->cfg->dev_addr, dev->info.p2p_device_addr, p2p->cfg->dev_addr, dev->info.p2p_device_addr,
wpabuf_head(req), wpabuf_len(req), 5000) < 0) { wpabuf_head(req), wpabuf_len(req), 5000) < 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Failed to send Action frame");
"P2P: Failed to send Action frame");
ret = -1; ret = -1;
} }
@ -299,14 +295,12 @@ void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
return; return;
dialog_token = *pos++; dialog_token = *pos++;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "GAS Initial Request from " MACSTR
"P2P: GAS Initial Request from " MACSTR " (dialog token %u, " " (dialog token %u, freq %d)",
"freq %d)",
MAC2STR(sa), dialog_token, rx_freq); MAC2STR(sa), dialog_token, rx_freq);
if (*pos != WLAN_EID_ADV_PROTO) { if (*pos != WLAN_EID_ADV_PROTO) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unexpected IE in GAS Initial Request: %u", *pos);
"P2P: Unexpected IE in GAS Initial Request: %u", *pos);
return; return;
} }
pos++; pos++;
@ -314,15 +308,13 @@ void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
slen = *pos++; slen = *pos++;
next = pos + slen; next = pos + slen;
if (next > end || slen < 2) { if (next > end || slen < 2) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Invalid IE in GAS Initial Request");
"P2P: Invalid IE in GAS Initial Request");
return; return;
} }
pos++; /* skip QueryRespLenLimit and PAME-BI */ pos++; /* skip QueryRespLenLimit and PAME-BI */
if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) { if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
"P2P: Unsupported GAS advertisement protocol id %u",
*pos); *pos);
return; return;
} }
@ -341,8 +333,7 @@ void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
if (pos + 4 > end) if (pos + 4 > end)
return; return;
if (WPA_GET_LE16(pos) != ANQP_VENDOR_SPECIFIC) { if (WPA_GET_LE16(pos) != ANQP_VENDOR_SPECIFIC) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
"P2P: Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
return; return;
} }
pos += 2; pos += 2;
@ -350,21 +341,18 @@ void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
slen = WPA_GET_LE16(pos); slen = WPA_GET_LE16(pos);
pos += 2; pos += 2;
if (pos + slen > end || slen < 3 + 1) { if (pos + slen > end || slen < 3 + 1) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Invalid ANQP Query Request length");
"P2P: Invalid ANQP Query Request length");
return; return;
} }
if (WPA_GET_BE24(pos) != OUI_WFA) { if (WPA_GET_BE24(pos) != OUI_WFA) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unsupported ANQP OUI %06x", WPA_GET_BE24(pos));
"P2P: Unsupported ANQP OUI %06x", WPA_GET_BE24(pos));
return; return;
} }
pos += 3; pos += 3;
if (*pos != P2P_OUI_TYPE) { if (*pos != P2P_OUI_TYPE) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unsupported ANQP vendor type %u", *pos);
"P2P: Unsupported ANQP vendor type %u", *pos);
return; return;
} }
pos++; pos++;
@ -372,8 +360,7 @@ void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
if (pos + 2 > end) if (pos + 2 > end)
return; return;
update_indic = WPA_GET_LE16(pos); update_indic = WPA_GET_LE16(pos);
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Service Update Indicator: %u", update_indic);
"P2P: Service Update Indicator: %u", update_indic);
pos += 2; pos += 2;
p2p->cfg->sd_request(p2p->cfg->cb_ctx, freq, sa, dialog_token, 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 */ /* TODO: fix the length limit to match with the maximum frame length */
if (wpabuf_len(resp_tlvs) > 1400) { if (wpabuf_len(resp_tlvs) > 1400) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: SD response long " p2p_dbg(p2p, "SD response long enough to require fragmentation");
"enough to require fragmentation");
if (p2p->sd_resp) { if (p2p->sd_resp) {
/* /*
* TODO: Could consider storing the fragmented response * 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 * Though, that would eat more memory, so there are
* also benefits to just using a single buffer. * also benefits to just using a single buffer.
*/ */
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Drop " p2p_dbg(p2p, "Drop previous SD response");
"previous SD response");
wpabuf_free(p2p->sd_resp); wpabuf_free(p2p->sd_resp);
} }
p2p->sd_resp = wpabuf_dup(resp_tlvs); p2p->sd_resp = wpabuf_dup(resp_tlvs);
if (p2p->sd_resp == NULL) { if (p2p->sd_resp == NULL) {
wpa_msg(p2p->cfg->msg_ctx, MSG_ERROR, "P2P: Failed to " p2p_err(p2p, "Failed to allocate SD response fragmentation area");
"allocate SD response fragmentation area");
return; return;
} }
os_memcpy(p2p->sd_resp_addr, dst, ETH_ALEN); 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, resp = p2p_build_sd_response(dialog_token, WLAN_STATUS_SUCCESS,
1, p2p->srv_update_indic, NULL); 1, p2p->srv_update_indic, NULL);
} else { } else {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: SD response fits " p2p_dbg(p2p, "SD response fits in initial response");
"in initial response");
resp = p2p_build_sd_response(dialog_token, resp = p2p_build_sd_response(dialog_token,
WLAN_STATUS_SUCCESS, 0, WLAN_STATUS_SUCCESS, 0,
p2p->srv_update_indic, resp_tlvs); 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, if (p2p_send_action(p2p, freq, dst, p2p->cfg->dev_addr,
p2p->cfg->dev_addr, p2p->cfg->dev_addr,
wpabuf_head(resp), wpabuf_len(resp), 200) < 0) wpabuf_head(resp), wpabuf_len(resp), 200) < 0)
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Failed to send Action frame");
"P2P: Failed to send Action frame");
wpabuf_free(resp); 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 || if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) { os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Ignore unexpected GAS Initial Response from "
"P2P: Ignore unexpected GAS Initial Response from "
MACSTR, MAC2STR(sa)); MACSTR, MAC2STR(sa));
return; return;
} }
p2p->cfg->send_action_done(p2p->cfg->cb_ctx); p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
p2p_clear_timeout(p2p); p2p_clear_timeout(p2p);
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Received GAS Initial Response from " MACSTR " (len=%d)",
"P2P: Received GAS Initial Response from " MACSTR " (len=%d)",
MAC2STR(sa), (int) len); MAC2STR(sa), (int) len);
if (len < 5 + 2) { if (len < 5 + 2) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Too short GAS Initial Response frame");
"P2P: Too short GAS Initial Response frame");
return; return;
} }
@ -474,20 +453,16 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
pos += 2; pos += 2;
comeback_delay = WPA_GET_LE16(pos); comeback_delay = WPA_GET_LE16(pos);
pos += 2; pos += 2;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "dialog_token=%u status_code=%u comeback_delay=%u",
"P2P: dialog_token=%u status_code=%u comeback_delay=%u",
dialog_token, status_code, comeback_delay); dialog_token, status_code, comeback_delay);
if (status_code) { if (status_code) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Service Discovery failed: status code %u",
"P2P: Service Discovery failed: status code %u",
status_code); status_code);
return; return;
} }
if (*pos != WLAN_EID_ADV_PROTO) { if (*pos != WLAN_EID_ADV_PROTO) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unexpected IE in GAS Initial Response: %u", *pos);
"P2P: Unexpected IE in GAS Initial Response: %u",
*pos);
return; return;
} }
pos++; pos++;
@ -495,15 +470,13 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
slen = *pos++; slen = *pos++;
next = pos + slen; next = pos + slen;
if (next > end || slen < 2) { if (next > end || slen < 2) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Invalid IE in GAS Initial Response");
"P2P: Invalid IE in GAS Initial Response");
return; return;
} }
pos++; /* skip QueryRespLenLimit and PAME-BI */ pos++; /* skip QueryRespLenLimit and PAME-BI */
if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) { if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
"P2P: Unsupported GAS advertisement protocol id %u",
*pos); *pos);
return; return;
} }
@ -511,27 +484,22 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
pos = next; pos = next;
/* Query Response */ /* Query Response */
if (pos + 2 > end) { if (pos + 2 > end) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Too short Query " p2p_dbg(p2p, "Too short Query Response");
"Response");
return; return;
} }
slen = WPA_GET_LE16(pos); slen = WPA_GET_LE16(pos);
pos += 2; pos += 2;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Query Response Length: %d", p2p_dbg(p2p, "Query Response Length: %d", slen);
slen);
if (pos + slen > end) { if (pos + slen > end) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Not enough Query " p2p_dbg(p2p, "Not enough Query Response data");
"Response data");
return; return;
} }
end = pos + slen; end = pos + slen;
if (comeback_delay) { if (comeback_delay) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Fragmented " p2p_dbg(p2p, "Fragmented response - request fragments");
"response - request fragments");
if (p2p->sd_rx_resp) { if (p2p->sd_rx_resp) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Drop " p2p_dbg(p2p, "Drop old SD reassembly buffer");
"old SD reassembly buffer");
wpabuf_free(p2p->sd_rx_resp); wpabuf_free(p2p->sd_rx_resp);
p2p->sd_rx_resp = NULL; 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) if (pos + 4 > end)
return; return;
if (WPA_GET_LE16(pos) != ANQP_VENDOR_SPECIFIC) { if (WPA_GET_LE16(pos) != ANQP_VENDOR_SPECIFIC) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
"P2P: Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
return; return;
} }
pos += 2; pos += 2;
@ -552,21 +519,18 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
slen = WPA_GET_LE16(pos); slen = WPA_GET_LE16(pos);
pos += 2; pos += 2;
if (pos + slen > end || slen < 3 + 1) { if (pos + slen > end || slen < 3 + 1) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Invalid ANQP Query Response length");
"P2P: Invalid ANQP Query Response length");
return; return;
} }
if (WPA_GET_BE24(pos) != OUI_WFA) { if (WPA_GET_BE24(pos) != OUI_WFA) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unsupported ANQP OUI %06x", WPA_GET_BE24(pos));
"P2P: Unsupported ANQP OUI %06x", WPA_GET_BE24(pos));
return; return;
} }
pos += 3; pos += 3;
if (*pos != P2P_OUI_TYPE) { if (*pos != P2P_OUI_TYPE) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unsupported ANQP vendor type %u", *pos);
"P2P: Unsupported ANQP vendor type %u", *pos);
return; return;
} }
pos++; pos++;
@ -574,8 +538,7 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
if (pos + 2 > end) if (pos + 2 > end)
return; return;
update_indic = WPA_GET_LE16(pos); update_indic = WPA_GET_LE16(pos);
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Service Update Indicator: %u", update_indic);
"P2P: Service Update Indicator: %u", update_indic);
pos += 2; pos += 2;
p2p->sd_peer->flags |= P2P_DEV_SD_INFO; 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) {
if (!p2p->sd_query->for_all_peers) { if (!p2p->sd_query->for_all_peers) {
struct p2p_sd_query *q; struct p2p_sd_query *q;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Remove completed SD query %p",
"P2P: Remove completed SD query %p",
p2p->sd_query); p2p->sd_query);
q = p2p->sd_query; q = p2p->sd_query;
p2p_unlink_sd_query(p2p, 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) if (len < 1)
return; return;
dialog_token = *data; dialog_token = *data;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Dialog Token: %u", p2p_dbg(p2p, "Dialog Token: %u", dialog_token);
dialog_token);
if (dialog_token != p2p->sd_resp_dialog_token) { if (dialog_token != p2p->sd_resp_dialog_token) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No pending SD " p2p_dbg(p2p, "No pending SD response fragment for dialog token %u",
"response fragment for dialog token %u", dialog_token); dialog_token);
return; return;
} }
if (p2p->sd_resp == NULL) { if (p2p->sd_resp == NULL) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No pending SD " p2p_dbg(p2p, "No pending SD response fragment available");
"response fragment available");
return; return;
} }
if (os_memcmp(sa, p2p->sd_resp_addr, ETH_ALEN) != 0) { if (os_memcmp(sa, p2p->sd_resp_addr, ETH_ALEN) != 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No pending SD " p2p_dbg(p2p, "No pending SD response fragment for " MACSTR,
"response fragment for " MACSTR, MAC2STR(sa)); MAC2STR(sa));
return; return;
} }
@ -646,19 +606,16 @@ void p2p_rx_gas_comeback_req(struct p2p_data *p2p, const u8 *sa,
wpabuf_len(p2p->sd_resp)); wpabuf_len(p2p->sd_resp));
if (resp == NULL) if (resp == NULL)
return; return;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Send GAS Comeback " p2p_dbg(p2p, "Send GAS Comeback Response (frag_id %d more=%d frag_len=%d)",
"Response (frag_id %d more=%d frag_len=%d)",
p2p->sd_frag_id, more, (int) frag_len); p2p->sd_frag_id, more, (int) frag_len);
p2p->sd_frag_id++; p2p->sd_frag_id++;
p2p->sd_resp_pos += frag_len; p2p->sd_resp_pos += frag_len;
if (more) { if (more) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: %d more bytes " p2p_dbg(p2p, "%d more bytes remain to be sent",
"remain to be sent",
(int) (wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos)); (int) (wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos));
} else { } else {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: All fragments of " p2p_dbg(p2p, "All fragments of SD response sent");
"SD response sent");
wpabuf_free(p2p->sd_resp); wpabuf_free(p2p->sd_resp);
p2p->sd_resp = NULL; 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, if (p2p_send_action(p2p, rx_freq, sa, p2p->cfg->dev_addr,
p2p->cfg->dev_addr, p2p->cfg->dev_addr,
wpabuf_head(resp), wpabuf_len(resp), 200) < 0) wpabuf_head(resp), wpabuf_len(resp), 200) < 0)
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Failed to send Action frame");
"P2P: Failed to send Action frame");
wpabuf_free(resp); 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 || if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) { os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Ignore unexpected GAS Comeback Response from "
"P2P: Ignore unexpected GAS Comeback Response from "
MACSTR, MAC2STR(sa)); MACSTR, MAC2STR(sa));
return; return;
} }
p2p->cfg->send_action_done(p2p->cfg->cb_ctx); p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
p2p_clear_timeout(p2p); p2p_clear_timeout(p2p);
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Received GAS Comeback Response from " MACSTR " (len=%d)",
"P2P: Received GAS Comeback Response from " MACSTR " (len=%d)",
MAC2STR(sa), (int) len); MAC2STR(sa), (int) len);
if (len < 6 + 2) { if (len < 6 + 2) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Too short GAS Comeback Response frame");
"P2P: Too short GAS Comeback Response frame");
return; return;
} }
@ -718,22 +671,19 @@ void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
pos++; pos++;
comeback_delay = WPA_GET_LE16(pos); comeback_delay = WPA_GET_LE16(pos);
pos += 2; pos += 2;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "dialog_token=%u status_code=%u frag_id=%d more_frags=%d "
"P2P: dialog_token=%u status_code=%u frag_id=%d more_frags=%d "
"comeback_delay=%u", "comeback_delay=%u",
dialog_token, status_code, frag_id, more_frags, dialog_token, status_code, frag_id, more_frags,
comeback_delay); comeback_delay);
/* TODO: check frag_id match */ /* TODO: check frag_id match */
if (status_code) { if (status_code) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Service Discovery failed: status code %u",
"P2P: Service Discovery failed: status code %u",
status_code); status_code);
return; return;
} }
if (*pos != WLAN_EID_ADV_PROTO) { if (*pos != WLAN_EID_ADV_PROTO) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unexpected IE in GAS Comeback Response: %u",
"P2P: Unexpected IE in GAS Comeback Response: %u",
*pos); *pos);
return; return;
} }
@ -742,15 +692,13 @@ void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
slen = *pos++; slen = *pos++;
next = pos + slen; next = pos + slen;
if (next > end || slen < 2) { if (next > end || slen < 2) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Invalid IE in GAS Comeback Response");
"P2P: Invalid IE in GAS Comeback Response");
return; return;
} }
pos++; /* skip QueryRespLenLimit and PAME-BI */ pos++; /* skip QueryRespLenLimit and PAME-BI */
if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) { if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
"P2P: Unsupported GAS advertisement protocol id %u",
*pos); *pos);
return; return;
} }
@ -758,22 +706,18 @@ void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
pos = next; pos = next;
/* Query Response */ /* Query Response */
if (pos + 2 > end) { if (pos + 2 > end) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Too short Query " p2p_dbg(p2p, "Too short Query Response");
"Response");
return; return;
} }
slen = WPA_GET_LE16(pos); slen = WPA_GET_LE16(pos);
pos += 2; pos += 2;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Query Response Length: %d", p2p_dbg(p2p, "Query Response Length: %d", slen);
slen);
if (pos + slen > end) { if (pos + slen > end) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Not enough Query " p2p_dbg(p2p, "Not enough Query Response data");
"Response data");
return; return;
} }
if (slen == 0) { if (slen == 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No Query Response " p2p_dbg(p2p, "No Query Response data");
"data");
return; return;
} }
end = pos + slen; end = pos + slen;
@ -790,34 +734,29 @@ void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
if (pos + 4 > end) if (pos + 4 > end)
return; return;
if (WPA_GET_LE16(pos) != ANQP_VENDOR_SPECIFIC) { if (WPA_GET_LE16(pos) != ANQP_VENDOR_SPECIFIC) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
"P2P: Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
return; return;
} }
pos += 2; pos += 2;
slen = WPA_GET_LE16(pos); slen = WPA_GET_LE16(pos);
pos += 2; pos += 2;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: ANQP Query Response " p2p_dbg(p2p, "ANQP Query Response length: %u", slen);
"length: %u", slen);
if (slen < 3 + 1) { if (slen < 3 + 1) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Invalid ANQP Query Response length");
"P2P: Invalid ANQP Query Response length");
return; return;
} }
if (pos + 4 > end) if (pos + 4 > end)
return; return;
if (WPA_GET_BE24(pos) != OUI_WFA) { if (WPA_GET_BE24(pos) != OUI_WFA) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unsupported ANQP OUI %06x", WPA_GET_BE24(pos));
"P2P: Unsupported ANQP OUI %06x", WPA_GET_BE24(pos));
return; return;
} }
pos += 3; pos += 3;
if (*pos != P2P_OUI_TYPE) { if (*pos != P2P_OUI_TYPE) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Unsupported ANQP vendor type %u", *pos);
"P2P: Unsupported ANQP vendor type %u", *pos);
return; return;
} }
pos++; pos++;
@ -825,27 +764,23 @@ void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
if (pos + 2 > end) if (pos + 2 > end)
return; return;
p2p->sd_rx_update_indic = WPA_GET_LE16(pos); p2p->sd_rx_update_indic = WPA_GET_LE16(pos);
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Service Update Indicator: %u", p2p->sd_rx_update_indic);
"P2P: Service Update Indicator: %u", p2p->sd_rx_update_indic);
pos += 2; pos += 2;
skip_nqp_header: skip_nqp_header:
if (wpabuf_resize(&p2p->sd_rx_resp, end - pos) < 0) if (wpabuf_resize(&p2p->sd_rx_resp, end - pos) < 0)
return; return;
wpabuf_put_data(p2p->sd_rx_resp, pos, end - pos); wpabuf_put_data(p2p->sd_rx_resp, pos, end - pos);
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Current SD reassembly " p2p_dbg(p2p, "Current SD reassembly buffer length: %u",
"buffer length: %u",
(unsigned int) wpabuf_len(p2p->sd_rx_resp)); (unsigned int) wpabuf_len(p2p->sd_rx_resp));
if (more_frags) { if (more_frags) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: More fragments " p2p_dbg(p2p, "More fragments remains");
"remains");
/* TODO: what would be a good size limit? */ /* TODO: what would be a good size limit? */
if (wpabuf_len(p2p->sd_rx_resp) > 64000) { if (wpabuf_len(p2p->sd_rx_resp) > 64000) {
wpabuf_free(p2p->sd_rx_resp); wpabuf_free(p2p->sd_rx_resp);
p2p->sd_rx_resp = NULL; p2p->sd_rx_resp = NULL;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Too long " p2p_dbg(p2p, "Too long SD response - drop it");
"SD response - drop it");
return; return;
} }
p2p_send_gas_comeback_req(p2p, sa, dialog_token, rx_freq); 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) {
if (!p2p->sd_query->for_all_peers) { if (!p2p->sd_query->for_all_peers) {
struct p2p_sd_query *q; struct p2p_sd_query *q;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Remove completed SD query %p",
"P2P: Remove completed SD query %p",
p2p->sd_query); p2p->sd_query);
q = p2p->sd_query; q = p2p->sd_query;
p2p_unlink_sd_query(p2p, 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; q->next = p2p->sd_queries;
p2p->sd_queries = q; 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) { if (dst == NULL) {
struct p2p_device *dev; 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) int p2p_sd_cancel_request(struct p2p_data *p2p, void *req)
{ {
if (p2p_unlink_sd_query(p2p, req)) { if (p2p_unlink_sd_query(p2p, req)) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, p2p_dbg(p2p, "Cancel pending SD query %p", req);
"P2P: Cancel pending SD query %p", req);
p2p_free_sd_query(req); p2p_free_sd_query(req);
return 0; return 0;
} }

View 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 * wpas_p2p_init - Initialize P2P module for %wpa_supplicant
* @global: Pointer to global data from wpa_supplicant_init() * @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)); os_memset(&p2p, 0, sizeof(p2p));
p2p.msg_ctx = wpa_s;
p2p.cb_ctx = wpa_s; p2p.cb_ctx = wpa_s;
p2p.debug_print = wpas_p2p_debug_print;
p2p.p2p_scan = wpas_p2p_scan; p2p.p2p_scan = wpas_p2p_scan;
p2p.send_action = wpas_send_action; p2p.send_action = wpas_send_action;
p2p.send_action_done = wpas_send_action_done; p2p.send_action_done = wpas_send_action_done;