wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Macros | Enumerations | Functions
p2p_i.h File Reference

P2P - Internal definitions for P2P module. More...

#include "utils/list.h"
#include "p2p.h"

Go to the source code of this file.

Data Structures

struct  p2p_device
 P2P Device data (internal to P2P module) More...
 
struct  p2p_sd_query
 
struct  p2p_pending_action_tx
 
struct  p2p_data
 P2P module data (internal to P2P module) More...
 
struct  p2p_message
 Parsed P2P message (or P2P IE) More...
 
struct  p2p_group_info
 
struct  p2p_group_info::p2p_client_info
 
struct  p2p_noa_desc
 

Macros

#define P2P_GO_NEG_CNF_MAX_RETRY_COUNT   1
 
#define P2P_DEV_GROUP_CLIENT_RESP_THRESHOLD   1
 
#define MAX_SVC_ADV_LEN   600
 
#define MAX_SVC_ADV_IE_LEN   (9 + MAX_SVC_ADV_LEN + (5 * (MAX_SVC_ADV_LEN / 240)))
 
#define P2P_DEV_PROBE_REQ_ONLY   BIT(0)
 
#define P2P_DEV_REPORTED   BIT(1)
 
#define P2P_DEV_NOT_YET_READY   BIT(2)
 
#define P2P_DEV_PD_PEER_DISPLAY   BIT(5)
 
#define P2P_DEV_PD_PEER_KEYPAD   BIT(6)
 
#define P2P_DEV_USER_REJECTED   BIT(7)
 
#define P2P_DEV_PEER_WAITING_RESPONSE   BIT(8)
 
#define P2P_DEV_PREFER_PERSISTENT_GROUP   BIT(9)
 
#define P2P_DEV_WAIT_GO_NEG_RESPONSE   BIT(10)
 
#define P2P_DEV_WAIT_GO_NEG_CONFIRM   BIT(11)
 
#define P2P_DEV_GROUP_CLIENT_ONLY   BIT(12)
 
#define P2P_DEV_FORCE_FREQ   BIT(13)
 
#define P2P_DEV_PD_FOR_JOIN   BIT(14)
 
#define P2P_DEV_REPORTED_ONCE   BIT(15)
 
#define P2P_DEV_PREFER_PERSISTENT_RECONN   BIT(16)
 
#define P2P_DEV_PD_BEFORE_GO_NEG   BIT(17)
 
#define P2P_DEV_NO_PREF_CHAN   BIT(18)
 
#define P2P_DEV_WAIT_INV_REQ_ACK   BIT(19)
 
#define P2P_DEV_P2PS_REPORTED   BIT(20)
 
#define P2P_DEV_PD_PEER_P2PS   BIT(21)
 
#define P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT   BIT(22)
 
#define P2P_MAX_GROUP_ENTRIES   50
 

Enumerations

enum  p2p_go_state { UNKNOWN_GO, LOCAL_GO, REMOTE_GO }
 

Functions

int p2p_random (char *buf, size_t len)
 Generate random string for SSID and passphrase. More...
 
int p2p_channel_to_freq (int op_class, int channel)
 Convert channel info to frequency. More...
 
int p2p_freq_to_channel (unsigned int freq, u8 *op_class, u8 *channel)
 Convert frequency into channel info. More...
 
void p2p_channels_intersect (const struct p2p_channels *a, const struct p2p_channels *b, struct p2p_channels *res)
 Intersection of supported channel lists. More...
 
void p2p_channels_union_inplace (struct p2p_channels *res, const struct p2p_channels *b)
 Inplace union of channel lists. More...
 
void p2p_channels_union (const struct p2p_channels *a, const struct p2p_channels *b, struct p2p_channels *res)
 Union of channel lists. More...
 
void p2p_channels_remove_freqs (struct p2p_channels *chan, const struct wpa_freq_range_list *list)
 
int p2p_channels_includes (const struct p2p_channels *channels, u8 reg_class, u8 channel)
 Check whether a channel is included in the list. More...
 
void p2p_channels_dump (struct p2p_data *p2p, const char *title, const struct p2p_channels *chan)
 
int p2p_channel_select (struct p2p_channels *chans, const int *classes, u8 *op_class, u8 *op_channel)
 
int p2p_channel_random_social (struct p2p_channels *chans, u8 *op_class, u8 *op_channel)
 
