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 "ieee80211_i.h"
00017 
00018 
00019 /* Data structures */
00020 
00029 enum mesh_config_capab_flags {
00030         MESHCONF_CAPAB_ACCEPT_PLINKS = BIT(0),
00031         MESHCONF_CAPAB_FORWARDING = BIT(3),
00032         MESHCONF_CAPAB_TBTT_ADJUSTING = BIT(5),
00033 };
00034 
00053 enum mesh_path_flags {
00054         MESH_PATH_ACTIVE =      BIT(0),
00055         MESH_PATH_RESOLVING =   BIT(1),
00056         MESH_PATH_SN_VALID =    BIT(2),
00057         MESH_PATH_FIXED =       BIT(3),
00058         MESH_PATH_RESOLVED =    BIT(4),
00059         MESH_PATH_REQ_QUEUED =  BIT(5),
00060 };
00061 
00076 enum mesh_deferred_task_flags {
00077         MESH_WORK_HOUSEKEEPING,
00078         MESH_WORK_GROW_MPATH_TABLE,
00079         MESH_WORK_GROW_MPP_TABLE,
00080         MESH_WORK_ROOT,
00081         MESH_WORK_DRIFT_ADJUST,
00082 };
00083 
00116 struct mesh_path {
00117         u8 dst[ETH_ALEN];
00118         u8 mpp[ETH_ALEN];       /* used for MPP or MAP */
00119         struct ieee80211_sub_if_data *sdata;
00120         struct sta_info __rcu *next_hop;
00121         struct timer_list timer;
00122         struct sk_buff_head frame_queue;
00123         struct rcu_head rcu;
00124         u32 sn;
00125         u32 metric;
00126         u8 hop_count;
00127         unsigned long exp_time;
00128         u32 discovery_timeout;
00129         u8 discovery_retries;
00130         enum mesh_path_flags flags;
00131         spinlock_t state_lock;
00132         u8 rann_snd_addr[ETH_ALEN];
00133         u32 rann_metric;
00134         bool is_root;
00135         bool is_gate;
00136 };
00137 
00157 struct mesh_table {
00158         /* Number of buckets will be 2^N */
00159         struct hlist_head *hash_buckets;
00160         spinlock_t *hashwlock;          /* One per bucket, for add/del */
00161         unsigned int hash_mask;         /* (2^size_order) - 1 */
00162         __u32 hash_rnd;                 /* Used for hash generation */
00163         atomic_t entries;               /* Up to MAX_MESH_NEIGHBOURS */
00164         void (*free_node) (struct hlist_node *p, bool free_leafs);
00165         int (*copy_node) (struct hlist_node *p, struct mesh_table *newtbl);
00166         int size_order;
00167         int mean_chain_len;
00168         struct hlist_head *known_gates;
00169         spinlock_t gates_lock;
00170 
00171         struct rcu_head rcu_head;
00172 };
00173 
00174 /* Recent multicast cache */
00175 /* RMC_BUCKETS must be a power of 2, maximum 256 */
00176 #define RMC_BUCKETS             256
00177 #define RMC_QUEUE_MAX_LEN       4
00178 #define RMC_TIMEOUT             (3 * HZ)
00179 
00191 struct rmc_entry {
00192         struct list_head list;
00193         u32 seqnum;
00194         unsigned long exp_time;
00195         u8 sa[ETH_ALEN];
00196 };
00197 
00198 struct mesh_rmc {
00199         struct rmc_entry bucket[RMC_BUCKETS];
00200         u32 idx_mask;
00201 };
00202 
00203 #define IEEE80211_MESH_PEER_INACTIVITY_LIMIT (1800 * HZ)
00204 #define IEEE80211_MESH_HOUSEKEEPING_INTERVAL (60 * HZ)
00205 
00206 #define MESH_DEFAULT_BEACON_INTERVAL            1000    /* in 1024 us units */
00207 
00208 #define MESH_PATH_EXPIRE (600 * HZ)
00209 
00210 /* Default maximum number of plinks per interface */
00211 #define MESH_MAX_PLINKS         256
00212 
00213 /* Maximum number of paths per interface */
00214 #define MESH_MAX_MPATHS         1024
00215 
00216 /* Public interfaces */
00217 /* Various */
00218 int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
00219                                   const u8 *da, const u8 *sa);
00220 int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
00221                 struct ieee80211_sub_if_data *sdata, char *addr4or5,
00222                 char *addr6);
00223 int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
00224                 struct ieee80211_sub_if_data *sdata);
00225 bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
00226                         struct ieee802_11_elems *ie);
00227 void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
00228 void mesh_mgmt_ies_add(struct sk_buff *skb,
00229                 struct ieee80211_sub_if_data *sdata);
00230 int mesh_add_meshconf_ie(struct sk_buff *skb,
00231                          struct ieee80211_sub_if_data *sdata);
00232 int mesh_add_meshid_ie(struct sk_buff *skb,
00233                        struct ieee80211_sub_if_data *sdata);
00234 int mesh_add_rsn_ie(struct sk_buff *skb,
00235                     struct ieee80211_sub_if_data *sdata);
00236 int mesh_add_vendor_ies(struct sk_buff *skb,
00237                         struct ieee80211_sub_if_data *sdata);
00238 int mesh_add_ds_params_ie(struct sk_buff *skb,
00239                           struct ieee80211_sub_if_data *sdata);
00240 int mesh_add_ht_cap_ie(struct sk_buff *skb,
00241                        struct ieee80211_sub_if_data *sdata);
00242 int mesh_add_ht_oper_ie(struct sk_buff *skb,
00243                         struct ieee80211_sub_if_data *sdata);
00244 void mesh_rmc_free(struct ieee80211_sub_if_data *sdata);
00245 int mesh_rmc_init(struct ieee80211_sub_if_data *sdata);
00246 void ieee80211s_init(void);
00247 void ieee80211s_update_metric(struct ieee80211_local *local,
00248                 struct sta_info *stainfo, struct sk_buff *skb);
00249 void ieee80211s_stop(void);
00250 void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
00251 void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
00252 void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
00253 void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh);
00254 struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method);
00255 
00256 /* Mesh paths */
00257 int mesh_nexthop_lookup(struct sk_buff *skb,
00258                 struct ieee80211_sub_if_data *sdata);
00259 int mesh_nexthop_resolve(struct sk_buff *skb,
00260                          struct ieee80211_sub_if_data *sdata);
00261 void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata);
00262 struct mesh_path *mesh_path_lookup(u8 *dst,
00263                 struct ieee80211_sub_if_data *sdata);
00264 struct mesh_path *mpp_path_lookup(u8 *dst,
00265                                   struct ieee80211_sub_if_data *sdata);
00266 int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata);
00267 struct mesh_path *mesh_path_lookup_by_idx(int idx,
00268                 struct ieee80211_sub_if_data *sdata);
00269 void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop);
00270 void mesh_path_expire(struct ieee80211_sub_if_data *sdata);
00271 void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
00272                 struct ieee80211_mgmt *mgmt, size_t len);
00273 int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata);
00274 
00275 int mesh_path_add_gate(struct mesh_path *mpath);
00276 int mesh_path_send_to_gates(struct mesh_path *mpath);
00277 int mesh_gate_num(struct ieee80211_sub_if_data *sdata);
00278 /* Mesh plinks */
00279 void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
00280                            u8 *hw_addr,
00281                            struct ieee802_11_elems *ie);
00282 bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie);
00283 void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata);
00284 void mesh_plink_broken(struct sta_info *sta);
00285 void mesh_plink_deactivate(struct sta_info *sta);
00286 int mesh_plink_open(struct sta_info *sta);
00287 void mesh_plink_block(struct sta_info *sta);
00288 void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
00289                          struct ieee80211_mgmt *mgmt, size_t len,
00290                          struct ieee80211_rx_status *rx_status);
00291 
00292 /* Private interfaces */
00293 /* Mesh tables */
00294 void mesh_mpath_table_grow(void);
00295 void mesh_mpp_table_grow(void);
00296 /* Mesh paths */
00297 int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, __le16 target_rcode,
00298                        const u8 *ra, struct ieee80211_sub_if_data *sdata);
00299 void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
00300 void mesh_path_flush_pending(struct mesh_path *mpath);
00301 void mesh_path_tx_pending(struct mesh_path *mpath);
00302 int mesh_pathtbl_init(void);
00303 void mesh_pathtbl_unregister(void);
00304 int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata);
00305 void mesh_path_timer(unsigned long data);
00306 void mesh_path_flush_by_nexthop(struct sta_info *sta);
00307 void mesh_path_discard_frame(struct sk_buff *skb,
00308                 struct ieee80211_sub_if_data *sdata);
00309 void mesh_path_quiesce(struct ieee80211_sub_if_data *sdata);
00310 void mesh_path_restart(struct ieee80211_sub_if_data *sdata);
00311 void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata);
00312 
00313 bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt);
00314 extern int mesh_paths_generation;
00315 
00316 #ifdef CONFIG_MAC80211_MESH
00317 extern int mesh_allocated;
00318 
00319 static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata)
00320 {
00321         return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks -
00322                atomic_read(&sdata->u.mesh.mshstats.estab_plinks);
00323 }
00324 
00325 static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata)
00326 {
00327         return (min_t(long, mesh_plink_free_count(sdata),
00328                    MESH_MAX_PLINKS - sdata->local->num_sta)) > 0;
00329 }
00330 
00331 static inline void mesh_path_activate(struct mesh_path *mpath)
00332 {
00333         mpath->flags |= MESH_PATH_ACTIVE | MESH_PATH_RESOLVED;
00334 }
00335 
00336 static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
00337 {
00338         return sdata->u.mesh.mesh_pp_id == IEEE80211_PATH_PROTOCOL_HWMP;
00339 }
00340 
00341 void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local);
00342 
00343 void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata);
00344 void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata);
00345 void mesh_plink_quiesce(struct sta_info *sta);
00346 void mesh_plink_restart(struct sta_info *sta);
00347 void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata);
00348 void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata);
00349 #else
00350 #define mesh_allocated  0
00351 static inline void
00352 ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local) {}
00353 static inline void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata)
00354 {}
00355 static inline void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata)
00356 {}
00357 static inline void mesh_plink_quiesce(struct sta_info *sta) {}
00358 static inline void mesh_plink_restart(struct sta_info *sta) {}
00359 static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
00360 { return false; }
00361 static inline void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata)
00362 {}
00363 #endif
00364 
00365 #endif /* IEEE80211S_H */


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