159aa14a9SRui Paulo /*- 259aa14a9SRui Paulo * Copyright (c) 2009 The FreeBSD Foundation 359aa14a9SRui Paulo * All rights reserved. 459aa14a9SRui Paulo * 559aa14a9SRui Paulo * This software was developed by Rui Paulo under sponsorship from the 659aa14a9SRui Paulo * FreeBSD Foundation. 759aa14a9SRui Paulo * 859aa14a9SRui Paulo * Redistribution and use in source and binary forms, with or without 959aa14a9SRui Paulo * modification, are permitted provided that the following conditions 1059aa14a9SRui Paulo * are met: 1159aa14a9SRui Paulo * 1. Redistributions of source code must retain the above copyright 1259aa14a9SRui Paulo * notice, this list of conditions and the following disclaimer. 1359aa14a9SRui Paulo * 2. Redistributions in binary form must reproduce the above copyright 1459aa14a9SRui Paulo * notice, this list of conditions and the following disclaimer in the 1559aa14a9SRui Paulo * documentation and/or other materials provided with the distribution. 1659aa14a9SRui Paulo * 1759aa14a9SRui Paulo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1859aa14a9SRui Paulo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1959aa14a9SRui Paulo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2059aa14a9SRui Paulo * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2159aa14a9SRui Paulo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2259aa14a9SRui Paulo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2359aa14a9SRui Paulo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2459aa14a9SRui Paulo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2559aa14a9SRui Paulo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2659aa14a9SRui Paulo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2759aa14a9SRui Paulo * SUCH DAMAGE. 2859aa14a9SRui Paulo * 2959aa14a9SRui Paulo * $FreeBSD$ 3059aa14a9SRui Paulo */ 3159aa14a9SRui Paulo #ifndef _NET80211_IEEE80211_MESH_H_ 3259aa14a9SRui Paulo #define _NET80211_IEEE80211_MESH_H_ 3359aa14a9SRui Paulo 3459aa14a9SRui Paulo #define IEEE80211_MESH_DEFAULT_TTL 31 356eb9b443SMonthadar Al Jaberi #define IEEE80211_MESH_MAX_NEIGHBORS 15 3659aa14a9SRui Paulo 3759aa14a9SRui Paulo /* 3859aa14a9SRui Paulo * NB: all structures are __packed so sizeof works on arm, et. al. 3959aa14a9SRui Paulo */ 4059aa14a9SRui Paulo /* 4159aa14a9SRui Paulo * 802.11s Information Elements. 4259aa14a9SRui Paulo */ 4359aa14a9SRui Paulo /* Mesh Configuration */ 4481b95c2cSAdrian Chadd #define IEEE80211_MESH_CONF_SZ (7) 4559aa14a9SRui Paulo struct ieee80211_meshconf_ie { 4659aa14a9SRui Paulo uint8_t conf_ie; /* IEEE80211_ELEMID_MESHCONF */ 4759aa14a9SRui Paulo uint8_t conf_len; 486b8c1829SRui Paulo uint8_t conf_pselid; /* Active Path Sel. Proto. ID */ 496b8c1829SRui Paulo uint8_t conf_pmetid; /* Active Metric Identifier */ 506b8c1829SRui Paulo uint8_t conf_ccid; /* Congestion Control Mode ID */ 516b8c1829SRui Paulo uint8_t conf_syncid; /* Sync. Protocol ID */ 526b8c1829SRui Paulo uint8_t conf_authid; /* Auth. Protocol ID */ 5359aa14a9SRui Paulo uint8_t conf_form; /* Formation Information */ 5481b95c2cSAdrian Chadd uint8_t conf_cap; 5559aa14a9SRui Paulo } __packed; 5659aa14a9SRui Paulo 5759aa14a9SRui Paulo /* Hybrid Wireless Mesh Protocol */ 5881b95c2cSAdrian Chadd enum { 5981b95c2cSAdrian Chadd /* 0 reserved */ 6081b95c2cSAdrian Chadd IEEE80211_MESHCONF_PATH_HWMP = 1, 6181b95c2cSAdrian Chadd /* 2-254 reserved */ 6281b95c2cSAdrian Chadd IEEE80211_MESHCONF_PATH_VENDOR = 255, 6381b95c2cSAdrian Chadd }; 6481b95c2cSAdrian Chadd 6559aa14a9SRui Paulo /* Airtime Link Metric */ 6681b95c2cSAdrian Chadd enum { 6781b95c2cSAdrian Chadd /* 0 reserved */ 6881b95c2cSAdrian Chadd IEEE80211_MESHCONF_METRIC_AIRTIME = 1, 6981b95c2cSAdrian Chadd /* 2-254 reserved */ 7081b95c2cSAdrian Chadd IEEE80211_MESHCONF_METRIC_VENDOR = 255, 7181b95c2cSAdrian Chadd }; 7281b95c2cSAdrian Chadd 736b8c1829SRui Paulo /* Congestion Control */ 7481b95c2cSAdrian Chadd enum { 7581b95c2cSAdrian Chadd IEEE80211_MESHCONF_CC_DISABLED = 0, 7681b95c2cSAdrian Chadd IEEE80211_MESHCONF_CC_SIG = 1, 7781b95c2cSAdrian Chadd /* 2-254 reserved */ 7881b95c2cSAdrian Chadd IEEE80211_MESHCONF_CC_VENDOR = 255, 7981b95c2cSAdrian Chadd }; 8081b95c2cSAdrian Chadd 8159aa14a9SRui Paulo /* Neighbour Offset */ 8281b95c2cSAdrian Chadd enum { 8381b95c2cSAdrian Chadd /* 0 reserved */ 8481b95c2cSAdrian Chadd IEEE80211_MESHCONF_SYNC_NEIGHOFF = 1, 8581b95c2cSAdrian Chadd /* 2-254 rserved */ 8681b95c2cSAdrian Chadd IEEE80211_MESHCONF_SYNC_VENDOR = 255, 8781b95c2cSAdrian Chadd }; 8881b95c2cSAdrian Chadd 8981b95c2cSAdrian Chadd /* Authentication Protocol Identifier */ 9081b95c2cSAdrian Chadd enum { 9181b95c2cSAdrian Chadd 9281b95c2cSAdrian Chadd IEEE80211_MESHCONF_AUTH_DISABLED = 0, 9359aa14a9SRui Paulo /* Simultaneous Authenticaction of Equals */ 9481b95c2cSAdrian Chadd IEEE80211_MESHCONF_AUTH_SEA = 1, 9581b95c2cSAdrian Chadd IEEE80211_MESHCONF_AUTH_8021X = 2, /* IEEE 802.1X */ 9681b95c2cSAdrian Chadd /* 3-254 reserved */ 9781b95c2cSAdrian Chadd IEEE80211_MESHCONF_AUTH_VENDOR = 255, 9881b95c2cSAdrian Chadd }; 9981b95c2cSAdrian Chadd 10081b95c2cSAdrian Chadd /* Mesh Formation Info */ 1019fc85253SMonthadar Al Jaberi #define IEEE80211_MESHCONF_FORM_GATE 0x01 /* Connected to Gate */ 10281b95c2cSAdrian Chadd #define IEEE80211_MESHCONF_FORM_NNEIGH_MASK 0x7E /* Number of Neighbours */ 10381b95c2cSAdrian Chadd #define IEEE80211_MESHCONF_FORM_SA 0xF0 /* indicating 802.1X auth */ 10481b95c2cSAdrian Chadd 10581b95c2cSAdrian Chadd /* Mesh Capability */ 10659aa14a9SRui Paulo #define IEEE80211_MESHCONF_CAP_AP 0x01 /* Accepting Peers */ 10759aa14a9SRui Paulo #define IEEE80211_MESHCONF_CAP_MCCAS 0x02 /* MCCA supported */ 10859aa14a9SRui Paulo #define IEEE80211_MESHCONF_CAP_MCCAE 0x04 /* MCCA enabled */ 10959aa14a9SRui Paulo #define IEEE80211_MESHCONF_CAP_FWRD 0x08 /* forwarding enabled */ 11059aa14a9SRui Paulo #define IEEE80211_MESHCONF_CAP_BTR 0x10 /* Beacon Timing Report Enab */ 11181b95c2cSAdrian Chadd #define IEEE80211_MESHCONF_CAP_TBTT 0x20 /* TBTT Adjusting */ 11281b95c2cSAdrian Chadd #define IEEE80211_MESHCONF_CAP_PSL 0x40 /* Power Save Level */ 11381b95c2cSAdrian Chadd /* 0x80 reserved */ 11459aa14a9SRui Paulo 11559aa14a9SRui Paulo /* Mesh Identifier */ 11659aa14a9SRui Paulo struct ieee80211_meshid_ie { 11759aa14a9SRui Paulo uint8_t id_ie; /* IEEE80211_ELEMID_MESHID */ 11859aa14a9SRui Paulo uint8_t id_len; 11959aa14a9SRui Paulo } __packed; 12059aa14a9SRui Paulo 12159aa14a9SRui Paulo /* Link Metric Report */ 12259aa14a9SRui Paulo struct ieee80211_meshlmetric_ie { 123bdd2a076SAdrian Chadd uint8_t lm_ie; /* IEEE80211_ACTION_MESH_LMETRIC */ 12459aa14a9SRui Paulo uint8_t lm_len; 125bdd2a076SAdrian Chadd uint8_t lm_flags; 126bdd2a076SAdrian Chadd #define IEEE80211_MESH_LMETRIC_FLAGS_REQ 0x01 /* Request */ 127bdd2a076SAdrian Chadd /* 128bdd2a076SAdrian Chadd * XXX: this field should be variable in size and depend on 129bdd2a076SAdrian Chadd * the active active path selection metric identifier 130bdd2a076SAdrian Chadd */ 13159aa14a9SRui Paulo uint32_t lm_metric; 13259aa14a9SRui Paulo #define IEEE80211_MESHLMETRIC_INITIALVAL 0 13359aa14a9SRui Paulo } __packed; 13459aa14a9SRui Paulo 13559aa14a9SRui Paulo /* Congestion Notification */ 13659aa14a9SRui Paulo struct ieee80211_meshcngst_ie { 13759aa14a9SRui Paulo uint8_t cngst_ie; /* IEEE80211_ELEMID_MESHCNGST */ 13859aa14a9SRui Paulo uint8_t cngst_len; 13959aa14a9SRui Paulo uint16_t cngst_timer[4]; /* Expiration Timers: AC_BK, 14059aa14a9SRui Paulo AC_BE, AC_VI, AC_VO */ 14159aa14a9SRui Paulo } __packed; 14259aa14a9SRui Paulo 14359aa14a9SRui Paulo /* Peer Link Management */ 144c2042c35SMonthadar Al Jaberi #define IEEE80211_MPM_BASE_SZ (4) 145c2042c35SMonthadar Al Jaberi #define IEEE80211_MPM_MAX_SZ (8) 14659aa14a9SRui Paulo struct ieee80211_meshpeer_ie { 14759aa14a9SRui Paulo uint8_t peer_ie; /* IEEE80211_ELEMID_MESHPEER */ 14859aa14a9SRui Paulo uint8_t peer_len; 149c2042c35SMonthadar Al Jaberi uint16_t peer_proto; /* Peer Management Protocol */ 15059aa14a9SRui Paulo uint16_t peer_llinkid; /* Local Link ID */ 15159aa14a9SRui Paulo uint16_t peer_linkid; /* Peer Link ID */ 15259aa14a9SRui Paulo uint16_t peer_rcode; 15359aa14a9SRui Paulo } __packed; 15459aa14a9SRui Paulo 155c2042c35SMonthadar Al Jaberi /* Mesh Peering Protocol Identifier field value */ 156c2042c35SMonthadar Al Jaberi enum { 157c2042c35SMonthadar Al Jaberi IEEE80211_MPPID_MPM = 0, /* Mesh peering management */ 158c2042c35SMonthadar Al Jaberi IEEE80211_MPPID_AUTH_MPM = 1, /* Auth. mesh peering exchange */ 159c2042c35SMonthadar Al Jaberi /* 2-65535 reserved */ 160c2042c35SMonthadar Al Jaberi }; 161c2042c35SMonthadar Al Jaberi 16259aa14a9SRui Paulo #ifdef notyet 16359aa14a9SRui Paulo /* Mesh Channel Switch Annoucement */ 16459aa14a9SRui Paulo struct ieee80211_meshcsa_ie { 16559aa14a9SRui Paulo uint8_t csa_ie; /* IEEE80211_ELEMID_MESHCSA */ 16659aa14a9SRui Paulo uint8_t csa_len; 16759aa14a9SRui Paulo uint8_t csa_mode; 16859aa14a9SRui Paulo uint8_t csa_newclass; /* New Regulatory Class */ 16959aa14a9SRui Paulo uint8_t csa_newchan; 17059aa14a9SRui Paulo uint8_t csa_precvalue; /* Precedence Value */ 17159aa14a9SRui Paulo uint8_t csa_count; 17259aa14a9SRui Paulo } __packed; 17359aa14a9SRui Paulo 17459aa14a9SRui Paulo /* Mesh TIM */ 17559aa14a9SRui Paulo /* Equal to the non Mesh version */ 17659aa14a9SRui Paulo 17759aa14a9SRui Paulo /* Mesh Awake Window */ 17859aa14a9SRui Paulo struct ieee80211_meshawakew_ie { 17959aa14a9SRui Paulo uint8_t awakew_ie; /* IEEE80211_ELEMID_MESHAWAKEW */ 18059aa14a9SRui Paulo uint8_t awakew_len; 18159aa14a9SRui Paulo uint8_t awakew_windowlen; /* in TUs */ 18259aa14a9SRui Paulo } __packed; 18359aa14a9SRui Paulo 18459aa14a9SRui Paulo /* Mesh Beacon Timing */ 18559aa14a9SRui Paulo struct ieee80211_meshbeacont_ie { 18659aa14a9SRui Paulo uint8_t beacont_ie; /* IEEE80211_ELEMID_MESHBEACONT */ 18759aa14a9SRui Paulo uint8_t beacont_len; 18859aa14a9SRui Paulo struct { 18959aa14a9SRui Paulo uint8_t mp_aid; /* Least Octet of AID */ 19059aa14a9SRui Paulo uint16_t mp_btime; /* Beacon Time */ 19159aa14a9SRui Paulo uint16_t mp_bint; /* Beacon Interval */ 19259aa14a9SRui Paulo } __packed mp[1]; /* NB: variable size */ 19359aa14a9SRui Paulo } __packed; 19459aa14a9SRui Paulo #endif 19559aa14a9SRui Paulo 1969fc85253SMonthadar Al Jaberi /* Gate (GANN) Annoucement */ 197e1373e86SMonthadar Al Jaberi /* 198e1373e86SMonthadar Al Jaberi * NB: these macros used for the length in the IEs does not include 2 bytes 199e1373e86SMonthadar Al Jaberi * for _ie and _len fields as is defined by the standard. 200e1373e86SMonthadar Al Jaberi */ 201e1373e86SMonthadar Al Jaberi #define IEEE80211_MESHGANN_BASE_SZ (15) 2029fc85253SMonthadar Al Jaberi struct ieee80211_meshgann_ie { 203e1373e86SMonthadar Al Jaberi uint8_t gann_ie; /* IEEE80211_ELEMID_MESHGANN */ 204e1373e86SMonthadar Al Jaberi uint8_t gann_len; 205e1373e86SMonthadar Al Jaberi uint8_t gann_flags; 206e1373e86SMonthadar Al Jaberi uint8_t gann_hopcount; 207e1373e86SMonthadar Al Jaberi uint8_t gann_ttl; 208e1373e86SMonthadar Al Jaberi uint8_t gann_addr[IEEE80211_ADDR_LEN]; 209e1373e86SMonthadar Al Jaberi uint32_t gann_seq; /* GANN Sequence Number */ 210e1373e86SMonthadar Al Jaberi uint16_t gann_interval; /* GANN Interval */ 21159aa14a9SRui Paulo } __packed; 21259aa14a9SRui Paulo 21359aa14a9SRui Paulo /* Root (MP) Annoucement */ 2141f88a92bSAdrian Chadd #define IEEE80211_MESHRANN_BASE_SZ (21) 21559aa14a9SRui Paulo struct ieee80211_meshrann_ie { 21659aa14a9SRui Paulo uint8_t rann_ie; /* IEEE80211_ELEMID_MESHRANN */ 21759aa14a9SRui Paulo uint8_t rann_len; 21859aa14a9SRui Paulo uint8_t rann_flags; 2199fc85253SMonthadar Al Jaberi #define IEEE80211_MESHRANN_FLAGS_GATE 0x01 /* Mesh Gate */ 22059aa14a9SRui Paulo uint8_t rann_hopcount; 22159aa14a9SRui Paulo uint8_t rann_ttl; 22259aa14a9SRui Paulo uint8_t rann_addr[IEEE80211_ADDR_LEN]; 22359aa14a9SRui Paulo uint32_t rann_seq; /* HWMP Sequence Number */ 2241f88a92bSAdrian Chadd uint32_t rann_interval; 22559aa14a9SRui Paulo uint32_t rann_metric; 22659aa14a9SRui Paulo } __packed; 22759aa14a9SRui Paulo 22859aa14a9SRui Paulo /* Mesh Path Request */ 2291f88a92bSAdrian Chadd #define IEEE80211_MESHPREQ_BASE_SZ (26) 2301f88a92bSAdrian Chadd #define IEEE80211_MESHPREQ_BASE_SZ_AE (32) 2311f88a92bSAdrian Chadd #define IEEE80211_MESHPREQ_TRGT_SZ (11) 2321f88a92bSAdrian Chadd #define IEEE80211_MESHPREQ_TCNT_OFFSET (27) 2331f88a92bSAdrian Chadd #define IEEE80211_MESHPREQ_TCNT_OFFSET_AE (33) 23459aa14a9SRui Paulo struct ieee80211_meshpreq_ie { 23559aa14a9SRui Paulo uint8_t preq_ie; /* IEEE80211_ELEMID_MESHPREQ */ 23659aa14a9SRui Paulo uint8_t preq_len; 23759aa14a9SRui Paulo uint8_t preq_flags; 2389fc85253SMonthadar Al Jaberi #define IEEE80211_MESHPREQ_FLAGS_GATE 0x01 /* Mesh Gate */ 2393d7486ceSMonthadar Al Jaberi #define IEEE80211_MESHPREQ_FLAGS_AM 0x02 /* 0 = bcast / 1 = ucast */ 24059aa14a9SRui Paulo #define IEEE80211_MESHPREQ_FLAGS_PP 0x04 /* Proactive PREP */ 24159aa14a9SRui Paulo #define IEEE80211_MESHPREQ_FLAGS_AE 0x40 /* Address Extension */ 24259aa14a9SRui Paulo uint8_t preq_hopcount; 24359aa14a9SRui Paulo uint8_t preq_ttl; 24459aa14a9SRui Paulo uint32_t preq_id; 24559aa14a9SRui Paulo uint8_t preq_origaddr[IEEE80211_ADDR_LEN]; 24659aa14a9SRui Paulo uint32_t preq_origseq; /* HWMP Sequence Number */ 2471f88a92bSAdrian Chadd /* NB: may have Originator External Address */ 2481f88a92bSAdrian Chadd uint8_t preq_orig_ext_addr[IEEE80211_ADDR_LEN]; 24959aa14a9SRui Paulo uint32_t preq_lifetime; 25059aa14a9SRui Paulo uint32_t preq_metric; 25159aa14a9SRui Paulo uint8_t preq_tcount; /* target count */ 25259aa14a9SRui Paulo struct { 25359aa14a9SRui Paulo uint8_t target_flags; 25459aa14a9SRui Paulo #define IEEE80211_MESHPREQ_TFLAGS_TO 0x01 /* Target Only */ 25559aa14a9SRui Paulo #define IEEE80211_MESHPREQ_TFLAGS_USN 0x04 /* Unknown HWMP seq number */ 25659aa14a9SRui Paulo uint8_t target_addr[IEEE80211_ADDR_LEN]; 25759aa14a9SRui Paulo uint32_t target_seq; /* HWMP Sequence Number */ 25859aa14a9SRui Paulo } __packed preq_targets[1]; /* NB: variable size */ 25959aa14a9SRui Paulo } __packed; 26059aa14a9SRui Paulo 26159aa14a9SRui Paulo /* Mesh Path Reply */ 2621f88a92bSAdrian Chadd #define IEEE80211_MESHPREP_BASE_SZ (31) 2631f88a92bSAdrian Chadd #define IEEE80211_MESHPREP_BASE_SZ_AE (37) 26459aa14a9SRui Paulo struct ieee80211_meshprep_ie { 26559aa14a9SRui Paulo uint8_t prep_ie; /* IEEE80211_ELEMID_MESHPREP */ 26659aa14a9SRui Paulo uint8_t prep_len; 26759aa14a9SRui Paulo uint8_t prep_flags; 2681f88a92bSAdrian Chadd #define IEEE80211_MESHPREP_FLAGS_AE 0x40 /* Address Extension */ 26959aa14a9SRui Paulo uint8_t prep_hopcount; 27059aa14a9SRui Paulo uint8_t prep_ttl; 27159aa14a9SRui Paulo uint8_t prep_targetaddr[IEEE80211_ADDR_LEN]; 27259aa14a9SRui Paulo uint32_t prep_targetseq; 2731f88a92bSAdrian Chadd /* NB: May have Target External Address */ 2741f88a92bSAdrian Chadd uint8_t prep_target_ext_addr[IEEE80211_ADDR_LEN]; 27559aa14a9SRui Paulo uint32_t prep_lifetime; 27659aa14a9SRui Paulo uint32_t prep_metric; 27759aa14a9SRui Paulo uint8_t prep_origaddr[IEEE80211_ADDR_LEN]; 27859aa14a9SRui Paulo uint32_t prep_origseq; /* HWMP Sequence Number */ 27959aa14a9SRui Paulo } __packed; 28059aa14a9SRui Paulo 28159aa14a9SRui Paulo /* Mesh Path Error */ 2821f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_MAXDEST (19) 2831f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_NDEST_OFFSET (3) 2841f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_BASE_SZ (2) 2851f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_DEST_SZ (13) 2861f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_DEST_SZ_AE (19) 28759aa14a9SRui Paulo struct ieee80211_meshperr_ie { 28859aa14a9SRui Paulo uint8_t perr_ie; /* IEEE80211_ELEMID_MESHPERR */ 28959aa14a9SRui Paulo uint8_t perr_len; 290c77735e2SRui Paulo uint8_t perr_ttl; 29159aa14a9SRui Paulo uint8_t perr_ndests; /* Number of Destinations */ 29259aa14a9SRui Paulo struct { 293c77735e2SRui Paulo uint8_t dest_flags; 2941f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_DFLAGS_USN 0x01 /* XXX: not part of standard */ 2951f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_DFLAGS_RC 0x02 /* XXX: not part of standard */ 2961f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_FLAGS_AE 0x40 /* Address Extension */ 29759aa14a9SRui Paulo uint8_t dest_addr[IEEE80211_ADDR_LEN]; 29859aa14a9SRui Paulo uint32_t dest_seq; /* HWMP Sequence Number */ 2991f88a92bSAdrian Chadd /* NB: May have Destination External Address */ 3001f88a92bSAdrian Chadd uint8_t dest_ext_addr[IEEE80211_ADDR_LEN]; 301c77735e2SRui Paulo uint16_t dest_rcode; 30259aa14a9SRui Paulo } __packed perr_dests[1]; /* NB: variable size */ 30359aa14a9SRui Paulo } __packed; 30459aa14a9SRui Paulo 30559aa14a9SRui Paulo #ifdef notyet 30659aa14a9SRui Paulo /* Mesh Proxy Update */ 30759aa14a9SRui Paulo struct ieee80211_meshpu_ie { 30859aa14a9SRui Paulo uint8_t pu_ie; /* IEEE80211_ELEMID_MESHPU */ 30959aa14a9SRui Paulo uint8_t pu_len; 31059aa14a9SRui Paulo uint8_t pu_flags; 31159aa14a9SRui Paulo #define IEEE80211_MESHPU_FLAGS_MASK 0x1 31259aa14a9SRui Paulo #define IEEE80211_MESHPU_FLAGS_DEL 0x0 31359aa14a9SRui Paulo #define IEEE80211_MESHPU_FLAGS_ADD 0x1 31459aa14a9SRui Paulo uint8_t pu_seq; /* PU Sequence Number */ 31559aa14a9SRui Paulo uint8_t pu_addr[IEEE80211_ADDR_LEN]; 31659aa14a9SRui Paulo uint8_t pu_naddr; /* Number of Proxied Addresses */ 31759aa14a9SRui Paulo /* NB: proxied address follows */ 31859aa14a9SRui Paulo } __packed; 31959aa14a9SRui Paulo 32059aa14a9SRui Paulo /* Mesh Proxy Update Confirmation */ 32159aa14a9SRui Paulo struct ieee80211_meshpuc_ie { 32259aa14a9SRui Paulo uint8_t puc_ie; /* IEEE80211_ELEMID_MESHPUC */ 32359aa14a9SRui Paulo uint8_t puc_len; 32459aa14a9SRui Paulo uint8_t puc_flags; 32559aa14a9SRui Paulo uint8_t puc_seq; /* PU Sequence Number */ 32659aa14a9SRui Paulo uint8_t puc_daddr[IEEE80211_ADDR_LEN]; 32759aa14a9SRui Paulo } __packed; 32859aa14a9SRui Paulo #endif 32959aa14a9SRui Paulo 33059aa14a9SRui Paulo /* 33159aa14a9SRui Paulo * 802.11s Action Frames 332ebeaa1adSMonthadar Al Jaberi * XXX: these are wrong, and some of them should be 333ebeaa1adSMonthadar Al Jaberi * under MESH category while PROXY is under MULTIHOP category. 33459aa14a9SRui Paulo */ 33559aa14a9SRui Paulo #define IEEE80211_ACTION_CAT_INTERWORK 15 33659aa14a9SRui Paulo #define IEEE80211_ACTION_CAT_RESOURCE 16 33759aa14a9SRui Paulo #define IEEE80211_ACTION_CAT_PROXY 17 33859aa14a9SRui Paulo 33959aa14a9SRui Paulo /* 34059aa14a9SRui Paulo * Mesh Peering Action codes. 34159aa14a9SRui Paulo */ 34259aa14a9SRui Paulo enum { 343ebeaa1adSMonthadar Al Jaberi /* 0 reserved */ 344ebeaa1adSMonthadar Al Jaberi IEEE80211_ACTION_MESHPEERING_OPEN = 1, 345ebeaa1adSMonthadar Al Jaberi IEEE80211_ACTION_MESHPEERING_CONFIRM = 2, 346ebeaa1adSMonthadar Al Jaberi IEEE80211_ACTION_MESHPEERING_CLOSE = 3, 347ebeaa1adSMonthadar Al Jaberi /* 4-255 reserved */ 34859aa14a9SRui Paulo }; 34959aa14a9SRui Paulo 35059aa14a9SRui Paulo /* 351bdd2a076SAdrian Chadd * Mesh Action code. 35259aa14a9SRui Paulo */ 35359aa14a9SRui Paulo enum { 354bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_LMETRIC = 0, /* Mesh Link Metric Report */ 355bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_HWMP = 1, /* HWMP Mesh Path Selection */ 356bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_GANN = 2, /* Gate Announcement */ 357bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_CC = 3, /* Congestion Control */ 358bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_MCCA_SREQ = 4, /* MCCA Setup Request */ 359bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_MCCA_SREP = 5, /* MCCA Setup Reply */ 360bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_MCCA_AREQ = 6, /* MCCA Advertisement Req. */ 361bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_MCCA_ADVER =7, /* MCCA Advertisement */ 362bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_MCCA_TRDOWN = 8, /* MCCA Teardown */ 363bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_TBTT_REQ = 9, /* TBTT Adjustment Request */ 364bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_TBTT_RES = 10, /* TBTT Adjustment Response */ 365bdd2a076SAdrian Chadd /* 11-255 reserved */ 36659aa14a9SRui Paulo }; 36759aa14a9SRui Paulo 36859aa14a9SRui Paulo /* 36959aa14a9SRui Paulo * Different mesh control structures based on the AE 37059aa14a9SRui Paulo * (Address Extension) bits. 37159aa14a9SRui Paulo */ 37259aa14a9SRui Paulo struct ieee80211_meshcntl { 37359aa14a9SRui Paulo uint8_t mc_flags; /* Address Extension 00 */ 37459aa14a9SRui Paulo uint8_t mc_ttl; /* TTL */ 37559aa14a9SRui Paulo uint8_t mc_seq[4]; /* Sequence No. */ 37659aa14a9SRui Paulo /* NB: more addresses may follow */ 37759aa14a9SRui Paulo } __packed; 37859aa14a9SRui Paulo 37959aa14a9SRui Paulo struct ieee80211_meshcntl_ae01 { 38059aa14a9SRui Paulo uint8_t mc_flags; /* Address Extension 01 */ 38159aa14a9SRui Paulo uint8_t mc_ttl; /* TTL */ 38259aa14a9SRui Paulo uint8_t mc_seq[4]; /* Sequence No. */ 38359aa14a9SRui Paulo uint8_t mc_addr4[IEEE80211_ADDR_LEN]; 38459aa14a9SRui Paulo } __packed; 38559aa14a9SRui Paulo 38659aa14a9SRui Paulo struct ieee80211_meshcntl_ae10 { 38759aa14a9SRui Paulo uint8_t mc_flags; /* Address Extension 10 */ 38859aa14a9SRui Paulo uint8_t mc_ttl; /* TTL */ 38959aa14a9SRui Paulo uint8_t mc_seq[4]; /* Sequence No. */ 39059aa14a9SRui Paulo uint8_t mc_addr5[IEEE80211_ADDR_LEN]; 39159aa14a9SRui Paulo uint8_t mc_addr6[IEEE80211_ADDR_LEN]; 39259aa14a9SRui Paulo } __packed; 39359aa14a9SRui Paulo 3943c314f6dSMonthadar Al Jaberi #define IEEE80211_MESH_AE_MASK 0x03 3953c314f6dSMonthadar Al Jaberi enum { 3963c314f6dSMonthadar Al Jaberi IEEE80211_MESH_AE_00 = 0, /* MC has no AE subfield */ 3973c314f6dSMonthadar Al Jaberi IEEE80211_MESH_AE_01 = 1, /* MC contain addr4 */ 3983c314f6dSMonthadar Al Jaberi IEEE80211_MESH_AE_10 = 2, /* MC contain addr5 & addr6 */ 3993c314f6dSMonthadar Al Jaberi IEEE80211_MESH_AE_11 = 3, /* RESERVED */ 4003c314f6dSMonthadar Al Jaberi }; 4013c314f6dSMonthadar Al Jaberi 40259aa14a9SRui Paulo #ifdef _KERNEL 4031f88a92bSAdrian Chadd MALLOC_DECLARE(M_80211_MESH_PREQ); 4041f88a92bSAdrian Chadd MALLOC_DECLARE(M_80211_MESH_PREP); 4051f88a92bSAdrian Chadd MALLOC_DECLARE(M_80211_MESH_PERR); 4061f88a92bSAdrian Chadd 40759aa14a9SRui Paulo MALLOC_DECLARE(M_80211_MESH_RT); 4084cc361aaSMonthadar Al Jaberi MALLOC_DECLARE(M_80211_MESH_GT_RT); 409b5df85a6SMonthadar Al Jaberi /* 410b5df85a6SMonthadar Al Jaberi * Basic forwarding information: 411b5df85a6SMonthadar Al Jaberi * o Destination MAC 412b5df85a6SMonthadar Al Jaberi * o Next-hop MAC 413b5df85a6SMonthadar Al Jaberi * o Precursor list (not implemented yet) 414b5df85a6SMonthadar Al Jaberi * o Path timeout 415b5df85a6SMonthadar Al Jaberi * The rest is part of the active Mesh path selection protocol. 416b5df85a6SMonthadar Al Jaberi * XXX: to be moved out later. 417b5df85a6SMonthadar Al Jaberi */ 41859aa14a9SRui Paulo struct ieee80211_mesh_route { 41959aa14a9SRui Paulo TAILQ_ENTRY(ieee80211_mesh_route) rt_next; 42047451c66SMonthadar Al Jaberi struct ieee80211vap *rt_vap; 421b5df85a6SMonthadar Al Jaberi struct mtx rt_lock; /* fine grained route lock */ 42247451c66SMonthadar Al Jaberi struct callout rt_discovery; /* discovery timeout */ 423b5df85a6SMonthadar Al Jaberi int rt_updtime; /* last update time */ 42459aa14a9SRui Paulo uint8_t rt_dest[IEEE80211_ADDR_LEN]; 4253c314f6dSMonthadar Al Jaberi uint8_t rt_mesh_gate[IEEE80211_ADDR_LEN]; /* meshDA */ 42659aa14a9SRui Paulo uint8_t rt_nexthop[IEEE80211_ADDR_LEN]; 42759aa14a9SRui Paulo uint32_t rt_metric; /* path metric */ 42859aa14a9SRui Paulo uint16_t rt_nhops; /* number of hops */ 429c104cff2SRui Paulo uint16_t rt_flags; 43047451c66SMonthadar Al Jaberi #define IEEE80211_MESHRT_FLAGS_DISCOVER 0x01 /* path discovery */ 43147451c66SMonthadar Al Jaberi #define IEEE80211_MESHRT_FLAGS_VALID 0x02 /* path discovery complete */ 43247451c66SMonthadar Al Jaberi #define IEEE80211_MESHRT_FLAGS_PROXY 0x04 /* proxy entry */ 433e1373e86SMonthadar Al Jaberi #define IEEE80211_MESHRT_FLAGS_GATE 0x08 /* mesh gate entry */ 434b5df85a6SMonthadar Al Jaberi uint32_t rt_lifetime; /* route timeout */ 43559aa14a9SRui Paulo uint32_t rt_lastmseq; /* last seq# seen dest */ 4363c314f6dSMonthadar Al Jaberi uint32_t rt_ext_seq; /* proxy seq number */ 43759aa14a9SRui Paulo void *rt_priv; /* private data */ 43859aa14a9SRui Paulo }; 43959aa14a9SRui Paulo #define IEEE80211_MESH_ROUTE_PRIV(rt, cast) ((cast *)rt->rt_priv) 44059aa14a9SRui Paulo 4414cc361aaSMonthadar Al Jaberi /* 4424cc361aaSMonthadar Al Jaberi * Stored information about known mesh gates. 4434cc361aaSMonthadar Al Jaberi */ 4444cc361aaSMonthadar Al Jaberi struct ieee80211_mesh_gate_route { 4454cc361aaSMonthadar Al Jaberi TAILQ_ENTRY(ieee80211_mesh_gate_route) gr_next; 4464cc361aaSMonthadar Al Jaberi uint8_t gr_addr[IEEE80211_ADDR_LEN]; 4474cc361aaSMonthadar Al Jaberi uint32_t gr_lastseq; 4484cc361aaSMonthadar Al Jaberi struct ieee80211_mesh_route *gr_route; 4494cc361aaSMonthadar Al Jaberi }; 4504cc361aaSMonthadar Al Jaberi 45159aa14a9SRui Paulo #define IEEE80211_MESH_PROTO_DSZ 12 /* description size */ 45259aa14a9SRui Paulo /* 45359aa14a9SRui Paulo * Mesh Path Selection Protocol. 45459aa14a9SRui Paulo */ 45559aa14a9SRui Paulo enum ieee80211_state; 45659aa14a9SRui Paulo struct ieee80211_mesh_proto_path { 4576b8c1829SRui Paulo uint8_t mpp_active; 45859aa14a9SRui Paulo char mpp_descr[IEEE80211_MESH_PROTO_DSZ]; 4596b8c1829SRui Paulo uint8_t mpp_ie; 46059aa14a9SRui Paulo struct ieee80211_node * 46159aa14a9SRui Paulo (*mpp_discover)(struct ieee80211vap *, 46259aa14a9SRui Paulo const uint8_t [IEEE80211_ADDR_LEN], 46359aa14a9SRui Paulo struct mbuf *); 46459aa14a9SRui Paulo void (*mpp_peerdown)(struct ieee80211_node *); 4653db82516SMonthadar Al Jaberi void (*mpp_senderror)(struct ieee80211vap *, 4663db82516SMonthadar Al Jaberi const uint8_t [IEEE80211_ADDR_LEN], 4673db82516SMonthadar Al Jaberi struct ieee80211_mesh_route *, int); 46859aa14a9SRui Paulo void (*mpp_vattach)(struct ieee80211vap *); 46959aa14a9SRui Paulo void (*mpp_vdetach)(struct ieee80211vap *); 47059aa14a9SRui Paulo int (*mpp_newstate)(struct ieee80211vap *, 47159aa14a9SRui Paulo enum ieee80211_state, int); 472c104cff2SRui Paulo const size_t mpp_privlen; /* size required in the routing table 47359aa14a9SRui Paulo for private data */ 474e50821abSSam Leffler int mpp_inact; /* inact. timeout for invalid routes 475e50821abSSam Leffler (ticks) */ 47659aa14a9SRui Paulo }; 47759aa14a9SRui Paulo 47859aa14a9SRui Paulo /* 47959aa14a9SRui Paulo * Mesh Link Metric Report Protocol. 48059aa14a9SRui Paulo */ 48159aa14a9SRui Paulo struct ieee80211_mesh_proto_metric { 4826b8c1829SRui Paulo uint8_t mpm_active; 48359aa14a9SRui Paulo char mpm_descr[IEEE80211_MESH_PROTO_DSZ]; 4846b8c1829SRui Paulo uint8_t mpm_ie; 48559aa14a9SRui Paulo uint32_t (*mpm_metric)(struct ieee80211_node *); 48659aa14a9SRui Paulo }; 48759aa14a9SRui Paulo 48859aa14a9SRui Paulo #ifdef notyet 48959aa14a9SRui Paulo /* 49059aa14a9SRui Paulo * Mesh Authentication Protocol. 49159aa14a9SRui Paulo */ 49259aa14a9SRui Paulo struct ieee80211_mesh_proto_auth { 49359aa14a9SRui Paulo uint8_t mpa_ie[4]; 49459aa14a9SRui Paulo }; 49559aa14a9SRui Paulo 49659aa14a9SRui Paulo struct ieee80211_mesh_proto_congestion { 49759aa14a9SRui Paulo }; 49859aa14a9SRui Paulo 49959aa14a9SRui Paulo struct ieee80211_mesh_proto_sync { 50059aa14a9SRui Paulo }; 50159aa14a9SRui Paulo #endif 50259aa14a9SRui Paulo 50359aa14a9SRui Paulo typedef uint32_t ieee80211_mesh_seq; 50459aa14a9SRui Paulo #define IEEE80211_MESH_SEQ_LEQ(a, b) ((int32_t)((a)-(b)) <= 0) 50559aa14a9SRui Paulo #define IEEE80211_MESH_SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0) 50659aa14a9SRui Paulo 50759aa14a9SRui Paulo struct ieee80211_mesh_state { 50859aa14a9SRui Paulo int ms_idlen; 50959aa14a9SRui Paulo uint8_t ms_id[IEEE80211_MESHID_LEN]; 51059aa14a9SRui Paulo ieee80211_mesh_seq ms_seq; /* seq no for meshcntl */ 51159aa14a9SRui Paulo uint16_t ms_neighbors; 51259aa14a9SRui Paulo uint8_t ms_ttl; /* mesh ttl set in packets */ 51359aa14a9SRui Paulo #define IEEE80211_MESHFLAGS_AP 0x01 /* accept peers */ 5149fc85253SMonthadar Al Jaberi #define IEEE80211_MESHFLAGS_GATE 0x02 /* mesh gate role */ 51559aa14a9SRui Paulo #define IEEE80211_MESHFLAGS_FWD 0x04 /* forward packets */ 516ed0b5440SMonthadar Al Jaberi #define IEEE80211_MESHFLAGS_ROOT 0x08 /* configured as root */ 51759aa14a9SRui Paulo uint8_t ms_flags; 51859aa14a9SRui Paulo struct mtx ms_rt_lock; 519c104cff2SRui Paulo struct callout ms_cleantimer; 520ed0b5440SMonthadar Al Jaberi struct callout ms_gatetimer; 521ed0b5440SMonthadar Al Jaberi ieee80211_mesh_seq ms_gateseq; 5224cc361aaSMonthadar Al Jaberi TAILQ_HEAD(, ieee80211_mesh_gate_route) ms_known_gates; 52359aa14a9SRui Paulo TAILQ_HEAD(, ieee80211_mesh_route) ms_routes; 52459aa14a9SRui Paulo struct ieee80211_mesh_proto_metric *ms_pmetric; 52559aa14a9SRui Paulo struct ieee80211_mesh_proto_path *ms_ppath; 52659aa14a9SRui Paulo }; 52759aa14a9SRui Paulo void ieee80211_mesh_attach(struct ieee80211com *); 52859aa14a9SRui Paulo void ieee80211_mesh_detach(struct ieee80211com *); 52959aa14a9SRui Paulo 53059aa14a9SRui Paulo struct ieee80211_mesh_route * 53159aa14a9SRui Paulo ieee80211_mesh_rt_find(struct ieee80211vap *, 53259aa14a9SRui Paulo const uint8_t [IEEE80211_ADDR_LEN]); 53359aa14a9SRui Paulo struct ieee80211_mesh_route * 53459aa14a9SRui Paulo ieee80211_mesh_rt_add(struct ieee80211vap *, 53559aa14a9SRui Paulo const uint8_t [IEEE80211_ADDR_LEN]); 53659aa14a9SRui Paulo void ieee80211_mesh_rt_del(struct ieee80211vap *, 53759aa14a9SRui Paulo const uint8_t [IEEE80211_ADDR_LEN]); 53859aa14a9SRui Paulo void ieee80211_mesh_rt_flush(struct ieee80211vap *); 5393ca80f0dSRui Paulo void ieee80211_mesh_rt_flush_peer(struct ieee80211vap *, 5403ca80f0dSRui Paulo const uint8_t [IEEE80211_ADDR_LEN]); 541b5df85a6SMonthadar Al Jaberi int ieee80211_mesh_rt_update(struct ieee80211_mesh_route *rt, int); 542c104cff2SRui Paulo void ieee80211_mesh_proxy_check(struct ieee80211vap *, 543c104cff2SRui Paulo const uint8_t [IEEE80211_ADDR_LEN]); 54459aa14a9SRui Paulo 54559aa14a9SRui Paulo int ieee80211_mesh_register_proto_path(const 54659aa14a9SRui Paulo struct ieee80211_mesh_proto_path *); 54759aa14a9SRui Paulo int ieee80211_mesh_register_proto_metric(const 54859aa14a9SRui Paulo struct ieee80211_mesh_proto_metric *); 54959aa14a9SRui Paulo 55059aa14a9SRui Paulo uint8_t * ieee80211_add_meshid(uint8_t *, struct ieee80211vap *); 55159aa14a9SRui Paulo uint8_t * ieee80211_add_meshconf(uint8_t *, struct ieee80211vap *); 55259aa14a9SRui Paulo uint8_t * ieee80211_add_meshpeer(uint8_t *, uint8_t, uint16_t, uint16_t, 55359aa14a9SRui Paulo uint16_t); 554bdd2a076SAdrian Chadd uint8_t * ieee80211_add_meshlmetric(uint8_t *, uint8_t, uint32_t); 555ed0b5440SMonthadar Al Jaberi uint8_t * ieee80211_add_meshgate(uint8_t *, 556ed0b5440SMonthadar Al Jaberi struct ieee80211_meshgann_ie *); 55759aa14a9SRui Paulo 55859aa14a9SRui Paulo void ieee80211_mesh_node_init(struct ieee80211vap *, 55959aa14a9SRui Paulo struct ieee80211_node *); 56059aa14a9SRui Paulo void ieee80211_mesh_node_cleanup(struct ieee80211_node *); 56159aa14a9SRui Paulo void ieee80211_parse_meshid(struct ieee80211_node *, 56259aa14a9SRui Paulo const uint8_t *); 56359aa14a9SRui Paulo struct ieee80211_scanparams; 56459aa14a9SRui Paulo void ieee80211_mesh_init_neighbor(struct ieee80211_node *, 56559aa14a9SRui Paulo const struct ieee80211_frame *, 56659aa14a9SRui Paulo const struct ieee80211_scanparams *); 567d093681cSRui Paulo void ieee80211_mesh_update_beacon(struct ieee80211vap *, 568d093681cSRui Paulo struct ieee80211_beacon_offsets *); 569*a21c6123SMonthadar Al Jaberi struct ieee80211_mesh_gate_route * 570*a21c6123SMonthadar Al Jaberi ieee80211_mesh_mark_gate(struct ieee80211vap *, 571*a21c6123SMonthadar Al Jaberi const uint8_t *, struct ieee80211_mesh_route *); 57259aa14a9SRui Paulo 573c104cff2SRui Paulo /* 574c104cff2SRui Paulo * Return non-zero if proxy operation is enabled. 575c104cff2SRui Paulo */ 576c104cff2SRui Paulo static __inline int 577c104cff2SRui Paulo ieee80211_mesh_isproxyena(struct ieee80211vap *vap) 578c104cff2SRui Paulo { 579c104cff2SRui Paulo struct ieee80211_mesh_state *ms = vap->iv_mesh; 580c104cff2SRui Paulo return (ms->ms_flags & 5819fc85253SMonthadar Al Jaberi (IEEE80211_MESHFLAGS_AP | IEEE80211_MESHFLAGS_GATE)) != 0; 582c104cff2SRui Paulo } 583c104cff2SRui Paulo 584c104cff2SRui Paulo /* 585c104cff2SRui Paulo * Process an outbound frame: if a path is known to the 586c104cff2SRui Paulo * destination then return a reference to the next hop 587c104cff2SRui Paulo * for immediate transmission. Otherwise initiate path 588c104cff2SRui Paulo * discovery and, if possible queue the packet to be 589c104cff2SRui Paulo * sent when path discovery completes. 590c104cff2SRui Paulo */ 59159aa14a9SRui Paulo static __inline struct ieee80211_node * 59259aa14a9SRui Paulo ieee80211_mesh_discover(struct ieee80211vap *vap, 59359aa14a9SRui Paulo const uint8_t dest[IEEE80211_ADDR_LEN], struct mbuf *m) 59459aa14a9SRui Paulo { 59559aa14a9SRui Paulo struct ieee80211_mesh_state *ms = vap->iv_mesh; 59659aa14a9SRui Paulo return ms->ms_ppath->mpp_discover(vap, dest, m); 59759aa14a9SRui Paulo } 59859aa14a9SRui Paulo 59959aa14a9SRui Paulo #endif /* _KERNEL */ 60059aa14a9SRui Paulo #endif /* !_NET80211_IEEE80211_MESH_H_ */ 601