hostapd
p2p.h
1 /*
2  * Wi-Fi Direct - 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 
9 #ifndef P2P_H
10 #define P2P_H
11 
12 #include "common/ieee802_11_defs.h"
13 #include "wps/wps.h"
14 
15 /* P2P ASP Setup Capability */
16 #define P2PS_SETUP_NONE 0
17 #define P2PS_SETUP_NEW BIT(0)
18 #define P2PS_SETUP_CLIENT BIT(1)
19 #define P2PS_SETUP_GROUP_OWNER BIT(2)
20 
21 #define P2PS_WILD_HASH_STR "org.wi-fi.wfds"
22 #define P2PS_HASH_LEN 6
23 #define P2P_MAX_QUERY_HASH 6
24 #define P2PS_FEATURE_CAPAB_CPT_MAX 2
25 
29 #define P2P_MAX_PREF_CHANNELS 100
30 
34 #define P2P_MAX_REG_CLASSES 15
35 
39 #define P2P_MAX_REG_CLASS_CHANNELS 20
40 
44 struct p2p_channels {
48  struct p2p_reg_class {
53 
57  u8 channel[P2P_MAX_REG_CLASS_CHANNELS];
58 
62  size_t channels;
63  } reg_class[P2P_MAX_REG_CLASSES];
64 
68  size_t reg_classes;
69 };
70 
71 enum p2p_wps_method {
72  WPS_NOT_READY, WPS_PIN_DISPLAY, WPS_PIN_KEYPAD, WPS_PBC, WPS_NFC,
73  WPS_P2PS
74 };
75 
86  int status;
87 
91  int role_go;
92 
96  int freq;
97 
98  int ht40;
99 
100  int vht;
101 
102  u8 max_oper_chwidth;
103 
104  unsigned int vht_center_freq2;
105 
109  u8 ssid[SSID_MAX_LEN];
110 
114  size_t ssid_len;
115 
119  u8 psk[32];
120 
124  int psk_set;
125 
129  char passphrase[64];
130 
134  u8 peer_device_addr[ETH_ALEN];
135 
139  u8 peer_interface_addr[ETH_ALEN];
140 
144  enum p2p_wps_method wps_method;
145 
146 #define P2P_MAX_CHANNELS 50
147 
151  int freq_list[P2P_MAX_CHANNELS];
152 
160 
164  unsigned int peer_config_timeout;
165 };
166 
171  unsigned int pd_seeker:1;
172 
176  int status;
177 
181  u32 adv_id;
182 
187 
191  u16 method;
192 
197 
201  u8 role;
202 
206  u8 session_mac[ETH_ALEN];
207 
211  u8 adv_mac[ETH_ALEN];
212 
220 
228  u8 cpt_priority[P2PS_FEATURE_CAPAB_CPT_MAX + 1];
229 
233  unsigned int force_freq;
234 
238  unsigned int pref_freq;
239 
243  char info[0];
244 };
245 
247  struct p2ps_advertisement *next;
248 
252  char *svc_info;
253 
257  u32 id;
258 
263 
267  u8 state;
268 
273 
277  u8 hash[P2PS_HASH_LEN];
278 
286 
294  u8 cpt_priority[P2PS_FEATURE_CAPAB_CPT_MAX + 1];
295 
299  char svc_name[0];
300 };
301 
302 
303 struct p2p_data;
304 
305 enum p2p_scan_type {
306  P2P_SCAN_SOCIAL,
307  P2P_SCAN_FULL,
308  P2P_SCAN_SPECIFIC,
309  P2P_SCAN_SOCIAL_PLUS_ONE
310 };
311 
312 #define P2P_MAX_WPS_VENDOR_EXT 10
313 
321  u8 p2p_device_addr[ETH_ALEN];
322 
326  u8 pri_dev_type[8];
327 
331  char device_name[WPS_DEV_NAME_MAX_LEN + 1];
332 
336  char manufacturer[WPS_MANUFACTURER_MAX_LEN + 1];
337 
341  char model_name[WPS_MODEL_NAME_MAX_LEN + 1];
342 
346  char model_number[WPS_MODEL_NUMBER_MAX_LEN + 1];
347 
351  char serial_number[WPS_SERIAL_NUMBER_MAX_LEN + 1];
352 
356  int level;
357 
362 
367 
372 
379  u8 wps_sec_dev_type_list[WPS_SEC_DEV_TYPE_MAX_LEN];
380 
385 
386  struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
387 
392 
400 
405 };
406 
407 enum p2p_prov_disc_status {
408  P2P_PROV_DISC_SUCCESS,
409  P2P_PROV_DISC_TIMEOUT,
410  P2P_PROV_DISC_REJECTED,
411  P2P_PROV_DISC_TIMEOUT_JOIN,
412  P2P_PROV_DISC_INFO_UNAVAILABLE,
413 };
414 
415 struct p2p_channel {
416  u8 op_class;
417  u8 chan;
418 };
419 
426 struct p2p_config {
430  char country[3];
431 
436 
441 
447 
452 
457 
462 
471 
484  struct p2p_channels cli_channels;
485 
489  unsigned int num_pref_chan;
490 
495 
499  u8 pri_dev_type[8];
500 
504 #define P2P_SEC_DEVICE_TYPES 5
505 
509  u8 sec_dev_type[P2P_SEC_DEVICE_TYPES][8];
510 
515 
519  u8 dev_addr[ETH_ALEN];
520 
524  char *dev_name;
525 
526  char *manufacturer;
527  char *model_name;
528  char *model_number;
529  char *serial_number;
530 
531  u8 uuid[16];
532  u16 config_methods;
533 
538 
545  size_t max_peers;
546 
551 
558  u8 ssid_postfix[SSID_MAX_LEN - 9];
559 
564 
568  unsigned int max_listen;
569 
576  unsigned int passphrase_len;
577 
581  void *cb_ctx;
582 
589  void (*debug_print)(void *ctx, int level, const char *msg);
590 
591 
592  /* Callbacks to request lower layer driver operations */
593 
624  int (*p2p_scan)(void *ctx, enum p2p_scan_type type, int freq,
625  unsigned int num_req_dev_types,
626  const u8 *req_dev_types, const u8 *dev_id, u16 pw_id);
627 
650  int (*send_probe_resp)(void *ctx, const struct wpabuf *buf,
651  unsigned int freq);
652 
671  int (*send_action)(void *ctx, unsigned int freq, const u8 *dst,
672  const u8 *src, const u8 *bssid, const u8 *buf,
673  size_t len, unsigned int wait_time);
674 
683  void (*send_action_done)(void *ctx);
684 
705  int (*start_listen)(void *ctx, unsigned int freq,
706  unsigned int duration,
707  const struct wpabuf *probe_resp_ie);
715  void (*stop_listen)(void *ctx);
716 
729  int (*get_noa)(void *ctx, const u8 *interface_addr, u8 *buf,
730  size_t buf_len);
731 
732  /* Callbacks to notify events to upper layer management entity */
733 
746  void (*dev_found)(void *ctx, const u8 *addr,
747  const struct p2p_peer_info *info,
748  int new_device);
749 
757  void (*dev_lost)(void *ctx, const u8 *dev_addr);
758 
763  void (*find_stopped)(void *ctx);
764 
779  void (*go_neg_req_rx)(void *ctx, const u8 *src, u16 dev_passwd_id,
780  u8 go_intent);
781 
799  void (*go_neg_completed)(void *ctx, struct p2p_go_neg_results *res);
800 
819  void (*sd_request)(void *ctx, int freq, const u8 *sa, u8 dialog_token,
820  u16 update_indic, const u8 *tlvs, size_t tlvs_len);
821 
835  void (*sd_response)(void *ctx, const u8 *sa, u16 update_indic,
836  const u8 *tlvs, size_t tlvs_len);
837 
855  void (*prov_disc_req)(void *ctx, const u8 *peer, u16 config_methods,
856  const u8 *dev_addr, const u8 *pri_dev_type,
857  const char *dev_name, u16 supp_config_methods,
858  u8 dev_capab, u8 group_capab,
859  const u8 *group_id, size_t group_id_len);
860 
872  void (*prov_disc_resp)(void *ctx, const u8 *peer, u16 config_methods);
873 
889  void (*prov_disc_fail)(void *ctx, const u8 *peer,
890  enum p2p_prov_disc_status status,
891  u32 adv_id, const u8 *adv_mac,
892  const char *deferred_session_resp);
893 
928  u8 (*invitation_process)(void *ctx, const u8 *sa, const u8 *bssid,
929  const u8 *go_dev_addr, const u8 *ssid,
930  size_t ssid_len, int *go, u8 *group_bssid,
931  int *force_freq, int persistent_group,
932  const struct p2p_channels *channels,
933  int dev_pw_id);
934 
952  void (*invitation_received)(void *ctx, const u8 *sa, const u8 *bssid,
953  const u8 *ssid, size_t ssid_len,
954  const u8 *go_dev_addr, u8 status,
955  int op_freq);
956 
974  void (*invitation_result)(void *ctx, int status, const u8 *bssid,
975  const struct p2p_channels *channels,
976  const u8 *addr, int freq, int peer_oper_freq);
977 
985  int (*go_connected)(void *ctx, const u8 *dev_addr);
986 
995  void (*presence_resp)(void *ctx, const u8 *src, u8 status,
996  const u8 *noa, size_t noa_len);
997 
1005  int (*is_concurrent_session_active)(void *ctx);
1006 
1013  int (*is_p2p_in_progress)(void *ctx);
1014 
1028  int (*get_persistent_group)(void *ctx, const u8 *addr, const u8 *ssid,
1029  size_t ssid_len, u8 *go_dev_addr,
1030  u8 *ret_ssid, size_t *ret_ssid_len,
1031  u8 *intended_iface_addr);
1032 
1049  int (*get_go_info)(void *ctx, u8 *intended_addr,
1050  u8 *ssid, size_t *ssid_len, int *group_iface,
1051  unsigned int *freq);
1052 
1060  int (*remove_stale_groups)(void *ctx, const u8 *peer, const u8 *go,
1061  const u8 *ssid, size_t ssid_len);
1062 
1069  void (*p2ps_prov_complete)(void *ctx, u8 status, const u8 *dev,
1070  const u8 *adv_mac, const u8 *ses_mac,
1071  const u8 *grp_mac, u32 adv_id, u32 ses_id,
1072  u8 conncap, int passwd_id,
1073  const u8 *persist_ssid,
1074  size_t persist_ssid_size, int response_done,
1075  int prov_start, const char *session_info,
1076  const u8 *feat_cap, size_t feat_cap_len,
1077  unsigned int freq, const u8 *group_ssid,
1078  size_t group_ssid_len);
1079 
1088  int (*prov_disc_resp_cb)(void *ctx);
1089 
1103  u8 (*p2ps_group_capability)(void *ctx, u8 incoming, u8 role,
1104  unsigned int *force_freq,
1105  unsigned int *pref_freq);
1106 
1118  int (*get_pref_freq_list)(void *ctx, int go,
1119  unsigned int *len, unsigned int *freq_list);
1120 };
1121 
1122 
1123 /* P2P module initialization/deinitialization */
1124 
1136 struct p2p_data * p2p_init(const struct p2p_config *cfg);
1137 
1142 void p2p_deinit(struct p2p_data *p2p);
1143 
1150 void p2p_flush(struct p2p_data *p2p);
1151 
1163 int p2p_unauthorize(struct p2p_data *p2p, const u8 *addr);
1164 
1173 int p2p_set_dev_name(struct p2p_data *p2p, const char *dev_name);
1174 
1175 int p2p_set_manufacturer(struct p2p_data *p2p, const char *manufacturer);
1176 int p2p_set_model_name(struct p2p_data *p2p, const char *model_name);
1177 int p2p_set_model_number(struct p2p_data *p2p, const char *model_number);
1178 int p2p_set_serial_number(struct p2p_data *p2p, const char *serial_number);
1179 
1180 void p2p_set_config_methods(struct p2p_data *p2p, u16 config_methods);
1181 void p2p_set_uuid(struct p2p_data *p2p, const u8 *uuid);
1182 
1191 int p2p_set_pri_dev_type(struct p2p_data *p2p, const u8 *pri_dev_type);
1192 
1201 int p2p_set_sec_dev_types(struct p2p_data *p2p, const u8 dev_types[][8],
1202  size_t num_dev_types);
1203 
1204 int p2p_set_country(struct p2p_data *p2p, const char *country);
1205 
1206 
1207 /* Commands from upper layer management entity */
1208 
1209 enum p2p_discovery_type {
1210  P2P_FIND_START_WITH_FULL,
1211  P2P_FIND_ONLY_SOCIAL,
1212  P2P_FIND_PROGRESSIVE
1213 };
1214 
1234 int p2p_find(struct p2p_data *p2p, unsigned int timeout,
1235  enum p2p_discovery_type type,
1236  unsigned int num_req_dev_types, const u8 *req_dev_types,
1237  const u8 *dev_id, unsigned int search_delay,
1238  u8 seek_count, const char **seek_string, int freq);
1239 
1245 void p2p_notify_scan_trigger_status(struct p2p_data *p2p, int status);
1246 
1251 void p2p_stop_find(struct p2p_data *p2p);
1252 
1261 void p2p_stop_find_for_freq(struct p2p_data *p2p, int freq);
1262 
1274 int p2p_listen(struct p2p_data *p2p, unsigned int timeout);
1275 
1280 void p2p_stop_listen(struct p2p_data *p2p);
1281 
1303 int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr,
1304  enum p2p_wps_method wps_method,
1305  int go_intent, const u8 *own_interface_addr,
1306  unsigned int force_freq, int persistent_group,
1307  const u8 *force_ssid, size_t force_ssid_len,
1308  int pd_before_go_neg, unsigned int pref_freq, u16 oob_pw_id);
1309 
1331 int p2p_authorize(struct p2p_data *p2p, const u8 *peer_addr,
1332  enum p2p_wps_method wps_method,
1333  int go_intent, const u8 *own_interface_addr,
1334  unsigned int force_freq, int persistent_group,
1335  const u8 *force_ssid, size_t force_ssid_len,
1336  unsigned int pref_freq, u16 oob_pw_id);
1337 
1344 int p2p_reject(struct p2p_data *p2p, const u8 *peer_addr);
1345 
1365 int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr,
1366  struct p2ps_provision *p2ps_prov, u16 config_methods,
1367  int join, int force_freq,
1368  int user_initiated_pd);
1369 
1380 void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst,
1381  const struct wpabuf *tlvs);
1382 
1383 #ifdef CONFIG_WIFI_DISPLAY
1384 void * p2p_sd_request_wfd(struct p2p_data *p2p, const u8 *dst,
1385  const struct wpabuf *tlvs);
1386 #endif /* CONFIG_WIFI_DISPLAY */
1387 
1394 int p2p_sd_cancel_request(struct p2p_data *p2p, void *req);
1395 
1407 void p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst,
1408  u8 dialog_token, const struct wpabuf *resp_tlvs);
1409 
1418 void p2p_sd_service_update(struct p2p_data *p2p);
1419 
1420 
1421 enum p2p_invite_role {
1422  P2P_INVITE_ROLE_GO,
1423  P2P_INVITE_ROLE_ACTIVE_GO,
1424  P2P_INVITE_ROLE_CLIENT
1425 };
1426 
1444 int p2p_invite(struct p2p_data *p2p, const u8 *peer, enum p2p_invite_role role,
1445  const u8 *bssid, const u8 *ssid, size_t ssid_len,
1446  unsigned int force_freq, const u8 *go_dev_addr,
1447  int persistent_group, unsigned int pref_freq, int dev_pw_id);
1448 
1464 int p2p_presence_req(struct p2p_data *p2p, const u8 *go_interface_addr,
1465  const u8 *own_interface_addr, unsigned int freq,
1466  u32 duration1, u32 interval1, u32 duration2,
1467  u32 interval2);
1468 
1482 int p2p_ext_listen(struct p2p_data *p2p, unsigned int period,
1483  unsigned int interval);
1484 
1485 /* Event notifications from upper layer management operations */
1486 
1495 void p2p_wps_success_cb(struct p2p_data *p2p, const u8 *mac_addr);
1496 
1505 void p2p_group_formation_failed(struct p2p_data *p2p);
1506 
1517 u16 p2p_get_provisioning_info(struct p2p_data *p2p, const u8 *addr);
1518 
1527 void p2p_clear_provisioning_info(struct p2p_data *p2p, const u8 *addr);
1528 
1529 
1530 /* Event notifications from lower layer driver operations */
1531 
1541 enum p2p_probe_req_status {
1542  P2P_PREQ_MALFORMED,
1543  P2P_PREQ_NOT_LISTEN,
1544  P2P_PREQ_NOT_P2P,
1545  P2P_PREQ_NOT_PROCESSED,
1546  P2P_PREQ_PROCESSED
1547 };
1548 
1561 enum p2p_probe_req_status
1562 p2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *dst,
1563  const u8 *bssid, const u8 *ie, size_t ie_len,
1564  unsigned int rx_freq, int p2p_lo_started);
1565 
1577 void p2p_rx_action(struct p2p_data *p2p, const u8 *da, const u8 *sa,
1578  const u8 *bssid, u8 category,
1579  const u8 *data, size_t len, int freq);
1580 
1607 int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq,
1608  struct os_reltime *rx_time, int level, const u8 *ies,
1609  size_t ies_len);
1610 
1621 void p2p_scan_res_handled(struct p2p_data *p2p);
1622 
1623 enum p2p_send_action_result {
1624  P2P_SEND_ACTION_SUCCESS /* Frame was send and acknowledged */,
1625  P2P_SEND_ACTION_NO_ACK /* Frame was sent, but not acknowledged */,
1626  P2P_SEND_ACTION_FAILED /* Frame was not sent due to a failure */
1627 };
1628 
1641 void p2p_send_action_cb(struct p2p_data *p2p, unsigned int freq, const u8 *dst,
1642  const u8 *src, const u8 *bssid,
1643  enum p2p_send_action_result result);
1644 
1654 void p2p_listen_cb(struct p2p_data *p2p, unsigned int freq,
1655  unsigned int duration);
1656 
1666 int p2p_listen_end(struct p2p_data *p2p, unsigned int freq);
1667 
1668 void p2p_deauth_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code,
1669  const u8 *ie, size_t ie_len);
1670 
1671 void p2p_disassoc_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code,
1672  const u8 *ie, size_t ie_len);
1673 
1674 
1675 /* Per-group P2P state for GO */
1676 
1677 struct p2p_group;
1678 
1693 
1697  u8 interface_addr[ETH_ALEN];
1698 
1702  unsigned int max_clients;
1703 
1707  u8 ssid[SSID_MAX_LEN];
1708 
1712  size_t ssid_len;
1713 
1717  int freq;
1718 
1724 
1728  void *cb_ctx;
1729 
1743  void (*ie_update)(void *ctx, struct wpabuf *beacon_ies,
1744  struct wpabuf *proberesp_ies);
1745 
1751  void (*idle_update)(void *ctx, int idle);
1752 };
1753 
1764 struct p2p_group * p2p_group_init(struct p2p_data *p2p,
1765  struct p2p_group_config *config);
1766 
1771 void p2p_group_deinit(struct p2p_group *group);
1772 
1781 int p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr,
1782  const u8 *ie, size_t len);
1783 
1793 struct wpabuf * p2p_group_assoc_resp_ie(struct p2p_group *group, u8 status);
1794 
1800 void p2p_group_notif_disassoc(struct p2p_group *group, const u8 *addr);
1801 
1806 void p2p_group_notif_formation_done(struct p2p_group *group);
1807 
1819 int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa,
1820  size_t noa_len);
1821 
1833 int p2p_group_match_dev_type(struct p2p_group *group, struct wpabuf *wps);
1834 
1838 int p2p_group_match_dev_id(struct p2p_group *group, struct wpabuf *p2p);
1839 
1845 int p2p_group_go_discover(struct p2p_group *group, const u8 *dev_id,
1846  const u8 *searching_dev, int rx_freq);
1847 
1848 
1849 /* Generic helper functions */
1850 
1861 int p2p_ie_text(struct wpabuf *p2p_ie, char *buf, char *end);
1862 
1874 int p2p_scan_result_text(const u8 *ies, size_t ies_len, char *buf, char *end);
1875 
1883 int p2p_parse_dev_addr_in_p2p_ie(struct wpabuf *p2p_ie, u8 *dev_addr);
1884 
1892 int p2p_parse_dev_addr(const u8 *ies, size_t ies_len, u8 *dev_addr);
1893 
1904 int p2p_assoc_req_ie(struct p2p_data *p2p, const u8 *bssid, u8 *buf,
1905  size_t len, int p2p_group, struct wpabuf *p2p_ie);
1906 
1914 void p2p_scan_ie(struct p2p_data *p2p, struct wpabuf *ies, const u8 *dev_id,
1915  unsigned int bands);
1916 
1922 size_t p2p_scan_ie_buf_len(struct p2p_data *p2p);
1923 
1930 int p2p_go_params(struct p2p_data *p2p, struct p2p_go_neg_results *params);
1931 
1937 u8 p2p_get_group_capab(const struct wpabuf *p2p_ie);
1938 
1944 int p2p_get_cross_connect_disallowed(const struct wpabuf *p2p_ie);
1945 
1951 const u8 * p2p_get_go_dev_addr(const struct wpabuf *p2p_ie);
1952 
1960 const struct p2p_peer_info * p2p_get_peer_info(struct p2p_data *p2p,
1961  const u8 *addr, int next);
1962 
1974 int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
1975  char *buf, size_t buflen);
1976 
1983 int p2p_peer_known(struct p2p_data *p2p, const u8 *addr);
1984 
1994 void p2p_set_client_discoverability(struct p2p_data *p2p, int enabled);
1995 
2001 void p2p_set_managed_oper(struct p2p_data *p2p, int enabled);
2002 
2014 int p2p_config_get_random_social(struct p2p_config *p2p, u8 *op_class,
2015  u8 *op_channel);
2016 
2017 int p2p_set_listen_channel(struct p2p_data *p2p, u8 reg_class, u8 channel,
2018  u8 forced);
2019 
2020 u8 p2p_get_listen_channel(struct p2p_data *p2p);
2021 
2022 int p2p_set_ssid_postfix(struct p2p_data *p2p, const u8 *postfix, size_t len);
2023 
2024 int p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr,
2025  u8 *iface_addr);
2026 int p2p_get_dev_addr(struct p2p_data *p2p, const u8 *iface_addr,
2027  u8 *dev_addr);
2028 
2029 void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr);
2030 
2036 void p2p_set_cross_connect(struct p2p_data *p2p, int enabled);
2037 
2038 int p2p_get_oper_freq(struct p2p_data *p2p, const u8 *iface_addr);
2039 
2045 void p2p_set_intra_bss_dist(struct p2p_data *p2p, int enabled);
2046 
2047 int p2p_channels_includes_freq(const struct p2p_channels *channels,
2048  unsigned int freq);
2049 
2050 int p2p_channels_to_freqs(const struct p2p_channels *channels,
2051  int *freq_list, unsigned int max_len);
2052 
2059 int p2p_supported_freq(struct p2p_data *p2p, unsigned int freq);
2060 
2067 int p2p_supported_freq_go(struct p2p_data *p2p, unsigned int freq);
2068 
2075 int p2p_supported_freq_cli(struct p2p_data *p2p, unsigned int freq);
2076 
2083 unsigned int p2p_get_pref_freq(struct p2p_data *p2p,
2084  const struct p2p_channels *channels);
2085 
2086 void p2p_update_channel_list(struct p2p_data *p2p,
2087  const struct p2p_channels *chan,
2088  const struct p2p_channels *cli_chan);
2089 
2097 void p2p_set_best_channels(struct p2p_data *p2p, int freq_24, int freq_5,
2098  int freq_overall);
2099 
2109 void p2p_set_own_freq_preference(struct p2p_data *p2p, int freq);
2110 
2111 const u8 * p2p_get_go_neg_peer(struct p2p_data *p2p);
2112 
2118 unsigned int p2p_get_group_num_members(struct p2p_group *group);
2119 
2125 int p2p_client_limit_reached(struct p2p_group *group);
2126 
2134 const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next);
2135 
2143 const u8 * p2p_group_get_client_interface_addr(struct p2p_group *group,
2144  const u8 *dev_addr);
2145 
2153 const u8 * p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr);
2154 
2161 int p2p_group_is_client_connected(struct p2p_group *group, const u8 *dev_addr);
2162 
2168 const struct p2p_group_config * p2p_group_get_config(struct p2p_group *group);
2169 
2178 void p2p_loop_on_all_groups(struct p2p_data *p2p,
2179  int (*group_callback)(struct p2p_group *group,
2180  void *user_data),
2181  void *user_data);
2182 
2190 const struct p2p_peer_info *
2191 p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next);
2192 
2197 void p2p_remove_wps_vendor_extensions(struct p2p_data *p2p);
2198 
2208 int p2p_add_wps_vendor_extension(struct p2p_data *p2p,
2209  const struct wpabuf *vendor_ext);
2210 
2219 int p2p_set_oper_channel(struct p2p_data *p2p, u8 op_reg_class, u8 op_channel,
2220  int cfg_op_channel);
2221 
2229 int p2p_set_pref_chan(struct p2p_data *p2p, unsigned int num_pref_chan,
2230  const struct p2p_channel *pref_chan);
2231 
2238 int p2p_set_no_go_freq(struct p2p_data *p2p,
2239  const struct wpa_freq_range_list *list);
2240 
2247 int p2p_in_progress(struct p2p_data *p2p);
2248 
2249 const char * p2p_wps_method_text(enum p2p_wps_method method);
2250 
2257 void p2p_set_config_timeout(struct p2p_data *p2p, u8 go_timeout,
2258  u8 client_timeout);
2259 
2260 int p2p_set_wfd_ie_beacon(struct p2p_data *p2p, struct wpabuf *ie);
2261 int p2p_set_wfd_ie_probe_req(struct p2p_data *p2p, struct wpabuf *ie);
2262 int p2p_set_wfd_ie_probe_resp(struct p2p_data *p2p, struct wpabuf *ie);
2263 int p2p_set_wfd_ie_assoc_req(struct p2p_data *p2p, struct wpabuf *ie);
2264 int p2p_set_wfd_ie_invitation(struct p2p_data *p2p, struct wpabuf *ie);
2265 int p2p_set_wfd_ie_prov_disc_req(struct p2p_data *p2p, struct wpabuf *ie);
2266 int p2p_set_wfd_ie_prov_disc_resp(struct p2p_data *p2p, struct wpabuf *ie);
2267 int p2p_set_wfd_ie_go_neg(struct p2p_data *p2p, struct wpabuf *ie);
2268 int p2p_set_wfd_dev_info(struct p2p_data *p2p, const struct wpabuf *elem);
2269 int p2p_set_wfd_assoc_bssid(struct p2p_data *p2p, const struct wpabuf *elem);
2270 int p2p_set_wfd_coupled_sink_info(struct p2p_data *p2p,
2271  const struct wpabuf *elem);
2272 struct wpabuf * wifi_display_encaps(struct wpabuf *subelems);
2273 
2292 int p2p_set_disc_int(struct p2p_data *p2p, int min_disc_int, int max_disc_int,
2293  int max_disc_tu);
2294 
2304 const char * p2p_get_state_txt(struct p2p_data *p2p);
2305 
2306 struct wpabuf * p2p_build_nfc_handover_req(struct p2p_data *p2p,
2307  int client_freq,
2308  const u8 *go_dev_addr,
2309  const u8 *ssid, size_t ssid_len);
2310 struct wpabuf * p2p_build_nfc_handover_sel(struct p2p_data *p2p,
2311  int client_freq,
2312  const u8 *go_dev_addr,
2313  const u8 *ssid, size_t ssid_len);
2314 
2316  int sel;
2317  const u8 *wsc_attr;
2318  size_t wsc_len;
2319  const u8 *p2p_attr;
2320  size_t p2p_len;
2321 
2322  enum {
2323  NO_ACTION, JOIN_GROUP, AUTH_JOIN, INIT_GO_NEG, RESP_GO_NEG,
2324  BOTH_GO, PEER_CLIENT
2325  } next_step;
2326  struct p2p_peer_info *peer;
2327  u8 oob_dev_pw[WPS_OOB_PUBKEY_HASH_LEN + 2 +
2328  WPS_OOB_DEVICE_PASSWORD_LEN];
2329  size_t oob_dev_pw_len;
2330  int go_freq;
2331  u8 go_dev_addr[ETH_ALEN];
2332  u8 go_ssid[SSID_MAX_LEN];
2333  size_t go_ssid_len;
2334 };
2335 
2336 int p2p_process_nfc_connection_handover(struct p2p_data *p2p,
2337  struct p2p_nfc_params *params);
2338 
2339 void p2p_set_authorized_oob_dev_pw_id(struct p2p_data *p2p, u16 dev_pw_id,
2340  int go_intent,
2341  const u8 *own_interface_addr);
2342 
2343 int p2p_set_passphrase_len(struct p2p_data *p2p, unsigned int len);
2344 
2345 void p2p_loop_on_known_peers(struct p2p_data *p2p,
2346  void (*peer_callback)(struct p2p_peer_info *peer,
2347  void *user_data),
2348  void *user_data);
2349 
2350 void p2p_set_vendor_elems(struct p2p_data *p2p, struct wpabuf **vendor_elem);
2351 
2352 void p2p_set_intended_addr(struct p2p_data *p2p, const u8 *intended_addr);
2353 
2354 struct p2ps_advertisement *
2355 p2p_service_p2ps_id(struct p2p_data *p2p, u32 adv_id);
2356 int p2p_service_add_asp(struct p2p_data *p2p, int auto_accept, u32 adv_id,
2357  const char *adv_str, u8 svc_state,
2358  u16 config_methods, const char *svc_info,
2359  const u8 *cpt_priority);
2360 int p2p_service_del_asp(struct p2p_data *p2p, u32 adv_id);
2361 void p2p_service_flush_asp(struct p2p_data *p2p);
2362 struct p2ps_advertisement * p2p_get_p2ps_adv_list(struct p2p_data *p2p);
2363 
2371 void p2p_expire_peers(struct p2p_data *p2p);
2372 
2373 void p2p_set_own_pref_freq_list(struct p2p_data *p2p,
2374  const unsigned int *pref_freq_list,
2375  unsigned int size);
2376 
2384 int p2p_group_get_common_freqs(struct p2p_group *group, int *common_freqs,
2385  unsigned int *num);
2386 
2387 struct wpabuf * p2p_build_probe_resp_template(struct p2p_data *p2p,
2388  unsigned int freq);
2389 
2390 #endif /* P2P_H */
Definition: p2p.h:2315
struct wpabuf * p2ps_instance
p2ps_instance - P2PS Application Service Info
Definition: p2p.h:404
size_t channels
channels - Number of channel entries in use
Definition: p2p.h:62
u8 reg_class
reg_class - Regulatory class (IEEE 802.11-2007, Annex J)
Definition: p2p.h:52
int ip_addr_alloc
ip_addr_alloc - Whether IP address allocation within 4-way handshake is supported ...
Definition: p2p.h:1723
u8 channel[P2P_MAX_REG_CLASS_CHANNELS]
channel - Supported channels
Definition: p2p.h:57
unsigned int pref_freq
pref_freq - Preferred operating frequency in MHz or 0.
Definition: p2p.h:238
size_t ssid_len
ssid_len - ssid length in octets
Definition: p2p_i.h:353
u8 hash[P2PS_HASH_LEN]
hash - 6 octet Service Name has to match against incoming Probe Requests
Definition: p2p.h:277
int freq
freq - Frequency of the group operational channel in MHz
Definition: p2p.h:96
int level
level - Signal level
Definition: p2p.h:356
struct p2p_config - P2P configuration
Definition: p2p.h:426
u8 reg_class
reg_class - Regulatory class for own listen channel
Definition: p2p.h:435
unsigned int max_clients
max_clients - Maximum number of clients in the group
Definition: p2p.h:1702
struct p2p_peer_info - P2P peer information
Definition: p2p.h:317
int concurrent_operations
concurrent_operations - Whether concurrent operations are supported
Definition: p2p.h:537
size_t reg_classes
reg_classes - Number of reg_class entries in use
Definition: p2p.h:68
unsigned int passphrase_len
passphrase_len - Passphrase length (8..63)
Definition: p2p.h:576
u8 channel_forced
channel_forced - the listen channel was forced by configuration or by control interface and cannot be...
Definition: p2p.h:446
void * cb_ctx
cb_ctx - Context to use with callback functions
Definition: p2p.h:581
u8 ssid[SSID_MAX_LEN]
ssid - SSID of the group
Definition: p2p.h:109
Definition: config.py:1
size_t ssid_postfix_len
ssid_postfix_len - Length of the ssid_postfix data
Definition: p2p.h:563
int status
status - Negotiation result (Status Code)
Definition: p2p.h:86
Definition: p2p_connect.py:1
Definition: wpabuf.h:20
char * dev_name
dev_name - Device Name
Definition: p2p.h:524
size_t wps_sec_dev_type_list_len
wps_sec_dev_type_list_len - Length of secondary device type list
Definition: p2p.h:384
u16 config_methods
config_methods - WPS Methods which are allowed for this service
Definition: p2p.h:262
size_t ssid_len
ssid_len - Length of SSID in octets
Definition: p2p.h:114
u8 channel
channel - Own listen channel
Definition: p2p.h:440
size_t num_sec_dev_types
num_sec_dev_types - Number of sec_dev_type entries
Definition: p2p.h:514
u8 dev_capab
dev_capab - Device Capabilities
Definition: p2p.h:366
unsigned int max_listen
max_listen - Maximum listen duration in ms
Definition: p2p.h:568
Definition: p2p_stop_find.py:1
Definition: common.h:519
u8 op_channel
op_channel - Own operational channel
Definition: p2p.h:456
struct p2p_config * cfg
cfg - P2P module configuration
Definition: p2p_i.h:181
u32 id
id - P2PS Advertisement ID
Definition: p2p.h:257
u8 auto_accept
auto_accept - Automatically Accept provisioning request if possible.
Definition: p2p.h:272
Definition: p2p.h:167
u8 cfg_op_channel
cfg_op_channel - Whether op_channel is hardcoded in configuration
Definition: p2p.h:461
Definition: p2p.h:415
Definition: os.h:26
struct p2p_channels - List of supported channels
Definition: p2p.h:44
u8 op_reg_class
Regulatory class for own operational channel.
Definition: p2p.h:451
u8 cpt_mask
cpt_mask - Supported Coordination Protocol Transport mask
Definition: p2p.h:219
struct p2p_data - P2P module data (internal to P2P module)
Definition: p2p_i.h:174
Definition: p2p_flush.py:1
struct wpabuf * wfd_subelems
wfd_subelems - Wi-Fi Display subelements from WFD IE(s)
Definition: p2p.h:391
size_t ssid_len
ssid_len - Length of SSID
Definition: p2p.h:1712
int freq
freq - Operating channel of the group
Definition: p2p.h:1717
u32 session_id
session_id - P2PS Session ID
Definition: p2p.h:186
char svc_name[0]
svc_name - NULL Terminated UTF-8 Service Name, and svc_info storage
Definition: p2p.h:299
struct p2p_reg_class - Supported regulatory class
Definition: p2p.h:48
unsigned int force_freq
force_freq - The only allowed channel frequency in MHz or 0.
Definition: p2p.h:233
u8 ssid[SSID_MAX_LEN]
ssid - Selected SSID for GO Negotiation (if local end will be GO)
Definition: p2p_i.h:348
int psk_set
psk_set - Whether PSK field is configured (GO only)
Definition: p2p.h:124
u8 state
state - Current state of the service: 0 - Out Of Service, 1-255 Vendor defined
Definition: p2p.h:267
int persistent_group
persistent_group - Whether the group is persistent 0 = not a persistent group 1 = persistent group wi...
Definition: p2p.h:1692
struct p2p_go_neg_results - P2P Group Owner Negotiation results
Definition: p2p.h:79
char * svc_info
svc_info - Pointer to (internal) Service defined information
Definition: p2p.h:252
struct p2p_group_config - P2P group configuration
Definition: p2p.h:1685
int p2p_intra_bss
p2p_intra_bss - Intra BSS communication is supported
Definition: p2p.h:550
Definition: p2p.h:246
int role_go
role_go - Whether local end is Group Owner
Definition: p2p.h:91
unsigned int peer_config_timeout
peer_config_timeout - Peer configuration timeout (in 10 msec units)
Definition: p2p.h:164
u16 method
method - WPS Method (to be) used to establish session
Definition: p2p.h:191
u16 config_methods
config_methods - WPS Configuration Methods
Definition: p2p.h:361
struct wpabuf * vendor_elems
vendor_elems - Unrecognized vendor elements
Definition: p2p.h:399
u8 conncap
conncap - Connection Capabilities negotiated between P2P peers
Definition: p2p.h:196
u8 role
role - Info about the roles to be used for this connection
Definition: p2p.h:201
int status
status - Remote returned provisioning status code
Definition: p2p.h:176
size_t max_peers
max_peers - Maximum number of discovered peers to remember
Definition: p2p.h:545
Definition: p2p_listen.py:1
struct p2p_group - Internal P2P module per-group data
Definition: p2p_group.c:34
void * cb_ctx
cb_ctx - Context to use with callback functions
Definition: p2p.h:1728
u8 cpt_mask
cpt_mask - supported Coordination Protocol Transport mask
Definition: p2p.h:285
int persistent_group
persistent_group - Whether the group should be made persistent 0 = not persistent 1 = persistent grou...
Definition: p2p.h:159
u8 cpt_priority[P2PS_FEATURE_CAPAB_CPT_MAX+1]
cpt_priority - Coordination Protocol Transport priority list
Definition: p2p.h:294
Definition: p2p_find.py:1
u8 go_intent
go_intent - Local GO Intent to be used during GO Negotiation
Definition: p2p_i.h:338
u8 group_capab
group_capab - Group Capabilities
Definition: p2p.h:371
struct p2p_channel * pref_chan
pref_chan - Preferred channels for GO Negotiation
Definition: p2p.h:494
unsigned int num_pref_chan
num_pref_chan - Number of pref_chan entries
Definition: p2p.h:489
Definition: p2p_invite.py:1
u32 adv_id
adv_id - P2PS Advertisement ID
Definition: p2p.h:181