diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-07-15 21:44:13 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-08-22 16:29:54 -0400 |
commit | 358c8d9d332230b14e130b78a6930996cdbf84c2 (patch) | |
tree | 0a563e201e4c5fff9564579877ff0e5f0dd58294 /net/mac80211/rx.c | |
parent | e7827a7031a931c74c48e4a53f73ed862f0c8da0 (diff) |
mac80211: use ieee80211 frame control directly
Remove the last users of the rx/tx_data->fc data members and use the
le16 frame_control from the header directly.
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/rx.c')
-rw-r--r-- | net/mac80211/rx.c | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 4e9631c140a3..3a96251379f9 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -867,16 +867,18 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | |||
867 | { | 867 | { |
868 | struct ieee80211_hdr *hdr; | 868 | struct ieee80211_hdr *hdr; |
869 | u16 sc; | 869 | u16 sc; |
870 | __le16 fc; | ||
870 | unsigned int frag, seq; | 871 | unsigned int frag, seq; |
871 | struct ieee80211_fragment_entry *entry; | 872 | struct ieee80211_fragment_entry *entry; |
872 | struct sk_buff *skb; | 873 | struct sk_buff *skb; |
873 | DECLARE_MAC_BUF(mac); | 874 | DECLARE_MAC_BUF(mac); |
874 | 875 | ||
875 | hdr = (struct ieee80211_hdr *)rx->skb->data; | 876 | hdr = (struct ieee80211_hdr *)rx->skb->data; |
877 | fc = hdr->frame_control; | ||
876 | sc = le16_to_cpu(hdr->seq_ctrl); | 878 | sc = le16_to_cpu(hdr->seq_ctrl); |
877 | frag = sc & IEEE80211_SCTL_FRAG; | 879 | frag = sc & IEEE80211_SCTL_FRAG; |
878 | 880 | ||
879 | if (likely((!ieee80211_has_morefrags(hdr->frame_control) && frag == 0) || | 881 | if (likely((!ieee80211_has_morefrags(fc) && frag == 0) || |
880 | (rx->skb)->len < 24 || | 882 | (rx->skb)->len < 24 || |
881 | is_multicast_ether_addr(hdr->addr1))) { | 883 | is_multicast_ether_addr(hdr->addr1))) { |
882 | /* not fragmented */ | 884 | /* not fragmented */ |
@@ -891,7 +893,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | |||
891 | entry = ieee80211_reassemble_add(rx->sdata, frag, seq, | 893 | entry = ieee80211_reassemble_add(rx->sdata, frag, seq, |
892 | rx->queue, &(rx->skb)); | 894 | rx->queue, &(rx->skb)); |
893 | if (rx->key && rx->key->conf.alg == ALG_CCMP && | 895 | if (rx->key && rx->key->conf.alg == ALG_CCMP && |
894 | ieee80211_has_protected(hdr->frame_control)) { | 896 | ieee80211_has_protected(fc)) { |
895 | /* Store CCMP PN so that we can verify that the next | 897 | /* Store CCMP PN so that we can verify that the next |
896 | * fragment has a sequential PN value. */ | 898 | * fragment has a sequential PN value. */ |
897 | entry->ccmp = 1; | 899 | entry->ccmp = 1; |
@@ -930,11 +932,11 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | |||
930 | memcpy(entry->last_pn, pn, CCMP_PN_LEN); | 932 | memcpy(entry->last_pn, pn, CCMP_PN_LEN); |
931 | } | 933 | } |
932 | 934 | ||
933 | skb_pull(rx->skb, ieee80211_hdrlen(hdr->frame_control)); | 935 | skb_pull(rx->skb, ieee80211_hdrlen(fc)); |
934 | __skb_queue_tail(&entry->skb_list, rx->skb); | 936 | __skb_queue_tail(&entry->skb_list, rx->skb); |
935 | entry->last_frag = frag; | 937 | entry->last_frag = frag; |
936 | entry->extra_len += rx->skb->len; | 938 | entry->extra_len += rx->skb->len; |
937 | if (rx->fc & IEEE80211_FCTL_MOREFRAGS) { | 939 | if (ieee80211_has_morefrags(fc)) { |
938 | rx->skb = NULL; | 940 | rx->skb = NULL; |
939 | return RX_QUEUED; | 941 | return RX_QUEUED; |
940 | } | 942 | } |
@@ -974,10 +976,9 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx) | |||
974 | struct sk_buff *skb; | 976 | struct sk_buff *skb; |
975 | int no_pending_pkts; | 977 | int no_pending_pkts; |
976 | DECLARE_MAC_BUF(mac); | 978 | DECLARE_MAC_BUF(mac); |
979 | __le16 fc = ((struct ieee80211_hdr *)rx->skb->data)->frame_control; | ||
977 | 980 | ||
978 | if (likely(!rx->sta || | 981 | if (likely(!rx->sta || !ieee80211_is_pspoll(fc) || |
979 | (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_CTL || | ||
980 | (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_PSPOLL || | ||
981 | !(rx->flags & IEEE80211_RX_RA_MATCH))) | 982 | !(rx->flags & IEEE80211_RX_RA_MATCH))) |
982 | return RX_CONTINUE; | 983 | return RX_CONTINUE; |
983 | 984 | ||
@@ -1073,7 +1074,7 @@ ieee80211_802_1x_port_control(struct ieee80211_rx_data *rx) | |||
1073 | } | 1074 | } |
1074 | 1075 | ||
1075 | static int | 1076 | static int |
1076 | ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx) | 1077 | ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc) |
1077 | { | 1078 | { |
1078 | /* | 1079 | /* |
1079 | * Pass through unencrypted frames if the hardware has | 1080 | * Pass through unencrypted frames if the hardware has |
@@ -1083,9 +1084,8 @@ ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx) | |||
1083 | return 0; | 1084 | return 0; |
1084 | 1085 | ||
1085 | /* Drop unencrypted frames if key is set. */ | 1086 | /* Drop unencrypted frames if key is set. */ |
1086 | if (unlikely(!(rx->fc & IEEE80211_FCTL_PROTECTED) && | 1087 | if (unlikely(!ieee80211_has_protected(fc) && |
1087 | (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA && | 1088 | !ieee80211_is_nullfunc(fc) && |
1088 | (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_NULLFUNC && | ||
1089 | (rx->key || rx->sdata->drop_unencrypted))) | 1089 | (rx->key || rx->sdata->drop_unencrypted))) |
1090 | return -EACCES; | 1090 | return -EACCES; |
1091 | 1091 | ||
@@ -1184,7 +1184,7 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx) | |||
1184 | /* | 1184 | /* |
1185 | * requires that rx->skb is a frame with ethernet header | 1185 | * requires that rx->skb is a frame with ethernet header |
1186 | */ | 1186 | */ |
1187 | static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx) | 1187 | static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc) |
1188 | { | 1188 | { |
1189 | static const u8 pae_group_addr[ETH_ALEN] __aligned(2) | 1189 | static const u8 pae_group_addr[ETH_ALEN] __aligned(2) |
1190 | = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x03 }; | 1190 | = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x03 }; |
@@ -1200,7 +1200,7 @@ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx) | |||
1200 | return true; | 1200 | return true; |
1201 | 1201 | ||
1202 | if (ieee80211_802_1x_port_control(rx) || | 1202 | if (ieee80211_802_1x_port_control(rx) || |
1203 | ieee80211_drop_unencrypted(rx)) | 1203 | ieee80211_drop_unencrypted(rx, fc)) |
1204 | return false; | 1204 | return false; |
1205 | 1205 | ||
1206 | return true; | 1206 | return true; |
@@ -1270,20 +1270,21 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1270 | { | 1270 | { |
1271 | struct net_device *dev = rx->dev; | 1271 | struct net_device *dev = rx->dev; |
1272 | struct ieee80211_local *local = rx->local; | 1272 | struct ieee80211_local *local = rx->local; |
1273 | u16 fc, ethertype; | 1273 | u16 ethertype; |
1274 | u8 *payload; | 1274 | u8 *payload; |
1275 | struct sk_buff *skb = rx->skb, *frame = NULL; | 1275 | struct sk_buff *skb = rx->skb, *frame = NULL; |
1276 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | ||
1277 | __le16 fc = hdr->frame_control; | ||
1276 | const struct ethhdr *eth; | 1278 | const struct ethhdr *eth; |
1277 | int remaining, err; | 1279 | int remaining, err; |
1278 | u8 dst[ETH_ALEN]; | 1280 | u8 dst[ETH_ALEN]; |
1279 | u8 src[ETH_ALEN]; | 1281 | u8 src[ETH_ALEN]; |
1280 | DECLARE_MAC_BUF(mac); | 1282 | DECLARE_MAC_BUF(mac); |
1281 | 1283 | ||
1282 | fc = rx->fc; | 1284 | if (unlikely(!ieee80211_is_data(fc))) |
1283 | if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) | ||
1284 | return RX_CONTINUE; | 1285 | return RX_CONTINUE; |
1285 | 1286 | ||
1286 | if (unlikely(!WLAN_FC_DATA_PRESENT(fc))) | 1287 | if (unlikely(!ieee80211_is_data_present(fc))) |
1287 | return RX_DROP_MONITOR; | 1288 | return RX_DROP_MONITOR; |
1288 | 1289 | ||
1289 | if (!(rx->flags & IEEE80211_RX_AMSDU)) | 1290 | if (!(rx->flags & IEEE80211_RX_AMSDU)) |
@@ -1365,7 +1366,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1365 | memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN); | 1366 | memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN); |
1366 | } | 1367 | } |
1367 | 1368 | ||
1368 | if (!ieee80211_frame_allowed(rx)) { | 1369 | if (!ieee80211_frame_allowed(rx, fc)) { |
1369 | if (skb == frame) /* last frame */ | 1370 | if (skb == frame) /* last frame */ |
1370 | return RX_DROP_UNUSABLE; | 1371 | return RX_DROP_UNUSABLE; |
1371 | dev_kfree_skb(frame); | 1372 | dev_kfree_skb(frame); |
@@ -1439,21 +1440,21 @@ static ieee80211_rx_result debug_noinline | |||
1439 | ieee80211_rx_h_data(struct ieee80211_rx_data *rx) | 1440 | ieee80211_rx_h_data(struct ieee80211_rx_data *rx) |
1440 | { | 1441 | { |
1441 | struct net_device *dev = rx->dev; | 1442 | struct net_device *dev = rx->dev; |
1442 | u16 fc; | 1443 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
1444 | __le16 fc = hdr->frame_control; | ||
1443 | int err; | 1445 | int err; |
1444 | 1446 | ||
1445 | fc = rx->fc; | 1447 | if (unlikely(!ieee80211_is_data(hdr->frame_control))) |
1446 | if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) | ||
1447 | return RX_CONTINUE; | 1448 | return RX_CONTINUE; |
1448 | 1449 | ||
1449 | if (unlikely(!WLAN_FC_DATA_PRESENT(fc))) | 1450 | if (unlikely(!ieee80211_is_data_present(hdr->frame_control))) |
1450 | return RX_DROP_MONITOR; | 1451 | return RX_DROP_MONITOR; |
1451 | 1452 | ||
1452 | err = ieee80211_data_to_8023(rx); | 1453 | err = ieee80211_data_to_8023(rx); |
1453 | if (unlikely(err)) | 1454 | if (unlikely(err)) |
1454 | return RX_DROP_UNUSABLE; | 1455 | return RX_DROP_UNUSABLE; |
1455 | 1456 | ||
1456 | if (!ieee80211_frame_allowed(rx)) | 1457 | if (!ieee80211_frame_allowed(rx, fc)) |
1457 | return RX_DROP_MONITOR; | 1458 | return RX_DROP_MONITOR; |
1458 | 1459 | ||
1459 | rx->skb->dev = dev; | 1460 | rx->skb->dev = dev; |
@@ -1818,13 +1819,12 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
1818 | struct ieee80211_sub_if_data *sdata; | 1819 | struct ieee80211_sub_if_data *sdata; |
1819 | struct ieee80211_hdr *hdr; | 1820 | struct ieee80211_hdr *hdr; |
1820 | struct ieee80211_rx_data rx; | 1821 | struct ieee80211_rx_data rx; |
1821 | u16 type; | ||
1822 | int prepares; | 1822 | int prepares; |
1823 | struct ieee80211_sub_if_data *prev = NULL; | 1823 | struct ieee80211_sub_if_data *prev = NULL; |
1824 | struct sk_buff *skb_new; | 1824 | struct sk_buff *skb_new; |
1825 | u8 *bssid; | 1825 | u8 *bssid; |
1826 | 1826 | ||
1827 | hdr = (struct ieee80211_hdr *) skb->data; | 1827 | hdr = (struct ieee80211_hdr *)skb->data; |
1828 | memset(&rx, 0, sizeof(rx)); | 1828 | memset(&rx, 0, sizeof(rx)); |
1829 | rx.skb = skb; | 1829 | rx.skb = skb; |
1830 | rx.local = local; | 1830 | rx.local = local; |
@@ -1832,9 +1832,8 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
1832 | rx.status = status; | 1832 | rx.status = status; |
1833 | rx.rate = rate; | 1833 | rx.rate = rate; |
1834 | rx.fc = le16_to_cpu(hdr->frame_control); | 1834 | rx.fc = le16_to_cpu(hdr->frame_control); |
1835 | type = rx.fc & IEEE80211_FCTL_FTYPE; | ||
1836 | 1835 | ||
1837 | if (type == IEEE80211_FTYPE_DATA || type == IEEE80211_FTYPE_MGMT) | 1836 | if (ieee80211_is_data(hdr->frame_control) || ieee80211_is_mgmt(hdr->frame_control)) |
1838 | local->dot11ReceivedFragmentCount++; | 1837 | local->dot11ReceivedFragmentCount++; |
1839 | 1838 | ||
1840 | rx.sta = sta_info_get(local, hdr->addr2); | 1839 | rx.sta = sta_info_get(local, hdr->addr2); |