Remove experimental non-AP STA code from hostapd

This was used to allow hostapd to associate as a non-AP STA to another
AP one the same channel while still acting as an AP with the Host AP
driver. This was very experimental and did not work with all firmware
versions. Nowadays, much better way of doing this is to use mac80211
virtual non-AP STA interface. As such, this experimental code can be
removed from hostapd to reduce the code size and make MLME code easier
to understand since it is now only handling AP functionality.
This commit is contained in:
Jouni Malinen 2008-11-21 20:48:58 +02:00
parent ddaa83ebeb
commit fe2c5241b5
7 changed files with 1 additions and 221 deletions

View File

@ -1445,13 +1445,6 @@ struct hostapd_config * hostapd_config_read(const char *fname)
conf->country[2] = ' ';
} else if (os_strcmp(buf, "ieee80211d") == 0) {
conf->ieee80211d = atoi(pos);
} else if (os_strcmp(buf, "assoc_ap_addr") == 0) {
if (hwaddr_aton(pos, bss->assoc_ap_addr)) {
printf("Line %d: invalid MAC address '%s'\n",
line, pos);
errors++;
}
bss->assoc_ap = 1;
} else if (os_strcmp(buf, "ieee8021x") == 0) {
bss->ieee802_1x = atoi(pos);
} else if (os_strcmp(buf, "eapol_version") == 0) {

View File

@ -189,9 +189,6 @@ struct hostapd_bss_config {
char iapp_iface[IFNAMSIZ + 1]; /* interface used with IAPP broadcast
* frames */
u8 assoc_ap_addr[ETH_ALEN];
int assoc_ap; /* whether assoc_ap_addr is set */
enum {
ACCEPT_UNLESS_DENIED = 0,
DENY_UNLESS_ACCEPTED = 1,

View File

@ -1095,15 +1095,6 @@ static void * hostap_init(struct hostapd_data *hapd)
return NULL;
}
if (hapd->conf->assoc_ap &&
hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD_STA, 1)) {
printf("Could not enable hostapd STA mode for interface %s\n",
drv->iface);
close(drv->ioctl_sock);
free(drv);
return NULL;
}
if (hostap_init_sockets(drv)) {
close(drv->ioctl_sock);
free(drv);

View File

@ -1700,9 +1700,6 @@ hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
}
#endif /* EAP_SERVER */
if (hapd->conf->assoc_ap)
hapd->assoc_ap_state = WAIT_BEACON;
hapd->driver = hapd->iconf->driver;
return hapd;

View File

@ -308,10 +308,6 @@ wme_ac_vo_txop_limit=47
wme_ac_vo_acm=0
# Note: for IEEE 802.11b mode: cWmin=3 cWmax=4 burst=102
# Associate as a station to another AP while still acting as an AP on the same
# channel.
#assoc_ap_addr=00:12:34:56:78:9a
# Static WEP key configuration
#
# The key number to use when transmitting.

View File

@ -138,12 +138,6 @@ struct hostapd_data {
struct iapp_data *iapp;
enum { DO_NOT_ASSOC = 0, WAIT_BEACON, AUTHENTICATE, ASSOCIATE,
ASSOCIATED } assoc_ap_state;
char assoc_ap_ssid[33];
int assoc_ap_ssid_len;
u16 assoc_ap_aid;
struct hostapd_cached_radius_acl *acl_cache;
struct hostapd_acl_query_data *acl_queries;

View File

@ -340,84 +340,6 @@ void ieee802_11_send_deauth(struct hostapd_data *hapd, u8 *addr, u16 reason)
}
static void ieee802_11_sta_authenticate(void *eloop_ctx, void *timeout_ctx)
{
struct hostapd_data *hapd = eloop_ctx;
struct ieee80211_mgmt mgmt;
char ssid_txt[33];
if (hapd->assoc_ap_state == WAIT_BEACON)
hapd->assoc_ap_state = AUTHENTICATE;
if (hapd->assoc_ap_state != AUTHENTICATE)
return;
ieee802_11_print_ssid(ssid_txt, (u8 *) hapd->assoc_ap_ssid,
hapd->assoc_ap_ssid_len);
printf("Authenticate with AP " MACSTR " SSID=%s (as station)\n",
MAC2STR(hapd->conf->assoc_ap_addr), ssid_txt);
os_memset(&mgmt, 0, sizeof(mgmt));
mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
WLAN_FC_STYPE_AUTH);
os_memcpy(mgmt.da, hapd->conf->assoc_ap_addr, ETH_ALEN);
os_memcpy(mgmt.sa, hapd->own_addr, ETH_ALEN);
os_memcpy(mgmt.bssid, hapd->conf->assoc_ap_addr, ETH_ALEN);
mgmt.u.auth.auth_alg = host_to_le16(WLAN_AUTH_OPEN);
mgmt.u.auth.auth_transaction = host_to_le16(1);
mgmt.u.auth.status_code = host_to_le16(0);
if (hostapd_send_mgmt_frame(hapd, &mgmt, IEEE80211_HDRLEN +
sizeof(mgmt.u.auth), 0) < 0)
perror("ieee802_11_sta_authenticate: send");
/* Try to authenticate again, if this attempt fails or times out. */
eloop_register_timeout(5, 0, ieee802_11_sta_authenticate, hapd, NULL);
}
static void ieee802_11_sta_associate(void *eloop_ctx, void *timeout_ctx)
{
struct hostapd_data *hapd = eloop_ctx;
u8 buf[256];
struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) buf;
u8 *p;
char ssid_txt[33];
if (hapd->assoc_ap_state == AUTHENTICATE)
hapd->assoc_ap_state = ASSOCIATE;
if (hapd->assoc_ap_state != ASSOCIATE)
return;
ieee802_11_print_ssid(ssid_txt, (u8 *) hapd->assoc_ap_ssid,
hapd->assoc_ap_ssid_len);
printf("Associate with AP " MACSTR " SSID=%s (as station)\n",
MAC2STR(hapd->conf->assoc_ap_addr), ssid_txt);
os_memset(mgmt, 0, sizeof(*mgmt));
mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
WLAN_FC_STYPE_ASSOC_REQ);
os_memcpy(mgmt->da, hapd->conf->assoc_ap_addr, ETH_ALEN);
os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
os_memcpy(mgmt->bssid, hapd->conf->assoc_ap_addr, ETH_ALEN);
mgmt->u.assoc_req.capab_info = host_to_le16(0);
mgmt->u.assoc_req.listen_interval = host_to_le16(1);
p = &mgmt->u.assoc_req.variable[0];
*p++ = WLAN_EID_SSID;
*p++ = hapd->assoc_ap_ssid_len;
os_memcpy(p, hapd->assoc_ap_ssid, hapd->assoc_ap_ssid_len);
p += hapd->assoc_ap_ssid_len;
p = hostapd_eid_supp_rates(hapd, p);
p = hostapd_eid_ext_supp_rates(hapd, p);
if (hostapd_send_mgmt_frame(hapd, mgmt, p - (u8 *) mgmt, 0) < 0)
perror("ieee802_11_sta_associate: send");
/* Try to authenticate again, if this attempt fails or times out. */
eloop_register_timeout(5, 0, ieee802_11_sta_associate, hapd, NULL);
}
static u16 auth_shared_key(struct hostapd_data *hapd, struct sta_info *sta,
u16 auth_transaction, u8 *challenge, int iswep)
{
@ -578,22 +500,6 @@ static void handle_auth(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
status_code, !!(fc & WLAN_FC_ISWEP),
challenge ? " challenge" : "");
if (hapd->assoc_ap_state == AUTHENTICATE && auth_transaction == 2 &&
os_memcmp(mgmt->sa, hapd->conf->assoc_ap_addr, ETH_ALEN) == 0 &&
os_memcmp(mgmt->bssid, hapd->conf->assoc_ap_addr, ETH_ALEN) == 0) {
if (status_code != 0) {
printf("Authentication (as station) with AP "
MACSTR " failed (status_code=%d)\n",
MAC2STR(hapd->conf->assoc_ap_addr),
status_code);
return;
}
printf("Authenticated (as station) with AP " MACSTR "\n",
MAC2STR(hapd->conf->assoc_ap_addr));
ieee802_11_sta_associate(hapd, NULL);
return;
}
if (hapd->tkip_countermeasures) {
resp = WLAN_REASON_MICHAEL_MIC_FAILURE;
goto fail;
@ -1167,57 +1073,6 @@ static void handle_assoc(struct hostapd_data *hapd,
}
static void handle_assoc_resp(struct hostapd_data *hapd,
struct ieee80211_mgmt *mgmt, size_t len)
{
u16 status_code, aid;
if (hapd->assoc_ap_state != ASSOCIATE) {
printf("Unexpected association response received from " MACSTR
"\n", MAC2STR(mgmt->sa));
return;
}
if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.assoc_resp)) {
printf("handle_assoc_resp - too short payload (len=%lu)\n",
(unsigned long) len);
return;
}
if (os_memcmp(mgmt->sa, hapd->conf->assoc_ap_addr, ETH_ALEN) != 0 ||
os_memcmp(mgmt->bssid, hapd->conf->assoc_ap_addr, ETH_ALEN) != 0) {
printf("Received association response from unexpected address "
"(SA=" MACSTR " BSSID=" MACSTR "\n",
MAC2STR(mgmt->sa), MAC2STR(mgmt->bssid));
return;
}
status_code = le_to_host16(mgmt->u.assoc_resp.status_code);
aid = le_to_host16(mgmt->u.assoc_resp.aid);
aid &= ~(BIT(14) | BIT(15));
if (status_code != 0) {
printf("Association (as station) with AP " MACSTR " failed "
"(status_code=%d)\n",
MAC2STR(hapd->conf->assoc_ap_addr), status_code);
/* Try to authenticate again */
hapd->assoc_ap_state = AUTHENTICATE;
eloop_register_timeout(5, 0, ieee802_11_sta_authenticate,
hapd, NULL);
}
printf("Associated (as station) with AP " MACSTR " (aid=%d)\n",
MAC2STR(hapd->conf->assoc_ap_addr), aid);
hapd->assoc_ap_aid = aid;
hapd->assoc_ap_state = ASSOCIATED;
if (hostapd_set_assoc_ap(hapd, hapd->conf->assoc_ap_addr)) {
printf("Could not set associated AP address to kernel "
"driver.\n");
}
}
static void handle_disassoc(struct hostapd_data *hapd,
struct ieee80211_mgmt *mgmt, size_t len)
{
@ -1233,19 +1088,6 @@ static void handle_disassoc(struct hostapd_data *hapd,
MAC2STR(mgmt->sa),
le_to_host16(mgmt->u.disassoc.reason_code));
if (hapd->assoc_ap_state != DO_NOT_ASSOC &&
os_memcmp(mgmt->sa, hapd->conf->assoc_ap_addr, ETH_ALEN) == 0) {
printf("Assoc AP " MACSTR " sent disassociation "
"(reason_code=%d) - try to authenticate\n",
MAC2STR(hapd->conf->assoc_ap_addr),
le_to_host16(mgmt->u.disassoc.reason_code));
hapd->assoc_ap_state = AUTHENTICATE;
ieee802_11_sta_authenticate(hapd, NULL);
eloop_register_timeout(0, 500000, ieee802_11_sta_authenticate,
hapd, NULL);
return;
}
sta = ap_get_sta(hapd, mgmt->sa);
if (sta == NULL) {
printf("Station " MACSTR " trying to disassociate, but it "
@ -1294,18 +1136,6 @@ static void handle_deauth(struct hostapd_data *hapd,
MAC2STR(mgmt->sa),
le_to_host16(mgmt->u.deauth.reason_code));
if (hapd->assoc_ap_state != DO_NOT_ASSOC &&
os_memcmp(mgmt->sa, hapd->conf->assoc_ap_addr, ETH_ALEN) == 0) {
printf("Assoc AP " MACSTR " sent deauthentication "
"(reason_code=%d) - try to authenticate\n",
MAC2STR(hapd->conf->assoc_ap_addr),
le_to_host16(mgmt->u.deauth.reason_code));
hapd->assoc_ap_state = AUTHENTICATE;
eloop_register_timeout(0, 500000, ieee802_11_sta_authenticate,
hapd, NULL);
return;
}
sta = ap_get_sta(hapd, mgmt->sa);
if (sta == NULL) {
printf("Station " MACSTR " trying to deauthenticate, but it "
@ -1342,17 +1172,6 @@ static void handle_beacon(struct hostapd_data *hapd,
sizeof(mgmt->u.beacon)), &elems,
0);
if (hapd->assoc_ap_state == WAIT_BEACON &&
os_memcmp(mgmt->sa, hapd->conf->assoc_ap_addr, ETH_ALEN) == 0) {
if (elems.ssid && elems.ssid_len <= 32) {
os_memcpy(hapd->assoc_ap_ssid, elems.ssid,
elems.ssid_len);
hapd->assoc_ap_ssid[elems.ssid_len] = '\0';
hapd->assoc_ap_ssid_len = elems.ssid_len;
}
ieee802_11_sta_authenticate(hapd, NULL);
}
ap_list_process_beacon(hapd->iface, mgmt, &elems, fi);
}
@ -1505,10 +1324,7 @@ void ieee802_11_mgmt(struct hostapd_data *hapd, u8 *buf, size_t len, u16 stype,
mgmt->bssid[4] == 0xff && mgmt->bssid[5] == 0xff;
if (!broadcast &&
os_memcmp(mgmt->bssid, hapd->own_addr, ETH_ALEN) != 0 &&
(hapd->assoc_ap_state == DO_NOT_ASSOC ||
os_memcmp(mgmt->bssid, hapd->conf->assoc_ap_addr, ETH_ALEN) != 0))
{
os_memcmp(mgmt->bssid, hapd->own_addr, ETH_ALEN) != 0) {
printf("MGMT: BSSID=" MACSTR " not our address\n",
MAC2STR(mgmt->bssid));
return;
@ -1537,10 +1353,6 @@ void ieee802_11_mgmt(struct hostapd_data *hapd, u8 *buf, size_t len, u16 stype,
wpa_printf(MSG_DEBUG, "mgmt::assoc_req");
handle_assoc(hapd, mgmt, len, 0);
break;
case WLAN_FC_STYPE_ASSOC_RESP:
wpa_printf(MSG_DEBUG, "mgmt::assoc_resp");
handle_assoc_resp(hapd, mgmt, len);
break;
case WLAN_FC_STYPE_REASSOC_REQ:
wpa_printf(MSG_DEBUG, "mgmt::reassoc_req");
handle_assoc(hapd, mgmt, len, 1);