int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr, struct p2ps_provision *p2ps_prov, u16 config_methods, int join, int force_freq, int user_initiated_pd) { struct p2p_device *dev; dev = p2p_get_device(p2p, peer_addr); if (dev == NULL) { dev = p2p_get_device_interface(p2p, peer_addr); } if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) { p2p_dbg(p2p, "Provision Discovery Request destination " MACSTR " not yet known", MAC2STR(peer_addr)); os_free(p2ps_prov); return -1; } p2p_dbg(p2p, "Provision Discovery Request with " MACSTR " (config methods 0x%x)", MAC2STR(peer_addr), config_methods); if (config_methods == 0 && !p2ps_prov) { os_free(p2ps_prov); return -1; } if (p2ps_prov && p2ps_prov->status == P2P_SC_SUCCESS_DEFERRED && p2p->p2ps_prov) { /* Use cached method from deferred provisioning */ p2ps_prov->method = p2p->p2ps_prov->method; } /* Reset provisioning info */ dev->wps_prov_info = 0; p2ps_prov_free(p2p); p2p->p2ps_prov = p2ps_prov; dev->req_config_methods = config_methods; if (join) { dev->flags |= P2P_DEV_PD_FOR_JOIN; } else { dev->flags &= ~P2P_DEV_PD_FOR_JOIN; } if (p2p->state != P2P_IDLE && p2p->state != P2P_SEARCH && p2p->state != P2P_LISTEN_ONLY) { p2p_dbg(p2p, "Busy with other operations; postpone Provision Discovery Request with " MACSTR " (config methods 0x%x)", MAC2STR(peer_addr), config_methods); return 0; } p2p->user_initiated_pd = user_initiated_pd; p2p->pd_force_freq = force_freq; if (p2p->user_initiated_pd) { p2p->pd_retries = MAX_PROV_DISC_REQ_RETRIES; } /* * Assign dialog token here to use the same value in each retry within * the same PD exchange. */ dev->dialog_token++; if (dev->dialog_token == 0) { dev->dialog_token = 1; } return p2p_send_prov_disc_req(p2p, dev, join, force_freq); }
int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr, u16 config_methods, int join, int force_freq, int user_initiated_pd) { struct p2p_device *dev; dev = p2p_get_device(p2p, peer_addr); if (dev == NULL) dev = p2p_get_device_interface(p2p, peer_addr); if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) { wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Provision " "Discovery Request destination " MACSTR " not yet known", MAC2STR(peer_addr)); return -1; } wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Provision Discovery " "Request with " MACSTR " (config methods 0x%x)", MAC2STR(peer_addr), config_methods); if (config_methods == 0) return -1; /* Reset provisioning info */ dev->wps_prov_info = 0; dev->req_config_methods = config_methods; if (join) dev->flags |= P2P_DEV_PD_FOR_JOIN; else dev->flags &= ~P2P_DEV_PD_FOR_JOIN; if (p2p->state != P2P_IDLE && p2p->state != P2P_SEARCH && p2p->state != P2P_LISTEN_ONLY) { wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Busy with other " "operations; postpone Provision Discovery Request " "with " MACSTR " (config methods 0x%x)", MAC2STR(peer_addr), config_methods); return 0; } p2p->user_initiated_pd = user_initiated_pd; if (p2p->user_initiated_pd) p2p->pd_retries = MAX_PROV_DISC_REQ_RETRIES; /* * Assign dialog token here to use the same value in each retry within * the same PD exchange. */ dev->dialog_token++; if (dev->dialog_token == 0) dev->dialog_token = 1; return p2p_send_prov_disc_req(p2p, dev, join, force_freq); }
int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr, u16 config_methods, int join, int force_freq) { struct p2p_device *dev; dev = p2p_get_device(p2p, peer_addr); if (dev == NULL) dev = p2p_get_device_interface(p2p, peer_addr); if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) { wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Provision " "Discovery Request destination " MACSTR " not yet known", MAC2STR(peer_addr)); return -1; } wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Provision Discovery " "Request with " MACSTR " (config methods 0x%x)", MAC2STR(peer_addr), config_methods); if (config_methods == 0) return -1; /* Reset provisioning info */ dev->wps_prov_info = 0; dev->req_config_methods = config_methods; if (join) dev->flags |= P2P_DEV_PD_FOR_JOIN; else dev->flags &= ~P2P_DEV_PD_FOR_JOIN; if (p2p->go_neg_peer || (p2p->state != P2P_IDLE && p2p->state != P2P_SEARCH && p2p->state != P2P_LISTEN_ONLY)) { wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Busy with other " "operations; postpone Provision Discovery Request " "with " MACSTR " (config methods 0x%x)", MAC2STR(peer_addr), config_methods); return 0; } /* * We use the join param as a cue to differentiate between user * initiated PD request and one issued during finds (internal). */ p2p->user_initiated_pd = !join; /* Also set some retries to attempt in case of IDLE state */ if (p2p->user_initiated_pd && p2p->state == P2P_IDLE) p2p->pd_retries = MAX_PROV_DISC_REQ_RETRIES; return p2p_send_prov_disc_req(p2p, dev, join, force_freq); }