size_t len;
struct wpabuf *buf;
int ret;
+ char *freq;
+ int forced_freq = 0;
+
+ freq = strstr(pos, " freq=");
+ if (freq) {
+ *freq = '\0';
+ freq += 6;
+ forced_freq = atoi(freq);
+ }
len = os_strlen(pos);
if (len & 0x01)
return -1;
}
- ret = wpas_wps_nfc_tag_read(wpa_s, buf);
+ ret = wpas_wps_nfc_tag_read(wpa_s, buf, forced_freq);
wpabuf_free(buf);
return ret;
struct wpabuf *req, *sel;
int ret;
char *pos, *role, *type, *pos2;
+ char *freq;
+ int forced_freq = 0;
+
+ freq = strstr(cmd, " freq=");
+ if (freq) {
+ *freq = '\0';
+ freq += 6;
+ forced_freq = atoi(freq);
+ }
role = cmd;
pos = os_strchr(role, ' ');
ret = wpas_er_wps_nfc_report_handover(wpa_s, req, sel);
} else if (os_strcmp(role, "INIT") == 0 && os_strcmp(type, "P2P") == 0)
{
- ret = wpas_p2p_nfc_report_handover(wpa_s, 1, req, sel);
+ ret = wpas_p2p_nfc_report_handover(wpa_s, 1, req, sel, 0);
} else if (os_strcmp(role, "RESP") == 0 && os_strcmp(type, "P2P") == 0)
{
- ret = wpas_p2p_nfc_report_handover(wpa_s, 0, req, sel);
+ ret = wpas_p2p_nfc_report_handover(wpa_s, 0, req, sel,
+ forced_freq);
} else {
wpa_printf(MSG_DEBUG, "NFC: Unsupported connection handover "
"reported: role=%s type=%s", role, type);
static int wpas_p2p_nfc_init_go_neg(struct wpa_supplicant *wpa_s,
- struct p2p_nfc_params *params)
+ struct p2p_nfc_params *params,
+ int forced_freq)
{
wpa_printf(MSG_DEBUG, "P2P: Initiate GO Negotiation based on NFC "
"connection handover");
return wpas_p2p_connect(wpa_s, params->peer->p2p_device_addr, NULL,
WPS_NFC, 0, 0, 0, 0, wpa_s->conf->p2p_go_intent,
- 0, -1, 0, 1, 1);
+ forced_freq, -1, 0, 1, 1);
}
static int wpas_p2p_nfc_resp_go_neg(struct wpa_supplicant *wpa_s,
- struct p2p_nfc_params *params)
+ struct p2p_nfc_params *params,
+ int forced_freq)
{
int res;
"connection handover");
res = wpas_p2p_connect(wpa_s, params->peer->p2p_device_addr, NULL,
WPS_NFC, 0, 0, 0, 1, wpa_s->conf->p2p_go_intent,
- 0, -1, 0, 1, 1);
+ forced_freq, -1, 0, 1, 1);
if (res)
return res;
static int wpas_p2p_nfc_connection_handover(struct wpa_supplicant *wpa_s,
const struct wpabuf *data,
- int sel, int tag)
+ int sel, int tag, int forced_freq)
{
const u8 *pos, *end;
u16 len, id;
case AUTH_JOIN:
return wpas_p2p_nfc_auth_join(wpa_s, ¶ms, tag);
case INIT_GO_NEG:
- return wpas_p2p_nfc_init_go_neg(wpa_s, ¶ms);
+ return wpas_p2p_nfc_init_go_neg(wpa_s, ¶ms, forced_freq);
case RESP_GO_NEG:
/* TODO: use own OOB Dev Pw */
- return wpas_p2p_nfc_resp_go_neg(wpa_s, ¶ms);
+ return wpas_p2p_nfc_resp_go_neg(wpa_s, ¶ms, forced_freq);
}
return -1;
int wpas_p2p_nfc_tag_process(struct wpa_supplicant *wpa_s,
- const struct wpabuf *data)
+ const struct wpabuf *data, int forced_freq)
{
if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
return -1;
- return wpas_p2p_nfc_connection_handover(wpa_s, data, 1, 1);
+ return wpas_p2p_nfc_connection_handover(wpa_s, data, 1, 1, forced_freq);
}
int wpas_p2p_nfc_report_handover(struct wpa_supplicant *wpa_s, int init,
const struct wpabuf *req,
- const struct wpabuf *sel)
+ const struct wpabuf *sel, int forced_freq)
{
struct wpabuf *tmp;
int ret;
wpabuf_head(req), wpabuf_len(req));
wpa_hexdump_ascii(MSG_DEBUG, "NFC: Sel",
wpabuf_head(sel), wpabuf_len(sel));
+ if (forced_freq)
+ wpa_printf(MSG_DEBUG, "NFC: Forced freq %d", forced_freq);
tmp = ndef_parse_p2p(init ? sel : req);
if (tmp == NULL) {
wpa_printf(MSG_DEBUG, "P2P: Could not parse NDEF");
return -1;
}
- ret = wpas_p2p_nfc_connection_handover(wpa_s, tmp, init, 0);
+ ret = wpas_p2p_nfc_connection_handover(wpa_s, tmp, init, 0,
+ forced_freq);
wpabuf_free(tmp);
return ret;