diff options
Diffstat (limited to 'net/mac80211/mesh_hwmp.c')
-rw-r--r-- | net/mac80211/mesh_hwmp.c | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 324ebea10c4c..576a6e55323e 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c | |||
@@ -7,6 +7,7 @@ | |||
7 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <asm/unaligned.h> | ||
10 | #include "mesh.h" | 11 | #include "mesh.h" |
11 | 12 | ||
12 | #define IEEE80211_FC(type, stype) cpu_to_le16(type | stype) | 13 | #define IEEE80211_FC(type, stype) cpu_to_le16(type | stype) |
@@ -24,40 +25,41 @@ | |||
24 | /* Reply and forward */ | 25 | /* Reply and forward */ |
25 | #define MP_F_RF 0x2 | 26 | #define MP_F_RF 0x2 |
26 | 27 | ||
28 | static inline u32 u32_field_get(u8 *preq_elem, int offset, bool ae) | ||
29 | { | ||
30 | if (ae) | ||
31 | offset += 6; | ||
32 | return le32_to_cpu(get_unaligned((__le32 *) (preq_elem + offset))); | ||
33 | } | ||
34 | |||
27 | /* HWMP IE processing macros */ | 35 | /* HWMP IE processing macros */ |
28 | #define AE_F (1<<6) | 36 | #define AE_F (1<<6) |
29 | #define AE_F_SET(x) (*x & AE_F) | 37 | #define AE_F_SET(x) (*x & AE_F) |
30 | #define PREQ_IE_FLAGS(x) (*(x)) | 38 | #define PREQ_IE_FLAGS(x) (*(x)) |
31 | #define PREQ_IE_HOPCOUNT(x) (*(x + 1)) | 39 | #define PREQ_IE_HOPCOUNT(x) (*(x + 1)) |
32 | #define PREQ_IE_TTL(x) (*(x + 2)) | 40 | #define PREQ_IE_TTL(x) (*(x + 2)) |
33 | #define PREQ_IE_PREQ_ID(x) le32_to_cpu(*((__le32 *) (x + 3))) | 41 | #define PREQ_IE_PREQ_ID(x) u32_field_get(x, 3, 0) |
34 | #define PREQ_IE_ORIG_ADDR(x) (x + 7) | 42 | #define PREQ_IE_ORIG_ADDR(x) (x + 7) |
35 | #define PREQ_IE_ORIG_DSN(x) le32_to_cpu(*((__le32 *) (x + 13))) | 43 | #define PREQ_IE_ORIG_DSN(x) u32_field_get(x, 13, 0); |
36 | #define PREQ_IE_LIFETIME(x) le32_to_cpu(*((__le32 *) \ | 44 | #define PREQ_IE_LIFETIME(x) u32_field_get(x, 17, AE_F_SET(x)); |
37 | (AE_F_SET(x) ? x + 23 : x + 17))) | 45 | #define PREQ_IE_METRIC(x) u32_field_get(x, 21, AE_F_SET(x)); |
38 | #define PREQ_IE_METRIC(x) le32_to_cpu(*((__le32 *) \ | 46 | #define PREQ_IE_DST_F(x) (*(AE_F_SET(x) ? x + 32 : x + 26)) |
39 | (AE_F_SET(x) ? x + 27 : x + 21))) | 47 | #define PREQ_IE_DST_ADDR(x) (AE_F_SET(x) ? x + 33 : x + 27) |
40 | #define PREQ_IE_DST_F(x) (*(AE_F_SET(x) ? x + 32 : x + 26)) | 48 | #define PREQ_IE_DST_DSN(x) u32_field_get(x, 33, AE_F_SET(x)); |
41 | #define PREQ_IE_DST_ADDR(x) (AE_F_SET(x) ? x + 33 : x + 27) | 49 | |
42 | #define PREQ_IE_DST_DSN(x) le32_to_cpu(*((__le32 *) \ | 50 | |
43 | (AE_F_SET(x) ? x + 39 : x + 33))) | 51 | #define PREP_IE_FLAGS(x) PREQ_IE_FLAGS(x) |
44 | 52 | #define PREP_IE_HOPCOUNT(x) PREQ_IE_HOPCOUNT(x) | |
45 | 53 | #define PREP_IE_TTL(x) PREQ_IE_TTL(x) | |
46 | #define PREP_IE_FLAGS(x) PREQ_IE_FLAGS(x) | 54 | #define PREP_IE_ORIG_ADDR(x) (x + 3) |
47 | #define PREP_IE_HOPCOUNT(x) PREQ_IE_HOPCOUNT(x) | 55 | #define PREP_IE_ORIG_DSN(x) u32_field_get(x, 9, 0); |
48 | #define PREP_IE_TTL(x) PREQ_IE_TTL(x) | 56 | #define PREP_IE_LIFETIME(x) u32_field_get(x, 13, AE_F_SET(x)); |
49 | #define PREP_IE_ORIG_ADDR(x) (x + 3) | 57 | #define PREP_IE_METRIC(x) u32_field_get(x, 17, AE_F_SET(x)); |
50 | #define PREP_IE_ORIG_DSN(x) le32_to_cpu(*((__le32 *) (x + 9))) | 58 | #define PREP_IE_DST_ADDR(x) (AE_F_SET(x) ? x + 27 : x + 21) |
51 | #define PREP_IE_LIFETIME(x) le32_to_cpu(*((__le32 *) \ | 59 | #define PREP_IE_DST_DSN(x) u32_field_get(x, 27, AE_F_SET(x)); |
52 | (AE_F_SET(x) ? x + 19 : x + 13))) | 60 | |
53 | #define PREP_IE_METRIC(x) le32_to_cpu(*((__le32 *) \ | 61 | #define PERR_IE_DST_ADDR(x) (x + 2) |
54 | (AE_F_SET(x) ? x + 23 : x + 17))) | 62 | #define PERR_IE_DST_DSN(x) u32_field_get(x, 8, 0); |
55 | #define PREP_IE_DST_ADDR(x) (AE_F_SET(x) ? x + 27 : x + 21) | ||
56 | #define PREP_IE_DST_DSN(x) le32_to_cpu(*((__le32 *) \ | ||
57 | (AE_F_SET(x) ? x + 33 : x + 27))) | ||
58 | |||
59 | #define PERR_IE_DST_ADDR(x) (x + 2) | ||
60 | #define PERR_IE_DST_DSN(x) le32_to_cpu(*((__le32 *) (x + 8))) | ||
61 | 63 | ||
62 | #define TU_TO_EXP_TIME(x) (jiffies + msecs_to_jiffies(x * 1024 / 1000)) | 64 | #define TU_TO_EXP_TIME(x) (jiffies + msecs_to_jiffies(x * 1024 / 1000)) |
63 | #define MSEC_TO_TU(x) (x*1000/1024) | 65 | #define MSEC_TO_TU(x) (x*1000/1024) |