コード例 #1
0
ファイル: ap_drv_ops.c プロジェクト: kompiro/rtl8188eu
int hostapd_set_bss_params(struct hostapd_data *hapd, int use_protection)
{
    int ret = 0;
    int preamble;
#ifdef CONFIG_IEEE80211N
    u8 buf[60], *ht_capab, *ht_oper, *pos;

    pos = buf;
    ht_capab = pos;
    pos = hostapd_eid_ht_capabilities(hapd, pos);
    ht_oper = pos;
    pos = hostapd_eid_ht_operation(hapd, pos);
    if (pos > ht_oper && ht_oper > ht_capab &&
            hostapd_set_ht_params(hapd, ht_capab + 2, ht_capab[1],
                                  ht_oper + 2, ht_oper[1])) {
        wpa_printf(MSG_ERROR, "Could not set HT capabilities "
                   "for kernel driver");
        ret = -1;
    }

#endif /* CONFIG_IEEE80211N */

    if (hostapd_set_cts_protect(hapd, use_protection)) {
        wpa_printf(MSG_ERROR, "Failed to set CTS protect in kernel "
                   "driver");
        ret = -1;
    }

    if (hapd->iface->current_mode &&
            hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G &&
            hostapd_set_short_slot_time(hapd,
                                        hapd->iface->num_sta_no_short_slot_time
                                        > 0 ? 0 : 1)) {
        wpa_printf(MSG_ERROR, "Failed to set Short Slot Time option "
                   "in kernel driver");
        ret = -1;
    }

    if (hapd->iface->num_sta_no_short_preamble == 0 &&
            hapd->iconf->preamble == SHORT_PREAMBLE)
        preamble = SHORT_PREAMBLE;
    else
        preamble = LONG_PREAMBLE;
    if (hostapd_set_preamble(hapd, preamble)) {
        wpa_printf(MSG_ERROR, "Could not set preamble for kernel "
                   "driver");
        ret = -1;
    }

    if (hostapd_set_ap_isolate(hapd, hapd->conf->isolate) &&
            hapd->conf->isolate) {
        wpa_printf(MSG_ERROR, "Could not enable AP isolation in "
                   "kernel driver");
        ret = -1;
    }

    return ret;
}
コード例 #2
0
ファイル: beacon.c プロジェクト: AhmadTux/DragonFlyBSD
void ieee802_11_set_beacon(struct hostapd_data *hapd)
{
	struct ieee80211_mgmt *head;
	u8 *pos, *tail, *tailpos;
	int preamble;
	u16 capab_info;
	size_t head_len, tail_len;
	int cts_protection = ((ieee802_11_erp_info(hapd) &
			      ERP_INFO_USE_PROTECTION) ? 1 : 0);

#define BEACON_HEAD_BUF_SIZE 256
#define BEACON_TAIL_BUF_SIZE 512
	head = os_zalloc(BEACON_HEAD_BUF_SIZE);
	tailpos = tail = os_malloc(BEACON_TAIL_BUF_SIZE);
	if (head == NULL || tail == NULL) {
		wpa_printf(MSG_ERROR, "Failed to set beacon data");
		os_free(head);
		os_free(tail);
		return;
	}

	head->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
					   WLAN_FC_STYPE_BEACON);
	head->duration = host_to_le16(0);
	os_memset(head->da, 0xff, ETH_ALEN);

	os_memcpy(head->sa, hapd->own_addr, ETH_ALEN);
	os_memcpy(head->bssid, hapd->own_addr, ETH_ALEN);
	head->u.beacon.beacon_int =
		host_to_le16(hapd->iconf->beacon_int);

	/* hardware or low-level driver will setup seq_ctrl and timestamp */
	capab_info = hostapd_own_capab_info(hapd, NULL, 0);
	head->u.beacon.capab_info = host_to_le16(capab_info);
	pos = &head->u.beacon.variable[0];

	/* SSID */
	*pos++ = WLAN_EID_SSID;
	if (hapd->conf->ignore_broadcast_ssid == 2) {
		/* clear the data, but keep the correct length of the SSID */
		*pos++ = hapd->conf->ssid.ssid_len;
		os_memset(pos, 0, hapd->conf->ssid.ssid_len);
		pos += hapd->conf->ssid.ssid_len;
	} else if (hapd->conf->ignore_broadcast_ssid) {
		*pos++ = 0; /* empty SSID */
	} else {
		*pos++ = hapd->conf->ssid.ssid_len;
		os_memcpy(pos, hapd->conf->ssid.ssid,
			  hapd->conf->ssid.ssid_len);
		pos += hapd->conf->ssid.ssid_len;
	}

	/* Supported rates */
	pos = hostapd_eid_supp_rates(hapd, pos);

	/* DS Params */
	pos = hostapd_eid_ds_params(hapd, pos);

	head_len = pos - (u8 *) head;

	tailpos = hostapd_eid_country(hapd, tailpos,
				      tail + BEACON_TAIL_BUF_SIZE - tailpos);

	/* ERP Information element */
	tailpos = hostapd_eid_erp_info(hapd, tailpos);

	/* Extended supported rates */
	tailpos = hostapd_eid_ext_supp_rates(hapd, tailpos);

	tailpos = hostapd_eid_wpa(hapd, tailpos, tail + BEACON_TAIL_BUF_SIZE -
				  tailpos, NULL);

	/* Wi-Fi Alliance WMM */
	tailpos = hostapd_eid_wmm(hapd, tailpos);

