xref: /freebsd/sys/net80211/ieee80211_mesh.h (revision c2042c359f8069517ecc5393aec312f1720da4b2)
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
3559aa14a9SRui Paulo 
3659aa14a9SRui Paulo /*
3759aa14a9SRui Paulo  * NB: all structures are __packed  so sizeof works on arm, et. al.
3859aa14a9SRui Paulo  */
3959aa14a9SRui Paulo /*
4059aa14a9SRui Paulo  * 802.11s Information Elements.
4159aa14a9SRui Paulo */
4259aa14a9SRui Paulo /* Mesh Configuration */
4381b95c2cSAdrian Chadd #define IEEE80211_MESH_CONF_SZ		(7)
4459aa14a9SRui Paulo struct ieee80211_meshconf_ie {
4559aa14a9SRui Paulo 	uint8_t		conf_ie;	/* IEEE80211_ELEMID_MESHCONF */
4659aa14a9SRui Paulo 	uint8_t		conf_len;
476b8c1829SRui Paulo 	uint8_t		conf_pselid;	/* Active Path Sel. Proto. ID */
486b8c1829SRui Paulo 	uint8_t		conf_pmetid;	/* Active Metric Identifier */
496b8c1829SRui Paulo 	uint8_t		conf_ccid;	/* Congestion Control Mode ID  */
506b8c1829SRui Paulo 	uint8_t		conf_syncid;	/* Sync. Protocol ID */
516b8c1829SRui Paulo 	uint8_t		conf_authid;	/* Auth. Protocol ID */
5259aa14a9SRui Paulo 	uint8_t		conf_form;	/* Formation Information */
5381b95c2cSAdrian Chadd 	uint8_t		conf_cap;
5459aa14a9SRui Paulo } __packed;
5559aa14a9SRui Paulo 
5659aa14a9SRui Paulo /* Hybrid Wireless Mesh Protocol */
5781b95c2cSAdrian Chadd enum {
5881b95c2cSAdrian Chadd 	/* 0 reserved */
5981b95c2cSAdrian Chadd 	IEEE80211_MESHCONF_PATH_HWMP		= 1,
6081b95c2cSAdrian Chadd 	/* 2-254 reserved */
6181b95c2cSAdrian Chadd 	IEEE80211_MESHCONF_PATH_VENDOR		= 255,
6281b95c2cSAdrian Chadd };
6381b95c2cSAdrian Chadd 
6459aa14a9SRui Paulo /* Airtime Link Metric */
6581b95c2cSAdrian Chadd enum {
6681b95c2cSAdrian Chadd 	/* 0 reserved */
6781b95c2cSAdrian Chadd 	IEEE80211_MESHCONF_METRIC_AIRTIME	= 1,
6881b95c2cSAdrian Chadd 	/* 2-254 reserved */
6981b95c2cSAdrian Chadd 	IEEE80211_MESHCONF_METRIC_VENDOR	= 255,
7081b95c2cSAdrian Chadd };
7181b95c2cSAdrian Chadd 
726b8c1829SRui Paulo /* Congestion Control */
7381b95c2cSAdrian Chadd enum {
7481b95c2cSAdrian Chadd 	IEEE80211_MESHCONF_CC_DISABLED		= 0,
7581b95c2cSAdrian Chadd 	IEEE80211_MESHCONF_CC_SIG		= 1,
7681b95c2cSAdrian Chadd 	/* 2-254 reserved */
7781b95c2cSAdrian Chadd 	IEEE80211_MESHCONF_CC_VENDOR		= 255,
7881b95c2cSAdrian Chadd };
7981b95c2cSAdrian Chadd 
8059aa14a9SRui Paulo /* Neighbour Offset */
8181b95c2cSAdrian Chadd enum {
8281b95c2cSAdrian Chadd 	/* 0 reserved */
8381b95c2cSAdrian Chadd 	IEEE80211_MESHCONF_SYNC_NEIGHOFF	= 1,
8481b95c2cSAdrian Chadd 	/* 2-254 rserved */
8581b95c2cSAdrian Chadd 	IEEE80211_MESHCONF_SYNC_VENDOR		= 255,
8681b95c2cSAdrian Chadd };
8781b95c2cSAdrian Chadd 
8881b95c2cSAdrian Chadd /* Authentication Protocol Identifier */
8981b95c2cSAdrian Chadd enum {
9081b95c2cSAdrian Chadd 
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 */
10059aa14a9SRui Paulo #define	IEEE80211_MESHCONF_FORM_MP	0x01 	/* Connected to Portal */
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 */
143*c2042c35SMonthadar Al Jaberi #define IEEE80211_MPM_BASE_SZ	(4)
144*c2042c35SMonthadar 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;
148*c2042c35SMonthadar 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 
154*c2042c35SMonthadar Al Jaberi /* Mesh Peering Protocol Identifier field value */
155*c2042c35SMonthadar Al Jaberi enum {
156*c2042c35SMonthadar Al Jaberi 	IEEE80211_MPPID_MPM		= 0,	/* Mesh peering management */
157*c2042c35SMonthadar Al Jaberi 	IEEE80211_MPPID_AUTH_MPM	= 1,	/* Auth. mesh peering exchange */
158*c2042c35SMonthadar Al Jaberi 	/* 2-65535 reserved */
159*c2042c35SMonthadar Al Jaberi };
160*c2042c35SMonthadar 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 
19559aa14a9SRui Paulo /* Portal (MP) Annoucement */
19659aa14a9SRui Paulo struct ieee80211_meshpann_ie {
19759aa14a9SRui Paulo 	uint8_t		pann_ie;		/* IEEE80211_ELEMID_MESHPANN */
19859aa14a9SRui Paulo 	uint8_t		pann_len;
19959aa14a9SRui Paulo 	uint8_t		pann_flags;
20059aa14a9SRui Paulo 	uint8_t		pann_hopcount;
20159aa14a9SRui Paulo 	uint8_t		pann_ttl;
20259aa14a9SRui Paulo 	uint8_t		pann_addr[IEEE80211_ADDR_LEN];
20359aa14a9SRui Paulo 	uint8_t		pann_seq;		/* PANN Sequence Number */
20459aa14a9SRui Paulo } __packed;
20559aa14a9SRui Paulo 
20659aa14a9SRui Paulo /* Root (MP) Annoucement */
2071f88a92bSAdrian Chadd #define	IEEE80211_MESHRANN_BASE_SZ 	(21)
20859aa14a9SRui Paulo struct ieee80211_meshrann_ie {
20959aa14a9SRui Paulo 	uint8_t		rann_ie;		/* IEEE80211_ELEMID_MESHRANN */
21059aa14a9SRui Paulo 	uint8_t		rann_len;
21159aa14a9SRui Paulo 	uint8_t		rann_flags;
21259aa14a9SRui Paulo #define	IEEE80211_MESHRANN_FLAGS_PR	0x01	/* Portal Role */
21359aa14a9SRui Paulo 	uint8_t		rann_hopcount;
21459aa14a9SRui Paulo 	uint8_t		rann_ttl;
21559aa14a9SRui Paulo 	uint8_t		rann_addr[IEEE80211_ADDR_LEN];
21659aa14a9SRui Paulo 	uint32_t	rann_seq;		/* HWMP Sequence Number */
2171f88a92bSAdrian Chadd 	uint32_t	rann_interval;
21859aa14a9SRui Paulo 	uint32_t	rann_metric;
21959aa14a9SRui Paulo } __packed;
22059aa14a9SRui Paulo 
22159aa14a9SRui Paulo /* Mesh Path Request */
2221f88a92bSAdrian Chadd #define	IEEE80211_MESHPREQ_BASE_SZ 		(26)
2231f88a92bSAdrian Chadd #define	IEEE80211_MESHPREQ_BASE_SZ_AE 		(32)
2241f88a92bSAdrian Chadd #define	IEEE80211_MESHPREQ_TRGT_SZ 		(11)
2251f88a92bSAdrian Chadd #define	IEEE80211_MESHPREQ_TCNT_OFFSET		(27)
2261f88a92bSAdrian Chadd #define	IEEE80211_MESHPREQ_TCNT_OFFSET_AE	(33)
22759aa14a9SRui Paulo struct ieee80211_meshpreq_ie {
22859aa14a9SRui Paulo 	uint8_t		preq_ie;	/* IEEE80211_ELEMID_MESHPREQ */
22959aa14a9SRui Paulo 	uint8_t		preq_len;
23059aa14a9SRui Paulo 	uint8_t		preq_flags;
23159aa14a9SRui Paulo #define	IEEE80211_MESHPREQ_FLAGS_PR	0x01	/* Portal Role */
23259aa14a9SRui Paulo #define	IEEE80211_MESHPREQ_FLAGS_AM	0x02	/* 0 = ucast / 1 = bcast */
23359aa14a9SRui Paulo #define	IEEE80211_MESHPREQ_FLAGS_PP	0x04	/* Proactive PREP */
23459aa14a9SRui Paulo #define	IEEE80211_MESHPREQ_FLAGS_AE	0x40	/* Address Extension */
23559aa14a9SRui Paulo 	uint8_t		preq_hopcount;
23659aa14a9SRui Paulo 	uint8_t		preq_ttl;
23759aa14a9SRui Paulo 	uint32_t	preq_id;
23859aa14a9SRui Paulo 	uint8_t		preq_origaddr[IEEE80211_ADDR_LEN];
23959aa14a9SRui Paulo 	uint32_t	preq_origseq;	/* HWMP Sequence Number */
2401f88a92bSAdrian Chadd 	/* NB: may have Originator External Address */
2411f88a92bSAdrian Chadd 	uint8_t		preq_orig_ext_addr[IEEE80211_ADDR_LEN];
24259aa14a9SRui Paulo 	uint32_t	preq_lifetime;
24359aa14a9SRui Paulo 	uint32_t	preq_metric;
24459aa14a9SRui Paulo 	uint8_t		preq_tcount;	/* target count */
24559aa14a9SRui Paulo 	struct {
24659aa14a9SRui Paulo 		uint8_t		target_flags;
24759aa14a9SRui Paulo #define	IEEE80211_MESHPREQ_TFLAGS_TO	0x01	/* Target Only */
24859aa14a9SRui Paulo #define	IEEE80211_MESHPREQ_TFLAGS_RF	0x02	/* Reply and Forward */
24959aa14a9SRui Paulo #define	IEEE80211_MESHPREQ_TFLAGS_USN	0x04	/* Unknown HWMP seq number */
25059aa14a9SRui Paulo 		uint8_t		target_addr[IEEE80211_ADDR_LEN];
25159aa14a9SRui Paulo 		uint32_t	target_seq;	/* HWMP Sequence Number */
25259aa14a9SRui Paulo 	} __packed preq_targets[1];		/* NB: variable size */
25359aa14a9SRui Paulo } __packed;
25459aa14a9SRui Paulo 
25559aa14a9SRui Paulo /* Mesh Path Reply */
2561f88a92bSAdrian Chadd #define	IEEE80211_MESHPREP_BASE_SZ 	(31)
2571f88a92bSAdrian Chadd #define	IEEE80211_MESHPREP_BASE_SZ_AE 	(37)
25859aa14a9SRui Paulo struct ieee80211_meshprep_ie {
25959aa14a9SRui Paulo 	uint8_t		prep_ie;	/* IEEE80211_ELEMID_MESHPREP */
26059aa14a9SRui Paulo 	uint8_t		prep_len;
26159aa14a9SRui Paulo 	uint8_t		prep_flags;
2621f88a92bSAdrian Chadd #define	IEEE80211_MESHPREP_FLAGS_AE	0x40	/* Address Extension */
26359aa14a9SRui Paulo 	uint8_t		prep_hopcount;
26459aa14a9SRui Paulo 	uint8_t		prep_ttl;
26559aa14a9SRui Paulo 	uint8_t		prep_targetaddr[IEEE80211_ADDR_LEN];
26659aa14a9SRui Paulo 	uint32_t	prep_targetseq;
2671f88a92bSAdrian Chadd 	/* NB: May have Target External Address */
2681f88a92bSAdrian Chadd 	uint8_t		prep_target_ext_addr[IEEE80211_ADDR_LEN];
26959aa14a9SRui Paulo 	uint32_t	prep_lifetime;
27059aa14a9SRui Paulo 	uint32_t	prep_metric;
27159aa14a9SRui Paulo 	uint8_t		prep_origaddr[IEEE80211_ADDR_LEN];
27259aa14a9SRui Paulo 	uint32_t	prep_origseq;	/* HWMP Sequence Number */
27359aa14a9SRui Paulo } __packed;
27459aa14a9SRui Paulo 
27559aa14a9SRui Paulo /* Mesh Path Error */
2761f88a92bSAdrian Chadd #define	IEEE80211_MESHPERR_MAXDEST	(19)
2771f88a92bSAdrian Chadd #define	IEEE80211_MESHPERR_NDEST_OFFSET	(3)
2781f88a92bSAdrian Chadd #define	IEEE80211_MESHPERR_BASE_SZ 	(2)
2791f88a92bSAdrian Chadd #define	IEEE80211_MESHPERR_DEST_SZ 	(13)
2801f88a92bSAdrian Chadd #define	IEEE80211_MESHPERR_DEST_SZ_AE 	(19)
28159aa14a9SRui Paulo struct ieee80211_meshperr_ie {
28259aa14a9SRui Paulo 	uint8_t		perr_ie;	/* IEEE80211_ELEMID_MESHPERR */
28359aa14a9SRui Paulo 	uint8_t		perr_len;
284c77735e2SRui Paulo 	uint8_t		perr_ttl;
28559aa14a9SRui Paulo 	uint8_t		perr_ndests;	/* Number of Destinations */
28659aa14a9SRui Paulo 	struct {
287c77735e2SRui Paulo 		uint8_t		dest_flags;
2881f88a92bSAdrian Chadd #define	IEEE80211_MESHPERR_DFLAGS_USN	0x01	/* XXX: not part of standard */
2891f88a92bSAdrian Chadd #define	IEEE80211_MESHPERR_DFLAGS_RC	0x02	/* XXX: not part of standard */
2901f88a92bSAdrian Chadd #define	IEEE80211_MESHPERR_FLAGS_AE	0x40	/* Address Extension */
29159aa14a9SRui Paulo 		uint8_t		dest_addr[IEEE80211_ADDR_LEN];
29259aa14a9SRui Paulo 		uint32_t	dest_seq;	/* HWMP Sequence Number */
2931f88a92bSAdrian Chadd 		/* NB: May have Destination External Address */
2941f88a92bSAdrian Chadd 		uint8_t		dest_ext_addr[IEEE80211_ADDR_LEN];
295c77735e2SRui Paulo 		uint16_t	dest_rcode;
29659aa14a9SRui Paulo 	} __packed perr_dests[1];		/* NB: variable size */
29759aa14a9SRui Paulo } __packed;
29859aa14a9SRui Paulo 
29959aa14a9SRui Paulo #ifdef notyet
30059aa14a9SRui Paulo /* Mesh Proxy Update */
30159aa14a9SRui Paulo struct ieee80211_meshpu_ie {
30259aa14a9SRui Paulo 	uint8_t		pu_ie;		/* IEEE80211_ELEMID_MESHPU */
30359aa14a9SRui Paulo 	uint8_t		pu_len;
30459aa14a9SRui Paulo 	uint8_t		pu_flags;
30559aa14a9SRui Paulo #define	IEEE80211_MESHPU_FLAGS_MASK		0x1
30659aa14a9SRui Paulo #define	IEEE80211_MESHPU_FLAGS_DEL		0x0
30759aa14a9SRui Paulo #define	IEEE80211_MESHPU_FLAGS_ADD		0x1
30859aa14a9SRui Paulo 	uint8_t		pu_seq;		/* PU Sequence Number */
30959aa14a9SRui Paulo 	uint8_t		pu_addr[IEEE80211_ADDR_LEN];
31059aa14a9SRui Paulo 	uint8_t		pu_naddr;	/* Number of Proxied Addresses */
31159aa14a9SRui Paulo 	/* NB: proxied address follows */
31259aa14a9SRui Paulo } __packed;
31359aa14a9SRui Paulo 
31459aa14a9SRui Paulo /* Mesh Proxy Update Confirmation */
31559aa14a9SRui Paulo struct ieee80211_meshpuc_ie {
31659aa14a9SRui Paulo 	uint8_t		puc_ie;		/* IEEE80211_ELEMID_MESHPUC */
31759aa14a9SRui Paulo 	uint8_t		puc_len;
31859aa14a9SRui Paulo 	uint8_t		puc_flags;
31959aa14a9SRui Paulo 	uint8_t		puc_seq;	/* PU Sequence Number */
32059aa14a9SRui Paulo 	uint8_t		puc_daddr[IEEE80211_ADDR_LEN];
32159aa14a9SRui Paulo } __packed;
32259aa14a9SRui Paulo #endif
32359aa14a9SRui Paulo 
32459aa14a9SRui Paulo /*
32559aa14a9SRui Paulo  * 802.11s Action Frames
326ebeaa1adSMonthadar Al Jaberi  * XXX: these are wrong, and some of them should be
327ebeaa1adSMonthadar Al Jaberi  * under MESH category while PROXY is under MULTIHOP category.
32859aa14a9SRui Paulo  */
32959aa14a9SRui Paulo #define	IEEE80211_ACTION_CAT_INTERWORK		15
33059aa14a9SRui Paulo #define	IEEE80211_ACTION_CAT_RESOURCE		16
33159aa14a9SRui Paulo #define	IEEE80211_ACTION_CAT_PROXY		17
33259aa14a9SRui Paulo 
33359aa14a9SRui Paulo /*
33459aa14a9SRui Paulo  * Mesh Peering Action codes.
33559aa14a9SRui Paulo  */
33659aa14a9SRui Paulo enum {
337ebeaa1adSMonthadar Al Jaberi 	/* 0 reserved */
338ebeaa1adSMonthadar Al Jaberi 	IEEE80211_ACTION_MESHPEERING_OPEN	= 1,
339ebeaa1adSMonthadar Al Jaberi 	IEEE80211_ACTION_MESHPEERING_CONFIRM	= 2,
340ebeaa1adSMonthadar Al Jaberi 	IEEE80211_ACTION_MESHPEERING_CLOSE	= 3,
341ebeaa1adSMonthadar Al Jaberi 	/* 4-255 reserved */
34259aa14a9SRui Paulo };
34359aa14a9SRui Paulo 
34459aa14a9SRui Paulo /*
345bdd2a076SAdrian Chadd  * Mesh Action code.
34659aa14a9SRui Paulo  */
34759aa14a9SRui Paulo enum {
348bdd2a076SAdrian Chadd 	IEEE80211_ACTION_MESH_LMETRIC	= 0,	/* Mesh Link Metric Report */
349bdd2a076SAdrian Chadd 	IEEE80211_ACTION_MESH_HWMP	= 1,	/* HWMP Mesh Path Selection */
350bdd2a076SAdrian Chadd 	IEEE80211_ACTION_MESH_GANN	= 2,	/* Gate Announcement */
351bdd2a076SAdrian Chadd 	IEEE80211_ACTION_MESH_CC	= 3,	/* Congestion Control */
352bdd2a076SAdrian Chadd 	IEEE80211_ACTION_MESH_MCCA_SREQ	= 4,	/* MCCA Setup Request */
353bdd2a076SAdrian Chadd 	IEEE80211_ACTION_MESH_MCCA_SREP	= 5,	/* MCCA Setup Reply */
354bdd2a076SAdrian Chadd 	IEEE80211_ACTION_MESH_MCCA_AREQ	= 6,	/* MCCA Advertisement Req. */
355bdd2a076SAdrian Chadd 	IEEE80211_ACTION_MESH_MCCA_ADVER =7,	/* MCCA Advertisement */
356bdd2a076SAdrian Chadd 	IEEE80211_ACTION_MESH_MCCA_TRDOWN = 8,	/* MCCA Teardown */
357bdd2a076SAdrian Chadd 	IEEE80211_ACTION_MESH_TBTT_REQ	= 9,	/* TBTT Adjustment Request */
358bdd2a076SAdrian Chadd 	IEEE80211_ACTION_MESH_TBTT_RES	= 10,	/* TBTT Adjustment Response */
359bdd2a076SAdrian Chadd 	/* 11-255 reserved */
36059aa14a9SRui Paulo };
36159aa14a9SRui Paulo 
36259aa14a9SRui Paulo /*
36359aa14a9SRui Paulo  * Mesh Portal Annoucement Action codes.
36459aa14a9SRui Paulo  */
36559aa14a9SRui Paulo enum {
36659aa14a9SRui Paulo 	IEEE80211_ACTION_MESHPANN	= 0,
36759aa14a9SRui Paulo 	/* 1-255 reserved */
36859aa14a9SRui Paulo };
36959aa14a9SRui Paulo 
37059aa14a9SRui Paulo /*
37159aa14a9SRui Paulo  * Different mesh control structures based on the AE
37259aa14a9SRui Paulo  * (Address Extension) bits.
37359aa14a9SRui Paulo  */
37459aa14a9SRui Paulo struct ieee80211_meshcntl {
37559aa14a9SRui Paulo 	uint8_t		mc_flags;	/* Address Extension 00 */
37659aa14a9SRui Paulo 	uint8_t		mc_ttl;		/* TTL */
37759aa14a9SRui Paulo 	uint8_t		mc_seq[4];	/* Sequence No. */
37859aa14a9SRui Paulo 	/* NB: more addresses may follow */
37959aa14a9SRui Paulo } __packed;
38059aa14a9SRui Paulo 
38159aa14a9SRui Paulo struct ieee80211_meshcntl_ae01 {
38259aa14a9SRui Paulo 	uint8_t		mc_flags;	/* Address Extension 01 */
38359aa14a9SRui Paulo 	uint8_t		mc_ttl;		/* TTL */
38459aa14a9SRui Paulo 	uint8_t		mc_seq[4];	/* Sequence No. */
38559aa14a9SRui Paulo 	uint8_t		mc_addr4[IEEE80211_ADDR_LEN];
38659aa14a9SRui Paulo } __packed;
38759aa14a9SRui Paulo 
38859aa14a9SRui Paulo struct ieee80211_meshcntl_ae10 {
38959aa14a9SRui Paulo 	uint8_t		mc_flags;	/* Address Extension 10 */
39059aa14a9SRui Paulo 	uint8_t		mc_ttl;		/* TTL */
39159aa14a9SRui Paulo 	uint8_t		mc_seq[4];	/* Sequence No. */
392c104cff2SRui Paulo 	uint8_t		mc_addr4[IEEE80211_ADDR_LEN];
39359aa14a9SRui Paulo 	uint8_t		mc_addr5[IEEE80211_ADDR_LEN];
39459aa14a9SRui Paulo } __packed;
39559aa14a9SRui Paulo 
39659aa14a9SRui Paulo struct ieee80211_meshcntl_ae11 {
39759aa14a9SRui Paulo 	uint8_t		mc_flags;	/* Address Extension 11 */
39859aa14a9SRui Paulo 	uint8_t		mc_ttl;		/* TTL */
39959aa14a9SRui Paulo 	uint8_t		mc_seq[4];	/* Sequence No. */
40059aa14a9SRui Paulo 	uint8_t		mc_addr4[IEEE80211_ADDR_LEN];
40159aa14a9SRui Paulo 	uint8_t		mc_addr5[IEEE80211_ADDR_LEN];
40259aa14a9SRui Paulo 	uint8_t		mc_addr6[IEEE80211_ADDR_LEN];
40359aa14a9SRui Paulo } __packed;
40459aa14a9SRui Paulo 
40559aa14a9SRui Paulo #ifdef _KERNEL
4061f88a92bSAdrian Chadd MALLOC_DECLARE(M_80211_MESH_PREQ);
4071f88a92bSAdrian Chadd MALLOC_DECLARE(M_80211_MESH_PREP);
4081f88a92bSAdrian Chadd MALLOC_DECLARE(M_80211_MESH_PERR);
4091f88a92bSAdrian Chadd 
41059aa14a9SRui Paulo MALLOC_DECLARE(M_80211_MESH_RT);
41159aa14a9SRui Paulo struct ieee80211_mesh_route {
41259aa14a9SRui Paulo 	TAILQ_ENTRY(ieee80211_mesh_route)	rt_next;
413e50821abSSam Leffler 	int			rt_crtime;	/* creation time */
41459aa14a9SRui Paulo 	uint8_t			rt_dest[IEEE80211_ADDR_LEN];
41559aa14a9SRui Paulo 	uint8_t			rt_nexthop[IEEE80211_ADDR_LEN];
41659aa14a9SRui Paulo 	uint32_t		rt_metric;	/* path metric */
41759aa14a9SRui Paulo 	uint16_t		rt_nhops;	/* number of hops */
418c104cff2SRui Paulo 	uint16_t		rt_flags;
419c104cff2SRui Paulo #define	IEEE80211_MESHRT_FLAGS_VALID	0x01	/* patch discovery complete */
420c104cff2SRui Paulo #define	IEEE80211_MESHRT_FLAGS_PROXY	0x02	/* proxy entry */
42159aa14a9SRui Paulo 	uint32_t		rt_lifetime;
42259aa14a9SRui Paulo 	uint32_t		rt_lastmseq;	/* last seq# seen dest */
42359aa14a9SRui Paulo 	void			*rt_priv;	/* private data */
42459aa14a9SRui Paulo };
42559aa14a9SRui Paulo #define	IEEE80211_MESH_ROUTE_PRIV(rt, cast)	((cast *)rt->rt_priv)
42659aa14a9SRui Paulo 
42759aa14a9SRui Paulo #define	IEEE80211_MESH_PROTO_DSZ	12	/* description size */
42859aa14a9SRui Paulo /*
42959aa14a9SRui Paulo  * Mesh Path Selection Protocol.
43059aa14a9SRui Paulo  */
43159aa14a9SRui Paulo enum ieee80211_state;
43259aa14a9SRui Paulo struct ieee80211_mesh_proto_path {
4336b8c1829SRui Paulo 	uint8_t		mpp_active;
43459aa14a9SRui Paulo 	char 		mpp_descr[IEEE80211_MESH_PROTO_DSZ];
4356b8c1829SRui Paulo 	uint8_t		mpp_ie;
43659aa14a9SRui Paulo 	struct ieee80211_node *
43759aa14a9SRui Paulo 	    		(*mpp_discover)(struct ieee80211vap *,
43859aa14a9SRui Paulo 				const uint8_t [IEEE80211_ADDR_LEN],
43959aa14a9SRui Paulo 				struct mbuf *);
44059aa14a9SRui Paulo 	void		(*mpp_peerdown)(struct ieee80211_node *);
44159aa14a9SRui Paulo 	void		(*mpp_vattach)(struct ieee80211vap *);
44259aa14a9SRui Paulo 	void		(*mpp_vdetach)(struct ieee80211vap *);
44359aa14a9SRui Paulo 	int		(*mpp_newstate)(struct ieee80211vap *,
44459aa14a9SRui Paulo 			    enum ieee80211_state, int);
445c104cff2SRui Paulo 	const size_t	mpp_privlen;	/* size required in the routing table
44659aa14a9SRui Paulo 					   for private data */
447e50821abSSam Leffler 	int		mpp_inact;	/* inact. timeout for invalid routes
448e50821abSSam Leffler 					   (ticks) */
44959aa14a9SRui Paulo };
45059aa14a9SRui Paulo 
45159aa14a9SRui Paulo /*
45259aa14a9SRui Paulo  * Mesh Link Metric Report Protocol.
45359aa14a9SRui Paulo  */
45459aa14a9SRui Paulo struct ieee80211_mesh_proto_metric {
4556b8c1829SRui Paulo 	uint8_t		mpm_active;
45659aa14a9SRui Paulo 	char		mpm_descr[IEEE80211_MESH_PROTO_DSZ];
4576b8c1829SRui Paulo 	uint8_t		mpm_ie;
45859aa14a9SRui Paulo 	uint32_t	(*mpm_metric)(struct ieee80211_node *);
45959aa14a9SRui Paulo };
46059aa14a9SRui Paulo 
46159aa14a9SRui Paulo #ifdef notyet
46259aa14a9SRui Paulo /*
46359aa14a9SRui Paulo  * Mesh Authentication Protocol.
46459aa14a9SRui Paulo  */
46559aa14a9SRui Paulo struct ieee80211_mesh_proto_auth {
46659aa14a9SRui Paulo 	uint8_t		mpa_ie[4];
46759aa14a9SRui Paulo };
46859aa14a9SRui Paulo 
46959aa14a9SRui Paulo struct ieee80211_mesh_proto_congestion {
47059aa14a9SRui Paulo };
47159aa14a9SRui Paulo 
47259aa14a9SRui Paulo struct ieee80211_mesh_proto_sync {
47359aa14a9SRui Paulo };
47459aa14a9SRui Paulo #endif
47559aa14a9SRui Paulo 
47659aa14a9SRui Paulo typedef uint32_t ieee80211_mesh_seq;
47759aa14a9SRui Paulo #define	IEEE80211_MESH_SEQ_LEQ(a, b)	((int32_t)((a)-(b)) <= 0)
47859aa14a9SRui Paulo #define	IEEE80211_MESH_SEQ_GEQ(a, b)	((int32_t)((a)-(b)) >= 0)
47959aa14a9SRui Paulo 
48059aa14a9SRui Paulo struct ieee80211_mesh_state {
48159aa14a9SRui Paulo 	int				ms_idlen;
48259aa14a9SRui Paulo 	uint8_t				ms_id[IEEE80211_MESHID_LEN];
48359aa14a9SRui Paulo 	ieee80211_mesh_seq		ms_seq;	/* seq no for meshcntl */
48459aa14a9SRui Paulo 	uint16_t			ms_neighbors;
48559aa14a9SRui Paulo 	uint8_t				ms_ttl;	/* mesh ttl set in packets */
48659aa14a9SRui Paulo #define IEEE80211_MESHFLAGS_AP		0x01	/* accept peers */
48759aa14a9SRui Paulo #define IEEE80211_MESHFLAGS_PORTAL	0x02	/* mesh portal role */
48859aa14a9SRui Paulo #define IEEE80211_MESHFLAGS_FWD		0x04	/* forward packets */
48959aa14a9SRui Paulo 	uint8_t				ms_flags;
49059aa14a9SRui Paulo 	struct mtx			ms_rt_lock;
491c104cff2SRui Paulo 	struct callout			ms_cleantimer;
49259aa14a9SRui Paulo 	TAILQ_HEAD(, ieee80211_mesh_route)  ms_routes;
49359aa14a9SRui Paulo 	struct ieee80211_mesh_proto_metric *ms_pmetric;
49459aa14a9SRui Paulo 	struct ieee80211_mesh_proto_path   *ms_ppath;
49559aa14a9SRui Paulo };
49659aa14a9SRui Paulo void		ieee80211_mesh_attach(struct ieee80211com *);
49759aa14a9SRui Paulo void		ieee80211_mesh_detach(struct ieee80211com *);
49859aa14a9SRui Paulo 
49959aa14a9SRui Paulo struct ieee80211_mesh_route *
50059aa14a9SRui Paulo 		ieee80211_mesh_rt_find(struct ieee80211vap *,
50159aa14a9SRui Paulo 		    const uint8_t [IEEE80211_ADDR_LEN]);
50259aa14a9SRui Paulo struct ieee80211_mesh_route *
50359aa14a9SRui Paulo                 ieee80211_mesh_rt_add(struct ieee80211vap *,
50459aa14a9SRui Paulo 		    const uint8_t [IEEE80211_ADDR_LEN]);
50559aa14a9SRui Paulo void		ieee80211_mesh_rt_del(struct ieee80211vap *,
50659aa14a9SRui Paulo 		    const uint8_t [IEEE80211_ADDR_LEN]);
50759aa14a9SRui Paulo void		ieee80211_mesh_rt_flush(struct ieee80211vap *);
5083ca80f0dSRui Paulo void		ieee80211_mesh_rt_flush_peer(struct ieee80211vap *,
5093ca80f0dSRui Paulo 		    const uint8_t [IEEE80211_ADDR_LEN]);
510c104cff2SRui Paulo void		ieee80211_mesh_proxy_check(struct ieee80211vap *,
511c104cff2SRui Paulo 		    const uint8_t [IEEE80211_ADDR_LEN]);
51259aa14a9SRui Paulo 
51359aa14a9SRui Paulo int		ieee80211_mesh_register_proto_path(const
51459aa14a9SRui Paulo 		    struct ieee80211_mesh_proto_path *);
51559aa14a9SRui Paulo int		ieee80211_mesh_register_proto_metric(const
51659aa14a9SRui Paulo 		    struct ieee80211_mesh_proto_metric *);
51759aa14a9SRui Paulo 
51859aa14a9SRui Paulo uint8_t *	ieee80211_add_meshid(uint8_t *, struct ieee80211vap *);
51959aa14a9SRui Paulo uint8_t *	ieee80211_add_meshconf(uint8_t *, struct ieee80211vap *);
52059aa14a9SRui Paulo uint8_t *	ieee80211_add_meshpeer(uint8_t *, uint8_t, uint16_t, uint16_t,
52159aa14a9SRui Paulo 		    uint16_t);
522bdd2a076SAdrian Chadd uint8_t *	ieee80211_add_meshlmetric(uint8_t *, uint8_t, uint32_t);
52359aa14a9SRui Paulo 
52459aa14a9SRui Paulo void		ieee80211_mesh_node_init(struct ieee80211vap *,
52559aa14a9SRui Paulo 		    struct ieee80211_node *);
52659aa14a9SRui Paulo void		ieee80211_mesh_node_cleanup(struct ieee80211_node *);
52759aa14a9SRui Paulo void		ieee80211_parse_meshid(struct ieee80211_node *,
52859aa14a9SRui Paulo 		    const uint8_t *);
52959aa14a9SRui Paulo struct ieee80211_scanparams;
53059aa14a9SRui Paulo void		ieee80211_mesh_init_neighbor(struct ieee80211_node *,
53159aa14a9SRui Paulo 		   const struct ieee80211_frame *,
53259aa14a9SRui Paulo 		   const struct ieee80211_scanparams *);
533d093681cSRui Paulo void		ieee80211_mesh_update_beacon(struct ieee80211vap *,
534d093681cSRui Paulo 		    struct ieee80211_beacon_offsets *);
53559aa14a9SRui Paulo 
536c104cff2SRui Paulo /*
537c104cff2SRui Paulo  * Return non-zero if proxy operation is enabled.
538c104cff2SRui Paulo  */
539c104cff2SRui Paulo static __inline int
540c104cff2SRui Paulo ieee80211_mesh_isproxyena(struct ieee80211vap *vap)
541c104cff2SRui Paulo {
542c104cff2SRui Paulo 	struct ieee80211_mesh_state *ms = vap->iv_mesh;
543c104cff2SRui Paulo 	return (ms->ms_flags &
544c104cff2SRui Paulo 	    (IEEE80211_MESHFLAGS_AP | IEEE80211_MESHFLAGS_PORTAL)) != 0;
545c104cff2SRui Paulo }
546c104cff2SRui Paulo 
547c104cff2SRui Paulo /*
548c104cff2SRui Paulo  * Process an outbound frame: if a path is known to the
549c104cff2SRui Paulo  * destination then return a reference to the next hop
550c104cff2SRui Paulo  * for immediate transmission.  Otherwise initiate path
551c104cff2SRui Paulo  * discovery and, if possible queue the packet to be
552c104cff2SRui Paulo  * sent when path discovery completes.
553c104cff2SRui Paulo  */
55459aa14a9SRui Paulo static __inline struct ieee80211_node *
55559aa14a9SRui Paulo ieee80211_mesh_discover(struct ieee80211vap *vap,
55659aa14a9SRui Paulo     const uint8_t dest[IEEE80211_ADDR_LEN], struct mbuf *m)
55759aa14a9SRui Paulo {
55859aa14a9SRui Paulo 	struct ieee80211_mesh_state *ms = vap->iv_mesh;
55959aa14a9SRui Paulo 	return ms->ms_ppath->mpp_discover(vap, dest, m);
56059aa14a9SRui Paulo }
56159aa14a9SRui Paulo 
56259aa14a9SRui Paulo #endif /* _KERNEL */
56359aa14a9SRui Paulo #endif /* !_NET80211_IEEE80211_MESH_H_ */
564