int p2p_parse_p2p_ie (const struct wpabuf *buf, struct p2p_message *msg)
 Parse P2P IE. More...
 
int p2p_parse_ies (const u8 *data, size_t len, struct p2p_message *msg)
 Parse P2P message IEs (both WPS and P2P IE) More...
 
int p2p_parse (const u8 *data, size_t len, struct p2p_message *msg)
 Parse a P2P Action frame contents. More...
 
int p2p_parse_ies_separate (const u8 *wsc, size_t wsc_len, const u8 *p2p, size_t p2p_len, struct p2p_message *msg)
 
void p2p_parse_free (struct p2p_message *msg)
 Free temporary data from P2P parsing. More...
 
int p2p_attr_text (struct wpabuf *data, char *buf, char *end)
 Build text format description of P2P IE attributes. More...
 
int p2p_group_info_parse (const u8 *gi, size_t gi_len, struct p2p_group_info *info)
 
const u8 * p2p_group_get_interface_addr (struct p2p_group *group)
 
u8 p2p_group_presence_req (struct p2p_group *group, const u8 *client_interface_addr, const u8 *noa, size_t noa_len)
 
int p2p_group_is_group_id_match (struct p2p_group *group, const u8 *group_id, size_t group_id_len)
 
void p2p_group_update_ies (struct p2p_group *group)
 
void p2p_group_force_beacon_update_ies (struct p2p_group *group)
 
struct wpabufp2p_group_get_wfd_ie (struct p2p_group *g)
 
void p2p_buf_add_group_info (struct p2p_group *group, struct wpabuf *buf, int max_clients)
 
void p2p_group_buf_add_id (struct p2p_group *group, struct wpabuf *buf)
 
int p2p_group_get_freq (struct p2p_group *group)
 
void p2p_buf_add_action_hdr (struct wpabuf *buf, u8 subtype, u8 dialog_token)
 
void p2p_buf_add_public_action_hdr (struct wpabuf *buf, u8 subtype, u8 dialog_token)
 
u8 * p2p_buf_add_ie_hdr (struct wpabuf *buf)
 
void p2p_buf_add_status (struct wpabuf *buf, u8 status)
 
void p2p_buf_add_device_info (struct wpabuf *buf, struct p2p_data *p2p, struct p2p_device *peer)
 
void p2p_buf_add_device_id (struct wpabuf *buf, const u8 *dev_addr)
 
void p2p_buf_update_ie_hdr (struct wpabuf *buf, u8 *len)
 
void p2p_buf_add_capability (struct wpabuf *buf, u8 dev_capab, u8 group_capab)
 
void p2p_buf_add_go_intent (struct wpabuf *buf, u8 go_intent)
 
void p2p_buf_add_listen_channel (struct wpabuf *buf, const char *country, u8 reg_class, u8 channel)
 
void p2p_buf_add_operating_channel (struct wpabuf *buf, const char *country, u8 reg_class, u8 channel)
 
void p2p_buf_add_channel_list (struct wpabuf *buf, const char *country, struct p2p_channels *chan)
 
void p2p_buf_add_config_timeout (struct wpabuf *buf, u8 go_timeout, u8 client_timeout)
 
void p2p_buf_add_intended_addr (struct wpabuf *buf, const u8 *interface_addr)
 
void p2p_buf_add_group_bssid (struct wpabuf *buf, const u8 *bssid)
 
void p2p_buf_add_group_id (struct wpabuf *buf, const u8 *dev_addr, const u8 *ssid, size_t ssid_len)
 
void p2p_buf_add_invitation_flags (struct wpabuf *buf, u8 flags)
 
void p2p_buf_add_noa (struct wpabuf *buf, u8 noa_index, u8 opp_ps, u8 ctwindow, struct p2p_noa_desc *desc1, struct p2p_noa_desc *desc2)
 
void p2p_buf_add_ext_listen_timing (struct wpabuf *buf, u16 period, u16 interval)
 
void p2p_buf_add_p2p_interface (struct wpabuf *buf, struct p2p_data *p2p)
 
void p2p_buf_add_oob_go_neg_channel (struct wpabuf *buf, const char *country, u8 oper_class, u8 channel, enum p2p_role_indication role)
 
