diff options
author | Rui Paulo <rpaulo@gmail.com> | 2009-11-09 18:46:50 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-11-13 17:43:54 -0500 |
commit | d611f062f4351d8609910648854908fecf58970d (patch) | |
tree | ef3541e0e9347a42b497e3bbdb66045090533308 /net/mac80211/mesh_hwmp.c | |
parent | 90a5e16992fa6105f7ebf3f29f5cf5feb1bbf7dc (diff) |
mac80211: update PERR frame format
Update the PERR IE frame format according to latest draft (3.03).
Signed-off-by: Rui Paulo <rpaulo@gmail.com>
Signed-off-by: Javier Cardona <javier@cozybit.com>
Reviewed-by: Andrey Yurovsky <andrey@cozybit.com>
Tested-by: Brian Cavagnolo <brian@cozybit.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/mesh_hwmp.c')
-rw-r--r-- | net/mac80211/mesh_hwmp.c | 58 |
1 files changed, 49 insertions, 9 deletions
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 7b9dd87cf9f2..eb4180bff575 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c | |||
@@ -27,6 +27,10 @@ | |||
27 | #define MP_F_DO 0x1 | 27 | #define MP_F_DO 0x1 |
28 | /* Reply and forward */ | 28 | /* Reply and forward */ |
29 | #define MP_F_RF 0x2 | 29 | #define MP_F_RF 0x2 |
30 | /* Unknown Sequence Number */ | ||
31 | #define MP_F_USN 0x01 | ||
32 | /* Reason code Present */ | ||
33 | #define MP_F_RCODE 0x02 | ||
30 | 34 | ||
31 | static void mesh_queue_preq(struct mesh_path *, u8); | 35 | static void mesh_queue_preq(struct mesh_path *, u8); |
32 | 36 | ||
@@ -37,6 +41,13 @@ static inline u32 u32_field_get(u8 *preq_elem, int offset, bool ae) | |||
37 | return get_unaligned_le32(preq_elem + offset); | 41 | return get_unaligned_le32(preq_elem + offset); |
38 | } | 42 | } |
39 | 43 | ||
44 | static inline u32 u16_field_get(u8 *preq_elem, int offset, bool ae) | ||
45 | { | ||
46 | if (ae) | ||
47 | offset += 6; | ||
48 | return get_unaligned_le16(preq_elem + offset); | ||
49 | } | ||
50 | |||
40 | /* HWMP IE processing macros */ | 51 | /* HWMP IE processing macros */ |
41 | #define AE_F (1<<6) | 52 | #define AE_F (1<<6) |
42 | #define AE_F_SET(x) (*x & AE_F) | 53 | #define AE_F_SET(x) (*x & AE_F) |
@@ -63,8 +74,11 @@ static inline u32 u32_field_get(u8 *preq_elem, int offset, bool ae) | |||
63 | #define PREP_IE_DST_ADDR(x) (AE_F_SET(x) ? x + 27 : x + 21) | 74 | #define PREP_IE_DST_ADDR(x) (AE_F_SET(x) ? x + 27 : x + 21) |
64 | #define PREP_IE_DST_DSN(x) u32_field_get(x, 27, AE_F_SET(x)); | 75 | #define PREP_IE_DST_DSN(x) u32_field_get(x, 27, AE_F_SET(x)); |
65 | 76 | ||
66 | #define PERR_IE_DST_ADDR(x) (x + 2) | 77 | #define PERR_IE_TTL(x) (*(x)) |
67 | #define PERR_IE_DST_DSN(x) u32_field_get(x, 8, 0); | 78 | #define PERR_IE_DST_FLAGS(x) (*(x + 2)) |
79 | #define PERR_IE_DST_ADDR(x) (x + 3) | ||
80 | #define PERR_IE_DST_DSN(x) u32_field_get(x, 9, 0); | ||
81 | #define PERR_IE_DST_RCODE(x) u16_field_get(x, 13, 0); | ||
68 | 82 | ||
69 | #define MSEC_TO_TU(x) (x*1000/1024) | 83 | #define MSEC_TO_TU(x) (x*1000/1024) |
70 | #define DSN_GT(x, y) ((long) (y) - (long) (x) < 0) | 84 | #define DSN_GT(x, y) ((long) (y) - (long) (x) < 0) |
@@ -181,8 +195,8 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, | |||
181 | * @dst_dsn: dsn of the broken destination | 195 | * @dst_dsn: dsn of the broken destination |
182 | * @ra: node this frame is addressed to | 196 | * @ra: node this frame is addressed to |
183 | */ | 197 | */ |
184 | int mesh_path_error_tx(u8 *dst, __le32 dst_dsn, u8 *ra, | 198 | int mesh_path_error_tx(u8 ttl, u8 *dst, __le32 dst_dsn, __le16 dst_rcode, |
185 | struct ieee80211_sub_if_data *sdata) | 199 | u8 *ra, struct ieee80211_sub_if_data *sdata) |
186 | { | 200 | { |
187 | struct ieee80211_local *local = sdata->local; | 201 | struct ieee80211_local *local = sdata->local; |
188 | struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); | 202 | struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); |
@@ -207,17 +221,29 @@ int mesh_path_error_tx(u8 *dst, __le32 dst_dsn, u8 *ra, | |||
207 | /* BSSID is left zeroed, wildcard value */ | 221 | /* BSSID is left zeroed, wildcard value */ |
208 | mgmt->u.action.category = MESH_PATH_SEL_CATEGORY; | 222 | mgmt->u.action.category = MESH_PATH_SEL_CATEGORY; |
209 | mgmt->u.action.u.mesh_action.action_code = MESH_PATH_SEL_ACTION; | 223 | mgmt->u.action.u.mesh_action.action_code = MESH_PATH_SEL_ACTION; |
210 | ie_len = 12; | 224 | ie_len = 15; |
211 | pos = skb_put(skb, 2 + ie_len); | 225 | pos = skb_put(skb, 2 + ie_len); |
212 | *pos++ = WLAN_EID_PERR; | 226 | *pos++ = WLAN_EID_PERR; |
213 | *pos++ = ie_len; | 227 | *pos++ = ie_len; |
214 | /* mode flags, reserved */ | 228 | /* ttl */ |
215 | *pos++ = 0; | 229 | *pos++ = MESH_TTL; |
216 | /* number of destinations */ | 230 | /* number of destinations */ |
217 | *pos++ = 1; | 231 | *pos++ = 1; |
232 | /* | ||
233 | * flags bit, bit 1 is unset if we know the sequence number and | ||
234 | * bit 2 is set if we have a reason code | ||
235 | */ | ||
236 | *pos = 0; | ||
237 | if (!dst_dsn) | ||
238 | *pos |= MP_F_USN; | ||
239 | if (dst_rcode) | ||
240 | *pos |= MP_F_RCODE; | ||
241 | pos++; | ||
218 | memcpy(pos, dst, ETH_ALEN); | 242 | memcpy(pos, dst, ETH_ALEN); |
219 | pos += ETH_ALEN; | 243 | pos += ETH_ALEN; |
220 | memcpy(pos, &dst_dsn, 4); | 244 | memcpy(pos, &dst_dsn, 4); |
245 | pos += 4; | ||
246 | memcpy(pos, &dst_rcode, 2); | ||
221 | 247 | ||
222 | ieee80211_tx_skb(sdata, skb, 1); | 248 | ieee80211_tx_skb(sdata, skb, 1); |
223 | return 0; | 249 | return 0; |
@@ -598,13 +624,26 @@ fail: | |||
598 | static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata, | 624 | static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata, |
599 | struct ieee80211_mgmt *mgmt, u8 *perr_elem) | 625 | struct ieee80211_mgmt *mgmt, u8 *perr_elem) |
600 | { | 626 | { |
627 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | ||
601 | struct mesh_path *mpath; | 628 | struct mesh_path *mpath; |
629 | u8 ttl; | ||
602 | u8 *ta, *dst_addr; | 630 | u8 *ta, *dst_addr; |
631 | u8 dst_flags; | ||
603 | u32 dst_dsn; | 632 | u32 dst_dsn; |
633 | u16 dst_rcode; | ||
604 | 634 | ||
605 | ta = mgmt->sa; | 635 | ta = mgmt->sa; |
636 | ttl = PERR_IE_TTL(perr_elem); | ||
637 | if (ttl <= 1) { | ||
638 | ifmsh->mshstats.dropped_frames_ttl++; | ||
639 | return; | ||
640 | } | ||
641 | ttl--; | ||
642 | dst_flags = PERR_IE_DST_FLAGS(perr_elem); | ||
606 | dst_addr = PERR_IE_DST_ADDR(perr_elem); | 643 | dst_addr = PERR_IE_DST_ADDR(perr_elem); |
607 | dst_dsn = PERR_IE_DST_DSN(perr_elem); | 644 | dst_dsn = PERR_IE_DST_DSN(perr_elem); |
645 | dst_rcode = PERR_IE_DST_RCODE(perr_elem); | ||
646 | |||
608 | rcu_read_lock(); | 647 | rcu_read_lock(); |
609 | mpath = mesh_path_lookup(dst_addr, sdata); | 648 | mpath = mesh_path_lookup(dst_addr, sdata); |
610 | if (mpath) { | 649 | if (mpath) { |
@@ -616,7 +655,8 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata, | |||
616 | mpath->flags &= ~MESH_PATH_ACTIVE; | 655 | mpath->flags &= ~MESH_PATH_ACTIVE; |
617 | mpath->dsn = dst_dsn; | 656 | mpath->dsn = dst_dsn; |
618 | spin_unlock_bh(&mpath->state_lock); | 657 | spin_unlock_bh(&mpath->state_lock); |
619 | mesh_path_error_tx(dst_addr, cpu_to_le32(dst_dsn), | 658 | mesh_path_error_tx(ttl, dst_addr, cpu_to_le32(dst_dsn), |
659 | cpu_to_le16(dst_rcode), | ||
620 | sdata->dev->broadcast, sdata); | 660 | sdata->dev->broadcast, sdata); |
621 | } else | 661 | } else |
622 | spin_unlock_bh(&mpath->state_lock); | 662 | spin_unlock_bh(&mpath->state_lock); |
@@ -711,7 +751,7 @@ void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, | |||
711 | last_hop_metric); | 751 | last_hop_metric); |
712 | } | 752 | } |
713 | if (elems.perr) { | 753 | if (elems.perr) { |
714 | if (elems.perr_len != 12) | 754 | if (elems.perr_len != 15) |
715 | /* Right now we support only one destination per PERR */ | 755 | /* Right now we support only one destination per PERR */ |
716 | return; | 756 | return; |
717 | hwmp_perr_frame_process(sdata, mgmt, elems.perr); | 757 | hwmp_perr_frame_process(sdata, mgmt, elems.perr); |