p2p_i.h 24 KB

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