void p2p_buf_add_service_hash (struct wpabuf *buf, struct p2p_data *p2p)
 
void p2p_buf_add_session_info (struct wpabuf *buf, const char *info)
 
void p2p_buf_add_connection_capability (struct wpabuf *buf, u8 connection_cap)
 
void p2p_buf_add_advertisement_id (struct wpabuf *buf, u32 id, const u8 *mac)
 
void p2p_buf_add_service_instance (struct wpabuf *buf, struct p2p_data *p2p, u8 count, const u8 *hash, struct p2ps_advertisement *adv_list)
 
void p2p_buf_add_session_id (struct wpabuf *buf, u32 id, const u8 *mac)
 
void p2p_buf_add_feature_capability (struct wpabuf *buf, u16 len, const u8 *mask)
 
void p2p_buf_add_persistent_group_info (struct wpabuf *buf, const u8 *dev_addr, const u8 *ssid, size_t ssid_len)
 
int p2p_build_wps_ie (struct p2p_data *p2p, struct wpabuf *buf, int pw_id, int all_attr)
 
void p2p_buf_add_pref_channel_list (struct wpabuf *buf, const u32 *preferred_freq_list, u32 size)
 
struct p2p_sd_queryp2p_pending_sd_req (struct p2p_data *p2p, struct p2p_device *dev)
 
void p2p_free_sd_queries (struct p2p_data *p2p)
 
void p2p_rx_gas_initial_req (struct p2p_data *p2p, const u8 *sa, const u8 *data, size_t len, int rx_freq)
 
void p2p_rx_gas_initial_resp (struct p2p_data *p2p, const u8 *sa, const u8 *data, size_t len, int rx_freq)
 
void p2p_rx_gas_comeback_req (struct p2p_data *p2p, const u8 *sa, const u8 *data, size_t len, int rx_freq)
 
void p2p_rx_gas_comeback_resp (struct p2p_data *p2p, const u8 *sa, const u8 *data, size_t len, int rx_freq)
 
int p2p_start_sd (struct p2p_data *p2p, struct p2p_device *dev)
 
int p2p_peer_channels_check (struct p2p_data *p2p, struct p2p_channels *own, struct p2p_device *dev, const u8 *channel_list, size_t channel_list_len)
 
void p2p_process_go_neg_req (struct p2p_data *p2p, const u8 *sa, const u8 *data, size_t len, int rx_freq)
 
void p2p_process_go_neg_resp (struct p2p_data *p2p, const u8 *sa, const u8 *data, size_t len, int rx_freq)
 
void p2p_process_go_neg_conf (struct p2p_data *p2p, const u8 *sa, const u8 *data, size_t len)
 
int p2p_connect_send (struct p2p_data *p2p, struct p2p_device *dev)
 
u16 p2p_wps_method_pw_id (enum p2p_wps_method wps_method)
 
void p2p_reselect_channel (struct p2p_data *p2p, struct p2p_channels *intersection)
 Re-select operating channel based on peer information. More...
 
void p2p_check_pref_chan (struct p2p_data *p2p, int go, struct p2p_device *dev, struct p2p_message *msg)
 
void p2p_process_prov_disc_req (struct p2p_data *p2p, const u8 *sa, const u8 *data, size_t len, int rx_freq)
 
void p2p_process_prov_disc_resp (struct p2p_data *p2p, const u8 *sa, const u8 *data, size_t len)
 
int p2p_send_prov_disc_req (struct p2p_data *p2p, struct p2p_device *dev, int join, int force_freq)
 
void p2p_reset_pending_pd (struct p2p_data *p2p)
 
void p2ps_prov_free (struct p2p_data *p2p)
 
void p2p_process_invitation_req (struct p2p_data *p2p, const u8 *sa, const u8 *data, size_t len, int rx_freq)
 
void p2p_process_invitation_resp (struct p2p_data *p2p, const u8 *sa, const u8 *data, size_t len)
 
int p2p_invite_send (struct p2p_data *p2p, struct p2p_device *dev, const u8 *go_dev_addr, int dev_pw_id)
 
void p2p_invitation_req_cb (struct p2p_data *p2p, int success)
 
void p2p_invitation_resp_cb (struct p2p_data *p2p, int success)
 
void p2p_process_dev_disc_req (struct p2p_data *p2p, const u8 *sa, const u8 *data, size_t len, int rx_freq)
 
void p2p_dev_disc_req_cb (struct p2p_data *p2p, int success)
 
int p2p_send_dev_disc_req (struct p2p_data *p2p, struct p2p_device *dev)
 
void p2p_dev_disc_resp_cb (struct p2p_data *p2p, int success)
 
void p2p_process_dev_disc_resp (struct p2p_data *p2p, const u8 *sa, const u8 *data, size_t len)
 
void p2p_go_disc_req_cb (struct p2p_data *p2p, int success)
 
void p2p_process_go_disc_req (struct p2p_data *p2p, const u8 *da, const u8 *sa, const u8 *data, size_t len, int rx_freq)
 
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_continue_find (struct p2p_data *p2p)
 
struct p2p_devicep2p_add_dev_from_go_neg_req (struct p2p_data *p2p, const u8 *addr, struct p2p_message *msg)
 
void p2p_add_dev_info (struct p2p_data *p2p, const u8 *addr, struct p2p_device *dev, struct p2p_message *msg)
 
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...
 
struct p2p_devicep2p_get_device (struct p2p_data *p2p, const u8 *addr)
 Fetch a peer entry. More...
 
struct p2p_devicep2p_get_device_interface (struct p2p_data *p2p, const u8 *addr)
 Fetch a peer entry based on P2P Interface Address. More...
 
void p2p_go_neg_failed (struct p2p_data *p2p, int status)
 
void p2p_go_complete (struct p2p_data *p2p, struct p2p_device *peer)
 
int p2p_match_dev_type (struct p2p_data *p2p, struct wpabuf *wps)
 Match local device type with requested type. More...
 
int dev_type_list_match (const u8 *dev_type, const u8 *req_dev_type[], size_t num_req_dev_type)
 
struct wpabufp2p_build_probe_resp_ies (struct p2p_data *p2p, const u8 *query_hash, u8 query_count)
 
void p2p_build_ssid (struct p2p_data *p2p, u8 *ssid, size_t *ssid_len)
 
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_stop_listen_for_freq (struct p2p_data *p2p, int freq)
 
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...
 
void p2p_go_neg_wait_timeout (void *eloop_ctx, void *timeout_ctx)
 
int p2p_go_select_channel (struct p2p_data *p2p, struct p2p_device *dev, u8 *status)
 
