xref: /freebsd/sys/net80211/ieee80211_mesh.h (revision 3ca80f0dbc5894b39e40a5198763bc37773e9bc5)
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 */
4359aa14a9SRui Paulo struct ieee80211_meshconf_ie {
4459aa14a9SRui Paulo 	uint8_t		conf_ie;	/* IEEE80211_ELEMID_MESHCONF */
4559aa14a9SRui Paulo 	uint8_t		conf_len;
4659aa14a9SRui Paulo 	uint8_t		conf_ver;
4759aa14a9SRui Paulo 	uint8_t		conf_pselid[4];	/* Active Path Sel. Proto. ID */
4859aa14a9SRui Paulo 	uint8_t		conf_pmetid[4];	/* APS Metric Identifier */
4959aa14a9SRui Paulo 	uint8_t		conf_ccid[4];	/* Congestion Control Mode ID  */
5059aa14a9SRui Paulo 	uint8_t		conf_syncid[4];	/* Sync. Protocol ID */
5159aa14a9SRui Paulo 	uint8_t		conf_authid[4];	/* Auth. Protocol ID */
5259aa14a9SRui Paulo 	uint8_t		conf_form;	/* Formation Information */
5359aa14a9SRui Paulo 	uint8_t		conf_cap;
5459aa14a9SRui Paulo } __packed;
5559aa14a9SRui Paulo 
5659aa14a9SRui Paulo #define	IEEE80211_MESHCONF_VERSION		1
5759aa14a9SRui Paulo /* Null Protocol */
5859aa14a9SRui Paulo #define	IEEE80211_MESHCONF_NULL_OUI		0x00, 0x0f, 0xac
5959aa14a9SRui Paulo #define	IEEE80211_MESHCONF_NULL_VALUE		0xff
6059aa14a9SRui Paulo #define	IEEE80211_MESHCONF_NULL		{ IEEE80211_MESHCONF_NULL_OUI, \
6159aa14a9SRui Paulo 					  IEEE80211_MESHCONF_NULL_VALUE }
6259aa14a9SRui Paulo /* Hybrid Wireless Mesh Protocol */
6359aa14a9SRui Paulo #define	IEEE80211_MESHCONF_HWMP_OUI		0x00, 0x0f, 0xac
6459aa14a9SRui Paulo #define	IEEE80211_MESHCONF_HWMP_VALUE		0x00
6559aa14a9SRui Paulo #define	IEEE80211_MESHCONF_HWMP		{ IEEE80211_MESHCONF_HWMP_OUI, \
6659aa14a9SRui Paulo 					  IEEE80211_MESHCONF_HWMP_VALUE }
6759aa14a9SRui Paulo /* Airtime Link Metric */
6859aa14a9SRui Paulo #define	IEEE80211_MESHCONF_AIRTIME_OUI		0x00, 0x0f, 0xac
6959aa14a9SRui Paulo #define	IEEE80211_MESHCONF_AIRTIME_VALUE	0x00
7059aa14a9SRui Paulo #define	IEEE80211_MESHCONF_AIRTIME	{ IEEE80211_MESHCONF_AIRTIME_OUI, \
7159aa14a9SRui Paulo 					  IEEE80211_MESHCONF_AIRTIME_VALUE }
7259aa14a9SRui Paulo /* Congestion Control Signaling */
7359aa14a9SRui Paulo #define	IEEE80211_MESHCONF_CCSIG_OUI		0x00, 0x0f, 0xac
7459aa14a9SRui Paulo #define	IEEE80211_MESHCONF_CCSIG_VALUE		0x00
7559aa14a9SRui Paulo #define	IEEE80211_MESHCONF_CCSIG	{ IEEE80211_MESHCONF_CCSIG_OUI,\
7659aa14a9SRui Paulo 					  IEEE80211_MESHCONF_CCSIG_VALUE }
7759aa14a9SRui Paulo /* Neighbour Offset */
7859aa14a9SRui Paulo #define	IEEE80211_MESHCONF_NEIGHOFF_OUI		0x00, 0x0f, 0xac
7959aa14a9SRui Paulo #define	IEEE80211_MESHCONF_NEIGHOFF_VALUE	0x00
8059aa14a9SRui Paulo #define	IEEE80211_MESHCONF_NEIGHOFF	{ IEEE80211_MESHCONF_NEIGHOFF_OUI, \
8159aa14a9SRui Paulo 					  IEEE80211_MESHCONF_NEIGHOFF_VALUE }
8259aa14a9SRui Paulo /* Simultaneous Authenticaction of Equals */
8359aa14a9SRui Paulo #define	IEEE80211_MESHCONF_SAE_OUI		0x00, 0x0f, 0xac
8459aa14a9SRui Paulo #define	IEEE80211_MESHCONF_SAE_VALUE		0x01
8559aa14a9SRui Paulo #define	IEEE80211_MESHCONF_SAE		{ IEEE80211_MESHCONF_SAE_OUI, \
8659aa14a9SRui Paulo 					  IEEE80211_MESHCONF_SAE_VALUE }
8759aa14a9SRui Paulo #define	IEEE80211_MESHCONF_FORM_MP		0x01 /* Connected to Portal */
8859aa14a9SRui Paulo #define	IEEE80211_MESHCONF_FORM_NNEIGH_MASK	0x04 /* Number of Neighbours */
8959aa14a9SRui Paulo #define	IEEE80211_MESHCONF_CAP_AP	0x01	/* Accepting Peers */
9059aa14a9SRui Paulo #define	IEEE80211_MESHCONF_CAP_MCCAS	0x02	/* MCCA supported */
9159aa14a9SRui Paulo #define	IEEE80211_MESHCONF_CAP_MCCAE	0x04	/* MCCA enabled */
9259aa14a9SRui Paulo #define	IEEE80211_MESHCONF_CAP_FWRD 	0x08	/* forwarding enabled */
9359aa14a9SRui Paulo #define	IEEE80211_MESHCONF_CAP_BTR	0x10	/* Beacon Timing Report Enab */
9459aa14a9SRui Paulo #define	IEEE80211_MESHCONF_CAP_TBTTA	0x20	/* TBTT Adj. Enabled */
9559aa14a9SRui Paulo #define	IEEE80211_MESHCONF_CAP_PSL	0x40	/* Power Save Level */
9659aa14a9SRui Paulo 
9759aa14a9SRui Paulo /* Mesh Identifier */
9859aa14a9SRui Paulo struct ieee80211_meshid_ie {
9959aa14a9SRui Paulo 	uint8_t		id_ie;		/* IEEE80211_ELEMID_MESHID */
10059aa14a9SRui Paulo 	uint8_t		id_len;
10159aa14a9SRui Paulo } __packed;
10259aa14a9SRui Paulo 
10359aa14a9SRui Paulo /* Link Metric Report */
10459aa14a9SRui Paulo struct ieee80211_meshlmetric_ie {
10559aa14a9SRui Paulo 	uint8_t		lm_ie;	/* IEEE80211_ELEMID_MESHLINK */
10659aa14a9SRui Paulo 	uint8_t		lm_len;
10759aa14a9SRui Paulo 	uint32_t	lm_metric;
10859aa14a9SRui Paulo #define	IEEE80211_MESHLMETRIC_INITIALVAL	0
10959aa14a9SRui Paulo } __packed;
11059aa14a9SRui Paulo 
11159aa14a9SRui Paulo /* Congestion Notification */
11259aa14a9SRui Paulo struct ieee80211_meshcngst_ie {
11359aa14a9SRui Paulo 	uint8_t		cngst_ie;	/* IEEE80211_ELEMID_MESHCNGST */
11459aa14a9SRui Paulo 	uint8_t		cngst_len;
11559aa14a9SRui Paulo 	uint16_t	cngst_timer[4];	/* Expiration Timers: AC_BK,
11659aa14a9SRui Paulo 					   AC_BE, AC_VI, AC_VO */
11759aa14a9SRui Paulo } __packed;
11859aa14a9SRui Paulo 
11959aa14a9SRui Paulo /* Peer Version */
12059aa14a9SRui Paulo struct ieee80211_meshpeerver_ie {
12159aa14a9SRui Paulo 	uint8_t		peerver_ie;	/* IEEE80211_ELEMID_MESHPEERVER */
12259aa14a9SRui Paulo 	uint8_t		peerver_len;
12359aa14a9SRui Paulo 	uint8_t		peerver_proto[4];
12459aa14a9SRui Paulo } __packed;
12559aa14a9SRui Paulo /* Mesh Peering Management Protocol */
12659aa14a9SRui Paulo #define	IEEE80211_MESHPEERVER_PEER_OUI		0x00, 0x0f, 0xac
12759aa14a9SRui Paulo #define	IEEE80211_MESHPEERVER_PEER_VALUE	0x2a
12859aa14a9SRui Paulo #define	IEEE80211_MESHPEERVER_PEER	{ IEEE80211_MESHPEERVER_PEER_OUI, \
12959aa14a9SRui Paulo 					  IEEE80211_MESHPEERVER_PEER_VALUE }
13059aa14a9SRui Paulo /* Abbreviated Handshake Protocol */
13159aa14a9SRui Paulo #define	IEEE80211_MESHPEERVER_AH_OUI		0x00, 0x0f, 0xac
13259aa14a9SRui Paulo #define	IEEE80211_MESHPEERVER_AH_VALUE		0x2b
13359aa14a9SRui Paulo #define	IEEE80211_MESHPEERVER_AH	{ IEEE80211_MESHPEERVER_AH_OUI, \
13459aa14a9SRui Paulo 					  IEEE80211_MESHPEERVER_AH_VALUE }
13559aa14a9SRui Paulo 
13659aa14a9SRui Paulo /* Peer Link Management */
13759aa14a9SRui Paulo struct ieee80211_meshpeer_ie {
13859aa14a9SRui Paulo 	uint8_t		peer_ie;	/* IEEE80211_ELEMID_MESHPEER */
13959aa14a9SRui Paulo 	uint8_t		peer_len;
14059aa14a9SRui Paulo 	uint8_t		peer_subtype;
14159aa14a9SRui Paulo 	uint16_t	peer_llinkid;	/* Local Link ID */
14259aa14a9SRui Paulo 	uint16_t	peer_linkid;	/* Peer Link ID */
14359aa14a9SRui Paulo 	uint16_t	peer_rcode;
14459aa14a9SRui Paulo } __packed;
14559aa14a9SRui Paulo 
14659aa14a9SRui Paulo enum {
14759aa14a9SRui Paulo 	IEEE80211_MESH_PEER_LINK_OPEN		= 0,
14859aa14a9SRui Paulo 	IEEE80211_MESH_PEER_LINK_CONFIRM	= 1,
14959aa14a9SRui Paulo 	IEEE80211_MESH_PEER_LINK_CLOSE		= 2,
15059aa14a9SRui Paulo 	/* values 3-255 are reserved */
15159aa14a9SRui Paulo };
15259aa14a9SRui Paulo 
15359aa14a9SRui Paulo #ifdef notyet
15459aa14a9SRui Paulo /* Mesh Channel Switch Annoucement */
15559aa14a9SRui Paulo struct ieee80211_meshcsa_ie {
15659aa14a9SRui Paulo 	uint8_t		csa_ie;		/* IEEE80211_ELEMID_MESHCSA */
15759aa14a9SRui Paulo 	uint8_t		csa_len;
15859aa14a9SRui Paulo 	uint8_t		csa_mode;
15959aa14a9SRui Paulo 	uint8_t		csa_newclass;	/* New Regulatory Class */
16059aa14a9SRui Paulo 	uint8_t		csa_newchan;
16159aa14a9SRui Paulo 	uint8_t		csa_precvalue;	/* Precedence Value */
16259aa14a9SRui Paulo 	uint8_t		csa_count;
16359aa14a9SRui Paulo } __packed;
16459aa14a9SRui Paulo 
16559aa14a9SRui Paulo /* Mesh TIM */
16659aa14a9SRui Paulo /* Equal to the non Mesh version */
16759aa14a9SRui Paulo 
16859aa14a9SRui Paulo /* Mesh Awake Window */
16959aa14a9SRui Paulo struct ieee80211_meshawakew_ie {
17059aa14a9SRui Paulo 	uint8_t		awakew_ie;		/* IEEE80211_ELEMID_MESHAWAKEW */
17159aa14a9SRui Paulo 	uint8_t		awakew_len;
17259aa14a9SRui Paulo 	uint8_t		awakew_windowlen;	/* in TUs */
17359aa14a9SRui Paulo } __packed;
17459aa14a9SRui Paulo 
17559aa14a9SRui Paulo /* Mesh Beacon Timing */
17659aa14a9SRui Paulo struct ieee80211_meshbeacont_ie {
17759aa14a9SRui Paulo 	uint8_t		beacont_ie;		/* IEEE80211_ELEMID_MESHBEACONT */
17859aa14a9SRui Paulo 	uint8_t		beacont_len;
17959aa14a9SRui Paulo 	struct {
18059aa14a9SRui Paulo 		uint8_t		mp_aid;		/* Least Octet of AID */
18159aa14a9SRui Paulo 		uint16_t	mp_btime;	/* Beacon Time */
18259aa14a9SRui Paulo 		uint16_t	mp_bint;	/* Beacon Interval */
18359aa14a9SRui Paulo 	} __packed mp[1];			/* NB: variable size */
18459aa14a9SRui Paulo } __packed;
18559aa14a9SRui Paulo #endif
18659aa14a9SRui Paulo 
18759aa14a9SRui Paulo /* Portal (MP) Annoucement */
18859aa14a9SRui Paulo struct ieee80211_meshpann_ie {
18959aa14a9SRui Paulo 	uint8_t		pann_ie;		/* IEEE80211_ELEMID_MESHPANN */
19059aa14a9SRui Paulo 	uint8_t		pann_len;
19159aa14a9SRui Paulo 	uint8_t		pann_flags;
19259aa14a9SRui Paulo 	uint8_t		pann_hopcount;
19359aa14a9SRui Paulo 	uint8_t		pann_ttl;
19459aa14a9SRui Paulo 	uint8_t		pann_addr[IEEE80211_ADDR_LEN];
19559aa14a9SRui Paulo 	uint8_t		pann_seq;		/* PANN Sequence Number */
19659aa14a9SRui Paulo } __packed;
19759aa14a9SRui Paulo 
19859aa14a9SRui Paulo /* Root (MP) Annoucement */
19959aa14a9SRui Paulo struct ieee80211_meshrann_ie {
20059aa14a9SRui Paulo 	uint8_t		rann_ie;		/* IEEE80211_ELEMID_MESHRANN */
20159aa14a9SRui Paulo 	uint8_t		rann_len;
20259aa14a9SRui Paulo 	uint8_t		rann_flags;
20359aa14a9SRui Paulo #define	IEEE80211_MESHRANN_FLAGS_PR	0x01	/* Portal Role */
20459aa14a9SRui Paulo 	uint8_t		rann_hopcount;
20559aa14a9SRui Paulo 	uint8_t		rann_ttl;
20659aa14a9SRui Paulo 	uint8_t		rann_addr[IEEE80211_ADDR_LEN];
20759aa14a9SRui Paulo 	uint32_t	rann_seq;		/* HWMP Sequence Number */
20859aa14a9SRui Paulo 	uint32_t	rann_metric;
20959aa14a9SRui Paulo } __packed;
21059aa14a9SRui Paulo 
21159aa14a9SRui Paulo /* Mesh Path Request */
21259aa14a9SRui Paulo struct ieee80211_meshpreq_ie {
21359aa14a9SRui Paulo 	uint8_t		preq_ie;	/* IEEE80211_ELEMID_MESHPREQ */
21459aa14a9SRui Paulo 	uint8_t		preq_len;
21559aa14a9SRui Paulo 	uint8_t		preq_flags;
21659aa14a9SRui Paulo #define	IEEE80211_MESHPREQ_FLAGS_PR	0x01	/* Portal Role */
21759aa14a9SRui Paulo #define	IEEE80211_MESHPREQ_FLAGS_AM	0x02	/* 0 = ucast / 1 = bcast */
21859aa14a9SRui Paulo #define	IEEE80211_MESHPREQ_FLAGS_PP	0x04	/* Proactive PREP */
21959aa14a9SRui Paulo #define	IEEE80211_MESHPREQ_FLAGS_AE	0x40	/* Address Extension */
22059aa14a9SRui Paulo 	uint8_t		preq_hopcount;
22159aa14a9SRui Paulo 	uint8_t		preq_ttl;
22259aa14a9SRui Paulo 	uint32_t	preq_id;
22359aa14a9SRui Paulo 	uint8_t		preq_origaddr[IEEE80211_ADDR_LEN];
22459aa14a9SRui Paulo 	uint32_t	preq_origseq;	/* HWMP Sequence Number */
22559aa14a9SRui Paulo 	/* NB: may have Originator Proxied Address */
22659aa14a9SRui Paulo 	uint32_t	preq_lifetime;
22759aa14a9SRui Paulo 	uint32_t	preq_metric;
22859aa14a9SRui Paulo 	uint8_t		preq_tcount;	/* target count */
22959aa14a9SRui Paulo 	struct {
23059aa14a9SRui Paulo 		uint8_t		target_flags;
23159aa14a9SRui Paulo #define	IEEE80211_MESHPREQ_TFLAGS_TO	0x01	/* Target Only */
23259aa14a9SRui Paulo #define	IEEE80211_MESHPREQ_TFLAGS_RF	0x02	/* Reply and Forward */
23359aa14a9SRui Paulo #define	IEEE80211_MESHPREQ_TFLAGS_USN	0x04	/* Unknown HWMP seq number */
23459aa14a9SRui Paulo 		uint8_t		target_addr[IEEE80211_ADDR_LEN];
23559aa14a9SRui Paulo 		uint32_t	target_seq;	/* HWMP Sequence Number */
23659aa14a9SRui Paulo 	} __packed preq_targets[1];		/* NB: variable size */
23759aa14a9SRui Paulo } __packed;
23859aa14a9SRui Paulo 
23959aa14a9SRui Paulo /* Mesh Path Reply */
24059aa14a9SRui Paulo struct ieee80211_meshprep_ie {
24159aa14a9SRui Paulo 	uint8_t		prep_ie;	/* IEEE80211_ELEMID_MESHPREP */
24259aa14a9SRui Paulo 	uint8_t		prep_len;
24359aa14a9SRui Paulo 	uint8_t		prep_flags;
24459aa14a9SRui Paulo 	uint8_t		prep_hopcount;
24559aa14a9SRui Paulo 	uint8_t		prep_ttl;
24659aa14a9SRui Paulo 	uint8_t		prep_targetaddr[IEEE80211_ADDR_LEN];
24759aa14a9SRui Paulo 	uint32_t	prep_targetseq;
24859aa14a9SRui Paulo 	/* NB: May have Target Proxied Address */
24959aa14a9SRui Paulo 	uint32_t	prep_lifetime;
25059aa14a9SRui Paulo 	uint32_t	prep_metric;
25159aa14a9SRui Paulo 	uint8_t		prep_origaddr[IEEE80211_ADDR_LEN];
25259aa14a9SRui Paulo 	uint32_t	prep_origseq;	/* HWMP Sequence Number */
25359aa14a9SRui Paulo } __packed;
25459aa14a9SRui Paulo 
25559aa14a9SRui Paulo /* Mesh Path Error */
25659aa14a9SRui Paulo struct ieee80211_meshperr_ie {
25759aa14a9SRui Paulo 	uint8_t		perr_ie;	/* IEEE80211_ELEMID_MESHPERR */
25859aa14a9SRui Paulo 	uint8_t		perr_len;
25959aa14a9SRui Paulo 	uint8_t		perr_mode;	/* NB: reserved */
26059aa14a9SRui Paulo 	uint8_t		perr_ndests;	/* Number of Destinations */
26159aa14a9SRui Paulo 	struct {
26259aa14a9SRui Paulo 		uint8_t		dest_addr[IEEE80211_ADDR_LEN];
26359aa14a9SRui Paulo 		uint32_t	dest_seq;	/* HWMP Sequence Number */
26459aa14a9SRui Paulo 	} __packed perr_dests[1];		/* NB: variable size */
26559aa14a9SRui Paulo } __packed;
26659aa14a9SRui Paulo 
26759aa14a9SRui Paulo #ifdef notyet
26859aa14a9SRui Paulo /* Mesh Proxy Update */
26959aa14a9SRui Paulo struct ieee80211_meshpu_ie {
27059aa14a9SRui Paulo 	uint8_t		pu_ie;		/* IEEE80211_ELEMID_MESHPU */
27159aa14a9SRui Paulo 	uint8_t		pu_len;
27259aa14a9SRui Paulo 	uint8_t		pu_flags;
27359aa14a9SRui Paulo #define	IEEE80211_MESHPU_FLAGS_MASK		0x1
27459aa14a9SRui Paulo #define	IEEE80211_MESHPU_FLAGS_DEL		0x0
27559aa14a9SRui Paulo #define	IEEE80211_MESHPU_FLAGS_ADD		0x1
27659aa14a9SRui Paulo 	uint8_t		pu_seq;		/* PU Sequence Number */
27759aa14a9SRui Paulo 	uint8_t		pu_addr[IEEE80211_ADDR_LEN];
27859aa14a9SRui Paulo 	uint8_t		pu_naddr;	/* Number of Proxied Addresses */
27959aa14a9SRui Paulo 	/* NB: proxied address follows */
28059aa14a9SRui Paulo } __packed;
28159aa14a9SRui Paulo 
28259aa14a9SRui Paulo /* Mesh Proxy Update Confirmation */
28359aa14a9SRui Paulo struct ieee80211_meshpuc_ie {
28459aa14a9SRui Paulo 	uint8_t		puc_ie;		/* IEEE80211_ELEMID_MESHPUC */
28559aa14a9SRui Paulo 	uint8_t		puc_len;
28659aa14a9SRui Paulo 	uint8_t		puc_flags;
28759aa14a9SRui Paulo 	uint8_t		puc_seq;	/* PU Sequence Number */
28859aa14a9SRui Paulo 	uint8_t		puc_daddr[IEEE80211_ADDR_LEN];
28959aa14a9SRui Paulo } __packed;
29059aa14a9SRui Paulo #endif
29159aa14a9SRui Paulo 
29259aa14a9SRui Paulo /*
29359aa14a9SRui Paulo  * 802.11s Action Frames
29459aa14a9SRui Paulo  */
29559aa14a9SRui Paulo #define	IEEE80211_ACTION_CAT_MESHPEERING	30	/* XXX Linux */
29659aa14a9SRui Paulo #define	IEEE80211_ACTION_CAT_MESHLMETRIC	13
29759aa14a9SRui Paulo #define	IEEE80211_ACTION_CAT_MESHPATH		32	/* XXX Linux */
29859aa14a9SRui Paulo #define	IEEE80211_ACTION_CAT_INTERWORK		15
29959aa14a9SRui Paulo #define	IEEE80211_ACTION_CAT_RESOURCE		16
30059aa14a9SRui Paulo #define	IEEE80211_ACTION_CAT_PROXY		17
30159aa14a9SRui Paulo 
30259aa14a9SRui Paulo /*
30359aa14a9SRui Paulo  * Mesh Peering Action codes.
30459aa14a9SRui Paulo  */
30559aa14a9SRui Paulo enum {
30659aa14a9SRui Paulo 	IEEE80211_ACTION_MESHPEERING_OPEN	= 0,
30759aa14a9SRui Paulo 	IEEE80211_ACTION_MESHPEERING_CONFIRM	= 1,
30859aa14a9SRui Paulo 	IEEE80211_ACTION_MESHPEERING_CLOSE	= 2,
30959aa14a9SRui Paulo 	/* 3-255 reserved */
31059aa14a9SRui Paulo };
31159aa14a9SRui Paulo 
31259aa14a9SRui Paulo /*
31359aa14a9SRui Paulo  * Mesh Path Selection Action codes.
31459aa14a9SRui Paulo  */
31559aa14a9SRui Paulo enum {
31659aa14a9SRui Paulo 	IEEE80211_ACTION_MESHPATH_REQ	= 0,
31759aa14a9SRui Paulo 	IEEE80211_ACTION_MESHPATH_REP	= 1,
31859aa14a9SRui Paulo 	IEEE80211_ACTION_MESHPATH_ERR	= 2,
31959aa14a9SRui Paulo 	IEEE80211_ACTION_MESHPATH_RANN	= 3,
32059aa14a9SRui Paulo 	/* 4-255 reserved */
32159aa14a9SRui Paulo };
32259aa14a9SRui Paulo 
32359aa14a9SRui Paulo /*
32459aa14a9SRui Paulo  * Mesh Link Metric Action codes.
32559aa14a9SRui Paulo  */
32659aa14a9SRui Paulo enum {
32759aa14a9SRui Paulo 	IEEE80211_ACTION_MESHLMETRIC_REQ = 0,	/* Link Metric Request */
32859aa14a9SRui Paulo 	IEEE80211_ACTION_MESHLMETRIC_REP = 1,	/* Link Metric Report */
32959aa14a9SRui Paulo 	/* 2-255 reserved */
33059aa14a9SRui Paulo };
33159aa14a9SRui Paulo 
33259aa14a9SRui Paulo /*
33359aa14a9SRui Paulo  * Mesh Portal Annoucement Action codes.
33459aa14a9SRui Paulo  */
33559aa14a9SRui Paulo enum {
33659aa14a9SRui Paulo 	IEEE80211_ACTION_MESHPANN	= 0,
33759aa14a9SRui Paulo 	/* 1-255 reserved */
33859aa14a9SRui Paulo };
33959aa14a9SRui Paulo 
34059aa14a9SRui Paulo /*
34159aa14a9SRui Paulo  * Different mesh control structures based on the AE
34259aa14a9SRui Paulo  * (Address Extension) bits.
34359aa14a9SRui Paulo  */
34459aa14a9SRui Paulo struct ieee80211_meshcntl {
34559aa14a9SRui Paulo 	uint8_t		mc_flags;	/* Address Extension 00 */
34659aa14a9SRui Paulo 	uint8_t		mc_ttl;		/* TTL */
34759aa14a9SRui Paulo 	uint8_t		mc_seq[4];	/* Sequence No. */
34859aa14a9SRui Paulo 	/* NB: more addresses may follow */
34959aa14a9SRui Paulo } __packed;
35059aa14a9SRui Paulo 
35159aa14a9SRui Paulo struct ieee80211_meshcntl_ae01 {
35259aa14a9SRui Paulo 	uint8_t		mc_flags;	/* Address Extension 01 */
35359aa14a9SRui Paulo 	uint8_t		mc_ttl;		/* TTL */
35459aa14a9SRui Paulo 	uint8_t		mc_seq[4];	/* Sequence No. */
35559aa14a9SRui Paulo 	uint8_t		mc_addr4[IEEE80211_ADDR_LEN];
35659aa14a9SRui Paulo } __packed;
35759aa14a9SRui Paulo 
35859aa14a9SRui Paulo struct ieee80211_meshcntl_ae10 {
35959aa14a9SRui Paulo 	uint8_t		mc_flags;	/* Address Extension 10 */
36059aa14a9SRui Paulo 	uint8_t		mc_ttl;		/* TTL */
36159aa14a9SRui Paulo 	uint8_t		mc_seq[4];	/* Sequence No. */
362c104cff2SRui Paulo 	uint8_t		mc_addr4[IEEE80211_ADDR_LEN];
36359aa14a9SRui Paulo 	uint8_t		mc_addr5[IEEE80211_ADDR_LEN];
36459aa14a9SRui Paulo } __packed;
36559aa14a9SRui Paulo 
36659aa14a9SRui Paulo struct ieee80211_meshcntl_ae11 {
36759aa14a9SRui Paulo 	uint8_t		mc_flags;	/* Address Extension 11 */
36859aa14a9SRui Paulo 	uint8_t		mc_ttl;		/* TTL */
36959aa14a9SRui Paulo 	uint8_t		mc_seq[4];	/* Sequence No. */
37059aa14a9SRui Paulo 	uint8_t		mc_addr4[IEEE80211_ADDR_LEN];
37159aa14a9SRui Paulo 	uint8_t		mc_addr5[IEEE80211_ADDR_LEN];
37259aa14a9SRui Paulo 	uint8_t		mc_addr6[IEEE80211_ADDR_LEN];
37359aa14a9SRui Paulo } __packed;
37459aa14a9SRui Paulo 
37559aa14a9SRui Paulo #ifdef _KERNEL
37659aa14a9SRui Paulo MALLOC_DECLARE(M_80211_MESH_RT);
37759aa14a9SRui Paulo struct ieee80211_mesh_route {
37859aa14a9SRui Paulo 	TAILQ_ENTRY(ieee80211_mesh_route)	rt_next;
379e50821abSSam Leffler 	int			rt_crtime;	/* creation time */
38059aa14a9SRui Paulo 	uint8_t			rt_dest[IEEE80211_ADDR_LEN];
38159aa14a9SRui Paulo 	uint8_t			rt_nexthop[IEEE80211_ADDR_LEN];
38259aa14a9SRui Paulo 	uint32_t		rt_metric;	/* path metric */
38359aa14a9SRui Paulo 	uint16_t		rt_nhops;	/* number of hops */
384c104cff2SRui Paulo 	uint16_t		rt_flags;
385c104cff2SRui Paulo #define	IEEE80211_MESHRT_FLAGS_VALID	0x01	/* patch discovery complete */
386c104cff2SRui Paulo #define	IEEE80211_MESHRT_FLAGS_PROXY	0x02	/* proxy entry */
38759aa14a9SRui Paulo 	uint32_t		rt_lifetime;
38859aa14a9SRui Paulo 	uint32_t		rt_lastmseq;	/* last seq# seen dest */
38959aa14a9SRui Paulo 	void			*rt_priv;	/* private data */
39059aa14a9SRui Paulo };
39159aa14a9SRui Paulo #define	IEEE80211_MESH_ROUTE_PRIV(rt, cast)	((cast *)rt->rt_priv)
39259aa14a9SRui Paulo 
39359aa14a9SRui Paulo #define	IEEE80211_MESH_PROTO_DSZ	12	/* description size */
39459aa14a9SRui Paulo /*
39559aa14a9SRui Paulo  * Mesh Path Selection Protocol.
39659aa14a9SRui Paulo  */
39759aa14a9SRui Paulo enum ieee80211_state;
39859aa14a9SRui Paulo struct ieee80211_mesh_proto_path {
39959aa14a9SRui Paulo 	char 		mpp_descr[IEEE80211_MESH_PROTO_DSZ];
40059aa14a9SRui Paulo 	uint8_t		mpp_ie[4];
40159aa14a9SRui Paulo 	struct ieee80211_node *
40259aa14a9SRui Paulo 	    		(*mpp_discover)(struct ieee80211vap *,
40359aa14a9SRui Paulo 				const uint8_t [IEEE80211_ADDR_LEN],
40459aa14a9SRui Paulo 				struct mbuf *);
40559aa14a9SRui Paulo 	void		(*mpp_peerdown)(struct ieee80211_node *);
40659aa14a9SRui Paulo 	void		(*mpp_vattach)(struct ieee80211vap *);
40759aa14a9SRui Paulo 	void		(*mpp_vdetach)(struct ieee80211vap *);
40859aa14a9SRui Paulo 	int		(*mpp_newstate)(struct ieee80211vap *,
40959aa14a9SRui Paulo 			    enum ieee80211_state, int);
410c104cff2SRui Paulo 	const size_t	mpp_privlen;	/* size required in the routing table
41159aa14a9SRui Paulo 					   for private data */
412e50821abSSam Leffler 	int		mpp_inact;	/* inact. timeout for invalid routes
413e50821abSSam Leffler 					   (ticks) */
41459aa14a9SRui Paulo };
41559aa14a9SRui Paulo 
41659aa14a9SRui Paulo /*
41759aa14a9SRui Paulo  * Mesh Link Metric Report Protocol.
41859aa14a9SRui Paulo  */
41959aa14a9SRui Paulo struct ieee80211_mesh_proto_metric {
42059aa14a9SRui Paulo 	char		mpm_descr[IEEE80211_MESH_PROTO_DSZ];
42159aa14a9SRui Paulo 	uint8_t		mpm_ie[4];
42259aa14a9SRui Paulo 	uint32_t	(*mpm_metric)(struct ieee80211_node *);
42359aa14a9SRui Paulo };
42459aa14a9SRui Paulo 
42559aa14a9SRui Paulo #ifdef notyet
42659aa14a9SRui Paulo /*
42759aa14a9SRui Paulo  * Mesh Authentication Protocol.
42859aa14a9SRui Paulo  */
42959aa14a9SRui Paulo struct ieee80211_mesh_proto_auth {
43059aa14a9SRui Paulo 	uint8_t		mpa_ie[4];
43159aa14a9SRui Paulo };
43259aa14a9SRui Paulo 
43359aa14a9SRui Paulo struct ieee80211_mesh_proto_congestion {
43459aa14a9SRui Paulo };
43559aa14a9SRui Paulo 
43659aa14a9SRui Paulo struct ieee80211_mesh_proto_sync {
43759aa14a9SRui Paulo };
43859aa14a9SRui Paulo #endif
43959aa14a9SRui Paulo 
44059aa14a9SRui Paulo typedef uint32_t ieee80211_mesh_seq;
44159aa14a9SRui Paulo #define	IEEE80211_MESH_SEQ_LEQ(a, b)	((int32_t)((a)-(b)) <= 0)
44259aa14a9SRui Paulo #define	IEEE80211_MESH_SEQ_GEQ(a, b)	((int32_t)((a)-(b)) >= 0)
44359aa14a9SRui Paulo 
44459aa14a9SRui Paulo struct ieee80211_mesh_state {
44559aa14a9SRui Paulo 	int				ms_idlen;
44659aa14a9SRui Paulo 	uint8_t				ms_id[IEEE80211_MESHID_LEN];
44759aa14a9SRui Paulo 	ieee80211_mesh_seq		ms_seq;	/* seq no for meshcntl */
44859aa14a9SRui Paulo 	uint16_t			ms_neighbors;
44959aa14a9SRui Paulo 	uint8_t				ms_ttl;	/* mesh ttl set in packets */
45059aa14a9SRui Paulo #define IEEE80211_MESHFLAGS_AP		0x01	/* accept peers */
45159aa14a9SRui Paulo #define IEEE80211_MESHFLAGS_PORTAL	0x02	/* mesh portal role */
45259aa14a9SRui Paulo #define IEEE80211_MESHFLAGS_FWD		0x04	/* forward packets */
45359aa14a9SRui Paulo 	uint8_t				ms_flags;
45459aa14a9SRui Paulo 	struct mtx			ms_rt_lock;
455c104cff2SRui Paulo 	struct callout			ms_cleantimer;
45659aa14a9SRui Paulo 	TAILQ_HEAD(, ieee80211_mesh_route)  ms_routes;
45759aa14a9SRui Paulo 	struct ieee80211_mesh_proto_metric *ms_pmetric;
45859aa14a9SRui Paulo 	struct ieee80211_mesh_proto_path   *ms_ppath;
45959aa14a9SRui Paulo };
46059aa14a9SRui Paulo void		ieee80211_mesh_attach(struct ieee80211com *);
46159aa14a9SRui Paulo void		ieee80211_mesh_detach(struct ieee80211com *);
46259aa14a9SRui Paulo 
46359aa14a9SRui Paulo struct ieee80211_mesh_route *
46459aa14a9SRui Paulo 		ieee80211_mesh_rt_find(struct ieee80211vap *,
46559aa14a9SRui Paulo 		    const uint8_t [IEEE80211_ADDR_LEN]);
46659aa14a9SRui Paulo struct ieee80211_mesh_route *
46759aa14a9SRui Paulo                 ieee80211_mesh_rt_add(struct ieee80211vap *,
46859aa14a9SRui Paulo 		    const uint8_t [IEEE80211_ADDR_LEN]);
46959aa14a9SRui Paulo void		ieee80211_mesh_rt_del(struct ieee80211vap *,
47059aa14a9SRui Paulo 		    const uint8_t [IEEE80211_ADDR_LEN]);
47159aa14a9SRui Paulo void		ieee80211_mesh_rt_flush(struct ieee80211vap *);
4723ca80f0dSRui Paulo void		ieee80211_mesh_rt_flush_peer(struct ieee80211vap *,
4733ca80f0dSRui Paulo 		    const uint8_t [IEEE80211_ADDR_LEN]);
474c104cff2SRui Paulo void		ieee80211_mesh_proxy_check(struct ieee80211vap *,
475c104cff2SRui Paulo 		    const uint8_t [IEEE80211_ADDR_LEN]);
47659aa14a9SRui Paulo 
47759aa14a9SRui Paulo int		ieee80211_mesh_register_proto_path(const
47859aa14a9SRui Paulo 		    struct ieee80211_mesh_proto_path *);
47959aa14a9SRui Paulo int		ieee80211_mesh_register_proto_metric(const
48059aa14a9SRui Paulo 		    struct ieee80211_mesh_proto_metric *);
48159aa14a9SRui Paulo 
48259aa14a9SRui Paulo uint8_t *	ieee80211_add_meshpeerver(uint8_t *, struct ieee80211vap *);
48359aa14a9SRui Paulo uint8_t *	ieee80211_add_meshid(uint8_t *, struct ieee80211vap *);
48459aa14a9SRui Paulo uint8_t *	ieee80211_add_meshconf(uint8_t *, struct ieee80211vap *);
48559aa14a9SRui Paulo uint8_t *	ieee80211_add_meshpeer(uint8_t *, uint8_t, uint16_t, uint16_t,
48659aa14a9SRui Paulo 		    uint16_t);
48759aa14a9SRui Paulo uint8_t *	ieee80211_add_meshlmetric(uint8_t *, uint32_t);
48859aa14a9SRui Paulo 
48959aa14a9SRui Paulo void		ieee80211_mesh_node_init(struct ieee80211vap *,
49059aa14a9SRui Paulo 		    struct ieee80211_node *);
49159aa14a9SRui Paulo void		ieee80211_mesh_node_cleanup(struct ieee80211_node *);
49259aa14a9SRui Paulo void		ieee80211_parse_meshid(struct ieee80211_node *,
49359aa14a9SRui Paulo 		    const uint8_t *);
49459aa14a9SRui Paulo struct ieee80211_scanparams;
49559aa14a9SRui Paulo void		ieee80211_mesh_init_neighbor(struct ieee80211_node *,
49659aa14a9SRui Paulo 		   const struct ieee80211_frame *,
49759aa14a9SRui Paulo 		   const struct ieee80211_scanparams *);
49859aa14a9SRui Paulo 
499c104cff2SRui Paulo /*
500c104cff2SRui Paulo  * Return non-zero if proxy operation is enabled.
501c104cff2SRui Paulo  */
502c104cff2SRui Paulo static __inline int
503c104cff2SRui Paulo ieee80211_mesh_isproxyena(struct ieee80211vap *vap)
504c104cff2SRui Paulo {
505c104cff2SRui Paulo 	struct ieee80211_mesh_state *ms = vap->iv_mesh;
506c104cff2SRui Paulo 	return (ms->ms_flags &
507c104cff2SRui Paulo 	    (IEEE80211_MESHFLAGS_AP | IEEE80211_MESHFLAGS_PORTAL)) != 0;
508c104cff2SRui Paulo }
509c104cff2SRui Paulo 
510c104cff2SRui Paulo /*
511c104cff2SRui Paulo  * Process an outbound frame: if a path is known to the
512c104cff2SRui Paulo  * destination then return a reference to the next hop
513c104cff2SRui Paulo  * for immediate transmission.  Otherwise initiate path
514c104cff2SRui Paulo  * discovery and, if possible queue the packet to be
515c104cff2SRui Paulo  * sent when path discovery completes.
516c104cff2SRui Paulo  */
51759aa14a9SRui Paulo static __inline struct ieee80211_node *
51859aa14a9SRui Paulo ieee80211_mesh_discover(struct ieee80211vap *vap,
51959aa14a9SRui Paulo     const uint8_t dest[IEEE80211_ADDR_LEN], struct mbuf *m)
52059aa14a9SRui Paulo {
52159aa14a9SRui Paulo 	struct ieee80211_mesh_state *ms = vap->iv_mesh;
52259aa14a9SRui Paulo 	return ms->ms_ppath->mpp_discover(vap, dest, m);
52359aa14a9SRui Paulo }
52459aa14a9SRui Paulo 
52559aa14a9SRui Paulo #endif /* _KERNEL */
52659aa14a9SRui Paulo #endif /* !_NET80211_IEEE80211_MESH_H_ */
527