Exemplo n.º 1
0
int mac_hash_add_mac(struct manage_stainfo *maclist,struct mac_info *sta)
{
	asd_printf(ASD_DEFAULT,MSG_DEBUG,"%s :  sta "MACSTR"\n",__func__,MAC2STR(sta->mac));
	sta->hnext = maclist->sta_hash[STA_HASH(sta->mac)];
	maclist->sta_hash[STA_HASH(sta->mac)] = sta;
	return 0;
}
Exemplo n.º 2
0
int mac_hash_del_mac(struct manage_stainfo *maclist,const unsigned char *mac)
{
	asd_printf(ASD_DEFAULT,MSG_DEBUG,"%s :  sta "MACSTR"\n",__func__,MAC2STR(mac));
	struct mac_info *s;
	s = maclist->sta_hash[STA_HASH(mac)];
	if(!s) return -1;
	if(0 == memcmp(s->mac,mac,MAC_LEN) )
	{
		maclist->sta_hash[STA_HASH(mac)]  = s->hnext;
		return 0;
	}
	while((s->hnext != NULL)&&(memcmp(s->hnext->mac,mac,MAC_LEN) != 0))
		s = s->hnext;
	if(NULL == s->hnext) return -1;
	s->hnext = s->hnext->hnext;
	return 0;
}
Exemplo n.º 3
0
struct ap_info * ap_get_ap(struct hostapd_iface *iface, const u8 *ap)
{
	struct ap_info *s;

	s = iface->ap_hash[STA_HASH(ap)];
	while (s != NULL && os_memcmp(s->addr, ap, ETH_ALEN) != 0)
		s = s->hnext;
	return s;
}
Exemplo n.º 4
0
struct sta_info* ap_get_sta(hostapd *hapd, u8 *sta)
{
    struct sta_info *s;

    s = hapd->sta_hash[STA_HASH(sta)];
    while (s != NULL && memcmp(s->addr, sta, 6) != 0)
        s = s->hnext;
    return s;
}
Exemplo n.º 5
0
/* Caller must hold local->bss_lock */
static void __ieee80211_rx_bss_hash_del(struct ieee80211_local *local,
					struct ieee80211_bss *bss)
{
	struct ieee80211_bss *b, *prev = NULL;
	b = local->bss_hash[STA_HASH(bss->bssid)];
	while (b) {
		if (b == bss) {
			if (!prev)
				local->bss_hash[STA_HASH(bss->bssid)] =
					bss->hnext;
			else
				prev->hnext = bss->hnext;
			break;
		}
		prev = b;
		b = b->hnext;
	}
}
Exemplo n.º 6
0
struct PMK_STAINFO * pmk_ap_get_sta(WID_WLAN *WLAN, const u8 *sta)
{
	struct PMK_STAINFO *s;

