aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ieee80211.h
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/linux/ieee80211.h
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/linux/ieee80211.h')
-rw-r--r--include/linux/ieee80211.h61
1 files changed, 61 insertions, 0 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 */