• Home
  • Raw
  • Download

Lines Matching refs:p2p

25 static void p2p_device_free(struct p2p_data *p2p, struct p2p_device *dev);
26 static void p2p_process_presence_req(struct p2p_data *p2p, const u8 *da,
29 static void p2p_process_presence_resp(struct p2p_data *p2p, const u8 *da,
53 void p2p_expire_peers(struct p2p_data *p2p) in p2p_expire_peers() argument
60 dl_list_for_each_safe(dev, n, &p2p->devices, struct p2p_device, list) { in p2p_expire_peers()
64 if (dev == p2p->go_neg_peer) { in p2p_expire_peers()
73 if (p2p->cfg->go_connected && in p2p_expire_peers()
74 p2p->cfg->go_connected(p2p->cfg->cb_ctx, in p2p_expire_peers()
84 for (i = 0; i < p2p->num_groups; i++) { in p2p_expire_peers()
86 p2p->groups[i], dev->info.p2p_device_addr)) in p2p_expire_peers()
89 if (i < p2p->num_groups) { in p2p_expire_peers()
98 p2p_dbg(p2p, "Expiring old peer entry " MACSTR, in p2p_expire_peers()
101 p2p_device_free(p2p, dev); in p2p_expire_peers()
141 const char * p2p_get_state_txt(struct p2p_data *p2p) in p2p_get_state_txt() argument
143 return p2p_state_txt(p2p->state); in p2p_get_state_txt()
147 struct p2ps_advertisement * p2p_get_p2ps_adv_list(struct p2p_data *p2p) in p2p_get_p2ps_adv_list() argument
149 return p2p ? p2p->p2ps_adv_list : NULL; in p2p_get_p2ps_adv_list()
153 void p2p_set_intended_addr(struct p2p_data *p2p, const u8 *intended_addr) in p2p_set_intended_addr() argument
155 if (p2p && intended_addr) in p2p_set_intended_addr()
156 os_memcpy(p2p->intended_addr, intended_addr, ETH_ALEN); in p2p_set_intended_addr()
160 u16 p2p_get_provisioning_info(struct p2p_data *p2p, const u8 *addr) in p2p_get_provisioning_info() argument
164 if (!addr || !p2p) in p2p_get_provisioning_info()
167 dev = p2p_get_device(p2p, addr); in p2p_get_provisioning_info()
175 void p2p_clear_provisioning_info(struct p2p_data *p2p, const u8 *addr) in p2p_clear_provisioning_info() argument
179 if (!addr || !p2p) in p2p_clear_provisioning_info()
182 dev = p2p_get_device(p2p, addr); in p2p_clear_provisioning_info()
188 void p2p_set_state(struct p2p_data *p2p, int new_state) in p2p_set_state() argument
190 p2p_dbg(p2p, "State %s -> %s", in p2p_set_state()
191 p2p_state_txt(p2p->state), p2p_state_txt(new_state)); in p2p_set_state()
192 p2p->state = new_state; in p2p_set_state()
194 if (new_state == P2P_IDLE && p2p->pending_channel) { in p2p_set_state()
195 p2p_dbg(p2p, "Apply change in listen channel"); in p2p_set_state()
196 p2p->cfg->reg_class = p2p->pending_reg_class; in p2p_set_state()
197 p2p->cfg->channel = p2p->pending_channel; in p2p_set_state()
198 p2p->pending_reg_class = 0; in p2p_set_state()
199 p2p->pending_channel = 0; in p2p_set_state()
204 void p2p_set_timeout(struct p2p_data *p2p, unsigned int sec, unsigned int usec) in p2p_set_timeout() argument
206 p2p_dbg(p2p, "Set timeout (state=%s): %u.%06u sec", in p2p_set_timeout()
207 p2p_state_txt(p2p->state), sec, usec); in p2p_set_timeout()
208 eloop_cancel_timeout(p2p_state_timeout, p2p, NULL); in p2p_set_timeout()
209 eloop_register_timeout(sec, usec, p2p_state_timeout, p2p, NULL); in p2p_set_timeout()
213 void p2p_clear_timeout(struct p2p_data *p2p) in p2p_clear_timeout() argument
215 p2p_dbg(p2p, "Clear timeout (state=%s)", p2p_state_txt(p2p->state)); in p2p_clear_timeout()
216 eloop_cancel_timeout(p2p_state_timeout, p2p, NULL); in p2p_clear_timeout()
220 void p2p_go_neg_failed(struct p2p_data *p2p, int status) in p2p_go_neg_failed() argument
223 struct p2p_device *peer = p2p->go_neg_peer; in p2p_go_neg_failed()
228 eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL); in p2p_go_neg_failed()
229 if (p2p->state != P2P_SEARCH) { in p2p_go_neg_failed()
234 p2p_clear_timeout(p2p); in p2p_go_neg_failed()
235 p2p_set_state(p2p, P2P_IDLE); in p2p_go_neg_failed()
243 p2p->go_neg_peer = NULL; in p2p_go_neg_failed()
249 p2p->cfg->go_neg_completed(p2p->cfg->cb_ctx, &res); in p2p_go_neg_failed()
253 static void p2p_listen_in_find(struct p2p_data *p2p, int dev_disc) in p2p_listen_in_find() argument
259 p2p_dbg(p2p, "Starting short listen state (state=%s)", in p2p_listen_in_find()
260 p2p_state_txt(p2p->state)); in p2p_listen_in_find()
262 if (p2p->pending_listen_freq) { in p2p_listen_in_find()
264 p2p_dbg(p2p, "p2p_listen command pending already"); in p2p_listen_in_find()
268 freq = p2p_channel_to_freq(p2p->cfg->reg_class, p2p->cfg->channel); in p2p_listen_in_find()
270 p2p_dbg(p2p, "Unknown regulatory class/channel"); in p2p_listen_in_find()
276 tu = (r % ((p2p->max_disc_int - p2p->min_disc_int) + 1) + in p2p_listen_in_find()
277 p2p->min_disc_int) * 100; in p2p_listen_in_find()
278 if (p2p->max_disc_tu >= 0 && tu > (unsigned int) p2p->max_disc_tu) in p2p_listen_in_find()
279 tu = p2p->max_disc_tu; in p2p_listen_in_find()
282 if (p2p->cfg->max_listen && 1024 * tu / 1000 > p2p->cfg->max_listen) in p2p_listen_in_find()
283 tu = p2p->cfg->max_listen * 1000 / 1024; in p2p_listen_in_find()
286 p2p_dbg(p2p, "Skip listen state since duration was 0 TU"); in p2p_listen_in_find()
287 p2p_set_timeout(p2p, 0, 0); in p2p_listen_in_find()
291 ies = p2p_build_probe_resp_ies(p2p, NULL, 0); in p2p_listen_in_find()
295 p2p->pending_listen_freq = freq; in p2p_listen_in_find()
296 p2p->pending_listen_sec = 0; in p2p_listen_in_find()
297 p2p->pending_listen_usec = 1024 * tu; in p2p_listen_in_find()
299 if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, freq, 1024 * tu / 1000, in p2p_listen_in_find()
301 p2p_dbg(p2p, "Failed to start listen mode"); in p2p_listen_in_find()
302 p2p->pending_listen_freq = 0; in p2p_listen_in_find()
308 int p2p_listen(struct p2p_data *p2p, unsigned int timeout) in p2p_listen() argument
313 p2p_dbg(p2p, "Going to listen(only) state"); in p2p_listen()
315 if (p2p->pending_listen_freq) { in p2p_listen()
317 p2p_dbg(p2p, "p2p_listen command pending already"); in p2p_listen()
321 freq = p2p_channel_to_freq(p2p->cfg->reg_class, p2p->cfg->channel); in p2p_listen()
323 p2p_dbg(p2p, "Unknown regulatory class/channel"); in p2p_listen()
327 p2p->pending_listen_sec = timeout / 1000; in p2p_listen()
328 p2p->pending_listen_usec = (timeout % 1000) * 1000; in p2p_listen()
330 if (p2p->p2p_scan_running) { in p2p_listen()
331 if (p2p->start_after_scan == P2P_AFTER_SCAN_CONNECT) { in p2p_listen()
332 p2p_dbg(p2p, "p2p_scan running - connect is already pending - skip listen"); in p2p_listen()
335 p2p_dbg(p2p, "p2p_scan running - delay start of listen state"); in p2p_listen()
336 p2p->start_after_scan = P2P_AFTER_SCAN_LISTEN; in p2p_listen()
340 ies = p2p_build_probe_resp_ies(p2p, NULL, 0); in p2p_listen()
344 p2p->pending_listen_freq = freq; in p2p_listen()
346 if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, freq, timeout, ies) < 0) { in p2p_listen()
347 p2p_dbg(p2p, "Failed to start listen mode"); in p2p_listen()
348 p2p->pending_listen_freq = 0; in p2p_listen()
354 p2p_set_state(p2p, P2P_LISTEN_ONLY); in p2p_listen()
360 static void p2p_device_clear_reported(struct p2p_data *p2p) in p2p_device_clear_reported() argument
363 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_device_clear_reported()
376 struct p2p_device * p2p_get_device(struct p2p_data *p2p, const u8 *addr) in p2p_get_device() argument
379 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_get_device()
393 struct p2p_device * p2p_get_device_interface(struct p2p_data *p2p, in p2p_get_device_interface() argument
397 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_get_device_interface()
414 static struct p2p_device * p2p_create_device(struct p2p_data *p2p, in p2p_create_device() argument
420 dev = p2p_get_device(p2p, addr); in p2p_create_device()
424 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_create_device()
430 if (count + 1 > p2p->cfg->max_peers && oldest) { in p2p_create_device()
431 p2p_dbg(p2p, "Remove oldest peer entry to make room for a new peer"); in p2p_create_device()
433 p2p_device_free(p2p, oldest); in p2p_create_device()
439 dl_list_add(&p2p->devices, &dev->list); in p2p_create_device()
461 static int p2p_add_group_clients(struct p2p_data *p2p, const u8 *go_dev_addr, in p2p_add_group_clients() argument
480 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_add_group_clients()
490 if (os_memcmp(cli->p2p_device_addr, p2p->cfg->dev_addr, in p2p_add_group_clients()
493 dev = p2p_get_device(p2p, cli->p2p_device_addr); in p2p_add_group_clients()
518 dev = p2p_create_device(p2p, cli->p2p_device_addr); in p2p_add_group_clients()
524 p2p->cfg->dev_found(p2p->cfg->cb_ctx, in p2p_add_group_clients()
543 static void p2p_copy_wps_info(struct p2p_data *p2p, struct p2p_device *dev, in p2p_copy_wps_info() argument
619 p2p_dbg(p2p, "Update peer " MACSTR in p2p_copy_wps_info()
706 int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, in p2p_add_device() argument
720 p2p_dbg(p2p, "Failed to parse P2P IE for a device entry"); in p2p_add_device()
730 p2p_dbg(p2p, "Ignore scan data without P2P Device Info or P2P Device Id"); in p2p_add_device()
735 if (!is_zero_ether_addr(p2p->peer_filter) && in p2p_add_device()
736 os_memcmp(p2p_dev_addr, p2p->peer_filter, ETH_ALEN) != 0) { in p2p_add_device()
737 p2p_dbg(p2p, "Do not add peer filter for " MACSTR in p2p_add_device()
743 dev = p2p_create_device(p2p, p2p_dev_addr); in p2p_add_device()
765 p2p_dbg(p2p, in p2p_add_device()
806 p2p_dbg(p2p, "Update Listen frequency based on DS Parameter Set IE: %d -> %d MHz", in p2p_add_device()
813 p2p_dbg(p2p, "Update Listen frequency based on scan results (" in p2p_add_device()
828 p2p_copy_wps_info(p2p, dev, 0, &msg); in p2p_add_device()
855 p2p_add_group_clients(p2p, p2p_dev_addr, addr, freq, in p2p_add_device()
870 p2p_dbg(p2p, "Peer found with Listen frequency %d MHz (rx_time=%u.%06u)", in p2p_add_device()
874 p2p_dbg(p2p, "Do not report rejected device"); in p2p_add_device()
894 p2p_dbg(p2p, "Do not report peer " MACSTR in p2p_add_device()
899 p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, &dev->info, in p2p_add_device()
910 static void p2p_device_free(struct p2p_data *p2p, struct p2p_device *dev) in p2p_device_free() argument
914 if (p2p->go_neg_peer == dev) { in p2p_device_free()
918 p2p_go_neg_failed(p2p, -1); in p2p_device_free()
920 if (p2p->invite_peer == dev) in p2p_device_free()
921 p2p->invite_peer = NULL; in p2p_device_free()
922 if (p2p->sd_peer == dev) in p2p_device_free()
923 p2p->sd_peer = NULL; in p2p_device_free()
924 if (p2p->pending_client_disc_go == dev) in p2p_device_free()
925 p2p->pending_client_disc_go = NULL; in p2p_device_free()
929 p2p->cfg->dev_lost(p2p->cfg->cb_ctx, in p2p_device_free()
946 static int p2p_get_next_prog_freq(struct p2p_data *p2p) in p2p_get_next_prog_freq() argument
956 c = &p2p->cfg->channels; in p2p_get_next_prog_freq()
959 if (cla->reg_class != p2p->last_prog_scan_class) in p2p_get_next_prog_freq()
962 if (cla->channel[ch] == p2p->last_prog_scan_chan) { in p2p_get_next_prog_freq()
989 p2p_dbg(p2p, "Next progressive search channel: reg_class %u channel %u -> %d MHz", in p2p_get_next_prog_freq()
991 p2p->last_prog_scan_class = reg_class; in p2p_get_next_prog_freq()
992 p2p->last_prog_scan_chan = channel; in p2p_get_next_prog_freq()
1000 static void p2p_search(struct p2p_data *p2p) in p2p_search() argument
1007 if (p2p->drv_in_listen) { in p2p_search()
1008 p2p_dbg(p2p, "Driver is still in Listen state - wait for it to end before continuing"); in p2p_search()
1011 p2p->cfg->stop_listen(p2p->cfg->cb_ctx); in p2p_search()
1013 if (p2p->find_pending_full && in p2p_search()
1014 (p2p->find_type == P2P_FIND_PROGRESSIVE || in p2p_search()
1015 p2p->find_type == P2P_FIND_START_WITH_FULL)) { in p2p_search()
1017 p2p_dbg(p2p, "Starting search (pending full scan)"); in p2p_search()
1018 p2p->find_pending_full = 0; in p2p_search()
1019 } else if ((p2p->find_type == P2P_FIND_PROGRESSIVE && in p2p_search()
1020 (freq = p2p_get_next_prog_freq(p2p)) > 0) || in p2p_search()
1021 (p2p->find_type == P2P_FIND_START_WITH_FULL && in p2p_search()
1022 (freq = p2p->find_specified_freq) > 0)) { in p2p_search()
1024 p2p_dbg(p2p, "Starting search (+ freq %u)", freq); in p2p_search()
1027 p2p_dbg(p2p, "Starting search"); in p2p_search()
1030 res = p2p->cfg->p2p_scan(p2p->cfg->cb_ctx, type, freq, in p2p_search()
1031 p2p->num_req_dev_types, p2p->req_dev_types, in p2p_search()
1032 p2p->find_dev_id, pw_id); in p2p_search()
1034 p2p_dbg(p2p, "Scan request schedule failed"); in p2p_search()
1035 p2p_continue_find(p2p); in p2p_search()
1042 struct p2p_data *p2p = eloop_ctx; in p2p_find_timeout() local
1043 p2p_dbg(p2p, "Find timeout -> stop"); in p2p_find_timeout()
1044 p2p_stop_find(p2p); in p2p_find_timeout()
1048 void p2p_notify_scan_trigger_status(struct p2p_data *p2p, int status) in p2p_notify_scan_trigger_status() argument
1051 p2p_dbg(p2p, "Scan request failed"); in p2p_notify_scan_trigger_status()
1053 p2p_continue_find(p2p); in p2p_notify_scan_trigger_status()
1055 p2p_dbg(p2p, "Running p2p_scan"); in p2p_notify_scan_trigger_status()
1056 p2p->p2p_scan_running = 1; in p2p_notify_scan_trigger_status()
1057 eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL); in p2p_notify_scan_trigger_status()
1059 p2p, NULL); in p2p_notify_scan_trigger_status()
1064 static int p2p_run_after_scan(struct p2p_data *p2p) in p2p_run_after_scan() argument
1069 if (p2p->after_scan_tx) { in p2p_run_after_scan()
1070 p2p->after_scan_tx_in_progress = 1; in p2p_run_after_scan()
1071 p2p_dbg(p2p, "Send pending Action frame at p2p_scan completion"); in p2p_run_after_scan()
1072 p2p->cfg->send_action(p2p->cfg->cb_ctx, in p2p_run_after_scan()
1073 p2p->after_scan_tx->freq, in p2p_run_after_scan()
1074 p2p->after_scan_tx->dst, in p2p_run_after_scan()
1075 p2p->after_scan_tx->src, in p2p_run_after_scan()
1076 p2p->after_scan_tx->bssid, in p2p_run_after_scan()
1077 (u8 *) (p2p->after_scan_tx + 1), in p2p_run_after_scan()
1078 p2p->after_scan_tx->len, in p2p_run_after_scan()
1079 p2p->after_scan_tx->wait_time, NULL); in p2p_run_after_scan()
1080 os_free(p2p->after_scan_tx); in p2p_run_after_scan()
1081 p2p->after_scan_tx = NULL; in p2p_run_after_scan()
1085 op = p2p->start_after_scan; in p2p_run_after_scan()
1086 p2p->start_after_scan = P2P_AFTER_SCAN_NOTHING; in p2p_run_after_scan()
1091 p2p_dbg(p2p, "Start previously requested Listen state"); in p2p_run_after_scan()
1092 p2p_listen(p2p, p2p->pending_listen_sec * 1000 + in p2p_run_after_scan()
1093 p2p->pending_listen_usec / 1000); in p2p_run_after_scan()
1096 p2p_dbg(p2p, "Start previously requested connect with " MACSTR, in p2p_run_after_scan()
1097 MAC2STR(p2p->after_scan_peer)); in p2p_run_after_scan()
1098 dev = p2p_get_device(p2p, p2p->after_scan_peer); in p2p_run_after_scan()
1100 p2p_dbg(p2p, "Peer not known anymore"); in p2p_run_after_scan()
1103 p2p_connect_send(p2p, dev); in p2p_run_after_scan()
1113 struct p2p_data *p2p = eloop_ctx; in p2p_scan_timeout() local
1115 p2p_dbg(p2p, "p2p_scan timeout (running=%d)", p2p->p2p_scan_running); in p2p_scan_timeout()
1116 running = p2p->p2p_scan_running; in p2p_scan_timeout()
1118 p2p->p2p_scan_running = 0; in p2p_scan_timeout()
1121 p2p_run_after_scan(p2p); in p2p_scan_timeout()
1125 static void p2p_free_req_dev_types(struct p2p_data *p2p) in p2p_free_req_dev_types() argument
1127 p2p->num_req_dev_types = 0; in p2p_free_req_dev_types()
1128 os_free(p2p->req_dev_types); in p2p_free_req_dev_types()
1129 p2p->req_dev_types = NULL; in p2p_free_req_dev_types()
1133 static int p2ps_gen_hash(struct p2p_data *p2p, const char *str, u8 *hash) in p2ps_gen_hash() argument
1144 os_memcpy(hash, p2p->wild_card_hash, P2PS_HASH_LEN); in p2ps_gen_hash()
1168 int p2p_find(struct p2p_data *p2p, unsigned int timeout, in p2p_find() argument
1177 p2p_dbg(p2p, "Starting find (type=%d)", type); in p2p_find()
1178 if (p2p->p2p_scan_running) { in p2p_find()
1179 p2p_dbg(p2p, "p2p_scan is already running"); in p2p_find()
1182 p2p_free_req_dev_types(p2p); in p2p_find()
1184 p2p->req_dev_types = os_memdup(req_dev_types, in p2p_find()
1187 if (p2p->req_dev_types == NULL) in p2p_find()
1189 p2p->num_req_dev_types = num_req_dev_types; in p2p_find()
1193 os_memcpy(p2p->find_dev_id_buf, dev_id, ETH_ALEN); in p2p_find()
1194 p2p->find_dev_id = p2p->find_dev_id_buf; in p2p_find()
1196 p2p->find_dev_id = NULL; in p2p_find()
1200 p2p->p2ps_seek = 0; in p2p_find()
1206 p2p_dbg(p2p, "ASP search"); in p2p_find()
1207 p2p->p2ps_seek_count = 0; in p2p_find()
1208 p2p->p2ps_seek = 1; in p2p_find()
1214 if (!p2ps_gen_hash(p2p, seek[i], buf)) in p2p_find()
1217 p2p_dbg(p2p, "Seek service %s hash " MACSTR, in p2p_find()
1219 os_memcpy(&p2p->p2ps_seek_hash[count * P2PS_HASH_LEN], in p2p_find()
1224 p2p->p2ps_seek_count = count; in p2p_find()
1225 p2p->p2ps_seek = 1; in p2p_find()
1227 p2p->p2ps_seek_count = 0; in p2p_find()
1228 p2p->p2ps_seek = 1; in p2p_find()
1232 if (p2p->p2ps_seek_count == 0 && p2p->p2ps_seek) { in p2p_find()
1233 p2p->p2ps_seek_count = 1; in p2p_find()
1234 os_memcpy(&p2p->p2ps_seek_hash, p2p->wild_card_hash, in p2p_find()
1238 p2p->start_after_scan = P2P_AFTER_SCAN_NOTHING; in p2p_find()
1239 p2p_clear_timeout(p2p); in p2p_find()
1240 if (p2p->pending_listen_freq) { in p2p_find()
1241 p2p_dbg(p2p, "Clear pending_listen_freq for p2p_find"); in p2p_find()
1242 p2p->pending_listen_freq = 0; in p2p_find()
1244 p2p->cfg->stop_listen(p2p->cfg->cb_ctx); in p2p_find()
1245 p2p->find_pending_full = 0; in p2p_find()
1246 p2p->find_type = type; in p2p_find()
1248 p2p->find_specified_freq = freq; in p2p_find()
1250 p2p->find_specified_freq = 0; in p2p_find()
1251 p2p_device_clear_reported(p2p); in p2p_find()
1252 os_memset(p2p->sd_query_no_ack, 0, ETH_ALEN); in p2p_find()
1253 p2p_set_state(p2p, P2P_SEARCH); in p2p_find()
1254 p2p->search_delay = search_delay; in p2p_find()
1255 p2p->in_search_delay = 0; in p2p_find()
1256 eloop_cancel_timeout(p2p_find_timeout, p2p, NULL); in p2p_find()
1257 p2p->last_p2p_find_timeout = timeout; in p2p_find()
1260 p2p, NULL); in p2p_find()
1269 res = p2p->cfg->p2p_scan(p2p->cfg->cb_ctx, in p2p_find()
1271 p2p->num_req_dev_types, in p2p_find()
1272 p2p->req_dev_types, dev_id, in p2p_find()
1278 res = p2p->cfg->p2p_scan(p2p->cfg->cb_ctx, P2P_SCAN_FULL, 0, in p2p_find()
1279 p2p->num_req_dev_types, in p2p_find()
1280 p2p->req_dev_types, dev_id, in p2p_find()
1284 res = p2p->cfg->p2p_scan(p2p->cfg->cb_ctx, P2P_SCAN_SOCIAL, 0, in p2p_find()
1285 p2p->num_req_dev_types, in p2p_find()
1286 p2p->req_dev_types, dev_id, in p2p_find()
1294 p2p->find_start = start; in p2p_find()
1296 if (res != 0 && p2p->p2p_scan_running) { in p2p_find()
1297 p2p_dbg(p2p, "Failed to start p2p_scan - another p2p_scan was already running"); in p2p_find()
1301 p2p->find_pending_full = 1; in p2p_find()
1304 p2p_dbg(p2p, "Failed to start p2p_scan"); in p2p_find()
1305 p2p_set_state(p2p, P2P_IDLE); in p2p_find()
1306 eloop_cancel_timeout(p2p_find_timeout, p2p, NULL); in p2p_find()
1313 void p2p_stop_find_for_freq(struct p2p_data *p2p, int freq) in p2p_stop_find_for_freq() argument
1315 p2p_dbg(p2p, "Stopping find"); in p2p_stop_find_for_freq()
1316 eloop_cancel_timeout(p2p_find_timeout, p2p, NULL); in p2p_stop_find_for_freq()
1317 p2p_clear_timeout(p2p); in p2p_stop_find_for_freq()
1318 if (p2p->state == P2P_SEARCH || p2p->state == P2P_SD_DURING_FIND) in p2p_stop_find_for_freq()
1319 p2p->cfg->find_stopped(p2p->cfg->cb_ctx); in p2p_stop_find_for_freq()
1321 p2p->p2ps_seek_count = 0; in p2p_stop_find_for_freq()
1323 p2p_set_state(p2p, P2P_IDLE); in p2p_stop_find_for_freq()
1324 p2p_free_req_dev_types(p2p); in p2p_stop_find_for_freq()
1325 p2p->start_after_scan = P2P_AFTER_SCAN_NOTHING; in p2p_stop_find_for_freq()
1326 if (p2p->go_neg_peer) in p2p_stop_find_for_freq()
1327 p2p->go_neg_peer->flags &= ~P2P_DEV_PEER_WAITING_RESPONSE; in p2p_stop_find_for_freq()
1328 p2p->go_neg_peer = NULL; in p2p_stop_find_for_freq()
1329 p2p->sd_peer = NULL; in p2p_stop_find_for_freq()
1330 p2p->invite_peer = NULL; in p2p_stop_find_for_freq()
1331 p2p_stop_listen_for_freq(p2p, freq); in p2p_stop_find_for_freq()
1332 p2p->send_action_in_progress = 0; in p2p_stop_find_for_freq()
1336 void p2p_stop_listen_for_freq(struct p2p_data *p2p, int freq) in p2p_stop_listen_for_freq() argument
1338 if (freq > 0 && p2p->drv_in_listen == freq && p2p->in_listen) { in p2p_stop_listen_for_freq()
1339 p2p_dbg(p2p, "Skip stop_listen since we are on correct channel for response"); in p2p_stop_listen_for_freq()
1342 if (p2p->in_listen) { in p2p_stop_listen_for_freq()
1343 p2p->in_listen = 0; in p2p_stop_listen_for_freq()
1344 p2p_clear_timeout(p2p); in p2p_stop_listen_for_freq()
1346 if (p2p->drv_in_listen) { in p2p_stop_listen_for_freq()
1352 p2p_dbg(p2p, "Clear drv_in_listen (%d)", p2p->drv_in_listen); in p2p_stop_listen_for_freq()
1353 p2p->drv_in_listen = 0; in p2p_stop_listen_for_freq()
1355 p2p->cfg->stop_listen(p2p->cfg->cb_ctx); in p2p_stop_listen_for_freq()
1359 void p2p_stop_listen(struct p2p_data *p2p) in p2p_stop_listen() argument
1361 if (p2p->state != P2P_LISTEN_ONLY) { in p2p_stop_listen()
1362 p2p_dbg(p2p, "Skip stop_listen since not in listen_only state."); in p2p_stop_listen()
1366 p2p_stop_listen_for_freq(p2p, 0); in p2p_stop_listen()
1367 p2p_set_state(p2p, P2P_IDLE); in p2p_stop_listen()
1371 void p2p_stop_find(struct p2p_data *p2p) in p2p_stop_find() argument
1373 p2p->pending_listen_freq = 0; in p2p_stop_find()
1374 p2p_stop_find_for_freq(p2p, 0); in p2p_stop_find()
1378 static int p2p_prepare_channel_pref(struct p2p_data *p2p, in p2p_prepare_channel_pref() argument
1385 p2p_dbg(p2p, "Prepare channel pref - force_freq=%u pref_freq=%u go=%d", in p2p_prepare_channel_pref()
1388 p2p_dbg(p2p, "Unsupported frequency %u MHz", freq); in p2p_prepare_channel_pref()
1392 if (!p2p_channels_includes(&p2p->cfg->channels, op_class, op_channel) && in p2p_prepare_channel_pref()
1393 (go || !p2p_channels_includes(&p2p->cfg->cli_channels, op_class, in p2p_prepare_channel_pref()
1395 p2p_dbg(p2p, "Frequency %u MHz (oper_class %u channel %u) not allowed for P2P", in p2p_prepare_channel_pref()
1400 p2p->op_reg_class = op_class; in p2p_prepare_channel_pref()
1401 p2p->op_channel = op_channel; in p2p_prepare_channel_pref()
1404 p2p->channels.reg_classes = 1; in p2p_prepare_channel_pref()
1405 p2p->channels.reg_class[0].channels = 1; in p2p_prepare_channel_pref()
1406 p2p->channels.reg_class[0].reg_class = p2p->op_reg_class; in p2p_prepare_channel_pref()
1407 p2p->channels.reg_class[0].channel[0] = p2p->op_channel; in p2p_prepare_channel_pref()
1409 os_memcpy(&p2p->channels, &p2p->cfg->channels, in p2p_prepare_channel_pref()
1417 static void p2p_prepare_channel_best(struct p2p_data *p2p) in p2p_prepare_channel_best() argument
1424 p2p_dbg(p2p, "Prepare channel best"); in p2p_prepare_channel_best()
1426 if (!p2p->cfg->cfg_op_channel && p2p->best_freq_overall > 0 && in p2p_prepare_channel_best()
1427 p2p_supported_freq(p2p, p2p->best_freq_overall) && in p2p_prepare_channel_best()
1428 p2p_freq_to_channel(p2p->best_freq_overall, &op_class, &op_channel) in p2p_prepare_channel_best()
1430 p2p_dbg(p2p, "Select best overall channel as operating channel preference"); in p2p_prepare_channel_best()
1431 p2p->op_reg_class = op_class; in p2p_prepare_channel_best()
1432 p2p->op_channel = op_channel; in p2p_prepare_channel_best()
1433 } else if (!p2p->cfg->cfg_op_channel && p2p->best_freq_5 > 0 && in p2p_prepare_channel_best()
1434 p2p_supported_freq(p2p, p2p->best_freq_5) && in p2p_prepare_channel_best()
1435 p2p_freq_to_channel(p2p->best_freq_5, &op_class, &op_channel) in p2p_prepare_channel_best()
1437 p2p_dbg(p2p, "Select best 5 GHz channel as operating channel preference"); in p2p_prepare_channel_best()
1438 p2p->op_reg_class = op_class; in p2p_prepare_channel_best()
1439 p2p->op_channel = op_channel; in p2p_prepare_channel_best()
1440 } else if (!p2p->cfg->cfg_op_channel && p2p->best_freq_24 > 0 && in p2p_prepare_channel_best()
1441 p2p_supported_freq(p2p, p2p->best_freq_24) && in p2p_prepare_channel_best()
1442 p2p_freq_to_channel(p2p->best_freq_24, &op_class, in p2p_prepare_channel_best()
1444 p2p_dbg(p2p, "Select best 2.4 GHz channel as operating channel preference"); in p2p_prepare_channel_best()
1445 p2p->op_reg_class = op_class; in p2p_prepare_channel_best()
1446 p2p->op_channel = op_channel; in p2p_prepare_channel_best()
1447 } else if (p2p->cfg->num_pref_chan > 0 && in p2p_prepare_channel_best()
1448 p2p_channels_includes(&p2p->cfg->channels, in p2p_prepare_channel_best()
1449 p2p->cfg->pref_chan[0].op_class, in p2p_prepare_channel_best()
1450 p2p->cfg->pref_chan[0].chan)) { in p2p_prepare_channel_best()
1451 p2p_dbg(p2p, "Select first pref_chan entry as operating channel preference"); in p2p_prepare_channel_best()
1452 p2p->op_reg_class = p2p->cfg->pref_chan[0].op_class; in p2p_prepare_channel_best()
1453 p2p->op_channel = p2p->cfg->pref_chan[0].chan; in p2p_prepare_channel_best()
1454 } else if (p2p_channel_select(&p2p->cfg->channels, op_classes_vht, in p2p_prepare_channel_best()
1455 &p2p->op_reg_class, &p2p->op_channel) == in p2p_prepare_channel_best()
1457 …p2p_dbg(p2p, "Select possible VHT channel (op_class %u channel %u) as operating channel preference… in p2p_prepare_channel_best()
1458 p2p->op_reg_class, p2p->op_channel); in p2p_prepare_channel_best()
1459 } else if (p2p_channel_select(&p2p->cfg->channels, op_classes_ht40, in p2p_prepare_channel_best()
1460 &p2p->op_reg_class, &p2p->op_channel) == in p2p_prepare_channel_best()
1462 …p2p_dbg(p2p, "Select possible HT40 channel (op_class %u channel %u) as operating channel preferenc… in p2p_prepare_channel_best()
1463 p2p->op_reg_class, p2p->op_channel); in p2p_prepare_channel_best()
1464 } else if (p2p_channel_select(&p2p->cfg->channels, op_classes_5ghz, in p2p_prepare_channel_best()
1465 &p2p->op_reg_class, &p2p->op_channel) == in p2p_prepare_channel_best()
1467 …p2p_dbg(p2p, "Select possible 5 GHz channel (op_class %u channel %u) as operating channel preferen… in p2p_prepare_channel_best()
1468 p2p->op_reg_class, p2p->op_channel); in p2p_prepare_channel_best()
1469 } else if (p2p_channels_includes(&p2p->cfg->channels, in p2p_prepare_channel_best()
1470 p2p->cfg->op_reg_class, in p2p_prepare_channel_best()
1471 p2p->cfg->op_channel)) { in p2p_prepare_channel_best()
1472 p2p_dbg(p2p, "Select pre-configured channel as operating channel preference"); in p2p_prepare_channel_best()
1473 p2p->op_reg_class = p2p->cfg->op_reg_class; in p2p_prepare_channel_best()
1474 p2p->op_channel = p2p->cfg->op_channel; in p2p_prepare_channel_best()
1475 } else if (p2p_channel_random_social(&p2p->cfg->channels, in p2p_prepare_channel_best()
1476 &p2p->op_reg_class, in p2p_prepare_channel_best()
1477 &p2p->op_channel, in p2p_prepare_channel_best()
1479 …p2p_dbg(p2p, "Select random available social channel (op_class %u channel %u) as operating channel… in p2p_prepare_channel_best()
1480 p2p->op_reg_class, p2p->op_channel); in p2p_prepare_channel_best()
1484 p2p_channel_select(&p2p->cfg->channels, NULL, in p2p_prepare_channel_best()
1485 &p2p->op_reg_class, in p2p_prepare_channel_best()
1486 &p2p->op_channel); in p2p_prepare_channel_best()
1487 …p2p_dbg(p2p, "Select random available channel %d from operating class %d as operating channel pref… in p2p_prepare_channel_best()
1488 p2p->op_channel, p2p->op_reg_class); in p2p_prepare_channel_best()
1491 os_memcpy(&p2p->channels, &p2p->cfg->channels, in p2p_prepare_channel_best()
1510 int p2p_prepare_channel(struct p2p_data *p2p, struct p2p_device *dev, in p2p_prepare_channel() argument
1513 p2p_dbg(p2p, "Prepare channel - force_freq=%u pref_freq=%u go=%d", in p2p_prepare_channel()
1516 if (p2p_prepare_channel_pref(p2p, force_freq, pref_freq, go) < in p2p_prepare_channel()
1520 p2p_prepare_channel_best(p2p); in p2p_prepare_channel()
1522 p2p_channels_dump(p2p, "prepared channels", &p2p->channels); in p2p_prepare_channel()
1524 p2p_channels_remove_freqs(&p2p->channels, &p2p->no_go_freq); in p2p_prepare_channel()
1526 p2p_channels_union_inplace(&p2p->channels, in p2p_prepare_channel()
1527 &p2p->cfg->cli_channels); in p2p_prepare_channel()
1528 p2p_channels_dump(p2p, "after go/cli filter/add", &p2p->channels); in p2p_prepare_channel()
1530 p2p_dbg(p2p, "Own preference for operation channel: Operating Class %u Channel %u%s", in p2p_prepare_channel()
1531 p2p->op_reg_class, p2p->op_channel, in p2p_prepare_channel()
1563 int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr, in p2p_connect() argument
1572 p2p_dbg(p2p, "Request to start group negotiation - peer=" MACSTR in p2p_connect()
1579 dev = p2p_get_device(p2p, peer_addr); in p2p_connect()
1581 p2p_dbg(p2p, "Cannot connect to unknown P2P Device " MACSTR, in p2p_connect()
1586 if (p2p_prepare_channel(p2p, dev, force_freq, pref_freq, in p2p_connect()
1593 p2p_dbg(p2p, "Cannot connect to P2P Device " MACSTR in p2p_connect()
1599 p2p_dbg(p2p, "Cannot connect to P2P Device " MACSTR in p2p_connect()
1612 p2p->ssid_set = 0; in p2p_connect()
1616 os_memcpy(p2p->ssid, force_ssid, force_ssid_len); in p2p_connect()
1617 p2p->ssid_len = force_ssid_len; in p2p_connect()
1618 p2p->ssid_set = 1; in p2p_connect()
1636 dev->tie_breaker = p2p->next_tie_breaker; in p2p_connect()
1637 p2p->next_tie_breaker = !p2p->next_tie_breaker; in p2p_connect()
1643 p2p->go_intent = go_intent; in p2p_connect()
1644 os_memcpy(p2p->intended_addr, own_interface_addr, ETH_ALEN); in p2p_connect()
1646 if (p2p->state != P2P_IDLE) in p2p_connect()
1647 p2p_stop_find(p2p); in p2p_connect()
1649 if (p2p->after_scan_tx) { in p2p_connect()
1655 p2p_dbg(p2p, "Dropped previous pending Action frame TX that was waiting for p2p_scan completion"); in p2p_connect()
1656 os_free(p2p->after_scan_tx); in p2p_connect()
1657 p2p->after_scan_tx = NULL; in p2p_connect()
1664 if (p2p->p2p_scan_running) { in p2p_connect()
1665 p2p_dbg(p2p, "p2p_scan running - delay connect send"); in p2p_connect()
1666 p2p->start_after_scan = P2P_AFTER_SCAN_CONNECT; in p2p_connect()
1667 os_memcpy(p2p->after_scan_peer, peer_addr, ETH_ALEN); in p2p_connect()
1670 p2p->start_after_scan = P2P_AFTER_SCAN_NOTHING; in p2p_connect()
1672 return p2p_connect_send(p2p, dev); in p2p_connect()
1676 int p2p_authorize(struct p2p_data *p2p, const u8 *peer_addr, in p2p_authorize() argument
1685 p2p_dbg(p2p, "Request to authorize group negotiation - peer=" MACSTR in p2p_authorize()
1691 dev = p2p_get_device(p2p, peer_addr); in p2p_authorize()
1693 p2p_dbg(p2p, "Cannot authorize unknown P2P Device " MACSTR, in p2p_authorize()
1698 if (p2p_prepare_channel(p2p, dev, force_freq, pref_freq, go_intent == in p2p_authorize()
1702 p2p->ssid_set = 0; in p2p_authorize()
1706 os_memcpy(p2p->ssid, force_ssid, force_ssid_len); in p2p_authorize()
1707 p2p->ssid_len = force_ssid_len; in p2p_authorize()
1708 p2p->ssid_set = 1; in p2p_authorize()
1716 p2p->go_intent = go_intent; in p2p_authorize()
1717 os_memcpy(p2p->intended_addr, own_interface_addr, ETH_ALEN); in p2p_authorize()
1727 void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr, in p2p_add_dev_info() argument
1732 p2p_copy_wps_info(p2p, dev, 0, msg); in p2p_add_dev_info()
1739 p2p_dbg(p2p, "Unknown peer Listen channel: " in p2p_add_dev_info()
1747 p2p_dbg(p2p, "Update peer " MACSTR in p2p_add_dev_info()
1762 p2p_dbg(p2p, "Completed device entry based on data from GO Negotiation Request"); in p2p_add_dev_info()
1764 p2p_dbg(p2p, "Created device entry based on GO Neg Req: " in p2p_add_dev_info()
1775 p2p_dbg(p2p, "Do not report rejected device"); in p2p_add_dev_info()
1779 p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, &dev->info, in p2p_add_dev_info()
1785 void p2p_build_ssid(struct p2p_data *p2p, u8 *ssid, size_t *ssid_len) in p2p_build_ssid() argument
1790 p2p->cfg->ssid_postfix, p2p->cfg->ssid_postfix_len); in p2p_build_ssid()
1791 *ssid_len = P2P_WILDCARD_SSID_LEN + 2 + p2p->cfg->ssid_postfix_len; in p2p_build_ssid()
1795 int p2p_go_params(struct p2p_data *p2p, struct p2p_go_neg_results *params) in p2p_go_params() argument
1797 if (p2p->ssid_set) { in p2p_go_params()
1798 os_memcpy(params->ssid, p2p->ssid, p2p->ssid_len); in p2p_go_params()
1799 params->ssid_len = p2p->ssid_len; in p2p_go_params()
1801 p2p_build_ssid(p2p, params->ssid, &params->ssid_len); in p2p_go_params()
1803 p2p->ssid_set = 0; in p2p_go_params()
1805 if (p2p->passphrase_set) { in p2p_go_params()
1806 os_memcpy(params->passphrase, p2p->passphrase, os_strlen(p2p->passphrase)); in p2p_go_params()
1808 p2p_random(params->passphrase, p2p->cfg->passphrase_len); in p2p_go_params()
1810 p2p->passphrase_set = 0; in p2p_go_params()
1815 void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer) in p2p_go_complete() argument
1821 p2p_dbg(p2p, "GO Negotiation with " MACSTR " completed (%s will be GO)", in p2p_go_complete()
1838 res.freq = p2p_channel_to_freq(p2p->op_reg_class, in p2p_go_complete()
1839 p2p->op_channel); in p2p_go_complete()
1840 os_memcpy(res.ssid, p2p->ssid, p2p->ssid_len); in p2p_go_complete()
1841 res.ssid_len = p2p->ssid_len; in p2p_go_complete()
1842 p2p_random(res.passphrase, p2p->cfg->passphrase_len); in p2p_go_complete()
1845 if (p2p->ssid_len) { in p2p_go_complete()
1846 os_memcpy(res.ssid, p2p->ssid, p2p->ssid_len); in p2p_go_complete()
1847 res.ssid_len = p2p->ssid_len; in p2p_go_complete()
1851 p2p_channels_dump(p2p, "own channels", &p2p->channels); in p2p_go_complete()
1852 p2p_channels_dump(p2p, "peer channels", &peer->channels); in p2p_go_complete()
1853 p2p_channels_intersect(&p2p->channels, &peer->channels, in p2p_go_complete()
1856 p2p_channels_remove_freqs(&intersection, &p2p->no_go_freq); in p2p_go_complete()
1857 p2p_channels_dump(p2p, "intersection after no-GO removal", in p2p_go_complete()
1866 p2p_clear_timeout(p2p); in p2p_go_complete()
1867 p2p->ssid_set = 0; in p2p_go_complete()
1875 p2p_set_state(p2p, P2P_PROVISIONING); in p2p_go_complete()
1876 p2p->cfg->go_neg_completed(p2p->cfg->cb_ctx, &res); in p2p_go_complete()
1880 static void p2p_rx_p2p_action(struct p2p_data *p2p, const u8 *sa, in p2p_rx_p2p_action() argument
1883 p2p_dbg(p2p, "RX P2P Public Action from " MACSTR, MAC2STR(sa)); in p2p_rx_p2p_action()
1891 p2p_process_go_neg_req(p2p, sa, data + 1, len - 1, rx_freq); in p2p_rx_p2p_action()
1894 p2p_process_go_neg_resp(p2p, sa, data + 1, len - 1, rx_freq); in p2p_rx_p2p_action()
1897 p2p_process_go_neg_conf(p2p, sa, data + 1, len - 1); in p2p_rx_p2p_action()
1900 p2p_process_invitation_req(p2p, sa, data + 1, len - 1, in p2p_rx_p2p_action()
1904 p2p_process_invitation_resp(p2p, sa, data + 1, len - 1); in p2p_rx_p2p_action()
1907 p2p_process_prov_disc_req(p2p, sa, data + 1, len - 1, rx_freq); in p2p_rx_p2p_action()
1910 p2p_process_prov_disc_resp(p2p, sa, data + 1, len - 1); in p2p_rx_p2p_action()
1913 p2p_process_dev_disc_req(p2p, sa, data + 1, len - 1, rx_freq); in p2p_rx_p2p_action()
1916 p2p_process_dev_disc_resp(p2p, sa, data + 1, len - 1); in p2p_rx_p2p_action()
1919 p2p_dbg(p2p, "Unsupported P2P Public Action frame type %d", in p2p_rx_p2p_action()
1926 static void p2p_rx_action_public(struct p2p_data *p2p, const u8 *da, in p2p_rx_action_public() argument
1945 p2p_rx_p2p_action(p2p, sa, data, len, freq); in p2p_rx_action_public()
1948 p2p_rx_gas_initial_req(p2p, sa, data + 1, len - 1, freq); in p2p_rx_action_public()
1951 p2p_rx_gas_initial_resp(p2p, sa, data + 1, len - 1, freq); in p2p_rx_action_public()
1954 p2p_rx_gas_comeback_req(p2p, sa, data + 1, len - 1, freq); in p2p_rx_action_public()
1957 p2p_rx_gas_comeback_resp(p2p, sa, data + 1, len - 1, freq); in p2p_rx_action_public()
1963 void p2p_rx_action(struct p2p_data *p2p, const u8 *da, const u8 *sa, in p2p_rx_action() argument
1968 p2p_rx_action_public(p2p, da, sa, bssid, data, len, freq); in p2p_rx_action()
1984 p2p_dbg(p2p, "RX P2P Action from " MACSTR, MAC2STR(sa)); in p2p_rx_action()
1991 p2p_dbg(p2p, "Received P2P Action - Notice of Absence"); in p2p_rx_action()
1995 p2p_process_presence_req(p2p, da, sa, data + 1, len - 1, freq); in p2p_rx_action()
1998 p2p_process_presence_resp(p2p, da, sa, data + 1, len - 1); in p2p_rx_action()
2001 p2p_process_go_disc_req(p2p, da, sa, data + 1, len - 1, freq); in p2p_rx_action()
2004 p2p_dbg(p2p, "Received P2P Action - unknown type %u", data[0]); in p2p_rx_action()
2012 struct p2p_data *p2p = eloop_ctx; in p2p_go_neg_start() local
2013 if (p2p->go_neg_peer == NULL) in p2p_go_neg_start()
2015 if (p2p->pending_listen_freq) { in p2p_go_neg_start()
2016 p2p_dbg(p2p, "Clear pending_listen_freq for p2p_go_neg_start"); in p2p_go_neg_start()
2017 p2p->pending_listen_freq = 0; in p2p_go_neg_start()
2019 p2p->cfg->stop_listen(p2p->cfg->cb_ctx); in p2p_go_neg_start()
2020 p2p->go_neg_peer->status = P2P_SC_SUCCESS; in p2p_go_neg_start()
2025 p2p_set_timeout(p2p, 0, 500000); in p2p_go_neg_start()
2026 p2p_connect_send(p2p, p2p->go_neg_peer); in p2p_go_neg_start()
2032 struct p2p_data *p2p = eloop_ctx; in p2p_invite_start() local
2033 if (p2p->invite_peer == NULL) in p2p_invite_start()
2035 if (p2p->pending_listen_freq) { in p2p_invite_start()
2036 p2p_dbg(p2p, "Clear pending_listen_freq for p2p_invite_start"); in p2p_invite_start()
2037 p2p->pending_listen_freq = 0; in p2p_invite_start()
2039 p2p->cfg->stop_listen(p2p->cfg->cb_ctx); in p2p_invite_start()
2040 p2p_invite_send(p2p, p2p->invite_peer, p2p->invite_go_dev_addr, in p2p_invite_start()
2041 p2p->invite_dev_pw_id); in p2p_invite_start()
2045 static void p2p_add_dev_from_probe_req(struct p2p_data *p2p, const u8 *addr, in p2p_add_dev_from_probe_req() argument
2070 dev = p2p_get_device(p2p, addr); in p2p_add_dev_from_probe_req()
2082 p2p_dbg(p2p, in p2p_add_dev_from_probe_req()
2094 dev = p2p_create_device(p2p, addr); in p2p_add_dev_from_probe_req()
2109 p2p_copy_wps_info(p2p, dev, 1, &msg); in p2p_add_dev_from_probe_req()
2118 p2p_dbg(p2p, "Created device entry based on Probe Req: " MACSTR in p2p_add_dev_from_probe_req()
2126 struct p2p_device * p2p_add_dev_from_go_neg_req(struct p2p_data *p2p, in p2p_add_dev_from_go_neg_req() argument
2132 dev = p2p_get_device(p2p, addr); in p2p_add_dev_from_go_neg_req()
2138 dev = p2p_create_device(p2p, addr); in p2p_add_dev_from_go_neg_req()
2142 p2p_add_dev_info(p2p, addr, dev, msg); in p2p_add_dev_from_go_neg_req()
2182 int p2p_match_dev_type(struct p2p_data *p2p, struct wpabuf *wps) in p2p_match_dev_type() argument
2193 if (dev_type_list_match(p2p->cfg->pri_dev_type, attr.req_dev_type, in p2p_match_dev_type()
2197 for (i = 0; i < p2p->cfg->num_sec_dev_types; i++) { in p2p_match_dev_type()
2198 if (dev_type_list_match(p2p->cfg->sec_dev_type[i], in p2p_match_dev_type()
2209 struct wpabuf * p2p_build_probe_resp_ies(struct p2p_data *p2p, in p2p_build_probe_resp_ies() argument
2219 if (p2p->wfd_ie_probe_resp) in p2p_build_probe_resp_ies()
2220 extra = wpabuf_len(p2p->wfd_ie_probe_resp); in p2p_build_probe_resp_ies()
2223 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P]) in p2p_build_probe_resp_ies()
2224 extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P]); in p2p_build_probe_resp_ies()
2233 if (p2p->go_neg_peer) { in p2p_build_probe_resp_ies()
2235 pw_id = p2p_wps_method_pw_id(p2p->go_neg_peer->wps_method); in p2p_build_probe_resp_ies()
2238 if (p2p_build_wps_ie(p2p, buf, pw_id, 1) < 0) { in p2p_build_probe_resp_ies()
2239 p2p_dbg(p2p, "Failed to build WPS IE for Probe Response"); in p2p_build_probe_resp_ies()
2245 if (p2p->wfd_ie_probe_resp) in p2p_build_probe_resp_ies()
2246 wpabuf_put_buf(buf, p2p->wfd_ie_probe_resp); in p2p_build_probe_resp_ies()
2249 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P]) in p2p_build_probe_resp_ies()
2251 p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P]); in p2p_build_probe_resp_ies()
2255 p2p_buf_add_capability(buf, p2p->dev_capab & in p2p_build_probe_resp_ies()
2257 if (p2p->ext_listen_interval) in p2p_build_probe_resp_ies()
2258 p2p_buf_add_ext_listen_timing(buf, p2p->ext_listen_period, in p2p_build_probe_resp_ies()
2259 p2p->ext_listen_interval); in p2p_build_probe_resp_ies()
2260 p2p_buf_add_device_info(buf, p2p, NULL); in p2p_build_probe_resp_ies()
2264 p2p_buf_add_service_instance(buf, p2p, query_count, query_hash, in p2p_build_probe_resp_ies()
2265 p2p->p2ps_adv_list); in p2p_build_probe_resp_ies()
2271 static int p2p_build_probe_resp_buf(struct p2p_data *p2p, struct wpabuf *buf, in p2p_build_probe_resp_buf() argument
2284 os_memcpy(resp->sa, p2p->cfg->dev_addr, ETH_ALEN); in p2p_build_probe_resp_buf()
2285 os_memcpy(resp->bssid, p2p->cfg->dev_addr, ETH_ALEN); in p2p_build_probe_resp_buf()
2309 channel = p2p->cfg->channel; in p2p_build_probe_resp_buf()
2311 p2p_err(p2p, "Failed to convert freq to channel"); in p2p_build_probe_resp_buf()
2324 static int p2p_service_find_asp(struct p2p_data *p2p, const u8 *hash) in p2p_service_find_asp() argument
2329 p2p_dbg(p2p, "ASP find - ASP list: %p", p2p->p2ps_adv_list); in p2p_service_find_asp()
2332 any_wfa = os_memcmp(hash, p2p->wild_card_hash, P2PS_HASH_LEN) == 0; in p2p_service_find_asp()
2334 adv_data = p2p->p2ps_adv_list; in p2p_service_find_asp()
2350 p2p_reply_probe(struct p2p_data *p2p, const u8 *addr, const u8 *dst, in p2p_reply_probe() argument
2362 p2p_dbg(p2p, "Could not parse Probe Request frame - ignore it"); in p2p_reply_probe()
2366 if (elems.p2p == NULL) { in p2p_reply_probe()
2368 p2p_dbg(p2p, "Not a P2P probe - ignore it"); in p2p_reply_probe()
2373 os_memcmp(dst, p2p->cfg->dev_addr, ETH_ALEN) != 0) { in p2p_reply_probe()
2376 p2p_dbg(p2p, "Probe Req DA " MACSTR " not ours - ignore it", in p2p_reply_probe()
2383 p2p_dbg(p2p, "Probe Req BSSID " MACSTR " not wildcard - ignore it", in p2p_reply_probe()
2392 p2p_dbg(p2p, "Probe Req not using P2P Wildcard SSID - ignore it"); in p2p_reply_probe()
2398 p2p_dbg(p2p, "Probe Req with 11b rates only supported - ignore it"); in p2p_reply_probe()
2405 p2p_dbg(p2p, "Could not parse P2P attributes in Probe Req - ignore it"); in p2p_reply_probe()
2414 …p2p_dbg(p2p, "in_listen=%d drv_in_listen=%d when received P2PS Probe Request at %u MHz; own Listen… in p2p_reply_probe()
2415 p2p->in_listen, p2p->drv_in_listen, rx_freq, in p2p_reply_probe()
2416 p2p->cfg->channel, p2p->pending_listen_freq); in p2p_reply_probe()
2418 if (!p2p->in_listen && !p2p->drv_in_listen && in p2p_reply_probe()
2419 p2p->pending_listen_freq && rx_freq && in p2p_reply_probe()
2420 rx_freq != p2p->pending_listen_freq) { in p2p_reply_probe()
2421 …p2p_dbg(p2p, "Do not reply to Probe Request frame that was received on %u MHz while waiting to sta… in p2p_reply_probe()
2422 rx_freq, p2p->pending_listen_freq); in p2p_reply_probe()
2428 if (p2p_service_find_asp(p2p, hash)) { in p2p_reply_probe()
2429 p2p_dbg(p2p, "Service Hash match found: " in p2p_reply_probe()
2439 p2p_dbg(p2p, "No Service Hash match found"); in p2p_reply_probe()
2445 p2p_dbg(p2p, "No P2PS Hash in Probe Request"); in p2p_reply_probe()
2447 if (!p2p->in_listen || !p2p->drv_in_listen) { in p2p_reply_probe()
2449 p2p_dbg(p2p, "Not in Listen state (in_listen=%d drv_in_listen=%d) - ignore Probe Request", in p2p_reply_probe()
2450 p2p->in_listen, p2p->drv_in_listen); in p2p_reply_probe()
2457 os_memcmp(msg.device_id, p2p->cfg->dev_addr, ETH_ALEN) != 0) { in p2p_reply_probe()
2459 p2p_dbg(p2p, "Probe Req requested Device ID " MACSTR " did not match - ignore it", in p2p_reply_probe()
2467 !p2p_match_dev_type(p2p, msg.wps_attributes)) { in p2p_reply_probe()
2469 p2p_dbg(p2p, "Probe Req requested Device Type did not match - ignore it"); in p2p_reply_probe()
2474 if (!p2p->cfg->send_probe_resp) { in p2p_reply_probe()
2476 p2p_dbg(p2p, "Probe Resp generated elsewhere - do not generate additional response"); in p2p_reply_probe()
2481 p2p_dbg(p2p, "Reply to P2P Probe Request in Listen state"); in p2p_reply_probe()
2489 ies = p2p_build_probe_resp_ies(p2p, msg.service_hash, in p2p_reply_probe()
2501 if (p2p_build_probe_resp_buf(p2p, buf, ies, addr, rx_freq)) { in p2p_reply_probe()
2509 p2p->cfg->send_probe_resp(p2p->cfg->cb_ctx, buf, rx_freq); in p2p_reply_probe()
2518 p2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *dst, in p2p_probe_req_rx() argument
2524 p2p_add_dev_from_probe_req(p2p, addr, ie, ie_len); in p2p_probe_req_rx()
2527 p2p_dbg(p2p, in p2p_probe_req_rx()
2532 res = p2p_reply_probe(p2p, addr, dst, bssid, ie, ie_len, rx_freq); in p2p_probe_req_rx()
2544 if ((p2p->state == P2P_CONNECT || p2p->state == P2P_CONNECT_LISTEN) && in p2p_probe_req_rx()
2545 p2p->go_neg_peer && in p2p_probe_req_rx()
2546 os_memcmp(addr, p2p->go_neg_peer->info.p2p_device_addr, ETH_ALEN) in p2p_probe_req_rx()
2548 !(p2p->go_neg_peer->flags & P2P_DEV_WAIT_GO_NEG_CONFIRM)) { in p2p_probe_req_rx()
2550 p2p_dbg(p2p, "Found GO Negotiation peer - try to start GO negotiation from timeout"); in p2p_probe_req_rx()
2551 eloop_cancel_timeout(p2p_go_neg_start, p2p, NULL); in p2p_probe_req_rx()
2552 eloop_register_timeout(0, 0, p2p_go_neg_start, p2p, NULL); in p2p_probe_req_rx()
2556 if ((p2p->state == P2P_INVITE || p2p->state == P2P_INVITE_LISTEN) && in p2p_probe_req_rx()
2557 p2p->invite_peer && in p2p_probe_req_rx()
2558 (p2p->invite_peer->flags & P2P_DEV_WAIT_INV_REQ_ACK) && in p2p_probe_req_rx()
2559 os_memcmp(addr, p2p->invite_peer->info.p2p_device_addr, ETH_ALEN) in p2p_probe_req_rx()
2562 p2p_dbg(p2p, "Found Invite peer - try to start Invite from timeout"); in p2p_probe_req_rx()
2563 eloop_cancel_timeout(p2p_invite_start, p2p, NULL); in p2p_probe_req_rx()
2564 eloop_register_timeout(0, 0, p2p_invite_start, p2p, NULL); in p2p_probe_req_rx()
2572 static int p2p_assoc_req_ie_wlan_ap(struct p2p_data *p2p, const u8 *bssid, in p2p_assoc_req_ie_wlan_ap() argument
2589 p2p_dbg(p2p, "BSS P2P manageability %s", in p2p_assoc_req_ie_wlan_ap()
2607 if (p2p->num_groups > 0) { in p2p_assoc_req_ie_wlan_ap()
2609 if ((p2p->dev_capab & P2P_DEV_CAPAB_CONCURRENT_OPER) && in p2p_assoc_req_ie_wlan_ap()
2610 (p2p->dev_capab & P2P_DEV_CAPAB_INFRA_MANAGED) && in p2p_assoc_req_ie_wlan_ap()
2611 p2p->cross_connect) in p2p_assoc_req_ie_wlan_ap()
2614 p2p_buf_add_capability(tmp, p2p->dev_capab, group_capab); in p2p_assoc_req_ie_wlan_ap()
2615 if ((p2p->dev_capab & P2P_DEV_CAPAB_CONCURRENT_OPER) && in p2p_assoc_req_ie_wlan_ap()
2616 (p2p->dev_capab & P2P_DEV_CAPAB_INFRA_MANAGED)) in p2p_assoc_req_ie_wlan_ap()
2617 p2p_buf_add_p2p_interface(tmp, p2p); in p2p_assoc_req_ie_wlan_ap()
2633 int p2p_assoc_req_ie(struct p2p_data *p2p, const u8 *bssid, u8 *buf, in p2p_assoc_req_ie() argument
2644 return p2p_assoc_req_ie_wlan_ap(p2p, bssid, buf, len, p2p_ie); in p2p_assoc_req_ie()
2647 if (p2p->wfd_ie_assoc_req) in p2p_assoc_req_ie()
2648 extra = wpabuf_len(p2p->wfd_ie_assoc_req); in p2p_assoc_req_ie()
2651 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_REQ]) in p2p_assoc_req_ie()
2652 extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_REQ]); in p2p_assoc_req_ie()
2665 if (p2p->wfd_ie_assoc_req) in p2p_assoc_req_ie()
2666 wpabuf_put_buf(tmp, p2p->wfd_ie_assoc_req); in p2p_assoc_req_ie()
2669 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_REQ]) in p2p_assoc_req_ie()
2671 p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_REQ]); in p2p_assoc_req_ie()
2673 peer = bssid ? p2p_get_device(p2p, bssid) : NULL; in p2p_assoc_req_ie()
2676 p2p_buf_add_capability(tmp, p2p->dev_capab, 0); in p2p_assoc_req_ie()
2677 if (p2p->ext_listen_interval) in p2p_assoc_req_ie()
2678 p2p_buf_add_ext_listen_timing(tmp, p2p->ext_listen_period, in p2p_assoc_req_ie()
2679 p2p->ext_listen_interval); in p2p_assoc_req_ie()
2680 p2p_buf_add_device_info(tmp, p2p, peer); in p2p_assoc_req_ie()
2712 p2p_service_p2ps_id(struct p2p_data *p2p, u32 adv_id) in p2p_service_p2ps_id() argument
2716 if (!p2p) in p2p_service_p2ps_id()
2719 adv_data = p2p->p2ps_adv_list; in p2p_service_p2ps_id()
2730 int p2p_service_del_asp(struct p2p_data *p2p, u32 adv_id) in p2p_service_del_asp() argument
2735 if (!p2p) in p2p_service_del_asp()
2738 adv_data = p2p->p2ps_adv_list; in p2p_service_del_asp()
2739 prior = &p2p->p2ps_adv_list; in p2p_service_del_asp()
2742 p2p_dbg(p2p, "Delete ASP adv_id=0x%x", adv_id); in p2p_service_del_asp()
2755 int p2p_service_add_asp(struct p2p_data *p2p, int auto_accept, u32 adv_id, in p2p_service_add_asp() argument
2764 if (!p2p || !adv_str || !adv_str[0] || !cpt_priority) in p2p_service_add_asp()
2767 if (!(config_methods & p2p->cfg->config_methods)) { in p2p_service_add_asp()
2768 p2p_dbg(p2p, "Config methods not supported svc: 0x%x dev: 0x%x", in p2p_service_add_asp()
2769 config_methods, p2p->cfg->config_methods); in p2p_service_add_asp()
2773 if (!p2ps_gen_hash(p2p, adv_str, buf)) in p2p_service_add_asp()
2789 adv_data->config_methods = config_methods & p2p->cfg->config_methods; in p2p_service_add_asp()
2807 tmp = p2p->p2ps_adv_list; in p2p_service_add_asp()
2808 prev = &p2p->p2ps_adv_list; in p2p_service_add_asp()
2831 adv_data->next = p2p->p2ps_adv_list; in p2p_service_add_asp()
2832 p2p->p2ps_adv_list = adv_data; in p2p_service_add_asp()
2835 p2p_dbg(p2p, in p2p_service_add_asp()
2844 void p2p_service_flush_asp(struct p2p_data *p2p) in p2p_service_flush_asp() argument
2848 if (!p2p) in p2p_service_flush_asp()
2851 adv = p2p->p2ps_adv_list; in p2p_service_flush_asp()
2858 p2p->p2ps_adv_list = NULL; in p2p_service_flush_asp()
2859 p2ps_prov_free(p2p); in p2p_service_flush_asp()
2860 p2p_dbg(p2p, "All ASP advertisements flushed"); in p2p_service_flush_asp()
2898 static void p2p_clear_go_neg(struct p2p_data *p2p) in p2p_clear_go_neg() argument
2900 p2p->go_neg_peer = NULL; in p2p_clear_go_neg()
2901 p2p_clear_timeout(p2p); in p2p_clear_go_neg()
2902 p2p_set_state(p2p, P2P_IDLE); in p2p_clear_go_neg()
2906 void p2p_wps_success_cb(struct p2p_data *p2p, const u8 *mac_addr) in p2p_wps_success_cb() argument
2908 if (p2p->go_neg_peer == NULL) { in p2p_wps_success_cb()
2909 p2p_dbg(p2p, "No pending Group Formation - ignore WPS registration success notification"); in p2p_wps_success_cb()
2913 if (os_memcmp(mac_addr, p2p->go_neg_peer->intended_addr, ETH_ALEN) != in p2p_wps_success_cb()
2915 p2p_dbg(p2p, "Ignore WPS registration success notification for " in p2p_wps_success_cb()
2918 MAC2STR(p2p->go_neg_peer->intended_addr)); in p2p_wps_success_cb()
2922 p2p_dbg(p2p, "Group Formation completed successfully with " MACSTR, in p2p_wps_success_cb()
2925 p2p_clear_go_neg(p2p); in p2p_wps_success_cb()
2929 void p2p_group_formation_failed(struct p2p_data *p2p) in p2p_group_formation_failed() argument
2931 if (p2p->go_neg_peer == NULL) { in p2p_group_formation_failed()
2932 p2p_dbg(p2p, "No pending Group Formation - ignore group formation failure notification"); in p2p_group_formation_failed()
2936 p2p_dbg(p2p, "Group Formation failed with " MACSTR, in p2p_group_formation_failed()
2937 MAC2STR(p2p->go_neg_peer->intended_addr)); in p2p_group_formation_failed()
2939 p2p_clear_go_neg(p2p); in p2p_group_formation_failed()
2945 struct p2p_data *p2p; in p2p_init() local
2951 p2p = os_zalloc(sizeof(*p2p) + sizeof(*cfg)); in p2p_init()
2952 if (p2p == NULL) in p2p_init()
2954 p2p->cfg = (struct p2p_config *) (p2p + 1); in p2p_init()
2955 os_memcpy(p2p->cfg, cfg, sizeof(*cfg)); in p2p_init()
2957 p2p->cfg->dev_name = os_strdup(cfg->dev_name); in p2p_init()
2959 p2p->cfg->manufacturer = os_strdup(cfg->manufacturer); in p2p_init()
2961 p2p->cfg->model_name = os_strdup(cfg->model_name); in p2p_init()
2963 p2p->cfg->model_number = os_strdup(cfg->model_number); in p2p_init()
2965 p2p->cfg->serial_number = os_strdup(cfg->serial_number); in p2p_init()
2967 p2p->cfg->pref_chan = os_malloc(cfg->num_pref_chan * in p2p_init()
2969 if (p2p->cfg->pref_chan) { in p2p_init()
2970 os_memcpy(p2p->cfg->pref_chan, cfg->pref_chan, in p2p_init()
2974 p2p->cfg->num_pref_chan = 0; in p2p_init()
2977 p2ps_gen_hash(p2p, P2PS_WILD_HASH_STR, p2p->wild_card_hash); in p2p_init()
2979 p2p->min_disc_int = 1; in p2p_init()
2980 p2p->max_disc_int = 3; in p2p_init()
2981 p2p->max_disc_tu = -1; in p2p_init()
2983 if (os_get_random(&p2p->next_tie_breaker, 1) < 0) in p2p_init()
2984 p2p->next_tie_breaker = 0; in p2p_init()
2985 p2p->next_tie_breaker &= 0x01; in p2p_init()
2987 p2p->dev_capab |= P2P_DEV_CAPAB_SERVICE_DISCOVERY; in p2p_init()
2988 p2p->dev_capab |= P2P_DEV_CAPAB_INVITATION_PROCEDURE; in p2p_init()
2990 p2p->dev_capab |= P2P_DEV_CAPAB_CONCURRENT_OPER; in p2p_init()
2991 p2p->dev_capab |= P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY; in p2p_init()
2993 dl_list_init(&p2p->devices); in p2p_init()
2995 p2p->go_timeout = 100; in p2p_init()
2996 p2p->client_timeout = 20; in p2p_init()
2997 p2p->num_p2p_sd_queries = 0; in p2p_init()
2999 p2p_dbg(p2p, "initialized"); in p2p_init()
3000 p2p_channels_dump(p2p, "channels", &p2p->cfg->channels); in p2p_init()
3001 p2p_channels_dump(p2p, "cli_channels", &p2p->cfg->cli_channels); in p2p_init()
3003 return p2p; in p2p_init()
3007 void p2p_deinit(struct p2p_data *p2p) in p2p_deinit() argument
3010 wpabuf_free(p2p->wfd_ie_beacon); in p2p_deinit()
3011 wpabuf_free(p2p->wfd_ie_probe_req); in p2p_deinit()
3012 wpabuf_free(p2p->wfd_ie_probe_resp); in p2p_deinit()
3013 wpabuf_free(p2p->wfd_ie_assoc_req); in p2p_deinit()
3014 wpabuf_free(p2p->wfd_ie_invitation); in p2p_deinit()
3015 wpabuf_free(p2p->wfd_ie_prov_disc_req); in p2p_deinit()
3016 wpabuf_free(p2p->wfd_ie_prov_disc_resp); in p2p_deinit()
3017 wpabuf_free(p2p->wfd_ie_go_neg); in p2p_deinit()
3018 wpabuf_free(p2p->wfd_dev_info); in p2p_deinit()
3019 wpabuf_free(p2p->wfd_assoc_bssid); in p2p_deinit()
3020 wpabuf_free(p2p->wfd_coupled_sink_info); in p2p_deinit()
3021 wpabuf_free(p2p->wfd_r2_dev_info); in p2p_deinit()
3024 eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL); in p2p_deinit()
3025 eloop_cancel_timeout(p2p_go_neg_start, p2p, NULL); in p2p_deinit()
3026 eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL); in p2p_deinit()
3027 p2p_flush(p2p); in p2p_deinit()
3028 p2p_free_req_dev_types(p2p); in p2p_deinit()
3029 os_free(p2p->cfg->dev_name); in p2p_deinit()
3030 os_free(p2p->cfg->manufacturer); in p2p_deinit()
3031 os_free(p2p->cfg->model_name); in p2p_deinit()
3032 os_free(p2p->cfg->model_number); in p2p_deinit()
3033 os_free(p2p->cfg->serial_number); in p2p_deinit()
3034 os_free(p2p->cfg->pref_chan); in p2p_deinit()
3035 os_free(p2p->groups); in p2p_deinit()
3036 p2ps_prov_free(p2p); in p2p_deinit()
3037 wpabuf_free(p2p->sd_resp); in p2p_deinit()
3038 p2p_remove_wps_vendor_extensions(p2p); in p2p_deinit()
3039 os_free(p2p->no_go_freq.range); in p2p_deinit()
3040 p2p_service_flush_asp(p2p); in p2p_deinit()
3042 os_free(p2p); in p2p_deinit()
3046 void p2p_flush(struct p2p_data *p2p) in p2p_flush() argument
3050 p2p_ext_listen(p2p, 0, 0); in p2p_flush()
3051 p2p_stop_find(p2p); in p2p_flush()
3052 dl_list_for_each_safe(dev, prev, &p2p->devices, struct p2p_device, in p2p_flush()
3055 p2p_device_free(p2p, dev); in p2p_flush()
3057 p2p_free_sd_queries(p2p); in p2p_flush()
3058 os_free(p2p->after_scan_tx); in p2p_flush()
3059 p2p->after_scan_tx = NULL; in p2p_flush()
3060 p2p->ssid_set = 0; in p2p_flush()
3061 p2ps_prov_free(p2p); in p2p_flush()
3062 p2p_reset_pending_pd(p2p); in p2p_flush()
3063 p2p->override_pref_op_class = 0; in p2p_flush()
3064 p2p->override_pref_channel = 0; in p2p_flush()
3068 int p2p_unauthorize(struct p2p_data *p2p, const u8 *addr) in p2p_unauthorize() argument
3072 dev = p2p_get_device(p2p, addr); in p2p_unauthorize()
3076 p2p_dbg(p2p, "Unauthorizing " MACSTR, MAC2STR(addr)); in p2p_unauthorize()
3078 if (p2p->go_neg_peer == dev) { in p2p_unauthorize()
3079 eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL); in p2p_unauthorize()
3080 p2p->go_neg_peer = NULL; in p2p_unauthorize()
3089 if (p2p->after_scan_tx && in p2p_unauthorize()
3090 os_memcmp(addr, p2p->after_scan_tx->dst, ETH_ALEN) == 0) { in p2p_unauthorize()
3091 os_free(p2p->after_scan_tx); in p2p_unauthorize()
3092 p2p->after_scan_tx = NULL; in p2p_unauthorize()
3099 int p2p_set_dev_name(struct p2p_data *p2p, const char *dev_name) in p2p_set_dev_name() argument
3101 os_free(p2p->cfg->dev_name); in p2p_set_dev_name()
3103 p2p->cfg->dev_name = os_strdup(dev_name); in p2p_set_dev_name()
3104 if (p2p->cfg->dev_name == NULL) in p2p_set_dev_name()
3107 p2p->cfg->dev_name = NULL; in p2p_set_dev_name()
3112 int p2p_set_manufacturer(struct p2p_data *p2p, const char *manufacturer) in p2p_set_manufacturer() argument
3114 os_free(p2p->cfg->manufacturer); in p2p_set_manufacturer()
3115 p2p->cfg->manufacturer = NULL; in p2p_set_manufacturer()
3117 p2p->cfg->manufacturer = os_strdup(manufacturer); in p2p_set_manufacturer()
3118 if (p2p->cfg->manufacturer == NULL) in p2p_set_manufacturer()
3126 int p2p_set_model_name(struct p2p_data *p2p, const char *model_name) in p2p_set_model_name() argument
3128 os_free(p2p->cfg->model_name); in p2p_set_model_name()
3129 p2p->cfg->model_name = NULL; in p2p_set_model_name()
3131 p2p->cfg->model_name = os_strdup(model_name); in p2p_set_model_name()
3132 if (p2p->cfg->model_name == NULL) in p2p_set_model_name()
3140 int p2p_set_model_number(struct p2p_data *p2p, const char *model_number) in p2p_set_model_number() argument
3142 os_free(p2p->cfg->model_number); in p2p_set_model_number()
3143 p2p->cfg->model_number = NULL; in p2p_set_model_number()
3145 p2p->cfg->model_number = os_strdup(model_number); in p2p_set_model_number()
3146 if (p2p->cfg->model_number == NULL) in p2p_set_model_number()
3154 int p2p_set_serial_number(struct p2p_data *p2p, const char *serial_number) in p2p_set_serial_number() argument
3156 os_free(p2p->cfg->serial_number); in p2p_set_serial_number()
3157 p2p->cfg->serial_number = NULL; in p2p_set_serial_number()
3159 p2p->cfg->serial_number = os_strdup(serial_number); in p2p_set_serial_number()
3160 if (p2p->cfg->serial_number == NULL) in p2p_set_serial_number()
3168 void p2p_set_config_methods(struct p2p_data *p2p, u16 config_methods) in p2p_set_config_methods() argument
3170 p2p->cfg->config_methods = config_methods; in p2p_set_config_methods()
3174 void p2p_set_uuid(struct p2p_data *p2p, const u8 *uuid) in p2p_set_uuid() argument
3176 os_memcpy(p2p->cfg->uuid, uuid, 16); in p2p_set_uuid()
3180 int p2p_set_pri_dev_type(struct p2p_data *p2p, const u8 *pri_dev_type) in p2p_set_pri_dev_type() argument
3182 os_memcpy(p2p->cfg->pri_dev_type, pri_dev_type, 8); in p2p_set_pri_dev_type()
3187 int p2p_set_sec_dev_types(struct p2p_data *p2p, const u8 dev_types[][8], in p2p_set_sec_dev_types() argument
3192 p2p->cfg->num_sec_dev_types = num_dev_types; in p2p_set_sec_dev_types()
3193 os_memcpy(p2p->cfg->sec_dev_type, dev_types, num_dev_types * 8); in p2p_set_sec_dev_types()
3198 void p2p_remove_wps_vendor_extensions(struct p2p_data *p2p) in p2p_remove_wps_vendor_extensions() argument
3203 wpabuf_free(p2p->wps_vendor_ext[i]); in p2p_remove_wps_vendor_extensions()
3204 p2p->wps_vendor_ext[i] = NULL; in p2p_remove_wps_vendor_extensions()
3209 int p2p_add_wps_vendor_extension(struct p2p_data *p2p, in p2p_add_wps_vendor_extension() argument
3218 if (p2p->wps_vendor_ext[i] == NULL) in p2p_add_wps_vendor_extension()
3224 p2p->wps_vendor_ext[i] = wpabuf_dup(vendor_ext); in p2p_add_wps_vendor_extension()
3225 if (p2p->wps_vendor_ext[i] == NULL) in p2p_add_wps_vendor_extension()
3232 int p2p_set_country(struct p2p_data *p2p, const char *country) in p2p_set_country() argument
3234 os_memcpy(p2p->cfg->country, country, 3); in p2p_set_country()
3239 static int p2p_pre_find_operation(struct p2p_data *p2p, struct p2p_device *dev) in p2p_pre_find_operation() argument
3246 dev->sd_pending_bcast_queries = p2p->num_p2p_sd_queries; in p2p_pre_find_operation()
3249 res = p2p_start_sd(p2p, dev); in p2p_pre_find_operation()
3257 p2p_dbg(p2p, "Send pending Provision Discovery Request to " in p2p_pre_find_operation()
3261 if (p2p_send_prov_disc_req(p2p, dev, 0, 0) == 0) in p2p_pre_find_operation()
3269 void p2p_continue_find(struct p2p_data *p2p) in p2p_continue_find() argument
3274 p2p_set_state(p2p, P2P_SEARCH); in p2p_continue_find()
3278 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_continue_find()
3279 if (dev == p2p->last_p2p_find_oper) { in p2p_continue_find()
3285 res = p2p_pre_find_operation(p2p, dev); in p2p_continue_find()
3287 p2p->last_p2p_find_oper = dev; in p2p_continue_find()
3298 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_continue_find()
3299 res = p2p_pre_find_operation(p2p, dev); in p2p_continue_find()
3301 p2p->last_p2p_find_oper = dev; in p2p_continue_find()
3306 if (dev == p2p->last_p2p_find_oper) in p2p_continue_find()
3311 os_memset(p2p->sd_query_no_ack, 0, ETH_ALEN); in p2p_continue_find()
3312 p2p_listen_in_find(p2p, 1); in p2p_continue_find()
3316 static void p2p_sd_cb(struct p2p_data *p2p, int success) in p2p_sd_cb() argument
3318 p2p_dbg(p2p, "Service Discovery Query TX callback: success=%d", in p2p_sd_cb()
3320 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_sd_cb()
3323 if (p2p->sd_peer) { in p2p_sd_cb()
3324 if (is_zero_ether_addr(p2p->sd_query_no_ack)) { in p2p_sd_cb()
3325 os_memcpy(p2p->sd_query_no_ack, in p2p_sd_cb()
3326 p2p->sd_peer->info.p2p_device_addr, in p2p_sd_cb()
3328 p2p_dbg(p2p, in p2p_sd_cb()
3330 MACSTR, MAC2STR(p2p->sd_query_no_ack)); in p2p_sd_cb()
3332 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_sd_cb()
3334 p2p->sd_peer = NULL; in p2p_sd_cb()
3335 if (p2p->state != P2P_IDLE) in p2p_sd_cb()
3336 p2p_continue_find(p2p); in p2p_sd_cb()
3340 if (p2p->sd_peer == NULL) { in p2p_sd_cb()
3341 p2p_dbg(p2p, "No SD peer entry known"); in p2p_sd_cb()
3342 if (p2p->state != P2P_IDLE) in p2p_sd_cb()
3343 p2p_continue_find(p2p); in p2p_sd_cb()
3347 if (p2p->sd_query && p2p->sd_query->for_all_peers) { in p2p_sd_cb()
3350 p2p->sd_peer->sd_pending_bcast_queries--; in p2p_sd_cb()
3356 if (p2p->sd_peer->sd_pending_bcast_queries == 0) in p2p_sd_cb()
3357 p2p->sd_peer->sd_pending_bcast_queries = -1; in p2p_sd_cb()
3361 p2p_set_state(p2p, P2P_SD_DURING_FIND); in p2p_sd_cb()
3362 p2p_set_timeout(p2p, 0, 200000); in p2p_sd_cb()
3370 static void p2p_retry_pd(struct p2p_data *p2p) in p2p_retry_pd() argument
3379 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_retry_pd()
3380 if (os_memcmp(p2p->pending_pd_devaddr, in p2p_retry_pd()
3386 p2p_dbg(p2p, "Send pending Provision Discovery Request to " in p2p_retry_pd()
3390 p2p_send_prov_disc_req(p2p, dev, in p2p_retry_pd()
3392 p2p->pd_force_freq); in p2p_retry_pd()
3398 static void p2p_prov_disc_cb(struct p2p_data *p2p, int success) in p2p_prov_disc_cb() argument
3400 p2p_dbg(p2p, "Provision Discovery Request TX callback: success=%d", in p2p_prov_disc_cb()
3414 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_prov_disc_cb()
3416 if (p2p->user_initiated_pd && in p2p_prov_disc_cb()
3417 (p2p->state == P2P_SEARCH || p2p->state == P2P_LISTEN_ONLY)) in p2p_prov_disc_cb()
3420 p2p->pending_action_state = P2P_PENDING_PD; in p2p_prov_disc_cb()
3421 p2p_set_timeout(p2p, 0, 50000); in p2p_prov_disc_cb()
3422 } else if (p2p->state != P2P_IDLE) in p2p_prov_disc_cb()
3423 p2p_continue_find(p2p); in p2p_prov_disc_cb()
3424 else if (p2p->user_initiated_pd) { in p2p_prov_disc_cb()
3425 p2p->pending_action_state = P2P_PENDING_PD; in p2p_prov_disc_cb()
3426 p2p_set_timeout(p2p, 0, 300000); in p2p_prov_disc_cb()
3437 if (p2p->p2ps_prov && !p2p->p2ps_prov->pd_seeker && in p2p_prov_disc_cb()
3438 p2p->p2ps_prov->status != P2P_SC_SUCCESS_DEFERRED) { in p2p_prov_disc_cb()
3439 p2p_dbg(p2p, "P2PS PD completion on Follow-on PD Request ACK"); in p2p_prov_disc_cb()
3441 if (p2p->send_action_in_progress) { in p2p_prov_disc_cb()
3442 p2p->send_action_in_progress = 0; in p2p_prov_disc_cb()
3443 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_prov_disc_cb()
3446 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_prov_disc_cb()
3448 if (p2p->cfg->p2ps_prov_complete) { in p2p_prov_disc_cb()
3449 p2p->cfg->p2ps_prov_complete( in p2p_prov_disc_cb()
3450 p2p->cfg->cb_ctx, in p2p_prov_disc_cb()
3451 p2p->p2ps_prov->status, in p2p_prov_disc_cb()
3452 p2p->p2ps_prov->adv_mac, in p2p_prov_disc_cb()
3453 p2p->p2ps_prov->adv_mac, in p2p_prov_disc_cb()
3454 p2p->p2ps_prov->session_mac, in p2p_prov_disc_cb()
3455 NULL, p2p->p2ps_prov->adv_id, in p2p_prov_disc_cb()
3456 p2p->p2ps_prov->session_id, in p2p_prov_disc_cb()
3461 if (p2p->user_initiated_pd) in p2p_prov_disc_cb()
3462 p2p_reset_pending_pd(p2p); in p2p_prov_disc_cb()
3464 p2ps_prov_free(p2p); in p2p_prov_disc_cb()
3472 if (p2p->user_initiated_pd) in p2p_prov_disc_cb()
3473 p2p->pending_action_state = P2P_PENDING_PD; in p2p_prov_disc_cb()
3475 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_prov_disc_cb()
3478 if (p2p->state == P2P_SEARCH) in p2p_prov_disc_cb()
3479 p2p_set_state(p2p, P2P_PD_DURING_FIND); in p2p_prov_disc_cb()
3480 p2p_set_timeout(p2p, 0, 200000); in p2p_prov_disc_cb()
3484 static int p2p_check_after_scan_tx_continuation(struct p2p_data *p2p) in p2p_check_after_scan_tx_continuation() argument
3486 if (p2p->after_scan_tx_in_progress) { in p2p_check_after_scan_tx_continuation()
3487 p2p->after_scan_tx_in_progress = 0; in p2p_check_after_scan_tx_continuation()
3488 if (p2p->start_after_scan != P2P_AFTER_SCAN_NOTHING && in p2p_check_after_scan_tx_continuation()
3489 p2p_run_after_scan(p2p)) in p2p_check_after_scan_tx_continuation()
3491 if (p2p->state == P2P_SEARCH) { in p2p_check_after_scan_tx_continuation()
3492 p2p_dbg(p2p, "Continue find after after_scan_tx completion"); in p2p_check_after_scan_tx_continuation()
3493 p2p_continue_find(p2p); in p2p_check_after_scan_tx_continuation()
3501 static void p2p_prov_disc_resp_cb(struct p2p_data *p2p, int success) in p2p_prov_disc_resp_cb() argument
3503 p2p_dbg(p2p, "Provision Discovery Response TX callback: success=%d", in p2p_prov_disc_resp_cb()
3506 if (p2p->send_action_in_progress) { in p2p_prov_disc_resp_cb()
3507 p2p->send_action_in_progress = 0; in p2p_prov_disc_resp_cb()
3508 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_prov_disc_resp_cb()
3511 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_prov_disc_resp_cb()
3516 if (!p2p->cfg->prov_disc_resp_cb || in p2p_prov_disc_resp_cb()
3517 p2p->cfg->prov_disc_resp_cb(p2p->cfg->cb_ctx) < 1) in p2p_prov_disc_resp_cb()
3520 p2p_dbg(p2p, in p2p_prov_disc_resp_cb()
3525 p2p_check_after_scan_tx_continuation(p2p); in p2p_prov_disc_resp_cb()
3529 int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq, in p2p_scan_res_handler() argument
3533 if (os_reltime_before(rx_time, &p2p->find_start)) { in p2p_scan_res_handler()
3541 p2p_dbg(p2p, "Ignore old scan result for " MACSTR in p2p_scan_res_handler()
3545 (unsigned int) p2p->find_start.sec, in p2p_scan_res_handler()
3546 (unsigned int) p2p->find_start.usec); in p2p_scan_res_handler()
3550 p2p_add_device(p2p, bssid, freq, rx_time, level, ies, ies_len, 1); in p2p_scan_res_handler()
3556 void p2p_scan_res_handled(struct p2p_data *p2p) in p2p_scan_res_handled() argument
3558 if (!p2p->p2p_scan_running) { in p2p_scan_res_handled()
3559 p2p_dbg(p2p, "p2p_scan was not running, but scan results received"); in p2p_scan_res_handled()
3561 p2p->p2p_scan_running = 0; in p2p_scan_res_handled()
3562 eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL); in p2p_scan_res_handled()
3564 if (p2p_run_after_scan(p2p)) in p2p_scan_res_handled()
3566 if (p2p->state == P2P_SEARCH) in p2p_scan_res_handled()
3567 p2p_continue_find(p2p); in p2p_scan_res_handled()
3571 void p2p_scan_ie(struct p2p_data *p2p, struct wpabuf *ies, const u8 *dev_id, in p2p_scan_ie() argument
3578 if (p2p->wfd_ie_probe_req) in p2p_scan_ie()
3579 wpabuf_put_buf(ies, p2p->wfd_ie_probe_req); in p2p_scan_ie()
3582 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_PROBE_REQ_P2P]) in p2p_scan_ie()
3584 p2p->vendor_elem[VENDOR_ELEM_PROBE_REQ_P2P]); in p2p_scan_ie()
3588 dev_capab = p2p->dev_capab & ~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY; in p2p_scan_ie()
3591 if (p2p->p2ps_seek && p2p->p2ps_seek_count) in p2p_scan_ie()
3598 if (p2p->cfg->reg_class && p2p->cfg->channel) in p2p_scan_ie()
3599 p2p_buf_add_listen_channel(ies, p2p->cfg->country, in p2p_scan_ie()
3600 p2p->cfg->reg_class, in p2p_scan_ie()
3601 p2p->cfg->channel); in p2p_scan_ie()
3602 if (p2p->ext_listen_interval) in p2p_scan_ie()
3603 p2p_buf_add_ext_listen_timing(ies, p2p->ext_listen_period, in p2p_scan_ie()
3604 p2p->ext_listen_interval); in p2p_scan_ie()
3607 p2p_buf_add_device_info(ies, p2p, NULL); in p2p_scan_ie()
3609 if (p2p->p2ps_seek && p2p->p2ps_seek_count) in p2p_scan_ie()
3610 p2p_buf_add_service_hash(ies, p2p); in p2p_scan_ie()
3617 size_t p2p_scan_ie_buf_len(struct p2p_data *p2p) in p2p_scan_ie_buf_len() argument
3622 if (p2p && p2p->wfd_ie_probe_req) in p2p_scan_ie_buf_len()
3623 len += wpabuf_len(p2p->wfd_ie_probe_req); in p2p_scan_ie_buf_len()
3626 if (p2p && p2p->vendor_elem && in p2p_scan_ie_buf_len()
3627 p2p->vendor_elem[VENDOR_ELEM_PROBE_REQ_P2P]) in p2p_scan_ie_buf_len()
3628 len += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_PROBE_REQ_P2P]); in p2p_scan_ie_buf_len()
3640 static void p2p_go_neg_req_cb(struct p2p_data *p2p, int success) in p2p_go_neg_req_cb() argument
3642 struct p2p_device *dev = p2p->go_neg_peer; in p2p_go_neg_req_cb()
3645 p2p_dbg(p2p, "GO Negotiation Request TX callback: success=%d", success); in p2p_go_neg_req_cb()
3648 p2p_dbg(p2p, "No pending GO Negotiation"); in p2p_go_neg_req_cb()
3654 p2p_set_state(p2p, P2P_IDLE); in p2p_go_neg_req_cb()
3665 …p2p_dbg(p2p, "Peer " MACSTR " did not acknowledge request - try to use device discoverability thro… in p2p_go_neg_req_cb()
3667 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_go_neg_req_cb()
3668 p2p_send_dev_disc_req(p2p, dev); in p2p_go_neg_req_cb()
3676 p2p_set_state(p2p, P2P_CONNECT); in p2p_go_neg_req_cb()
3678 if (!success && p2p->go_neg_peer && in p2p_go_neg_req_cb()
3679 (p2p->go_neg_peer->flags & P2P_DEV_PEER_WAITING_RESPONSE)) { in p2p_go_neg_req_cb()
3691 p2p_set_timeout(p2p, 0, timeout); in p2p_go_neg_req_cb()
3695 static void p2p_go_neg_resp_cb(struct p2p_data *p2p, int success) in p2p_go_neg_resp_cb() argument
3697 p2p_dbg(p2p, "GO Negotiation Response TX callback: success=%d", in p2p_go_neg_resp_cb()
3699 if (!p2p->go_neg_peer && p2p->state == P2P_PROVISIONING) { in p2p_go_neg_resp_cb()
3700 p2p_dbg(p2p, "Ignore TX callback event - GO Negotiation is not running anymore"); in p2p_go_neg_resp_cb()
3703 p2p_set_state(p2p, P2P_CONNECT); in p2p_go_neg_resp_cb()
3704 p2p_set_timeout(p2p, 0, 500000); in p2p_go_neg_resp_cb()
3708 static void p2p_go_neg_resp_failure_cb(struct p2p_data *p2p, int success, in p2p_go_neg_resp_failure_cb() argument
3711 p2p_dbg(p2p, "GO Negotiation Response (failure) TX callback: success=%d", success); in p2p_go_neg_resp_failure_cb()
3712 if (p2p->go_neg_peer && p2p->go_neg_peer->status != P2P_SC_SUCCESS) { in p2p_go_neg_resp_failure_cb()
3713 p2p_go_neg_failed(p2p, p2p->go_neg_peer->status); in p2p_go_neg_resp_failure_cb()
3719 dev = p2p_get_device(p2p, addr); in p2p_go_neg_resp_failure_cb()
3725 if (p2p->state == P2P_SEARCH || p2p->state == P2P_SD_DURING_FIND) in p2p_go_neg_resp_failure_cb()
3726 p2p_continue_find(p2p); in p2p_go_neg_resp_failure_cb()
3730 static void p2p_go_neg_conf_cb(struct p2p_data *p2p, in p2p_go_neg_conf_cb() argument
3735 p2p_dbg(p2p, "GO Negotiation Confirm TX callback: result=%d", result); in p2p_go_neg_conf_cb()
3737 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_go_neg_conf_cb()
3738 p2p_go_neg_failed(p2p, -1); in p2p_go_neg_conf_cb()
3742 dev = p2p->go_neg_peer; in p2p_go_neg_conf_cb()
3752 p2p_dbg(p2p, "GO Negotiation Confirm retry %d", in p2p_go_neg_conf_cb()
3754 p2p->pending_action_state = P2P_PENDING_GO_NEG_CONFIRM; in p2p_go_neg_conf_cb()
3755 if (p2p_send_action(p2p, dev->go_neg_conf_freq, in p2p_go_neg_conf_cb()
3757 p2p->cfg->dev_addr, in p2p_go_neg_conf_cb()
3765 p2p_dbg(p2p, "Failed to re-send Action frame"); in p2p_go_neg_conf_cb()
3783 …p2p_dbg(p2p, "Assume GO Negotiation Confirm TX was actually received by the peer even though Ack w… in p2p_go_neg_conf_cb()
3786 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_go_neg_conf_cb()
3791 p2p_go_complete(p2p, dev); in p2p_go_neg_conf_cb()
3795 void p2p_send_action_cb(struct p2p_data *p2p, unsigned int freq, const u8 *dst, in p2p_send_action_cb() argument
3802 p2p_dbg(p2p, "Action frame TX callback (state=%d freq=%u dst=" MACSTR in p2p_send_action_cb()
3804 p2p->pending_action_state, freq, MAC2STR(dst), MAC2STR(src), in p2p_send_action_cb()
3805 MAC2STR(bssid), result, p2p_state_txt(p2p->state)); in p2p_send_action_cb()
3807 state = p2p->pending_action_state; in p2p_send_action_cb()
3808 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_send_action_cb()
3811 if (p2p->send_action_in_progress) { in p2p_send_action_cb()
3812 p2p->send_action_in_progress = 0; in p2p_send_action_cb()
3813 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_send_action_cb()
3815 p2p_check_after_scan_tx_continuation(p2p); in p2p_send_action_cb()
3818 p2p_go_neg_req_cb(p2p, success); in p2p_send_action_cb()
3821 p2p_go_neg_resp_cb(p2p, success); in p2p_send_action_cb()
3824 p2p_go_neg_resp_failure_cb(p2p, success, dst); in p2p_send_action_cb()
3827 p2p_go_neg_conf_cb(p2p, result); in p2p_send_action_cb()
3830 p2p_sd_cb(p2p, success); in p2p_send_action_cb()
3833 p2p_prov_disc_cb(p2p, success); in p2p_send_action_cb()
3836 p2p_prov_disc_resp_cb(p2p, success); in p2p_send_action_cb()
3839 p2p_invitation_req_cb(p2p, success); in p2p_send_action_cb()
3842 p2p_invitation_resp_cb(p2p, success); in p2p_send_action_cb()
3843 if (p2p->inv_status != P2P_SC_SUCCESS) in p2p_send_action_cb()
3844 p2p_check_after_scan_tx_continuation(p2p); in p2p_send_action_cb()
3847 p2p_dev_disc_req_cb(p2p, success); in p2p_send_action_cb()
3850 p2p_dev_disc_resp_cb(p2p, success); in p2p_send_action_cb()
3853 p2p_go_disc_req_cb(p2p, success); in p2p_send_action_cb()
3857 p2p->after_scan_tx_in_progress = 0; in p2p_send_action_cb()
3861 void p2p_listen_cb(struct p2p_data *p2p, unsigned int freq, in p2p_listen_cb() argument
3864 if (freq == p2p->pending_client_disc_freq) { in p2p_listen_cb()
3865 p2p_dbg(p2p, "Client discoverability remain-awake completed"); in p2p_listen_cb()
3866 p2p->pending_client_disc_freq = 0; in p2p_listen_cb()
3870 if (freq != p2p->pending_listen_freq) { in p2p_listen_cb()
3871 p2p_dbg(p2p, "Unexpected listen callback for freq=%u duration=%u (pending_listen_freq=%u)", in p2p_listen_cb()
3872 freq, duration, p2p->pending_listen_freq); in p2p_listen_cb()
3876 p2p_dbg(p2p, "Starting Listen timeout(%u,%u) on freq=%u based on callback", in p2p_listen_cb()
3877 p2p->pending_listen_sec, p2p->pending_listen_usec, in p2p_listen_cb()
3878 p2p->pending_listen_freq); in p2p_listen_cb()
3879 p2p->in_listen = 1; in p2p_listen_cb()
3880 p2p->drv_in_listen = freq; in p2p_listen_cb()
3881 if (p2p->pending_listen_sec || p2p->pending_listen_usec) { in p2p_listen_cb()
3887 p2p_set_timeout(p2p, p2p->pending_listen_sec, in p2p_listen_cb()
3888 p2p->pending_listen_usec + 20000); in p2p_listen_cb()
3891 p2p->pending_listen_freq = 0; in p2p_listen_cb()
3895 int p2p_listen_end(struct p2p_data *p2p, unsigned int freq) in p2p_listen_end() argument
3897 p2p_dbg(p2p, "Driver ended Listen state (freq=%u)", freq); in p2p_listen_end()
3898 p2p->drv_in_listen = 0; in p2p_listen_end()
3899 if (p2p->in_listen) in p2p_listen_end()
3902 if (p2p->state == P2P_WAIT_PEER_CONNECT && p2p->go_neg_peer && in p2p_listen_end()
3903 p2p->pending_listen_freq) { in p2p_listen_end()
3909 p2p_dbg(p2p, in p2p_listen_end()
3911 p2p_set_timeout(p2p, 0, 100000); in p2p_listen_end()
3915 if (p2p->state == P2P_CONNECT_LISTEN && p2p->go_neg_peer) { in p2p_listen_end()
3916 if (p2p->go_neg_peer->connect_reqs >= 120) { in p2p_listen_end()
3917 p2p_dbg(p2p, "Timeout on sending GO Negotiation Request without getting response"); in p2p_listen_end()
3918 p2p_go_neg_failed(p2p, -1); in p2p_listen_end()
3922 p2p_set_state(p2p, P2P_CONNECT); in p2p_listen_end()
3923 p2p_connect_send(p2p, p2p->go_neg_peer); in p2p_listen_end()
3925 } else if (p2p->state == P2P_SEARCH) { in p2p_listen_end()
3926 if (p2p->p2p_scan_running) { in p2p_listen_end()
3935 p2p_dbg(p2p, "p2p_scan already in progress - do not try to start a new one"); in p2p_listen_end()
3938 if (p2p->pending_listen_freq) { in p2p_listen_end()
3944 p2p_dbg(p2p, "Listen operation did not seem to start - delay search phase to avoid busy loop"); in p2p_listen_end()
3945 p2p_set_timeout(p2p, 0, 100000); in p2p_listen_end()
3948 if (p2p->search_delay) { in p2p_listen_end()
3949 p2p_dbg(p2p, "Delay search operation by %u ms", in p2p_listen_end()
3950 p2p->search_delay); in p2p_listen_end()
3951 p2p_set_timeout(p2p, p2p->search_delay / 1000, in p2p_listen_end()
3952 (p2p->search_delay % 1000) * 1000); in p2p_listen_end()
3955 p2p_search(p2p); in p2p_listen_end()
3963 static void p2p_timeout_connect(struct p2p_data *p2p) in p2p_timeout_connect() argument
3965 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_timeout_connect()
3966 if (p2p->go_neg_peer && in p2p_timeout_connect()
3967 (p2p->go_neg_peer->flags & P2P_DEV_WAIT_GO_NEG_CONFIRM)) { in p2p_timeout_connect()
3968 p2p_dbg(p2p, "Wait for GO Negotiation Confirm timed out - assume GO Negotiation failed"); in p2p_timeout_connect()
3969 p2p_go_neg_failed(p2p, -1); in p2p_timeout_connect()
3972 if (p2p->go_neg_peer && in p2p_timeout_connect()
3973 (p2p->go_neg_peer->flags & P2P_DEV_PEER_WAITING_RESPONSE) && in p2p_timeout_connect()
3974 p2p->go_neg_peer->connect_reqs < 120) { in p2p_timeout_connect()
3975 p2p_dbg(p2p, "Peer expected to wait our response - skip listen"); in p2p_timeout_connect()
3976 p2p_connect_send(p2p, p2p->go_neg_peer); in p2p_timeout_connect()
3979 if (p2p->go_neg_peer && p2p->go_neg_peer->oob_go_neg_freq > 0) { in p2p_timeout_connect()
3980 p2p_dbg(p2p, "Skip connect-listen since GO Neg channel known (OOB)"); in p2p_timeout_connect()
3981 p2p_set_state(p2p, P2P_CONNECT_LISTEN); in p2p_timeout_connect()
3982 p2p_set_timeout(p2p, 0, 30000); in p2p_timeout_connect()
3985 p2p_set_state(p2p, P2P_CONNECT_LISTEN); in p2p_timeout_connect()
3986 p2p_listen_in_find(p2p, 0); in p2p_timeout_connect()
3990 static void p2p_timeout_connect_listen(struct p2p_data *p2p) in p2p_timeout_connect_listen() argument
3992 if (p2p->go_neg_peer) { in p2p_timeout_connect_listen()
3993 if (p2p->drv_in_listen) { in p2p_timeout_connect_listen()
3994 p2p_dbg(p2p, "Driver is still in Listen state; wait for it to complete"); in p2p_timeout_connect_listen()
3998 if (p2p->go_neg_peer->connect_reqs >= 120) { in p2p_timeout_connect_listen()
3999 p2p_dbg(p2p, "Timeout on sending GO Negotiation Request without getting response"); in p2p_timeout_connect_listen()
4000 p2p_go_neg_failed(p2p, -1); in p2p_timeout_connect_listen()
4004 p2p_set_state(p2p, P2P_CONNECT); in p2p_timeout_connect_listen()
4005 p2p_connect_send(p2p, p2p->go_neg_peer); in p2p_timeout_connect_listen()
4007 p2p_set_state(p2p, P2P_IDLE); in p2p_timeout_connect_listen()
4011 static void p2p_timeout_wait_peer_connect(struct p2p_data *p2p) in p2p_timeout_wait_peer_connect() argument
4013 p2p_set_state(p2p, P2P_WAIT_PEER_IDLE); in p2p_timeout_wait_peer_connect()
4015 if (p2p->cfg->is_concurrent_session_active && in p2p_timeout_wait_peer_connect()
4016 p2p->cfg->is_concurrent_session_active(p2p->cfg->cb_ctx)) in p2p_timeout_wait_peer_connect()
4017 p2p_set_timeout(p2p, 0, 500000); in p2p_timeout_wait_peer_connect()
4019 p2p_set_timeout(p2p, 0, 200000); in p2p_timeout_wait_peer_connect()
4023 static void p2p_timeout_wait_peer_idle(struct p2p_data *p2p) in p2p_timeout_wait_peer_idle() argument
4025 struct p2p_device *dev = p2p->go_neg_peer; in p2p_timeout_wait_peer_idle()
4028 p2p_dbg(p2p, "Unknown GO Neg peer - stop GO Neg wait"); in p2p_timeout_wait_peer_idle()
4032 p2p_dbg(p2p, "Go to Listen state while waiting for the peer to become ready for GO Negotiation"); in p2p_timeout_wait_peer_idle()
4033 p2p_set_state(p2p, P2P_WAIT_PEER_CONNECT); in p2p_timeout_wait_peer_idle()
4034 p2p_listen_in_find(p2p, 0); in p2p_timeout_wait_peer_idle()
4038 static void p2p_timeout_sd_during_find(struct p2p_data *p2p) in p2p_timeout_sd_during_find() argument
4040 p2p_dbg(p2p, "Service Discovery Query timeout"); in p2p_timeout_sd_during_find()
4041 if (p2p->sd_peer) { in p2p_timeout_sd_during_find()
4042 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_timeout_sd_during_find()
4043 p2p->sd_peer = NULL; in p2p_timeout_sd_during_find()
4045 p2p_continue_find(p2p); in p2p_timeout_sd_during_find()
4049 static void p2p_timeout_prov_disc_during_find(struct p2p_data *p2p) in p2p_timeout_prov_disc_during_find() argument
4051 p2p_dbg(p2p, "Provision Discovery Request timeout"); in p2p_timeout_prov_disc_during_find()
4052 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_timeout_prov_disc_during_find()
4053 p2p_continue_find(p2p); in p2p_timeout_prov_disc_during_find()
4057 static void p2p_timeout_prov_disc_req(struct p2p_data *p2p) in p2p_timeout_prov_disc_req() argument
4062 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_timeout_prov_disc_req()
4069 if (!p2p->user_initiated_pd) in p2p_timeout_prov_disc_req()
4072 p2p_dbg(p2p, "User initiated Provision Discovery Request timeout"); in p2p_timeout_prov_disc_req()
4074 if (p2p->pd_retries) { in p2p_timeout_prov_disc_req()
4075 p2p->pd_retries--; in p2p_timeout_prov_disc_req()
4076 p2p_retry_pd(p2p); in p2p_timeout_prov_disc_req()
4081 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_timeout_prov_disc_req()
4082 if (os_memcmp(p2p->pending_pd_devaddr, in p2p_timeout_prov_disc_req()
4090 if (p2p->p2ps_prov) { in p2p_timeout_prov_disc_req()
4091 adv_id = p2p->p2ps_prov->adv_id; in p2p_timeout_prov_disc_req()
4092 adv_mac = p2p->p2ps_prov->adv_mac; in p2p_timeout_prov_disc_req()
4095 if (p2p->cfg->prov_disc_fail) in p2p_timeout_prov_disc_req()
4096 p2p->cfg->prov_disc_fail(p2p->cfg->cb_ctx, in p2p_timeout_prov_disc_req()
4097 p2p->pending_pd_devaddr, in p2p_timeout_prov_disc_req()
4102 p2p_reset_pending_pd(p2p); in p2p_timeout_prov_disc_req()
4107 static void p2p_timeout_invite(struct p2p_data *p2p) in p2p_timeout_invite() argument
4109 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_timeout_invite()
4110 p2p_set_state(p2p, P2P_INVITE_LISTEN); in p2p_timeout_invite()
4111 if (p2p->inv_role == P2P_INVITE_ROLE_ACTIVE_GO) { in p2p_timeout_invite()
4116 p2p_dbg(p2p, "Inviting in active GO role - wait on operating channel"); in p2p_timeout_invite()
4117 p2p_set_timeout(p2p, 0, 100000); in p2p_timeout_invite()
4120 p2p_listen_in_find(p2p, 0); in p2p_timeout_invite()
4124 static void p2p_timeout_invite_listen(struct p2p_data *p2p) in p2p_timeout_invite_listen() argument
4126 if (p2p->invite_peer && p2p->invite_peer->invitation_reqs < 100) { in p2p_timeout_invite_listen()
4127 p2p_set_state(p2p, P2P_INVITE); in p2p_timeout_invite_listen()
4128 p2p_invite_send(p2p, p2p->invite_peer, in p2p_timeout_invite_listen()
4129 p2p->invite_go_dev_addr, p2p->invite_dev_pw_id); in p2p_timeout_invite_listen()
4131 if (p2p->invite_peer) { in p2p_timeout_invite_listen()
4132 p2p_dbg(p2p, "Invitation Request retry limit reached"); in p2p_timeout_invite_listen()
4133 if (p2p->cfg->invitation_result) in p2p_timeout_invite_listen()
4134 p2p->cfg->invitation_result( in p2p_timeout_invite_listen()
4135 p2p->cfg->cb_ctx, -1, NULL, NULL, in p2p_timeout_invite_listen()
4136 p2p->invite_peer->info.p2p_device_addr, in p2p_timeout_invite_listen()
4139 p2p_set_state(p2p, P2P_IDLE); in p2p_timeout_invite_listen()
4146 struct p2p_data *p2p = eloop_ctx; in p2p_state_timeout() local
4148 p2p_dbg(p2p, "Timeout (state=%s)", p2p_state_txt(p2p->state)); in p2p_state_timeout()
4150 p2p->in_listen = 0; in p2p_state_timeout()
4151 if (p2p->drv_in_listen) { in p2p_state_timeout()
4152 p2p_dbg(p2p, "Driver is still in listen state - stop it"); in p2p_state_timeout()
4153 p2p->cfg->stop_listen(p2p->cfg->cb_ctx); in p2p_state_timeout()
4156 switch (p2p->state) { in p2p_state_timeout()
4159 if (p2p->pending_action_state == P2P_PENDING_PD) in p2p_state_timeout()
4160 p2p_timeout_prov_disc_req(p2p); in p2p_state_timeout()
4164 if (p2p->pending_action_state == P2P_PENDING_PD) in p2p_state_timeout()
4165 p2p_timeout_prov_disc_req(p2p); in p2p_state_timeout()
4166 if (p2p->search_delay && !p2p->in_search_delay) { in p2p_state_timeout()
4167 p2p_dbg(p2p, "Delay search operation by %u ms", in p2p_state_timeout()
4168 p2p->search_delay); in p2p_state_timeout()
4169 p2p->in_search_delay = 1; in p2p_state_timeout()
4170 p2p_set_timeout(p2p, p2p->search_delay / 1000, in p2p_state_timeout()
4171 (p2p->search_delay % 1000) * 1000); in p2p_state_timeout()
4174 p2p->in_search_delay = 0; in p2p_state_timeout()
4175 p2p_search(p2p); in p2p_state_timeout()
4178 p2p_timeout_connect(p2p); in p2p_state_timeout()
4181 p2p_timeout_connect_listen(p2p); in p2p_state_timeout()
4187 if (p2p->pending_action_state == P2P_PENDING_PD) in p2p_state_timeout()
4188 p2p_timeout_prov_disc_req(p2p); in p2p_state_timeout()
4190 if (p2p->ext_listen_only) { in p2p_state_timeout()
4191 p2p_dbg(p2p, "Extended Listen Timing - Listen State completed"); in p2p_state_timeout()
4192 p2p->ext_listen_only = 0; in p2p_state_timeout()
4193 p2p_set_state(p2p, P2P_IDLE); in p2p_state_timeout()
4197 p2p_timeout_wait_peer_connect(p2p); in p2p_state_timeout()
4200 p2p_timeout_wait_peer_idle(p2p); in p2p_state_timeout()
4203 p2p_timeout_sd_during_find(p2p); in p2p_state_timeout()
4208 p2p_timeout_prov_disc_during_find(p2p); in p2p_state_timeout()
4211 p2p_timeout_invite(p2p); in p2p_state_timeout()
4214 p2p_timeout_invite_listen(p2p); in p2p_state_timeout()
4220 int p2p_reject(struct p2p_data *p2p, const u8 *peer_addr) in p2p_reject() argument
4224 dev = p2p_get_device(p2p, peer_addr); in p2p_reject()
4225 p2p_dbg(p2p, "Local request to reject connection attempts by peer " in p2p_reject()
4228 p2p_dbg(p2p, "Peer " MACSTR " unknown", MAC2STR(peer_addr)); in p2p_reject()
4273 const struct p2p_peer_info * p2p_get_peer_info(struct p2p_data *p2p, in p2p_get_peer_info() argument
4279 dev = p2p_get_device(p2p, addr); in p2p_get_peer_info()
4281 dev = dl_list_first(&p2p->devices, struct p2p_device, list); in p2p_get_peer_info()
4285 if (&dev->list == &p2p->devices) in p2p_get_peer_info()
4423 int p2p_peer_known(struct p2p_data *p2p, const u8 *addr) in p2p_peer_known() argument
4425 return p2p_get_device(p2p, addr) != NULL; in p2p_peer_known()
4429 void p2p_set_client_discoverability(struct p2p_data *p2p, int enabled) in p2p_set_client_discoverability() argument
4432 p2p_dbg(p2p, "Client discoverability enabled"); in p2p_set_client_discoverability()
4433 p2p->dev_capab |= P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY; in p2p_set_client_discoverability()
4435 p2p_dbg(p2p, "Client discoverability disabled"); in p2p_set_client_discoverability()
4436 p2p->dev_capab &= ~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY; in p2p_set_client_discoverability()
4477 int p2p_presence_req(struct p2p_data *p2p, const u8 *go_interface_addr, in p2p_presence_req() argument
4484 p2p_dbg(p2p, "Send Presence Request to GO " MACSTR in p2p_presence_req()
4495 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_presence_req()
4496 if (p2p_send_action(p2p, freq, go_interface_addr, own_interface_addr, in p2p_presence_req()
4499 p2p_dbg(p2p, "Failed to send Action frame"); in p2p_presence_req()
4532 static void p2p_process_presence_req(struct p2p_data *p2p, const u8 *da, in p2p_process_presence_req() argument
4545 p2p_dbg(p2p, "Received P2P Action - P2P Presence Request"); in p2p_process_presence_req()
4547 for (g = 0; g < p2p->num_groups; g++) { in p2p_process_presence_req()
4548 if (os_memcmp(da, p2p_group_get_interface_addr(p2p->groups[g]), in p2p_process_presence_req()
4550 group = p2p->groups[g]; in p2p_process_presence_req()
4555 p2p_dbg(p2p, "Ignore P2P Presence Request for unknown group " in p2p_process_presence_req()
4561 p2p_dbg(p2p, "Failed to parse P2P Presence Request"); in p2p_process_presence_req()
4568 p2p_dbg(p2p, "No NoA attribute in P2P Presence Request"); in p2p_process_presence_req()
4576 if (p2p->cfg->get_noa) in p2p_process_presence_req()
4577 noa_len = p2p->cfg->get_noa(p2p->cfg->cb_ctx, da, noa, in p2p_process_presence_req()
4589 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_process_presence_req()
4590 if (p2p_send_action(p2p, rx_freq, sa, da, da, in p2p_process_presence_req()
4592 p2p_dbg(p2p, "Failed to send Action frame"); in p2p_process_presence_req()
4598 static void p2p_process_presence_resp(struct p2p_data *p2p, const u8 *da, in p2p_process_presence_resp() argument
4603 p2p_dbg(p2p, "Received P2P Action - P2P Presence Response"); in p2p_process_presence_resp()
4606 p2p_dbg(p2p, "Failed to parse P2P Presence Response"); in p2p_process_presence_resp()
4611 p2p_dbg(p2p, "No Status or NoA attribute in P2P Presence Response"); in p2p_process_presence_resp()
4616 if (p2p->cfg->presence_resp) { in p2p_process_presence_resp()
4617 p2p->cfg->presence_resp(p2p->cfg->cb_ctx, sa, *msg.status, in p2p_process_presence_resp()
4622 p2p_dbg(p2p, "P2P Presence Request was rejected: status %u", in p2p_process_presence_resp()
4628 p2p_dbg(p2p, "P2P Presence Request was accepted"); in p2p_process_presence_resp()
4638 struct p2p_data *p2p = eloop_ctx; in p2p_ext_listen_timeout() local
4640 if (p2p->ext_listen_interval) { in p2p_ext_listen_timeout()
4642 eloop_register_timeout(p2p->ext_listen_interval_sec, in p2p_ext_listen_timeout()
4643 p2p->ext_listen_interval_usec, in p2p_ext_listen_timeout()
4644 p2p_ext_listen_timeout, p2p, NULL); in p2p_ext_listen_timeout()
4647 if ((p2p->cfg->is_p2p_in_progress && in p2p_ext_listen_timeout()
4648 p2p->cfg->is_p2p_in_progress(p2p->cfg->cb_ctx)) || in p2p_ext_listen_timeout()
4649 (p2p->pending_action_state == P2P_PENDING_PD && in p2p_ext_listen_timeout()
4650 p2p->pd_retries > 0)) { in p2p_ext_listen_timeout()
4651 p2p_dbg(p2p, "Operation in progress - skip Extended Listen timeout (%s)", in p2p_ext_listen_timeout()
4652 p2p_state_txt(p2p->state)); in p2p_ext_listen_timeout()
4656 if (p2p->state == P2P_LISTEN_ONLY && p2p->ext_listen_only) { in p2p_ext_listen_timeout()
4663 p2p_dbg(p2p, "Previous Extended Listen operation had not been completed - try again"); in p2p_ext_listen_timeout()
4664 p2p->ext_listen_only = 0; in p2p_ext_listen_timeout()
4665 p2p_set_state(p2p, P2P_IDLE); in p2p_ext_listen_timeout()
4668 if (p2p->state != P2P_IDLE) { in p2p_ext_listen_timeout()
4669 p2p_dbg(p2p, "Skip Extended Listen timeout in active state (%s)", p2p_state_txt(p2p->state)); in p2p_ext_listen_timeout()
4673 p2p_dbg(p2p, "Extended Listen timeout"); in p2p_ext_listen_timeout()
4674 p2p->ext_listen_only = 1; in p2p_ext_listen_timeout()
4675 if (p2p_listen(p2p, p2p->ext_listen_period) < 0) { in p2p_ext_listen_timeout()
4676 p2p_dbg(p2p, "Failed to start Listen state for Extended Listen Timing"); in p2p_ext_listen_timeout()
4677 p2p->ext_listen_only = 0; in p2p_ext_listen_timeout()
4682 int p2p_ext_listen(struct p2p_data *p2p, unsigned int period, in p2p_ext_listen() argument
4687 p2p_dbg(p2p, "Invalid Extended Listen Timing request: period=%u interval=%u", in p2p_ext_listen()
4692 eloop_cancel_timeout(p2p_ext_listen_timeout, p2p, NULL); in p2p_ext_listen()
4695 p2p_dbg(p2p, "Disabling Extended Listen Timing"); in p2p_ext_listen()
4696 p2p->ext_listen_period = 0; in p2p_ext_listen()
4697 p2p->ext_listen_interval = 0; in p2p_ext_listen()
4701 p2p_dbg(p2p, "Enabling Extended Listen Timing: period %u msec, interval %u msec", in p2p_ext_listen()
4703 p2p->ext_listen_period = period; in p2p_ext_listen()
4704 p2p->ext_listen_interval = interval; in p2p_ext_listen()
4705 p2p->ext_listen_interval_sec = interval / 1000; in p2p_ext_listen()
4706 p2p->ext_listen_interval_usec = (interval % 1000) * 1000; in p2p_ext_listen()
4708 eloop_register_timeout(p2p->ext_listen_interval_sec, in p2p_ext_listen()
4709 p2p->ext_listen_interval_usec, in p2p_ext_listen()
4710 p2p_ext_listen_timeout, p2p, NULL); in p2p_ext_listen()
4716 void p2p_deauth_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code, in p2p_deauth_notif() argument
4732 p2p_dbg(p2p, "Deauthentication notification BSSID " MACSTR in p2p_deauth_notif()
4740 void p2p_disassoc_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code, in p2p_disassoc_notif() argument
4756 p2p_dbg(p2p, "Disassociation notification BSSID " MACSTR in p2p_disassoc_notif()
4764 void p2p_set_managed_oper(struct p2p_data *p2p, int enabled) in p2p_set_managed_oper() argument
4767 p2p_dbg(p2p, "Managed P2P Device operations enabled"); in p2p_set_managed_oper()
4768 p2p->dev_capab |= P2P_DEV_CAPAB_INFRA_MANAGED; in p2p_set_managed_oper()
4770 p2p_dbg(p2p, "Managed P2P Device operations disabled"); in p2p_set_managed_oper()
4771 p2p->dev_capab &= ~P2P_DEV_CAPAB_INFRA_MANAGED; in p2p_set_managed_oper()
4776 int p2p_config_get_random_social(struct p2p_config *p2p, u8 *op_class, in p2p_config_get_random_social() argument
4781 return p2p_channel_random_social(&p2p->channels, op_class, op_channel, in p2p_config_get_random_social()
4786 int p2p_set_listen_channel(struct p2p_data *p2p, u8 reg_class, u8 channel, in p2p_set_listen_channel() argument
4796 if (p2p->cfg->channel_forced && forced == 0) { in p2p_set_listen_channel()
4797 p2p_dbg(p2p, in p2p_set_listen_channel()
4802 p2p_dbg(p2p, "Set Listen channel: reg_class %u channel %u", in p2p_set_listen_channel()
4805 if (p2p->state == P2P_IDLE) { in p2p_set_listen_channel()
4806 p2p->cfg->reg_class = reg_class; in p2p_set_listen_channel()
4807 p2p->cfg->channel = channel; in p2p_set_listen_channel()
4808 p2p->cfg->channel_forced = forced; in p2p_set_listen_channel()
4810 p2p_dbg(p2p, "Defer setting listen channel"); in p2p_set_listen_channel()
4811 p2p->pending_reg_class = reg_class; in p2p_set_listen_channel()
4812 p2p->pending_channel = channel; in p2p_set_listen_channel()
4813 p2p->pending_channel_forced = forced; in p2p_set_listen_channel()
4820 u8 p2p_get_listen_channel(struct p2p_data *p2p) in p2p_get_listen_channel() argument
4822 return p2p->cfg->channel; in p2p_get_listen_channel()
4826 int p2p_set_ssid_postfix(struct p2p_data *p2p, const u8 *postfix, size_t len) in p2p_set_ssid_postfix() argument
4828 p2p_dbg(p2p, "New SSID postfix: %s", wpa_ssid_txt(postfix, len)); in p2p_set_ssid_postfix()
4830 p2p->cfg->ssid_postfix_len = 0; in p2p_set_ssid_postfix()
4833 if (len > sizeof(p2p->cfg->ssid_postfix)) in p2p_set_ssid_postfix()
4835 os_memcpy(p2p->cfg->ssid_postfix, postfix, len); in p2p_set_ssid_postfix()
4836 p2p->cfg->ssid_postfix_len = len; in p2p_set_ssid_postfix()
4841 int p2p_set_oper_channel(struct p2p_data *p2p, u8 op_reg_class, u8 op_channel, in p2p_set_oper_channel() argument
4847 p2p_dbg(p2p, "Set Operating channel: reg_class %u channel %u", in p2p_set_oper_channel()
4849 p2p->cfg->op_reg_class = op_reg_class; in p2p_set_oper_channel()
4850 p2p->cfg->op_channel = op_channel; in p2p_set_oper_channel()
4851 p2p->cfg->cfg_op_channel = cfg_op_channel; in p2p_set_oper_channel()
4856 int p2p_set_pref_chan(struct p2p_data *p2p, unsigned int num_pref_chan, in p2p_set_pref_chan() argument
4869 os_free(p2p->cfg->pref_chan); in p2p_set_pref_chan()
4870 p2p->cfg->pref_chan = n; in p2p_set_pref_chan()
4871 p2p->cfg->num_pref_chan = num_pref_chan; in p2p_set_pref_chan()
4877 int p2p_set_no_go_freq(struct p2p_data *p2p, in p2p_set_no_go_freq() argument
4883 os_free(p2p->no_go_freq.range); in p2p_set_no_go_freq()
4884 p2p->no_go_freq.range = NULL; in p2p_set_no_go_freq()
4885 p2p->no_go_freq.num = 0; in p2p_set_no_go_freq()
4893 os_free(p2p->no_go_freq.range); in p2p_set_no_go_freq()
4894 p2p->no_go_freq.range = tmp; in p2p_set_no_go_freq()
4895 p2p->no_go_freq.num = list->num; in p2p_set_no_go_freq()
4896 p2p_dbg(p2p, "Updated no GO chan list"); in p2p_set_no_go_freq()
4902 int p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr, in p2p_get_interface_addr() argument
4905 struct p2p_device *dev = p2p_get_device(p2p, dev_addr); in p2p_get_interface_addr()
4913 int p2p_get_dev_addr(struct p2p_data *p2p, const u8 *iface_addr, in p2p_get_dev_addr() argument
4916 struct p2p_device *dev = p2p_get_device_interface(p2p, iface_addr); in p2p_get_dev_addr()
4924 void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr) in p2p_set_peer_filter() argument
4926 os_memcpy(p2p->peer_filter, addr, ETH_ALEN); in p2p_set_peer_filter()
4927 if (is_zero_ether_addr(p2p->peer_filter)) in p2p_set_peer_filter()
4928 p2p_dbg(p2p, "Disable peer filter"); in p2p_set_peer_filter()
4930 p2p_dbg(p2p, "Enable peer filter for " MACSTR, in p2p_set_peer_filter()
4931 MAC2STR(p2p->peer_filter)); in p2p_set_peer_filter()
4935 void p2p_set_cross_connect(struct p2p_data *p2p, int enabled) in p2p_set_cross_connect() argument
4937 p2p_dbg(p2p, "Cross connection %s", enabled ? "enabled" : "disabled"); in p2p_set_cross_connect()
4938 if (p2p->cross_connect == enabled) in p2p_set_cross_connect()
4940 p2p->cross_connect = enabled; in p2p_set_cross_connect()
4945 int p2p_get_oper_freq(struct p2p_data *p2p, const u8 *iface_addr) in p2p_get_oper_freq() argument
4947 struct p2p_device *dev = p2p_get_device_interface(p2p, iface_addr); in p2p_get_oper_freq()
4956 void p2p_set_intra_bss_dist(struct p2p_data *p2p, int enabled) in p2p_set_intra_bss_dist() argument
4958 p2p_dbg(p2p, "Intra BSS distribution %s", in p2p_set_intra_bss_dist()
4960 p2p->cfg->p2p_intra_bss = enabled; in p2p_set_intra_bss_dist()
4964 void p2p_update_channel_list(struct p2p_data *p2p, in p2p_update_channel_list() argument
4968 p2p_dbg(p2p, "Update channel list"); in p2p_update_channel_list()
4969 os_memcpy(&p2p->cfg->channels, chan, sizeof(struct p2p_channels)); in p2p_update_channel_list()
4970 p2p_channels_dump(p2p, "channels", &p2p->cfg->channels); in p2p_update_channel_list()
4971 os_memcpy(&p2p->cfg->cli_channels, cli_chan, in p2p_update_channel_list()
4973 p2p_channels_dump(p2p, "cli_channels", &p2p->cfg->cli_channels); in p2p_update_channel_list()
4977 int p2p_send_action(struct p2p_data *p2p, unsigned int freq, const u8 *dst, in p2p_send_action() argument
4983 if (p2p->p2p_scan_running) { in p2p_send_action()
4984 p2p_dbg(p2p, "Delay Action frame TX until p2p_scan completes"); in p2p_send_action()
4985 if (p2p->after_scan_tx) { in p2p_send_action()
4986 p2p_dbg(p2p, "Dropped previous pending Action frame TX"); in p2p_send_action()
4987 os_free(p2p->after_scan_tx); in p2p_send_action()
4989 p2p->after_scan_tx = os_malloc(sizeof(*p2p->after_scan_tx) + in p2p_send_action()
4991 if (p2p->after_scan_tx == NULL) in p2p_send_action()
4993 p2p->after_scan_tx->freq = freq; in p2p_send_action()
4994 os_memcpy(p2p->after_scan_tx->dst, dst, ETH_ALEN); in p2p_send_action()
4995 os_memcpy(p2p->after_scan_tx->src, src, ETH_ALEN); in p2p_send_action()
4996 os_memcpy(p2p->after_scan_tx->bssid, bssid, ETH_ALEN); in p2p_send_action()
4997 p2p->after_scan_tx->len = len; in p2p_send_action()
4998 p2p->after_scan_tx->wait_time = wait_time; in p2p_send_action()
4999 os_memcpy(p2p->after_scan_tx + 1, buf, len); in p2p_send_action()
5003 res = p2p->cfg->send_action(p2p->cfg->cb_ctx, freq, dst, src, bssid, in p2p_send_action()
5005 if (res == 0 && scheduled && p2p->in_listen && freq > 0 && in p2p_send_action()
5006 (unsigned int) p2p->drv_in_listen != freq) { in p2p_send_action()
5007 p2p_dbg(p2p, in p2p_send_action()
5009 p2p->drv_in_listen, freq); in p2p_send_action()
5010 p2p_stop_listen_for_freq(p2p, freq); in p2p_send_action()
5016 void p2p_set_best_channels(struct p2p_data *p2p, int freq_24, int freq_5, in p2p_set_best_channels() argument
5019 p2p_dbg(p2p, "Best channel: 2.4 GHz: %d, 5 GHz: %d, overall: %d", in p2p_set_best_channels()
5021 p2p->best_freq_24 = freq_24; in p2p_set_best_channels()
5022 p2p->best_freq_5 = freq_5; in p2p_set_best_channels()
5023 p2p->best_freq_overall = freq_overall; in p2p_set_best_channels()
5027 void p2p_set_own_freq_preference(struct p2p_data *p2p, int freq) in p2p_set_own_freq_preference() argument
5029 p2p_dbg(p2p, "Own frequency preference: %d MHz", freq); in p2p_set_own_freq_preference()
5030 p2p->own_freq_preference = freq; in p2p_set_own_freq_preference()
5034 const u8 * p2p_get_go_neg_peer(struct p2p_data *p2p) in p2p_get_go_neg_peer() argument
5036 if (p2p == NULL || p2p->go_neg_peer == NULL) in p2p_get_go_neg_peer()
5038 return p2p->go_neg_peer->info.p2p_device_addr; in p2p_get_go_neg_peer()
5043 p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next) in p2p_get_peer_found() argument
5048 dev = p2p_get_device(p2p, addr); in p2p_get_peer_found()
5062 if (!dev || &dev->list == &p2p->devices) in p2p_get_peer_found()
5067 dev = dl_list_first(&p2p->devices, struct p2p_device, list); in p2p_get_peer_found()
5074 if (!dev || &dev->list == &p2p->devices) in p2p_get_peer_found()
5083 int p2p_in_progress(struct p2p_data *p2p) in p2p_in_progress() argument
5085 if (p2p == NULL) in p2p_in_progress()
5087 if (p2p->state == P2P_SEARCH) in p2p_in_progress()
5089 return p2p->state != P2P_IDLE && p2p->state != P2P_PROVISIONING; in p2p_in_progress()
5093 void p2p_set_config_timeout(struct p2p_data *p2p, u8 go_timeout, in p2p_set_config_timeout() argument
5096 if (p2p) { in p2p_set_config_timeout()
5097 p2p->go_timeout = go_timeout; in p2p_set_config_timeout()
5098 p2p->client_timeout = client_timeout; in p2p_set_config_timeout()
5105 static void p2p_update_wfd_ie_groups(struct p2p_data *p2p) in p2p_update_wfd_ie_groups() argument
5110 for (g = 0; g < p2p->num_groups; g++) { in p2p_update_wfd_ie_groups()
5111 group = p2p->groups[g]; in p2p_update_wfd_ie_groups()
5117 int p2p_set_wfd_ie_beacon(struct p2p_data *p2p, struct wpabuf *ie) in p2p_set_wfd_ie_beacon() argument
5119 wpabuf_free(p2p->wfd_ie_beacon); in p2p_set_wfd_ie_beacon()
5120 p2p->wfd_ie_beacon = ie; in p2p_set_wfd_ie_beacon()
5121 p2p_update_wfd_ie_groups(p2p); in p2p_set_wfd_ie_beacon()
5126 int p2p_set_wfd_ie_probe_req(struct p2p_data *p2p, struct wpabuf *ie) in p2p_set_wfd_ie_probe_req() argument
5128 wpabuf_free(p2p->wfd_ie_probe_req); in p2p_set_wfd_ie_probe_req()
5129 p2p->wfd_ie_probe_req = ie; in p2p_set_wfd_ie_probe_req()
5134 int p2p_set_wfd_ie_probe_resp(struct p2p_data *p2p, struct wpabuf *ie) in p2p_set_wfd_ie_probe_resp() argument
5136 wpabuf_free(p2p->wfd_ie_probe_resp); in p2p_set_wfd_ie_probe_resp()
5137 p2p->wfd_ie_probe_resp = ie; in p2p_set_wfd_ie_probe_resp()
5138 p2p_update_wfd_ie_groups(p2p); in p2p_set_wfd_ie_probe_resp()
5143 int p2p_set_wfd_ie_assoc_req(struct p2p_data *p2p, struct wpabuf *ie) in p2p_set_wfd_ie_assoc_req() argument
5145 wpabuf_free(p2p->wfd_ie_assoc_req); in p2p_set_wfd_ie_assoc_req()
5146 p2p->wfd_ie_assoc_req = ie; in p2p_set_wfd_ie_assoc_req()
5151 int p2p_set_wfd_ie_invitation(struct p2p_data *p2p, struct wpabuf *ie) in p2p_set_wfd_ie_invitation() argument
5153 wpabuf_free(p2p->wfd_ie_invitation); in p2p_set_wfd_ie_invitation()
5154 p2p->wfd_ie_invitation = ie; in p2p_set_wfd_ie_invitation()
5159 int p2p_set_wfd_ie_prov_disc_req(struct p2p_data *p2p, struct wpabuf *ie) in p2p_set_wfd_ie_prov_disc_req() argument
5161 wpabuf_free(p2p->wfd_ie_prov_disc_req); in p2p_set_wfd_ie_prov_disc_req()
5162 p2p->wfd_ie_prov_disc_req = ie; in p2p_set_wfd_ie_prov_disc_req()
5167 int p2p_set_wfd_ie_prov_disc_resp(struct p2p_data *p2p, struct wpabuf *ie) in p2p_set_wfd_ie_prov_disc_resp() argument
5169 wpabuf_free(p2p->wfd_ie_prov_disc_resp); in p2p_set_wfd_ie_prov_disc_resp()
5170 p2p->wfd_ie_prov_disc_resp = ie; in p2p_set_wfd_ie_prov_disc_resp()
5175 int p2p_set_wfd_ie_go_neg(struct p2p_data *p2p, struct wpabuf *ie) in p2p_set_wfd_ie_go_neg() argument
5177 wpabuf_free(p2p->wfd_ie_go_neg); in p2p_set_wfd_ie_go_neg()
5178 p2p->wfd_ie_go_neg = ie; in p2p_set_wfd_ie_go_neg()
5183 int p2p_set_wfd_dev_info(struct p2p_data *p2p, const struct wpabuf *elem) in p2p_set_wfd_dev_info() argument
5185 wpabuf_free(p2p->wfd_dev_info); in p2p_set_wfd_dev_info()
5187 p2p->wfd_dev_info = wpabuf_dup(elem); in p2p_set_wfd_dev_info()
5188 if (p2p->wfd_dev_info == NULL) in p2p_set_wfd_dev_info()
5191 p2p->wfd_dev_info = NULL; in p2p_set_wfd_dev_info()
5197 int p2p_set_wfd_r2_dev_info(struct p2p_data *p2p, const struct wpabuf *elem) in p2p_set_wfd_r2_dev_info() argument
5199 wpabuf_free(p2p->wfd_r2_dev_info); in p2p_set_wfd_r2_dev_info()
5201 p2p->wfd_r2_dev_info = wpabuf_dup(elem); in p2p_set_wfd_r2_dev_info()
5202 if (p2p->wfd_r2_dev_info == NULL) in p2p_set_wfd_r2_dev_info()
5205 p2p->wfd_r2_dev_info = NULL; in p2p_set_wfd_r2_dev_info()
5211 int p2p_set_wfd_assoc_bssid(struct p2p_data *p2p, const struct wpabuf *elem) in p2p_set_wfd_assoc_bssid() argument
5213 wpabuf_free(p2p->wfd_assoc_bssid); in p2p_set_wfd_assoc_bssid()
5215 p2p->wfd_assoc_bssid = wpabuf_dup(elem); in p2p_set_wfd_assoc_bssid()
5216 if (p2p->wfd_assoc_bssid == NULL) in p2p_set_wfd_assoc_bssid()
5219 p2p->wfd_assoc_bssid = NULL; in p2p_set_wfd_assoc_bssid()
5225 int p2p_set_wfd_coupled_sink_info(struct p2p_data *p2p, in p2p_set_wfd_coupled_sink_info() argument
5228 wpabuf_free(p2p->wfd_coupled_sink_info); in p2p_set_wfd_coupled_sink_info()
5230 p2p->wfd_coupled_sink_info = wpabuf_dup(elem); in p2p_set_wfd_coupled_sink_info()
5231 if (p2p->wfd_coupled_sink_info == NULL) in p2p_set_wfd_coupled_sink_info()
5234 p2p->wfd_coupled_sink_info = NULL; in p2p_set_wfd_coupled_sink_info()
5242 int p2p_set_disc_int(struct p2p_data *p2p, int min_disc_int, int max_disc_int, in p2p_set_disc_int() argument
5248 p2p->min_disc_int = min_disc_int; in p2p_set_disc_int()
5249 p2p->max_disc_int = max_disc_int; in p2p_set_disc_int()
5250 p2p->max_disc_tu = max_disc_tu; in p2p_set_disc_int()
5251 p2p_dbg(p2p, "Set discoverable interval: min=%d max=%d max_tu=%d", in p2p_set_disc_int()
5258 void p2p_dbg(struct p2p_data *p2p, const char *fmt, ...) in p2p_dbg() argument
5263 if (!p2p->cfg->debug_print) in p2p_dbg()
5270 p2p->cfg->debug_print(p2p->cfg->cb_ctx, MSG_DEBUG, buf); in p2p_dbg()
5274 void p2p_info(struct p2p_data *p2p, const char *fmt, ...) in p2p_info() argument
5279 if (!p2p->cfg->debug_print) in p2p_info()
5286 p2p->cfg->debug_print(p2p->cfg->cb_ctx, MSG_INFO, buf); in p2p_info()
5290 void p2p_err(struct p2p_data *p2p, const char *fmt, ...) in p2p_err() argument
5295 if (!p2p->cfg->debug_print) in p2p_err()
5302 p2p->cfg->debug_print(p2p->cfg->cb_ctx, MSG_ERROR, buf); in p2p_err()
5306 void p2p_loop_on_known_peers(struct p2p_data *p2p, in p2p_loop_on_known_peers() argument
5313 dl_list_for_each_safe(dev, n, &p2p->devices, struct p2p_device, list) { in p2p_loop_on_known_peers()
5321 static struct wpabuf * p2p_build_nfc_handover(struct p2p_data *p2p, in p2p_build_nfc_handover() argument
5334 op_class = p2p->cfg->reg_class; in p2p_build_nfc_handover()
5335 channel = p2p->cfg->channel; in p2p_build_nfc_handover()
5337 p2p_buf_add_capability(buf, p2p->dev_capab & in p2p_build_nfc_handover()
5339 p2p_buf_add_device_info(buf, p2p, NULL); in p2p_build_nfc_handover()
5341 if (p2p->num_groups > 0) { in p2p_build_nfc_handover()
5342 int freq = p2p_group_get_freq(p2p->groups[0]); in p2p_build_nfc_handover()
5345 p2p_dbg(p2p, in p2p_build_nfc_handover()
5354 p2p_dbg(p2p, in p2p_build_nfc_handover()
5362 p2p_buf_add_oob_go_neg_channel(buf, p2p->cfg->country, op_class, in p2p_build_nfc_handover()
5365 if (p2p->num_groups > 0) { in p2p_build_nfc_handover()
5367 p2p_buf_add_group_info(p2p->groups[0], buf, 5); in p2p_build_nfc_handover()
5368 p2p_group_buf_add_id(p2p->groups[0], buf); in p2p_build_nfc_handover()
5383 struct wpabuf * p2p_build_nfc_handover_req(struct p2p_data *p2p, in p2p_build_nfc_handover_req() argument
5388 return p2p_build_nfc_handover(p2p, client_freq, go_dev_addr, ssid, in p2p_build_nfc_handover_req()
5393 struct wpabuf * p2p_build_nfc_handover_sel(struct p2p_data *p2p, in p2p_build_nfc_handover_sel() argument
5398 return p2p_build_nfc_handover(p2p, client_freq, go_dev_addr, ssid, in p2p_build_nfc_handover_sel()
5403 int p2p_process_nfc_connection_handover(struct p2p_data *p2p, in p2p_process_nfc_connection_handover() argument
5416 p2p_dbg(p2p, "Failed to parse WSC/P2P attributes from NFC"); in p2p_process_nfc_connection_handover()
5426 p2p_dbg(p2p, "Ignore scan data without P2P Device Info or P2P Device Id"); in p2p_process_nfc_connection_handover()
5437 dev = p2p_create_device(p2p, p2p_dev_addr); in p2p_process_nfc_connection_handover()
5447 p2p_copy_wps_info(p2p, dev, 0, &msg); in p2p_process_nfc_connection_handover()
5450 p2p_dbg(p2p, "OOB GO Negotiation Channel attribute not included"); in p2p_process_nfc_connection_handover()
5462 p2p_dbg(p2p, "Unknown peer OOB GO Neg channel"); in p2p_process_nfc_connection_handover()
5469 p2p_dbg(p2p, "Peer OOB GO operating channel: %u MHz", freq); in p2p_process_nfc_connection_handover()
5472 p2p_dbg(p2p, "Peer (client) OOB GO operating channel: %u MHz", in p2p_process_nfc_connection_handover()
5476 p2p_dbg(p2p, "Peer OOB GO Neg channel: %u MHz", freq); in p2p_process_nfc_connection_handover()
5480 freq = p2p_channel_to_freq(p2p->cfg->reg_class, in p2p_process_nfc_connection_handover()
5481 p2p->cfg->channel); in p2p_process_nfc_connection_handover()
5483 p2p_dbg(p2p, "Own listen channel not known"); in p2p_process_nfc_connection_handover()
5487 p2p_dbg(p2p, "Use own Listen channel as OOB GO Neg channel: %u MHz", freq); in p2p_process_nfc_connection_handover()
5499 p2p_dbg(p2p, "Do not report rejected device"); in p2p_process_nfc_connection_handover()
5505 p2p->cfg->dev_found(p2p->cfg->cb_ctx, p2p_dev_addr, &dev->info, in p2p_process_nfc_connection_handover()
5511 if (role == P2P_GO_IN_A_GROUP && p2p->num_groups > 0) in p2p_process_nfc_connection_handover()
5518 } else if (p2p->num_groups > 0) in p2p_process_nfc_connection_handover()
5529 void p2p_set_authorized_oob_dev_pw_id(struct p2p_data *p2p, u16 dev_pw_id, in p2p_set_authorized_oob_dev_pw_id() argument
5534 p2p->authorized_oob_dev_pw_id = dev_pw_id; in p2p_set_authorized_oob_dev_pw_id()
5536 p2p_dbg(p2p, "NFC OOB Password unauthorized for static handover"); in p2p_set_authorized_oob_dev_pw_id()
5540 p2p_dbg(p2p, "NFC OOB Password (id=%u) authorized for static handover", in p2p_set_authorized_oob_dev_pw_id()
5543 p2p->go_intent = go_intent; in p2p_set_authorized_oob_dev_pw_id()
5544 os_memcpy(p2p->intended_addr, own_interface_addr, ETH_ALEN); in p2p_set_authorized_oob_dev_pw_id()
5550 int p2p_set_passphrase_len(struct p2p_data *p2p, unsigned int len) in p2p_set_passphrase_len() argument
5554 p2p->cfg->passphrase_len = len; in p2p_set_passphrase_len()
5559 void p2p_set_vendor_elems(struct p2p_data *p2p, struct wpabuf **vendor_elem) in p2p_set_vendor_elems() argument
5561 p2p->vendor_elem = vendor_elem; in p2p_set_vendor_elems()
5567 struct p2p_data *p2p = eloop_ctx; in p2p_go_neg_wait_timeout() local
5569 p2p_dbg(p2p, in p2p_go_neg_wait_timeout()
5571 p2p_go_neg_failed(p2p, -1); in p2p_go_neg_wait_timeout()
5575 void p2p_set_own_pref_freq_list(struct p2p_data *p2p, in p2p_set_own_pref_freq_list() argument
5583 p2p->num_pref_freq = size; in p2p_set_own_pref_freq_list()
5585 p2p->pref_freq_list[i] = pref_freq_list[i]; in p2p_set_own_pref_freq_list()
5586 p2p_dbg(p2p, "Own preferred frequency list[%u]=%u MHz", in p2p_set_own_pref_freq_list()
5587 i, p2p->pref_freq_list[i]); in p2p_set_own_pref_freq_list()
5592 void p2p_set_override_pref_op_chan(struct p2p_data *p2p, u8 op_class, in p2p_set_override_pref_op_chan() argument
5595 p2p->override_pref_op_class = op_class; in p2p_set_override_pref_op_chan()
5596 p2p->override_pref_channel = chan; in p2p_set_override_pref_op_chan()
5600 struct wpabuf * p2p_build_probe_resp_template(struct p2p_data *p2p, in p2p_build_probe_resp_template() argument
5607 ies = p2p_build_probe_resp_ies(p2p, NULL, 0); in p2p_build_probe_resp_template()
5620 ret = p2p_build_probe_resp_buf(p2p, buf, ies, addr, freq); in p2p_build_probe_resp_template()