blob: d59a8ac4372dd8efffe34b4efbab982f264ef638 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
2 * P2P - Internal definitions for P2P module
3 * Copyright (c) 2009-2010, Atheros Communications
4 *
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08005 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07007 */
8
9#ifndef P2P_I_H
10#define P2P_I_H
11
12#include "utils/list.h"
13#include "p2p.h"
14
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070015enum p2p_go_state {
16 UNKNOWN_GO,
17 LOCAL_GO,
18 REMOTE_GO
19};
20
21/**
22 * struct p2p_device - P2P Device data (internal to P2P module)
23 */
24struct p2p_device {
25 struct dl_list list;
26 struct os_time last_seen;
27 int listen_freq;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070028 enum p2p_wps_method wps_method;
29
30 struct p2p_peer_info info;
31
32 /*
33 * If the peer was discovered based on an interface address (e.g., GO
34 * from Beacon/Probe Response), the interface address is stored here.
35 * p2p_device_addr must still be set in such a case to the unique
36 * identifier for the P2P Device.
37 */
38 u8 interface_addr[ETH_ALEN];
39
40 /*
41 * P2P Device Address of the GO in whose group this P2P Device is a
42 * client.
43 */
44 u8 member_in_go_dev[ETH_ALEN];
45
46 /*
47 * P2P Interface Address of the GO in whose group this P2P Device is a
48 * client.
49 */
50 u8 member_in_go_iface[ETH_ALEN];
51
52 int go_neg_req_sent;
53 enum p2p_go_state go_state;
54 u8 dialog_token;
Dmitry Shmidt9cdf1b92013-02-27 12:58:50 -080055 u8 tie_breaker;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070056 u8 intended_addr[ETH_ALEN];
57
58 char country[3];
59 struct p2p_channels channels;
60 int oper_freq;
61 u8 oper_ssid[32];
62 size_t oper_ssid_len;
63
64 /**
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080065 * req_config_methods - Pending provision discovery methods
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070066 */
67 u16 req_config_methods;
68
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080069 /**
70 * wps_prov_info - Stored provisioning WPS config method
71 *
72 * This is used to store pending WPS config method between Provisioning
73 * Discovery and connection to a running group.
74 */
75 u16 wps_prov_info;
76
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070077#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
78#define P2P_DEV_REPORTED BIT(1)
79#define P2P_DEV_NOT_YET_READY BIT(2)
80#define P2P_DEV_SD_INFO BIT(3)
81#define P2P_DEV_SD_SCHEDULE BIT(4)
82#define P2P_DEV_PD_PEER_DISPLAY BIT(5)
83#define P2P_DEV_PD_PEER_KEYPAD BIT(6)
84#define P2P_DEV_USER_REJECTED BIT(7)
85#define P2P_DEV_PEER_WAITING_RESPONSE BIT(8)
86#define P2P_DEV_PREFER_PERSISTENT_GROUP BIT(9)
87#define P2P_DEV_WAIT_GO_NEG_RESPONSE BIT(10)
88#define P2P_DEV_WAIT_GO_NEG_CONFIRM BIT(11)
89#define P2P_DEV_GROUP_CLIENT_ONLY BIT(12)
90#define P2P_DEV_FORCE_FREQ BIT(13)
91#define P2P_DEV_PD_FOR_JOIN BIT(14)
92#define P2P_DEV_REPORTED_ONCE BIT(15)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080093#define P2P_DEV_PREFER_PERSISTENT_RECONN BIT(16)
Dmitry Shmidt04949592012-07-19 12:16:46 -070094#define P2P_DEV_PD_BEFORE_GO_NEG BIT(17)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070095 unsigned int flags;
96
97 int status; /* enum p2p_status_code */
98 unsigned int wait_count;
99 unsigned int connect_reqs;
100 unsigned int invitation_reqs;
101
102 u16 ext_listen_period;
103 u16 ext_listen_interval;
104
105 u8 go_timeout;
106 u8 client_timeout;
107};
108
109struct p2p_sd_query {
110 struct p2p_sd_query *next;
111 u8 peer[ETH_ALEN];
112 int for_all_peers;
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700113 int wsd; /* Wi-Fi Display Service Discovery Request */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700114 struct wpabuf *tlvs;
115};
116
117struct p2p_pending_action_tx {
118 unsigned int freq;
119 u8 dst[ETH_ALEN];
120 u8 src[ETH_ALEN];
121 u8 bssid[ETH_ALEN];
122 size_t len;
123 unsigned int wait_time;
124 /* Followed by len octets of the frame */
125};
126
127/**
128 * struct p2p_data - P2P module data (internal to P2P module)
129 */
130struct p2p_data {
131 /**
132 * cfg - P2P module configuration
133 *
134 * This is included in the same memory allocation with the
135 * struct p2p_data and as such, must not be freed separately.
136 */
137 struct p2p_config *cfg;
138
139 /**
140 * state - The current P2P state
141 */
142 enum p2p_state {
143 /**
144 * P2P_IDLE - Idle
145 */
146 P2P_IDLE,
147
148 /**
149 * P2P_SEARCH - Search (Device Discovery)
150 */
151 P2P_SEARCH,
152
153 /**
154 * P2P_CONNECT - Trying to start GO Negotiation
155 */
156 P2P_CONNECT,
157
158 /**
159 * P2P_CONNECT_LISTEN - Listen during GO Negotiation start
160 */
161 P2P_CONNECT_LISTEN,
162
163 /**
164 * P2P_GO_NEG - In GO Negotiation
165 */
166 P2P_GO_NEG,
167
168 /**
169 * P2P_LISTEN_ONLY - Listen only
170 */
171 P2P_LISTEN_ONLY,
172
173 /**
174 * P2P_WAIT_PEER_CONNECT - Waiting peer in List for GO Neg
175 */
176 P2P_WAIT_PEER_CONNECT,
177
178 /**
179 * P2P_WAIT_PEER_IDLE - Waiting peer idle for GO Neg
180 */
181 P2P_WAIT_PEER_IDLE,
182
183 /**
184 * P2P_SD_DURING_FIND - Service Discovery during find
185 */
186 P2P_SD_DURING_FIND,
187
188 /**
189 * P2P_PROVISIONING - Provisioning (during group formation)
190 */
191 P2P_PROVISIONING,
192
193 /**
194 * P2P_PD_DURING_FIND - Provision Discovery during find
195 */
196 P2P_PD_DURING_FIND,
197
198 /**
199 * P2P_INVITE - Trying to start Invite
200 */
201 P2P_INVITE,
202
203 /**
204 * P2P_INVITE_LISTEN - Listen during Invite
205 */
206 P2P_INVITE_LISTEN,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800207
208 /**
209 * P2P_SEARCH_WHEN_READY - Waiting to start Search
210 */
211 P2P_SEARCH_WHEN_READY,
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700212
213 /**
214 * P2P_CONTINUE_SEARCH_WHEN_READY - Waiting to continue Search
215 */
216 P2P_CONTINUE_SEARCH_WHEN_READY,
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700217 } state;
218
219 /**
220 * min_disc_int - minDiscoverableInterval
221 */
222 int min_disc_int;
223
224 /**
225 * max_disc_int - maxDiscoverableInterval
226 */
227 int max_disc_int;
228
229 /**
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800230 * max_disc_tu - Maximum number of TUs for discoverable interval
231 */
232 int max_disc_tu;
233
234 /**
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700235 * devices - List of known P2P Device peers
236 */
237 struct dl_list devices;
238
Irfan Sherifff44b9c42012-06-13 11:09:23 -0700239#ifdef ANDROID_P2P
240 /**
241 * sd_dev_list - device pointer to be serviced next
242 * for service discovery
243 */
244 struct dl_list *sd_dev_list;
245#endif
246
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700247 /**
248 * go_neg_peer - Pointer to GO Negotiation peer
249 */
250 struct p2p_device *go_neg_peer;
251
252 /**
253 * invite_peer - Pointer to Invite peer
254 */
255 struct p2p_device *invite_peer;
256
257 const u8 *invite_go_dev_addr;
258 u8 invite_go_dev_addr_buf[ETH_ALEN];
259
260 /**
261 * sd_peer - Pointer to Service Discovery peer
262 */
263 struct p2p_device *sd_peer;
264
265 /**
266 * sd_query - Pointer to Service Discovery query
267 */
268 struct p2p_sd_query *sd_query;
269
270 /* GO Negotiation data */
271
272 /**
273 * intended_addr - Local Intended P2P Interface Address
274 *
275 * This address is used during group owner negotiation as the Intended
276 * P2P Interface Address and the group interface will be created with
277 * address as the local address in case of successfully completed
278 * negotiation.
279 */
280 u8 intended_addr[ETH_ALEN];
281
282 /**
283 * go_intent - Local GO Intent to be used during GO Negotiation
284 */
285 u8 go_intent;
286
287 /**
288 * next_tie_breaker - Next tie-breaker value to use in GO Negotiation
289 */
290 u8 next_tie_breaker;
291
292 /**
293 * ssid - Selected SSID for GO Negotiation (if local end will be GO)
294 */
295 u8 ssid[32];
296
297 /**
298 * ssid_len - ssid length in octets
299 */
300 size_t ssid_len;
301
302 /**
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800303 * ssid_set - Whether SSID is already set for GO Negotiation
304 */
305 int ssid_set;
306
307 /**
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700308 * Regulatory class for own operational channel
309 */
310 u8 op_reg_class;
311
312 /**
313 * op_channel - Own operational channel
314 */
315 u8 op_channel;
316
317 /**
318 * channels - Own supported regulatory classes and channels
319 *
320 * List of supposerted channels per regulatory class. The regulatory
321 * classes are defined in IEEE Std 802.11-2007 Annex J and the
322 * numbering of the clases depends on the configured country code.
323 */
324 struct p2p_channels channels;
325
326 enum p2p_pending_action_state {
327 P2P_NO_PENDING_ACTION,
328 P2P_PENDING_GO_NEG_REQUEST,
329 P2P_PENDING_GO_NEG_RESPONSE,
330 P2P_PENDING_GO_NEG_RESPONSE_FAILURE,
331 P2P_PENDING_GO_NEG_CONFIRM,
332 P2P_PENDING_SD,
333 P2P_PENDING_PD,
334 P2P_PENDING_INVITATION_REQUEST,
335 P2P_PENDING_INVITATION_RESPONSE,
336 P2P_PENDING_DEV_DISC_REQUEST,
337 P2P_PENDING_DEV_DISC_RESPONSE,
338 P2P_PENDING_GO_DISC_REQ
339 } pending_action_state;
340
341 unsigned int pending_listen_freq;
342 unsigned int pending_listen_sec;
343 unsigned int pending_listen_usec;
344
345 u8 dev_capab;
346
347 int in_listen;
348 int drv_in_listen;
349
350 /**
351 * sd_queries - Pending service discovery queries
352 */
353 struct p2p_sd_query *sd_queries;
354
355 /**
356 * srv_update_indic - Service Update Indicator for local services
357 */
358 u16 srv_update_indic;
Dmitry Shmidtb5e8f062012-08-08 10:56:33 -0700359#ifdef ANDROID_P2P
360 /**
361 * srv_count - Registered services count
362 */
363 u16 srv_count;
364#endif
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700365 struct wpabuf *sd_resp; /* Fragmented SD response */
366 u8 sd_resp_addr[ETH_ALEN];
367 u8 sd_resp_dialog_token;
368 size_t sd_resp_pos; /* Offset in sd_resp */
369 u8 sd_frag_id;
370
371 struct wpabuf *sd_rx_resp; /* Reassembled SD response */
372 u16 sd_rx_update_indic;
373
374 /* P2P Invitation data */
375 enum p2p_invite_role inv_role;
376 u8 inv_bssid[ETH_ALEN];
377 int inv_bssid_set;
378 u8 inv_ssid[32];
379 size_t inv_ssid_len;
380 u8 inv_sa[ETH_ALEN];
381 u8 inv_group_bssid[ETH_ALEN];
382 u8 *inv_group_bssid_ptr;
383 u8 inv_go_dev_addr[ETH_ALEN];
384 u8 inv_status;
385 int inv_op_freq;
386 int inv_persistent;
387
388 enum p2p_discovery_type find_type;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800389 unsigned int last_p2p_find_timeout;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700390 u8 last_prog_scan_class;
391 u8 last_prog_scan_chan;
392 int p2p_scan_running;
393 enum p2p_after_scan {
394 P2P_AFTER_SCAN_NOTHING,
395 P2P_AFTER_SCAN_LISTEN,
396 P2P_AFTER_SCAN_CONNECT
397 } start_after_scan;
398 u8 after_scan_peer[ETH_ALEN];
399 struct p2p_pending_action_tx *after_scan_tx;
400
401 /* Requested device types for find/search */
402 unsigned int num_req_dev_types;
403 u8 *req_dev_types;
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -0800404 u8 *find_dev_id;
405 u8 find_dev_id_buf[ETH_ALEN];
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700406
Dmitry Shmidtf8623282013-02-20 14:34:59 -0800407 struct os_time find_start; /* time of last p2p_find start */
408
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700409 struct p2p_group **groups;
410 size_t num_groups;
411
412 struct p2p_device *pending_client_disc_go;
413 u8 pending_client_disc_addr[ETH_ALEN];
414 u8 pending_dev_disc_dialog_token;
415 u8 pending_dev_disc_addr[ETH_ALEN];
416 int pending_dev_disc_freq;
417 unsigned int pending_client_disc_freq;
418
419 int ext_listen_only;
420 unsigned int ext_listen_period;
421 unsigned int ext_listen_interval;
422 unsigned int ext_listen_interval_sec;
423 unsigned int ext_listen_interval_usec;
424
425 u8 peer_filter[ETH_ALEN];
426
427 int cross_connect;
428
429 int best_freq_24;
430 int best_freq_5;
431 int best_freq_overall;
432
433 /**
434 * wps_vendor_ext - WPS Vendor Extensions to add
435 */
436 struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
Jouni Malinen75ecf522011-06-27 15:19:46 -0700437
438 /*
439 * user_initiated_pd - Whether a PD request is user initiated or not.
440 */
441 u8 user_initiated_pd;
442
443 /*
444 * Keep track of which peer a given PD request was sent to.
445 * Used to raise a timeout alert in case there is no response.
446 */
447 u8 pending_pd_devaddr[ETH_ALEN];
448
449 /*
450 * Retry counter for provision discovery requests when issued
451 * in IDLE state.
452 */
453 int pd_retries;
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700454
455 u8 go_timeout;
456 u8 client_timeout;
457
458 /* Extra delay in milliseconds between search iterations */
459 unsigned int search_delay;
460 int in_search_delay;
461
462#ifdef CONFIG_WIFI_DISPLAY
463 struct wpabuf *wfd_ie_beacon;
464 struct wpabuf *wfd_ie_probe_req;
465 struct wpabuf *wfd_ie_probe_resp;
466 struct wpabuf *wfd_ie_assoc_req;
467 struct wpabuf *wfd_ie_invitation;
468 struct wpabuf *wfd_ie_prov_disc_req;
469 struct wpabuf *wfd_ie_prov_disc_resp;
470 struct wpabuf *wfd_ie_go_neg;
471 struct wpabuf *wfd_dev_info;
472 struct wpabuf *wfd_assoc_bssid;
473 struct wpabuf *wfd_coupled_sink_info;
474#endif /* CONFIG_WIFI_DISPLAY */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700475};
476
477/**
478 * struct p2p_message - Parsed P2P message (or P2P IE)
479 */
480struct p2p_message {
481 struct wpabuf *p2p_attributes;
482 struct wpabuf *wps_attributes;
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700483 struct wpabuf *wfd_subelems;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700484
485 u8 dialog_token;
486
487 const u8 *capability;
488 const u8 *go_intent;
489 const u8 *status;
490 const u8 *listen_channel;
491 const u8 *operating_channel;
492 const u8 *channel_list;
493 u8 channel_list_len;
494 const u8 *config_timeout;
495 const u8 *intended_addr;
496 const u8 *group_bssid;
497 const u8 *invitation_flags;
498
499 const u8 *group_info;
500 size_t group_info_len;
501
502 const u8 *group_id;
503 size_t group_id_len;
504
505 const u8 *device_id;
506
507 const u8 *manageability;
508
509 const u8 *noa;
510 size_t noa_len;
511
512 const u8 *ext_listen_timing;
513
514 const u8 *minor_reason_code;
515
516 /* P2P Device Info */
517 const u8 *p2p_device_info;
518 size_t p2p_device_info_len;
519 const u8 *p2p_device_addr;
520 const u8 *pri_dev_type;
521 u8 num_sec_dev_types;
522 char device_name[33];
523 u16 config_methods;
524
525 /* WPS IE */
526 u16 dev_password_id;
527 u16 wps_config_methods;
528 const u8 *wps_pri_dev_type;
529 const u8 *wps_sec_dev_type_list;
530 size_t wps_sec_dev_type_list_len;
531 const u8 *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
532 size_t wps_vendor_ext_len[P2P_MAX_WPS_VENDOR_EXT];
533 const u8 *manufacturer;
534 size_t manufacturer_len;
535 const u8 *model_name;
536 size_t model_name_len;
537 const u8 *model_number;
538 size_t model_number_len;
539 const u8 *serial_number;
540 size_t serial_number_len;
541
542 /* DS Parameter Set IE */
543 const u8 *ds_params;
544
545 /* SSID IE */
546 const u8 *ssid;
547};
548
549
550#define P2P_MAX_GROUP_ENTRIES 50
551
552struct p2p_group_info {
553 unsigned int num_clients;
554 struct p2p_client_info {
555 const u8 *p2p_device_addr;
556 const u8 *p2p_interface_addr;
557 u8 dev_capab;
558 u16 config_methods;
559 const u8 *pri_dev_type;
560 u8 num_sec_dev_types;
561 const u8 *sec_dev_types;
562 const char *dev_name;
563 size_t dev_name_len;
564 } client[P2P_MAX_GROUP_ENTRIES];
565};
566
567
568/* p2p_utils.c */
569int p2p_random(char *buf, size_t len);
570int p2p_channel_to_freq(const char *country, int reg_class, int channel);
571int p2p_freq_to_channel(const char *country, unsigned int freq, u8 *reg_class,
572 u8 *channel);
573void p2p_channels_intersect(const struct p2p_channels *a,
574 const struct p2p_channels *b,
575 struct p2p_channels *res);
576int p2p_channels_includes(const struct p2p_channels *channels, u8 reg_class,
577 u8 channel);
578
579/* p2p_parse.c */
580int p2p_parse_p2p_ie(const struct wpabuf *buf, struct p2p_message *msg);
581int p2p_parse_ies(const u8 *data, size_t len, struct p2p_message *msg);
582int p2p_parse(const u8 *data, size_t len, struct p2p_message *msg);
583void p2p_parse_free(struct p2p_message *msg);
584int p2p_attr_text(struct wpabuf *data, char *buf, char *end);
585int p2p_group_info_parse(const u8 *gi, size_t gi_len,
586 struct p2p_group_info *info);
587
588/* p2p_build.c */
589
590struct p2p_noa_desc {
591 u8 count_type;
592 u32 duration;
593 u32 interval;
594 u32 start_time;
595};
596
597/* p2p_group.c */
598const u8 * p2p_group_get_interface_addr(struct p2p_group *group);
599u8 p2p_group_presence_req(struct p2p_group *group,
600 const u8 *client_interface_addr,
601 const u8 *noa, size_t noa_len);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700602int p2p_group_is_group_id_match(struct p2p_group *group, const u8 *group_id,
603 size_t group_id_len);
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700604void p2p_group_update_ies(struct p2p_group *group);
605struct wpabuf * p2p_group_get_wfd_ie(struct p2p_group *g);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700606
607
608void p2p_buf_add_action_hdr(struct wpabuf *buf, u8 subtype, u8 dialog_token);
609void p2p_buf_add_public_action_hdr(struct wpabuf *buf, u8 subtype,
610 u8 dialog_token);
611u8 * p2p_buf_add_ie_hdr(struct wpabuf *buf);
612void p2p_buf_add_status(struct wpabuf *buf, u8 status);
613void p2p_buf_add_device_info(struct wpabuf *buf, struct p2p_data *p2p,
614 struct p2p_device *peer);
615void p2p_buf_add_device_id(struct wpabuf *buf, const u8 *dev_addr);
616void p2p_buf_update_ie_hdr(struct wpabuf *buf, u8 *len);
617void p2p_buf_add_capability(struct wpabuf *buf, u8 dev_capab, u8 group_capab);
618void p2p_buf_add_go_intent(struct wpabuf *buf, u8 go_intent);
619void p2p_buf_add_listen_channel(struct wpabuf *buf, const char *country,
620 u8 reg_class, u8 channel);
621void p2p_buf_add_operating_channel(struct wpabuf *buf, const char *country,
622 u8 reg_class, u8 channel);
623void p2p_buf_add_channel_list(struct wpabuf *buf, const char *country,
624 struct p2p_channels *chan);
625void p2p_buf_add_config_timeout(struct wpabuf *buf, u8 go_timeout,
626 u8 client_timeout);
627void p2p_buf_add_intended_addr(struct wpabuf *buf, const u8 *interface_addr);
628void p2p_buf_add_group_bssid(struct wpabuf *buf, const u8 *bssid);
629void p2p_buf_add_group_id(struct wpabuf *buf, const u8 *dev_addr,
630 const u8 *ssid, size_t ssid_len);
631void p2p_buf_add_invitation_flags(struct wpabuf *buf, u8 flags);
632void p2p_buf_add_noa(struct wpabuf *buf, u8 noa_index, u8 opp_ps, u8 ctwindow,
633 struct p2p_noa_desc *desc1, struct p2p_noa_desc *desc2);
634void p2p_buf_add_ext_listen_timing(struct wpabuf *buf, u16 period,
635 u16 interval);
636void p2p_buf_add_p2p_interface(struct wpabuf *buf, struct p2p_data *p2p);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700637void p2p_build_wps_ie(struct p2p_data *p2p, struct wpabuf *buf, int pw_id,
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700638 int all_attr);
639
640/* p2p_sd.c */
641struct p2p_sd_query * p2p_pending_sd_req(struct p2p_data *p2p,
642 struct p2p_device *dev);
643void p2p_free_sd_queries(struct p2p_data *p2p);
644void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
645 const u8 *data, size_t len, int rx_freq);
646void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
647 const u8 *data, size_t len, int rx_freq);
648void p2p_rx_gas_comeback_req(struct p2p_data *p2p, const u8 *sa,
649 const u8 *data, size_t len, int rx_freq);
650void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
651 const u8 *data, size_t len, int rx_freq);
652int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev);
653
654/* p2p_go_neg.c */
655int p2p_peer_channels_check(struct p2p_data *p2p, struct p2p_channels *own,
656 struct p2p_device *dev,
657 const u8 *channel_list, size_t channel_list_len);
658void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
659 const u8 *data, size_t len, int rx_freq);
660void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
661 const u8 *data, size_t len, int rx_freq);
662void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
663 const u8 *data, size_t len);
664int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700665u16 p2p_wps_method_pw_id(enum p2p_wps_method wps_method);
Dmitry Shmidt91c40cd2012-09-25 14:23:53 -0700666void p2p_reselect_channel(struct p2p_data *p2p,
667 struct p2p_channels *intersection);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700668
669/* p2p_pd.c */
670void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa,
671 const u8 *data, size_t len, int rx_freq);
672void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa,
673 const u8 *data, size_t len);
674int p2p_send_prov_disc_req(struct p2p_data *p2p, struct p2p_device *dev,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800675 int join, int force_freq);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700676void p2p_reset_pending_pd(struct p2p_data *p2p);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700677
678/* p2p_invitation.c */
679void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
680 const u8 *data, size_t len, int rx_freq);
681void p2p_process_invitation_resp(struct p2p_data *p2p, const u8 *sa,
682 const u8 *data, size_t len);
683int p2p_invite_send(struct p2p_data *p2p, struct p2p_device *dev,
684 const u8 *go_dev_addr);
685void p2p_invitation_req_cb(struct p2p_data *p2p, int success);
686void p2p_invitation_resp_cb(struct p2p_data *p2p, int success);
687
688/* p2p_dev_disc.c */
689void p2p_process_dev_disc_req(struct p2p_data *p2p, const u8 *sa,
690 const u8 *data, size_t len, int rx_freq);
691void p2p_dev_disc_req_cb(struct p2p_data *p2p, int success);
692int p2p_send_dev_disc_req(struct p2p_data *p2p, struct p2p_device *dev);
693void p2p_dev_disc_resp_cb(struct p2p_data *p2p, int success);
694void p2p_process_dev_disc_resp(struct p2p_data *p2p, const u8 *sa,
695 const u8 *data, size_t len);
696void p2p_go_disc_req_cb(struct p2p_data *p2p, int success);
697void p2p_process_go_disc_req(struct p2p_data *p2p, const u8 *da, const u8 *sa,
698 const u8 *data, size_t len, int rx_freq);
699
700/* p2p.c */
701void p2p_set_state(struct p2p_data *p2p, int new_state);
702void p2p_set_timeout(struct p2p_data *p2p, unsigned int sec,
703 unsigned int usec);
704void p2p_clear_timeout(struct p2p_data *p2p);
705void p2p_continue_find(struct p2p_data *p2p);
706struct p2p_device * p2p_add_dev_from_go_neg_req(struct p2p_data *p2p,
707 const u8 *addr,
708 struct p2p_message *msg);
709void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr,
710 struct p2p_device *dev, struct p2p_message *msg);
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800711int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
Dmitry Shmidtf8623282013-02-20 14:34:59 -0800712 struct os_time *rx_time, int level, const u8 *ies,
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800713 size_t ies_len, int scan_res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700714struct p2p_device * p2p_get_device(struct p2p_data *p2p, const u8 *addr);
715struct p2p_device * p2p_get_device_interface(struct p2p_data *p2p,
716 const u8 *addr);
717void p2p_go_neg_failed(struct p2p_data *p2p, struct p2p_device *peer,
718 int status);
719void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer);
720int p2p_match_dev_type(struct p2p_data *p2p, struct wpabuf *wps);
721int dev_type_list_match(const u8 *dev_type, const u8 *req_dev_type[],
722 size_t num_req_dev_type);
723struct wpabuf * p2p_build_probe_resp_ies(struct p2p_data *p2p);
724void p2p_build_ssid(struct p2p_data *p2p, u8 *ssid, size_t *ssid_len);
725int p2p_send_action(struct p2p_data *p2p, unsigned int freq, const u8 *dst,
726 const u8 *src, const u8 *bssid, const u8 *buf,
727 size_t len, unsigned int wait_time);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700728void p2p_stop_listen_for_freq(struct p2p_data *p2p, int freq);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700729
730#endif /* P2P_I_H */