1 /*
2  * wpa_supplicant - P2P
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_SUPPLICANT_H
10 #define P2P_SUPPLICANT_H
11 
12 enum p2p_wps_method;
13 struct p2p_go_neg_results;
14 enum p2p_send_action_result;
15 struct p2p_peer_info;
16 struct p2p_channels;
17 struct wps_event_fail;
18 struct p2ps_provision;
19 
20 enum wpas_p2p_channel_update_trig {
21 	WPAS_P2P_CHANNEL_UPDATE_ANY,
22 	WPAS_P2P_CHANNEL_UPDATE_DRIVER,
23 	WPAS_P2P_CHANNEL_UPDATE_STATE_CHANGE,
24 	WPAS_P2P_CHANNEL_UPDATE_AVOID,
25 	WPAS_P2P_CHANNEL_UPDATE_DISALLOW,
26 	WPAS_P2P_CHANNEL_UPDATE_CS,
27 };
28 
29 int wpas_p2p_add_p2pdev_interface(struct wpa_supplicant *wpa_s,
30 				  const char *conf_p2p_dev);
31 struct wpa_supplicant * wpas_get_p2p_go_iface(struct wpa_supplicant *wpa_s,
32 					      const u8 *ssid, size_t ssid_len);
33 struct wpa_supplicant * wpas_get_p2p_client_iface(struct wpa_supplicant *wpa_s,
34 						  const u8 *peer_dev_addr);
35 int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
36 		     const char *pin, enum p2p_wps_method wps_method,
37 		     int persistent_group, int auto_join, int join, int auth,
38 		     int go_intent, int freq, unsigned int vht_center_freq2,
39 		     int persistent_id, int pd, int ht40, int vht,
40 		     unsigned int vht_chwidth, int he, int edmg,
41 		     const u8 *group_ssid, size_t group_ssid_len,
42 		     bool allow_6ghz);
43 int wpas_p2p_handle_frequency_conflicts(struct wpa_supplicant *wpa_s,
44                                           int freq, struct wpa_ssid *ssid);
45 int wpas_p2p_group_add(struct wpa_supplicant *wpa_s, int persistent_group,
46 		       int freq, int vht_center_freq2, int ht40, int vht,
47 		       int max_oper_chwidth, int he, int edmg, bool allow_6ghz);
48 int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s,
49 				  struct wpa_ssid *ssid, int addr_allocated,
50 				  int force_freq, int neg_freq,
51 				  int vht_center_freq2, int ht40, int vht,
52 				  int max_oper_chwidth, int he, int edmg,
53 				  const struct p2p_channels *channels,
54 				  int connection_timeout, int force_scan,
55 				  bool allow_6ghz);
56 struct p2p_group * wpas_p2p_group_init(struct wpa_supplicant *wpa_s,
57 				       struct wpa_ssid *ssid);
58 enum wpas_p2p_prov_disc_use {
59 	WPAS_P2P_PD_FOR_GO_NEG,
60 	WPAS_P2P_PD_FOR_JOIN,
61 	WPAS_P2P_PD_AUTO,
62 	WPAS_P2P_PD_FOR_ASP
63 };
64 int wpas_p2p_prov_disc(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
65 		       const char *config_method,
66 		       enum wpas_p2p_prov_disc_use use,
67 		       struct p2ps_provision *p2ps_prov);
68 void wpas_send_action_tx_status(struct wpa_supplicant *wpa_s, const u8 *dst,
69 				const u8 *data, size_t data_len,
70 				enum p2p_send_action_result result);
71 int wpas_p2p_scan_result_text(const u8 *ies, size_t ies_len, char *buf,
72 			      char *end);
73 enum p2p_discovery_type;
74 int wpas_p2p_find(struct wpa_supplicant *wpa_s, unsigned int timeout,
75 		  enum p2p_discovery_type type,
76 		  unsigned int num_req_dev_types, const u8 *req_dev_types,
77 		  const u8 *dev_id, unsigned int search_delay,
78 		  u8 seek_cnt, const char **seek_string, int freq,
79 		  bool include_6ghz);
80 void wpas_p2p_stop_find(struct wpa_supplicant *wpa_s);
81 int wpas_p2p_listen(struct wpa_supplicant *wpa_s, unsigned int timeout);
82 int wpas_p2p_listen_start(struct wpa_supplicant *wpa_s, unsigned int timeout);
83 int wpas_p2p_assoc_req_ie(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
84 			  u8 *buf, size_t len, int p2p_group);
85 void wpas_p2p_scan_ie(struct wpa_supplicant *wpa_s, struct wpabuf *ies);
86 u64 wpas_p2p_sd_request(struct wpa_supplicant *wpa_s, const u8 *dst,
87 			const struct wpabuf *tlvs);
88 u64 wpas_p2p_sd_request_asp(struct wpa_supplicant *wpa_s, const u8 *dst, u8 id,
89 			    const char *svc_str, const char *info_substr);
90 u64 wpas_p2p_sd_request_upnp(struct wpa_supplicant *wpa_s, const u8 *dst,
91 			     u8 version, const char *query);
92 u64 wpas_p2p_sd_request_wifi_display(struct wpa_supplicant *wpa_s,
93 				     const u8 *dst, const char *role);
94 int wpas_p2p_sd_cancel_request(struct wpa_supplicant *wpa_s, u64 req);
95 void wpas_p2p_sd_response(struct wpa_supplicant *wpa_s, int freq,
96 			  const u8 *dst, u8 dialog_token,
97 			  const struct wpabuf *resp_tlvs);
98 void wpas_p2p_sd_service_update(struct wpa_supplicant *wpa_s);
99 void wpas_p2p_service_flush(struct wpa_supplicant *wpa_s);
100 int wpas_p2p_service_add_bonjour(struct wpa_supplicant *wpa_s,
101 				 struct wpabuf *query, struct wpabuf *resp);
102 int wpas_p2p_service_del_bonjour(struct wpa_supplicant *wpa_s,
103 				 const struct wpabuf *query);
104 int wpas_p2p_service_add_upnp(struct wpa_supplicant *wpa_s, u8 version,
105 			      const char *service);
106 int wpas_p2p_service_del_upnp(struct wpa_supplicant *wpa_s, u8 version,
107 			      const char *service);
108 int wpas_p2p_service_add_asp(struct wpa_supplicant *wpa_s, int auto_accept,
109 			     u32 adv_id, const char *adv_str, u8 svc_state,
110 			     u16 config_methods, const char *svc_info,
111 			     const u8 *cpt_priority);
112 int wpas_p2p_service_del_asp(struct wpa_supplicant *wpa_s, u32 adv_id);
113 void wpas_p2p_service_flush_asp(struct wpa_supplicant *wpa_s);
114 int wpas_p2p_service_p2ps_id_exists(struct wpa_supplicant *wpa_s, u32 adv_id);
115 void wpas_sd_request(void *ctx, int freq, const u8 *sa, u8 dialog_token,
116 		     u16 update_indic, const u8 *tlvs, size_t tlvs_len);
117 void wpas_sd_response(void *ctx, const u8 *sa, u16 update_indic,
118 		      const u8 *tlvs, size_t tlvs_len);
119 int wpas_p2p_reject(struct wpa_supplicant *wpa_s, const u8 *addr);
120 int wpas_p2p_invite(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
121 		    struct wpa_ssid *ssid, const u8 *go_dev_addr, int freq,
122 		    int vht_center_freq2, int ht40, int vht, int max_chwidth,
123 		    int pref_freq, int he, int edmg, bool allow_6ghz);
124 int wpas_p2p_invite_group(struct wpa_supplicant *wpa_s, const char *ifname,
125 			  const u8 *peer_addr, const u8 *go_dev_addr,
126 			  bool allow_6ghz);
127 int wpas_p2p_presence_req(struct wpa_supplicant *wpa_s, u32 duration1,
128 			  u32 interval1, u32 duration2, u32 interval2);
129 int wpas_p2p_ext_listen(struct wpa_supplicant *wpa_s, unsigned int period,
130 			unsigned int interval);
131 int wpas_p2p_deauth_notif(struct wpa_supplicant *wpa_s, const u8 *bssid,
132 			  u16 reason_code, const u8 *ie, size_t ie_len,
133 			  int locally_generated);
134 void wpas_p2p_disassoc_notif(struct wpa_supplicant *wpa_s, const u8 *bssid,
135 			     u16 reason_code, const u8 *ie, size_t ie_len,
136 			     int locally_generated);
137 int wpas_p2p_set_noa(struct wpa_supplicant *wpa_s, u8 count, int start,
138 		     int duration);
139 int wpas_p2p_set_cross_connect(struct wpa_supplicant *wpa_s, int enabled);
140 int wpas_p2p_cancel(struct wpa_supplicant *wpa_s);
141 int wpas_p2p_unauthorize(struct wpa_supplicant *wpa_s, const char *addr);
142 int wpas_p2p_disconnect(struct wpa_supplicant *wpa_s);
143 struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s,
144 					  const u8 *addr, const u8 *ssid,
145 					  size_t ssid_len);
146 void wpas_p2p_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
147 				       const u8 *addr);
148 int wpas_p2p_scan_no_go_seen(struct wpa_supplicant *wpa_s);
149 int wpas_p2p_get_sec_channel_offset_40mhz(struct wpa_supplicant *wpa_s,
150 					  struct hostapd_hw_modes *mode,
151 					  u8 channel);
152 int wpas_p2p_get_vht80_center(struct wpa_supplicant *wpa_s,
153 			      struct hostapd_hw_modes *mode, u8 channel,
154 			      u8 op_class);
155 int wpas_p2p_get_vht160_center(struct wpa_supplicant *wpa_s,
156 			       struct hostapd_hw_modes *mode, u8 channel,
157 			       u8 op_class);
158 unsigned int wpas_p2p_search_delay(struct wpa_supplicant *wpa_s);
159 void wpas_p2p_new_psk_cb(struct wpa_supplicant *wpa_s, const u8 *mac_addr,
160 			 const u8 *p2p_dev_addr,
161 			 const u8 *psk, size_t psk_len);
162 void wpas_p2p_remove_client(struct wpa_supplicant *wpa_s, const u8 *peer,
163 			    int iface_addr);
164 struct wpabuf * wpas_p2p_nfc_handover_req(struct wpa_supplicant *wpa_s,
165 					  int ndef);
166 struct wpabuf * wpas_p2p_nfc_handover_sel(struct wpa_supplicant *wpa_s,
167 					  int ndef, int tag);
168 int wpas_p2p_nfc_tag_process(struct wpa_supplicant *wpa_s,
169 			     const struct wpabuf *data, int forced_freq);
170 int wpas_p2p_nfc_report_handover(struct wpa_supplicant *wpa_s, int init,
171 				 const struct wpabuf *req,
172 				 const struct wpabuf *sel, int forced_freq);
173 int wpas_p2p_nfc_tag_enabled(struct wpa_supplicant *wpa_s, int enabled);
174 void wpas_p2p_pbc_overlap_cb(void *eloop_ctx, void *timeout_ctx);
175 int wpas_p2p_try_edmg_channel(struct wpa_supplicant *wpa_s,
176 			      struct p2p_go_neg_results *params);
177 
178 #ifdef CONFIG_P2P
179 
180 int wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s);
181 void wpas_p2p_deinit(struct wpa_supplicant *wpa_s);
182 void wpas_p2p_completed(struct wpa_supplicant *wpa_s);
183 void wpas_p2p_update_config(struct wpa_supplicant *wpa_s);
184 int wpas_p2p_probe_req_rx(struct wpa_supplicant *wpa_s, const u8 *addr,
185 			  const u8 *dst, const u8 *bssid,
186 			  const u8 *ie, size_t ie_len,
187 			  unsigned int rx_freq, int ssi_signal);
188 void wpas_p2p_wps_success(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
189 			  int registrar);
190 
191 void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s,
192 				  enum wpas_p2p_channel_update_trig trig);
193 
194 void wpas_p2p_update_best_channels(struct wpa_supplicant *wpa_s,
195 				   int freq_24, int freq_5, int freq_overall);
196 void wpas_p2p_rx_action(struct wpa_supplicant *wpa_s, const u8 *da,
197 			const u8 *sa, const u8 *bssid,
198 			u8 category, const u8 *data, size_t len, int freq);
199 void wpas_p2p_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
200 				   unsigned int freq, unsigned int duration);
201 void wpas_p2p_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
202 					  unsigned int freq);
203 void wpas_p2p_interface_unavailable(struct wpa_supplicant *wpa_s);
204 void wpas_p2p_notif_connected(struct wpa_supplicant *wpa_s);
205 void wpas_p2p_notif_disconnected(struct wpa_supplicant *wpa_s);
206 int wpas_p2p_notif_pbc_overlap(struct wpa_supplicant *wpa_s);
207 int wpas_p2p_4way_hs_failed(struct wpa_supplicant *wpa_s);
208 void wpas_p2p_ap_setup_failed(struct wpa_supplicant *wpa_s);
209 void wpas_p2p_indicate_state_change(struct wpa_supplicant *wpa_s);
210 void wpas_p2p_deinit_iface(struct wpa_supplicant *wpa_s);
211 void wpas_p2p_ap_deinit(struct wpa_supplicant *wpa_s);
212 void wpas_p2p_network_removed(struct wpa_supplicant *wpa_s,
213 			      struct wpa_ssid *ssid);
214 int wpas_p2p_in_progress(struct wpa_supplicant *wpa_s);
215 int wpas_p2p_wps_eapol_cb(struct wpa_supplicant *wpa_s);
216 void wpas_p2p_wps_failed(struct wpa_supplicant *wpa_s,
217 			 struct wps_event_fail *fail);
218 int wpas_p2p_group_remove(struct wpa_supplicant *wpa_s, const char *ifname);
219 int wpas_p2p_lo_start(struct wpa_supplicant *wpa_s, unsigned int freq,
220 		      unsigned int period, unsigned int interval,
221 		      unsigned int count);
222 int wpas_p2p_lo_stop(struct wpa_supplicant *wpa_s);
223 int wpas_p2p_mac_setup(struct wpa_supplicant *wpa_s);
224 
225 #else /* CONFIG_P2P */
226 
227 static inline int
wpas_p2p_init(struct wpa_global * global,struct wpa_supplicant * wpa_s)228 wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s)
229 {
230 	return 0;
231 }
232 
wpas_p2p_deinit(struct wpa_supplicant * wpa_s)233 static inline void wpas_p2p_deinit(struct wpa_supplicant *wpa_s)
234 {
235 }
236 
wpas_p2p_completed(struct wpa_supplicant * wpa_s)237 static inline void wpas_p2p_completed(struct wpa_supplicant *wpa_s)
238 {
239 }
240 
wpas_p2p_update_config(struct wpa_supplicant * wpa_s)241 static inline void wpas_p2p_update_config(struct wpa_supplicant *wpa_s)
242 {
243 }
244 
wpas_p2p_probe_req_rx(struct wpa_supplicant * wpa_s,const u8 * addr,const u8 * dst,const u8 * bssid,const u8 * ie,size_t ie_len,unsigned int rx_freq,int ssi_signal)245 static inline int wpas_p2p_probe_req_rx(struct wpa_supplicant *wpa_s,
246 					const u8 *addr,
247 					const u8 *dst, const u8 *bssid,
248 					const u8 *ie, size_t ie_len,
249 					unsigned int rx_freq, int ssi_signal)
250 {
251 	return 0;
252 }
253 
wpas_p2p_wps_success(struct wpa_supplicant * wpa_s,const u8 * peer_addr,int registrar)254 static inline void wpas_p2p_wps_success(struct wpa_supplicant *wpa_s,
255 					const u8 *peer_addr, int registrar)
256 {
257 }
258 
259 static inline void
wpas_p2p_update_channel_list(struct wpa_supplicant * wpa_s,enum wpas_p2p_channel_update_trig trig)260 wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s,
261 			     enum wpas_p2p_channel_update_trig trig)
262 {
263 }
264 
wpas_p2p_update_best_channels(struct wpa_supplicant * wpa_s,int freq_24,int freq_5,int freq_overall)265 static inline void wpas_p2p_update_best_channels(struct wpa_supplicant *wpa_s,
266 						 int freq_24, int freq_5,
267 						 int freq_overall)
268 {
269 }
270 
wpas_p2p_rx_action(struct wpa_supplicant * wpa_s,const u8 * da,const u8 * sa,const u8 * bssid,u8 category,const u8 * data,size_t len,int freq)271 static inline void wpas_p2p_rx_action(struct wpa_supplicant *wpa_s,
272 				      const u8 *da,
273 				      const u8 *sa, const u8 *bssid,
274 				      u8 category, const u8 *data, size_t len,
275 				      int freq)
276 {
277 }
278 
wpas_p2p_remain_on_channel_cb(struct wpa_supplicant * wpa_s,unsigned int freq,unsigned int duration)279 static inline void wpas_p2p_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
280 						 unsigned int freq,
281 						 unsigned int duration)
282 {
283 }
284 
285 static inline void
wpas_p2p_cancel_remain_on_channel_cb(struct wpa_supplicant * wpa_s,unsigned int freq)286 wpas_p2p_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
287 				     unsigned int freq)
288 {
289 }
290 
wpas_p2p_interface_unavailable(struct wpa_supplicant * wpa_s)291 static inline void wpas_p2p_interface_unavailable(struct wpa_supplicant *wpa_s)
292 {
293 }
294 
wpas_p2p_notif_connected(struct wpa_supplicant * wpa_s)295 static inline void wpas_p2p_notif_connected(struct wpa_supplicant *wpa_s)
296 {
297 }
298 
wpas_p2p_notif_disconnected(struct wpa_supplicant * wpa_s)299 static inline void wpas_p2p_notif_disconnected(struct wpa_supplicant *wpa_s)
300 {
301 }
302 
wpas_p2p_notif_pbc_overlap(struct wpa_supplicant * wpa_s)303 static inline int wpas_p2p_notif_pbc_overlap(struct wpa_supplicant *wpa_s)
304 {
305 	return 0;
306 }
307 
wpas_p2p_4way_hs_failed(struct wpa_supplicant * wpa_s)308 static inline int wpas_p2p_4way_hs_failed(struct wpa_supplicant *wpa_s)
309 {
310 	return 0;
311 }
312 
wpas_p2p_ap_setup_failed(struct wpa_supplicant * wpa_s)313 static inline void wpas_p2p_ap_setup_failed(struct wpa_supplicant *wpa_s)
314 {
315 }
316 
wpas_p2p_indicate_state_change(struct wpa_supplicant * wpa_s)317 static inline void wpas_p2p_indicate_state_change(struct wpa_supplicant *wpa_s)
318 {
319 }
320 
wpas_p2p_deinit_iface(struct wpa_supplicant * wpa_s)321 static inline void wpas_p2p_deinit_iface(struct wpa_supplicant *wpa_s)
322 {
323 }
324 
wpas_p2p_ap_deinit(struct wpa_supplicant * wpa_s)325 static inline void wpas_p2p_ap_deinit(struct wpa_supplicant *wpa_s)
326 {
327 }
328 
wpas_p2p_network_removed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)329 static inline void wpas_p2p_network_removed(struct wpa_supplicant *wpa_s,
330 					    struct wpa_ssid *ssid)
331 {
332 }
333 
wpas_p2p_in_progress(struct wpa_supplicant * wpa_s)334 static inline int wpas_p2p_in_progress(struct wpa_supplicant *wpa_s)
335 {
336 	return 0;
337 }
338 
wpas_p2p_wps_eapol_cb(struct wpa_supplicant * wpa_s)339 static inline int wpas_p2p_wps_eapol_cb(struct wpa_supplicant *wpa_s)
340 {
341 	return 0;
342 }
343 
wpas_p2p_wps_failed(struct wpa_supplicant * wpa_s,struct wps_event_fail * fail)344 static inline void wpas_p2p_wps_failed(struct wpa_supplicant *wpa_s,
345 				       struct wps_event_fail *fail)
346 {
347 }
348 
wpas_p2p_group_remove(struct wpa_supplicant * wpa_s,const char * ifname)349 static inline int wpas_p2p_group_remove(struct wpa_supplicant *wpa_s,
350 					const char *ifname)
351 {
352 	return 0;
353 }
354 
355 #endif /* CONFIG_P2P */
356 
357 #endif /* P2P_SUPPLICANT_H */
358