mesh.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, 2009 open80211s Ltd.
00003  * Authors:    Luis Carlos Cobo <luisca@cozybit.com>
00004  *             Javier Cardona <javier@cozybit.com>
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License version 2 as
00008  * published by the Free Software Foundation.
00009  */
00010 
00011 #ifndef IEEE80211S_H
00012 #define IEEE80211S_H
00013 
00014 #include <linux/types.h>
00015 #include <linux/jhash.h>
00016 #include <asm/unaligned.h>
00017 #include "ieee80211_i.h"
00018 
00019 
00020 /* Data structures */
00021 
00038 enum mesh_path_flags {
00039         MESH_PATH_ACTIVE =      BIT(0),
00040         MESH_PATH_RESOLVING =   BIT(1),
00041         MESH_PATH_SN_VALID =    BIT(2),
00042         MESH_PATH_FIXED =       BIT(3),
00043         MESH_PATH_RESOLVED =    BIT(4),
00044 };
00045 
00058 enum mesh_deferred_task_flags {
00059         MESH_WORK_HOUSEKEEPING,
00060         MESH_WORK_GROW_MPATH_TABLE,
00061         MESH_WORK_GROW_MPP_TABLE,
00062         MESH_WORK_ROOT,
00063 };
00064 
00094 struct mesh_path {
00095         u8 dst[ETH_ALEN];
00096         u8 mpp[ETH_ALEN];       /* used for MPP or MAP */
00097         struct ieee80211_sub_if_data *sdata;
00098         struct sta_info __rcu *next_hop;
00099         struct timer_list timer;
00100         struct sk_buff_head frame_queue;
00101         struct rcu_head rcu;
00102         u32 sn;
00103         u32 metric;
00104         u8 hop_count;
00105         unsigned long exp_time;
00106         u32 discovery_timeout;
00107         u8 discovery_retries;
00108         enum mesh_path_flags flags;
00109         spinlock_t state_lock;
00110         bool is_gate;
00111 };
00112 
00132 struct mesh_table {
00133         /* Number of buckets will be 2^N */
00134         struct hlist_head *hash_buckets;
00135         spinlock_t *hashwlock;          /* One per bucket, for add/del */
00136         unsigned int hash_mask;         /* (2^size_order) - 1 */
00137         __u32 hash_rnd;                 /* Used for hash generation */
00138         atomic_t entries;               /* Up to MAX_MESH_NEIGHBOURS */
00139         void (*free_node) (struct hlist_node *p, bool free_leafs);
00140         int (*copy_node) (struct hlist_node *p, struct mesh_table *newtbl);
00141         int size_order;
00142         int mean_chain_len;
00143         struct hlist_head *known_gates;
00144         spinlock_t gates_lock;
00145 
00146         struct rcu_head rcu_head;
00147 };
00148 
00149 /* Recent multicast cache */
00150 /* RMC_BUCKETS must be a power of 2, maximum 256 */
00151 #define RMC_BUCKETS             256
00152 #define RMC_QUEUE_MAX_LEN       4
00153 #define RMC_TIMEOUT             (3 * HZ)
00154 
00166 struct rmc_entry {
00167         struct list_head list;
00168         u32 seqnum;
00169         unsigned long exp_time;
00170         u8 sa[ETH_ALEN];
00171 };
00172 
00173 struct mesh_rmc {
00174         struct rmc_entry bucket[RMC_BUCKETS];
00175         u32 idx_mask;
00176 };
00177 
00178 #define IEEE80211_MESH_PEER_INACTIVITY_LIMIT (1800 * HZ)
00179 #define IEEE80211_MESH_HOUSEKEEPING_INTERVAL (60 * HZ)
00180 
00181 #define MESH_DEFAULT_BEACON_INTERVAL            1000    /* in 1024 us units */
00182 
00183 #define MESH_PATH_EXPIRE (600 * HZ)
00184 
00185 /* Default maximum number of plinks per interface */
00186 #define MESH_MAX_PLINKS         256
00187 
00188 /* Maximum number of paths per interface */
00189 #define MESH_MAX_MPATHS         1024
00190 
00191 /* Public interfaces */
00192 /* Various */
00193 int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
00194                                   const u8 *da, const u8 *sa);
00195 int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
00196                 struct ieee80211_sub_if_data *sdata, char *addr4or5,
00197                 char *addr6);
00198 int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
00199                 struct ieee80211_sub_if_data *sdata);
00200 bool mesh_matches_local(struct ieee802_11_elems *ie,
00201                 struct ieee80211_sub_if_data *sdata);
00202 void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
00203 void mesh_mgmt_ies_add(struct sk_buff *skb,
00204                 struct ieee80211_sub_if_data *sdata);
00205 int mesh_add_meshconf_ie(struct sk_buff *skb,
00206                          struct ieee80211_sub_if_data *sdata);
00207 int mesh_add_meshid_ie(struct sk_buff *skb,
00208                        struct ieee80211_sub_if_data *sdata);
00209 int mesh_add_rsn_ie(struct sk_buff *skb,
00210                     struct ieee80211_sub_if_data *sdata);
00211 int mesh_add_vendor_ies(struct sk_buff *skb,
00212                         struct ieee80211_sub_if_data *sdata);
00213 int mesh_add_ds_params_ie(struct sk_buff *skb,
00214                           struct ieee80211_sub_if_data *sdata);
00215 void mesh_rmc_free(struct ieee80211_sub_if_data *sdata);
00216 int mesh_rmc_init(struct ieee80211_sub_if_data *sdata);
00217 void ieee80211s_init(void);
00218 void ieee80211s_update_metric(struct ieee80211_local *local,
00219                 struct sta_info *stainfo, struct sk_buff *skb);
00220 void ieee80211s_stop(void);
00221 void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
00222 void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
00223 void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
00224 void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh);
00225 
00226 /* Mesh paths */
00227 int mesh_nexthop_lookup(struct sk_buff *skb,
00228                 struct ieee80211_sub_if_data *sdata);
00229 void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata);
00230 struct mesh_path *mesh_path_lookup(u8 *dst,
00231                 struct ieee80211_sub_if_data *sdata);
00232 struct mesh_path *mpp_path_lookup(u8 *dst,
00233                                   struct ieee80211_sub_if_data *sdata);
00234 int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata);
00235 struct mesh_path *mesh_path_lookup_by_idx(int idx,
00236                 struct ieee80211_sub_if_data *sdata);
00237 void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop);
00238 void mesh_path_expire(struct ieee80211_sub_if_data *sdata);
00239 void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
00240                 struct ieee80211_mgmt *mgmt, size_t len);
00241 int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata);
00242 
00243 int mesh_path_add_gate(struct mesh_path *mpath);
00244 int mesh_path_send_to_gates(struct mesh_path *mpath);
00245 int mesh_gate_num(struct ieee80211_sub_if_data *sdata);
00246 /* Mesh plinks */
00247 void mesh_neighbour_update(u8 *hw_addr, u32 rates,
00248                 struct ieee80211_sub_if_data *sdata,
00249                 struct ieee802_11_elems *ie);
00250 bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie);
00251 void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata);
00252 void mesh_plink_broken(struct sta_info *sta);
00253 void mesh_plink_deactivate(struct sta_info *sta);
00254 int mesh_plink_open(struct sta_info *sta);
00255 void mesh_plink_block(struct sta_info *sta);
00256 void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
00257                          struct ieee80211_mgmt *mgmt, size_t len,
00258                          struct ieee80211_rx_status *rx_status);
00259 
00260 /* Private interfaces */
00261 /* Mesh tables */
00262 void mesh_mpath_table_grow(void);
00263 void mesh_mpp_table_grow(void);
00264 /* Mesh paths */
00265 int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, __le16 target_rcode,
00266                        const u8 *ra, struct ieee80211_sub_if_data *sdata);
00267 void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
00268 void mesh_path_flush_pending(struct mesh_path *mpath);
00269 void mesh_path_tx_pending(struct mesh_path *mpath);
00270 int mesh_pathtbl_init(void);
00271 void mesh_pathtbl_unregister(void);
00272 int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata);
00273 void mesh_path_timer(unsigned long data);
00274 void mesh_path_flush_by_nexthop(struct sta_info *sta);
00275 void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata);
00276 void mesh_path_discard_frame(struct sk_buff *skb,
00277                 struct ieee80211_sub_if_data *sdata);
00278 void mesh_path_quiesce(struct ieee80211_sub_if_data *sdata);
00279 void mesh_path_restart(struct ieee80211_sub_if_data *sdata);
00280 void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata);
00281 
00282 bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt);
00283 extern int mesh_paths_generation;
00284 
00285 #ifdef CONFIG_MAC80211_MESH
00286 extern int mesh_allocated;
00287 
00288 static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata)
00289 {
00290         return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks -
00291                atomic_read(&sdata->u.mesh.mshstats.estab_plinks);
00292 }
00293 
00294 static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata)
00295 {
00296         return (min_t(long, mesh_plink_free_count(sdata),
00297                    MESH_MAX_PLINKS - sdata->local->num_sta)) > 0;
00298 }
00299 
00300 static inline void mesh_path_activate(struct mesh_path *mpath)
00301 {
00302         mpath->flags |= MESH_PATH_ACTIVE | MESH_PATH_RESOLVED;
00303 }
00304 
00305 static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
00306 {
00307         return sdata->u.mesh.mesh_pp_id == IEEE80211_PATH_PROTOCOL_HWMP;
00308 }
00309 
00310 void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local);
00311 
00312 void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata);
00313 void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata);
00314 void mesh_plink_quiesce(struct sta_info *sta);
00315 void mesh_plink_restart(struct sta_info *sta);
00316 #else
00317 #define mesh_allocated  0
00318 static inline void
00319 ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local) {}
00320 static inline void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata)
00321 {}
00322 static inline void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata)
00323 {}
00324 static inline void mesh_plink_quiesce(struct sta_info *sta) {}
00325 static inline void mesh_plink_restart(struct sta_info *sta) {}
00326 static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
00327 { return false; }
00328 #endif
00329 
00330 #endif /* IEEE80211S_H */


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Mon Oct 6 2014 08:27:10