aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-09-18 17:29:20 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:52:59 -0400
commitf97df02e23269c7650869f6192e809f8ac1a4b39 (patch)
treeec94bcf660ff34c51562ac285d2b6fac38cc9059 /include
parent75a5f0ccfdbc0151ee40bb742f7b5c8eba493c0e (diff)
[PATCH] wireless networking: move frame inline functions to generic header
These inlines are generally useful, not just with mac80211. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Michael Wu <flamingice@sourmilk.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/ieee80211.h61
-rw-r--r--include/net/mac80211.h60
2 files changed, 61 insertions, 60 deletions
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 272f8c8c90da..30621c27159f 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -16,6 +16,7 @@
16#define IEEE80211_H 16#define IEEE80211_H
17 17
18#include <linux/types.h> 18#include <linux/types.h>
19#include <asm/byteorder.h>
19 20
20#define FCS_LEN 4 21#define FCS_LEN 4
21 22
@@ -350,4 +351,64 @@ enum ieee80211_eid {
350 351
351#define WLAN_MAX_KEY_LEN 32 352#define WLAN_MAX_KEY_LEN 32
352 353
354/**
355 * ieee80211_get_SA - get pointer to SA
356 *
357 * Given an 802.11 frame, this function returns the offset
358 * to the source address (SA). It does not verify that the
359 * header is long enough to contain the address, and the
360 * header must be long enough to contain the frame control
361 * field.
362 *
363 * @hdr: the frame
364 */
365static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
366{
367 u8 *raw = (u8 *) hdr;
368 u8 tofrom = (*(raw+1)) & 3; /* get the TODS and FROMDS bits */
369
370 switch (tofrom) {
371 case 2:
372 return hdr->addr3;
373 case 3:
374 return hdr->addr4;
375 }
376 return hdr->addr2;
377}
378
379/**
380 * ieee80211_get_DA - get pointer to DA
381 *
382 * Given an 802.11 frame, this function returns the offset
383 * to the destination address (DA). It does not verify that
384 * the header is long enough to contain the address, and the
385 * header must be long enough to contain the frame control
386 * field.
387 *
388 * @hdr: the frame
389 */
390static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
391{
392 u8 *raw = (u8 *) hdr;
393 u8 to_ds = (*(raw+1)) & 1; /* get the TODS bit */
394
395 if (to_ds)
396 return hdr->addr3;
397 return hdr->addr1;
398}
399
400/**
401 * ieee80211_get_morefrag - determine whether the MOREFRAGS bit is set
402 *
403 * This function determines whether the "more fragments" bit is set
404 * in the frame.
405 *
406 * @hdr: the frame
407 */
408static inline int ieee80211_get_morefrag(struct ieee80211_hdr *hdr)
409{
410 return (le16_to_cpu(hdr->frame_control) &
411 IEEE80211_FCTL_MOREFRAGS) != 0;
412}
413
353#endif /* IEEE80211_H */ 414#endif /* IEEE80211_H */
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index d2cf734402e3..fcca9c39b9e7 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1399,64 +1399,4 @@ void ieee80211_wake_queues(struct ieee80211_hw *hw);
1399 */ 1399 */
1400void ieee80211_scan_completed(struct ieee80211_hw *hw); 1400void ieee80211_scan_completed(struct ieee80211_hw *hw);
1401 1401
1402/**
1403 * ieee80211_get_SA - get pointer to SA
1404 *
1405 * Given an 802.11 frame, this function returns the offset
1406 * to the source address (SA). It does not verify that the
1407 * header is long enough to contain the address, and the
1408 * header must be long enough to contain the frame control
1409 * field.
1410 *
1411 * @hdr: the frame
1412 */
1413static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
1414{
1415 u8 *raw = (u8 *) hdr;
1416 u8 tofrom = (*(raw+1)) & 3; /* get the TODS and FROMDS bits */
1417
1418 switch (tofrom) {
1419 case 2:
1420 return hdr->addr3;
1421 case 3:
1422 return hdr->addr4;
1423 }
1424 return hdr->addr2;
1425}
1426
1427/**
1428 * ieee80211_get_DA - get pointer to DA
1429 *
1430 * Given an 802.11 frame, this function returns the offset
1431 * to the destination address (DA). It does not verify that
1432 * the header is long enough to contain the address, and the
1433 * header must be long enough to contain the frame control
1434 * field.
1435 *
1436 * @hdr: the frame
1437 */
1438static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
1439{
1440 u8 *raw = (u8 *) hdr;
1441 u8 to_ds = (*(raw+1)) & 1; /* get the TODS bit */
1442
1443 if (to_ds)
1444 return hdr->addr3;
1445 return hdr->addr1;
1446}
1447
1448/**
1449 * ieee80211_get_morefrag - determine whether the MOREFRAGS bit is set
1450 *
1451 * This function determines whether the "more fragments" bit is set
1452 * in the frame.
1453 *
1454 * @hdr: the frame
1455 */
1456static inline int ieee80211_get_morefrag(struct ieee80211_hdr *hdr)
1457{
1458 return (le16_to_cpu(hdr->frame_control) &
1459 IEEE80211_FCTL_MOREFRAGS) != 0;
1460}
1461
1462#endif /* MAC80211_H */ 1402#endif /* MAC80211_H */