p2p_i.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  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. const u8 *invite_go_dev_addr;
  219. u8 invite_go_dev_addr_buf[ETH_ALEN];
  220. int invite_dev_pw_id;
  221. /**
  222. * sd_peer - Pointer to Service Discovery peer
  223. */
  224. struct p2p_device *sd_peer;
  225. /**
  226. * sd_query - Pointer to Service Discovery query
  227. */
  228. struct p2p_sd_query *sd_query;
  229. /**
  230. * num_p2p_sd_queries - Total number of broadcast SD queries present in
  231. * the list
  232. */
  233. int num_p2p_sd_queries;
  234. /* GO Negotiation data */
  235. /**
  236. * intended_addr - Local Intended P2P Interface Address
  237. *
  238. * This address is used during group owner negotiation as the Intended
  239. * P2P Interface Address and the group interface will be created with
  240. * address as the local address in case of successfully completed
  241. * negotiation.
  242. */
  243. u8 intended_addr[ETH_ALEN];
  244. /**
  245. * go_intent - Local GO Intent to be used during GO Negotiation
  246. */
  247. u8 go_intent;
  248. /**
  249. * next_tie_breaker - Next tie-breaker value to use in GO Negotiation
  250. */
  251. u8 next_tie_breaker;
  252. /**
  253. * ssid - Selected SSID for GO Negotiation (if local end will be GO)
  254. */
  255. u8 ssid[32];
  256. /**
  257. * ssid_len - ssid length in octets
  258. */
  259. size_t ssid_len;
  260. /**
  261. * ssid_set - Whether SSID is already set for GO Negotiation
  262. */
  263. int ssid_set;
  264. /**
  265. * Regulatory class for own operational channel
  266. */
  267. u8 op_reg_class;
  268. /**
  269. * op_channel - Own operational channel
  270. */
  271. u8 op_channel;
  272. /**
  273. * channels - Own supported regulatory classes and channels
  274. *
  275. * List of supposerted channels per regulatory class. The regulatory
  276. * classes are defined in IEEE Std 802.11-2007 Annex J and the
  277. * numbering of the clases depends on the configured country code.
  278. */
  279. struct p2p_channels channels;
  280. struct wpa_freq_range_list no_go_freq;
  281. enum p2p_pending_action_state {
  282. P2P_NO_PENDING_ACTION,
  283. P2P_PENDING_GO_NEG_REQUEST,
  284. P2P_PENDING_GO_NEG_RESPONSE,
  285. P2P_PENDING_GO_NEG_RESPONSE_FAILURE,
  286. P2P_PENDING_GO_NEG_CONFIRM,
  287. P2P_PENDING_SD,
  288. P2P_PENDING_PD,
  289. P2P_PENDING_INVITATION_REQUEST,
  290. P2P_PENDING_INVITATION_RESPONSE,
  291. P2P_PENDING_DEV_DISC_REQUEST,
  292. P2P_PENDING_DEV_DISC_RESPONSE,
  293. P2P_PENDING_GO_DISC_REQ
  294. } pending_action_state;
  295. unsigned int pending_listen_freq;
  296. unsigned int pending_listen_sec;
  297. unsigned int pending_listen_usec;
  298. u8 dev_capab;
  299. int in_listen;
  300. int drv_in_listen;
  301. /**
  302. * sd_queries - Pending service discovery queries
  303. */
  304. struct p2p_sd_query *sd_queries;
  305. /**
  306. * srv_update_indic - Service Update Indicator for local services
  307. */
  308. u16 srv_update_indic;
  309. struct wpabuf *sd_resp; /* Fragmented SD response */
  310. u8 sd_resp_addr[ETH_ALEN];
  311. u8 sd_resp_dialog_token;
  312. size_t sd_resp_pos; /* Offset in sd_resp */
  313. u8 sd_frag_id;
  314. struct wpabuf *sd_rx_resp; /* Reassembled SD response */
  315. u16 sd_rx_update_indic;
  316. /* P2P Invitation data */
  317. enum p2p_invite_role inv_role;
  318. u8 inv_bssid[ETH_ALEN];
  319. int inv_bssid_set;
  320. u8 inv_ssid[32];
  321. size_t inv_ssid_len;
  322. u8 inv_sa[ETH_ALEN];
  323. u8 inv_group_bssid[ETH_ALEN];
  324. u8 *inv_group_bssid_ptr;
  325. u8 inv_go_dev_addr[ETH_ALEN];
  326. u8 inv_status;
  327. int inv_op_freq;
  328. int inv_persistent;
  329. enum p2p_discovery_type find_type;
  330. unsigned int last_p2p_find_timeout;
  331. u8 last_prog_scan_class;
  332. u8 last_prog_scan_chan;
  333. int p2p_scan_running;
  334. enum p2p_after_scan {
  335. P2P_AFTER_SCAN_NOTHING,
  336. P2P_AFTER_SCAN_LISTEN,
  337. P2P_AFTER_SCAN_CONNECT
  338. } start_after_scan;
  339. u8 after_scan_peer[ETH_ALEN];
  340. struct p2p_pending_action_tx *after_scan_tx;
  341. unsigned int after_scan_tx_in_progress:1;
  342. unsigned int send_action_in_progress:1;
  343. /* Requested device types for find/search */
  344. unsigned int num_req_dev_types;
  345. u8 *req_dev_types;
  346. u8 *find_dev_id;
  347. u8 find_dev_id_buf[ETH_ALEN];
  348. struct os_reltime find_start; /* time of last p2p_find start */
  349. struct p2p_group **groups;
  350. size_t num_groups;
  351. struct p2p_device *pending_client_disc_go;
  352. u8 pending_client_disc_addr[ETH_ALEN];
  353. u8 pending_dev_disc_dialog_token;
  354. u8 pending_dev_disc_addr[ETH_ALEN];
  355. int pending_dev_disc_freq;
  356. unsigned int pending_client_disc_freq;
  357. int ext_listen_only;
  358. unsigned int ext_listen_period;
  359. unsigned int ext_listen_interval;
  360. unsigned int ext_listen_interval_sec;
  361. unsigned int ext_listen_interval_usec;
  362. u8 peer_filter[ETH_ALEN];
  363. int cross_connect;
  364. int best_freq_24;
  365. int best_freq_5;
  366. int best_freq_overall;
  367. int own_freq_preference;
  368. /**
  369. * wps_vendor_ext - WPS Vendor Extensions to add
  370. */
  371. struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
  372. /*
  373. * user_initiated_pd - Whether a PD request is user initiated or not.
  374. */
  375. u8 user_initiated_pd;
  376. /*
  377. * Keep track of which peer a given PD request was sent to.
  378. * Used to raise a timeout alert in case there is no response.
  379. */
  380. u8 pending_pd_devaddr[ETH_ALEN];
  381. /*
  382. * Retry counter for provision discovery requests when issued
  383. * in IDLE state.
  384. */
  385. int pd_retries;
  386. /**
  387. * pd_force_freq - Forced frequency for PD retries or 0 to auto-select
  388. *
  389. * This is is used during PD retries for join-a-group case to use the
  390. * correct operating frequency determined from a BSS entry for the GO.
  391. */
  392. int pd_force_freq;
  393. u8 go_timeout;
  394. u8 client_timeout;
  395. /* Extra delay in milliseconds between search iterations */
  396. unsigned int search_delay;
  397. int in_search_delay;
  398. u8 pending_reg_class;
  399. u8 pending_channel;
  400. u8 pending_channel_forced;
  401. #ifdef CONFIG_WIFI_DISPLAY
  402. struct wpabuf *wfd_ie_beacon;
  403. struct wpabuf *wfd_ie_probe_req;
  404. struct wpabuf *wfd_ie_probe_resp;
  405. struct wpabuf *wfd_ie_assoc_req;
  406. struct wpabuf *wfd_ie_invitation;
  407. struct wpabuf *wfd_ie_prov_disc_req;
  408. struct wpabuf *wfd_ie_prov_disc_resp;
  409. struct wpabuf *wfd_ie_go_neg;
  410. struct wpabuf *wfd_dev_info;
  411. struct wpabuf *wfd_assoc_bssid;
  412. struct wpabuf *wfd_coupled_sink_info;
  413. #endif /* CONFIG_WIFI_DISPLAY */
  414. u16 authorized_oob_dev_pw_id;
  415. struct wpabuf **vendor_elem;
  416. };
  417. /**
  418. * struct p2p_message - Parsed P2P message (or P2P IE)
  419. */
  420. struct p2p_message {
  421. struct wpabuf *p2p_attributes;
  422. struct wpabuf *wps_attributes;
  423. struct wpabuf *wfd_subelems;
  424. u8 dialog_token;
  425. const u8 *capability;
  426. const u8 *go_intent;
  427. const u8 *status;
  428. const u8 *listen_channel;
  429. const u8 *operating_channel;
  430. const u8 *channel_list;
  431. u8 channel_list_len;
  432. const u8 *config_timeout;
  433. const u8 *intended_addr;
  434. const u8 *group_bssid;
  435. const u8 *invitation_flags;
  436. const u8 *group_info;
  437. size_t group_info_len;
  438. const u8 *group_id;
  439. size_t group_id_len;
  440. const u8 *device_id;
  441. const u8 *manageability;
  442. const u8 *noa;
  443. size_t noa_len;
  444. const u8 *ext_listen_timing;
  445. const u8 *minor_reason_code;
  446. const u8 *oob_go_neg_channel;
  447. /* P2P Device Info */
  448. const u8 *p2p_device_info;
  449. size_t p2p_device_info_len;
  450. const u8 *p2p_device_addr;
  451. const u8 *pri_dev_type;
  452. u8 num_sec_dev_types;
  453. char device_name[33];
  454. u16 config_methods;
  455. /* WPS IE */
  456. u16 dev_password_id;
  457. int dev_password_id_present;
  458. u16 wps_config_methods;
  459. const u8 *wps_pri_dev_type;
  460. const u8 *wps_sec_dev_type_list;
  461. size_t wps_sec_dev_type_list_len;
  462. const u8 *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
  463. size_t wps_vendor_ext_len[P2P_MAX_WPS_VENDOR_EXT];
  464. const u8 *manufacturer;
  465. size_t manufacturer_len;
  466. const u8 *model_name;
  467. size_t model_name_len;
  468. const u8 *model_number;
  469. size_t model_number_len;
  470. const u8 *serial_number;
  471. size_t serial_number_len;
  472. const u8 *oob_dev_password;
  473. size_t oob_dev_password_len;
  474. /* DS Parameter Set IE */
  475. const u8 *ds_params;
  476. /* SSID IE */
  477. const u8 *ssid;
  478. };
  479. #define P2P_MAX_GROUP_ENTRIES 50
  480. struct p2p_group_info {
  481. unsigned int num_clients;
  482. struct p2p_client_info {
  483. const u8 *p2p_device_addr;
  484. const u8 *p2p_interface_addr;
  485. u8 dev_capab;
  486. u16 config_methods;
  487. const u8 *pri_dev_type;
  488. u8 num_sec_dev_types;
  489. const u8 *sec_dev_types;
  490. const char *dev_name;
  491. size_t dev_name_len;
  492. } client[P2P_MAX_GROUP_ENTRIES];
  493. };
  494. /* p2p_utils.c */
  495. int p2p_random(char *buf, size_t len);
  496. int p2p_channel_to_freq(int op_class, int channel);
  497. int p2p_freq_to_channel(unsigned int freq, u8 *op_class, u8 *channel);
  498. void p2p_channels_intersect(const struct p2p_channels *a,
  499. const struct p2p_channels *b,
  500. struct p2p_channels *res);
  501. void p2p_channels_union(const struct p2p_channels *a,
  502. const struct p2p_channels *b,
  503. struct p2p_channels *res);
  504. void p2p_channels_remove_freqs(struct p2p_channels *chan,
  505. const struct wpa_freq_range_list *list);
  506. int p2p_channels_includes(const struct p2p_channels *channels, u8 reg_class,
  507. u8 channel);
  508. void p2p_channels_dump(struct p2p_data *p2p, const char *title,
  509. const struct p2p_channels *chan);
  510. int p2p_channel_select(struct p2p_channels *chans, const int *classes,
  511. u8 *op_class, u8 *op_channel);
  512. int p2p_channel_random_social(struct p2p_channels *chans, u8 *op_class,
  513. u8 *op_channel);
  514. /* p2p_parse.c */
  515. int p2p_parse_p2p_ie(const struct wpabuf *buf, struct p2p_message *msg);
  516. int p2p_parse_ies(const u8 *data, size_t len, struct p2p_message *msg);
  517. int p2p_parse(const u8 *data, size_t len, struct p2p_message *msg);
  518. int p2p_parse_ies_separate(const u8 *wsc, size_t wsc_len, const u8 *p2p,
  519. size_t p2p_len, struct p2p_message *msg);
  520. void p2p_parse_free(struct p2p_message *msg);
  521. int p2p_attr_text(struct wpabuf *data, char *buf, char *end);
  522. int p2p_group_info_parse(const u8 *gi, size_t gi_len,
  523. struct p2p_group_info *info);
  524. /* p2p_build.c */
  525. struct p2p_noa_desc {
  526. u8 count_type;
  527. u32 duration;
  528. u32 interval;
  529. u32 start_time;
  530. };
  531. /* p2p_group.c */
  532. const u8 * p2p_group_get_interface_addr(struct p2p_group *group);
  533. u8 p2p_group_presence_req(struct p2p_group *group,
  534. const u8 *client_interface_addr,
  535. const u8 *noa, size_t noa_len);
  536. int p2p_group_is_group_id_match(struct p2p_group *group, const u8 *group_id,
  537. size_t group_id_len);
  538. void p2p_group_update_ies(struct p2p_group *group);
  539. void p2p_group_force_beacon_update_ies(struct p2p_group *group);
  540. struct wpabuf * p2p_group_get_wfd_ie(struct p2p_group *g);
  541. void p2p_buf_add_group_info(struct p2p_group *group, struct wpabuf *buf,
  542. int max_clients);
  543. void p2p_group_buf_add_id(struct p2p_group *group, struct wpabuf *buf);
  544. int p2p_group_get_freq(struct p2p_group *group);
  545. void p2p_buf_add_action_hdr(struct wpabuf *buf, u8 subtype, u8 dialog_token);
  546. void p2p_buf_add_public_action_hdr(struct wpabuf *buf, u8 subtype,
  547. u8 dialog_token);
  548. u8 * p2p_buf_add_ie_hdr(struct wpabuf *buf);
  549. void p2p_buf_add_status(struct wpabuf *buf, u8 status);
  550. void p2p_buf_add_device_info(struct wpabuf *buf, struct p2p_data *p2p,
  551. struct p2p_device *peer);
  552. void p2p_buf_add_device_id(struct wpabuf *buf, const u8 *dev_addr);
  553. void p2p_buf_update_ie_hdr(struct wpabuf *buf, u8 *len);
  554. void p2p_buf_add_capability(struct wpabuf *buf, u8 dev_capab, u8 group_capab);
  555. void p2p_buf_add_go_intent(struct wpabuf *buf, u8 go_intent);
  556. void p2p_buf_add_listen_channel(struct wpabuf *buf, const char *country,
  557. u8 reg_class, u8 channel);
  558. void p2p_buf_add_operating_channel(struct wpabuf *buf, const char *country,
  559. u8 reg_class, u8 channel);
  560. void p2p_buf_add_channel_list(struct wpabuf *buf, const char *country,
  561. struct p2p_channels *chan);
  562. void p2p_buf_add_config_timeout(struct wpabuf *buf, u8 go_timeout,
  563. u8 client_timeout);
  564. void p2p_buf_add_intended_addr(struct wpabuf *buf, const u8 *interface_addr);
  565. void p2p_buf_add_group_bssid(struct wpabuf *buf, const u8 *bssid);
  566. void p2p_buf_add_group_id(struct wpabuf *buf, const u8 *dev_addr,
  567. const u8 *ssid, size_t ssid_len);
  568. void p2p_buf_add_invitation_flags(struct wpabuf *buf, u8 flags);
  569. void p2p_buf_add_noa(struct wpabuf *buf, u8 noa_index, u8 opp_ps, u8 ctwindow,
  570. struct p2p_noa_desc *desc1, struct p2p_noa_desc *desc2);
  571. void p2p_buf_add_ext_listen_timing(struct wpabuf *buf, u16 period,
  572. u16 interval);
  573. void p2p_buf_add_p2p_interface(struct wpabuf *buf, struct p2p_data *p2p);
  574. void p2p_buf_add_oob_go_neg_channel(struct wpabuf *buf, const char *country,
  575. u8 oper_class, u8 channel,
  576. enum p2p_role_indication role);
  577. int p2p_build_wps_ie(struct p2p_data *p2p, struct wpabuf *buf, int pw_id,
  578. int all_attr);
  579. /* p2p_sd.c */
  580. struct p2p_sd_query * p2p_pending_sd_req(struct p2p_data *p2p,
  581. struct p2p_device *dev);
  582. void p2p_free_sd_queries(struct p2p_data *p2p);
  583. void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
  584. const u8 *data, size_t len, int rx_freq);
  585. void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
  586. const u8 *data, size_t len, int rx_freq);
  587. void p2p_rx_gas_comeback_req(struct p2p_data *p2p, const u8 *sa,
  588. const u8 *data, size_t len, int rx_freq);
  589. void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
  590. const u8 *data, size_t len, int rx_freq);
  591. int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev);
  592. /* p2p_go_neg.c */
  593. int p2p_peer_channels_check(struct p2p_data *p2p, struct p2p_channels *own,
  594. struct p2p_device *dev,
  595. const u8 *channel_list, size_t channel_list_len);
  596. void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
  597. const u8 *data, size_t len, int rx_freq);
  598. void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
  599. const u8 *data, size_t len, int rx_freq);
  600. void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
  601. const u8 *data, size_t len);
  602. int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev);
  603. u16 p2p_wps_method_pw_id(enum p2p_wps_method wps_method);
  604. void p2p_reselect_channel(struct p2p_data *p2p,
  605. struct p2p_channels *intersection);
  606. /* p2p_pd.c */
  607. void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa,
  608. const u8 *data, size_t len, int rx_freq);
  609. void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa,
  610. const u8 *data, size_t len);
  611. int p2p_send_prov_disc_req(struct p2p_data *p2p, struct p2p_device *dev,
  612. int join, int force_freq);
  613. void p2p_reset_pending_pd(struct p2p_data *p2p);
  614. /* p2p_invitation.c */
  615. void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
  616. const u8 *data, size_t len, int rx_freq);
  617. void p2p_process_invitation_resp(struct p2p_data *p2p, const u8 *sa,
  618. const u8 *data, size_t len);
  619. int p2p_invite_send(struct p2p_data *p2p, struct p2p_device *dev,
  620. const u8 *go_dev_addr, int dev_pw_id);
  621. void p2p_invitation_req_cb(struct p2p_data *p2p, int success);
  622. void p2p_invitation_resp_cb(struct p2p_data *p2p, int success);
  623. /* p2p_dev_disc.c */
  624. void p2p_process_dev_disc_req(struct p2p_data *p2p, const u8 *sa,
  625. const u8 *data, size_t len, int rx_freq);
  626. void p2p_dev_disc_req_cb(struct p2p_data *p2p, int success);
  627. int p2p_send_dev_disc_req(struct p2p_data *p2p, struct p2p_device *dev);
  628. void p2p_dev_disc_resp_cb(struct p2p_data *p2p, int success);
  629. void p2p_process_dev_disc_resp(struct p2p_data *p2p, const u8 *sa,
  630. const u8 *data, size_t len);
  631. void p2p_go_disc_req_cb(struct p2p_data *p2p, int success);
  632. void p2p_process_go_disc_req(struct p2p_data *p2p, const u8 *da, const u8 *sa,
  633. const u8 *data, size_t len, int rx_freq);
  634. /* p2p.c */
  635. void p2p_set_state(struct p2p_data *p2p, int new_state);
  636. void p2p_set_timeout(struct p2p_data *p2p, unsigned int sec,
  637. unsigned int usec);
  638. void p2p_clear_timeout(struct p2p_data *p2p);
  639. void p2p_continue_find(struct p2p_data *p2p);
  640. struct p2p_device * p2p_add_dev_from_go_neg_req(struct p2p_data *p2p,
  641. const u8 *addr,
  642. struct p2p_message *msg);
  643. void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr,
  644. struct p2p_device *dev, struct p2p_message *msg);
  645. int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
  646. struct os_reltime *rx_time, int level, const u8 *ies,
  647. size_t ies_len, int scan_res);
  648. struct p2p_device * p2p_get_device(struct p2p_data *p2p, const u8 *addr);
  649. struct p2p_device * p2p_get_device_interface(struct p2p_data *p2p,
  650. const u8 *addr);
  651. void p2p_go_neg_failed(struct p2p_data *p2p, struct p2p_device *peer,
  652. int status);
  653. void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer);
  654. int p2p_match_dev_type(struct p2p_data *p2p, struct wpabuf *wps);
  655. int dev_type_list_match(const u8 *dev_type, const u8 *req_dev_type[],
  656. size_t num_req_dev_type);
  657. struct wpabuf * p2p_build_probe_resp_ies(struct p2p_data *p2p);
  658. void p2p_build_ssid(struct p2p_data *p2p, u8 *ssid, size_t *ssid_len);
  659. int p2p_send_action(struct p2p_data *p2p, unsigned int freq, const u8 *dst,
  660. const u8 *src, const u8 *bssid, const u8 *buf,
  661. size_t len, unsigned int wait_time);
  662. void p2p_stop_listen_for_freq(struct p2p_data *p2p, int freq);
  663. int p2p_prepare_channel(struct p2p_data *p2p, struct p2p_device *dev,
  664. unsigned int force_freq, unsigned int pref_freq,
  665. int go);
  666. void p2p_dbg(struct p2p_data *p2p, const char *fmt, ...)
  667. PRINTF_FORMAT(2, 3);
  668. void p2p_info(struct p2p_data *p2p, const char *fmt, ...)
  669. PRINTF_FORMAT(2, 3);
  670. void p2p_err(struct p2p_data *p2p, const char *fmt, ...)
  671. PRINTF_FORMAT(2, 3);
  672. #endif /* P2P_I_H */