static int wpa_driver_hostap_associate(void *priv, struct wpa_driver_associate_params *params) { struct wpa_driver_hostap_data *drv = priv; int ret = 0; int allow_unencrypted_eapol; wpa_printf(MSG_DEBUG, "%s", __FUNCTION__); if (params->mode != drv->current_mode) { /* At the moment, Host AP driver requires host_roaming=2 for * infrastructure mode and host_roaming=0 for adhoc. */ if (prism2param(drv, PRISM2_PARAM_HOST_ROAMING, params->mode == IEEE80211_MODE_IBSS ? 0 : 2) < 0) { wpa_printf(MSG_DEBUG, "%s: failed to set host_roaming", __func__); } drv->current_mode = params->mode; } if (prism2param(drv, PRISM2_PARAM_PRIVACY_INVOKED, params->key_mgmt_suite != KEY_MGMT_NONE) < 0) ret = -1; if (wpa_driver_hostap_set_wpa_ie(drv, params->wpa_ie, params->wpa_ie_len) < 0) ret = -1; if (wpa_driver_wext_set_mode(drv->wext, params->mode) < 0) ret = -1; if (params->freq && wpa_driver_wext_set_freq(drv->wext, params->freq) < 0) ret = -1; if (wpa_driver_wext_set_ssid(drv->wext, params->ssid, params->ssid_len) < 0) ret = -1; if (wpa_driver_wext_set_bssid(drv->wext, params->bssid) < 0) ret = -1; /* Allow unencrypted EAPOL messages even if pairwise keys are set when * not using WPA. IEEE 802.1X specifies that these frames are not * encrypted, but WPA encrypts them when pairwise keys are in use. */ if (params->key_mgmt_suite == KEY_MGMT_802_1X || params->key_mgmt_suite == KEY_MGMT_PSK) allow_unencrypted_eapol = 0; else allow_unencrypted_eapol = 1; if (prism2param(drv, PRISM2_PARAM_IEEE_802_1X, allow_unencrypted_eapol) < 0) { wpa_printf(MSG_DEBUG, "hostap: Failed to configure " "ieee_802_1x param"); /* Ignore this error.. driver_hostap.c can also be used with * other drivers that do not support this prism2_param. */ } return ret; }
static int wpa_driver_hostap_set_wpa(void *priv, int enabled) { struct wpa_driver_hostap_data *drv = priv; int ret = 0; wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled); if (!enabled && wpa_driver_hostap_set_wpa_ie(drv, NULL, 0) < 0) ret = -1; if (prism2param(drv, PRISM2_PARAM_HOST_ROAMING, enabled ? 2 : 0) < 0) ret = -1; if (prism2param(drv, PRISM2_PARAM_WPA, enabled) < 0) ret = -1; return ret; }
static int wpa_driver_hostap_set_wpa(const char *ifname, int enabled) { int ret = 0; wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled); if (!enabled && wpa_driver_hostap_set_wpa_ie(ifname, NULL, 0) < 0) ret = -1; if (prism2param(ifname, PRISM2_PARAM_HOST_ROAMING, enabled ? 2 : 0) < 0) ret = -1; if (prism2param(ifname, PRISM2_PARAM_PRIVACY_INVOKED, enabled) < 0) ret = -1; if (prism2param(ifname, PRISM2_PARAM_WPA, enabled) < 0) ret = -1; return ret; }
static int wpa_driver_hostap_associate(const char *ifname, const char *bssid, const char *ssid, size_t ssid_len, int freq, const char *wpa_ie, size_t wpa_ie_len, wpa_cipher pairwise_suite, wpa_cipher group_suite, wpa_key_mgmt key_mgmt_suite) { int ret = 0; int allow_unencrypted_eapol; wpa_printf(MSG_DEBUG, "%s", __FUNCTION__); if (wpa_driver_hostap_set_wpa_ie(ifname, wpa_ie, wpa_ie_len) < 0) ret = -1; if (wpa_driver_wext_set_freq(ifname, freq) < 0) ret = -1; if (wpa_driver_wext_set_ssid(ifname, ssid, ssid_len) < 0) ret = -1; if (wpa_driver_wext_set_bssid(ifname, bssid) < 0) ret = -1; /* Allow unencrypted EAPOL messages even if pairwise keys are set when * not using WPA. IEEE 802.1X specifies that these frames are not * encrypted, but WPA encrypts them when pairwise keys are in use. */ if (key_mgmt_suite == KEY_MGMT_802_1X || key_mgmt_suite == KEY_MGMT_PSK) allow_unencrypted_eapol = 0; else allow_unencrypted_eapol = 1; if (prism2param(ifname, PRISM2_PARAM_IEEE_802_1X, allow_unencrypted_eapol) < 0) { wpa_printf(MSG_DEBUG, "hostap: Failed to configure " "ieee_802_1x param"); /* Ignore this error.. driver_hostap.c can also be used with * other drivers that do not support this prism2_param. */ } return ret; }