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

P2P - generic helper functions. More...

#include "includes.h"
#include "common.h"
#include "common/defs.h"
#include "common/ieee802_11_common.h"
#include "p2p_i.h"

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...
 
int p2p_channels_includes_freq (const struct p2p_channels *channels, unsigned int freq)
 
int p2p_supported_freq (struct p2p_data *p2p, unsigned int freq)
 Check whether channel is supported for P2P. More...
 
int p2p_supported_freq_go (struct p2p_data *p2p, unsigned int freq)
 Check whether channel is supported for P2P GO operation. More...
 
int p2p_supported_freq_cli (struct p2p_data *p2p, unsigned int freq)
 Check whether channel is supported for P2P client operation. More...
 
unsigned int p2p_get_pref_freq (struct p2p_data *p2p, const struct p2p_channels *channels)
 Get channel from preferred channel 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_channels_to_freqs (const struct p2p_channels *channels, int *freq_list, unsigned int max_len)
 

Detailed Description

P2P - generic helper functions.

Function Documentation

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
unsigned int p2p_get_pref_freq ( struct p2p_data p2p,
const struct p2p_channels channels 
)

Get channel from preferred channel list.

Parameters
p2pP2P module context from p2p_init()
channelsList of channels
Returns
Preferred channel
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'.

int p2p_supported_freq ( struct p2p_data p2p,
unsigned int  freq 
)

Check whether channel is supported for P2P.

Parameters
p2pP2P module context from p2p_init()
freqChannel frequency in MHz
Returns
0 if channel not usable for P2P, 1 if usable for P2P
int p2p_supported_freq_cli ( struct p2p_data p2p,
unsigned int  freq 
)

Check whether channel is supported for P2P client operation.

Parameters
p2pP2P module context from p2p_init()
freqChannel frequency in MHz
Returns
0 if channel not usable for P2P, 1 if usable for P2P
int p2p_supported_freq_go ( struct p2p_data p2p,
unsigned int  freq 
)

Check whether channel is supported for P2P GO operation.

Parameters
p2pP2P module context from p2p_init()
freqChannel frequency in MHz
Returns
0 if channel not usable for P2P, 1 if usable for P2P