wpa_supplicant / hostapd 2.0
Functions

wps.c File Reference

Wi-Fi Protected Setup. More...

#include "includes.h"
#include "common.h"
#include "crypto/dh_group5.h"
#include "common/ieee802_11_defs.h"
#include "wps_i.h"
#include "wps_dev_attr.h"

Functions

struct wps_datawps_init (const struct wps_config *cfg)
 Initialize WPS Registration protocol data.
void wps_deinit (struct wps_data *data)
 Deinitialize WPS Registration protocol data.
enum wps_process_res wps_process_msg (struct wps_data *wps, enum wsc_op_code op_code, const struct wpabuf *msg)
 Process a WPS message.
struct wpabufwps_get_msg (struct wps_data *wps, enum wsc_op_code *op_code)
 Build a WPS message.
int wps_is_selected_pbc_registrar (const struct wpabuf *msg)
 Check whether WPS IE indicates active PBC.
int wps_is_selected_pin_registrar (const struct wpabuf *msg)
 Check whether WPS IE indicates active PIN.
int wps_is_addr_authorized (const struct wpabuf *msg, const u8 *addr, int ver1_compat)
 Check whether WPS IE authorizes MAC address.
int wps_ap_priority_compar (const struct wpabuf *wps_a, const struct wpabuf *wps_b)
 Prioritize WPS IE from two APs.
const u8 * wps_get_uuid_e (const struct wpabuf *msg)
 Get UUID-E from WPS IE.
int wps_is_20 (const struct wpabuf *msg)
 Check whether WPS attributes claim support for WPS 2.0.
struct wpabufwps_build_assoc_req_ie (enum wps_request_type req_type)
 Build WPS IE for (Re)Association Request.
struct wpabufwps_build_assoc_resp_ie (void)
 Build WPS IE for (Re)Association Response.
struct wpabufwps_build_probe_req_ie (u16 pw_id, struct wps_device_data *dev, const u8 *uuid, enum wps_request_type req_type, unsigned int num_req_dev_types, const u8 *req_dev_types)
 Build WPS IE for Probe Request.
void wps_free_pending_msgs (struct upnp_pending_message *msgs)
int wps_attr_text (struct wpabuf *data, char *buf, char *end)

Detailed Description

Wi-Fi Protected Setup.

Copyright
Copyright (c) 2007-2009, Jouni Malinen <j@w1.fi>

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


Function Documentation

int wps_ap_priority_compar ( const struct wpabuf wps_a,
const struct wpabuf wps_b 
)

Prioritize WPS IE from two APs.

Parameters:
wps_aWPS IE contents from Beacon or Probe Response frame
wps_bWPS IE contents from Beacon or Probe Response frame
Returns:
1 if wps_b is considered more likely selection for WPS provisioning, -1 if wps_a is considered more like, or 0 if no preference
struct wpabuf* wps_build_assoc_req_ie ( enum wps_request_type  req_type) [read]

Build WPS IE for (Re)Association Request.

Parameters:
req_typeValue for Request Type attribute
Returns:
WPS IE or NULL on failure

The caller is responsible for freeing the buffer.

struct wpabuf* wps_build_assoc_resp_ie ( void  ) [read]

Build WPS IE for (Re)Association Response.

Returns:
WPS IE or NULL on failure

The caller is responsible for freeing the buffer.

struct wpabuf* wps_build_probe_req_ie ( u16  pw_id,
struct wps_device_data dev,
const u8 *  uuid,
enum wps_request_type  req_type,
unsigned int  num_req_dev_types,
const u8 *  req_dev_types 
) [read]

Build WPS IE for Probe Request.

Parameters:
pw_idPassword ID (DEV_PW_PUSHBUTTON for active PBC and DEV_PW_DEFAULT for most other use cases)
devDevice attributes
uuidOwn UUID
req_typeValue for Request Type attribute
num_req_dev_typesNumber of requested device types
req_dev_typesRequested device types (8 * num_req_dev_types octets) or NULL if none
Returns:
WPS IE or NULL on failure

The caller is responsible for freeing the buffer.

void wps_deinit ( struct wps_data data)

Deinitialize WPS Registration protocol data.

Parameters:
dataWPS Registration protocol data from wps_init()
struct wpabuf* wps_get_msg ( struct wps_data wps,
enum wsc_op_code op_code 
) [read]

Build a WPS message.

Parameters:
wpsWPS Registration protocol data from wps_init()
op_codeBuffer for returning message OP Code
Returns:
The generated WPS message or NULL on failure

This function is used to build a response to a message processed by calling wps_process_msg(). The caller is responsible for freeing the buffer.

const u8* wps_get_uuid_e ( const struct wpabuf msg)

Get UUID-E from WPS IE.

Parameters:
msgWPS IE contents from Beacon or Probe Response frame
Returns:
Pointer to UUID-E or NULL if not included

The returned pointer is to the msg contents and it remains valid only as long as the msg buffer is valid.

struct wps_data* wps_init ( const struct wps_config cfg) [read]

Initialize WPS Registration protocol data.

Parameters:
cfgWPS configuration
Returns:
Pointer to allocated data or NULL on failure

This function is used to initialize WPS data for a registration protocol instance (i.e., each run of registration protocol as a Registrar of Enrollee. The caller is responsible for freeing this data after the registration run has been completed by calling wps_deinit().

int wps_is_addr_authorized ( const struct wpabuf msg,
const u8 *  addr,
int  ver1_compat 
)

Check whether WPS IE authorizes MAC address.

Parameters:
msgWPS IE contents from Beacon or Probe Response frame
addrMAC address to search for
ver1_compatWhether to use version 1 compatibility mode
Returns:
1 if address is authorized, 0 if not
int wps_is_selected_pbc_registrar ( const struct wpabuf msg)

Check whether WPS IE indicates active PBC.

Parameters:
msgWPS IE contents from Beacon or Probe Response frame
Returns:
1 if PBC Registrar is active, 0 if not
int wps_is_selected_pin_registrar ( const struct wpabuf msg)

Check whether WPS IE indicates active PIN.

Parameters:
msgWPS IE contents from Beacon or Probe Response frame
Returns:
1 if PIN Registrar is active, 0 if not
enum wps_process_res wps_process_msg ( struct wps_data wps,
enum wsc_op_code  op_code,
const struct wpabuf msg 
)

Process a WPS message.

Parameters:
wpsWPS Registration protocol data from wps_init()
op_codeMessage OP Code
msgMessage data
Returns:
Processing result

This function is used to process WPS messages with OP Codes WSC_ACK, WSC_NACK, WSC_MSG, and WSC_Done. The caller (e.g., EAP server/peer) is responsible for reassembling the messages before calling this function. Response to this message is built by calling wps_get_msg().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines