aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/tx.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-02-23 09:17:19 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-03-06 15:30:42 -0500
commit902acc7896d7649fb30e4b22bd4e643c7f34b02c (patch)
tree8d8f2838fead8417e16e801383ddb2691a89719f /net/mac80211/tx.c
parentf7a921443740d7dafc65b17aa32531730d358f50 (diff)
mac80211: clean up mesh code
Various cleanups, reducing the #ifdef mess and other things. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/tx.c')
-rw-r--r--net/mac80211/tx.c120
1 files changed, 52 insertions, 68 deletions
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index fc1ffb55ed5c..3b06e0d8f35c 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -26,9 +26,7 @@
26 26
27#include "ieee80211_i.h" 27#include "ieee80211_i.h"
28#include "ieee80211_led.h" 28#include "ieee80211_led.h"
29#ifdef CONFIG_MAC80211_MESH
30#include "mesh.h" 29#include "mesh.h"
31#endif
32#include "wep.h" 30#include "wep.h"
33#include "wpa.h" 31#include "wpa.h"
34#include "wme.h" 32#include "wme.h"
@@ -1460,7 +1458,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1460 goto fail; 1458 goto fail;
1461 } 1459 }
1462 meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr, 1460 meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr,
1463 sdata); 1461 sdata);
1464 } 1462 }
1465 hdrlen = 30; 1463 hdrlen = 30;
1466 break; 1464 break;
@@ -1778,40 +1776,6 @@ static void ieee80211_beacon_add_tim(struct ieee80211_local *local,
1778 read_unlock_bh(&local->sta_lock); 1776 read_unlock_bh(&local->sta_lock);
1779} 1777}
1780 1778
1781#ifdef CONFIG_MAC80211_MESH
1782static struct sk_buff *ieee80211_mesh_beacon_get(struct net_device *dev)
1783{
1784 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1785 struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
1786 struct ieee80211_mgmt *mgmt;
1787 u8 *pos;
1788
1789 if (!skb)
1790 return NULL;
1791 skb_reserve(skb, local->hw.extra_tx_headroom);
1792 mgmt = (struct ieee80211_mgmt *)
1793 skb_put(skb, 24 + sizeof(mgmt->u.beacon));
1794 memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
1795 mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT,
1796 IEEE80211_STYPE_BEACON);
1797 memset(mgmt->da, 0xff, ETH_ALEN);
1798 memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN);
1799 /* BSSID is left zeroed, wildcard value */
1800 mgmt->u.beacon.beacon_int =
1801 cpu_to_le16(local->hw.conf.beacon_int);
1802 mgmt->u.beacon.capab_info = 0x0; /* 0x0 for MPs */
1803
1804 pos = skb_put(skb, 2);
1805 *pos++ = WLAN_EID_SSID;
1806 *pos++ = 0x0;
1807
1808 mesh_mgmt_ies_add(skb, dev);
1809
1810 return skb;
1811}
1812#endif
1813
1814
1815struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, 1779struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
1816 struct ieee80211_vif *vif, 1780 struct ieee80211_vif *vif,
1817 struct ieee80211_tx_control *control) 1781 struct ieee80211_tx_control *control)
@@ -1824,8 +1788,10 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
1824 struct rate_selection rsel; 1788 struct rate_selection rsel;
1825 struct beacon_data *beacon; 1789 struct beacon_data *beacon;
1826 struct ieee80211_supported_band *sband; 1790 struct ieee80211_supported_band *sband;
1791 struct ieee80211_mgmt *mgmt;
1827 int *num_beacons; 1792 int *num_beacons;
1828 int err = 0; 1793 bool err = true;
1794 u8 *pos;
1829 1795
1830 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 1796 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
1831 1797
@@ -1834,47 +1800,65 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
1834 sdata = vif_to_sdata(vif); 1800 sdata = vif_to_sdata(vif);
1835 bdev = sdata->dev; 1801 bdev = sdata->dev;
1836 1802
1837 switch (sdata->vif.type) { 1803 if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
1838 case IEEE80211_IF_TYPE_AP:
1839 ap = &sdata->u.ap; 1804 ap = &sdata->u.ap;
1840 beacon = rcu_dereference(ap->beacon); 1805 beacon = rcu_dereference(ap->beacon);
1841 if (!ap || !beacon) { 1806 if (ap && beacon) {
1842 err = -1; 1807 /*
1843 break; 1808 * headroom, head length,
1844 } 1809 * tail length and maximum TIM length
1810 */
1811 skb = dev_alloc_skb(local->tx_headroom +
1812 beacon->head_len +
1813 beacon->tail_len + 256);
1814 if (!skb)
1815 goto out;
1845 1816
1846 /* headroom, head length, tail length and maximum TIM length */ 1817 skb_reserve(skb, local->tx_headroom);
1847 skb = dev_alloc_skb(local->tx_headroom + beacon->head_len + 1818 memcpy(skb_put(skb, beacon->head_len), beacon->head,
1848 beacon->tail_len + 256); 1819 beacon->head_len);
1849 if (!skb)
1850 goto out;
1851 1820
1852 skb_reserve(skb, local->tx_headroom); 1821 ieee80211_include_sequence(sdata,
1853 memcpy(skb_put(skb, beacon->head_len), beacon->head, 1822 (struct ieee80211_hdr *)skb->data);
1854 beacon->head_len);
1855 1823
1856 ieee80211_include_sequence(sdata, 1824 ieee80211_beacon_add_tim(local, ap, skb, beacon);
1857 (struct ieee80211_hdr *)skb->data);
1858 1825
1859 ieee80211_beacon_add_tim(local, ap, skb, beacon); 1826 if (beacon->tail)
1827 memcpy(skb_put(skb, beacon->tail_len),
1828 beacon->tail, beacon->tail_len);
1860 1829
1861 if (beacon->tail) 1830 num_beacons = &ap->num_beacons;
1862 memcpy(skb_put(skb, beacon->tail_len), beacon->tail,
1863 beacon->tail_len);
1864 1831
1865 num_beacons = &ap->num_beacons; 1832 err = false;
1866 break; 1833 }
1834 } else if (ieee80211_vif_is_mesh(&sdata->vif)) {
1835 /* headroom, head length, tail length and maximum TIM length */
1836 skb = dev_alloc_skb(local->tx_headroom + 400);
1837 if (!skb)
1838 goto out;
1839
1840 skb_reserve(skb, local->hw.extra_tx_headroom);
1841 mgmt = (struct ieee80211_mgmt *)
1842 skb_put(skb, 24 + sizeof(mgmt->u.beacon));
1843 memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
1844 mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT,
1845 IEEE80211_STYPE_BEACON);
1846 memset(mgmt->da, 0xff, ETH_ALEN);
1847 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
1848 /* BSSID is left zeroed, wildcard value */
1849 mgmt->u.beacon.beacon_int =
1850 cpu_to_le16(local->hw.conf.beacon_int);
1851 mgmt->u.beacon.capab_info = 0x0; /* 0x0 for MPs */
1852
1853 pos = skb_put(skb, 2);
1854 *pos++ = WLAN_EID_SSID;
1855 *pos++ = 0x0;
1856
1857 mesh_mgmt_ies_add(skb, sdata->dev);
1867 1858
1868#ifdef CONFIG_MAC80211_MESH
1869 case IEEE80211_IF_TYPE_MESH_POINT:
1870 skb = ieee80211_mesh_beacon_get(bdev);
1871 num_beacons = &sdata->u.sta.num_beacons; 1859 num_beacons = &sdata->u.sta.num_beacons;
1872 break;
1873#endif
1874 1860
1875 default: 1861 err = false;
1876 err = -1;
1877 break;
1878 } 1862 }
1879 1863
1880 if (err) { 1864 if (err) {