atheros: Unify memory processing functions
There are two types of memory processing functions in the file atheros_driver.c, such as memory and os_memory. Unify the processing functions into one type which has the prefix "os_". Signed-off-by: Matt Woods <matt.woods@aliyun.com>
This commit is contained in:
parent
d386a9ace8
commit
47c1de20a4
1 changed files with 66 additions and 66 deletions
|
@ -189,13 +189,13 @@ set80211priv(struct atheros_driver_data *drv, int op, void *data, int len)
|
||||||
op == IEEE80211_IOCTL_FILTERFRAME)
|
op == IEEE80211_IOCTL_FILTERFRAME)
|
||||||
do_inline = 0;
|
do_inline = 0;
|
||||||
|
|
||||||
memset(&iwr, 0, sizeof(iwr));
|
os_memset(&iwr, 0, sizeof(iwr));
|
||||||
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
||||||
if (do_inline) {
|
if (do_inline) {
|
||||||
/*
|
/*
|
||||||
* Argument data fits inline; put it there.
|
* Argument data fits inline; put it there.
|
||||||
*/
|
*/
|
||||||
memcpy(iwr.u.name, data, len);
|
os_memcpy(iwr.u.name, data, len);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Argument data too big for inline transfer; setup a
|
* Argument data too big for inline transfer; setup a
|
||||||
|
@ -222,10 +222,10 @@ set80211param(struct atheros_driver_data *drv, int op, int arg)
|
||||||
{
|
{
|
||||||
struct iwreq iwr;
|
struct iwreq iwr;
|
||||||
|
|
||||||
memset(&iwr, 0, sizeof(iwr));
|
os_memset(&iwr, 0, sizeof(iwr));
|
||||||
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
||||||
iwr.u.mode = op;
|
iwr.u.mode = op;
|
||||||
memcpy(iwr.u.name+sizeof(__u32), &arg, sizeof(arg));
|
os_memcpy(iwr.u.name + sizeof(__u32), &arg, sizeof(arg));
|
||||||
|
|
||||||
if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_SETPARAM, &iwr) < 0) {
|
if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_SETPARAM, &iwr) < 0) {
|
||||||
wpa_printf(MSG_INFO,
|
wpa_printf(MSG_INFO,
|
||||||
|
@ -244,9 +244,9 @@ ether_sprintf(const u8 *addr)
|
||||||
static char buf[sizeof(MACSTR)];
|
static char buf[sizeof(MACSTR)];
|
||||||
|
|
||||||
if (addr != NULL)
|
if (addr != NULL)
|
||||||
snprintf(buf, sizeof(buf), MACSTR, MAC2STR(addr));
|
os_snprintf(buf, sizeof(buf), MACSTR, MAC2STR(addr));
|
||||||
else
|
else
|
||||||
snprintf(buf, sizeof(buf), MACSTR, 0,0,0,0,0,0);
|
os_snprintf(buf, sizeof(buf), MACSTR, 0, 0, 0, 0, 0, 0);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NO_STDOUT_DEBUG */
|
#endif /* CONFIG_NO_STDOUT_DEBUG */
|
||||||
|
@ -422,7 +422,7 @@ atheros_set_sta_authorized(void *priv, const u8 *addr, int authorized)
|
||||||
else
|
else
|
||||||
mlme.im_op = IEEE80211_MLME_UNAUTHORIZE;
|
mlme.im_op = IEEE80211_MLME_UNAUTHORIZE;
|
||||||
mlme.im_reason = 0;
|
mlme.im_reason = 0;
|
||||||
memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
|
os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
|
||||||
ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
|
ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wpa_printf(MSG_DEBUG, "%s: Failed to %sauthorize STA " MACSTR,
|
wpa_printf(MSG_DEBUG, "%s: Failed to %sauthorize STA " MACSTR,
|
||||||
|
@ -455,9 +455,9 @@ atheros_del_key(void *priv, const u8 *addr, int key_idx)
|
||||||
wpa_printf(MSG_DEBUG, "%s: addr=%s key_idx=%d",
|
wpa_printf(MSG_DEBUG, "%s: addr=%s key_idx=%d",
|
||||||
__func__, ether_sprintf(addr), key_idx);
|
__func__, ether_sprintf(addr), key_idx);
|
||||||
|
|
||||||
memset(&wk, 0, sizeof(wk));
|
os_memset(&wk, 0, sizeof(wk));
|
||||||
if (addr != NULL) {
|
if (addr != NULL) {
|
||||||
memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
|
os_memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
|
||||||
wk.idk_keyix = (u8) IEEE80211_KEYIX_NONE;
|
wk.idk_keyix = (u8) IEEE80211_KEYIX_NONE;
|
||||||
} else {
|
} else {
|
||||||
wk.idk_keyix = key_idx;
|
wk.idk_keyix = key_idx;
|
||||||
|
@ -538,20 +538,20 @@ atheros_set_key(const char *ifname, void *priv, enum wpa_alg alg,
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&wk, 0, sizeof(wk));
|
os_memset(&wk, 0, sizeof(wk));
|
||||||
wk.ik_type = cipher;
|
wk.ik_type = cipher;
|
||||||
wk.ik_flags = IEEE80211_KEY_RECV | IEEE80211_KEY_XMIT;
|
wk.ik_flags = IEEE80211_KEY_RECV | IEEE80211_KEY_XMIT;
|
||||||
if (addr == NULL || is_broadcast_ether_addr(addr)) {
|
if (addr == NULL || is_broadcast_ether_addr(addr)) {
|
||||||
memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
|
os_memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
|
||||||
wk.ik_keyix = key_idx;
|
wk.ik_keyix = key_idx;
|
||||||
if (set_tx)
|
if (set_tx)
|
||||||
wk.ik_flags |= IEEE80211_KEY_DEFAULT;
|
wk.ik_flags |= IEEE80211_KEY_DEFAULT;
|
||||||
} else {
|
} else {
|
||||||
memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
|
os_memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
|
||||||
wk.ik_keyix = IEEE80211_KEYIX_NONE;
|
wk.ik_keyix = IEEE80211_KEYIX_NONE;
|
||||||
}
|
}
|
||||||
wk.ik_keylen = key_len;
|
wk.ik_keylen = key_len;
|
||||||
memcpy(wk.ik_keydata, key, key_len);
|
os_memcpy(wk.ik_keydata, key, key_len);
|
||||||
|
|
||||||
ret = set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk));
|
ret = set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -575,11 +575,11 @@ atheros_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
|
||||||
wpa_printf(MSG_DEBUG, "%s: addr=%s idx=%d",
|
wpa_printf(MSG_DEBUG, "%s: addr=%s idx=%d",
|
||||||
__func__, ether_sprintf(addr), idx);
|
__func__, ether_sprintf(addr), idx);
|
||||||
|
|
||||||
memset(&wk, 0, sizeof(wk));
|
os_memset(&wk, 0, sizeof(wk));
|
||||||
if (addr == NULL)
|
if (addr == NULL)
|
||||||
memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
|
os_memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
|
||||||
else
|
else
|
||||||
memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
|
os_memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
|
||||||
wk.ik_keyix = idx;
|
wk.ik_keyix = idx;
|
||||||
|
|
||||||
if (set80211priv(drv, IEEE80211_IOCTL_GETKEY, &wk, sizeof(wk))) {
|
if (set80211priv(drv, IEEE80211_IOCTL_GETKEY, &wk, sizeof(wk))) {
|
||||||
|
@ -600,13 +600,13 @@ atheros_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
|
||||||
#define WPA_KEY_RSC_LEN 8
|
#define WPA_KEY_RSC_LEN 8
|
||||||
#endif
|
#endif
|
||||||
u8 tmp[WPA_KEY_RSC_LEN];
|
u8 tmp[WPA_KEY_RSC_LEN];
|
||||||
memcpy(tmp, &wk.ik_keytsc, sizeof(wk.ik_keytsc));
|
os_memcpy(tmp, &wk.ik_keytsc, sizeof(wk.ik_keytsc));
|
||||||
for (i = 0; i < WPA_KEY_RSC_LEN; i++) {
|
for (i = 0; i < WPA_KEY_RSC_LEN; i++) {
|
||||||
seq[i] = tmp[WPA_KEY_RSC_LEN - i - 1];
|
seq[i] = tmp[WPA_KEY_RSC_LEN - i - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else /* WORDS_BIGENDIAN */
|
#else /* WORDS_BIGENDIAN */
|
||||||
memcpy(seq, &wk.ik_keytsc, sizeof(wk.ik_keytsc));
|
os_memcpy(seq, &wk.ik_keytsc, sizeof(wk.ik_keytsc));
|
||||||
#endif /* WORDS_BIGENDIAN */
|
#endif /* WORDS_BIGENDIAN */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -616,7 +616,7 @@ static int
|
||||||
atheros_flush(void *priv)
|
atheros_flush(void *priv)
|
||||||
{
|
{
|
||||||
u8 allsta[IEEE80211_ADDR_LEN];
|
u8 allsta[IEEE80211_ADDR_LEN];
|
||||||
memset(allsta, 0xff, IEEE80211_ADDR_LEN);
|
os_memset(allsta, 0xff, IEEE80211_ADDR_LEN);
|
||||||
return atheros_sta_deauth(priv, NULL, allsta,
|
return atheros_sta_deauth(priv, NULL, allsta,
|
||||||
IEEE80211_REASON_AUTH_LEAVE);
|
IEEE80211_REASON_AUTH_LEAVE);
|
||||||
}
|
}
|
||||||
|
@ -629,19 +629,19 @@ atheros_read_sta_driver_data(void *priv, struct hostap_sta_driver_data *data,
|
||||||
struct atheros_driver_data *drv = priv;
|
struct atheros_driver_data *drv = priv;
|
||||||
struct ieee80211req_sta_stats stats;
|
struct ieee80211req_sta_stats stats;
|
||||||
|
|
||||||
memset(data, 0, sizeof(*data));
|
os_memset(data, 0, sizeof(*data));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fetch statistics for station from the system.
|
* Fetch statistics for station from the system.
|
||||||
*/
|
*/
|
||||||
memset(&stats, 0, sizeof(stats));
|
os_memset(&stats, 0, sizeof(stats));
|
||||||
memcpy(stats.is_u.macaddr, addr, IEEE80211_ADDR_LEN);
|
os_memcpy(stats.is_u.macaddr, addr, IEEE80211_ADDR_LEN);
|
||||||
if (set80211priv(drv, IEEE80211_IOCTL_STA_STATS,
|
if (set80211priv(drv, IEEE80211_IOCTL_STA_STATS,
|
||||||
&stats, sizeof(stats))) {
|
&stats, sizeof(stats))) {
|
||||||
wpa_printf(MSG_DEBUG, "%s: Failed to fetch STA stats (addr "
|
wpa_printf(MSG_DEBUG, "%s: Failed to fetch STA stats (addr "
|
||||||
MACSTR ")", __func__, MAC2STR(addr));
|
MACSTR ")", __func__, MAC2STR(addr));
|
||||||
if (memcmp(addr, drv->acct_mac, ETH_ALEN) == 0) {
|
if (os_memcmp(addr, drv->acct_mac, ETH_ALEN) == 0) {
|
||||||
memcpy(data, &drv->acct_data, sizeof(*data));
|
os_memcpy(data, &drv->acct_data, sizeof(*data));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -668,7 +668,7 @@ atheros_sta_clear_stats(void *priv, const u8 *addr)
|
||||||
wpa_printf(MSG_DEBUG, "%s: addr=%s", __func__, ether_sprintf(addr));
|
wpa_printf(MSG_DEBUG, "%s: addr=%s", __func__, ether_sprintf(addr));
|
||||||
|
|
||||||
mlme.im_op = IEEE80211_MLME_CLEAR_STATS;
|
mlme.im_op = IEEE80211_MLME_CLEAR_STATS;
|
||||||
memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
|
os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
|
||||||
ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme,
|
ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme,
|
||||||
sizeof(mlme));
|
sizeof(mlme));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -744,7 +744,7 @@ atheros_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
|
||||||
|
|
||||||
mlme.im_op = IEEE80211_MLME_DEAUTH;
|
mlme.im_op = IEEE80211_MLME_DEAUTH;
|
||||||
mlme.im_reason = reason_code;
|
mlme.im_reason = reason_code;
|
||||||
memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
|
os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
|
||||||
ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
|
ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wpa_printf(MSG_DEBUG, "%s: Failed to deauth STA (addr " MACSTR
|
wpa_printf(MSG_DEBUG, "%s: Failed to deauth STA (addr " MACSTR
|
||||||
|
@ -768,7 +768,7 @@ atheros_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr,
|
||||||
|
|
||||||
mlme.im_op = IEEE80211_MLME_DISASSOC;
|
mlme.im_op = IEEE80211_MLME_DISASSOC;
|
||||||
mlme.im_reason = reason_code;
|
mlme.im_reason = reason_code;
|
||||||
memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
|
os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
|
||||||
ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
|
ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wpa_printf(MSG_DEBUG, "%s: Failed to disassoc STA (addr "
|
wpa_printf(MSG_DEBUG, "%s: Failed to disassoc STA (addr "
|
||||||
|
@ -794,7 +794,7 @@ static int atheros_set_qos_map(void *ctx, const u8 *qos_map_set,
|
||||||
wpa_printf(MSG_ERROR, "Invalid QoS Map");
|
wpa_printf(MSG_ERROR, "Invalid QoS Map");
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
memset(&req, 0, sizeof(struct ieee80211req_athdbg));
|
os_memset(&req, 0, sizeof(struct ieee80211req_athdbg));
|
||||||
req.cmd = IEEE80211_DBGREQ_SETQOSMAPCONF;
|
req.cmd = IEEE80211_DBGREQ_SETQOSMAPCONF;
|
||||||
os_memset(&iwr, 0, sizeof(iwr));
|
os_memset(&iwr, 0, sizeof(iwr));
|
||||||
os_strlcpy(iwr.ifr_name, drv->iface, sizeof(iwr.ifr_name));
|
os_strlcpy(iwr.ifr_name, drv->iface, sizeof(iwr.ifr_name));
|
||||||
|
@ -1120,8 +1120,8 @@ atheros_new_sta(struct atheros_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
|
||||||
/*
|
/*
|
||||||
* Fetch negotiated WPA/RSN parameters from the system.
|
* Fetch negotiated WPA/RSN parameters from the system.
|
||||||
*/
|
*/
|
||||||
memset(&ie, 0, sizeof(ie));
|
os_memset(&ie, 0, sizeof(ie));
|
||||||
memcpy(ie.wpa_macaddr, addr, IEEE80211_ADDR_LEN);
|
os_memcpy(ie.wpa_macaddr, addr, IEEE80211_ADDR_LEN);
|
||||||
if (set80211priv(drv, IEEE80211_IOCTL_GETWPAIE, &ie, sizeof(ie))) {
|
if (set80211priv(drv, IEEE80211_IOCTL_GETWPAIE, &ie, sizeof(ie))) {
|
||||||
/*
|
/*
|
||||||
* See ATH_WPS_IE comment in the beginning of the file for a
|
* See ATH_WPS_IE comment in the beginning of the file for a
|
||||||
|
@ -1171,10 +1171,10 @@ atheros_new_sta(struct atheros_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
|
||||||
no_ie:
|
no_ie:
|
||||||
drv_event_assoc(hapd, addr, iebuf, ielen, 0);
|
drv_event_assoc(hapd, addr, iebuf, ielen, 0);
|
||||||
|
|
||||||
if (memcmp(addr, drv->acct_mac, ETH_ALEN) == 0) {
|
if (os_memcmp(addr, drv->acct_mac, ETH_ALEN) == 0) {
|
||||||
/* Cached accounting data is not valid anymore. */
|
/* Cached accounting data is not valid anymore. */
|
||||||
memset(drv->acct_mac, 0, ETH_ALEN);
|
os_memset(drv->acct_mac, 0, ETH_ALEN);
|
||||||
memset(&drv->acct_data, 0, sizeof(drv->acct_data));
|
os_memset(&drv->acct_data, 0, sizeof(drv->acct_data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1185,10 +1185,10 @@ atheros_wireless_event_wireless_custom(struct atheros_driver_data *drv,
|
||||||
#define MGMT_FRAM_TAG_SIZE 30 /* hardcoded in driver */
|
#define MGMT_FRAM_TAG_SIZE 30 /* hardcoded in driver */
|
||||||
wpa_printf(MSG_DEBUG, "Custom wireless event: '%s'", custom);
|
wpa_printf(MSG_DEBUG, "Custom wireless event: '%s'", custom);
|
||||||
|
|
||||||
if (strncmp(custom, "MLME-MICHAELMICFAILURE.indication", 33) == 0) {
|
if (os_strncmp(custom, "MLME-MICHAELMICFAILURE.indication", 33) == 0) {
|
||||||
char *pos;
|
char *pos;
|
||||||
u8 addr[ETH_ALEN];
|
u8 addr[ETH_ALEN];
|
||||||
pos = strstr(custom, "addr=");
|
pos = os_strstr(custom, "addr=");
|
||||||
if (pos == NULL) {
|
if (pos == NULL) {
|
||||||
wpa_printf(MSG_DEBUG,
|
wpa_printf(MSG_DEBUG,
|
||||||
"MLME-MICHAELMICFAILURE.indication "
|
"MLME-MICHAELMICFAILURE.indication "
|
||||||
|
@ -1212,33 +1212,33 @@ atheros_wireless_event_wireless_custom(struct atheros_driver_data *drv,
|
||||||
char *key, *value;
|
char *key, *value;
|
||||||
u32 val;
|
u32 val;
|
||||||
key = custom;
|
key = custom;
|
||||||
while ((key = strchr(key, '\n')) != NULL) {
|
while ((key = os_strchr(key, '\n')) != NULL) {
|
||||||
key++;
|
key++;
|
||||||
value = strchr(key, '=');
|
value = os_strchr(key, '=');
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
continue;
|
continue;
|
||||||
*value++ = '\0';
|
*value++ = '\0';
|
||||||
val = strtoul(value, NULL, 10);
|
val = strtoul(value, NULL, 10);
|
||||||
if (strcmp(key, "mac") == 0)
|
if (os_strcmp(key, "mac") == 0)
|
||||||
hwaddr_aton(value, drv->acct_mac);
|
hwaddr_aton(value, drv->acct_mac);
|
||||||
else if (strcmp(key, "rx_packets") == 0)
|
else if (os_strcmp(key, "rx_packets") == 0)
|
||||||
drv->acct_data.rx_packets = val;
|
drv->acct_data.rx_packets = val;
|
||||||
else if (strcmp(key, "tx_packets") == 0)
|
else if (os_strcmp(key, "tx_packets") == 0)
|
||||||
drv->acct_data.tx_packets = val;
|
drv->acct_data.tx_packets = val;
|
||||||
else if (strcmp(key, "rx_bytes") == 0)
|
else if (os_strcmp(key, "rx_bytes") == 0)
|
||||||
drv->acct_data.rx_bytes = val;
|
drv->acct_data.rx_bytes = val;
|
||||||
else if (strcmp(key, "tx_bytes") == 0)
|
else if (os_strcmp(key, "tx_bytes") == 0)
|
||||||
drv->acct_data.tx_bytes = val;
|
drv->acct_data.tx_bytes = val;
|
||||||
key = value;
|
key = value;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_WPS
|
#ifdef CONFIG_WPS
|
||||||
} else if (strncmp(custom, "PUSH-BUTTON.indication", 22) == 0) {
|
} else if (os_strncmp(custom, "PUSH-BUTTON.indication", 22) == 0) {
|
||||||
/* Some atheros kernels send push button as a wireless event */
|
/* Some atheros kernels send push button as a wireless event */
|
||||||
/* PROBLEM! this event is received for ALL BSSs ...
|
/* PROBLEM! this event is received for ALL BSSs ...
|
||||||
* so all are enabled for WPS... ugh.
|
* so all are enabled for WPS... ugh.
|
||||||
*/
|
*/
|
||||||
wpa_supplicant_event(drv->hapd, EVENT_WPS_BUTTON_PUSHED, NULL);
|
wpa_supplicant_event(drv->hapd, EVENT_WPS_BUTTON_PUSHED, NULL);
|
||||||
} else if (strncmp(custom, "Manage.prob_req ", 16) == 0) {
|
} else if (os_strncmp(custom, "Manage.prob_req ", 16) == 0) {
|
||||||
/*
|
/*
|
||||||
* Atheros driver uses a hack to pass Probe Request frames as a
|
* Atheros driver uses a hack to pass Probe Request frames as a
|
||||||
* binary data in the custom wireless event. The old way (using
|
* binary data in the custom wireless event. The old way (using
|
||||||
|
@ -1255,7 +1255,7 @@ atheros_wireless_event_wireless_custom(struct atheros_driver_data *drv,
|
||||||
(u8 *) custom + MGMT_FRAM_TAG_SIZE, len);
|
(u8 *) custom + MGMT_FRAM_TAG_SIZE, len);
|
||||||
#endif /* CONFIG_WPS */
|
#endif /* CONFIG_WPS */
|
||||||
#if defined(CONFIG_IEEE80211R) || defined(CONFIG_IEEE80211W)
|
#if defined(CONFIG_IEEE80211R) || defined(CONFIG_IEEE80211W)
|
||||||
} else if (strncmp(custom, "Manage.assoc_req ", 17) == 0) {
|
} else if (os_strncmp(custom, "Manage.assoc_req ", 17) == 0) {
|
||||||
/* Format: "Manage.assoc_req <frame len>" | zero padding |
|
/* Format: "Manage.assoc_req <frame len>" | zero padding |
|
||||||
* frame */
|
* frame */
|
||||||
int len = atoi(custom + 17);
|
int len = atoi(custom + 17);
|
||||||
|
@ -1267,7 +1267,7 @@ atheros_wireless_event_wireless_custom(struct atheros_driver_data *drv,
|
||||||
}
|
}
|
||||||
atheros_raw_receive(drv, NULL,
|
atheros_raw_receive(drv, NULL,
|
||||||
(u8 *) custom + MGMT_FRAM_TAG_SIZE, len);
|
(u8 *) custom + MGMT_FRAM_TAG_SIZE, len);
|
||||||
} else if (strncmp(custom, "Manage.auth ", 12) == 0) {
|
} else if (os_strncmp(custom, "Manage.auth ", 12) == 0) {
|
||||||
/* Format: "Manage.auth <frame len>" | zero padding | frame */
|
/* Format: "Manage.auth <frame len>" | zero padding | frame */
|
||||||
int len = atoi(custom + 12);
|
int len = atoi(custom + 12);
|
||||||
if (len < 0 ||
|
if (len < 0 ||
|
||||||
|
@ -1280,7 +1280,7 @@ atheros_wireless_event_wireless_custom(struct atheros_driver_data *drv,
|
||||||
(u8 *) custom + MGMT_FRAM_TAG_SIZE, len);
|
(u8 *) custom + MGMT_FRAM_TAG_SIZE, len);
|
||||||
#endif /* CONFIG_IEEE80211W || CONFIG_IEEE80211R */
|
#endif /* CONFIG_IEEE80211W || CONFIG_IEEE80211R */
|
||||||
#ifdef ATHEROS_USE_RAW_RECEIVE
|
#ifdef ATHEROS_USE_RAW_RECEIVE
|
||||||
} else if (strncmp(custom, "Manage.action ", 14) == 0) {
|
} else if (os_strncmp(custom, "Manage.action ", 14) == 0) {
|
||||||
/* Format: "Manage.assoc_req <frame len>" | zero padding | frame
|
/* Format: "Manage.assoc_req <frame len>" | zero padding | frame
|
||||||
*/
|
*/
|
||||||
int len = atoi(custom + 14);
|
int len = atoi(custom + 14);
|
||||||
|
@ -1395,7 +1395,7 @@ atheros_wireless_event_wireless(struct atheros_driver_data *drv,
|
||||||
while ((size_t) (end - pos) >= IW_EV_LCP_LEN) {
|
while ((size_t) (end - pos) >= IW_EV_LCP_LEN) {
|
||||||
/* Event data may be unaligned, so make a local, aligned copy
|
/* Event data may be unaligned, so make a local, aligned copy
|
||||||
* before processing. */
|
* before processing. */
|
||||||
memcpy(&iwe_buf, pos, IW_EV_LCP_LEN);
|
os_memcpy(&iwe_buf, pos, IW_EV_LCP_LEN);
|
||||||
wpa_printf(MSG_MSGDUMP, "Wireless event: cmd=0x%x len=%d",
|
wpa_printf(MSG_MSGDUMP, "Wireless event: cmd=0x%x len=%d",
|
||||||
iwe->cmd, iwe->len);
|
iwe->cmd, iwe->len);
|
||||||
if (iwe->len <= IW_EV_LCP_LEN || iwe->len > end - pos)
|
if (iwe->len <= IW_EV_LCP_LEN || iwe->len > end - pos)
|
||||||
|
@ -1409,10 +1409,10 @@ atheros_wireless_event_wireless(struct atheros_driver_data *drv,
|
||||||
/* WE-19 removed the pointer from struct iw_point */
|
/* WE-19 removed the pointer from struct iw_point */
|
||||||
char *dpos = (char *) &iwe_buf.u.data.length;
|
char *dpos = (char *) &iwe_buf.u.data.length;
|
||||||
int dlen = dpos - (char *) &iwe_buf;
|
int dlen = dpos - (char *) &iwe_buf;
|
||||||
memcpy(dpos, pos + IW_EV_LCP_LEN,
|
os_memcpy(dpos, pos + IW_EV_LCP_LEN,
|
||||||
sizeof(struct iw_event) - dlen);
|
sizeof(struct iw_event) - dlen);
|
||||||
} else {
|
} else {
|
||||||
memcpy(&iwe_buf, pos, sizeof(struct iw_event));
|
os_memcpy(&iwe_buf, pos, sizeof(struct iw_event));
|
||||||
custom += IW_EV_POINT_OFF;
|
custom += IW_EV_POINT_OFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1432,10 +1432,10 @@ atheros_wireless_event_wireless(struct atheros_driver_data *drv,
|
||||||
case IWEVCUSTOM:
|
case IWEVCUSTOM:
|
||||||
if (iwe->u.data.length > end - custom)
|
if (iwe->u.data.length > end - custom)
|
||||||
return;
|
return;
|
||||||
buf = malloc(iwe->u.data.length + 1);
|
buf = os_malloc(iwe->u.data.length + 1);
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return; /* XXX */
|
return; /* XXX */
|
||||||
memcpy(buf, custom, iwe->u.data.length);
|
os_memcpy(buf, custom, iwe->u.data.length);
|
||||||
buf[iwe->u.data.length] = '\0';
|
buf[iwe->u.data.length] = '\0';
|
||||||
|
|
||||||
if (iwe->u.data.flags != 0) {
|
if (iwe->u.data.flags != 0) {
|
||||||
|
@ -1446,7 +1446,7 @@ atheros_wireless_event_wireless(struct atheros_driver_data *drv,
|
||||||
atheros_wireless_event_wireless_custom(
|
atheros_wireless_event_wireless_custom(
|
||||||
drv, buf, buf + iwe->u.data.length);
|
drv, buf, buf + iwe->u.data.length);
|
||||||
}
|
}
|
||||||
free(buf);
|
os_free(buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1500,7 +1500,7 @@ atheros_get_we_version(struct atheros_driver_data *drv)
|
||||||
if (range == NULL)
|
if (range == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memset(&iwr, 0, sizeof(iwr));
|
os_memset(&iwr, 0, sizeof(iwr));
|
||||||
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
||||||
iwr.u.data.pointer = (caddr_t) range;
|
iwr.u.data.pointer = (caddr_t) range;
|
||||||
iwr.u.data.length = buflen;
|
iwr.u.data.length = buflen;
|
||||||
|
@ -1569,7 +1569,7 @@ atheros_send_eapol(void *priv, const u8 *addr, const u8 *data, size_t data_len,
|
||||||
*/
|
*/
|
||||||
len = data_len + sizeof(struct l2_ethhdr);
|
len = data_len + sizeof(struct l2_ethhdr);
|
||||||
if (len > sizeof(buf)) {
|
if (len > sizeof(buf)) {
|
||||||
bp = malloc(len);
|
bp = os_malloc(len);
|
||||||
if (bp == NULL) {
|
if (bp == NULL) {
|
||||||
wpa_printf(MSG_INFO,
|
wpa_printf(MSG_INFO,
|
||||||
"EAPOL frame discarded, cannot malloc temp buffer of size %lu!",
|
"EAPOL frame discarded, cannot malloc temp buffer of size %lu!",
|
||||||
|
@ -1578,17 +1578,17 @@ atheros_send_eapol(void *priv, const u8 *addr, const u8 *data, size_t data_len,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eth = (struct l2_ethhdr *) bp;
|
eth = (struct l2_ethhdr *) bp;
|
||||||
memcpy(eth->h_dest, addr, ETH_ALEN);
|
os_memcpy(eth->h_dest, addr, ETH_ALEN);
|
||||||
memcpy(eth->h_source, own_addr, ETH_ALEN);
|
os_memcpy(eth->h_source, own_addr, ETH_ALEN);
|
||||||
eth->h_proto = host_to_be16(ETH_P_EAPOL);
|
eth->h_proto = host_to_be16(ETH_P_EAPOL);
|
||||||
memcpy(eth+1, data, data_len);
|
os_memcpy(eth + 1, data, data_len);
|
||||||
|
|
||||||
wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", bp, len);
|
wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", bp, len);
|
||||||
|
|
||||||
status = l2_packet_send(drv->sock_xmit, addr, ETH_P_EAPOL, bp, len);
|
status = l2_packet_send(drv->sock_xmit, addr, ETH_P_EAPOL, bp, len);
|
||||||
|
|
||||||
if (bp != buf)
|
if (bp != buf)
|
||||||
free(bp);
|
os_free(bp);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1622,9 +1622,9 @@ atheros_init(struct hostapd_data *hapd, struct wpa_init_params *params)
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
memcpy(drv->iface, params->ifname, sizeof(drv->iface));
|
os_memcpy(drv->iface, params->ifname, sizeof(drv->iface));
|
||||||
|
|
||||||
memset(&ifr, 0, sizeof(ifr));
|
os_memset(&ifr, 0, sizeof(ifr));
|
||||||
os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
|
os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
|
||||||
if (ioctl(drv->ioctl_sock, SIOCGIFINDEX, &ifr) != 0) {
|
if (ioctl(drv->ioctl_sock, SIOCGIFINDEX, &ifr) != 0) {
|
||||||
wpa_printf(MSG_ERROR, "ioctl(SIOCGIFINDEX): %s",
|
wpa_printf(MSG_ERROR, "ioctl(SIOCGIFINDEX): %s",
|
||||||
|
@ -1658,7 +1658,7 @@ atheros_init(struct hostapd_data *hapd, struct wpa_init_params *params)
|
||||||
} else
|
} else
|
||||||
drv->sock_recv = drv->sock_xmit;
|
drv->sock_recv = drv->sock_xmit;
|
||||||
|
|
||||||
memset(&iwr, 0, sizeof(iwr));
|
os_memset(&iwr, 0, sizeof(iwr));
|
||||||
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
||||||
|
|
||||||
iwr.u.mode = IW_MODE_MASTER;
|
iwr.u.mode = IW_MODE_MASTER;
|
||||||
|
@ -1728,7 +1728,7 @@ atheros_set_ssid(void *priv, const u8 *buf, int len)
|
||||||
struct atheros_driver_data *drv = priv;
|
struct atheros_driver_data *drv = priv;
|
||||||
struct iwreq iwr;
|
struct iwreq iwr;
|
||||||
|
|
||||||
memset(&iwr, 0, sizeof(iwr));
|
os_memset(&iwr, 0, sizeof(iwr));
|
||||||
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
||||||
iwr.u.essid.flags = 1; /* SSID active */
|
iwr.u.essid.flags = 1; /* SSID active */
|
||||||
iwr.u.essid.pointer = (caddr_t) buf;
|
iwr.u.essid.pointer = (caddr_t) buf;
|
||||||
|
@ -1749,7 +1749,7 @@ atheros_get_ssid(void *priv, u8 *buf, int len)
|
||||||
struct iwreq iwr;
|
struct iwreq iwr;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
memset(&iwr, 0, sizeof(iwr));
|
os_memset(&iwr, 0, sizeof(iwr));
|
||||||
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
||||||
iwr.u.essid.pointer = (caddr_t) buf;
|
iwr.u.essid.pointer = (caddr_t) buf;
|
||||||
iwr.u.essid.length = (len > IW_ESSID_MAX_SIZE) ?
|
iwr.u.essid.length = (len > IW_ESSID_MAX_SIZE) ?
|
||||||
|
@ -1860,7 +1860,7 @@ static int atheros_send_mgmt(void *priv, const u8 *frm, size_t data_len,
|
||||||
wpa_printf(MSG_DEBUG, "%s frmlen = %lu " MACSTR, __func__,
|
wpa_printf(MSG_DEBUG, "%s frmlen = %lu " MACSTR, __func__,
|
||||||
(unsigned long) data_len, MAC2STR(mgmt->da));
|
(unsigned long) data_len, MAC2STR(mgmt->da));
|
||||||
mgmt_frm = (struct ieee80211req_mgmtbuf *) buf;
|
mgmt_frm = (struct ieee80211req_mgmtbuf *) buf;
|
||||||
memcpy(mgmt_frm->macaddr, (u8 *)mgmt->da, IEEE80211_ADDR_LEN);
|
os_memcpy(mgmt_frm->macaddr, (u8 *)mgmt->da, IEEE80211_ADDR_LEN);
|
||||||
mgmt_frm->buflen = data_len;
|
mgmt_frm->buflen = data_len;
|
||||||
if (&mgmt_frm->buf[0] + data_len > buf + sizeof(buf)) {
|
if (&mgmt_frm->buf[0] + data_len > buf + sizeof(buf)) {
|
||||||
wpa_printf(MSG_INFO, "atheros: Too long frame for "
|
wpa_printf(MSG_INFO, "atheros: Too long frame for "
|
||||||
|
|
Loading…
Reference in a new issue