diff options
author | David S. Miller <davem@davemloft.net> | 2008-06-16 21:50:49 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-06-16 21:50:49 -0400 |
commit | ccc580571cf0799d0460a085a7632b77753f083e (patch) | |
tree | 018e0f83776b089b1f272694132688ac93be25b4 /drivers/net/wireless/rndis_wlan.c | |
parent | 0f5cabba49021d36e9f76bd97d7fa0f4a408063f (diff) |
wext: Emit event stream entries correctly when compat.
Three major portions to this change:
1) Add IW_EV_COMPAT_LCP_LEN, IW_EV_COMPAT_POINT_OFF,
and IW_EV_COMPAT_POINT_LEN helper defines.
2) Delete iw_stream_check_add_*(), they are unused.
3) Add iw_request_info argument to iwe_stream_add_*(), and use it to
size the event and pointer lengths correctly depending upon whether
IW_REQUEST_FLAG_COMPAT is set or not.
4) The mechanical transformations to the drivers and wireless stack
bits to get the iw_request_info passed down into the routines
modified in #3. Also, explicit references to IW_EV_LCP_LEN are
replaced with iwe_stream_lcp_len(info).
With a lot of help and bug fixes from Masakazu Mokuno.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wireless/rndis_wlan.c')
-rw-r--r-- | drivers/net/wireless/rndis_wlan.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index a36d2c85e26e..65c50025c88f 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c | |||
@@ -1648,7 +1648,9 @@ static int rndis_iw_set_scan(struct net_device *dev, | |||
1648 | 1648 | ||
1649 | 1649 | ||
1650 | static char *rndis_translate_scan(struct net_device *dev, | 1650 | static char *rndis_translate_scan(struct net_device *dev, |
1651 | char *cev, char *end_buf, struct ndis_80211_bssid_ex *bssid) | 1651 | struct iw_request_info *info, char *cev, |
1652 | char *end_buf, | ||
1653 | struct ndis_80211_bssid_ex *bssid) | ||
1652 | { | 1654 | { |
1653 | #ifdef DEBUG | 1655 | #ifdef DEBUG |
1654 | struct usbnet *usbdev = dev->priv; | 1656 | struct usbnet *usbdev = dev->priv; |
@@ -1667,14 +1669,14 @@ static char *rndis_translate_scan(struct net_device *dev, | |||
1667 | iwe.cmd = SIOCGIWAP; | 1669 | iwe.cmd = SIOCGIWAP; |
1668 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; | 1670 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; |
1669 | memcpy(iwe.u.ap_addr.sa_data, bssid->mac, ETH_ALEN); | 1671 | memcpy(iwe.u.ap_addr.sa_data, bssid->mac, ETH_ALEN); |
1670 | cev = iwe_stream_add_event(cev, end_buf, &iwe, IW_EV_ADDR_LEN); | 1672 | cev = iwe_stream_add_event(info, cev, end_buf, &iwe, IW_EV_ADDR_LEN); |
1671 | 1673 | ||
1672 | devdbg(usbdev, "SSID(%d) %s", le32_to_cpu(bssid->ssid.length), | 1674 | devdbg(usbdev, "SSID(%d) %s", le32_to_cpu(bssid->ssid.length), |
1673 | bssid->ssid.essid); | 1675 | bssid->ssid.essid); |
1674 | iwe.cmd = SIOCGIWESSID; | 1676 | iwe.cmd = SIOCGIWESSID; |
1675 | iwe.u.essid.length = le32_to_cpu(bssid->ssid.length); | 1677 | iwe.u.essid.length = le32_to_cpu(bssid->ssid.length); |
1676 | iwe.u.essid.flags = 1; | 1678 | iwe.u.essid.flags = 1; |
1677 | cev = iwe_stream_add_point(cev, end_buf, &iwe, bssid->ssid.essid); | 1679 | cev = iwe_stream_add_point(info, cev, end_buf, &iwe, bssid->ssid.essid); |
1678 | 1680 | ||
1679 | devdbg(usbdev, "MODE %d", le32_to_cpu(bssid->net_infra)); | 1681 | devdbg(usbdev, "MODE %d", le32_to_cpu(bssid->net_infra)); |
1680 | iwe.cmd = SIOCGIWMODE; | 1682 | iwe.cmd = SIOCGIWMODE; |
@@ -1690,12 +1692,12 @@ static char *rndis_translate_scan(struct net_device *dev, | |||
1690 | iwe.u.mode = IW_MODE_AUTO; | 1692 | iwe.u.mode = IW_MODE_AUTO; |
1691 | break; | 1693 | break; |
1692 | } | 1694 | } |
1693 | cev = iwe_stream_add_event(cev, end_buf, &iwe, IW_EV_UINT_LEN); | 1695 | cev = iwe_stream_add_event(info, cev, end_buf, &iwe, IW_EV_UINT_LEN); |
1694 | 1696 | ||
1695 | devdbg(usbdev, "FREQ %d kHz", le32_to_cpu(bssid->config.ds_config)); | 1697 | devdbg(usbdev, "FREQ %d kHz", le32_to_cpu(bssid->config.ds_config)); |
1696 | iwe.cmd = SIOCGIWFREQ; | 1698 | iwe.cmd = SIOCGIWFREQ; |
1697 | dsconfig_to_freq(le32_to_cpu(bssid->config.ds_config), &iwe.u.freq); | 1699 | dsconfig_to_freq(le32_to_cpu(bssid->config.ds_config), &iwe.u.freq); |
1698 | cev = iwe_stream_add_event(cev, end_buf, &iwe, IW_EV_FREQ_LEN); | 1700 | cev = iwe_stream_add_event(info, cev, end_buf, &iwe, IW_EV_FREQ_LEN); |
1699 | 1701 | ||
1700 | devdbg(usbdev, "QUAL %d", le32_to_cpu(bssid->rssi)); | 1702 | devdbg(usbdev, "QUAL %d", le32_to_cpu(bssid->rssi)); |
1701 | iwe.cmd = IWEVQUAL; | 1703 | iwe.cmd = IWEVQUAL; |
@@ -1704,7 +1706,7 @@ static char *rndis_translate_scan(struct net_device *dev, | |||
1704 | iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | 1706 | iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED |
1705 | | IW_QUAL_LEVEL_UPDATED | 1707 | | IW_QUAL_LEVEL_UPDATED |
1706 | | IW_QUAL_NOISE_INVALID; | 1708 | | IW_QUAL_NOISE_INVALID; |
1707 | cev = iwe_stream_add_event(cev, end_buf, &iwe, IW_EV_QUAL_LEN); | 1709 | cev = iwe_stream_add_event(info, cev, end_buf, &iwe, IW_EV_QUAL_LEN); |
1708 | 1710 | ||
1709 | devdbg(usbdev, "ENCODE %d", le32_to_cpu(bssid->privacy)); | 1711 | devdbg(usbdev, "ENCODE %d", le32_to_cpu(bssid->privacy)); |
1710 | iwe.cmd = SIOCGIWENCODE; | 1712 | iwe.cmd = SIOCGIWENCODE; |
@@ -1714,10 +1716,10 @@ static char *rndis_translate_scan(struct net_device *dev, | |||
1714 | else | 1716 | else |
1715 | iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; | 1717 | iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; |
1716 | 1718 | ||
1717 | cev = iwe_stream_add_point(cev, end_buf, &iwe, NULL); | 1719 | cev = iwe_stream_add_point(info, cev, end_buf, &iwe, NULL); |
1718 | 1720 | ||
1719 | devdbg(usbdev, "RATES:"); | 1721 | devdbg(usbdev, "RATES:"); |
1720 | current_val = cev + IW_EV_LCP_LEN; | 1722 | current_val = cev + iwe_stream_lcp_len(info); |
1721 | iwe.cmd = SIOCGIWRATE; | 1723 | iwe.cmd = SIOCGIWRATE; |
1722 | for (i = 0; i < sizeof(bssid->rates); i++) { | 1724 | for (i = 0; i < sizeof(bssid->rates); i++) { |
1723 | if (bssid->rates[i] & 0x7f) { | 1725 | if (bssid->rates[i] & 0x7f) { |
@@ -1725,13 +1727,13 @@ static char *rndis_translate_scan(struct net_device *dev, | |||
1725 | ((bssid->rates[i] & 0x7f) * | 1727 | ((bssid->rates[i] & 0x7f) * |
1726 | 500000); | 1728 | 500000); |
1727 | devdbg(usbdev, " %d", iwe.u.bitrate.value); | 1729 | devdbg(usbdev, " %d", iwe.u.bitrate.value); |
1728 | current_val = iwe_stream_add_value(cev, | 1730 | current_val = iwe_stream_add_value(info, cev, |
1729 | current_val, end_buf, &iwe, | 1731 | current_val, end_buf, &iwe, |
1730 | IW_EV_PARAM_LEN); | 1732 | IW_EV_PARAM_LEN); |
1731 | } | 1733 | } |
1732 | } | 1734 | } |
1733 | 1735 | ||
1734 | if ((current_val - cev) > IW_EV_LCP_LEN) | 1736 | if ((current_val - cev) > iwe_stream_lcp_len(info)) |
1735 | cev = current_val; | 1737 | cev = current_val; |
1736 | 1738 | ||
1737 | beacon = le32_to_cpu(bssid->config.beacon_period); | 1739 | beacon = le32_to_cpu(bssid->config.beacon_period); |
@@ -1739,14 +1741,14 @@ static char *rndis_translate_scan(struct net_device *dev, | |||
1739 | iwe.cmd = IWEVCUSTOM; | 1741 | iwe.cmd = IWEVCUSTOM; |
1740 | snprintf(sbuf, sizeof(sbuf), "bcn_int=%d", beacon); | 1742 | snprintf(sbuf, sizeof(sbuf), "bcn_int=%d", beacon); |
1741 | iwe.u.data.length = strlen(sbuf); | 1743 | iwe.u.data.length = strlen(sbuf); |
1742 | cev = iwe_stream_add_point(cev, end_buf, &iwe, sbuf); | 1744 | cev = iwe_stream_add_point(info, cev, end_buf, &iwe, sbuf); |
1743 | 1745 | ||
1744 | atim = le32_to_cpu(bssid->config.atim_window); | 1746 | atim = le32_to_cpu(bssid->config.atim_window); |
1745 | devdbg(usbdev, "ATIM %d", atim); | 1747 | devdbg(usbdev, "ATIM %d", atim); |
1746 | iwe.cmd = IWEVCUSTOM; | 1748 | iwe.cmd = IWEVCUSTOM; |
1747 | snprintf(sbuf, sizeof(sbuf), "atim=%u", atim); | 1749 | snprintf(sbuf, sizeof(sbuf), "atim=%u", atim); |
1748 | iwe.u.data.length = strlen(sbuf); | 1750 | iwe.u.data.length = strlen(sbuf); |
1749 | cev = iwe_stream_add_point(cev, end_buf, &iwe, sbuf); | 1751 | cev = iwe_stream_add_point(info, cev, end_buf, &iwe, sbuf); |
1750 | 1752 | ||
1751 | ie = (void *)(bssid->ies + sizeof(struct ndis_80211_fixed_ies)); | 1753 | ie = (void *)(bssid->ies + sizeof(struct ndis_80211_fixed_ies)); |
1752 | ie_len = min(bssid_len - (int)sizeof(*bssid), | 1754 | ie_len = min(bssid_len - (int)sizeof(*bssid), |
@@ -1760,7 +1762,7 @@ static char *rndis_translate_scan(struct net_device *dev, | |||
1760 | (ie->id == MFIE_TYPE_RSN) ? 2 : 1); | 1762 | (ie->id == MFIE_TYPE_RSN) ? 2 : 1); |
1761 | iwe.cmd = IWEVGENIE; | 1763 | iwe.cmd = IWEVGENIE; |
1762 | iwe.u.data.length = min(ie->len + 2, MAX_WPA_IE_LEN); | 1764 | iwe.u.data.length = min(ie->len + 2, MAX_WPA_IE_LEN); |
1763 | cev = iwe_stream_add_point(cev, end_buf, &iwe, | 1765 | cev = iwe_stream_add_point(info, cev, end_buf, &iwe, |
1764 | (u8 *)ie); | 1766 | (u8 *)ie); |
1765 | } | 1767 | } |
1766 | 1768 | ||
@@ -1803,8 +1805,8 @@ static int rndis_iw_get_scan(struct net_device *dev, | |||
1803 | devdbg(usbdev, "SIOCGIWSCAN: %d BSSIDs found", count); | 1805 | devdbg(usbdev, "SIOCGIWSCAN: %d BSSIDs found", count); |
1804 | 1806 | ||
1805 | while (count && ((void *)bssid + bssid_len) <= (buf + len)) { | 1807 | while (count && ((void *)bssid + bssid_len) <= (buf + len)) { |
1806 | cev = rndis_translate_scan(dev, cev, extra + IW_SCAN_MAX_DATA, | 1808 | cev = rndis_translate_scan(dev, info, cev, |
1807 | bssid); | 1809 | extra + IW_SCAN_MAX_DATA, bssid); |
1808 | bssid = (void *)bssid + bssid_len; | 1810 | bssid = (void *)bssid + bssid_len; |
1809 | bssid_len = le32_to_cpu(bssid->length); | 1811 | bssid_len = le32_to_cpu(bssid->length); |
1810 | count--; | 1812 | count--; |