static int rtl871x_sta_add2_ops(const char *ifname, void *priv, struct hostapd_sta_add_params *params) { #if 0 ieee_param param; struct rtl871x_driver_data *drv = priv; printf("%s\n", __func__); memset(¶m, 0, sizeof(param)); param.cmd = RTL871X_HOSTAPD_ADD_STA; memcpy(param.sta_addr, params->addr, ETH_ALEN); param.u.add_sta.aid = params->aid; param.u.add_sta.capability = params->capability; param.u.add_sta.flags = params->flags; memcpy(param.u.add_sta.tx_supp_rates, params->supp_rates, params->supp_rates_len); #ifdef CONFIG_IEEE80211N if (params->ht_capabilities && params->ht_capabilities->length>0) { struct ieee80211_ht_capability *pht_cap = (struct ieee80211_ht_capability *)¶ms->ht_capabilities->data; memcpy((u8*)¶m.u.add_sta.ht_cap, (u8*)pht_cap, sizeof(struct ieee80211_ht_capability)); } #endif /* CONFIG_IEEE80211N */ return rtl871x_hostapd_ioctl(drv, ¶m, sizeof(param)); #else return 0; #endif }
static int rtl871x_set_wps_probe_resp_ie(struct rtl871x_driver_data *drv, const void *ie, size_t len) { int ret; size_t sz; ieee_param *pparam; printf("%s\n", __func__); sz = len + 12 + 2; // 12+2 = cmd+sta_addr+reserved, sizeof(ieee_param)=64, no packed pparam = os_zalloc(sz); if (pparam == NULL) { return -ENOMEM; } pparam->cmd = RTL871X_HOSTAPD_SET_WPS_PROBE_RESP; if (ie && len>0) { memcpy(pparam->u.bcn_ie.buf, ie, len); } ret = rtl871x_hostapd_ioctl(drv, pparam, sz); os_free(pparam); return ret; }
static int rtl871x_get_sta_wpaie(struct rtl871x_driver_data *drv, u8 *iebuf, u8 *addr) { struct ieee_param param; printf("+%s, " MACSTR " is sta's address\n", __func__, MAC2STR(addr)); memset(¶m, 0, sizeof(param)); param.cmd = RTL871X_HOSTAPD_GET_WPAIE_STA; memcpy(param.sta_addr, addr, ETH_ALEN); if (rtl871x_hostapd_ioctl(drv, ¶m, sizeof(param))) { printf("Could not get sta wpaie from kernel driver.\n"); return -1; } if(param.u.wpa_ie.len > 32) return -1; memcpy(iebuf, param.u.wpa_ie.reserved, param.u.wpa_ie.len); return 0; }
static int rtl871x_sta_flush_ops(void *priv) { ieee_param param; struct rtl871x_driver_data *drv = priv; memset(¶m, 0, sizeof(param)); param.cmd = RTL871X_HOSTAPD_FLUSH; return rtl871x_hostapd_ioctl(drv, ¶m, sizeof(param)); }
static int rtl871x_set_hidden_ssid_ops(const char *iface, void *priv, u8 value) { int ret; ieee_param pparam; struct rtl871x_driver_data *drv = priv; struct hostapd_data *hapd = drv->hapd; printf("%s\n", __func__); pparam.cmd = RTL871X_HOSTAPD_SET_HIDDEN_SSID; pparam.u.wpa_param.name = 0; pparam.u.wpa_param.value = value; ret = rtl871x_hostapd_ioctl(drv, &pparam, sizeof(ieee_param)); return ret; }
static int rtl871x_sta_remove_ops(void *priv, const u8 *addr) { struct rtl871x_driver_data *drv = priv; struct ieee_param param; printf("+%s, " MACSTR " is sta address removed\n", __func__, MAC2STR(addr)); memset(¶m, 0, sizeof(param)); param.cmd = RTL871X_HOSTAPD_REMOVE_STA; memcpy(param.sta_addr, addr, ETH_ALEN); if (rtl871x_hostapd_ioctl(drv, ¶m, sizeof(param))) { printf("Could not remove station from kernel driver.\n"); return -1; } return 0; }
static int rtl871x_set_beacon_ops(void *priv, struct wpa_driver_ap_params *params) { int ret; size_t sz; ieee_param *pparam; struct rtl871x_driver_data *drv = priv; struct hostapd_data *hapd = drv->hapd; u8 *ssid_ie; u8 ssid_len; u8 expend_len = 0; if ((params->head_len<24) ||(!params->head)) return -1; printf("%s\n", __func__); #ifdef RTL871X_HIDDEN_SSID_SUPPORT rtl871x_set_hidden_ssid_ops(drv->iface, priv, hapd->conf->ignore_broadcast_ssid); ssid_ie = get_ie((params->head+24+12), (params->head_len-24-12), WLAN_EID_SSID); if (hapd->conf->ignore_broadcast_ssid == 2) { ssid_len = ssid_ie[1]; /* confirm the ssid_len */ if (ssid_len != hapd->conf->ssid.ssid_len) { printf("%s ssid_len(%u) != hapd->conf->ssid.ssid_len(%u)!!\n", __func__ , ssid_len, hapd->conf->ssid.ssid_len ); } memcpy(ssid_ie+2, hapd->conf->ssid.ssid, ssid_len); } else if (hapd->conf->ignore_broadcast_ssid == 1) { expend_len = hapd->conf->ssid.ssid_len; printf("%s ignore_broadcast_ssid:%d, %s,%d, expend_len:%u\n", __func__ , hapd->conf->ignore_broadcast_ssid , hapd->conf->ssid.ssid , hapd->conf->ssid.ssid_len , expend_len ); } #endif /* RTL871X_HIDDEN_SSID_SUPPORT */ sz = params->head_len+params->tail_len+12-24 + 2 + expend_len; // 12+2 = cmd+sta_addr+reserved, sizeof(ieee_param)=64, no packed pparam = os_zalloc(sz); if (pparam == NULL) { return -ENOMEM; } pparam->cmd = RTL871X_HOSTAPD_SET_BEACON; memcpy(pparam->u.bcn_ie.reserved, &hapd->conf->max_num_sta, 2); // for set max_num_sta #ifdef RTL871X_HIDDEN_SSID_SUPPORT if (hapd->conf->ignore_broadcast_ssid == 1) { u8 *ssid_ie_next = params->head+24+12+2; size_t head_remain_len = params->head_len-24-12-2; memcpy(pparam->u.bcn_ie.buf, (params->head+24), 12); pparam->u.bcn_ie.buf[12] = WLAN_EID_SSID; pparam->u.bcn_ie.buf[13] = expend_len; memcpy(pparam->u.bcn_ie.buf+12+2, hapd->conf->ssid.ssid, expend_len); memcpy(pparam->u.bcn_ie.buf+12+2+expend_len, ssid_ie_next, head_remain_len); // 24=beacon header len. memcpy(&pparam->u.bcn_ie.buf[params->head_len-24+expend_len], params->tail, params->tail_len); } else #endif /* RTL871X_HIDDEN_SSID_SUPPORT */ { memcpy(pparam->u.bcn_ie.buf, (params->head+24), (params->head_len-24)); // 24=beacon header len. memcpy(&pparam->u.bcn_ie.buf[params->head_len-24], params->tail, params->tail_len); } ret = rtl871x_hostapd_ioctl(drv, pparam, sz); os_free(pparam); return ret; }
static int rtl871x_set_key_ops(const char *ifname, void *priv, enum wpa_alg alg, const u8 *addr, int idx, int txkey, const u8 *seq, size_t seq_len, const u8 *key, size_t key_len) { ieee_param *param; u8 *buf; char *alg_str; size_t blen; int ret = 0; struct rtl871x_driver_data *drv = priv; printf("%s\n", __func__); blen = sizeof(*param) + key_len; buf = os_zalloc(blen); if (buf == NULL) return -1; param = (ieee_param *)buf; param->cmd = RTL871X_SET_ENCRYPTION; if (addr == NULL) memset(param->sta_addr, 0xff, ETH_ALEN); else memcpy(param->sta_addr, addr, ETH_ALEN); switch (alg) { case WPA_ALG_NONE: alg_str = "none"; break; case WPA_ALG_WEP: alg_str = "WEP"; break; case WPA_ALG_TKIP: alg_str = "TKIP"; break; case WPA_ALG_CCMP: alg_str = "CCMP"; break; default: printf("%s: unknown/unsupported algorithm %d\n", __func__, alg); return -1; } os_strlcpy((char *) param->u.crypt.alg, alg_str, IEEE_CRYPT_ALG_NAME_LEN); param->u.crypt.set_tx = txkey ? 1 : 0; param->u.crypt.idx = idx; param->u.crypt.key_len = key_len; memcpy(param->u.crypt.key, key, key_len); if (rtl871x_hostapd_ioctl(drv, param, blen)) { printf("Failed to set encryption.\n"); ret = -1; } os_free(buf); return ret; }
static int rtl871x_sta_add2_ops(const char *ifname, void *priv, struct hostapd_sta_add_params *params) { #if 0 ieee_param param; //int i, tx_supp_rates = 0; struct rtl871x_driver_data *drv = priv; printf("%s\n", __func__); memset(¶m, 0, sizeof(param)); param.cmd = RTL871X_HOSTAPD_ADD_STA; memcpy(param.sta_addr, params->addr, ETH_ALEN); param.u.add_sta.aid = params->aid; param.u.add_sta.capability = params->capability; param.u.add_sta.flags = params->flags; memcpy(param.u.add_sta.tx_supp_rates, params->supp_rates, params->supp_rates_len); /* for (i = 0; i < params->supp_rates_len; i++) { if ((params->supp_rates[i] & 0x7f) == IEEE80211_CCK_RATE_1MB) tx_supp_rates |= IEEE80211_CCK_RATE_1MB_MASK; if ((params->supp_rates[i] & 0x7f) == IEEE80211_CCK_RATE_2MB) tx_supp_rates |= IEEE80211_CCK_RATE_2MB_MASK; if ((params->supp_rates[i] & 0x7f) == IEEE80211_CCK_RATE_5MB) tx_supp_rates |= IEEE80211_CCK_RATE_5MB_MASK; if ((params->supp_rates[i] & 0x7f) == IEEE80211_CCK_RATE_11MB) tx_supp_rates |= IEEE80211_CCK_RATE_11MB_MASK; if ((params->supp_rates[i] & 0x7f) == IEEE80211_OFDM_RATE_6MB) tx_supp_rates |= IEEE80211_OFDM_RATE_6MB_MASK; if ((params->supp_rates[i] & 0x7f) == IEEE80211_OFDM_RATE_9MB) tx_supp_rates |= IEEE80211_OFDM_RATE_9MB_MASK; if ((params->supp_rates[i] & 0x7f) == IEEE80211_OFDM_RATE_12MB) tx_supp_rates |= IEEE80211_OFDM_RATE_12MB_MASK; if ((params->supp_rates[i] & 0x7f) == IEEE80211_OFDM_RATE_18MB) tx_supp_rates |= IEEE80211_OFDM_RATE_18MB_MASK; if ((params->supp_rates[i] & 0x7f) == IEEE80211_OFDM_RATE_24MB) tx_supp_rates |= IEEE80211_OFDM_RATE_24MB_MASK; if ((params->supp_rates[i] & 0x7f) == IEEE80211_OFDM_RATE_36MB) tx_supp_rates |= IEEE80211_OFDM_RATE_36MB_MASK; if ((params->supp_rates[i] & 0x7f) == IEEE80211_OFDM_RATE_48MB) tx_supp_rates |= IEEE80211_OFDM_RATE_48MB_MASK; if ((params->supp_rates[i] & 0x7f) == IEEE80211_OFDM_RATE_54MB) tx_supp_rates |= IEEE80211_OFDM_RATE_54MB_MASK; } param.u.add_sta.tx_supp_rates = tx_supp_rates; */ #ifdef CONFIG_IEEE80211N if (params->ht_capabilities && params->ht_capabilities->length>0) { struct ieee80211_ht_capability *pht_cap = (struct ieee80211_ht_capability *)¶ms->ht_capabilities->data; memcpy((u8*)¶m.u.add_sta.ht_cap, (u8*)pht_cap, sizeof(struct ieee80211_ht_capability)); } #endif /* CONFIG_IEEE80211N */ return rtl871x_hostapd_ioctl(drv, ¶m, sizeof(param)); #else return 0; #endif }