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

Wi-Fi Protected Setup - Registrar. More...

#include "utils/includes.h"
#include "utils/common.h"
#include "utils/base64.h"
#include "utils/eloop.h"
#include "utils/uuid.h"
#include "utils/list.h"
#include "crypto/crypto.h"
#include "crypto/sha256.h"
#include "crypto/random.h"
#include "common/ieee802_11_defs.h"
#include "wps_i.h"
#include "wps_dev_attr.h"
#include "wps_upnp.h"
#include "wps_upnp_i.h"

Data Structures

struct  wps_uuid_pin
 
struct  wps_pbc_session
 
struct  wps_registrar_device
 
struct  wps_registrar
 

Macros

#define WPS_WORKAROUNDS
 
#define wps_free_nfc_pw_tokens(t, p)   do { } while (0)
 
#define PIN_LOCKED   BIT(0)
 
#define PIN_EXPIRES   BIT(1)
 
#define WPS_STRDUP(n)
 

Functions

int wps_device_store (struct wps_registrar *reg, struct wps_device_data *dev, const u8 *uuid)
 
int wps_registrar_pbc_overlap (struct wps_registrar *reg, const u8 *addr, const u8 *uuid_e)
 
const u8 * wps_authorized_macs (struct wps_registrar *reg, size_t *count)
 
struct wps_registrarwps_registrar_init (struct wps_context *wps, const struct wps_registrar_config *cfg)
 Initialize WPS Registrar data. More...
 
void wps_registrar_flush (struct wps_registrar *reg)
 
void wps_registrar_deinit (struct wps_registrar *reg)
 Deinitialize WPS Registrar data. More...
 
int wps_registrar_add_pin (struct wps_registrar *reg, const u8 *addr, const u8 *uuid, const u8 *pin, size_t pin_len, int timeout)
 Configure a new PIN for Registrar. More...
 
int wps_registrar_invalidate_pin (struct wps_registrar *reg, const u8 *uuid)
 Invalidate a PIN for a specific UUID-E. More...
 
int wps_registrar_unlock_pin (struct wps_registrar *reg, const u8 *uuid)
 Unlock a PIN for a specific UUID-E. More...
 
int wps_registrar_button_pushed (struct wps_registrar *reg, const u8 *p2p_dev_addr)
 Notify Registrar that AP button was pushed. More...
 
void wps_registrar_complete (struct wps_registrar *registrar, const u8 *uuid_e, const u8 *dev_pw, size_t dev_pw_len)
 
int wps_registrar_wps_cancel (struct wps_registrar *reg)
 
void wps_registrar_probe_req_rx (struct wps_registrar *reg, const u8 *addr, const struct wpabuf *wps_data, int p2p_wildcard)
 Notify Registrar of Probe Request. More...
 
int wps_cb_new_psk (struct wps_registrar *reg, const u8 *mac_addr, const u8 *p2p_dev_addr, const u8 *psk, size_t psk_len)
 
int wps_build_credential_wrap (struct wpabuf *msg, const struct wps_credential *cred)
 
int wps_build_cred (struct wps_data *wps, struct wpabuf *msg)
 
struct wpabufwps_registrar_get_msg (struct wps_data *wps, enum wsc_op_code *op_code)
 
enum wps_process_res wps_registrar_process_msg (struct wps_data *wps, enum wsc_op_code op_code, const struct wpabuf *msg)
 
int wps_registrar_update_ie (struct wps_registrar *reg)
 
void wps_registrar_selected_registrar_changed (struct wps_registrar *reg, u16 dev_pw_id)
 SetSelectedRegistrar change. More...
 
int wps_registrar_get_info (struct wps_registrar *reg, const u8 *addr, char *buf, size_t buflen)
 
int wps_registrar_config_ap (struct wps_registrar *reg, struct wps_credential *cred)
 

Detailed Description

Wi-Fi Protected Setup - Registrar.

Macro Definition Documentation

#define WPS_STRDUP (   n)
Value:
os_free(dst->n); \
dst->n = src->n ? os_strdup(src->n) : NULL

Function Documentation

int wps_registrar_add_pin ( struct wps_registrar reg,
const u8 *  addr,
const u8 *  uuid,
const u8 *  pin,
size_t  pin_len,
int  timeout 
)

Configure a new PIN for Registrar.

Parameters
regRegistrar data from wps_registrar_init()
addrEnrollee MAC address or NULL if not known
uuidUUID-E or NULL for wildcard (any UUID)
pinPIN (Device Password)
pin_lenLength of pin in octets
timeoutTime (in seconds) when the PIN will be invalidated; 0 = no timeout
Returns
0 on success, -1 on failure
int wps_registrar_button_pushed ( struct wps_registrar reg,
const u8 *  p2p_dev_addr 
)

Notify Registrar that AP button was pushed.

Parameters
regRegistrar data from wps_registrar_init()
p2p_dev_addrLimit allowed PBC devices to the specified P2P device, NULL indicates no such filtering
Returns
0 on success, -1 on failure, -2 on session overlap

This function is called on an AP when a push button is pushed to activate PBC mode. The PBC mode will be stopped after walk time (2 minutes) timeout or when a PBC registration is completed. If more than one Enrollee in active PBC mode has been detected during the monitor time (previous 2 minutes), the PBC mode is not activated and -2 is returned to indicate session overlap. This is skipped if a specific Enrollee is selected.

void wps_registrar_deinit ( struct wps_registrar reg)

Deinitialize WPS Registrar data.

Parameters
regRegistrar data from wps_registrar_init()
struct wps_registrar* wps_registrar_init ( struct wps_context wps,
const struct wps_registrar_config cfg 
)

Initialize WPS Registrar data.

Parameters
wpsPointer to longterm WPS context
cfgRegistrar configuration
Returns
Pointer to allocated Registrar data or NULL on failure

This function is used to initialize WPS Registrar functionality. It can be used for a single Registrar run (e.g., when run in a supplicant) or multiple runs (e.g., when run as an internal Registrar in an AP). Caller is responsible for freeing the returned data with wps_registrar_deinit() when Registrar functionality is not needed anymore.

int wps_registrar_invalidate_pin ( struct wps_registrar reg,
const u8 *  uuid 
)

Invalidate a PIN for a specific UUID-E.

Parameters
regRegistrar data from wps_registrar_init()
uuidUUID-E
Returns
0 on success, -1 on failure (e.g., PIN not found)
void wps_registrar_probe_req_rx ( struct wps_registrar reg,
const u8 *  addr,
const struct wpabuf wps_data,
int  p2p_wildcard 
)

Notify Registrar of Probe Request.

Parameters
regRegistrar data from wps_registrar_init()
addrMAC address of the Probe Request sender
wps_dataWPS IE contents

This function is called on an AP when a Probe Request with WPS IE is received. This is used to track PBC mode use and to detect possible overlap situation with other WPS APs.

void wps_registrar_selected_registrar_changed ( struct wps_registrar reg,
u16  dev_pw_id 
)

SetSelectedRegistrar change.

Parameters
regRegistrar data from wps_registrar_init()

This function is called when selected registrar state changes, e.g., when an AP receives a SetSelectedRegistrar UPnP message.

int wps_registrar_unlock_pin ( struct wps_registrar reg,
const u8 *  uuid 
)

Unlock a PIN for a specific UUID-E.

Parameters
regRegistrar data from wps_registrar_init()
uuidUUID-E
Returns
0 on success, -1 on failure

PINs are locked to enforce only one concurrent use. This function unlocks a PIN to allow it to be used again. If the specified PIN was configured using a wildcard UUID, it will be removed instead of allowing multiple uses.