void p2p_dbg (struct p2p_data *p2p, const char *fmt,...) PRINTF_FORMAT(2
 
void void p2p_info (struct p2p_data *p2p, const char *fmt,...) PRINTF_FORMAT(2
 
void void void p2p_err (struct p2p_data *p2p, const char *fmt,...) PRINTF_FORMAT(2
 

Detailed Description

P2P - Internal definitions for P2P module.

Function Documentation

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.

Parameters
p2pP2P module context from p2p_init()
addrSource address of Beacon or Probe Response frame (may be either P2P Device Address or P2P Interface Address)
levelSignal level (signal strength of the received frame from the peer)
freqFrequency on which the Beacon or Probe Response frame was received
rx_timeTime when the result was received
iesIEs from the Beacon or Probe Response frame
ies_lenLength of ies buffer in octets
scan_resWhether this was based on scan results
Returns
0 on success, -1 on failure

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.

int p2p_attr_text ( struct wpabuf data,
char *  buf,
char *  end 
)

Build text format description of P2P IE attributes.

Parameters
dataP2P IE contents
bufBuffer for returning text
endPointer to the end of the buf area
Returns
Number of octets written to the buffer or -1 on faikure

This function can be used to parse P2P IE contents into text format field=value lines.

int p2p_channel_to_freq ( int  op_class,
int  channel 
)

Convert channel info to frequency.

Parameters
op_classOperating class
channelChannel number
Returns
Frequency in MHz or -1 if the specified channel is unknown
int p2p_channels_includes ( const struct p2p_channels channels,
u8  reg_class,
u8  channel 
)

Check whether a channel is included in the list.

Parameters
channelsList of supported channels
reg_classRegulatory class of the channel to search
channelChannel number of the channel to search
Returns
1 if channel was found or 0 if not
void p2p_channels_intersect ( const struct p2p_channels a,
const struct p2p_channels b,
struct p2p_channels res 
)

Intersection of supported channel lists.

Parameters
aFirst set of supported channels
bSecond set of supported channels
resData structure for returning the intersection of support channels

This function can be used to find a common set of supported channels. Both input channels sets are assumed to use the same country code. If different country codes are used, the regulatory class numbers may not be matched correctly and results are undefined.

void p2p_channels_union ( const struct p2p_channels a,
const struct p2p_channels b,
struct p2p_channels res 
)

Union of channel lists.

Parameters
aFirst set of channels
bSecond set of channels
resData structure for returning the union of channels
void p2p_channels_union_inplace ( struct p2p_channels res,
const struct p2p_channels b 
)

Inplace union of channel lists.

Parameters
resInput data and place for returning union of the channel sets
bSecond set of channels
int p2p_freq_to_channel ( unsigned int  freq,
u8 *  op_class,
u8 *  channel 
)

Convert frequency into channel info.

Parameters
op_classBuffer for returning operating class
channelBuffer for returning channel number
Returns
0 on success, -1 if the specified frequency is unknown
struct p2p_device* p2p_get_device ( struct p2p_data p2p,
const u8 *  addr 
)

Fetch a peer entry.

Parameters
p2pP2P module context from p2p_init()
addrP2P Device Address of the peer
Returns
Pointer to the device entry or NULL if not found
struct p2p_device* p2p_get_device_interface ( struct p2p_data p2p,
const u8 *  addr 
)

Fetch a peer entry based on P2P Interface Address.

Parameters
p2pP2P module context from p2p_init()
addrP2P Interface Address of the peer
Returns
Pointer to the device entry or NULL if not found
int p2p_match_dev_type ( struct p2p_data p2p,
struct wpabuf wps 
)

Match local device type with requested type.

Parameters
p2pP2P module context from p2p_init()
wpsWPS TLVs from Probe Request frame (concatenated WPS IEs)
Returns
1 on match, 0 on mismatch

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.

int p2p_parse ( const u8 *  data,
size_t  len,
struct p2p_message msg 
)

Parse a P2P Action frame contents.

Parameters
dataAction frame payload after Category and Code fields
lenLength of data buffer in octets
msgBuffer for returning parsed attributes
Returns
0 on success, -1 on failure

Note: Caller must free temporary memory allocations by calling p2p_parse_free() when the parsed data is not needed anymore.

void p2p_parse_free ( struct p2p_message msg)

Free temporary data from P2P parsing.

Parameters
msgParsed attributes
int p2p_parse_ies ( const u8 *  data,
size_t  len,
struct p2p_message msg 
)

Parse P2P message IEs (both WPS and P2P IE)

Parameters
dataIEs from the message
lenLength of data buffer in octets
msgBuffer for returning parsed attributes
Returns
0 on success, -1 on failure

Note: Caller is responsible for clearing the msg data structure before calling this function.

Note: Caller must free temporary memory allocations by calling p2p_parse_free() when the parsed data is not needed anymore.

int p2p_parse_p2p_ie ( const struct wpabuf buf,
struct p2p_message msg 
)

Parse P2P IE.

Parameters
bufConcatenated P2P IE(s) payload
msgBuffer for returning parsed attributes
Returns
0 on success, -1 on failure

Note: Caller is responsible for clearing the msg data structure before calling this function.

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.

Parameters
p2pP2P module context from p2p_init()
devSelected peer device
force_freqForced frequency in MHz or 0 if not forced
pref_freqPreferred frequency in MHz or 0 if no preference
goWhether the local end will be forced to be GO
Returns
0 on success, -1 on failure (channel not supported for P2P)

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_random ( char *  buf,
size_t  len 
)

Generate random string for SSID and passphrase.

Parameters
bufBuffer for returning the result
lenNumber of octets to write to the buffer
Returns
0 on success, -1 on failure

This function generates a random string using the following character set: 'A'-'Z', 'a'-'z', '0'-'9'.

void p2p_reselect_channel ( struct p2p_data p2p,
struct p2p_channels intersection 
)

Re-select operating channel based on peer information.

Parameters
p2pP2P module context from p2p_init()
intersectionSupport channel list intersection from local and peer

This function is used to re-select the best channel after having received information from the peer to allow supported channel lists to be intersected. This can be used to improve initial channel selection done in p2p_prepare_channel() prior to the start of GO Negotiation. In addition, this can be used for Invitation case.