Module wlan_hw_sim::event::action

source ·
Expand description

Configurable and common handlers that act on PHYs in response to events.

This module provides recipes for event handlers in hardware simulator tests. Handlers are constructed using functions and always emit ActionResults as output. These recipes can be composed to form complex event handlers using terse and declarative syntax.

§Examples

Actions are exposed as functions that construct event handlers. The following example demonstrates constructing a client event handler that scans and transmits packets to an AP.

let advertisements = [ProbeResponse { /* ... */ }];
let mut handler = branch::or((
    event::on_scan(action::send_advertisements_and_scan_completion(&client, advertisements)),
    event::on_transmit(action::send_packet(&ap, rx_info_with_default_ap())),
));

A more complex action handles client association with an authentication tap for controlling the authentication process. The following example constructs such a handler.

let beacons = [Beacon { /* ... */ }];
let control = AuthenticationControl {
    updates: UpdateSink::new(),
    authenticator: /* ... */,
};
let tap = AuthenticationTap {
    control: &mut control,
    // This event handler reacts to `AuthenticationEvent`s and is passed the
    // `AuthenticationControl` as state.
    handler: action::authenticate_with_control_state(),
};
let mut handler = branch::or((
    event::on_scan(action::send_advertisements_and_scan_completion(&client, beacons)),
    event::on_transmit(action::connect_with_authentication_tap(
        &client, &ssid, &bssid, &channel, &protection, tap,
    )),
));

Structs§

Functions§

Type Aliases§