	s = WLAN->sta_hash[STA_HASH(sta)];
	while (s != NULL && os_memcmp(s->addr, sta, 6) != 0)
		s = s->hnext;
	return s;
}
Exemplo n.º 7
0
static void ap_sta_hash_del(hostapd *hapd, struct sta_info *sta)
{
    struct sta_info *s;

    s = hapd->sta_hash[STA_HASH(sta->addr)];
    if (s == NULL) return;
    if (memcmp(s->addr, sta->addr, 6) == 0) {
        hapd->sta_hash[STA_HASH(sta->addr)] = s->hnext;
        return;
    }

    while (s->hnext != NULL && memcmp(s->hnext->addr, sta->addr, 6) != 0)
        s = s->hnext;
    if (s->hnext != NULL)
        s->hnext = s->hnext->hnext;
    else
        printf("AP: could not remove STA " MACSTR " from hash table\n",
               MAC2STR(sta->addr));
}
Exemplo n.º 8
0
static void pmk_ap_sta_hash_del(WID_WLAN *WLAN, struct PMK_STAINFO *sta)
{
	struct PMK_STAINFO *s;

	s = WLAN->sta_hash[STA_HASH(sta->addr)];
	if (s == NULL) return;
	if (os_memcmp(s->addr, sta->addr, 6) == 0) {
		WLAN->sta_hash[STA_HASH(sta->addr)] = s->hnext;
		return;
	}

	while (s->hnext != NULL &&
	       os_memcmp(s->hnext->addr, sta->addr, ETH_ALEN) != 0)
		s = s->hnext;
	if (s->hnext != NULL)
		s->hnext = s->hnext->hnext;
	else
		asd_printf(ASD_DEFAULT,MSG_ERROR, "AP: could not remove STA " MACSTR
			   " from hash table", MAC2STR(sta->addr));
}
Exemplo n.º 9
0
static void ap_ap_hash_del(struct hostapd_iface *iface, struct ap_info *ap)
{
	struct ap_info *s;

	s = iface->ap_hash[STA_HASH(ap->addr)];
	if (s == NULL) return;
	if (os_memcmp(s->addr, ap->addr, ETH_ALEN) == 0) {
		iface->ap_hash[STA_HASH(ap->addr)] = s->hnext;
		return;
	}

	while (s->hnext != NULL &&
	       os_memcmp(s->hnext->addr, ap->addr, ETH_ALEN) != 0)
		s = s->hnext;
	if (s->hnext != NULL)
		s->hnext = s->hnext->hnext;
	else
		printf("AP: could not remove AP " MACSTR " from hash table\n",
		       MAC2STR(ap->addr));
}
Exemplo n.º 10
0
static void ap_sta_hash_del(struct hostapd_data *hapd, struct sta_info *sta)
{
	struct sta_info *s;

	s = hapd->sta_hash[STA_HASH(sta->addr)];
	if (s == NULL) return;
	if (os_memcmp(s->addr, sta->addr, 6) == 0) {
		hapd->sta_hash[STA_HASH(sta->addr)] = s->hnext;
		return;
	}

	while (s->hnext != NULL &&
	       os_memcmp(s->hnext->addr, sta->addr, ETH_ALEN) != 0)
		s = s->hnext;
	if (s->hnext != NULL)
		s->hnext = s->hnext->hnext;
	else
		wpa_printf(MSG_DEBUG, "AP: could not remove STA " MACSTR
			   " from hash table", MAC2STR(sta->addr));
}
Exemplo n.º 11
0
/* Caller must hold local->bss_lock */
static void __ieee80211_rx_bss_hash_add(struct ieee80211_local *local,
					struct ieee80211_bss *bss)
{
	u8 hash_idx;

	if (bss_mesh_cfg(bss))
		hash_idx = mesh_id_hash(bss_mesh_id(bss),
					bss_mesh_id_len(bss));
	else
		hash_idx = STA_HASH(bss->bssid);

	bss->hnext = local->bss_hash[hash_idx];
	local->bss_hash[hash_idx] = bss;
}
Exemplo n.º 12
0
struct mac_info * maclist_get_mac(struct manage_stainfo *maclist,const unsigned char *mac)
{
	asd_printf(ASD_DEFAULT,MSG_DEBUG,"%s :  sta "MACSTR"\n",__func__,MAC2STR(mac));
	struct mac_info *sta = NULL;
	sta = maclist->sta_hash[STA_HASH(mac)];
	while(sta)
	{
		if(0 == memcmp(sta->mac,mac,MAC_LEN) )
			return sta;
		sta = sta->hnext;
	}
	
	asd_printf(ASD_DEFAULT,MSG_DEBUG,"%s : "MACSTR" has not get!\n",__func__,MAC2STR(mac));
	return NULL;
}
Exemplo n.º 13
0
struct ieee80211_bss *
ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq,
		     u8 *ssid, u8 ssid_len)
{
	struct ieee80211_bss *bss;

	spin_lock_bh(&local->bss_lock);
	bss = local->bss_hash[STA_HASH(bssid)];
	while (bss) {
		if (!bss_mesh_cfg(bss) &&
		    !memcmp(bss->bssid, bssid, ETH_ALEN) &&
		    bss->freq == freq &&
		    bss->ssid_len == ssid_len &&
		    (ssid_len == 0 || !memcmp(bss->ssid, ssid, ssid_len))) {
			atomic_inc(&bss->users);
			break;
		}
		bss = bss->hnext;
	}
	spin_unlock_bh(&local->bss_lock);
	return bss;
}
Exemplo n.º 14
0
void ap_sta_hash_add(hostapd *hapd, struct sta_info *sta)
{
    sta->hnext = hapd->sta_hash[STA_HASH(sta->addr)];
    hapd->sta_hash[STA_HASH(sta->addr)] = sta;
}
Exemplo n.º 15
0
static void ap_ap_hash_add(struct hostapd_iface *iface, struct ap_info *ap)
{
	ap->hnext = iface->ap_hash[STA_HASH(ap->addr)];
	iface->ap_hash[STA_HASH(ap->addr)] = ap;
}
Exemplo n.º 16
0
static void Handle_read(int sock, void *eloop_ctx, void *sock_ctx)
{
    rtapd *rtapd = eloop_ctx;
    int len;
    unsigned char buf[3000];
    u8 *sa, *da, *pos, *pos_vlan, apidx=0, isVlanTag=0;
    u16 ethertype,i;
    priv_rec *rec;
    size_t left;
    u8  RalinkIe[9] = {221, 7, 0x00, 0x0c, 0x43, 0x00, 0x00, 0x00, 0x00};

    len = recv(sock, buf, sizeof(buf), 0);
    if (len < 0)
    {
        perror("recv");
        Handle_term(15,eloop_ctx,sock_ctx);
        return;
    }

    rec = (priv_rec*)buf;
    left = len -sizeof(*rec)+1;
    if (left <= 0)
    {
        DBGPRINT(RT_DEBUG_ERROR," too short recv\n");
        return;
    }

    sa = rec->saddr;
    da = rec->daddr;
    ethertype = rec->ethtype[0] << 8;
    ethertype |= rec->ethtype[1];

#ifdef ETH_P_VLAN
    if(ethertype == ETH_P_VLAN)
    {
        pos_vlan = rec->xframe;

        if(left >= 4)
        {
            ethertype = *(pos_vlan+2) << 8;
            ethertype |= *(pos_vlan+3);
        }

        if((ethertype == ETH_P_PRE_AUTH) || (ethertype == ETH_P_PAE))
        {
            isVlanTag = 1;
            DBGPRINT(RT_DEBUG_TRACE,"Recv vlan tag for 802.1x. (%02x %02x)\n", *(pos_vlan), *(pos_vlan+1));
        }
    }
#endif

    if ((ethertype == ETH_P_PRE_AUTH) || (ethertype == ETH_P_PAE))
    {
        // search this packet is coming from which interface
        for (i = 0; i < rtapd->conf->SsidNum; i++)
        {
            if (memcmp(da, rtapd->own_addr[i], 6) == 0)
            {
                apidx = i;
                break;
            }
        }

        if(i >= rtapd->conf->SsidNum)
        {
            DBGPRINT(RT_DEBUG_WARN, "Receive unexpected DA (%02x:%02x:%02x:%02x:%02x:%02x)\n",
                     MAC2STR(da));
            return;
        }

        if (ethertype == ETH_P_PRE_AUTH)
        {
            DBGPRINT(RT_DEBUG_TRACE, "Receive WPA2 pre-auth packet for %s%d\n", rtapd->prefix_wlan_name, apidx);
        }
        else
        {
            DBGPRINT(RT_DEBUG_TRACE, "Receive EAP packet for %s%d\n", rtapd->prefix_wlan_name, apidx);
        }
    }
    else
    {
        DBGPRINT(RT_DEBUG_ERROR, "Receive unexpected ethertype 0x%04X!!!\n", ethertype);
        return;
    }

    pos = rec->xframe;

    //strip 4 bytes for valn tag
    if(isVlanTag)
    {
        pos += 4;
        left -= 4;
    }

    /* Check if this is a internal command or not */
    if (left == sizeof(RalinkIe) &&
        RTMPCompareMemory(pos, RalinkIe, 5) == 0)
    {
        u8  icmd = *(pos + 5);

        switch(icmd)
        {
            case DOT1X_DISCONNECT_ENTRY:
            {
                struct sta_info *s;

                s = rtapd->sta_hash[STA_HASH(sa)];
                while (s != NULL && memcmp(s->addr, sa, 6) != 0)
                    s = s->hnext;

                DBGPRINT(RT_DEBUG_TRACE, "Receive discard-notification form wireless driver.\n");
                if (s)
                {
                    DBGPRINT(RT_DEBUG_TRACE,"This station(%02x:%02x:%02x:%02x:%02x:%02x) is removed.\n", MAC2STR(sa));
                    Ap_free_sta(rtapd, s);
                }
                else
                {
                    DBGPRINT(RT_DEBUG_INFO, "This station(%02x:%02x:%02x:%02x:%02x:%02x) doesn't exist.\n", MAC2STR(sa));
                }
            }
            break;

            case DOT1X_RELOAD_CONFIG:
                Handle_reload_config(rtapd);
                break;

            default:
                DBGPRINT(RT_DEBUG_ERROR, "Unknown internal command(%d)!!!\n", icmd);
                break;
        }
    }
    else
    {
        /* Process the general EAP packet */
        ieee802_1x_receive(rtapd, sa, &apidx, pos, left, ethertype, sock);
    }
}
Exemplo n.º 17
0
void pmk_ap_sta_hash_add(WID_WLAN *WLAN, struct PMK_STAINFO *sta)
{
	sta->hnext = WLAN->sta_hash[STA_HASH(sta->addr)];
	WLAN->sta_hash[STA_HASH(sta->addr)] = sta;
}