#ifdef CONFIG_IEEE80211N
	if (hapd->iconf->ieee80211n) {
		u8 *ht_capab, *ht_oper;
		ht_capab = tailpos;
		tailpos = hostapd_eid_ht_capabilities_info(hapd, tailpos);

		ht_oper = tailpos;
		tailpos = hostapd_eid_ht_operation(hapd, tailpos);

		if (tailpos > ht_oper && ht_oper > ht_capab &&
		    hostapd_set_ht_params(hapd->conf->iface, hapd,
					  ht_capab + 2, ht_capab[1],
					  ht_oper + 2, ht_oper[1])) {
			wpa_printf(MSG_ERROR, "Could not set HT capabilities "
				   "for kernel driver");
		}
	}
#endif /* CONFIG_IEEE80211N */

#ifdef CONFIG_WPS
	if (hapd->conf->wps_state && hapd->wps_beacon_ie) {
		os_memcpy(tailpos, hapd->wps_beacon_ie,
			  hapd->wps_beacon_ie_len);
		tailpos += hapd->wps_beacon_ie_len;
	}
#endif /* CONFIG_WPS */

	tail_len = tailpos > tail ? tailpos - tail : 0;

	if (hostapd_set_beacon(hapd->conf->iface, hapd, (u8 *) head, head_len,
			       tail, tail_len))
		wpa_printf(MSG_ERROR, "Failed to set beacon head/tail");

	os_free(tail);
	os_free(head);

	if (hostapd_set_cts_protect(hapd, cts_protection))
		wpa_printf(MSG_ERROR, "Failed to set CTS protect in kernel "
			   "driver");

	if (hapd->iface->current_mode &&
	    hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G &&
	    hostapd_set_short_slot_time(hapd,
					hapd->iface->num_sta_no_short_slot_time
					> 0 ? 0 : 1))
		wpa_printf(MSG_ERROR, "Failed to set Short Slot Time option "
			   "in kernel driver");

	if (hapd->iface->num_sta_no_short_preamble == 0 &&
	    hapd->iconf->preamble == SHORT_PREAMBLE)
		preamble = SHORT_PREAMBLE;
	else
		preamble = LONG_PREAMBLE;
	if (hostapd_set_preamble(hapd, preamble))
		wpa_printf(MSG_ERROR, "Could not set preamble for kernel "
			   "driver");
}