159aa14a9SRui Paulo /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
3fe267a55SPedro F. Giffuni *
459aa14a9SRui Paulo * Copyright (c) 2009 The FreeBSD Foundation
559aa14a9SRui Paulo *
659aa14a9SRui Paulo * This software was developed by Rui Paulo under sponsorship from the
759aa14a9SRui Paulo * FreeBSD Foundation.
859aa14a9SRui Paulo *
959aa14a9SRui Paulo * Redistribution and use in source and binary forms, with or without
1059aa14a9SRui Paulo * modification, are permitted provided that the following conditions
1159aa14a9SRui Paulo * are met:
1259aa14a9SRui Paulo * 1. Redistributions of source code must retain the above copyright
1359aa14a9SRui Paulo * notice, this list of conditions and the following disclaimer.
1459aa14a9SRui Paulo * 2. Redistributions in binary form must reproduce the above copyright
1559aa14a9SRui Paulo * notice, this list of conditions and the following disclaimer in the
1659aa14a9SRui Paulo * documentation and/or other materials provided with the distribution.
1759aa14a9SRui Paulo *
1859aa14a9SRui Paulo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1959aa14a9SRui Paulo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2059aa14a9SRui Paulo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2159aa14a9SRui Paulo * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2259aa14a9SRui Paulo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2359aa14a9SRui Paulo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2459aa14a9SRui Paulo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2559aa14a9SRui Paulo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2659aa14a9SRui Paulo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2759aa14a9SRui Paulo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2859aa14a9SRui Paulo * SUCH DAMAGE.
2959aa14a9SRui Paulo *
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 IEEE80211_MESHCONF_AUTH_DISABLED = 0,
9259aa14a9SRui Paulo /* Simultaneous Authenticaction of Equals */
9381b95c2cSAdrian Chadd IEEE80211_MESHCONF_AUTH_SEA = 1,
9481b95c2cSAdrian Chadd IEEE80211_MESHCONF_AUTH_8021X = 2, /* IEEE 802.1X */
9581b95c2cSAdrian Chadd /* 3-254 reserved */
9681b95c2cSAdrian Chadd IEEE80211_MESHCONF_AUTH_VENDOR = 255,
9781b95c2cSAdrian Chadd };
9881b95c2cSAdrian Chadd
9981b95c2cSAdrian Chadd /* Mesh Formation Info */
1009fc85253SMonthadar Al Jaberi #define IEEE80211_MESHCONF_FORM_GATE 0x01 /* Connected to Gate */
10181b95c2cSAdrian Chadd #define IEEE80211_MESHCONF_FORM_NNEIGH_MASK 0x7E /* Number of Neighbours */
10281b95c2cSAdrian Chadd #define IEEE80211_MESHCONF_FORM_SA 0xF0 /* indicating 802.1X auth */
10381b95c2cSAdrian Chadd
10481b95c2cSAdrian Chadd /* Mesh Capability */
10559aa14a9SRui Paulo #define IEEE80211_MESHCONF_CAP_AP 0x01 /* Accepting Peers */
10659aa14a9SRui Paulo #define IEEE80211_MESHCONF_CAP_MCCAS 0x02 /* MCCA supported */
10759aa14a9SRui Paulo #define IEEE80211_MESHCONF_CAP_MCCAE 0x04 /* MCCA enabled */
10859aa14a9SRui Paulo #define IEEE80211_MESHCONF_CAP_FWRD 0x08 /* forwarding enabled */
10959aa14a9SRui Paulo #define IEEE80211_MESHCONF_CAP_BTR 0x10 /* Beacon Timing Report Enab */
11081b95c2cSAdrian Chadd #define IEEE80211_MESHCONF_CAP_TBTT 0x20 /* TBTT Adjusting */
11181b95c2cSAdrian Chadd #define IEEE80211_MESHCONF_CAP_PSL 0x40 /* Power Save Level */
11281b95c2cSAdrian Chadd /* 0x80 reserved */
11359aa14a9SRui Paulo
11459aa14a9SRui Paulo /* Mesh Identifier */
11559aa14a9SRui Paulo struct ieee80211_meshid_ie {
11659aa14a9SRui Paulo uint8_t id_ie; /* IEEE80211_ELEMID_MESHID */
11759aa14a9SRui Paulo uint8_t id_len;
11859aa14a9SRui Paulo } __packed;
11959aa14a9SRui Paulo
12059aa14a9SRui Paulo /* Link Metric Report */
12159aa14a9SRui Paulo struct ieee80211_meshlmetric_ie {
122bdd2a076SAdrian Chadd uint8_t lm_ie; /* IEEE80211_ACTION_MESH_LMETRIC */
12359aa14a9SRui Paulo uint8_t lm_len;
124bdd2a076SAdrian Chadd uint8_t lm_flags;
125bdd2a076SAdrian Chadd #define IEEE80211_MESH_LMETRIC_FLAGS_REQ 0x01 /* Request */
126bdd2a076SAdrian Chadd /*
127bdd2a076SAdrian Chadd * XXX: this field should be variable in size and depend on
128bdd2a076SAdrian Chadd * the active active path selection metric identifier
129bdd2a076SAdrian Chadd */
13059aa14a9SRui Paulo uint32_t lm_metric;
13159aa14a9SRui Paulo #define IEEE80211_MESHLMETRIC_INITIALVAL 0
13259aa14a9SRui Paulo } __packed;
13359aa14a9SRui Paulo
13459aa14a9SRui Paulo /* Congestion Notification */
13559aa14a9SRui Paulo struct ieee80211_meshcngst_ie {
13659aa14a9SRui Paulo uint8_t cngst_ie; /* IEEE80211_ELEMID_MESHCNGST */
13759aa14a9SRui Paulo uint8_t cngst_len;
13859aa14a9SRui Paulo uint16_t cngst_timer[4]; /* Expiration Timers: AC_BK,
13959aa14a9SRui Paulo AC_BE, AC_VI, AC_VO */
14059aa14a9SRui Paulo } __packed;
14159aa14a9SRui Paulo
14259aa14a9SRui Paulo /* Peer Link Management */
143c2042c35SMonthadar Al Jaberi #define IEEE80211_MPM_BASE_SZ (4)
144c2042c35SMonthadar Al Jaberi #define IEEE80211_MPM_MAX_SZ (8)
14559aa14a9SRui Paulo struct ieee80211_meshpeer_ie {
14659aa14a9SRui Paulo uint8_t peer_ie; /* IEEE80211_ELEMID_MESHPEER */
14759aa14a9SRui Paulo uint8_t peer_len;
148c2042c35SMonthadar Al Jaberi uint16_t peer_proto; /* Peer Management Protocol */
14959aa14a9SRui Paulo uint16_t peer_llinkid; /* Local Link ID */
15059aa14a9SRui Paulo uint16_t peer_linkid; /* Peer Link ID */
15159aa14a9SRui Paulo uint16_t peer_rcode;
15259aa14a9SRui Paulo } __packed;
15359aa14a9SRui Paulo
154c2042c35SMonthadar Al Jaberi /* Mesh Peering Protocol Identifier field value */
155c2042c35SMonthadar Al Jaberi enum {
156c2042c35SMonthadar Al Jaberi IEEE80211_MPPID_MPM = 0, /* Mesh peering management */
157c2042c35SMonthadar Al Jaberi IEEE80211_MPPID_AUTH_MPM = 1, /* Auth. mesh peering exchange */
158c2042c35SMonthadar Al Jaberi /* 2-65535 reserved */
159c2042c35SMonthadar Al Jaberi };
160c2042c35SMonthadar Al Jaberi
16159aa14a9SRui Paulo #ifdef notyet
16259aa14a9SRui Paulo /* Mesh Channel Switch Annoucement */
16359aa14a9SRui Paulo struct ieee80211_meshcsa_ie {
16459aa14a9SRui Paulo uint8_t csa_ie; /* IEEE80211_ELEMID_MESHCSA */
16559aa14a9SRui Paulo uint8_t csa_len;
16659aa14a9SRui Paulo uint8_t csa_mode;
16759aa14a9SRui Paulo uint8_t csa_newclass; /* New Regulatory Class */
16859aa14a9SRui Paulo uint8_t csa_newchan;
16959aa14a9SRui Paulo uint8_t csa_precvalue; /* Precedence Value */
17059aa14a9SRui Paulo uint8_t csa_count;
17159aa14a9SRui Paulo } __packed;
17259aa14a9SRui Paulo
17359aa14a9SRui Paulo /* Mesh TIM */
17459aa14a9SRui Paulo /* Equal to the non Mesh version */
17559aa14a9SRui Paulo
17659aa14a9SRui Paulo /* Mesh Awake Window */
17759aa14a9SRui Paulo struct ieee80211_meshawakew_ie {
17859aa14a9SRui Paulo uint8_t awakew_ie; /* IEEE80211_ELEMID_MESHAWAKEW */
17959aa14a9SRui Paulo uint8_t awakew_len;
18059aa14a9SRui Paulo uint8_t awakew_windowlen; /* in TUs */
18159aa14a9SRui Paulo } __packed;
18259aa14a9SRui Paulo
18359aa14a9SRui Paulo /* Mesh Beacon Timing */
18459aa14a9SRui Paulo struct ieee80211_meshbeacont_ie {
18559aa14a9SRui Paulo uint8_t beacont_ie; /* IEEE80211_ELEMID_MESHBEACONT */
18659aa14a9SRui Paulo uint8_t beacont_len;
18759aa14a9SRui Paulo struct {
18859aa14a9SRui Paulo uint8_t mp_aid; /* Least Octet of AID */
18959aa14a9SRui Paulo uint16_t mp_btime; /* Beacon Time */
19059aa14a9SRui Paulo uint16_t mp_bint; /* Beacon Interval */
19159aa14a9SRui Paulo } __packed mp[1]; /* NB: variable size */
19259aa14a9SRui Paulo } __packed;
19359aa14a9SRui Paulo #endif
19459aa14a9SRui Paulo
1959fc85253SMonthadar Al Jaberi /* Gate (GANN) Annoucement */
196e1373e86SMonthadar Al Jaberi /*
197e1373e86SMonthadar Al Jaberi * NB: these macros used for the length in the IEs does not include 2 bytes
198e1373e86SMonthadar Al Jaberi * for _ie and _len fields as is defined by the standard.
199e1373e86SMonthadar Al Jaberi */
200e1373e86SMonthadar Al Jaberi #define IEEE80211_MESHGANN_BASE_SZ (15)
2019fc85253SMonthadar Al Jaberi struct ieee80211_meshgann_ie {
202e1373e86SMonthadar Al Jaberi uint8_t gann_ie; /* IEEE80211_ELEMID_MESHGANN */
203e1373e86SMonthadar Al Jaberi uint8_t gann_len;
204e1373e86SMonthadar Al Jaberi uint8_t gann_flags;
205e1373e86SMonthadar Al Jaberi uint8_t gann_hopcount;
206e1373e86SMonthadar Al Jaberi uint8_t gann_ttl;
207e1373e86SMonthadar Al Jaberi uint8_t gann_addr[IEEE80211_ADDR_LEN];
208e1373e86SMonthadar Al Jaberi uint32_t gann_seq; /* GANN Sequence Number */
209e1373e86SMonthadar Al Jaberi uint16_t gann_interval; /* GANN Interval */
21059aa14a9SRui Paulo } __packed;
21159aa14a9SRui Paulo
21259aa14a9SRui Paulo /* Root (MP) Annoucement */
2131f88a92bSAdrian Chadd #define IEEE80211_MESHRANN_BASE_SZ (21)
21459aa14a9SRui Paulo struct ieee80211_meshrann_ie {
21559aa14a9SRui Paulo uint8_t rann_ie; /* IEEE80211_ELEMID_MESHRANN */
21659aa14a9SRui Paulo uint8_t rann_len;
21759aa14a9SRui Paulo uint8_t rann_flags;
2189fc85253SMonthadar Al Jaberi #define IEEE80211_MESHRANN_FLAGS_GATE 0x01 /* Mesh Gate */
21959aa14a9SRui Paulo uint8_t rann_hopcount;
22059aa14a9SRui Paulo uint8_t rann_ttl;
22159aa14a9SRui Paulo uint8_t rann_addr[IEEE80211_ADDR_LEN];
22259aa14a9SRui Paulo uint32_t rann_seq; /* HWMP Sequence Number */
2231f88a92bSAdrian Chadd uint32_t rann_interval;
22459aa14a9SRui Paulo uint32_t rann_metric;
22559aa14a9SRui Paulo } __packed;
22659aa14a9SRui Paulo
22759aa14a9SRui Paulo /* Mesh Path Request */
2281f88a92bSAdrian Chadd #define IEEE80211_MESHPREQ_BASE_SZ (26)
2291f88a92bSAdrian Chadd #define IEEE80211_MESHPREQ_BASE_SZ_AE (32)
2301f88a92bSAdrian Chadd #define IEEE80211_MESHPREQ_TRGT_SZ (11)
2311f88a92bSAdrian Chadd #define IEEE80211_MESHPREQ_TCNT_OFFSET (27)
2321f88a92bSAdrian Chadd #define IEEE80211_MESHPREQ_TCNT_OFFSET_AE (33)
23359aa14a9SRui Paulo struct ieee80211_meshpreq_ie {
23459aa14a9SRui Paulo uint8_t preq_ie; /* IEEE80211_ELEMID_MESHPREQ */
23559aa14a9SRui Paulo uint8_t preq_len;
23659aa14a9SRui Paulo uint8_t preq_flags;
2379fc85253SMonthadar Al Jaberi #define IEEE80211_MESHPREQ_FLAGS_GATE 0x01 /* Mesh Gate */
2383d7486ceSMonthadar Al Jaberi #define IEEE80211_MESHPREQ_FLAGS_AM 0x02 /* 0 = bcast / 1 = ucast */
23959aa14a9SRui Paulo #define IEEE80211_MESHPREQ_FLAGS_PP 0x04 /* Proactive PREP */
24059aa14a9SRui Paulo #define IEEE80211_MESHPREQ_FLAGS_AE 0x40 /* Address Extension */
24159aa14a9SRui Paulo uint8_t preq_hopcount;
24259aa14a9SRui Paulo uint8_t preq_ttl;
24359aa14a9SRui Paulo uint32_t preq_id;
24459aa14a9SRui Paulo uint8_t preq_origaddr[IEEE80211_ADDR_LEN];
24559aa14a9SRui Paulo uint32_t preq_origseq; /* HWMP Sequence Number */
2461f88a92bSAdrian Chadd /* NB: may have Originator External Address */
2471f88a92bSAdrian Chadd uint8_t preq_orig_ext_addr[IEEE80211_ADDR_LEN];
24859aa14a9SRui Paulo uint32_t preq_lifetime;
24959aa14a9SRui Paulo uint32_t preq_metric;
25059aa14a9SRui Paulo uint8_t preq_tcount; /* target count */
25159aa14a9SRui Paulo struct {
25259aa14a9SRui Paulo uint8_t target_flags;
25359aa14a9SRui Paulo #define IEEE80211_MESHPREQ_TFLAGS_TO 0x01 /* Target Only */
25459aa14a9SRui Paulo #define IEEE80211_MESHPREQ_TFLAGS_USN 0x04 /* Unknown HWMP seq number */
25559aa14a9SRui Paulo uint8_t target_addr[IEEE80211_ADDR_LEN];
25659aa14a9SRui Paulo uint32_t target_seq; /* HWMP Sequence Number */
25759aa14a9SRui Paulo } __packed preq_targets[1]; /* NB: variable size */
25859aa14a9SRui Paulo } __packed;
25959aa14a9SRui Paulo
26059aa14a9SRui Paulo /* Mesh Path Reply */
2611f88a92bSAdrian Chadd #define IEEE80211_MESHPREP_BASE_SZ (31)
2621f88a92bSAdrian Chadd #define IEEE80211_MESHPREP_BASE_SZ_AE (37)
26359aa14a9SRui Paulo struct ieee80211_meshprep_ie {
26459aa14a9SRui Paulo uint8_t prep_ie; /* IEEE80211_ELEMID_MESHPREP */
26559aa14a9SRui Paulo uint8_t prep_len;
26659aa14a9SRui Paulo uint8_t prep_flags;
2671f88a92bSAdrian Chadd #define IEEE80211_MESHPREP_FLAGS_AE 0x40 /* Address Extension */
26859aa14a9SRui Paulo uint8_t prep_hopcount;
26959aa14a9SRui Paulo uint8_t prep_ttl;
27059aa14a9SRui Paulo uint8_t prep_targetaddr[IEEE80211_ADDR_LEN];
27159aa14a9SRui Paulo uint32_t prep_targetseq;
2721f88a92bSAdrian Chadd /* NB: May have Target External Address */
2731f88a92bSAdrian Chadd uint8_t prep_target_ext_addr[IEEE80211_ADDR_LEN];
27459aa14a9SRui Paulo uint32_t prep_lifetime;
27559aa14a9SRui Paulo uint32_t prep_metric;
27659aa14a9SRui Paulo uint8_t prep_origaddr[IEEE80211_ADDR_LEN];
27759aa14a9SRui Paulo uint32_t prep_origseq; /* HWMP Sequence Number */
27859aa14a9SRui Paulo } __packed;
27959aa14a9SRui Paulo
28059aa14a9SRui Paulo /* Mesh Path Error */
2811f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_MAXDEST (19)
2821f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_NDEST_OFFSET (3)
2831f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_BASE_SZ (2)
2841f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_DEST_SZ (13)
2851f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_DEST_SZ_AE (19)
28659aa14a9SRui Paulo struct ieee80211_meshperr_ie {
28759aa14a9SRui Paulo uint8_t perr_ie; /* IEEE80211_ELEMID_MESHPERR */
28859aa14a9SRui Paulo uint8_t perr_len;
289c77735e2SRui Paulo uint8_t perr_ttl;
29059aa14a9SRui Paulo uint8_t perr_ndests; /* Number of Destinations */
29159aa14a9SRui Paulo struct {
292c77735e2SRui Paulo uint8_t dest_flags;
2931f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_DFLAGS_USN 0x01 /* XXX: not part of standard */
2941f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_DFLAGS_RC 0x02 /* XXX: not part of standard */
2951f88a92bSAdrian Chadd #define IEEE80211_MESHPERR_FLAGS_AE 0x40 /* Address Extension */
29659aa14a9SRui Paulo uint8_t dest_addr[IEEE80211_ADDR_LEN];
29759aa14a9SRui Paulo uint32_t dest_seq; /* HWMP Sequence Number */
2981f88a92bSAdrian Chadd /* NB: May have Destination External Address */
2991f88a92bSAdrian Chadd uint8_t dest_ext_addr[IEEE80211_ADDR_LEN];
300c77735e2SRui Paulo uint16_t dest_rcode;
30159aa14a9SRui Paulo } __packed perr_dests[1]; /* NB: variable size */
30259aa14a9SRui Paulo } __packed;
30359aa14a9SRui Paulo
30459aa14a9SRui Paulo #ifdef notyet
30559aa14a9SRui Paulo /* Mesh Proxy Update */
30659aa14a9SRui Paulo struct ieee80211_meshpu_ie {
30759aa14a9SRui Paulo uint8_t pu_ie; /* IEEE80211_ELEMID_MESHPU */
30859aa14a9SRui Paulo uint8_t pu_len;
30959aa14a9SRui Paulo uint8_t pu_flags;
31059aa14a9SRui Paulo #define IEEE80211_MESHPU_FLAGS_MASK 0x1
31159aa14a9SRui Paulo #define IEEE80211_MESHPU_FLAGS_DEL 0x0
31259aa14a9SRui Paulo #define IEEE80211_MESHPU_FLAGS_ADD 0x1
31359aa14a9SRui Paulo uint8_t pu_seq; /* PU Sequence Number */
31459aa14a9SRui Paulo uint8_t pu_addr[IEEE80211_ADDR_LEN];
31559aa14a9SRui Paulo uint8_t pu_naddr; /* Number of Proxied Addresses */
31659aa14a9SRui Paulo /* NB: proxied address follows */
31759aa14a9SRui Paulo } __packed;
31859aa14a9SRui Paulo
31959aa14a9SRui Paulo /* Mesh Proxy Update Confirmation */
32059aa14a9SRui Paulo struct ieee80211_meshpuc_ie {
32159aa14a9SRui Paulo uint8_t puc_ie; /* IEEE80211_ELEMID_MESHPUC */
32259aa14a9SRui Paulo uint8_t puc_len;
32359aa14a9SRui Paulo uint8_t puc_flags;
32459aa14a9SRui Paulo uint8_t puc_seq; /* PU Sequence Number */
32559aa14a9SRui Paulo uint8_t puc_daddr[IEEE80211_ADDR_LEN];
32659aa14a9SRui Paulo } __packed;
32759aa14a9SRui Paulo #endif
32859aa14a9SRui Paulo
32959aa14a9SRui Paulo /*
33059aa14a9SRui Paulo * 802.11s Action Frames
331ebeaa1adSMonthadar Al Jaberi * XXX: these are wrong, and some of them should be
332ebeaa1adSMonthadar Al Jaberi * under MESH category while PROXY is under MULTIHOP category.
33359aa14a9SRui Paulo */
33459aa14a9SRui Paulo #define IEEE80211_ACTION_CAT_INTERWORK 15
33559aa14a9SRui Paulo #define IEEE80211_ACTION_CAT_RESOURCE 16
33659aa14a9SRui Paulo #define IEEE80211_ACTION_CAT_PROXY 17
33759aa14a9SRui Paulo
33859aa14a9SRui Paulo /*
33959aa14a9SRui Paulo * Mesh Peering Action codes.
34059aa14a9SRui Paulo */
34159aa14a9SRui Paulo enum {
342ebeaa1adSMonthadar Al Jaberi /* 0 reserved */
343ebeaa1adSMonthadar Al Jaberi IEEE80211_ACTION_MESHPEERING_OPEN = 1,
344ebeaa1adSMonthadar Al Jaberi IEEE80211_ACTION_MESHPEERING_CONFIRM = 2,
345ebeaa1adSMonthadar Al Jaberi IEEE80211_ACTION_MESHPEERING_CLOSE = 3,
346ebeaa1adSMonthadar Al Jaberi /* 4-255 reserved */
34759aa14a9SRui Paulo };
34859aa14a9SRui Paulo
34959aa14a9SRui Paulo /*
350bdd2a076SAdrian Chadd * Mesh Action code.
35159aa14a9SRui Paulo */
35259aa14a9SRui Paulo enum {
353bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_LMETRIC = 0, /* Mesh Link Metric Report */
354bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_HWMP = 1, /* HWMP Mesh Path Selection */
355bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_GANN = 2, /* Gate Announcement */
356bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_CC = 3, /* Congestion Control */
357bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_MCCA_SREQ = 4, /* MCCA Setup Request */
358bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_MCCA_SREP = 5, /* MCCA Setup Reply */
359bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_MCCA_AREQ = 6, /* MCCA Advertisement Req. */
360bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_MCCA_ADVER =7, /* MCCA Advertisement */
361bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_MCCA_TRDOWN = 8, /* MCCA Teardown */
362bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_TBTT_REQ = 9, /* TBTT Adjustment Request */
363bdd2a076SAdrian Chadd IEEE80211_ACTION_MESH_TBTT_RES = 10, /* TBTT Adjustment Response */
364bdd2a076SAdrian Chadd /* 11-255 reserved */
36559aa14a9SRui Paulo };
36659aa14a9SRui Paulo
36759aa14a9SRui Paulo /*
36859aa14a9SRui Paulo * Different mesh control structures based on the AE
36959aa14a9SRui Paulo * (Address Extension) bits.
37059aa14a9SRui Paulo */
37159aa14a9SRui Paulo struct ieee80211_meshcntl {
37259aa14a9SRui Paulo uint8_t mc_flags; /* Address Extension 00 */
37359aa14a9SRui Paulo uint8_t mc_ttl; /* TTL */
37459aa14a9SRui Paulo uint8_t mc_seq[4]; /* Sequence No. */
37559aa14a9SRui Paulo /* NB: more addresses may follow */
37659aa14a9SRui Paulo } __packed;
37759aa14a9SRui Paulo
37859aa14a9SRui Paulo struct ieee80211_meshcntl_ae01 {
37959aa14a9SRui Paulo uint8_t mc_flags; /* Address Extension 01 */
38059aa14a9SRui Paulo uint8_t mc_ttl; /* TTL */
38159aa14a9SRui Paulo uint8_t mc_seq[4]; /* Sequence No. */
38259aa14a9SRui Paulo uint8_t mc_addr4[IEEE80211_ADDR_LEN];
38359aa14a9SRui Paulo } __packed;
38459aa14a9SRui Paulo
38559aa14a9SRui Paulo struct ieee80211_meshcntl_ae10 {
38659aa14a9SRui Paulo uint8_t mc_flags; /* Address Extension 10 */
38759aa14a9SRui Paulo uint8_t mc_ttl; /* TTL */
38859aa14a9SRui Paulo uint8_t mc_seq[4]; /* Sequence No. */
38959aa14a9SRui Paulo uint8_t mc_addr5[IEEE80211_ADDR_LEN];
39059aa14a9SRui Paulo uint8_t mc_addr6[IEEE80211_ADDR_LEN];
39159aa14a9SRui Paulo } __packed;
39259aa14a9SRui Paulo
3933c314f6dSMonthadar Al Jaberi #define IEEE80211_MESH_AE_MASK 0x03
3943c314f6dSMonthadar Al Jaberi enum {
3953c314f6dSMonthadar Al Jaberi IEEE80211_MESH_AE_00 = 0, /* MC has no AE subfield */
3963c314f6dSMonthadar Al Jaberi IEEE80211_MESH_AE_01 = 1, /* MC contain addr4 */
3973c314f6dSMonthadar Al Jaberi IEEE80211_MESH_AE_10 = 2, /* MC contain addr5 & addr6 */
3983c314f6dSMonthadar Al Jaberi IEEE80211_MESH_AE_11 = 3, /* RESERVED */
3993c314f6dSMonthadar Al Jaberi };
4003c314f6dSMonthadar Al Jaberi
40159aa14a9SRui Paulo #ifdef _KERNEL
4021f88a92bSAdrian Chadd MALLOC_DECLARE(M_80211_MESH_PREQ);
4031f88a92bSAdrian Chadd MALLOC_DECLARE(M_80211_MESH_PREP);
4041f88a92bSAdrian Chadd MALLOC_DECLARE(M_80211_MESH_PERR);
4051f88a92bSAdrian Chadd
40659aa14a9SRui Paulo MALLOC_DECLARE(M_80211_MESH_RT);
4074cc361aaSMonthadar Al Jaberi MALLOC_DECLARE(M_80211_MESH_GT_RT);
408b5df85a6SMonthadar Al Jaberi /*
409b5df85a6SMonthadar Al Jaberi * Basic forwarding information:
410b5df85a6SMonthadar Al Jaberi * o Destination MAC
411b5df85a6SMonthadar Al Jaberi * o Next-hop MAC
412b5df85a6SMonthadar Al Jaberi * o Precursor list (not implemented yet)
413b5df85a6SMonthadar Al Jaberi * o Path timeout
414b5df85a6SMonthadar Al Jaberi * The rest is part of the active Mesh path selection protocol.
415b5df85a6SMonthadar Al Jaberi * XXX: to be moved out later.
416b5df85a6SMonthadar Al Jaberi */
41759aa14a9SRui Paulo struct ieee80211_mesh_route {
41859aa14a9SRui Paulo TAILQ_ENTRY(ieee80211_mesh_route) rt_next;
41947451c66SMonthadar Al Jaberi struct ieee80211vap *rt_vap;
42071f9dd12SAdrian Chadd ieee80211_rte_lock_t rt_lock; /* fine grained route lock */
42147451c66SMonthadar Al Jaberi struct callout rt_discovery; /* discovery timeout */
422b5df85a6SMonthadar Al Jaberi int rt_updtime; /* last update time */
42359aa14a9SRui Paulo uint8_t rt_dest[IEEE80211_ADDR_LEN];
4243c314f6dSMonthadar Al Jaberi uint8_t rt_mesh_gate[IEEE80211_ADDR_LEN]; /* meshDA */
42559aa14a9SRui Paulo uint8_t rt_nexthop[IEEE80211_ADDR_LEN];
42659aa14a9SRui Paulo uint32_t rt_metric; /* path metric */
42759aa14a9SRui Paulo uint16_t rt_nhops; /* number of hops */
428c104cff2SRui Paulo uint16_t rt_flags;
42947451c66SMonthadar Al Jaberi #define IEEE80211_MESHRT_FLAGS_DISCOVER 0x01 /* path discovery */
43047451c66SMonthadar Al Jaberi #define IEEE80211_MESHRT_FLAGS_VALID 0x02 /* path discovery complete */
43147451c66SMonthadar Al Jaberi #define IEEE80211_MESHRT_FLAGS_PROXY 0x04 /* proxy entry */
432e1373e86SMonthadar Al Jaberi #define IEEE80211_MESHRT_FLAGS_GATE 0x08 /* mesh gate entry */
433b5df85a6SMonthadar Al Jaberi uint32_t rt_lifetime; /* route timeout */
43459aa14a9SRui Paulo uint32_t rt_lastmseq; /* last seq# seen dest */
4353c314f6dSMonthadar Al Jaberi uint32_t rt_ext_seq; /* proxy seq number */
43659aa14a9SRui Paulo void *rt_priv; /* private data */
43759aa14a9SRui Paulo };
43859aa14a9SRui Paulo #define IEEE80211_MESH_ROUTE_PRIV(rt, cast) ((cast *)rt->rt_priv)
43959aa14a9SRui Paulo
4404cc361aaSMonthadar Al Jaberi /*
4414cc361aaSMonthadar Al Jaberi * Stored information about known mesh gates.
4424cc361aaSMonthadar Al Jaberi */
4434cc361aaSMonthadar Al Jaberi struct ieee80211_mesh_gate_route {
4444cc361aaSMonthadar Al Jaberi TAILQ_ENTRY(ieee80211_mesh_gate_route) gr_next;
4454cc361aaSMonthadar Al Jaberi uint8_t gr_addr[IEEE80211_ADDR_LEN];
4464cc361aaSMonthadar Al Jaberi uint32_t gr_lastseq;
4474cc361aaSMonthadar Al Jaberi struct ieee80211_mesh_route *gr_route;
4484cc361aaSMonthadar Al Jaberi };
4494cc361aaSMonthadar Al Jaberi
45059aa14a9SRui Paulo #define IEEE80211_MESH_PROTO_DSZ 12 /* description size */
45159aa14a9SRui Paulo /*
45259aa14a9SRui Paulo * Mesh Path Selection Protocol.
45359aa14a9SRui Paulo */
45459aa14a9SRui Paulo enum ieee80211_state;
45559aa14a9SRui Paulo struct ieee80211_mesh_proto_path {
4566b8c1829SRui Paulo uint8_t mpp_active;
45759aa14a9SRui Paulo char mpp_descr[IEEE80211_MESH_PROTO_DSZ];
4586b8c1829SRui Paulo uint8_t mpp_ie;
45959aa14a9SRui Paulo struct ieee80211_node *
46059aa14a9SRui Paulo (*mpp_discover)(struct ieee80211vap *,
46159aa14a9SRui Paulo const uint8_t [IEEE80211_ADDR_LEN],
46259aa14a9SRui Paulo struct mbuf *);
46359aa14a9SRui Paulo void (*mpp_peerdown)(struct ieee80211_node *);
4643db82516SMonthadar Al Jaberi void (*mpp_senderror)(struct ieee80211vap *,
4653db82516SMonthadar Al Jaberi const uint8_t [IEEE80211_ADDR_LEN],
4663db82516SMonthadar Al Jaberi struct ieee80211_mesh_route *, int);
46759aa14a9SRui Paulo void (*mpp_vattach)(struct ieee80211vap *);
46859aa14a9SRui Paulo void (*mpp_vdetach)(struct ieee80211vap *);
46959aa14a9SRui Paulo int (*mpp_newstate)(struct ieee80211vap *,
47059aa14a9SRui Paulo enum ieee80211_state, int);
471c104cff2SRui Paulo const size_t mpp_privlen; /* size required in the routing table
47259aa14a9SRui Paulo for private data */
473e50821abSSam Leffler int mpp_inact; /* inact. timeout for invalid routes
474e50821abSSam Leffler (ticks) */
47559aa14a9SRui Paulo };
47659aa14a9SRui Paulo
47759aa14a9SRui Paulo /*
47859aa14a9SRui Paulo * Mesh Link Metric Report Protocol.
47959aa14a9SRui Paulo */
48059aa14a9SRui Paulo struct ieee80211_mesh_proto_metric {
4816b8c1829SRui Paulo uint8_t mpm_active;
48259aa14a9SRui Paulo char mpm_descr[IEEE80211_MESH_PROTO_DSZ];
4836b8c1829SRui Paulo uint8_t mpm_ie;
48459aa14a9SRui Paulo uint32_t (*mpm_metric)(struct ieee80211_node *);
48559aa14a9SRui Paulo };
48659aa14a9SRui Paulo
48759aa14a9SRui Paulo #ifdef notyet
48859aa14a9SRui Paulo /*
48959aa14a9SRui Paulo * Mesh Authentication Protocol.
49059aa14a9SRui Paulo */
49159aa14a9SRui Paulo struct ieee80211_mesh_proto_auth {
49259aa14a9SRui Paulo uint8_t mpa_ie[4];
49359aa14a9SRui Paulo };
49459aa14a9SRui Paulo
49559aa14a9SRui Paulo struct ieee80211_mesh_proto_congestion {
49659aa14a9SRui Paulo };
49759aa14a9SRui Paulo
49859aa14a9SRui Paulo struct ieee80211_mesh_proto_sync {
49959aa14a9SRui Paulo };
50059aa14a9SRui Paulo #endif
50159aa14a9SRui Paulo
50259aa14a9SRui Paulo typedef uint32_t ieee80211_mesh_seq;
50359aa14a9SRui Paulo #define IEEE80211_MESH_SEQ_LEQ(a, b) ((int32_t)((a)-(b)) <= 0)
50459aa14a9SRui Paulo #define IEEE80211_MESH_SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0)
50559aa14a9SRui Paulo
50659aa14a9SRui Paulo struct ieee80211_mesh_state {
50759aa14a9SRui Paulo int ms_idlen;
50859aa14a9SRui Paulo uint8_t ms_id[IEEE80211_MESHID_LEN];
50959aa14a9SRui Paulo ieee80211_mesh_seq ms_seq; /* seq no for meshcntl */
51059aa14a9SRui Paulo uint16_t ms_neighbors;
51159aa14a9SRui Paulo uint8_t ms_ttl; /* mesh ttl set in packets */
51259aa14a9SRui Paulo #define IEEE80211_MESHFLAGS_AP 0x01 /* accept peers */
5139fc85253SMonthadar Al Jaberi #define IEEE80211_MESHFLAGS_GATE 0x02 /* mesh gate role */
51459aa14a9SRui Paulo #define IEEE80211_MESHFLAGS_FWD 0x04 /* forward packets */
515ed0b5440SMonthadar Al Jaberi #define IEEE80211_MESHFLAGS_ROOT 0x08 /* configured as root */
51659aa14a9SRui Paulo uint8_t ms_flags;
51771f9dd12SAdrian Chadd ieee80211_rt_lock_t ms_rt_lock;
518c104cff2SRui Paulo struct callout ms_cleantimer;
519ed0b5440SMonthadar Al Jaberi struct callout ms_gatetimer;
520ed0b5440SMonthadar Al Jaberi ieee80211_mesh_seq ms_gateseq;
5214cc361aaSMonthadar Al Jaberi TAILQ_HEAD(, ieee80211_mesh_gate_route) ms_known_gates;
52259aa14a9SRui Paulo TAILQ_HEAD(, ieee80211_mesh_route) ms_routes;
52359aa14a9SRui Paulo struct ieee80211_mesh_proto_metric *ms_pmetric;
52459aa14a9SRui Paulo struct ieee80211_mesh_proto_path *ms_ppath;
52559aa14a9SRui Paulo };
52659aa14a9SRui Paulo void ieee80211_mesh_attach(struct ieee80211com *);
52759aa14a9SRui Paulo void ieee80211_mesh_detach(struct ieee80211com *);
52859aa14a9SRui Paulo
52959aa14a9SRui Paulo struct ieee80211_mesh_route *
53059aa14a9SRui Paulo ieee80211_mesh_rt_find(struct ieee80211vap *,
53159aa14a9SRui Paulo const uint8_t [IEEE80211_ADDR_LEN]);
53259aa14a9SRui Paulo struct ieee80211_mesh_route *
53359aa14a9SRui Paulo ieee80211_mesh_rt_add(struct ieee80211vap *,
53459aa14a9SRui Paulo const uint8_t [IEEE80211_ADDR_LEN]);
53559aa14a9SRui Paulo void ieee80211_mesh_rt_del(struct ieee80211vap *,
53659aa14a9SRui Paulo const uint8_t [IEEE80211_ADDR_LEN]);
53759aa14a9SRui Paulo void ieee80211_mesh_rt_flush(struct ieee80211vap *);
5383ca80f0dSRui Paulo void ieee80211_mesh_rt_flush_peer(struct ieee80211vap *,
5393ca80f0dSRui Paulo const uint8_t [IEEE80211_ADDR_LEN]);
540b5df85a6SMonthadar Al Jaberi int ieee80211_mesh_rt_update(struct ieee80211_mesh_route *rt, int);
541c104cff2SRui Paulo void ieee80211_mesh_proxy_check(struct ieee80211vap *,
542c104cff2SRui Paulo const uint8_t [IEEE80211_ADDR_LEN]);
54359aa14a9SRui Paulo
54459aa14a9SRui Paulo int ieee80211_mesh_register_proto_path(const
54559aa14a9SRui Paulo struct ieee80211_mesh_proto_path *);
54659aa14a9SRui Paulo int ieee80211_mesh_register_proto_metric(const
54759aa14a9SRui Paulo struct ieee80211_mesh_proto_metric *);
54859aa14a9SRui Paulo
54959aa14a9SRui Paulo uint8_t * ieee80211_add_meshid(uint8_t *, struct ieee80211vap *);
55059aa14a9SRui Paulo uint8_t * ieee80211_add_meshconf(uint8_t *, struct ieee80211vap *);
55159aa14a9SRui Paulo uint8_t * ieee80211_add_meshpeer(uint8_t *, uint8_t, uint16_t, uint16_t,
55259aa14a9SRui Paulo uint16_t);
553bdd2a076SAdrian Chadd uint8_t * ieee80211_add_meshlmetric(uint8_t *, uint8_t, uint32_t);
554ed0b5440SMonthadar Al Jaberi uint8_t * ieee80211_add_meshgate(uint8_t *,
555ed0b5440SMonthadar Al Jaberi struct ieee80211_meshgann_ie *);
55659aa14a9SRui Paulo
55759aa14a9SRui Paulo void ieee80211_mesh_node_init(struct ieee80211vap *,
55859aa14a9SRui Paulo struct ieee80211_node *);
55959aa14a9SRui Paulo void ieee80211_mesh_node_cleanup(struct ieee80211_node *);
56059aa14a9SRui Paulo void ieee80211_parse_meshid(struct ieee80211_node *,
56159aa14a9SRui Paulo const uint8_t *);
56259aa14a9SRui Paulo struct ieee80211_scanparams;
56359aa14a9SRui Paulo void ieee80211_mesh_init_neighbor(struct ieee80211_node *,
56459aa14a9SRui Paulo const struct ieee80211_frame *,
56559aa14a9SRui Paulo const struct ieee80211_scanparams *);
566d093681cSRui Paulo void ieee80211_mesh_update_beacon(struct ieee80211vap *,
567d093681cSRui Paulo struct ieee80211_beacon_offsets *);
568a21c6123SMonthadar Al Jaberi struct ieee80211_mesh_gate_route *
569a21c6123SMonthadar Al Jaberi ieee80211_mesh_mark_gate(struct ieee80211vap *,
570a21c6123SMonthadar Al Jaberi const uint8_t *, struct ieee80211_mesh_route *);
571b79858daSMonthadar Al Jaberi void ieee80211_mesh_forward_to_gates(struct ieee80211vap *,
572b79858daSMonthadar Al Jaberi struct ieee80211_mesh_route *);
5734c4f4aa0SMonthadar Al Jaberi struct ieee80211_node *
5744c4f4aa0SMonthadar Al Jaberi ieee80211_mesh_find_txnode(struct ieee80211vap *,
5754c4f4aa0SMonthadar Al Jaberi const uint8_t [IEEE80211_ADDR_LEN]);
57659aa14a9SRui Paulo
577c104cff2SRui Paulo /*
578c104cff2SRui Paulo * Return non-zero if proxy operation is enabled.
579c104cff2SRui Paulo */
580c104cff2SRui Paulo static __inline int
ieee80211_mesh_isproxyena(struct ieee80211vap * vap)581c104cff2SRui Paulo ieee80211_mesh_isproxyena(struct ieee80211vap *vap)
582c104cff2SRui Paulo {
583c104cff2SRui Paulo struct ieee80211_mesh_state *ms = vap->iv_mesh;
584c104cff2SRui Paulo return (ms->ms_flags &
5859fc85253SMonthadar Al Jaberi (IEEE80211_MESHFLAGS_AP | IEEE80211_MESHFLAGS_GATE)) != 0;
586c104cff2SRui Paulo }
587c104cff2SRui Paulo
588c104cff2SRui Paulo /*
589c104cff2SRui Paulo * Process an outbound frame: if a path is known to the
590c104cff2SRui Paulo * destination then return a reference to the next hop
591c104cff2SRui Paulo * for immediate transmission. Otherwise initiate path
592c104cff2SRui Paulo * discovery and, if possible queue the packet to be
593c104cff2SRui Paulo * sent when path discovery completes.
594c104cff2SRui Paulo */
59559aa14a9SRui Paulo static __inline struct ieee80211_node *
ieee80211_mesh_discover(struct ieee80211vap * vap,const uint8_t dest[IEEE80211_ADDR_LEN],struct mbuf * m)59659aa14a9SRui Paulo ieee80211_mesh_discover(struct ieee80211vap *vap,
59759aa14a9SRui Paulo const uint8_t dest[IEEE80211_ADDR_LEN], struct mbuf *m)
59859aa14a9SRui Paulo {
59959aa14a9SRui Paulo struct ieee80211_mesh_state *ms = vap->iv_mesh;
60059aa14a9SRui Paulo return ms->ms_ppath->mpp_discover(vap, dest, m);
60159aa14a9SRui Paulo }
60259aa14a9SRui Paulo
60359aa14a9SRui Paulo #endif /* _KERNEL */
60459aa14a9SRui Paulo #endif /* !_NET80211_IEEE80211_MESH_H_ */
605