Commit 6c4711b4 authored by Luis Carlos Cobo's avatar Luis Carlos Cobo Committed by John W. Linville

mac80211: use a struct for bss->mesh_config

This allows cleaner code when accesing bss->mesh_config components.
Signed-off-by: default avatarLuis Carlos Cobo <luisca@cozybit.com>
Acked-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 05e5e883
...@@ -69,6 +69,14 @@ struct ieee80211_fragment_entry { ...@@ -69,6 +69,14 @@ struct ieee80211_fragment_entry {
u8 last_pn[6]; /* PN of the last fragment if CCMP was used */ u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
}; };
struct bss_mesh_config {
u32 path_proto_id;
u32 path_metric_id;
u32 cong_control_id;
u32 channel_precedence;
u8 mesh_version;
};
struct ieee80211_sta_bss { struct ieee80211_sta_bss {
struct list_head list; struct list_head list;
...@@ -94,7 +102,7 @@ struct ieee80211_sta_bss { ...@@ -94,7 +102,7 @@ struct ieee80211_sta_bss {
#ifdef CONFIG_MAC80211_MESH #ifdef CONFIG_MAC80211_MESH
u8 *mesh_id; u8 *mesh_id;
size_t mesh_id_len; size_t mesh_id_len;
u8 *mesh_cfg; struct bss_mesh_config *mesh_cfg;
#endif #endif
#define IEEE80211_MAX_SUPP_RATES 32 #define IEEE80211_MAX_SUPP_RATES 32
u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
...@@ -113,7 +121,8 @@ struct ieee80211_sta_bss { ...@@ -113,7 +121,8 @@ struct ieee80211_sta_bss {
u8 erp_value; u8 erp_value;
}; };
static inline u8 *bss_mesh_cfg(struct ieee80211_sta_bss *bss) static inline
struct bss_mesh_config *bss_mesh_cfg(struct ieee80211_sta_bss *bss)
{ {
#ifdef CONFIG_MAC80211_MESH #ifdef CONFIG_MAC80211_MESH
return bss->mesh_cfg; return bss->mesh_cfg;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <net/iw_handler.h> #include <net/iw_handler.h>
#include <asm/types.h> #include <asm/types.h>
#include <asm/unaligned.h>
#include <net/mac80211.h> #include <net/mac80211.h>
#include "ieee80211_i.h" #include "ieee80211_i.h"
...@@ -2123,6 +2124,11 @@ ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid, int freq, ...@@ -2123,6 +2124,11 @@ ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid, int freq,
} }
#ifdef CONFIG_MAC80211_MESH #ifdef CONFIG_MAC80211_MESH
static inline u32 bss_mesh_cfg_get(u8 *mesh_cfg, u8 offset)
{
return be32_to_cpu(get_unaligned((__be32 *) (mesh_cfg + offset)));
}
static struct ieee80211_sta_bss * static struct ieee80211_sta_bss *
ieee80211_rx_mesh_bss_get(struct net_device *dev, u8 *mesh_id, int mesh_id_len, ieee80211_rx_mesh_bss_get(struct net_device *dev, u8 *mesh_id, int mesh_id_len,
u8 *mesh_cfg, int freq) 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,7 +2168,7 @@ ieee80211_rx_mesh_bss_add(struct net_device *dev, u8 *mesh_id, int mesh_id_len,
if (!bss) if (!bss)
return NULL; return NULL;
bss->mesh_cfg = kmalloc(MESH_CFG_CMP_LEN, GFP_ATOMIC); bss->mesh_cfg = kmalloc(sizeof(struct bss_mesh_config), GFP_ATOMIC);
if (!bss->mesh_cfg) { if (!bss->mesh_cfg) {
kfree(bss); kfree(bss);
return NULL; return NULL;
...@@ -2180,7 +2186,12 @@ ieee80211_rx_mesh_bss_add(struct net_device *dev, u8 *mesh_id, int mesh_id_len, ...@@ -2180,7 +2186,12 @@ ieee80211_rx_mesh_bss_add(struct net_device *dev, u8 *mesh_id, int mesh_id_len,
atomic_inc(&bss->users); atomic_inc(&bss->users);
atomic_inc(&bss->users); atomic_inc(&bss->users);
memcpy(bss->mesh_cfg, mesh_cfg, MESH_CFG_CMP_LEN); bss->mesh_cfg->mesh_version = mesh_cfg[0];
bss->mesh_cfg->path_proto_id = bss_mesh_cfg_get(mesh_cfg, PP_OFFSET);
bss->mesh_cfg->path_metric_id = bss_mesh_cfg_get(mesh_cfg, PM_OFFSET);
bss->mesh_cfg->cong_control_id = bss_mesh_cfg_get(mesh_cfg, CC_OFFSET);
bss->mesh_cfg->channel_precedence = bss_mesh_cfg_get(mesh_cfg,
CP_OFFSET);
bss->mesh_id_len = mesh_id_len; bss->mesh_id_len = mesh_id_len;
bss->freq = freq; bss->freq = freq;
spin_lock_bh(&local->sta_bss_lock); spin_lock_bh(&local->sta_bss_lock);
...@@ -4057,36 +4068,33 @@ ieee80211_sta_scan_result(struct net_device *dev, ...@@ -4057,36 +4068,33 @@ ieee80211_sta_scan_result(struct net_device *dev,
if (bss_mesh_cfg(bss)) { if (bss_mesh_cfg(bss)) {
char *buf; char *buf;
u8 *cfg = bss_mesh_cfg(bss); struct bss_mesh_config *cfg = bss_mesh_cfg(bss);
buf = kmalloc(50, GFP_ATOMIC); buf = kmalloc(50, GFP_ATOMIC);
if (buf) { if (buf) {
memset(&iwe, 0, sizeof(iwe)); memset(&iwe, 0, sizeof(iwe));
iwe.cmd = IWEVCUSTOM; iwe.cmd = IWEVCUSTOM;
sprintf(buf, "Mesh network (version %d)", cfg[0]); sprintf(buf, "Mesh network (version %d)",
cfg->mesh_version);
iwe.u.data.length = strlen(buf); iwe.u.data.length = strlen(buf);
current_ev = iwe_stream_add_point(current_ev, end_buf, current_ev = iwe_stream_add_point(current_ev, end_buf,
&iwe, buf); &iwe, buf);
sprintf(buf, "Path Selection Protocol ID: " sprintf(buf, "Path Selection Protocol ID: "
"0x%02X%02X%02X%02X", cfg[1], cfg[2], cfg[3], "0x%08X", cfg->path_proto_id);
cfg[4]);
iwe.u.data.length = strlen(buf); iwe.u.data.length = strlen(buf);
current_ev = iwe_stream_add_point(current_ev, end_buf, current_ev = iwe_stream_add_point(current_ev, end_buf,
&iwe, buf); &iwe, buf);
sprintf(buf, "Path Selection Metric ID: " sprintf(buf, "Path Selection Metric ID: "
"0x%02X%02X%02X%02X", cfg[5], cfg[6], cfg[7], "0x%08X", cfg->path_metric_id);
cfg[8]);
iwe.u.data.length = strlen(buf); iwe.u.data.length = strlen(buf);
current_ev = iwe_stream_add_point(current_ev, end_buf, current_ev = iwe_stream_add_point(current_ev, end_buf,
&iwe, buf); &iwe, buf);
sprintf(buf, "Congestion Control Mode ID: " sprintf(buf, "Congestion Control Mode ID: "
"0x%02X%02X%02X%02X", cfg[9], cfg[10], "0x%08X", cfg->cong_control_id);
cfg[11], cfg[12]);
iwe.u.data.length = strlen(buf); iwe.u.data.length = strlen(buf);
current_ev = iwe_stream_add_point(current_ev, end_buf, current_ev = iwe_stream_add_point(current_ev, end_buf,
&iwe, buf); &iwe, buf);
sprintf(buf, "Channel Precedence: " sprintf(buf, "Channel Precedence: "
"0x%02X%02X%02X%02X", cfg[13], cfg[14], "0x%08X", cfg->channel_precedence);
cfg[15], cfg[16]);
iwe.u.data.length = strlen(buf); iwe.u.data.length = strlen(buf);
current_ev = iwe_stream_add_point(current_ev, end_buf, current_ev = iwe_stream_add_point(current_ev, end_buf,
&iwe, buf); &iwe, buf);
......
...@@ -11,10 +11,6 @@ ...@@ -11,10 +11,6 @@
#include "ieee80211_i.h" #include "ieee80211_i.h"
#include "mesh.h" #include "mesh.h"
#define PP_OFFSET 1 /* Path Selection Protocol */
#define PM_OFFSET 5 /* Path Selection Metric */
#define CC_OFFSET 9 /* Congestion Control Mode */
#define CAPAB_OFFSET 17
#define ACCEPT_PLINKS 0x80 #define ACCEPT_PLINKS 0x80
int mesh_allocated; int mesh_allocated;
......
...@@ -157,6 +157,16 @@ struct mesh_rmc { ...@@ -157,6 +157,16 @@ struct mesh_rmc {
*/ */
#define MESH_CFG_CMP_LEN 17 #define MESH_CFG_CMP_LEN 17
/*
* Components offset within the mesh configuration IE
*/
#define PP_OFFSET 1 /* Path Selection Protocol */
#define PM_OFFSET 5 /* Path Selection Metric */
#define CC_OFFSET 9 /* Congestion Control Mode */
#define CP_OFFSET 13 /* Channel Precedence */
#define CAPAB_OFFSET 17 /* Mesh Capabilities */
/* Default values, timeouts in ms */ /* Default values, timeouts in ms */
#define MESH_TTL 5 #define MESH_TTL 5
#define MESH_MAX_RETR 3 #define MESH_MAX_RETR 3
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment