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

Wi-Fi Direct - P2P group operations. More...

#include "includes.h"
#include "common.h"
#include "common/ieee802_11_defs.h"
#include "common/ieee802_11_common.h"
#include "common/wpa_ctrl.h"
#include "wps/wps_defs.h"
#include "wps/wps_i.h"
#include "p2p_i.h"
#include "p2p.h"

Data Structures

struct  p2p_group_member
 
struct  p2p_group
 Internal P2P module per-group data. More...
 

Functions

struct p2p_groupp2p_group_init (struct p2p_data *p2p, struct p2p_group_config *config)
 Initialize P2P group. More...
 
void p2p_group_deinit (struct p2p_group *group)
 Deinitialize P2P group. More...
 
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)
 
void p2p_group_update_ies (struct p2p_group *group)
 
int p2p_group_notif_assoc (struct p2p_group *group, const u8 *addr, const u8 *ie, size_t len)
 Notification of P2P client association with GO. More...
 
struct wpabufp2p_group_assoc_resp_ie (struct p2p_group *group, u8 status)
 Build P2P IE for (re)association response. More...
 
void p2p_group_notif_disassoc (struct p2p_group *group, const u8 *addr)
 Notification of P2P client disassociation from GO. More...
 
int p2p_group_match_dev_type (struct p2p_group *group, struct wpabuf *wps)
 Match device types in group with requested type. More...
 
int p2p_group_match_dev_id (struct p2p_group *group, struct wpabuf *p2p)
 Match P2P Device Address in group with requested device id.
 
void p2p_group_notif_formation_done (struct p2p_group *group)
 Notification of completed group formation. More...
 
int p2p_group_notif_noa (struct p2p_group *group, const u8 *noa, size_t noa_len)
 Notification of NoA change. More...
 
const u8 * p2p_group_get_dev_addr (struct p2p_group *group, const u8 *addr)
 Get a P2P Device Address of a client in a group. More...
 
int p2p_group_go_discover (struct p2p_group *group, const u8 *dev_id, const u8 *searching_dev, int rx_freq)
 Send GO Discoverability Request to a group client. More...
 
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)
 
unsigned int p2p_get_group_num_members (struct p2p_group *group)
 Get number of members in group. More...
 
int p2p_client_limit_reached (struct p2p_group *group)
 Check if client limit is reached. More...
 
const u8 * p2p_iterate_group_members (struct p2p_group *group, void **next)
 Iterate group members. More...
 
int p2p_group_is_client_connected (struct p2p_group *group, const u8 *dev_addr)
 Check whether a specific client is connected. More...
 
int p2p_group_is_group_id_match (struct p2p_group *group, const u8 *group_id, size_t group_id_len)
 
void p2p_group_force_beacon_update_ies (struct p2p_group *group)
 
int p2p_group_get_freq (struct p2p_group *group)
 
const struct p2p_group_configp2p_group_get_config (struct p2p_group *group)
 Get the group configuration. More...
 
void p2p_loop_on_all_groups (struct p2p_data *p2p, int(*group_callback)(struct p2p_group *group, void *user_data), void *user_data)
 Run the given callback on all groups. More...
 
int p2p_group_get_common_freqs (struct p2p_group *group, int *common_freqs, unsigned int *num)
 Get the group common frequencies. More...
 

Detailed Description

Wi-Fi Direct - P2P group operations.

Function Documentation

int p2p_client_limit_reached ( struct p2p_group group)

Check if client limit is reached.

Parameters
groupP2P group context from p2p_group_init()
Returns
1 if no of clients limit reached
unsigned int p2p_get_group_num_members ( struct p2p_group group)

Get number of members in group.

Parameters
groupP2P group context from p2p_group_init()
Returns
Number of members in the group
struct wpabuf* p2p_group_assoc_resp_ie ( struct p2p_group group,
u8  status 
)

Build P2P IE for (re)association response.

Parameters
groupP2P group context from p2p_group_init()
statusStatus value (P2P_SC_SUCCESS if association succeeded)
Returns
P2P IE for (Re)association Response or NULL on failure

The caller is responsible for freeing the returned buffer with wpabuf_free().

void p2p_group_deinit ( struct p2p_group group)

Deinitialize P2P group.

Parameters
groupP2P group context from p2p_group_init()
int p2p_group_get_common_freqs ( struct p2p_group group,
int *  common_freqs,
unsigned int *  num 
)

Get the group common frequencies.

Parameters
groupP2P group context from p2p_group_init()
common_freqsOn return will hold the group common frequencies
numOn return will hold the number of group common frequencies
Returns
0 on success, -1 otherwise
const struct p2p_group_config* p2p_group_get_config ( struct p2p_group group)

Get the group configuration.

Parameters
groupP2P group context from p2p_group_init()
Returns
The group configuration pointer
const u8* p2p_group_get_dev_addr ( struct p2p_group group,
const u8 *  addr 
)

Get a P2P Device Address of a client in a group.

Parameters
groupP2P group context from p2p_group_init()
addrP2P Interface Address of the client
Returns
P2P Device Address of the client if found or NULL if no match found
int p2p_group_go_discover ( struct p2p_group group,
const u8 *  dev_id,
const u8 *  searching_dev,
int  rx_freq 
)

Send GO Discoverability Request to a group client.

Parameters
groupP2P group context from p2p_group_init()
Returns
0 on success (frame scheduled); -1 if client was not found
struct p2p_group* p2p_group_init ( struct p2p_data p2p,
struct p2p_group_config config 
)

Initialize P2P group.

Parameters
p2pP2P module context from p2p_init()
configP2P group configuration (will be freed by p2p_group_deinit())
Returns
Pointer to private data or NULL on failure

This function is used to initialize per-group P2P module context. Currently, this is only used to manage GO functionality and P2P clients do not need to create an instance of this per-group information.

int p2p_group_is_client_connected ( struct p2p_group group,
const u8 *  dev_addr 
)

Check whether a specific client is connected.

Parameters
groupP2P group context from p2p_group_init()
addrP2P Device Address of the client
Returns
1 if client is connected or 0 if not
int p2p_group_match_dev_type ( struct p2p_group group,
struct wpabuf wps 
)

Match device types in group with requested type.

Parameters
groupP2P group context from p2p_group_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 device types of a group member for deciding whether a GO should reply to a Probe Request frame. Match will be reported if the WPS IE is not requested any specific device type.

int p2p_group_notif_assoc ( struct p2p_group group,
const u8 *  addr,
const u8 *  ie,
size_t  len 
)

Notification of P2P client association with GO.

Parameters
groupP2P group context from p2p_group_init()
addrInterface address of the P2P client
ieIEs from the (Re)association Request frame
lenLength of the ie buffer in octets
Returns
0 on success, -1 on failure
void p2p_group_notif_disassoc ( struct p2p_group group,
const u8 *  addr 
)

Notification of P2P client disassociation from GO.

Parameters
groupP2P group context from p2p_group_init()
addrInterface address of the P2P client
void p2p_group_notif_formation_done ( struct p2p_group group)

Notification of completed group formation.

Parameters
groupP2P group context from p2p_group_init()
int p2p_group_notif_noa ( struct p2p_group group,
const u8 *  noa,
size_t  noa_len 
)

Notification of NoA change.

Parameters
groupP2P group context from p2p_group_init()
noaNotice of Absence attribute payload, NULL if none
noa_lenLength of noa buffer in octets
Returns
0 on success, -1 on failure

Notify the P2P group management about a new NoA contents. This will be inserted into the P2P IEs in Beacon and Probe Response frames with rest of the group information.

const u8* p2p_iterate_group_members ( struct p2p_group group,
void **  next 
)

Iterate group members.

Parameters
groupP2P group context from p2p_group_init()
nextiteration pointer, must be a pointer to a void * that is set to NULL on the first call and not modified later
Returns
A P2P Device Address for each call and NULL for no more members
void p2p_loop_on_all_groups ( struct p2p_data p2p,
int(*)(struct p2p_group *group, void *user_data)  group_callback,
void *  user_data 
)

Run the given callback on all groups.

Parameters
p2pP2P module context from p2p_init()
group_callbackThe callback function pointer
user_dataSome user data pointer which can be NULL

The group_callback function can stop the iteration by returning 0.