wpa_supplicant / hostapd 2.0
Functions

p2p_utils.c File Reference

P2P - generic helper functions. More...

#include "includes.h"
#include "common.h"
#include "p2p_i.h"

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_supported_freq (struct p2p_data *p2p, unsigned int freq)
 Check whether channel is supported for P2P.

Detailed Description

P2P - generic helper functions.

Copyright
Copyright (c) 2009, Atheros Communications

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


Function Documentation

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
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
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines