static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd, struct sta_info *sta) { struct hostapd_iface *iface = hapd->iface; size_t i; for (i = 0; i < iface->num_bss; i++) { struct hostapd_data *bss = iface->bss[i]; struct sta_info *sta2; /* bss should always be set during operation, but it may be * NULL during reconfiguration. Assume the STA is not * associated to another BSS in that case to avoid NULL pointer * dereferences. */ if (bss == hapd || bss == NULL) continue; sta2 = ap_get_sta(bss, sta->addr); if (!sta2) continue; wpa_printf(MSG_DEBUG, "%s: disconnect old STA " MACSTR " association from another BSS %s", hapd->conf->iface, MAC2STR(sta2->addr), bss->conf->iface); ap_sta_disconnect(bss, sta2, sta2->addr, WLAN_REASON_PREV_AUTH_NOT_VALID); } }
static void iapp_process_add_notify(struct iapp_data *iapp, struct sockaddr_in *from, struct iapp_hdr *hdr, int len) { struct iapp_add_notify *add = (struct iapp_add_notify *) (hdr + 1); struct sta_info *sta; if (len != sizeof(*add)) { printf("Invalid IAPP-ADD packet length %d (expected %lu)\n", len, (unsigned long) sizeof(*add)); return; } sta = ap_get_sta(iapp->hapd, add->mac_addr); /* IAPP-ADD.indication(MAC Address, Sequence Number) */ hostapd_logger(iapp->hapd, add->mac_addr, HOSTAPD_MODULE_IAPP, HOSTAPD_LEVEL_INFO, "Received IAPP ADD-notify (seq# %d) from %s:%d%s", be_to_host16(add->seq_num), inet_ntoa(from->sin_addr), ntohs(from->sin_port), sta ? "" : " (STA not found)"); if (!sta) return; /* TODO: could use seq_num to try to determine whether last association * to this AP is newer than the one advertised in IAPP-ADD. Although, * this is not really a reliable verification. */ hostapd_logger(iapp->hapd, add->mac_addr, HOSTAPD_MODULE_IAPP, HOSTAPD_LEVEL_DEBUG, "Removing STA due to IAPP ADD-notify"); ap_sta_disconnect(iapp->hapd, sta, NULL, 0); }
static void hostapd_wpa_auth_disconnect(void *ctx, const u8 *addr, u16 reason) { struct hostapd_data *hapd = ctx; wpa_printf(MSG_DEBUG, "%s: WPA authenticator requests disconnect: " "STA " MACSTR " reason %d", __func__, MAC2STR(addr), reason); ap_sta_disconnect(hapd, NULL, addr, reason); }
void ap_ctrl_iface_sta_disconnect(struct wpa_supplicant *wpa_s, const u8 *addr, u16 reason) { if (wpa_s->ap_iface == NULL) return -1; ap_sta_disconnect(wpa_s->ap_iface->bss[0], NULL, addr, reason); }