wpa_supplicant / hostapd
2.5
|
Wi-Fi Direct - P2P module. More...
#include "includes.h"
#include "common.h"
#include "eloop.h"
#include "common/ieee802_11_defs.h"
#include "common/ieee802_11_common.h"
#include "common/wpa_ctrl.h"
#include "crypto/sha256.h"
#include "crypto/crypto.h"
#include "wps/wps_i.h"
#include "p2p_i.h"
#include "p2p.h"
Macros | |
#define | P2P_SCAN_TIMEOUT 35 |
#define | P2P_PEER_EXPIRATION_AGE 60 |
Number of seconds after which inactive peer entries will be removed. | |
Functions | |
void | p2p_expire_peers (struct p2p_data *p2p) |
Periodic cleanup function to expire peers. More... | |
const char * | p2p_get_state_txt (struct p2p_data *p2p) |
Get current P2P state for debug purposes. More... | |
struct p2ps_advertisement * | p2p_get_p2ps_adv_list (struct p2p_data *p2p) |
void | p2p_set_intended_addr (struct p2p_data *p2p, const u8 *intended_addr) |
u16 | p2p_get_provisioning_info (struct p2p_data *p2p, const u8 *addr) |
Get any stored provisioning info. More... | |
void | p2p_clear_provisioning_info (struct p2p_data *p2p, const u8 *addr) |
Clear any stored provisioning info. More... | |
void | p2p_set_state (struct p2p_data *p2p, int new_state) |
void | p2p_set_timeout (struct p2p_data *p2p, unsigned int sec, unsigned int usec) |
void | p2p_clear_timeout (struct p2p_data *p2p) |
void | p2p_go_neg_failed (struct p2p_data *p2p, int status) |
int | p2p_listen (struct p2p_data *p2p, unsigned int timeout) |
Start P2P Listen state for specified duration. More... | |
struct p2p_device * | p2p_get_device (struct p2p_data *p2p, const u8 *addr) |
Fetch a peer entry. More... | |
struct p2p_device * | p2p_get_device_interface (struct p2p_data *p2p, const u8 *addr) |
Fetch a peer entry based on P2P Interface Address. More... | |
int | p2p_add_device (struct p2p_data *p2p, const u8 *addr, int freq, struct os_reltime *rx_time, int level, const u8 *ies, size_t ies_len, int scan_res) |
Add peer entries based on scan results or P2P frames. More... | |
void | p2p_notify_scan_trigger_status (struct p2p_data *p2p, int status) |
Indicate scan trigger status. More... | |
int | p2p_find (struct p2p_data *p2p, unsigned int timeout, enum p2p_discovery_type type, unsigned int num_req_dev_types, const u8 *req_dev_types, const u8 *dev_id, unsigned int search_delay, u8 seek_count, const char **seek, int freq) |
Start P2P Find (Device Discovery) More... | |
void | p2p_stop_find_for_freq (struct p2p_data *p2p, int freq) |
Stop P2P Find for next oper on specific freq. More... | |
void | p2p_stop_listen_for_freq (struct p2p_data *p2p, int freq) |
void | p2p_stop_listen (struct p2p_data *p2p) |
Stop P2P Listen. More... | |
void | p2p_stop_find (struct p2p_data *p2p) |
Stop P2P Find (Device Discovery) More... | |
int | p2p_prepare_channel (struct p2p_data *p2p, struct p2p_device *dev, unsigned int force_freq, unsigned int pref_freq, int go) |
Select operating channel for GO Negotiation. More... | |
int | p2p_connect (struct p2p_data *p2p, const u8 *peer_addr, enum p2p_wps_method wps_method, int go_intent, const u8 *own_interface_addr, unsigned int force_freq, int persistent_group, const u8 *force_ssid, size_t force_ssid_len, int pd_before_go_neg, unsigned int pref_freq, u16 oob_pw_id) |
Start P2P group formation (GO negotiation) More... | |
int | p2p_authorize (struct p2p_data *p2p, const u8 *peer_addr, enum p2p_wps_method wps_method, int go_intent, const u8 *own_interface_addr, unsigned int force_freq, int persistent_group, const u8 *force_ssid, size_t force_ssid_len, unsigned int pref_freq, u16 oob_pw_id) |
Authorize P2P group formation (GO negotiation) More... | |
void | p2p_add_dev_info (struct p2p_data *p2p, const u8 *addr, struct p2p_device *dev, struct p2p_message *msg) |
void | p2p_build_ssid (struct p2p_data *p2p, u8 *ssid, size_t *ssid_len) |
int | p2p_go_params (struct p2p_data *p2p, struct p2p_go_neg_results *params) |
Generate random P2P group parameters. More... | |
void | p2p_go_complete (struct p2p_data *p2p, struct p2p_device *peer) |
void | p2p_rx_action (struct p2p_data *p2p, const u8 *da, const u8 *sa, const u8 *bssid, u8 category, const u8 *data, size_t len, int freq) |
Report received Action frame. More... | |
struct p2p_device * | p2p_add_dev_from_go_neg_req (struct p2p_data *p2p, const u8 *addr, struct p2p_message *msg) |
int | dev_type_list_match (const u8 *dev_type, const u8 *req_dev_type[], size_t num_req_dev_type) |
int | p2p_match_dev_type (struct p2p_data *p2p, struct wpabuf *wps) |
Match local device type with requested type. More... | |
struct wpabuf * | p2p_build_probe_resp_ies (struct p2p_data *p2p, const u8 *query_hash, u8 query_count) |
enum p2p_probe_req_status | p2p_probe_req_rx (struct p2p_data *p2p, const u8 *addr, const u8 *dst, const u8 *bssid, const u8 *ie, size_t ie_len, unsigned int rx_freq) |
Report reception of a Probe Request frame. More... | |
int | p2p_assoc_req_ie (struct p2p_data *p2p, const u8 *bssid, u8 *buf, size_t len, int p2p_group, struct wpabuf *p2p_ie) |
Build P2P IE for (Re)Association Request frame. More... | |
int | p2p_scan_result_text (const u8 *ies, size_t ies_len, char *buf, char *end) |
Build text format description of P2P IE. More... | |
struct p2ps_advertisement * | p2p_service_p2ps_id (struct p2p_data *p2p, u32 adv_id) |
int | p2p_service_del_asp (struct p2p_data *p2p, u32 adv_id) |
int | p2p_service_add_asp (struct p2p_data *p2p, int auto_accept, u32 adv_id, const char *adv_str, u8 svc_state, u16 config_methods, const char *svc_info, const u8 *cpt_priority) |
void | p2p_service_flush_asp (struct p2p_data *p2p) |
int | p2p_parse_dev_addr_in_p2p_ie (struct wpabuf *p2p_ie, u8 *dev_addr) |
Parse P2P Device Address from a concatenated P2P IE. More... | |
int | p2p_parse_dev_addr (const u8 *ies, size_t ies_len, u8 *dev_addr) |
Parse P2P Device Address from P2P IE(s) More... | |
void | p2p_wps_success_cb (struct p2p_data *p2p, const u8 *mac_addr) |
Report successfully completed WPS provisioning. More... | |
void | p2p_group_formation_failed (struct p2p_data *p2p) |
Report failed WPS provisioning. More... | |
struct p2p_data * | p2p_init (const struct p2p_config *cfg) |
Initialize P2P module. More... | |
void | p2p_deinit (struct p2p_data *p2p) |
Deinitialize P2P module. More... | |
void | p2p_flush (struct p2p_data *p2p) |
Flush P2P module state. More... | |
int | p2p_unauthorize (struct p2p_data *p2p, const u8 *addr) |
Unauthorize the specified peer device. More... | |
int | p2p_set_dev_name (struct p2p_data *p2p, const char *dev_name) |
Set device name. More... | |
int | p2p_set_manufacturer (struct p2p_data *p2p, const char *manufacturer) |
int | p2p_set_model_name (struct p2p_data *p2p, const char *model_name) |
int | p2p_set_model_number (struct p2p_data *p2p, const char *model_number) |
int | p2p_set_serial_number (struct p2p_data *p2p, const char *serial_number) |
void | p2p_set_config_methods (struct p2p_data *p2p, u16 config_methods) |
void | p2p_set_uuid (struct p2p_data *p2p, const u8 *uuid) |
int | p2p_set_pri_dev_type (struct p2p_data *p2p, const u8 *pri_dev_type) |
Set primary device type. More... | |
int | p2p_set_sec_dev_types (struct p2p_data *p2p, const u8 dev_types[][8], size_t num_dev_types) |
Set secondary device types. More... | |
void | p2p_remove_wps_vendor_extensions (struct p2p_data *p2p) |
Remove WPS vendor extensions. More... | |
int | p2p_add_wps_vendor_extension (struct p2p_data *p2p, const struct wpabuf *vendor_ext) |
Add a WPS vendor extension. More... | |
int | p2p_set_country (struct p2p_data *p2p, const char *country) |
void | p2p_continue_find (struct p2p_data *p2p) |
int | p2p_scan_res_handler (struct p2p_data *p2p, const u8 *bssid, int freq, struct os_reltime *rx_time, int level, const u8 *ies, size_t ies_len) |
Indicate a P2P scan results. More... | |
void | p2p_scan_res_handled (struct p2p_data *p2p) |
Indicate end of scan results. More... | |
void | p2p_scan_ie (struct p2p_data *p2p, struct wpabuf *ies, const u8 *dev_id) |
Build P2P IE for Probe Request. More... | |
size_t | p2p_scan_ie_buf_len (struct p2p_data *p2p) |
Get maximum buffer length needed for p2p_scan_ie. More... | |
int | p2p_ie_text (struct wpabuf *p2p_ie, char *buf, char *end) |
Build text format description of P2P IE. More... | |
void | p2p_send_action_cb (struct p2p_data *p2p, unsigned int freq, const u8 *dst, const u8 *src, const u8 *bssid, enum p2p_send_action_result result) |
Notify TX status of an Action frame. More... | |
void | p2p_listen_cb (struct p2p_data *p2p, unsigned int freq, unsigned int duration) |
Indicate the start of a requested Listen state. More... | |
int | p2p_listen_end (struct p2p_data *p2p, unsigned int freq) |
Indicate the end of a requested Listen state. More... | |
int | p2p_reject (struct p2p_data *p2p, const u8 *peer_addr) |
Reject peer device (explicitly block connection attempts) More... | |
const char * | p2p_wps_method_text (enum p2p_wps_method method) |
const struct p2p_peer_info * | p2p_get_peer_info (struct p2p_data *p2p, const u8 *addr, int next) |
Get P2P peer information. More... | |
int | p2p_get_peer_info_txt (const struct p2p_peer_info *info, char *buf, size_t buflen) |
Get internal P2P peer information in text format. More... | |
int | p2p_peer_known (struct p2p_data *p2p, const u8 *addr) |
Check whether P2P peer is known. More... | |
void | p2p_set_client_discoverability (struct p2p_data *p2p, int enabled) |
Set client discoverability capability. More... | |
int | p2p_presence_req (struct p2p_data *p2p, const u8 *go_interface_addr, const u8 *own_interface_addr, unsigned int freq, u32 duration1, u32 interval1, u32 duration2, u32 interval2) |
Request GO presence. More... | |
int | p2p_ext_listen (struct p2p_data *p2p, unsigned int period, unsigned int interval) |
Set Extended Listen Timing. More... | |
void | p2p_deauth_notif (struct p2p_data *p2p, const u8 *bssid, u16 reason_code, const u8 *ie, size_t ie_len) |
void | p2p_disassoc_notif (struct p2p_data *p2p, const u8 *bssid, u16 reason_code, const u8 *ie, size_t ie_len) |
void | p2p_set_managed_oper (struct p2p_data *p2p, int enabled) |
Set managed P2P Device operations capability. More... | |
int | p2p_config_get_random_social (struct p2p_config *p2p, u8 *op_class, u8 *op_channel) |
Return a random social channel. More... | |
int | p2p_set_listen_channel (struct p2p_data *p2p, u8 reg_class, u8 channel, u8 forced) |
u8 | p2p_get_listen_channel (struct p2p_data *p2p) |
int | p2p_set_ssid_postfix (struct p2p_data *p2p, const u8 *postfix, size_t len) |
int | p2p_set_oper_channel (struct p2p_data *p2p, u8 op_reg_class, u8 op_channel, int cfg_op_channel) |
Set the P2P operating channel. More... | |
int | p2p_set_pref_chan (struct p2p_data *p2p, unsigned int num_pref_chan, const struct p2p_channel *pref_chan) |
Set P2P preferred channel list. More... | |
int | p2p_set_no_go_freq (struct p2p_data *p2p, const struct wpa_freq_range_list *list) |
Set no GO channel ranges. More... | |
int | p2p_get_interface_addr (struct p2p_data *p2p, const u8 *dev_addr, u8 *iface_addr) |
int | p2p_get_dev_addr (struct p2p_data *p2p, const u8 *iface_addr, u8 *dev_addr) |
void | p2p_set_peer_filter (struct p2p_data *p2p, const u8 *addr) |
void | p2p_set_cross_connect (struct p2p_data *p2p, int enabled) |
Set cross connection capability. More... | |
int | p2p_get_oper_freq (struct p2p_data *p2p, const u8 *iface_addr) |
void | p2p_set_intra_bss_dist (struct p2p_data *p2p, int enabled) |
Set intra BSS distribution. More... | |
void | p2p_update_channel_list (struct p2p_data *p2p, const struct p2p_channels *chan, const struct p2p_channels *cli_chan) |
int | p2p_send_action (struct p2p_data *p2p, unsigned int freq, const u8 *dst, const u8 *src, const u8 *bssid, const u8 *buf, size_t len, unsigned int wait_time) |
void | p2p_set_best_channels (struct p2p_data *p2p, int freq_24, int freq_5, int freq_overall) |
Update best channel information. More... | |
void | p2p_set_own_freq_preference (struct p2p_data *p2p, int freq) |
Set own preference for channel. More... | |
const u8 * | p2p_get_go_neg_peer (struct p2p_data *p2p) |
const struct p2p_peer_info * | p2p_get_peer_found (struct p2p_data *p2p, const u8 *addr, int next) |
Get P2P peer info structure of a found peer. More... | |
int | p2p_in_progress (struct p2p_data *p2p) |
Check whether a P2P operation is progress. More... | |
void | p2p_set_config_timeout (struct p2p_data *p2p, u8 go_timeout, u8 client_timeout) |
Set local config timeouts. More... | |
int | p2p_set_disc_int (struct p2p_data *p2p, int min_disc_int, int max_disc_int, int max_disc_tu) |
Set min/max discoverable interval for p2p_find. More... | |
void | p2p_dbg (struct p2p_data *p2p, const char *fmt,...) |
void | p2p_info (struct p2p_data *p2p, const char *fmt,...) |
void | p2p_err (struct p2p_data *p2p, const char *fmt,...) |
void | p2p_loop_on_known_peers (struct p2p_data *p2p, void(*peer_callback)(struct p2p_peer_info *peer, void *user_data), void *user_data) |
int | p2p_set_passphrase_len (struct p2p_data *p2p, unsigned int len) |
void | p2p_set_vendor_elems (struct p2p_data *p2p, struct wpabuf **vendor_elem) |
void | p2p_go_neg_wait_timeout (void *eloop_ctx, void *timeout_ctx) |
void | p2p_set_own_pref_freq_list (struct p2p_data *p2p, const unsigned int *pref_freq_list, unsigned int size) |
Wi-Fi Direct - P2P module.
int p2p_add_device | ( | struct p2p_data * | p2p, |
const u8 * | addr, | ||
int | freq, | ||
struct os_reltime * | rx_time, | ||
int | level, | ||
const u8 * | ies, | ||
size_t | ies_len, | ||
int | scan_res | ||
) |
Add peer entries based on scan results or P2P frames.
p2p | P2P module context from p2p_init() |
addr | Source address of Beacon or Probe Response frame (may be either P2P Device Address or P2P Interface Address) |
level | Signal level (signal strength of the received frame from the peer) |
freq | Frequency on which the Beacon or Probe Response frame was received |
rx_time | Time when the result was received |
ies | IEs from the Beacon or Probe Response frame |
ies_len | Length of ies buffer in octets |
scan_res | Whether this was based on scan results |
If the scan result is for a GO, the clients in the group will also be added to the peer table. This function can also be used with some other frames like Provision Discovery Request that contains P2P Capability and P2P Device Info attributes.
Add a WPS vendor extension.
p2p | P2P module context from p2p_init() |
vendor_ext | The vendor extensions to add |
The wpabuf structures in the array are owned by the P2P module after this call.
int p2p_assoc_req_ie | ( | struct p2p_data * | p2p, |
const u8 * | bssid, | ||
u8 * | buf, | ||
size_t | len, | ||
int | p2p_group, | ||
struct wpabuf * | p2p_ie | ||
) |
Build P2P IE for (Re)Association Request frame.
p2p | P2P module context from p2p_init() |
bssid | BSSID |
buf | Buffer for writing the P2P IE |
len | Maximum buf length in octets |
p2p_group | Whether this is for association with a P2P GO |
p2p_ie | Reassembled P2P IE data from scan results or NULL if none |
int p2p_authorize | ( | struct p2p_data * | p2p, |
const u8 * | peer_addr, | ||
enum p2p_wps_method | wps_method, | ||
int | go_intent, | ||
const u8 * | own_interface_addr, | ||
unsigned int | force_freq, | ||
int | persistent_group, | ||
const u8 * | force_ssid, | ||
size_t | force_ssid_len, | ||
unsigned int | pref_freq, | ||
u16 | oob_pw_id | ||
) |
Authorize P2P group formation (GO negotiation)
p2p | P2P module context from p2p_init() |
peer_addr | MAC address of the peer P2P client |
wps_method | WPS method to be used in provisioning |
go_intent | Local GO intent value (1..15) |
own_interface_addr | Intended interface address to use with the group |
force_freq | The only allowed channel frequency in MHz or 0 |
persistent_group | Whether to create a persistent group (0 = no, 1 = persistent group without persistent reconnect, 2 = persistent group with persistent reconnect) |
force_ssid | Forced SSID for the group if we become GO or NULL to generate a new SSID |
force_ssid_len | Length of $force_ssid buffer |
pref_freq | Preferred operating frequency in MHz or 0 (this is only used if force_freq == 0) |
This is like p2p_connect(), but the actual group negotiation is not initiated automatically, i.e., the other end is expected to do that.
void p2p_clear_provisioning_info | ( | struct p2p_data * | p2p, |
const u8 * | addr | ||
) |
Clear any stored provisioning info.
p2p | P2P module context from p2p_init() |
iface_addr | Peer P2P Device Address |
This function is used to clear stored WPS provisioning info for the given peer.
int p2p_config_get_random_social | ( | struct p2p_config * | p2p, |
u8 * | op_class, | ||
u8 * | op_channel | ||
) |
Return a random social channel.
p2p | P2P config |
op_class | Selected operating class |
op_channel | Selected social channel |
This function is used before p2p_init is called. A random social channel from supports bands 2.4 GHz (channels 1,6,11) and 60 GHz (channel 2) is returned on success.
int p2p_connect | ( | struct p2p_data * | p2p, |
const u8 * | peer_addr, | ||
enum p2p_wps_method | wps_method, | ||
int | go_intent, | ||
const u8 * | own_interface_addr, | ||
unsigned int | force_freq, | ||
int | persistent_group, | ||
const u8 * | force_ssid, | ||
size_t | force_ssid_len, | ||
int | pd_before_go_neg, | ||
unsigned int | pref_freq, | ||
u16 | oob_pw_id | ||
) |
Start P2P group formation (GO negotiation)
p2p | P2P module context from p2p_init() |
peer_addr | MAC address of the peer P2P client |
wps_method | WPS method to be used in provisioning |
go_intent | Local GO intent value (1..15) |
own_interface_addr | Intended interface address to use with the group |
force_freq | The only allowed channel frequency in MHz or 0 |
persistent_group | Whether to create a persistent group (0 = no, 1 = persistent group without persistent reconnect, 2 = persistent group with persistent reconnect) |
force_ssid | Forced SSID for the group if we become GO or NULL to generate a new SSID |
force_ssid_len | Length of $force_ssid buffer |
pd_before_go_neg | Whether to send Provision Discovery prior to GO Negotiation as an interoperability workaround when initiating group formation |
pref_freq | Preferred operating frequency in MHz or 0 (this is only used if force_freq == 0) |
void p2p_deinit | ( | struct p2p_data * | p2p | ) |
Deinitialize P2P module.
p2p | P2P module context from p2p_init() |
void p2p_expire_peers | ( | struct p2p_data * | p2p | ) |
Periodic cleanup function to expire peers.
p2p | P2P module context from p2p_init() |
This is a cleanup function that the entity calling p2p_init() is expected to call periodically to clean up expired peer entries.
int p2p_ext_listen | ( | struct p2p_data * | p2p, |
unsigned int | period, | ||
unsigned int | interval | ||
) |
Set Extended Listen Timing.
p2p | P2P module context from p2p_init() |
freq | Group operating frequence (in MHz) |
period | Availability period in milliseconds (1-65535; 0 to disable) |
interval | Availability interval in milliseconds (1-65535; 0 to disable) |
This function can be used to enable or disable (period = interval = 0) Extended Listen Timing. When enabled, the P2P Device will become discoverable (go into Listen State) every interval milliseconds for at least period milliseconds.
int p2p_find | ( | struct p2p_data * | p2p, |
unsigned int | timeout, | ||
enum p2p_discovery_type | type, | ||
unsigned int | num_req_dev_types, | ||
const u8 * | req_dev_types, | ||
const u8 * | dev_id, | ||
unsigned int | search_delay, | ||
u8 | seek_count, | ||
const char ** | seek_string, | ||
int | freq | ||
) |
Start P2P Find (Device Discovery)
p2p | P2P module context from p2p_init() |
timeout | Timeout for find operation in seconds or 0 for no timeout |
type | Device Discovery type |
num_req_dev_types | Number of requested device types |
req_dev_types | Requested device types array, must be an array containing num_req_dev_types * WPS_DEV_TYPE_LEN bytes; NULL if no requested device types. |
dev_id | Device ID to search for or NULL to find all devices |
search_delay | Extra delay in milliseconds between search iterations |
seek_count | Number of ASP Service Strings in the seek_string array |
seek_string | ASP Service Strings to query for in Probe Requests |
freq | Requested first scan frequency (in MHz) to modify type == P2P_FIND_START_WITH_FULL behavior. 0 = Use normal full scan. If p2p_find is already in progress, this parameter is ignored and full scan will be executed. |
void p2p_flush | ( | struct p2p_data * | p2p | ) |
Flush P2P module state.
p2p | P2P module context from p2p_init() |
This command removes the P2P module state like peer device entries.
struct p2p_device* p2p_get_device | ( | struct p2p_data * | p2p, |
const u8 * | addr | ||
) |
Fetch a peer entry.
p2p | P2P module context from p2p_init() |
addr | P2P Device Address of the peer |
struct p2p_device* p2p_get_device_interface | ( | struct p2p_data * | p2p, |
const u8 * | addr | ||
) |
Fetch a peer entry based on P2P Interface Address.
p2p | P2P module context from p2p_init() |
addr | P2P Interface Address of the peer |
const struct p2p_peer_info* p2p_get_peer_found | ( | struct p2p_data * | p2p, |
const u8 * | addr, | ||
int | next | ||
) |
Get P2P peer info structure of a found peer.
p2p | P2P module context from p2p_init() |
addr | P2P Device Address of the peer or NULL to indicate the first peer |
next | Whether to select the peer entry following the one indicated by addr |
const struct p2p_peer_info* p2p_get_peer_info | ( | struct p2p_data * | p2p, |
const u8 * | addr, | ||
int | next | ||
) |
Get P2P peer information.
p2p | P2P module context from p2p_init() |
addr | P2P Device Address of the peer or NULL to indicate the first peer |
next | Whether to select the peer entry following the one indicated by addr |
int p2p_get_peer_info_txt | ( | const struct p2p_peer_info * | info, |
char * | buf, | ||
size_t | buflen | ||
) |
Get internal P2P peer information in text format.
info | Pointer to P2P peer info from p2p_get_peer_info() |
buf | Buffer for returning text |
buflen | Maximum buffer length |
Note: This information is internal to the P2P module and subject to change. As such, this should not really be used by external programs for purposes other than debugging.
u16 p2p_get_provisioning_info | ( | struct p2p_data * | p2p, |
const u8 * | addr | ||
) |
Get any stored provisioning info.
p2p | P2P module context from p2p_init() |
addr | Peer P2P Device Address |
This function is used to retrieve stored WPS provisioning info for the given peer.
const char* p2p_get_state_txt | ( | struct p2p_data * | p2p | ) |
Get current P2P state for debug purposes.
p2p | P2P module context from p2p_init() |
It should be noted that the P2P module state names are internal information and subject to change at any point, i.e., this information should be used mainly for debugging purposes.
int p2p_go_params | ( | struct p2p_data * | p2p, |
struct p2p_go_neg_results * | params | ||
) |
Generate random P2P group parameters.
p2p | P2P module context from p2p_init() |
params | Buffer for parameters |
void p2p_group_formation_failed | ( | struct p2p_data * | p2p | ) |
Report failed WPS provisioning.
p2p | P2P module context from p2p_init() |
This function is used to report failed group formation. This can happen either due to failed WPS provisioning or due to 15 second timeout during the provisioning phase.
int p2p_ie_text | ( | struct wpabuf * | p2p_ie, |
char * | buf, | ||
char * | end | ||
) |
Build text format description of P2P IE.
p2p_ie | P2P IE |
buf | Buffer for returning text |
end | Pointer to the end of the buf area |
This function can be used to parse P2P IE contents into text format field=value lines.
int p2p_in_progress | ( | struct p2p_data * | p2p | ) |
Check whether a P2P operation is progress.
p2p | P2P module context from p2p_init() |
struct p2p_data* p2p_init | ( | const struct p2p_config * | cfg | ) |
Initialize P2P module.
cfg | P2P module configuration |
This function is used to initialize global P2P module context (one per device). The P2P module will keep a copy of the configuration data, so the caller does not need to maintain this structure. However, the callback functions and the context parameters to them must be kept available until the P2P module is deinitialized with p2p_deinit().
int p2p_listen | ( | struct p2p_data * | p2p, |
unsigned int | timeout | ||
) |
Start P2P Listen state for specified duration.
p2p | P2P module context from p2p_init() |
timeout | Listen state duration in milliseconds |
This function can be used to request the P2P module to keep the device discoverable on the listen channel for an extended set of time. At least in its current form, this is mainly used for testing purposes and may not be of much use for normal P2P operations.
void p2p_listen_cb | ( | struct p2p_data * | p2p, |
unsigned int | freq, | ||
unsigned int | duration | ||
) |
Indicate the start of a requested Listen state.
p2p | P2P module context from p2p_init() |
freq | Listen channel frequency in MHz |
duration | Duration for the Listen state in milliseconds |
This function is used to indicate that a Listen state requested with struct p2p_config::start_listen() callback has started.
int p2p_listen_end | ( | struct p2p_data * | p2p, |
unsigned int | freq | ||
) |
Indicate the end of a requested Listen state.
p2p | P2P module context from p2p_init() |
freq | Listen channel frequency in MHz |
This function is used to indicate that a Listen state requested with struct p2p_config::start_listen() callback has ended.
Match local device type with requested type.
p2p | P2P module context from p2p_init() |
wps | WPS TLVs from Probe Request frame (concatenated WPS IEs) |
This function can be used to match the Requested Device Type attribute in WPS IE with the local device types for deciding whether to reply to a Probe Request frame.
void p2p_notify_scan_trigger_status | ( | struct p2p_data * | p2p, |
int | status | ||
) |
Indicate scan trigger status.
p2p | P2P module context from p2p_init() |
status | 0 on success, -1 on failure |
int p2p_parse_dev_addr | ( | const u8 * | ies, |
size_t | ies_len, | ||
u8 * | dev_addr | ||
) |
Parse P2P Device Address from P2P IE(s)
ies | Information elements from scan results |
ies_len | ies buffer length in octets |
dev_addr | Buffer for returning P2P Device Address |
int p2p_parse_dev_addr_in_p2p_ie | ( | struct wpabuf * | p2p_ie, |
u8 * | dev_addr | ||
) |
Parse P2P Device Address from a concatenated P2P IE.
p2p_ie | P2P IE |
dev_addr | Buffer for returning P2P Device Address |
int p2p_peer_known | ( | struct p2p_data * | p2p, |
const u8 * | addr | ||
) |
Check whether P2P peer is known.
p2p | P2P module context from p2p_init() |
addr | P2P Device Address of the peer |
int p2p_prepare_channel | ( | struct p2p_data * | p2p, |
struct p2p_device * | dev, | ||
unsigned int | force_freq, | ||
unsigned int | pref_freq, | ||
int | go | ||
) |
Select operating channel for GO Negotiation.
p2p | P2P module context from p2p_init() |
dev | Selected peer device |
force_freq | Forced frequency in MHz or 0 if not forced |
pref_freq | Preferred frequency in MHz or 0 if no preference |
go | Whether the local end will be forced to be GO |
This function is used to do initial operating channel selection for GO Negotiation prior to having received peer information. The selected channel may be further optimized in p2p_reselect_channel() once the peer information is available.
int p2p_presence_req | ( | struct p2p_data * | p2p, |
const u8 * | go_interface_addr, | ||
const u8 * | own_interface_addr, | ||
unsigned int | freq, | ||
u32 | duration1, | ||
u32 | interval1, | ||
u32 | duration2, | ||
u32 | interval2 | ||
) |
Request GO presence.
p2p | P2P module context from p2p_init() |
go_interface_addr | GO P2P Interface Address |
own_interface_addr | Own P2P Interface Address for this group |
freq | Group operating frequence (in MHz) |
duration1 | Preferred presence duration in microseconds |
interval1 | Preferred presence interval in microseconds |
duration2 | Acceptable presence duration in microseconds |
interval2 | Acceptable presence interval in microseconds |
If both duration and interval values are zero, the parameter pair is not specified (i.e., to remove Presence Request, use duration1 = interval1 = 0).
enum p2p_probe_req_status p2p_probe_req_rx | ( | struct p2p_data * | p2p, |
const u8 * | addr, | ||
const u8 * | dst, | ||
const u8 * | bssid, | ||
const u8 * | ie, | ||
size_t | ie_len, | ||
unsigned int | rx_freq | ||
) |
Report reception of a Probe Request frame.
p2p | P2P module context from p2p_init() |
addr | Source MAC address |
dst | Destination MAC address if available or NULL |
bssid | BSSID if available or NULL |
ie | Information elements from the Probe Request frame body |
ie_len | Length of ie buffer in octets |
rx_freq | Probe Request frame RX frequency |
int p2p_reject | ( | struct p2p_data * | p2p, |
const u8 * | peer_addr | ||
) |
Reject peer device (explicitly block connection attempts)
p2p | P2P module context from p2p_init() |
peer_addr | MAC address of the peer P2P client |
void p2p_remove_wps_vendor_extensions | ( | struct p2p_data * | p2p | ) |
Remove WPS vendor extensions.
p2p | P2P module context from p2p_init() |
void p2p_rx_action | ( | struct p2p_data * | p2p, |
const u8 * | da, | ||
const u8 * | sa, | ||
const u8 * | bssid, | ||
u8 | category, | ||
const u8 * | data, | ||
size_t | len, | ||
int | freq | ||
) |
Report received Action frame.
p2p | P2P module context from p2p_init() |
da | Destination address of the received Action frame |
sa | Source address of the received Action frame |
bssid | Address 3 of the received Action frame |
category | Category of the received Action frame |
data | Action frame body after the Category field |
len | Length of the data buffer in octets |
freq | Frequency (in MHz) on which the frame was received |
Build P2P IE for Probe Request.
p2p | P2P module context from p2p_init() |
ies | Buffer for writing P2P IE |
dev_id | Device ID to search for or NULL for any |
size_t p2p_scan_ie_buf_len | ( | struct p2p_data * | p2p | ) |
Get maximum buffer length needed for p2p_scan_ie.
p2p | P2P module context from p2p_init() |
void p2p_scan_res_handled | ( | struct p2p_data * | p2p | ) |
Indicate end of scan results.
p2p | P2P module context from p2p_init() |
This function is called to indicate that all P2P scan results from a scan have been reported with zero or more calls to p2p_scan_res_handler(). This function must be called as a response to successful struct p2p_config::p2p_scan() call if none of the p2p_scan_res_handler() calls stopped iteration.
int p2p_scan_res_handler | ( | struct p2p_data * | p2p, |
const u8 * | bssid, | ||
int | freq, | ||
struct os_reltime * | rx_time, | ||
int | level, | ||
const u8 * | ies, | ||
size_t | ies_len | ||
) |
Indicate a P2P scan results.
p2p | P2P module context from p2p_init() |
bssid | BSSID of the scan result |
freq | Frequency of the channel on which the device was found in MHz |
rx_time | Time when the result was received |
level | Signal level (signal strength of the received Beacon/Probe Response frame) |
ies | Pointer to IEs from the scan result |
ies_len | Length of the ies buffer |
This function is called to indicate a scan result entry with P2P IE from a scan requested with struct p2p_config::p2p_scan(). This can be called during the actual scan process (i.e., whenever a new device is found) or as a sequence of calls after the full scan has been completed. The former option can result in optimized operations, but may not be supported by all driver/firmware designs. The ies buffer need to include at least the P2P IE, but it is recommended to include all IEs received from the device. The caller does not need to check that the IEs contain a P2P IE before calling this function since frames will be filtered internally if needed.
This function will return 1 if it wants to stop scan result iteration (and scan in general if it is still in progress). This is used to allow faster start of a pending operation, e.g., to start a pending GO negotiation.
int p2p_scan_result_text | ( | const u8 * | ies, |
size_t | ies_len, | ||
char * | buf, | ||
char * | end | ||
) |
Build text format description of P2P IE.
ies | Information elements from scan results |
ies_len | ies buffer length in octets |
buf | Buffer for returning text |
end | Pointer to the end of the buf area |
This function can be used to parse P2P IE contents into text format field=value lines.
void p2p_send_action_cb | ( | struct p2p_data * | p2p, |
unsigned int | freq, | ||
const u8 * | dst, | ||
const u8 * | src, | ||
const u8 * | bssid, | ||
enum p2p_send_action_result | result | ||
) |
Notify TX status of an Action frame.
p2p | P2P module context from p2p_init() |
freq | Channel frequency in MHz |
dst | Destination MAC address (Address 1) |
src | Source MAC address (Address 2) |
bssid | BSSID (Address 3) |
result | Result of the transmission attempt |
This function is used to indicate the result of an Action frame transmission that was requested with struct p2p_config::send_action() callback.
void p2p_set_best_channels | ( | struct p2p_data * | p2p, |
int | freq_24, | ||
int | freq_5, | ||
int | freq_overall | ||
) |
Update best channel information.
p2p | P2P module context from p2p_init() |
freq_24 | Frequency (MHz) of best channel in 2.4 GHz band |
freq_5 | Frequency (MHz) of best channel in 5 GHz band |
freq_overall | Frequency (MHz) of best channel overall |
void p2p_set_client_discoverability | ( | struct p2p_data * | p2p, |
int | enabled | ||
) |
Set client discoverability capability.
p2p | P2P module context from p2p_init() |
enabled | Whether client discoverability will be enabled |
This function can be used to disable (and re-enable) client discoverability. This capability is enabled by default and should not be disabled in normal use cases, i.e., this is mainly for testing purposes.
void p2p_set_config_timeout | ( | struct p2p_data * | p2p, |
u8 | go_timeout, | ||
u8 | client_timeout | ||
) |
Set local config timeouts.
p2p | P2P module context from p2p_init() |
go_timeout | Time in 10 ms units it takes to start the GO mode |
client_timeout | Time in 10 ms units it takes to start the client mode |
void p2p_set_cross_connect | ( | struct p2p_data * | p2p, |
int | enabled | ||
) |
Set cross connection capability.
p2p | P2P module context from p2p_init() |
enabled | Whether cross connection will be enabled |
int p2p_set_dev_name | ( | struct p2p_data * | p2p, |
const char * | dev_name | ||
) |
Set device name.
p2p | P2P module context from p2p_init() |
This function can be used to update the P2P module configuration with information that was not available at the time of the p2p_init() call.
int p2p_set_disc_int | ( | struct p2p_data * | p2p, |
int | min_disc_int, | ||
int | max_disc_int, | ||
int | max_disc_tu | ||
) |
Set min/max discoverable interval for p2p_find.
p2p | P2P module context from p2p_init() |
min_disc_int | minDiscoverableInterval (in units of 100 TU); default 1 |
max_disc_int | maxDiscoverableInterval (in units of 100 TU); default 3 |
max_disc_tu | Maximum number of TUs (1.024 ms) for discoverable interval; or -1 not to limit |
This function can be used to configure minDiscoverableInterval and maxDiscoverableInterval parameters for the Listen state during device discovery (p2p_find). A random number of 100 TU units is picked for each Listen state iteration from [min_disc_int,max_disc_int] range.
max_disc_tu can be used to futher limit the discoverable duration. However, it should be noted that use of this parameter is not recommended since it would not be compliant with the P2P specification.
void p2p_set_intra_bss_dist | ( | struct p2p_data * | p2p, |
int | enabled | ||
) |
Set intra BSS distribution.
p2p | P2P module context from p2p_init() |
enabled | Whether intra BSS distribution will be enabled |
void p2p_set_managed_oper | ( | struct p2p_data * | p2p, |
int | enabled | ||
) |
Set managed P2P Device operations capability.
p2p | P2P module context from p2p_init() |
enabled | Whether managed P2P Device operations will be enabled |
int p2p_set_no_go_freq | ( | struct p2p_data * | p2p, |
const struct wpa_freq_range_list * | list | ||
) |
Set no GO channel ranges.
p2p | P2P module context from p2p_init() |
list | Channel ranges or NULL to remove restriction |
int p2p_set_oper_channel | ( | struct p2p_data * | p2p, |
u8 | op_reg_class, | ||
u8 | op_channel, | ||
int | cfg_op_channel | ||
) |
Set the P2P operating channel.
p2p | P2P module context from p2p_init() |
op_reg_class | Operating regulatory class to set |
op_channel | operating channel to set |
cfg_op_channel | : Whether op_channel is hardcoded in configuration |
void p2p_set_own_freq_preference | ( | struct p2p_data * | p2p, |
int | freq | ||
) |
Set own preference for channel.
p2p | P2P module context from p2p_init() |
freq | Frequency (MHz) of the preferred channel or 0 if no preference |
This function can be used to set a preference on the operating channel based on frequencies used on the other virtual interfaces that share the same radio. If non-zero, this is used to try to avoid multi-channel concurrency.
int p2p_set_pref_chan | ( | struct p2p_data * | p2p, |
unsigned int | num_pref_chan, | ||
const struct p2p_channel * | pref_chan | ||
) |
Set P2P preferred channel list.
p2p | P2P module context from p2p_init() |
num_pref_chan | Number of entries in pref_chan list |
pref_chan | Preferred channels or NULL to remove preferences |
int p2p_set_pri_dev_type | ( | struct p2p_data * | p2p, |
const u8 * | pri_dev_type | ||
) |
Set primary device type.
p2p | P2P module context from p2p_init() |
This function can be used to update the P2P module configuration with information that was not available at the time of the p2p_init() call.
int p2p_set_sec_dev_types | ( | struct p2p_data * | p2p, |
const u8 | dev_types[][8], | ||
size_t | num_dev_types | ||
) |
Set secondary device types.
p2p | P2P module context from p2p_init() |
This function can be used to update the P2P module configuration with information that was not available at the time of the p2p_init() call.
void p2p_stop_find | ( | struct p2p_data * | p2p | ) |
Stop P2P Find (Device Discovery)
p2p | P2P module context from p2p_init() |
void p2p_stop_find_for_freq | ( | struct p2p_data * | p2p, |
int | freq | ||
) |
Stop P2P Find for next oper on specific freq.
p2p | P2P module context from p2p_init() |
freq | Frequency in MHz for next operation |
This is like p2p_stop_find(), but Listen state is not stopped if we are already on the same frequency.
void p2p_stop_listen | ( | struct p2p_data * | p2p | ) |
Stop P2P Listen.
p2p | P2P module context from p2p_init() |
int p2p_unauthorize | ( | struct p2p_data * | p2p, |
const u8 * | addr | ||
) |
Unauthorize the specified peer device.
p2p | P2P module context from p2p_init() |
addr | P2P peer entry to be unauthorized |
This command removes any connection authorization from the specified P2P peer device address. This can be used, e.g., to cancel effect of a previous p2p_authorize() or p2p_connect() call that has not yet resulted in completed GO Negotiation.
void p2p_wps_success_cb | ( | struct p2p_data * | p2p, |
const u8 * | mac_addr | ||
) |
Report successfully completed WPS provisioning.
p2p | P2P module context from p2p_init() |
mac_addr | Peer address |
This function is used to report successfully completed WPS provisioning during group formation in both GO/Registrar and client/Enrollee roles.