p2p_i.h 22 KB

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