Control WPA supplicant

Overview

Test API to control WPA supplicant tool. More…

// typedefs

typedef enum tapi_wpa_supplicant_status tapi_wpa_supplicant_status;
typedef struct tapi_wpa_supplicant_security tapi_wpa_supplicant_security;

// enums

enum tapi_wpa_supplicant_status;

// structs

struct tapi_wpa_supplicant_security;

// global functions

void tapi_wpa_supplicant_security_init_simple(tapi_wifi_policy policy, const char* passphrase, tapi_wpa_supplicant_security* security);
void tapi_wpa_supplicant_security_init(tapi_wifi_policy policy, tapi_wifi_key_mgmt key_mgmt, tapi_wifi_cipher pairwise_cipher, tapi_wifi_cipher group_cipher, tapi_wifi_pmf pmf, tapi_wifi_pmf ieee80211w, const char* passphrase, tapi_wpa_supplicant_security* security);
void tapi_wpa_supplicant_security_clone(tapi_wpa_supplicant_security* to, const tapi_wpa_supplicant_security* from);
void tapi_wpa_supplicant_security_free(tapi_wpa_supplicant_security* security);
te_errno tapi_wpa_supplicant_configure(const char* ta, const char* ifname, const uint8_t* bssid, const char* ssid, tapi_wpa_supplicant_security* security, bool scan_ssid, const char* opts_fmt, ...);
te_errno te_errno tapi_wpa_supplicant_configure_va(const char* ta, const char* ifname, const uint8_t* bssid, const char* ssid, tapi_wpa_supplicant_security* security, bool scan_ssid, const char* opts_fmt, va_list ap);
te_errno tapi_wpa_supplicant_reset(const char* ta, const char* ifname);
te_errno tapi_wpa_supplicant_start(const char* ta, const char* ifname);
te_errno tapi_wpa_supplicant_stop(const char* ta, const char* ifname);
te_errno tapi_wpa_supplicant_get_status(const char* ta, const char* ifname, tapi_wpa_supplicant_status* status);

Detailed Documentation

Test API to control WPA supplicant tool.

Copyright (C) 2004-2022 OKTET Labs Ltd. All rights reserved.

Typedefs

typedef enum tapi_wpa_supplicant_status tapi_wpa_supplicant_status

WPA supplicant states. Based on https://w1.fi/wpa_supplicant/devel/defs_8h.html (wpa_states).

typedef struct tapi_wpa_supplicant_security tapi_wpa_supplicant_security

WPA supplicant security settings.

Global Functions

void tapi_wpa_supplicant_security_init_simple(tapi_wifi_policy policy, const char* passphrase, tapi_wpa_supplicant_security* security)

Initialize Wi-Fi client security settings container in a simple way. Refering on policy it guesses the value of PMF and key_mgmt, sets cipher to UNDEF value (to use default wpa_supplicant settings) and in the final it calls tapi_wpa_supplicant_security_init().

Parameters:

policy

Security protocol.

passphrase

SSID passphrase, may be NULL for open SSID.

security

Security container.

See also:

tapi_wpa_supplicant_security_free

void tapi_wpa_supplicant_security_init(tapi_wifi_policy policy, tapi_wifi_key_mgmt key_mgmt, tapi_wifi_cipher pairwise_cipher, tapi_wifi_cipher group_cipher, tapi_wifi_pmf pmf, tapi_wifi_pmf ieee80211w, const char* passphrase, tapi_wpa_supplicant_security* security)

Initialize Wi-Fi client security settings container.

Parameters:

policy

Security protocol.

key_mgmt

Authenticated key management protocol.

pairwise_cipher

Pairwise (unicast) encryption protocol.

group_cipher

Group (broadcast/multicast) encryption protocol.

pmf

Protected Management Frame (global).

ieee80211w

Protected Management Frame (per-network).

passphrase

SSID passphrase, may be NULL for open SSID.

security

Security container.

See also:

tapi_wpa_supplicant_security_free

void tapi_wpa_supplicant_security_clone(tapi_wpa_supplicant_security* to, const tapi_wpa_supplicant_security* from)

Copy security settings from one container to another deeply.

Parameters:

to

Destination security container.

from

Source security container.

void tapi_wpa_supplicant_security_free(tapi_wpa_supplicant_security* security)

Free memory allocated for security settings container.

Parameters:

security

Security container.

te_errno tapi_wpa_supplicant_configure(const char* ta, const char* ifname, const uint8_t* bssid, const char* ssid, tapi_wpa_supplicant_security* security, bool scan_ssid, const char* opts_fmt, ...)

Configure WPA supplicant settings. It does not care if the supplicant is already running or not, a user should ensure themselves that the supplicant is inactive before reconfiguring.

Parameters:

ta

Test agent name the supplicant is configured on.

ifname

Wi-Fi network interface the supplicant uses.

bssid

Wi-Fi Access Point’s BSSID, may be NULL.

ssid

Wi-Fi Access Point’s SSID, may be NULL.

security

Wi-Fi security settings, may be NULL to reset them.

scan_ssid

Enable/disable scanning SSID with specific Probe Request frames. This can be enabled to find APs that do not accept broadcast SSID or use multiple SSIDs; this will add latency to scanning, so enable this only when needed.

opts_fmt

Format string with extra wpa_supplicant options, such as “-dd”, “-D”, etc. Useful to set options which cannot be applied with a normal way

Format string arguments.

Returns:

Status code.

See also:

tapi_wpa_supplicant_configure_va

te_errno te_errno tapi_wpa_supplicant_configure_va(const char* ta, const char* ifname, const uint8_t* bssid, const char* ssid, tapi_wpa_supplicant_security* security, bool scan_ssid, const char* opts_fmt, va_list ap)

Same as tapi_wpa_supplicant_configure() but operates with va_list instead of format string.

See also:

tapi_wpa_supplicant_configure

te_errno tapi_wpa_supplicant_reset(const char* ta, const char* ifname)

Stop WPA supplicant and reset its settings.

Parameters:

ta

Test agent name the supplicant is configured on.

ifname

Wi-Fi network interface the supplicant uses.

Returns:

Status code.

te_errno tapi_wpa_supplicant_start(const char* ta, const char* ifname)

Start WPA supplicant.

Parameters:

ta

Test agent name the supplicant is started on.

ifname

Wi-Fi network interface the supplicant uses.

Returns:

Status code.

te_errno tapi_wpa_supplicant_stop(const char* ta, const char* ifname)

Stop WPA supplicant.

Parameters:

ta

Test agent name the supplicant is stopped on.

ifname

Wi-Fi network interface the supplicant uses.

Returns:

Status code.

te_errno tapi_wpa_supplicant_get_status(const char* ta, const char* ifname, tapi_wpa_supplicant_status* status)

Get WPA supplicant status.

Parameters:

ta

Test agent name the supplicant is running on.

ifname

Wi-Fi network interface the supplicant uses.

status

WPA supplicant status.

TE_ENOENT

If the supplicant is not running.

TE_EUNKNOWN

Unknown status, this function requires an update.

Returns:

Status code.