#ifndef _NET80211_IEEE80211_MESH_H_
#define _NET80211_IEEE80211_MESH_H_
#define IEEE80211_MESH_DEFAULT_TTL 31
#define IEEE80211_MESH_MAX_NEIGHBORS 15
#define IEEE80211_MESH_CONF_SZ (7)
struct ieee80211_meshconf_ie {
uint8_t conf_ie;
uint8_t conf_len;
uint8_t conf_pselid;
uint8_t conf_pmetid;
uint8_t conf_ccid;
uint8_t conf_syncid;
uint8_t conf_authid;
uint8_t conf_form;
uint8_t conf_cap;
} __packed;
enum {
IEEE80211_MESHCONF_PATH_HWMP = 1,
IEEE80211_MESHCONF_PATH_VENDOR = 255,
};
enum {
IEEE80211_MESHCONF_METRIC_AIRTIME = 1,
IEEE80211_MESHCONF_METRIC_VENDOR = 255,
};
enum {
IEEE80211_MESHCONF_CC_DISABLED = 0,
IEEE80211_MESHCONF_CC_SIG = 1,
IEEE80211_MESHCONF_CC_VENDOR = 255,
};
enum {
IEEE80211_MESHCONF_SYNC_NEIGHOFF = 1,
IEEE80211_MESHCONF_SYNC_VENDOR = 255,
};
enum {
IEEE80211_MESHCONF_AUTH_DISABLED = 0,
IEEE80211_MESHCONF_AUTH_SEA = 1,
IEEE80211_MESHCONF_AUTH_8021X = 2,
IEEE80211_MESHCONF_AUTH_VENDOR = 255,
};
#define IEEE80211_MESHCONF_FORM_GATE 0x01
#define IEEE80211_MESHCONF_FORM_NNEIGH_MASK 0x7E
#define IEEE80211_MESHCONF_FORM_SA 0xF0
#define IEEE80211_MESHCONF_CAP_AP 0x01
#define IEEE80211_MESHCONF_CAP_MCCAS 0x02
#define IEEE80211_MESHCONF_CAP_MCCAE 0x04
#define IEEE80211_MESHCONF_CAP_FWRD 0x08
#define IEEE80211_MESHCONF_CAP_BTR 0x10
#define IEEE80211_MESHCONF_CAP_TBTT 0x20
#define IEEE80211_MESHCONF_CAP_PSL 0x40
struct ieee80211_meshid_ie {
uint8_t id_ie;
uint8_t id_len;
} __packed;
struct ieee80211_meshlmetric_ie {
uint8_t lm_ie;
uint8_t lm_len;
uint8_t lm_flags;
#define IEEE80211_MESH_LMETRIC_FLAGS_REQ 0x01
uint32_t lm_metric;
#define IEEE80211_MESHLMETRIC_INITIALVAL 0
} __packed;
struct ieee80211_meshcngst_ie {
uint8_t cngst_ie;
uint8_t cngst_len;
uint16_t cngst_timer[4];
} __packed;
#define IEEE80211_MPM_BASE_SZ (4)
#define IEEE80211_MPM_MAX_SZ (8)
struct ieee80211_meshpeer_ie {
uint8_t peer_ie;
uint8_t peer_len;
uint16_t peer_proto;
uint16_t peer_llinkid;
uint16_t peer_linkid;
uint16_t peer_rcode;
} __packed;
enum {
IEEE80211_MPPID_MPM = 0,
IEEE80211_MPPID_AUTH_MPM = 1,
};
#ifdef notyet
struct ieee80211_meshcsa_ie {
uint8_t csa_ie;
uint8_t csa_len;
uint8_t csa_mode;
uint8_t csa_newclass;
uint8_t csa_newchan;
uint8_t csa_precvalue;
uint8_t csa_count;
} __packed;
struct ieee80211_meshawakew_ie {
uint8_t awakew_ie;
uint8_t awakew_len;
uint8_t awakew_windowlen;
} __packed;
struct ieee80211_meshbeacont_ie {
uint8_t beacont_ie;
uint8_t beacont_len;
struct {
uint8_t mp_aid;
uint16_t mp_btime;
uint16_t mp_bint;
} __packed mp[1];
} __packed;
#endif
#define IEEE80211_MESHGANN_BASE_SZ (15)
struct ieee80211_meshgann_ie {
uint8_t gann_ie;
uint8_t gann_len;
uint8_t gann_flags;
uint8_t gann_hopcount;
uint8_t gann_ttl;
uint8_t gann_addr[IEEE80211_ADDR_LEN];
uint32_t gann_seq;
uint16_t gann_interval;
} __packed;
#define IEEE80211_MESHRANN_BASE_SZ (21)
struct ieee80211_meshrann_ie {
uint8_t rann_ie;
uint8_t rann_len;
uint8_t rann_flags;
#define IEEE80211_MESHRANN_FLAGS_GATE 0x01
uint8_t rann_hopcount;
uint8_t rann_ttl;
uint8_t rann_addr[IEEE80211_ADDR_LEN];
uint32_t rann_seq;
uint32_t rann_interval;
uint32_t rann_metric;
} __packed;
#define IEEE80211_MESHPREQ_BASE_SZ (26)
#define IEEE80211_MESHPREQ_BASE_SZ_AE (32)
#define IEEE80211_MESHPREQ_TRGT_SZ (11)
#define IEEE80211_MESHPREQ_TCNT_OFFSET (27)
#define IEEE80211_MESHPREQ_TCNT_OFFSET_AE (33)
struct ieee80211_meshpreq_ie {
uint8_t preq_ie;
uint8_t preq_len;
uint8_t preq_flags;
#define IEEE80211_MESHPREQ_FLAGS_GATE 0x01
#define IEEE80211_MESHPREQ_FLAGS_AM 0x02
#define IEEE80211_MESHPREQ_FLAGS_PP 0x04
#define IEEE80211_MESHPREQ_FLAGS_AE 0x40
uint8_t preq_hopcount;
uint8_t preq_ttl;
uint32_t preq_id;
uint8_t preq_origaddr[IEEE80211_ADDR_LEN];
uint32_t preq_origseq;
uint8_t preq_orig_ext_addr[IEEE80211_ADDR_LEN];
uint32_t preq_lifetime;
uint32_t preq_metric;
uint8_t preq_tcount;
struct {
uint8_t target_flags;
#define IEEE80211_MESHPREQ_TFLAGS_TO 0x01
#define IEEE80211_MESHPREQ_TFLAGS_USN 0x04
uint8_t target_addr[IEEE80211_ADDR_LEN];
uint32_t target_seq;
} __packed preq_targets[1];
} __packed;
#define IEEE80211_MESHPREP_BASE_SZ (31)
#define IEEE80211_MESHPREP_BASE_SZ_AE (37)
struct ieee80211_meshprep_ie {
uint8_t prep_ie;
uint8_t prep_len;
uint8_t prep_flags;
#define IEEE80211_MESHPREP_FLAGS_AE 0x40
uint8_t prep_hopcount;
uint8_t prep_ttl;
uint8_t prep_targetaddr[IEEE80211_ADDR_LEN];
uint32_t prep_targetseq;
uint8_t prep_target_ext_addr[IEEE80211_ADDR_LEN];
uint32_t prep_lifetime;
uint32_t prep_metric;
uint8_t prep_origaddr[IEEE80211_ADDR_LEN];
uint32_t prep_origseq;
} __packed;
#define IEEE80211_MESHPERR_MAXDEST (19)
#define IEEE80211_MESHPERR_NDEST_OFFSET (3)
#define IEEE80211_MESHPERR_BASE_SZ (2)
#define IEEE80211_MESHPERR_DEST_SZ (13)
#define IEEE80211_MESHPERR_DEST_SZ_AE (19)
struct ieee80211_meshperr_ie {
uint8_t perr_ie;
uint8_t perr_len;
uint8_t perr_ttl;
uint8_t perr_ndests;
struct {
uint8_t dest_flags;
#define IEEE80211_MESHPERR_DFLAGS_USN 0x01
#define IEEE80211_MESHPERR_DFLAGS_RC 0x02
#define IEEE80211_MESHPERR_FLAGS_AE 0x40
uint8_t dest_addr[IEEE80211_ADDR_LEN];
uint32_t dest_seq;
uint8_t dest_ext_addr[IEEE80211_ADDR_LEN];
uint16_t dest_rcode;
} __packed perr_dests[1];
} __packed;
#ifdef notyet
struct ieee80211_meshpu_ie {
uint8_t pu_ie;
uint8_t pu_len;
uint8_t pu_flags;
#define IEEE80211_MESHPU_FLAGS_MASK 0x1
#define IEEE80211_MESHPU_FLAGS_DEL 0x0
#define IEEE80211_MESHPU_FLAGS_ADD 0x1
uint8_t pu_seq;
uint8_t pu_addr[IEEE80211_ADDR_LEN];
uint8_t pu_naddr;
} __packed;
struct ieee80211_meshpuc_ie {
uint8_t puc_ie;
uint8_t puc_len;
uint8_t puc_flags;
uint8_t puc_seq;
uint8_t puc_daddr[IEEE80211_ADDR_LEN];
} __packed;
#endif
#define IEEE80211_ACTION_CAT_INTERWORK 15
#define IEEE80211_ACTION_CAT_RESOURCE 16
#define IEEE80211_ACTION_CAT_PROXY 17
enum {
IEEE80211_ACTION_MESHPEERING_OPEN = 1,
IEEE80211_ACTION_MESHPEERING_CONFIRM = 2,
IEEE80211_ACTION_MESHPEERING_CLOSE = 3,
};
enum {
IEEE80211_ACTION_MESH_LMETRIC = 0,
IEEE80211_ACTION_MESH_HWMP = 1,
IEEE80211_ACTION_MESH_GANN = 2,
IEEE80211_ACTION_MESH_CC = 3,
IEEE80211_ACTION_MESH_MCCA_SREQ = 4,
IEEE80211_ACTION_MESH_MCCA_SREP = 5,
IEEE80211_ACTION_MESH_MCCA_AREQ = 6,
IEEE80211_ACTION_MESH_MCCA_ADVER =7,
IEEE80211_ACTION_MESH_MCCA_TRDOWN = 8,
IEEE80211_ACTION_MESH_TBTT_REQ = 9,
IEEE80211_ACTION_MESH_TBTT_RES = 10,
};
struct ieee80211_meshcntl {
uint8_t mc_flags;
uint8_t mc_ttl;
uint8_t mc_seq[4];
} __packed;
struct ieee80211_meshcntl_ae01 {
uint8_t mc_flags;
uint8_t mc_ttl;
uint8_t mc_seq[4];
uint8_t mc_addr4[IEEE80211_ADDR_LEN];
} __packed;
struct ieee80211_meshcntl_ae10 {
uint8_t mc_flags;
uint8_t mc_ttl;
uint8_t mc_seq[4];
uint8_t mc_addr5[IEEE80211_ADDR_LEN];
uint8_t mc_addr6[IEEE80211_ADDR_LEN];
} __packed;
#define IEEE80211_MESH_AE_MASK 0x03
enum {
IEEE80211_MESH_AE_00 = 0,
IEEE80211_MESH_AE_01 = 1,
IEEE80211_MESH_AE_10 = 2,
IEEE80211_MESH_AE_11 = 3,
};
#ifdef _KERNEL
MALLOC_DECLARE(M_80211_MESH_PREQ);
MALLOC_DECLARE(M_80211_MESH_PREP);
MALLOC_DECLARE(M_80211_MESH_PERR);
MALLOC_DECLARE(M_80211_MESH_RT);
MALLOC_DECLARE(M_80211_MESH_GT_RT);
struct ieee80211_mesh_route {
TAILQ_ENTRY(ieee80211_mesh_route) rt_next;
struct ieee80211vap *rt_vap;
ieee80211_rte_lock_t rt_lock;
struct callout rt_discovery;
int rt_updtime;
uint8_t rt_dest[IEEE80211_ADDR_LEN];
uint8_t rt_mesh_gate[IEEE80211_ADDR_LEN];
uint8_t rt_nexthop[IEEE80211_ADDR_LEN];
uint32_t rt_metric;
uint16_t rt_nhops;
uint16_t rt_flags;
#define IEEE80211_MESHRT_FLAGS_DISCOVER 0x01
#define IEEE80211_MESHRT_FLAGS_VALID 0x02
#define IEEE80211_MESHRT_FLAGS_PROXY 0x04
#define IEEE80211_MESHRT_FLAGS_GATE 0x08
uint32_t rt_lifetime;
uint32_t rt_lastmseq;
uint32_t rt_ext_seq;
void *rt_priv;
};
#define IEEE80211_MESH_ROUTE_PRIV(rt, cast) ((cast *)rt->rt_priv)
struct ieee80211_mesh_gate_route {
TAILQ_ENTRY(ieee80211_mesh_gate_route) gr_next;
uint8_t gr_addr[IEEE80211_ADDR_LEN];
uint32_t gr_lastseq;
struct ieee80211_mesh_route *gr_route;
};
#define IEEE80211_MESH_PROTO_DSZ 12
enum ieee80211_state;
struct ieee80211_mesh_proto_path {
uint8_t mpp_active;
char mpp_descr[IEEE80211_MESH_PROTO_DSZ];
uint8_t mpp_ie;
struct ieee80211_node *
(*mpp_discover)(struct ieee80211vap *,
const uint8_t [IEEE80211_ADDR_LEN],
struct mbuf *);
void (*mpp_peerdown)(struct ieee80211_node *);
void (*mpp_senderror)(struct ieee80211vap *,
const uint8_t [IEEE80211_ADDR_LEN],
struct ieee80211_mesh_route *, int);
void (*mpp_vattach)(struct ieee80211vap *);
void (*mpp_vdetach)(struct ieee80211vap *);
int (*mpp_newstate)(struct ieee80211vap *,
enum ieee80211_state, int);
const size_t mpp_privlen;
int mpp_inact;
};
struct ieee80211_mesh_proto_metric {
uint8_t mpm_active;
char mpm_descr[IEEE80211_MESH_PROTO_DSZ];
uint8_t mpm_ie;
uint32_t (*mpm_metric)(struct ieee80211_node *);
};
#ifdef notyet
struct ieee80211_mesh_proto_auth {
uint8_t mpa_ie[4];
};
struct ieee80211_mesh_proto_congestion {
};
struct ieee80211_mesh_proto_sync {
};
#endif
typedef uint32_t ieee80211_mesh_seq;
#define IEEE80211_MESH_SEQ_LEQ(a, b) ((int32_t)((a)-(b)) <= 0)
#define IEEE80211_MESH_SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0)
struct ieee80211_mesh_state {
int ms_idlen;
uint8_t ms_id[IEEE80211_MESHID_LEN];
ieee80211_mesh_seq ms_seq;
uint16_t ms_neighbors;
uint8_t ms_ttl;
#define IEEE80211_MESHFLAGS_AP 0x01
#define IEEE80211_MESHFLAGS_GATE 0x02
#define IEEE80211_MESHFLAGS_FWD 0x04
#define IEEE80211_MESHFLAGS_ROOT 0x08
uint8_t ms_flags;
ieee80211_rt_lock_t ms_rt_lock;
struct callout ms_cleantimer;
struct callout ms_gatetimer;
ieee80211_mesh_seq ms_gateseq;
TAILQ_HEAD(, ieee80211_mesh_gate_route) ms_known_gates;
TAILQ_HEAD(, ieee80211_mesh_route) ms_routes;
struct ieee80211_mesh_proto_metric *ms_pmetric;
struct ieee80211_mesh_proto_path *ms_ppath;
};
void ieee80211_mesh_attach(struct ieee80211com *);
void ieee80211_mesh_detach(struct ieee80211com *);
struct ieee80211_mesh_route *
ieee80211_mesh_rt_find(struct ieee80211vap *,
const uint8_t [IEEE80211_ADDR_LEN]);
struct ieee80211_mesh_route *
ieee80211_mesh_rt_add(struct ieee80211vap *,
const uint8_t [IEEE80211_ADDR_LEN]);
void ieee80211_mesh_rt_del(struct ieee80211vap *,
const uint8_t [IEEE80211_ADDR_LEN]);
void ieee80211_mesh_rt_flush(struct ieee80211vap *);
void ieee80211_mesh_rt_flush_peer(struct ieee80211vap *,
const uint8_t [IEEE80211_ADDR_LEN]);
int ieee80211_mesh_rt_update(struct ieee80211_mesh_route *rt, int);
void ieee80211_mesh_proxy_check(struct ieee80211vap *,
const uint8_t [IEEE80211_ADDR_LEN]);
int ieee80211_mesh_register_proto_path(const
struct ieee80211_mesh_proto_path *);
int ieee80211_mesh_register_proto_metric(const
struct ieee80211_mesh_proto_metric *);
uint8_t * ieee80211_add_meshid(uint8_t *, struct ieee80211vap *);
uint8_t * ieee80211_add_meshconf(uint8_t *, struct ieee80211vap *);
uint8_t * ieee80211_add_meshpeer(uint8_t *, uint8_t, uint16_t, uint16_t,
uint16_t);
uint8_t * ieee80211_add_meshlmetric(uint8_t *, uint8_t, uint32_t);
uint8_t * ieee80211_add_meshgate(uint8_t *,
struct ieee80211_meshgann_ie *);
void ieee80211_mesh_node_init(struct ieee80211vap *,
struct ieee80211_node *);
void ieee80211_mesh_node_cleanup(struct ieee80211_node *);
void ieee80211_parse_meshid(struct ieee80211_node *,
const uint8_t *);
struct ieee80211_scanparams;
void ieee80211_mesh_init_neighbor(struct ieee80211_node *,
const struct ieee80211_frame *,
const struct ieee80211_scanparams *);
void ieee80211_mesh_update_beacon(struct ieee80211vap *,
struct ieee80211_beacon_offsets *);
struct ieee80211_mesh_gate_route *
ieee80211_mesh_mark_gate(struct ieee80211vap *,
const uint8_t *, struct ieee80211_mesh_route *);
void ieee80211_mesh_forward_to_gates(struct ieee80211vap *,
struct ieee80211_mesh_route *);
struct ieee80211_node *
ieee80211_mesh_find_txnode(struct ieee80211vap *,
const uint8_t [IEEE80211_ADDR_LEN]);
static __inline int
ieee80211_mesh_isproxyena(struct ieee80211vap *vap)
{
struct ieee80211_mesh_state *ms = vap->iv_mesh;
return (ms->ms_flags &
(IEEE80211_MESHFLAGS_AP | IEEE80211_MESHFLAGS_GATE)) != 0;
}
static __inline struct ieee80211_node *
ieee80211_mesh_discover(struct ieee80211vap *vap,
const uint8_t dest[IEEE80211_ADDR_LEN], struct mbuf *m)
{
struct ieee80211_mesh_state *ms = vap->iv_mesh;
return ms->ms_ppath->mpp_discover(vap, dest, m);
}
#endif
#endif