Ejemplo n.º 1
0
static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx)
{
    struct hostapd_data *hapd = eloop_ctx;
    struct sta_info *sta = timeout_ctx;
    unsigned int timeout, sec, usec;
    u8 *trans_id, *nbuf;

    wpa_printf(MSG_DEBUG, "%s: SA Query timer for STA " MACSTR
               " (count=%d)",
               hapd->conf->iface, MAC2STR(sta->addr), sta->sa_query_count);

    if (sta->sa_query_count > 0 &&
            ap_check_sa_query_timeout(hapd, sta))
        return;

    nbuf = os_realloc_array(sta->sa_query_trans_id,
                            sta->sa_query_count + 1,
                            WLAN_SA_QUERY_TR_ID_LEN);
    if (nbuf == NULL)
        return;
    if (sta->sa_query_count == 0) {
        /* Starting a new SA Query procedure */
        os_get_reltime(&sta->sa_query_start);
    }
    trans_id = nbuf + sta->sa_query_count * WLAN_SA_QUERY_TR_ID_LEN;
    sta->sa_query_trans_id = nbuf;
    sta->sa_query_count++;

    if (os_get_random(trans_id, WLAN_SA_QUERY_TR_ID_LEN) < 0) {
        /*
         * We don't really care which ID is used here, so simply
         * hardcode this if the mostly theoretical os_get_random()
         * failure happens.
         */
        trans_id[0] = 0x12;
        trans_id[1] = 0x34;
    }

    timeout = hapd->conf->assoc_sa_query_retry_timeout;
    sec = ((timeout / 1000) * 1024) / 1000;
    usec = (timeout % 1000) * 1024;
    eloop_register_timeout(sec, usec, ap_sa_query_timer, hapd, sta);

    hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
                   HOSTAPD_LEVEL_DEBUG,
                   "association SA Query attempt %d", sta->sa_query_count);

    ieee802_11_send_sa_query_req(hapd, sta->addr, trans_id);
}
static int hostapd_ctrl_iface_sa_query(struct hostapd_data *hapd,
				       const char *txtaddr)
{
	u8 addr[ETH_ALEN];
	u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];

	wpa_printf(MSG_DEBUG, "CTRL_IFACE SA_QUERY %s", txtaddr);

	if (hwaddr_aton(txtaddr, addr))
		return -1;

	os_get_random(trans_id, WLAN_SA_QUERY_TR_ID_LEN);
	ieee802_11_send_sa_query_req(hapd, addr, trans_id);

	return 0;
}
Ejemplo n.º 3
0
static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx)
{
	struct hostapd_data *hapd = eloop_ctx;
	struct sta_info *sta = timeout_ctx;
	unsigned int timeout, sec, usec;
	u8 *trans_id, *nbuf;

	if (sta->sa_query_count > 0 &&
	    ap_check_sa_query_timeout(hapd, sta))
		return;

	nbuf = os_realloc(sta->sa_query_trans_id,
			  (sta->sa_query_count + 1) * WLAN_SA_QUERY_TR_ID_LEN);
	if (nbuf == NULL)
		return;
	if (sta->sa_query_count == 0) {
		/* Starting a new SA Query procedure */
		os_get_time(&sta->sa_query_start);
	}
	trans_id = nbuf + sta->sa_query_count * WLAN_SA_QUERY_TR_ID_LEN;
	sta->sa_query_trans_id = nbuf;
	sta->sa_query_count++;

	os_get_random(trans_id, WLAN_SA_QUERY_TR_ID_LEN);

	timeout = hapd->conf->assoc_sa_query_retry_timeout;
	sec = ((timeout / 1000) * 1024) / 1000;
	usec = (timeout % 1000) * 1024;
	eloop_register_timeout(sec, usec, ap_sa_query_timer, hapd, sta);

	hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
		       HOSTAPD_LEVEL_DEBUG,
		       "association SA Query attempt %d", sta->sa_query_count);

#ifdef NEED_AP_MLME
	ieee802_11_send_sa_query_req(hapd, sta->addr, trans_id);
#endif /* NEED_AP_MLME */
}