diff options
author | Luis Carlos Cobo <luisca@cozybit.com> | 2008-03-31 20:39:18 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-04-01 17:14:12 -0400 |
commit | 6c4711b4697d93424e4b1f76a9929ba844d714a5 (patch) | |
tree | 84fe42a88c9bac873889bd03ae8173db1b2b3aeb | |
parent | 05e5e88373d91c75e9262a3f984be511960e510d (diff) |
mac80211: use a struct for bss->mesh_config
This allows cleaner code when accesing bss->mesh_config components.
Signed-off-by: Luis Carlos Cobo <luisca@cozybit.com>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | net/mac80211/ieee80211_i.h | 13 | ||||
-rw-r--r-- | net/mac80211/ieee80211_sta.c | 32 | ||||
-rw-r--r-- | net/mac80211/mesh.c | 4 | ||||
-rw-r--r-- | net/mac80211/mesh.h | 10 |
4 files changed, 41 insertions, 18 deletions
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 0997a0f96203..6c62dd42f915 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -69,6 +69,14 @@ struct ieee80211_fragment_entry { | |||
69 | u8 last_pn[6]; /* PN of the last fragment if CCMP was used */ | 69 | u8 last_pn[6]; /* PN of the last fragment if CCMP was used */ |
70 | }; | 70 | }; |
71 | 71 | ||
72 | struct bss_mesh_config { | ||
73 | u32 path_proto_id; | ||
74 | u32 path_metric_id; | ||
75 | u32 cong_control_id; | ||
76 | u32 channel_precedence; | ||
77 | u8 mesh_version; | ||
78 | }; | ||
79 | |||
72 | 80 | ||
73 | struct ieee80211_sta_bss { | 81 | struct ieee80211_sta_bss { |
74 | struct list_head list; | 82 | struct list_head list; |
@@ -94,7 +102,7 @@ struct ieee80211_sta_bss { | |||
94 | #ifdef CONFIG_MAC80211_MESH | 102 | #ifdef CONFIG_MAC80211_MESH |
95 | u8 *mesh_id; | 103 | u8 *mesh_id; |
96 | size_t mesh_id_len; | 104 | size_t mesh_id_len; |
97 | u8 *mesh_cfg; | 105 | struct bss_mesh_config *mesh_cfg; |
98 | #endif | 106 | #endif |
99 | #define IEEE80211_MAX_SUPP_RATES 32 | 107 | #define IEEE80211_MAX_SUPP_RATES 32 |
100 | u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; | 108 | u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; |
@@ -113,7 +121,8 @@ struct ieee80211_sta_bss { | |||
113 | u8 erp_value; | 121 | u8 erp_value; |
114 | }; | 122 | }; |
115 | 123 | ||
116 | static inline u8 *bss_mesh_cfg(struct ieee80211_sta_bss *bss) | 124 | static inline |
125 | struct bss_mesh_config *bss_mesh_cfg(struct ieee80211_sta_bss *bss) | ||
117 | { | 126 | { |
118 | #ifdef CONFIG_MAC80211_MESH | 127 | #ifdef CONFIG_MAC80211_MESH |
119 | return bss->mesh_cfg; | 128 | return bss->mesh_cfg; |
diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c index 927ffbfe8582..110eaf3ab58c 100644 --- a/net/mac80211/ieee80211_sta.c +++ b/net/mac80211/ieee80211_sta.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/rtnetlink.h> | 27 | #include <linux/rtnetlink.h> |
28 | #include <net/iw_handler.h> | 28 | #include <net/iw_handler.h> |
29 | #include <asm/types.h> | 29 | #include <asm/types.h> |
30 | #include <asm/unaligned.h> | ||
30 | 31 | ||
31 | #include <net/mac80211.h> | 32 | #include <net/mac80211.h> |
32 | #include "ieee80211_i.h" | 33 | #include "ieee80211_i.h" |
@@ -2123,6 +2124,11 @@ ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid, int freq, | |||
2123 | } | 2124 | } |
2124 | 2125 | ||
2125 | #ifdef CONFIG_MAC80211_MESH | 2126 | #ifdef CONFIG_MAC80211_MESH |
2127 | static inline u32 bss_mesh_cfg_get(u8 *mesh_cfg, u8 offset) | ||
2128 | { | ||
2129 | return be32_to_cpu(get_unaligned((__be32 *) (mesh_cfg + offset))); | ||
2130 | } | ||
2131 | |||
2126 | static struct ieee80211_sta_bss * | 2132 | static struct ieee80211_sta_bss * |
2127 | ieee80211_rx_mesh_bss_get(struct net_device *dev, u8 *mesh_id, int mesh_id_len, | 2133 | ieee80211_rx_mesh_bss_get(struct net_device *dev, u8 *mesh_id, int mesh_id_len, |
2128 | u8 *mesh_cfg, int freq) | 2134 | u8 *mesh_cfg, int freq) |
@@ -2162,7 +2168,7 @@ ieee80211_rx_mesh_bss_add(struct net_device *dev, u8 *mesh_id, int mesh_id_len, | |||
2162 | if (!bss) | 2168 | if (!bss) |
2163 | return NULL; | 2169 | return NULL; |
2164 | 2170 | ||
2165 | bss->mesh_cfg = kmalloc(MESH_CFG_CMP_LEN, GFP_ATOMIC); | 2171 | bss->mesh_cfg = kmalloc(sizeof(struct bss_mesh_config), GFP_ATOMIC); |
2166 | if (!bss->mesh_cfg) { | 2172 | if (!bss->mesh_cfg) { |
2167 | kfree(bss); | 2173 | kfree(bss); |
2168 | return NULL; | 2174 | return NULL; |
@@ -2180,7 +2186,12 @@ ieee80211_rx_mesh_bss_add(struct net_device *dev, u8 *mesh_id, int mesh_id_len, | |||
2180 | 2186 | ||
2181 | atomic_inc(&bss->users); | 2187 | atomic_inc(&bss->users); |
2182 | atomic_inc(&bss->users); | 2188 | atomic_inc(&bss->users); |
2183 | memcpy(bss->mesh_cfg, mesh_cfg, MESH_CFG_CMP_LEN); | 2189 | bss->mesh_cfg->mesh_version = mesh_cfg[0]; |
2190 | bss->mesh_cfg->path_proto_id = bss_mesh_cfg_get(mesh_cfg, PP_OFFSET); | ||
2191 | bss->mesh_cfg->path_metric_id = bss_mesh_cfg_get(mesh_cfg, PM_OFFSET); | ||
2192 | bss->mesh_cfg->cong_control_id = bss_mesh_cfg_get(mesh_cfg, CC_OFFSET); | ||
2193 | bss->mesh_cfg->channel_precedence = bss_mesh_cfg_get(mesh_cfg, | ||
2194 | CP_OFFSET); | ||
2184 | bss->mesh_id_len = mesh_id_len; | 2195 | bss->mesh_id_len = mesh_id_len; |
2185 | bss->freq = freq; | 2196 | bss->freq = freq; |
2186 | spin_lock_bh(&local->sta_bss_lock); | 2197 | spin_lock_bh(&local->sta_bss_lock); |
@@ -4057,36 +4068,33 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4057 | 4068 | ||
4058 | if (bss_mesh_cfg(bss)) { | 4069 | if (bss_mesh_cfg(bss)) { |
4059 | char *buf; | 4070 | char *buf; |
4060 | u8 *cfg = bss_mesh_cfg(bss); | 4071 | struct bss_mesh_config *cfg = bss_mesh_cfg(bss); |
4061 | buf = kmalloc(50, GFP_ATOMIC); | 4072 | buf = kmalloc(50, GFP_ATOMIC); |
4062 | if (buf) { | 4073 | if (buf) { |
4063 | memset(&iwe, 0, sizeof(iwe)); | 4074 | memset(&iwe, 0, sizeof(iwe)); |
4064 | iwe.cmd = IWEVCUSTOM; | 4075 | iwe.cmd = IWEVCUSTOM; |
4065 | sprintf(buf, "Mesh network (version %d)", cfg[0]); | 4076 | sprintf(buf, "Mesh network (version %d)", |
4077 | cfg->mesh_version); | ||
4066 | iwe.u.data.length = strlen(buf); | 4078 | iwe.u.data.length = strlen(buf); |
4067 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4079 | current_ev = iwe_stream_add_point(current_ev, end_buf, |
4068 | &iwe, buf); | 4080 | &iwe, buf); |
4069 | sprintf(buf, "Path Selection Protocol ID: " | 4081 | sprintf(buf, "Path Selection Protocol ID: " |
4070 | "0x%02X%02X%02X%02X", cfg[1], cfg[2], cfg[3], | 4082 | "0x%08X", cfg->path_proto_id); |
4071 | cfg[4]); | ||
4072 | iwe.u.data.length = strlen(buf); | 4083 | iwe.u.data.length = strlen(buf); |
4073 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4084 | current_ev = iwe_stream_add_point(current_ev, end_buf, |
4074 | &iwe, buf); | 4085 | &iwe, buf); |
4075 | sprintf(buf, "Path Selection Metric ID: " | 4086 | sprintf(buf, "Path Selection Metric ID: " |
4076 | "0x%02X%02X%02X%02X", cfg[5], cfg[6], cfg[7], | 4087 | "0x%08X", cfg->path_metric_id); |
4077 | cfg[8]); | ||
4078 | iwe.u.data.length = strlen(buf); | 4088 | iwe.u.data.length = strlen(buf); |
4079 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4089 | current_ev = iwe_stream_add_point(current_ev, end_buf, |
4080 | &iwe, buf); | 4090 | &iwe, buf); |
4081 | sprintf(buf, "Congestion Control Mode ID: " | 4091 | sprintf(buf, "Congestion Control Mode ID: " |
4082 | "0x%02X%02X%02X%02X", cfg[9], cfg[10], | 4092 | "0x%08X", cfg->cong_control_id); |
4083 | cfg[11], cfg[12]); | ||
4084 | iwe.u.data.length = strlen(buf); | 4093 | iwe.u.data.length = strlen(buf); |
4085 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4094 | current_ev = iwe_stream_add_point(current_ev, end_buf, |
4086 | &iwe, buf); | 4095 | &iwe, buf); |
4087 | sprintf(buf, "Channel Precedence: " | 4096 | sprintf(buf, "Channel Precedence: " |
4088 | "0x%02X%02X%02X%02X", cfg[13], cfg[14], | 4097 | "0x%08X", cfg->channel_precedence); |
4089 | cfg[15], cfg[16]); | ||
4090 | iwe.u.data.length = strlen(buf); | 4098 | iwe.u.data.length = strlen(buf); |
4091 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4099 | current_ev = iwe_stream_add_point(current_ev, end_buf, |
4092 | &iwe, buf); | 4100 | &iwe, buf); |
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index 594a3356a508..b10f1e543a94 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
@@ -11,10 +11,6 @@ | |||
11 | #include "ieee80211_i.h" | 11 | #include "ieee80211_i.h" |
12 | #include "mesh.h" | 12 | #include "mesh.h" |
13 | 13 | ||
14 | #define PP_OFFSET 1 /* Path Selection Protocol */ | ||
15 | #define PM_OFFSET 5 /* Path Selection Metric */ | ||
16 | #define CC_OFFSET 9 /* Congestion Control Mode */ | ||
17 | #define CAPAB_OFFSET 17 | ||
18 | #define ACCEPT_PLINKS 0x80 | 14 | #define ACCEPT_PLINKS 0x80 |
19 | 15 | ||
20 | int mesh_allocated; | 16 | int mesh_allocated; |
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h index 742003d3a841..8ff46ea0f1d7 100644 --- a/net/mac80211/mesh.h +++ b/net/mac80211/mesh.h | |||
@@ -157,6 +157,16 @@ struct mesh_rmc { | |||
157 | */ | 157 | */ |
158 | #define MESH_CFG_CMP_LEN 17 | 158 | #define MESH_CFG_CMP_LEN 17 |
159 | 159 | ||
160 | /* | ||
161 | * Components offset within the mesh configuration IE | ||
162 | */ | ||
163 | #define PP_OFFSET 1 /* Path Selection Protocol */ | ||
164 | #define PM_OFFSET 5 /* Path Selection Metric */ | ||
165 | #define CC_OFFSET 9 /* Congestion Control Mode */ | ||
166 | #define CP_OFFSET 13 /* Channel Precedence */ | ||
167 | #define CAPAB_OFFSET 17 /* Mesh Capabilities */ | ||
168 | |||
169 | |||
160 | /* Default values, timeouts in ms */ | 170 | /* Default values, timeouts in ms */ |
161 | #define MESH_TTL 5 | 171 | #define MESH_TTL 5 |
162 | #define MESH_MAX_RETR 3 | 172 | #define MESH_MAX_RETR 3 |