本文整理汇总了C++中set80211priv函数的典型用法代码示例。如果您正苦于以下问题:C++ set80211priv函数的具体用法?C++ set80211priv怎么用?C++ set80211priv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set80211priv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int
main(int argc, char *argv[])
{
const char *ifname = "ath0";
struct ieee80211req_key setkey;
struct ieee80211req_del_key delkey;
int c, keyix;
int op = IEEE80211_IOCTL_SETKEY;
progname = argv[0];
while ((c = getopt(argc, argv, "di:")) != -1)
switch (c) {
case 'd':
op = IEEE80211_IOCTL_DELKEY;
break;
case 'i':
ifname = optarg;
break;
default:
usage();
/*NOTREACHED*/
}
argc -= optind;
argv += optind;
if (argc < 1)
usage();
keyix = atoi(argv[0]);
if (!(1 <= keyix && keyix <= 4))
errx(-1, "%s: invalid key index %s, must be [1..4]",
progname, argv[0]);
switch (op) {
case IEEE80211_IOCTL_DELKEY:
memset(&delkey, 0, sizeof(delkey));
delkey.idk_keyix = keyix-1;
return set80211priv(ifname, op, &delkey, sizeof(delkey), 1);
case IEEE80211_IOCTL_SETKEY:
if (argc != 3 && argc != 4)
usage();
memset(&setkey, 0, sizeof(setkey));
setkey.ik_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV;
setkey.ik_keyix = keyix-1;
setkey.ik_type = getcipher(argv[1]);
setkey.ik_keylen = getdata(argv[2], setkey.ik_keydata,
sizeof(setkey.ik_keydata));
if (argc == 4)
(void) getdata(argv[3], setkey.ik_macaddr,
IEEE80211_ADDR_LEN);
return set80211priv(ifname, op, &setkey, sizeof(setkey), 1);
}
return -1;
}
示例2: atheros_del_key
static int
atheros_del_key(void *priv, const u8 *addr, int key_idx)
{
struct atheros_driver_data *drv = priv;
struct ieee80211req_del_key wk;
int ret;
wpa_printf(MSG_DEBUG, "%s: addr=%s key_idx=%d",
__func__, ether_sprintf(addr), key_idx);
memset(&wk, 0, sizeof(wk));
if (addr != NULL) {
memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
wk.idk_keyix = (u8) IEEE80211_KEYIX_NONE;
} else {
wk.idk_keyix = key_idx;
}
ret = set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk));
if (ret < 0) {
wpa_printf(MSG_DEBUG, "%s: Failed to delete key (addr %s"
" key_idx %d)", __func__, ether_sprintf(addr),
key_idx);
}
return ret;
}
示例3: atheros_read_sta_driver_data
static int
atheros_read_sta_driver_data(void *priv, struct hostap_sta_driver_data *data,
const u8 *addr)
{
struct atheros_driver_data *drv = priv;
struct ieee80211req_sta_stats stats;
memset(data, 0, sizeof(*data));
/*
* Fetch statistics for station from the system.
*/
memset(&stats, 0, sizeof(stats));
memcpy(stats.is_u.macaddr, addr, IEEE80211_ADDR_LEN);
if (set80211priv(drv, IEEE80211_IOCTL_STA_STATS,
&stats, sizeof(stats))) {
wpa_printf(MSG_DEBUG, "%s: Failed to fetch STA stats (addr "
MACSTR ")", __func__, MAC2STR(addr));
if (memcmp(addr, drv->acct_mac, ETH_ALEN) == 0) {
memcpy(data, &drv->acct_data, sizeof(*data));
return 0;
}
printf("Failed to get station stats information element.\n");
return -1;
}
data->rx_packets = stats.is_stats.ns_rx_data;
data->rx_bytes = stats.is_stats.ns_rx_bytes;
data->tx_packets = stats.is_stats.ns_tx_data;
data->tx_bytes = stats.is_stats.ns_tx_bytes;
return 0;
}
示例4: ar6000_set_wps_ie
static int
ar6000_set_wps_ie(void *priv, const u8 *iebuf, size_t len, u32 frametype)
{
struct ar6000_driver_data *drv = priv;
u8 buf[256];
struct ieee80211req_getset_appiebuf * ie;
((int *)buf)[0] = AR6000_XIOCTL_WMI_SET_APPIE;
ie = (struct ieee80211req_getset_appiebuf *) &buf[4];
ie->app_frmtype = frametype;
ie->app_buflen = len;
os_memcpy(&(ie->app_buf[0]), ie, len);
/* append the WPA/RSN IE if it is set already */
if (((frametype == IEEE80211_APPIE_FRAME_BEACON) ||
(frametype == IEEE80211_APPIE_FRAME_PROBE_RESP)) &&
(drv->wpa_ie != NULL)) {
os_memcpy(&(ie->app_buf[len]), wpabuf_head(drv->wpa_ie),
wpabuf_len(drv->wpa_ie));
ie->app_buflen += wpabuf_len(drv->wpa_ie);
}
return set80211priv(drv, AR6000_IOCTL_EXTENDED, buf,
sizeof(struct ieee80211req_getset_appiebuf) + len);
}
示例5: ar6000_set_sta_authorized
static int
ar6000_set_sta_authorized(void *priv, const u8 *addr, int authorized)
{
struct ar6000_driver_data *drv = priv;
struct ieee80211req_mlme mlme;
int ret;
wpa_printf(MSG_DEBUG, "%s: addr=%s authorized=%d\n",
__func__, ether_sprintf(addr), authorized);
if (authorized)
mlme.im_op = IEEE80211_MLME_AUTHORIZE;
else
mlme.im_op = IEEE80211_MLME_UNAUTHORIZE;
mlme.im_reason = 0;
memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme,
sizeof(mlme));
if (ret < 0) {
wpa_printf(MSG_DEBUG, "%s: Failed to %sauthorize STA " MACSTR,
__func__, authorized ? "" : "un", MAC2STR(addr));
}
return ret;
}
示例6: atheros_set_wps_ie
static int
atheros_set_wps_ie(void *priv, const u8 *ie, size_t len, u32 frametype)
{
struct atheros_driver_data *drv = priv;
u8 buf[512];
struct ieee80211req_getset_appiebuf *beac_ie;
wpa_printf(MSG_DEBUG, "%s buflen = %lu", __func__,
(unsigned long) len);
beac_ie = (struct ieee80211req_getset_appiebuf *) buf;
beac_ie->app_frmtype = frametype;
beac_ie->app_buflen = len;
os_memcpy(&(beac_ie->app_buf[0]), ie, len);
/* append the WPA/RSN IE if it is set already */
if (((frametype == IEEE80211_APPIE_FRAME_BEACON) ||
(frametype == IEEE80211_APPIE_FRAME_PROBE_RESP)) &&
(drv->wpa_ie != NULL)) {
os_memcpy(&(beac_ie->app_buf[len]), wpabuf_head(drv->wpa_ie),
wpabuf_len(drv->wpa_ie));
beac_ie->app_buflen += wpabuf_len(drv->wpa_ie);
}
return set80211priv(drv, IEEE80211_IOCTL_SET_APPIEBUF, beac_ie,
sizeof(struct ieee80211req_getset_appiebuf) +
beac_ie->app_buflen);
}
示例7: wpa_driver_realtek_set_probe_req_ie
static int wpa_driver_realtek_set_probe_req_ie(void *priv, const u8 *ies,
size_t ies_len)
{
struct ieee80211req_getset_appiebuf *probe_req_ie;
int ret;
printf("Wpa_supplicant: %s +++\n", __FUNCTION__);
probe_req_ie = os_malloc(sizeof(*probe_req_ie) + ies_len);
if (probe_req_ie == NULL)
return -1;
probe_req_ie->app_frmtype = IEEE80211_APPIE_FRAME_PROBE_REQ;
probe_req_ie->app_buflen = ies_len;
os_memcpy(probe_req_ie->app_buf, ies, ies_len);
#ifdef RTK_INBAND_LE
probe_req_ie->app_frmtype = htonl(probe_req_ie->app_frmtype);
probe_req_ie->app_buflen = htonl(probe_req_ie->app_buflen);
#endif
ret = set80211priv(priv, IEEE80211_IOCTL_SET_APPIEBUF, probe_req_ie,
sizeof(struct ieee80211req_getset_appiebuf) +
ies_len, 1);
os_free(probe_req_ie);
return ret;
}
示例8: wpa_driver_madwifi_set_key
static int
wpa_driver_madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
const u8 *addr, int key_idx, int set_tx,
const u8 *seq, size_t seq_len,
const u8 *key, size_t key_len)
{
struct madwifi_driver_data *drv = priv;
struct ieee80211req_key wk;
u_int8_t cipher;
int ret;
if (alg == WPA_ALG_NONE)
return madwifi_del_key(drv, addr, key_idx);
wpa_printf(MSG_DEBUG, "%s: alg=%d addr=%s key_idx=%d",
__func__, alg, ether_sprintf(addr), key_idx);
if (alg == WPA_ALG_WEP)
cipher = IEEE80211_CIPHER_WEP;
else if (alg == WPA_ALG_TKIP)
cipher = IEEE80211_CIPHER_TKIP;
else if (alg == WPA_ALG_CCMP)
cipher = IEEE80211_CIPHER_AES_CCM;
else {
printf("%s: unknown/unsupported algorithm %d\n",
__func__, alg);
return -1;
}
if (key_len > sizeof(wk.ik_keydata)) {
printf("%s: key length %lu too big\n", __func__,
(unsigned long) key_len);
return -3;
}
memset(&wk, 0, sizeof(wk));
wk.ik_type = cipher;
wk.ik_flags = IEEE80211_KEY_RECV | IEEE80211_KEY_XMIT;
if (addr == NULL || is_broadcast_ether_addr(addr)) {
memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
wk.ik_keyix = key_idx;
wk.ik_flags |= IEEE80211_KEY_DEFAULT;
} else {
memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
wk.ik_keyix = IEEE80211_KEYIX_NONE;
}
wk.ik_keylen = key_len;
memcpy(wk.ik_keydata, key, key_len);
ret = set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk));
if (ret < 0) {
wpa_printf(MSG_DEBUG, "%s: Failed to set key (addr %s"
" key_idx %d alg %d key_len %lu set_tx %d)",
__func__, ether_sprintf(wk.ik_macaddr), key_idx,
alg, (unsigned long) key_len, set_tx);
}
return ret;
}
示例9: madwifi_set_key
static int
madwifi_set_key(const char *ifname, void *priv, const char *alg,
const u8 *addr, int key_idx,
const u8 *key, size_t key_len, int txkey)
{
struct madwifi_driver_data *drv = priv;
struct ieee80211req_key wk;
u_int8_t cipher;
int ret;
if (strcmp(alg, "none") == 0)
return madwifi_del_key(drv, addr, key_idx);
wpa_printf(MSG_DEBUG, "%s: alg=%s addr=%s key_idx=%d",
__func__, alg, ether_sprintf(addr), key_idx);
if (strcmp(alg, "WEP") == 0)
cipher = IEEE80211_CIPHER_WEP;
else if (strcmp(alg, "TKIP") == 0)
cipher = IEEE80211_CIPHER_TKIP;
else if (strcmp(alg, "CCMP") == 0)
cipher = IEEE80211_CIPHER_AES_CCM;
else {
printf("%s: unknown/unsupported algorithm %s\n",
__func__, alg);
return -1;
}
if (key_len > sizeof(wk.ik_keydata)) {
printf("%s: key length %lu too big\n", __func__,
(unsigned long) key_len);
return -3;
}
memset(&wk, 0, sizeof(wk));
wk.ik_type = cipher;
wk.ik_flags = IEEE80211_KEY_RECV | IEEE80211_KEY_XMIT;
if (addr == NULL) {
memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
wk.ik_keyix = key_idx;
wk.ik_flags |= IEEE80211_KEY_DEFAULT;
} else {
memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
wk.ik_keyix = IEEE80211_KEYIX_NONE;
}
wk.ik_keylen = key_len;
memcpy(wk.ik_keydata, key, key_len);
ret = set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk));
if (ret < 0) {
wpa_printf(MSG_DEBUG, "%s: Failed to set key (addr %s"
" key_idx %d alg '%s' key_len %lu txkey %d)",
__func__, ether_sprintf(wk.ik_macaddr), key_idx,
alg, (unsigned long) key_len, txkey);
}
return ret;
}
示例10: atheros_set_opt_ie
static int
atheros_set_opt_ie(void *priv, const u8 *ie, size_t ie_len)
{
struct atheros_driver_data *drv = priv;
u8 buf[512];
struct ieee80211req_getset_appiebuf *app_ie;
wpa_printf(MSG_DEBUG, "%s buflen = %lu", __func__,
(unsigned long) ie_len);
wpabuf_free(drv->wpa_ie);
drv->wpa_ie = wpabuf_alloc_copy(ie, ie_len);
app_ie = (struct ieee80211req_getset_appiebuf *) buf;
os_memcpy(&(app_ie->app_buf[0]), ie, ie_len);
app_ie->app_buflen = ie_len;
app_ie->app_frmtype = IEEE80211_APPIE_FRAME_BEACON;
/* append WPS IE for Beacon */
if (drv->wps_beacon_ie != NULL) {
os_memcpy(&(app_ie->app_buf[ie_len]),
wpabuf_head(drv->wps_beacon_ie),
wpabuf_len(drv->wps_beacon_ie));
app_ie->app_buflen = ie_len + wpabuf_len(drv->wps_beacon_ie);
}
set80211priv(drv, IEEE80211_IOCTL_SET_APPIEBUF, app_ie,
sizeof(struct ieee80211req_getset_appiebuf) +
app_ie->app_buflen);
/* append WPS IE for Probe Response */
app_ie->app_frmtype = IEEE80211_APPIE_FRAME_PROBE_RESP;
if (drv->wps_probe_resp_ie != NULL) {
os_memcpy(&(app_ie->app_buf[ie_len]),
wpabuf_head(drv->wps_probe_resp_ie),
wpabuf_len(drv->wps_probe_resp_ie));
app_ie->app_buflen = ie_len +
wpabuf_len(drv->wps_probe_resp_ie);
} else
app_ie->app_buflen = ie_len;
set80211priv(drv, IEEE80211_IOCTL_SET_APPIEBUF, app_ie,
sizeof(struct ieee80211req_getset_appiebuf) +
app_ie->app_buflen);
return 0;
}
示例11: sta_deauth
/*解除链路验证*/
int sta_deauth(u8 *addr, int reason_code, apdata_info *pap)
{
struct ieee80211req_mlme mlme;
DPrintf("[WAPID]:: deauth STA("MACSTR")\n", MAC2STR(addr));
mlme.im_op = IEEE80211_MLME_DEAUTH;
mlme.im_reason = reason_code;
memcpy(mlme.im_macaddr, addr, WLAN_ADDR_LEN);
return set80211priv(pap, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
}
示例12: madwifi_process_wpa_ie
static int
madwifi_process_wpa_ie(struct madwifi_driver_data *drv, struct sta_info *sta)
{
struct hostapd_data *hapd = drv->hapd;
struct ieee80211req_wpaie ie;
int ielen, res;
u8 *iebuf;
/*
* Fetch negotiated WPA/RSN parameters from the system.
*/
memset(&ie, 0, sizeof(ie));
memcpy(ie.wpa_macaddr, sta->addr, IEEE80211_ADDR_LEN);
if (set80211priv(drv, IEEE80211_IOCTL_GETWPAIE, &ie, sizeof(ie))) {
wpa_printf(MSG_ERROR, "%s: Failed to get WPA/RSN IE",
__func__);
printf("Failed to get WPA/RSN information element.\n");
return -1; /* XXX not right */
}
wpa_hexdump(MSG_MSGDUMP, "madwifi req WPA IE",
ie.wpa_ie, IEEE80211_MAX_OPT_IE);
wpa_hexdump(MSG_MSGDUMP, "madwifi req RSN IE",
ie.rsn_ie, IEEE80211_MAX_OPT_IE);
iebuf = ie.wpa_ie;
/* madwifi seems to return some random data if WPA/RSN IE is not set.
* Assume the IE was not included if the IE type is unknown. */
if (iebuf[0] != WLAN_EID_VENDOR_SPECIFIC)
iebuf[1] = 0;
#ifdef MADWIFI_NG
if (iebuf[1] == 0 && ie.rsn_ie[1] > 0) {
/* madwifi-ng svn #1453 added rsn_ie. Use it, if wpa_ie was not
* set. This is needed for WPA2. */
iebuf = ie.rsn_ie;
if (iebuf[0] != WLAN_EID_RSN)
iebuf[1] = 0;
}
#endif /* MADWIFI_NG */
ielen = iebuf[1];
if (ielen == 0) {
printf("No WPA/RSN information element for station!?\n");
return -1; /* XXX not right */
}
ielen += 2;
if (sta->wpa_sm == NULL)
sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, sta->addr);
if (sta->wpa_sm == NULL) {
printf("Failed to initialize WPA state machine\n");
return -1;
}
res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm,
iebuf, ielen, NULL, 0);
if (res != WPA_IE_OK) {
printf("WPA/RSN information element rejected? (res %u)\n", res);
return -1;
}
return 0;
}
示例13: wpa_driver_madwifi_associate
static int
wpa_driver_madwifi_associate(void *priv,
struct wpa_driver_associate_params *params)
{
struct wpa_driver_madwifi_data *drv = priv;
struct ieee80211req_mlme mlme;
int ret = 0, privacy = 1;
wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
/*
* NB: Don't need to set the freq or cipher-related state as
* this is implied by the bssid which is used to locate
* the scanned node state which holds it. The ssid is
* needed to disambiguate an AP that broadcasts multiple
* ssid's but uses the same bssid.
*/
/* XXX error handling is wrong but unclear what to do... */
if (wpa_driver_madwifi_set_wpa_ie(drv, params->wpa_ie,
params->wpa_ie_len) < 0)
ret = -1;
if (params->pairwise_suite == CIPHER_NONE &&
params->group_suite == CIPHER_NONE &&
params->key_mgmt_suite == KEY_MGMT_NONE &&
params->wpa_ie_len == 0)
privacy = 0;
if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy, 1) < 0)
ret = -1;
if (params->bssid == NULL) {
/* ap_scan=2 mode - driver takes care of AP selection and
* roaming */
/* FIX: this does not seem to work; would probably need to
* change something in the driver */
if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0, 1) < 0)
ret = -1;
}
if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
params->ssid_len) < 0)
ret = -1;
if (params->bssid) {
if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0)
ret = -1;
memset(&mlme, 0, sizeof(mlme));
mlme.im_op = IEEE80211_MLME_ASSOC;
memcpy(mlme.im_macaddr, params->bssid, IEEE80211_ADDR_LEN);
if (set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme,
sizeof(mlme), 1) < 0)
ret = -1;
}
return ret;
}
示例14: wpa_driver_realtek_associate
static int
wpa_driver_realtek_associate(void *priv,
struct wpa_driver_associate_params *params)
{
struct wpa_driver_realtek_data *drv = priv;
struct ieee80211req_mlme mlme;
int ret = 0, privacy = 1;
printf("Wpa_supplicant: %s +++\n", __FUNCTION__);
wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
//_Eric ?? if ret = -1, why still run continuously?
if(realtek_config_security(drv, params) < 0)
ret = -9;
if (params->bssid == NULL) {
//_Eric ?? it means no MAC but have SSID(name), driver shall try to find this AP automatically?
if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0, 1) < 0)
ret = -2;
if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
params->ssid_len) < 0)
ret = -3;
} else {
if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0)
ret = -4;
if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
params->ssid_len) < 0)
ret = -5;
os_memset(&mlme, 0, sizeof(mlme));
mlme.im_op = IEEE80211_MLME_ASSOC;
os_memcpy(mlme.im_macaddr, params->bssid, IEEE80211_ADDR_LEN);
printf("Try to assoc %02x:%02x:%02x:%02x:%02x:%02x \n",
params->bssid[0], params->bssid[1], params->bssid[2],
params->bssid[3], params->bssid[4], params->bssid[5]);
if (set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme,
sizeof(mlme), 1) < 0) {
wpa_printf(MSG_DEBUG, "%s: SETMLME[ASSOC] failed",
__func__);
ret = -1;
}
}
printf("Wpa_supplicant: %s --- ret = %d\n", __FUNCTION__, ret);
return ret;
}
示例15: madwifi_new_sta
static void
madwifi_new_sta(struct madwifi_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
{
struct hostapd_data *hapd = drv->hapd;
struct ieee80211req_wpaie ie;
int ielen = 0;
u8 *iebuf = NULL;
/*
* Fetch negotiated WPA/RSN parameters from the system.
*/
memset(&ie, 0, sizeof(ie));
memcpy(ie.wpa_macaddr, addr, IEEE80211_ADDR_LEN);
if (set80211priv(drv, IEEE80211_IOCTL_GETWPAIE, &ie, sizeof(ie))) {
/*
* See ATH_WPS_IE comment in the beginning of the file for a
* possible cause for the failure..
*/
wpa_printf(MSG_DEBUG, "%s: Failed to get WPA/RSN IE: %s",
__func__, strerror(errno));
goto no_ie;
}
wpa_hexdump(MSG_MSGDUMP, "madwifi req WPA IE",
ie.wpa_ie, IEEE80211_MAX_OPT_IE);
wpa_hexdump(MSG_MSGDUMP, "madwifi req RSN IE",
ie.rsn_ie, IEEE80211_MAX_OPT_IE);
iebuf = ie.wpa_ie;
/* madwifi seems to return some random data if WPA/RSN IE is not set.
* Assume the IE was not included if the IE type is unknown. */
if (iebuf[0] != WLAN_EID_VENDOR_SPECIFIC)
iebuf[1] = 0;
if (iebuf[1] == 0 && ie.rsn_ie[1] > 0) {
/* madwifi-ng svn #1453 added rsn_ie. Use it, if wpa_ie was not
* set. This is needed for WPA2. */
iebuf = ie.rsn_ie;
if (iebuf[0] != WLAN_EID_RSN)
iebuf[1] = 0;
}
ielen = iebuf[1];
if (ielen == 0)
iebuf = NULL;
else
ielen += 2;
no_ie:
drv_event_assoc(hapd, addr, iebuf, ielen);
if (memcmp(addr, drv->acct_mac, ETH_ALEN) == 0) {
/* Cached accounting data is not valid anymore. */
memset(drv->acct_mac, 0, ETH_ALEN);
memset(&drv->acct_data, 0, sizeof(drv->acct_data));
}
}