int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev) { struct wpabuf *req; int ret = 0; struct p2p_sd_query *query; int freq; unsigned int wait_time; freq = dev->listen_freq > 0 ? dev->listen_freq : dev->oper_freq; if (freq <= 0) { p2p_dbg(p2p, "No Listen/Operating frequency known for the peer " MACSTR " to send SD Request", MAC2STR(dev->info.p2p_device_addr)); return -1; } query = p2p_pending_sd_req(p2p, dev); if (query == NULL) return -1; p2p_dbg(p2p, "Start Service Discovery with " MACSTR, MAC2STR(dev->info.p2p_device_addr)); req = p2p_build_sd_query(p2p->srv_update_indic, query->tlvs); if (req == NULL) return -1; p2p->sd_peer = dev; p2p->sd_query = query; p2p->pending_action_state = P2P_PENDING_SD; wait_time = 5000; if (p2p->cfg->max_listen && wait_time > p2p->cfg->max_listen) wait_time = p2p->cfg->max_listen; if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr, p2p->cfg->dev_addr, dev->info.p2p_device_addr, wpabuf_head(req), wpabuf_len(req), wait_time) < 0) { p2p_dbg(p2p, "Failed to send Action frame"); ret = -1; } /* Update the pending broadcast SD query count for this device */ dev->sd_pending_bcast_queries--; /* * If there are no pending broadcast queries for this device, mark it as * done (-1). */ if (dev->sd_pending_bcast_queries == 0) dev->sd_pending_bcast_queries = -1; wpabuf_free(req); return ret; }
int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev) { struct wpabuf *req; int ret = 0; struct p2p_sd_query *query; int freq; unsigned int wait_time; freq = dev->listen_freq > 0 ? dev->listen_freq : dev->oper_freq; if (freq <= 0) { p2p_dbg(p2p, "No Listen/Operating frequency known for the peer " MACSTR " to send SD Request", MAC2STR(dev->info.p2p_device_addr)); return -1; } query = p2p_pending_sd_req(p2p, dev); if (query == NULL) return -1; if (p2p->state == P2P_SEARCH && os_memcmp(p2p->sd_query_no_ack, dev->info.p2p_device_addr, ETH_ALEN) == 0) { p2p_dbg(p2p, "Do not start Service Discovery with " MACSTR " due to it being the first no-ACK peer in this search iteration", MAC2STR(dev->info.p2p_device_addr)); return -2; } p2p_dbg(p2p, "Start Service Discovery with " MACSTR, MAC2STR(dev->info.p2p_device_addr)); req = p2p_build_sd_query(p2p->srv_update_indic, query->tlvs); if (req == NULL) return -1; dev->sd_reqs++; p2p->sd_peer = dev; p2p->sd_query = query; p2p->pending_action_state = P2P_PENDING_SD; wait_time = 5000; if (p2p->cfg->max_listen && wait_time > p2p->cfg->max_listen) wait_time = p2p->cfg->max_listen; if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr, p2p->cfg->dev_addr, dev->info.p2p_device_addr, wpabuf_head(req), wpabuf_len(req), wait_time) < 0) { p2p_dbg(p2p, "Failed to send Action frame"); ret = -1; } wpabuf_free(req); return ret; }
int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev, os_time_t *remaining_usec) { struct wpabuf *req; int ret = 0; struct p2p_sd_query *query; int freq; unsigned int wait_time; freq = dev->listen_freq > 0 ? dev->listen_freq : dev->oper_freq; if (freq <= 0) { p2p_dbg(p2p, "No Listen/Operating frequency known for the peer " MACSTR " to send SD Request", MAC2STR(dev->info.p2p_device_addr)); return -1; } query = p2p_pending_sd_req(p2p, dev, remaining_usec); if (query == NULL) return -1; p2p_dbg(p2p, "Start Service Discovery with " MACSTR, MAC2STR(dev->info.p2p_device_addr)); req = p2p_build_sd_query(p2p->srv_update_indic, query->tlvs); if (req == NULL) return -1; dev->sd_reqs++; p2p->sd_peer = dev; p2p->sd_query = query; p2p->pending_action_state = P2P_PENDING_SD; os_get_reltime(&dev->last_sd_bc_time); wait_time = 5000; if (p2p->cfg->max_listen && wait_time > p2p->cfg->max_listen) wait_time = p2p->cfg->max_listen; if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr, p2p->cfg->dev_addr, dev->info.p2p_device_addr, wpabuf_head(req), wpabuf_len(req), wait_time) < 0) { p2p_dbg(p2p, "Failed to send Action frame"); ret = -1; } wpabuf_free(req); return ret; }
int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev) { struct wpabuf *req; int ret = 0; struct p2p_sd_query *query; int freq; freq = dev->listen_freq > 0 ? dev->listen_freq : dev->oper_freq; if (freq <= 0) { wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No Listen/Operating frequency known for the " "peer " MACSTR " to send SD Request", MAC2STR(dev->info.p2p_device_addr)); return -1; } query = p2p_pending_sd_req(p2p, dev); if (query == NULL) return -1; wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Start Service Discovery with " MACSTR, MAC2STR(dev->info.p2p_device_addr)); req = p2p_build_sd_query(p2p->srv_update_indic, query->tlvs); if (req == NULL) return -1; p2p->sd_peer = dev; p2p->sd_query = query; p2p->pending_action_state = P2P_PENDING_SD; if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr, p2p->cfg->dev_addr, dev->info.p2p_device_addr, wpabuf_head(req), wpabuf_len(req), 5000) < 0) { wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Failed to send Action frame"); ret = -1; } wpabuf_free(req); return ret; }