-/**
- * setup_interface2 - Setup (initialize) an interface (part 2)
- * @iface: Pointer to interface data.
- * Returns: 0 on success; -1 on failure.
- *
- * Flushes old stations, sets the channel, DFS parameters, encryption,
- * beacons, and WDS links based on the configuration.
- */
-static int setup_interface2(struct hostapd_iface *iface)
-{
- struct hostapd_data *hapd = iface->bss[0];
- int freq;
- size_t j;
- int ret = 0;
- u8 *prev_addr;
-
- hostapd_flush_old_stations(hapd);
- hostapd_set_privacy(hapd, 0);
-
- if (hapd->iconf->channel) {
- freq = hostapd_hw_get_freq(hapd, hapd->iconf->channel);
- printf("Mode: %s Channel: %d Frequency: %d MHz\n",
- hostapd_hw_mode_txt(hapd->iconf->hw_mode),
- hapd->iconf->channel, freq);
-
- if (hostapd_set_freq(hapd, hapd->iconf->hw_mode, freq)) {
- printf("Could not set channel for kernel driver\n");
- return -1;
- }
- }
-
- hostapd_broadcast_wep_clear(hapd);
- if (hostapd_setup_encryption(hapd->conf->iface, hapd))
- return -1;
-
- hostapd_set_beacon_int(hapd, hapd->iconf->beacon_int);
- ieee802_11_set_beacon(hapd);
-
- if (hapd->iconf->rts_threshold > -1 &&
- hostapd_set_rts(hapd, hapd->iconf->rts_threshold)) {
- printf("Could not set RTS threshold for kernel driver\n");
- return -1;
- }
-
- if (hapd->iconf->fragm_threshold > -1 &&
- hostapd_set_frag(hapd, hapd->iconf->fragm_threshold)) {
- printf("Could not set fragmentation threshold for kernel "
- "driver\n");
- return -1;
- }
-
- prev_addr = hapd->own_addr;
-
- for (j = 0; j < iface->num_bss; j++) {
- hapd = iface->bss[j];
- if (j)
- os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
- if (hostapd_setup_bss(hapd, j == 0))
- return -1;
- if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0)
- prev_addr = hapd->own_addr;
- }
-
- hostapd_tx_queue_params(iface);
-
- ap_list_init(iface);
-
- if (hostapd_driver_commit(hapd) < 0) {
- wpa_printf(MSG_ERROR, "%s: Failed to commit driver "
- "configuration", __func__);
- return -1;
- }
-
- return ret;
-}
-
-
-static void setup_interface_start(void *eloop_data, void *user_ctx);
-static void setup_interface2_handler(void *eloop_data, void *user_ctx);
-
-/**
- * setup_interface_finalize - Finish setup interface & call the callback
- * @iface: Pointer to interface data.
- * @status: Status of the setup interface (0 on success; -1 on failure).
- * Returns: 0 on success; -1 on failure (e.g., was not in progress).
- */
-static int setup_interface_finalize(struct hostapd_iface *iface, int status)
-{
- hostapd_iface_cb cb;
-
- if (!iface->setup_cb)
- return -1;
-
- eloop_cancel_timeout(setup_interface_start, iface, NULL);
- eloop_cancel_timeout(setup_interface2_handler, iface, NULL);
- hostapd_select_hw_mode_stop(iface);
-
- cb = iface->setup_cb;
-
- iface->setup_cb = NULL;
-
- cb(iface, status);
-
- return 0;
-}
-
-
-/**
- * setup_interface2_wrapper - Wrapper for setup_interface2()
- * @iface: Pointer to interface data.
- * @status: Status of the hw mode select.
- *
- * Wrapper for setup_interface2() to calls finalize function upon completion.
- */
-static void setup_interface2_wrapper(struct hostapd_iface *iface, int status)
-{
- int ret = status;
- if (ret)
- printf("Could not select hw_mode and channel. (%d)\n", ret);
- else
- ret = setup_interface2(iface);
-
- setup_interface_finalize(iface, ret);
-}
-
-
-/**
- * setup_interface2_handler - Used for immediate call of setup_interface2
- * @eloop_data: Stores the struct hostapd_iface * for the interface.
- * @user_ctx: Unused.
- */
-static void setup_interface2_handler(void *eloop_data, void *user_ctx)
-{
- struct hostapd_iface *iface = eloop_data;
-
- setup_interface2_wrapper(iface, 0);
-}
-
-