wpa_supplicant / hostapd 2.0
Data Structures | Defines | 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

Defines

#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_SD_INFO   BIT(3)
#define P2P_DEV_SD_SCHEDULE   BIT(4)
#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_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.
int p2p_channel_to_freq (const char *country, int reg_class, int channel)
 Convert channel info to frequency.
int p2p_freq_to_channel (const char *country, unsigned int freq, u8 *reg_class, u8 *channel)
 Convert frequency into channel info.
void p2p_channels_intersect (const struct p2p_channels *a, const struct p2p_channels *b, struct p2p_channels *res)
 Intersection of supported channel lists.
int p2p_channels_includes (const struct p2p_channels *channels, u8 reg_class, u8 channel)
 Check whether a channel is included in the list.
int p2p_parse_p2p_ie (const struct wpabuf *buf, struct p2p_message *msg)
 Parse P2P IE.
int p2p_parse_ies (const u8 *data, size_t len, struct p2p_message *msg)
 Parse P2P message IEs (both WPS and P2P IE)
int p2p_parse (const u8 *data, size_t len, struct p2p_message *msg)
 Parse a P2P Action frame contents.
void p2p_parse_free (struct p2p_message *msg)
 Free temporary data from P2P parsing.
int p2p_attr_text (struct wpabuf *data, char *buf, char *end)
 Build text format description of P2P IE attributes.
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)
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_build_wps_ie (struct p2p_data *p2p, struct wpabuf *buf, int pw_id, int all_attr)
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_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 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)
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, int level, const u8 *ies, size_t ies_len)
 Add peer entries based on scan results.
struct p2p_devicep2p_get_device (struct p2p_data *p2p, const u8 *addr)
 Fetch a peer entry.
struct p2p_devicep2p_get_device_interface (struct p2p_data *p2p, const u8 *addr)
 Fetch a peer entry based on P2P Interface Address.
void p2p_go_neg_failed (struct p2p_data *p2p, struct p2p_device *peer, 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.
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)
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)

Detailed Description

P2P - Internal definitions for P2P module.

Copyright
Copyright (c) 2009-2010, Atheros Communications

This software may be distributed under the terms of the BSD license. See README for more details.


Function Documentation

int p2p_add_device ( struct p2p_data p2p,
const u8 *  addr,
int  freq,
int  level,
const u8 *  ies,
size_t  ies_len 
)

Add peer entries based on scan results.

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
iesIEs from the Beacon or Probe Response frame
ies_lenLength of ies buffer in octets
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 ( const char *  country,
int  reg_class,
int  channel 
)

Convert channel info to frequency.

Parameters:
countryCountry code
reg_classRegulatory 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.

int p2p_freq_to_channel ( const char *  country,
unsigned int  freq,
u8 *  reg_class,
u8 *  channel 
)

Convert frequency into channel info.

Parameters:
countryCountry code
reg_classBuffer for returning regulatory 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 
) [read]

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 
) [read]

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_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'.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines