xref: /freebsd/sys/net80211/ieee80211_mesh.h (revision b00ab754)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2009 The FreeBSD Foundation
5  * All rights reserved.
6  *
7  * This software was developed by Rui Paulo under sponsorship from the
8  * FreeBSD Foundation.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  * $FreeBSD$
32  */
33 #ifndef _NET80211_IEEE80211_MESH_H_
34 #define _NET80211_IEEE80211_MESH_H_
35 
36 #define	IEEE80211_MESH_DEFAULT_TTL	31
37 #define	IEEE80211_MESH_MAX_NEIGHBORS	15
38 
39 /*
40  * NB: all structures are __packed  so sizeof works on arm, et. al.
41  */
42 /*
43  * 802.11s Information Elements.
44 */
45 /* Mesh Configuration */
46 #define IEEE80211_MESH_CONF_SZ		(7)
47 struct ieee80211_meshconf_ie {
48 	uint8_t		conf_ie;	/* IEEE80211_ELEMID_MESHCONF */
49 	uint8_t		conf_len;
50 	uint8_t		conf_pselid;	/* Active Path Sel. Proto. ID */
51 	uint8_t		conf_pmetid;	/* Active Metric Identifier */
52 	uint8_t		conf_ccid;	/* Congestion Control Mode ID  */
53 	uint8_t		conf_syncid;	/* Sync. Protocol ID */
54 	uint8_t		conf_authid;	/* Auth. Protocol ID */
55 	uint8_t		conf_form;	/* Formation Information */
56 	uint8_t		conf_cap;
57 } __packed;
58 
59 /* Hybrid Wireless Mesh Protocol */
60 enum {
61 	/* 0 reserved */
62 	IEEE80211_MESHCONF_PATH_HWMP		= 1,
63 	/* 2-254 reserved */
64 	IEEE80211_MESHCONF_PATH_VENDOR		= 255,
65 };
66 
67 /* Airtime Link Metric */
68 enum {
69 	/* 0 reserved */
70 	IEEE80211_MESHCONF_METRIC_AIRTIME	= 1,
71 	/* 2-254 reserved */
72 	IEEE80211_MESHCONF_METRIC_VENDOR	= 255,
73 };
74 
75 /* Congestion Control */
76 enum {
77 	IEEE80211_MESHCONF_CC_DISABLED		= 0,
78 	IEEE80211_MESHCONF_CC_SIG		= 1,
79 	/* 2-254 reserved */
80 	IEEE80211_MESHCONF_CC_VENDOR		= 255,
81 };
82 
83 /* Neighbour Offset */
84 enum {
85 	/* 0 reserved */
86 	IEEE80211_MESHCONF_SYNC_NEIGHOFF	= 1,
87 	/* 2-254 rserved */
88 	IEEE80211_MESHCONF_SYNC_VENDOR		= 255,
89 };
90 
91 /* Authentication Protocol Identifier */
92 enum {
93 
94 	IEEE80211_MESHCONF_AUTH_DISABLED	= 0,
95 	/* Simultaneous Authenticaction of Equals */
96 	IEEE80211_MESHCONF_AUTH_SEA		= 1,
97 	IEEE80211_MESHCONF_AUTH_8021X		= 2, /* IEEE 802.1X */
98 	/* 3-254 reserved */
99 	IEEE80211_MESHCONF_AUTH_VENDOR		= 255,
100 };
101 
102 /* Mesh Formation Info */
103 #define	IEEE80211_MESHCONF_FORM_GATE	0x01 	/* Connected to Gate */
104 #define	IEEE80211_MESHCONF_FORM_NNEIGH_MASK 0x7E /* Number of Neighbours */
105 #define	IEEE80211_MESHCONF_FORM_SA	0xF0 	/* indicating 802.1X auth */
106 
107 /* Mesh Capability */
108 #define	IEEE80211_MESHCONF_CAP_AP	0x01	/* Accepting Peers */
109 #define	IEEE80211_MESHCONF_CAP_MCCAS	0x02	/* MCCA supported */
110 #define	IEEE80211_MESHCONF_CAP_MCCAE	0x04	/* MCCA enabled */
111 #define	IEEE80211_MESHCONF_CAP_FWRD 	0x08	/* forwarding enabled */
112 #define	IEEE80211_MESHCONF_CAP_BTR	0x10	/* Beacon Timing Report Enab */
113 #define	IEEE80211_MESHCONF_CAP_TBTT	0x20	/* TBTT Adjusting  */
114 #define	IEEE80211_MESHCONF_CAP_PSL	0x40	/* Power Save Level */
115 /* 0x80 reserved */
116 
117 /* Mesh Identifier */
118 struct ieee80211_meshid_ie {
119 	uint8_t		id_ie;		/* IEEE80211_ELEMID_MESHID */
120 	uint8_t		id_len;
121 } __packed;
122 
123 /* Link Metric Report */
124 struct ieee80211_meshlmetric_ie {
125 	uint8_t		lm_ie;	/* IEEE80211_ACTION_MESH_LMETRIC */
126 	uint8_t		lm_len;
127 	uint8_t		lm_flags;
128 #define	IEEE80211_MESH_LMETRIC_FLAGS_REQ	0x01	/* Request */
129 	/*
130 	 * XXX: this field should be variable in size and depend on
131 	 * the active active path selection metric identifier
132 	 */
133 	uint32_t	lm_metric;
134 #define	IEEE80211_MESHLMETRIC_INITIALVAL	0
135 } __packed;
136 
137 /* Congestion Notification */
138 struct ieee80211_meshcngst_ie {
139 	uint8_t		cngst_ie;	/* IEEE80211_ELEMID_MESHCNGST */
140 	uint8_t		cngst_len;
141 	uint16_t	cngst_timer[4];	/* Expiration Timers: AC_BK,
142 					   AC_BE, AC_VI, AC_VO */
143 } __packed;
144 
145 /* Peer Link Management */
146 #define IEEE80211_MPM_BASE_SZ	(4)
147 #define IEEE80211_MPM_MAX_SZ	(8)
148 struct ieee80211_meshpeer_ie {
149 	uint8_t		peer_ie;	/* IEEE80211_ELEMID_MESHPEER */
150 	uint8_t		peer_len;
151 	uint16_t	peer_proto;	/* Peer Management Protocol */
152 	uint16_t	peer_llinkid;	/* Local Link ID */
153 	uint16_t	peer_linkid;	/* Peer Link ID */
154 	uint16_t	peer_rcode;
155 } __packed;
156 
157 /* Mesh Peering Protocol Identifier field value */
158 enum {
159 	IEEE80211_MPPID_MPM		= 0,	/* Mesh peering management */
160 	IEEE80211_MPPID_AUTH_MPM	= 1,	/* Auth. mesh peering exchange */
161 	/* 2-65535 reserved */
162 };
163 
164 #ifdef notyet
165 /* Mesh Channel Switch Annoucement */
166 struct ieee80211_meshcsa_ie {
167 	uint8_t		csa_ie;		/* IEEE80211_ELEMID_MESHCSA */
168 	uint8_t		csa_len;
169 	uint8_t		csa_mode;
170 	uint8_t		csa_newclass;	/* New Regulatory Class */
171 	uint8_t		csa_newchan;
172 	uint8_t		csa_precvalue;	/* Precedence Value */
173 	uint8_t		csa_count;
174 } __packed;
175 
176 /* Mesh TIM */
177 /* Equal to the non Mesh version */
178 
179 /* Mesh Awake Window */
180 struct ieee80211_meshawakew_ie {
181 	uint8_t		awakew_ie;		/* IEEE80211_ELEMID_MESHAWAKEW */
182 	uint8_t		awakew_len;
183 	uint8_t		awakew_windowlen;	/* in TUs */
184 } __packed;
185 
186 /* Mesh Beacon Timing */
187 struct ieee80211_meshbeacont_ie {
188 	uint8_t		beacont_ie;		/* IEEE80211_ELEMID_MESHBEACONT */
189 	uint8_t		beacont_len;
190 	struct {
191 		uint8_t		mp_aid;		/* Least Octet of AID */
192 		uint16_t	mp_btime;	/* Beacon Time */
193 		uint16_t	mp_bint;	/* Beacon Interval */
194 	} __packed mp[1];			/* NB: variable size */
195 } __packed;
196 #endif
197 
198 /* Gate (GANN) Annoucement */
199 /*
200  * NB: these macros used for the length in the IEs does not include 2 bytes
201  * for _ie and _len fields as is defined by the standard.
202  */
203 #define	IEEE80211_MESHGANN_BASE_SZ 	(15)
204 struct ieee80211_meshgann_ie {
205 	uint8_t		gann_ie;		/* IEEE80211_ELEMID_MESHGANN */
206 	uint8_t		gann_len;
207 	uint8_t		gann_flags;
208 	uint8_t		gann_hopcount;
209 	uint8_t		gann_ttl;
210 	uint8_t		gann_addr[IEEE80211_ADDR_LEN];
211 	uint32_t	gann_seq;		/* GANN Sequence Number */
212 	uint16_t	gann_interval;		/* GANN Interval */
213 } __packed;
214 
215 /* Root (MP) Annoucement */
216 #define	IEEE80211_MESHRANN_BASE_SZ 	(21)
217 struct ieee80211_meshrann_ie {
218 	uint8_t		rann_ie;		/* IEEE80211_ELEMID_MESHRANN */
219 	uint8_t		rann_len;
220 	uint8_t		rann_flags;
221 #define	IEEE80211_MESHRANN_FLAGS_GATE	0x01	/* Mesh Gate */
222 	uint8_t		rann_hopcount;
223 	uint8_t		rann_ttl;
224 	uint8_t		rann_addr[IEEE80211_ADDR_LEN];
225 	uint32_t	rann_seq;		/* HWMP Sequence Number */
226 	uint32_t	rann_interval;
227 	uint32_t	rann_metric;
228 } __packed;
229 
230 /* Mesh Path Request */
231 #define	IEEE80211_MESHPREQ_BASE_SZ 		(26)
232 #define	IEEE80211_MESHPREQ_BASE_SZ_AE 		(32)
233 #define	IEEE80211_MESHPREQ_TRGT_SZ 		(11)
234 #define	IEEE80211_MESHPREQ_TCNT_OFFSET		(27)
235 #define	IEEE80211_MESHPREQ_TCNT_OFFSET_AE	(33)
236 struct ieee80211_meshpreq_ie {
237 	uint8_t		preq_ie;	/* IEEE80211_ELEMID_MESHPREQ */
238 	uint8_t		preq_len;
239 	uint8_t		preq_flags;
240 #define	IEEE80211_MESHPREQ_FLAGS_GATE	0x01	/* Mesh Gate */
241 #define	IEEE80211_MESHPREQ_FLAGS_AM	0x02	/* 0 = bcast / 1 = ucast */
242 #define	IEEE80211_MESHPREQ_FLAGS_PP	0x04	/* Proactive PREP */
243 #define	IEEE80211_MESHPREQ_FLAGS_AE	0x40	/* Address Extension */
244 	uint8_t		preq_hopcount;
245 	uint8_t		preq_ttl;
246 	uint32_t	preq_id;
247 	uint8_t		preq_origaddr[IEEE80211_ADDR_LEN];
248 	uint32_t	preq_origseq;	/* HWMP Sequence Number */
249 	/* NB: may have Originator External Address */
250 	uint8_t		preq_orig_ext_addr[IEEE80211_ADDR_LEN];
251 	uint32_t	preq_lifetime;
252 	uint32_t	preq_metric;
253 	uint8_t		preq_tcount;	/* target count */
254 	struct {
255 		uint8_t		target_flags;
256 #define	IEEE80211_MESHPREQ_TFLAGS_TO	0x01	/* Target Only */
257 #define	IEEE80211_MESHPREQ_TFLAGS_USN	0x04	/* Unknown HWMP seq number */
258 		uint8_t		target_addr[IEEE80211_ADDR_LEN];
259 		uint32_t	target_seq;	/* HWMP Sequence Number */
260 	} __packed preq_targets[1];		/* NB: variable size */
261 } __packed;
262 
263 /* Mesh Path Reply */
264 #define	IEEE80211_MESHPREP_BASE_SZ 	(31)
265 #define	IEEE80211_MESHPREP_BASE_SZ_AE 	(37)
266 struct ieee80211_meshprep_ie {
267 	uint8_t		prep_ie;	/* IEEE80211_ELEMID_MESHPREP */
268 	uint8_t		prep_len;
269 	uint8_t		prep_flags;
270 #define	IEEE80211_MESHPREP_FLAGS_AE	0x40	/* Address Extension */
271 	uint8_t		prep_hopcount;
272 	uint8_t		prep_ttl;
273 	uint8_t		prep_targetaddr[IEEE80211_ADDR_LEN];
274 	uint32_t	prep_targetseq;
275 	/* NB: May have Target External Address */
276 	uint8_t		prep_target_ext_addr[IEEE80211_ADDR_LEN];
277 	uint32_t	prep_lifetime;
278 	uint32_t	prep_metric;
279 	uint8_t		prep_origaddr[IEEE80211_ADDR_LEN];
280 	uint32_t	prep_origseq;	/* HWMP Sequence Number */
281 } __packed;
282 
283 /* Mesh Path Error */
284 #define	IEEE80211_MESHPERR_MAXDEST	(19)
285 #define	IEEE80211_MESHPERR_NDEST_OFFSET	(3)
286 #define	IEEE80211_MESHPERR_BASE_SZ 	(2)
287 #define	IEEE80211_MESHPERR_DEST_SZ 	(13)
288 #define	IEEE80211_MESHPERR_DEST_SZ_AE 	(19)
289 struct ieee80211_meshperr_ie {
290 	uint8_t		perr_ie;	/* IEEE80211_ELEMID_MESHPERR */
291 	uint8_t		perr_len;
292 	uint8_t		perr_ttl;
293 	uint8_t		perr_ndests;	/* Number of Destinations */
294 	struct {
295 		uint8_t		dest_flags;
296 #define	IEEE80211_MESHPERR_DFLAGS_USN	0x01	/* XXX: not part of standard */
297 #define	IEEE80211_MESHPERR_DFLAGS_RC	0x02	/* XXX: not part of standard */
298 #define	IEEE80211_MESHPERR_FLAGS_AE	0x40	/* Address Extension */
299 		uint8_t		dest_addr[IEEE80211_ADDR_LEN];
300 		uint32_t	dest_seq;	/* HWMP Sequence Number */
301 		/* NB: May have Destination External Address */
302 		uint8_t		dest_ext_addr[IEEE80211_ADDR_LEN];
303 		uint16_t	dest_rcode;
304 	} __packed perr_dests[1];		/* NB: variable size */
305 } __packed;
306 
307 #ifdef notyet
308 /* Mesh Proxy Update */
309 struct ieee80211_meshpu_ie {
310 	uint8_t		pu_ie;		/* IEEE80211_ELEMID_MESHPU */
311 	uint8_t		pu_len;
312 	uint8_t		pu_flags;
313 #define	IEEE80211_MESHPU_FLAGS_MASK		0x1
314 #define	IEEE80211_MESHPU_FLAGS_DEL		0x0
315 #define	IEEE80211_MESHPU_FLAGS_ADD		0x1
316 	uint8_t		pu_seq;		/* PU Sequence Number */
317 	uint8_t		pu_addr[IEEE80211_ADDR_LEN];
318 	uint8_t		pu_naddr;	/* Number of Proxied Addresses */
319 	/* NB: proxied address follows */
320 } __packed;
321 
322 /* Mesh Proxy Update Confirmation */
323 struct ieee80211_meshpuc_ie {
324 	uint8_t		puc_ie;		/* IEEE80211_ELEMID_MESHPUC */
325 	uint8_t		puc_len;
326 	uint8_t		puc_flags;
327 	uint8_t		puc_seq;	/* PU Sequence Number */
328 	uint8_t		puc_daddr[IEEE80211_ADDR_LEN];
329 } __packed;
330 #endif
331 
332 /*
333  * 802.11s Action Frames
334  * XXX: these are wrong, and some of them should be
335  * under MESH category while PROXY is under MULTIHOP category.
336  */
337 #define	IEEE80211_ACTION_CAT_INTERWORK		15
338 #define	IEEE80211_ACTION_CAT_RESOURCE		16
339 #define	IEEE80211_ACTION_CAT_PROXY		17
340 
341 /*
342  * Mesh Peering Action codes.
343  */
344 enum {
345 	/* 0 reserved */
346 	IEEE80211_ACTION_MESHPEERING_OPEN	= 1,
347 	IEEE80211_ACTION_MESHPEERING_CONFIRM	= 2,
348 	IEEE80211_ACTION_MESHPEERING_CLOSE	= 3,
349 	/* 4-255 reserved */
350 };
351 
352 /*
353  * Mesh Action code.
354  */
355 enum {
356 	IEEE80211_ACTION_MESH_LMETRIC	= 0,	/* Mesh Link Metric Report */
357 	IEEE80211_ACTION_MESH_HWMP	= 1,	/* HWMP Mesh Path Selection */
358 	IEEE80211_ACTION_MESH_GANN	= 2,	/* Gate Announcement */
359 	IEEE80211_ACTION_MESH_CC	= 3,	/* Congestion Control */
360 	IEEE80211_ACTION_MESH_MCCA_SREQ	= 4,	/* MCCA Setup Request */
361 	IEEE80211_ACTION_MESH_MCCA_SREP	= 5,	/* MCCA Setup Reply */
362 	IEEE80211_ACTION_MESH_MCCA_AREQ	= 6,	/* MCCA Advertisement Req. */
363 	IEEE80211_ACTION_MESH_MCCA_ADVER =7,	/* MCCA Advertisement */
364 	IEEE80211_ACTION_MESH_MCCA_TRDOWN = 8,	/* MCCA Teardown */
365 	IEEE80211_ACTION_MESH_TBTT_REQ	= 9,	/* TBTT Adjustment Request */
366 	IEEE80211_ACTION_MESH_TBTT_RES	= 10,	/* TBTT Adjustment Response */
367 	/* 11-255 reserved */
368 };
369 
370 /*
371  * Different mesh control structures based on the AE
372  * (Address Extension) bits.
373  */
374 struct ieee80211_meshcntl {
375 	uint8_t		mc_flags;	/* Address Extension 00 */
376 	uint8_t		mc_ttl;		/* TTL */
377 	uint8_t		mc_seq[4];	/* Sequence No. */
378 	/* NB: more addresses may follow */
379 } __packed;
380 
381 struct ieee80211_meshcntl_ae01 {
382 	uint8_t		mc_flags;	/* Address Extension 01 */
383 	uint8_t		mc_ttl;		/* TTL */
384 	uint8_t		mc_seq[4];	/* Sequence No. */
385 	uint8_t		mc_addr4[IEEE80211_ADDR_LEN];
386 } __packed;
387 
388 struct ieee80211_meshcntl_ae10 {
389 	uint8_t		mc_flags;	/* Address Extension 10 */
390 	uint8_t		mc_ttl;		/* TTL */
391 	uint8_t		mc_seq[4];	/* Sequence No. */
392 	uint8_t		mc_addr5[IEEE80211_ADDR_LEN];
393 	uint8_t		mc_addr6[IEEE80211_ADDR_LEN];
394 } __packed;
395 
396 #define IEEE80211_MESH_AE_MASK		0x03
397 enum {
398 	IEEE80211_MESH_AE_00		= 0,	/* MC has no AE subfield */
399 	IEEE80211_MESH_AE_01		= 1,	/* MC contain addr4 */
400 	IEEE80211_MESH_AE_10		= 2,	/* MC contain addr5 & addr6 */
401 	IEEE80211_MESH_AE_11		= 3,	/* RESERVED */
402 };
403 
404 #ifdef _KERNEL
405 MALLOC_DECLARE(M_80211_MESH_PREQ);
406 MALLOC_DECLARE(M_80211_MESH_PREP);
407 MALLOC_DECLARE(M_80211_MESH_PERR);
408 
409 MALLOC_DECLARE(M_80211_MESH_RT);
410 MALLOC_DECLARE(M_80211_MESH_GT_RT);
411 /*
412  * Basic forwarding information:
413  * o Destination MAC
414  * o Next-hop MAC
415  * o Precursor list (not implemented yet)
416  * o Path timeout
417  * The rest is part of the active Mesh path selection protocol.
418  * XXX: to be moved out later.
419  */
420 struct ieee80211_mesh_route {
421 	TAILQ_ENTRY(ieee80211_mesh_route)	rt_next;
422 	struct ieee80211vap	*rt_vap;
423 	ieee80211_rte_lock_t	rt_lock;	/* fine grained route lock */
424 	struct callout		rt_discovery;	/* discovery timeout */
425 	int			rt_updtime;	/* last update time */
426 	uint8_t			rt_dest[IEEE80211_ADDR_LEN];
427 	uint8_t			rt_mesh_gate[IEEE80211_ADDR_LEN]; /* meshDA */
428 	uint8_t			rt_nexthop[IEEE80211_ADDR_LEN];
429 	uint32_t		rt_metric;	/* path metric */
430 	uint16_t		rt_nhops;	/* number of hops */
431 	uint16_t		rt_flags;
432 #define	IEEE80211_MESHRT_FLAGS_DISCOVER	0x01	/* path discovery */
433 #define	IEEE80211_MESHRT_FLAGS_VALID	0x02	/* path discovery complete */
434 #define	IEEE80211_MESHRT_FLAGS_PROXY	0x04	/* proxy entry */
435 #define	IEEE80211_MESHRT_FLAGS_GATE	0x08	/* mesh gate entry */
436 	uint32_t		rt_lifetime;	/* route timeout */
437 	uint32_t		rt_lastmseq;	/* last seq# seen dest */
438 	uint32_t		rt_ext_seq;	/* proxy seq number */
439 	void			*rt_priv;	/* private data */
440 };
441 #define	IEEE80211_MESH_ROUTE_PRIV(rt, cast)	((cast *)rt->rt_priv)
442 
443 /*
444  * Stored information about known mesh gates.
445  */
446 struct ieee80211_mesh_gate_route {
447 	TAILQ_ENTRY(ieee80211_mesh_gate_route)	gr_next;
448 	uint8_t				gr_addr[IEEE80211_ADDR_LEN];
449 	uint32_t			gr_lastseq;
450 	struct ieee80211_mesh_route 	*gr_route;
451 };
452 
453 #define	IEEE80211_MESH_PROTO_DSZ	12	/* description size */
454 /*
455  * Mesh Path Selection Protocol.
456  */
457 enum ieee80211_state;
458 struct ieee80211_mesh_proto_path {
459 	uint8_t		mpp_active;
460 	char 		mpp_descr[IEEE80211_MESH_PROTO_DSZ];
461 	uint8_t		mpp_ie;
462 	struct ieee80211_node *
463 	    		(*mpp_discover)(struct ieee80211vap *,
464 				const uint8_t [IEEE80211_ADDR_LEN],
465 				struct mbuf *);
466 	void		(*mpp_peerdown)(struct ieee80211_node *);
467 	void		(*mpp_senderror)(struct ieee80211vap *,
468 				const uint8_t [IEEE80211_ADDR_LEN],
469 				struct ieee80211_mesh_route *, int);
470 	void		(*mpp_vattach)(struct ieee80211vap *);
471 	void		(*mpp_vdetach)(struct ieee80211vap *);
472 	int		(*mpp_newstate)(struct ieee80211vap *,
473 			    enum ieee80211_state, int);
474 	const size_t	mpp_privlen;	/* size required in the routing table
475 					   for private data */
476 	int		mpp_inact;	/* inact. timeout for invalid routes
477 					   (ticks) */
478 };
479 
480 /*
481  * Mesh Link Metric Report Protocol.
482  */
483 struct ieee80211_mesh_proto_metric {
484 	uint8_t		mpm_active;
485 	char		mpm_descr[IEEE80211_MESH_PROTO_DSZ];
486 	uint8_t		mpm_ie;
487 	uint32_t	(*mpm_metric)(struct ieee80211_node *);
488 };
489 
490 #ifdef notyet
491 /*
492  * Mesh Authentication Protocol.
493  */
494 struct ieee80211_mesh_proto_auth {
495 	uint8_t		mpa_ie[4];
496 };
497 
498 struct ieee80211_mesh_proto_congestion {
499 };
500 
501 struct ieee80211_mesh_proto_sync {
502 };
503 #endif
504 
505 typedef uint32_t ieee80211_mesh_seq;
506 #define	IEEE80211_MESH_SEQ_LEQ(a, b)	((int32_t)((a)-(b)) <= 0)
507 #define	IEEE80211_MESH_SEQ_GEQ(a, b)	((int32_t)((a)-(b)) >= 0)
508 
509 struct ieee80211_mesh_state {
510 	int				ms_idlen;
511 	uint8_t				ms_id[IEEE80211_MESHID_LEN];
512 	ieee80211_mesh_seq		ms_seq;	/* seq no for meshcntl */
513 	uint16_t			ms_neighbors;
514 	uint8_t				ms_ttl;	/* mesh ttl set in packets */
515 #define IEEE80211_MESHFLAGS_AP		0x01	/* accept peers */
516 #define IEEE80211_MESHFLAGS_GATE	0x02	/* mesh gate role */
517 #define IEEE80211_MESHFLAGS_FWD		0x04	/* forward packets */
518 #define IEEE80211_MESHFLAGS_ROOT	0x08	/* configured as root */
519 	uint8_t				ms_flags;
520 	ieee80211_rt_lock_t		ms_rt_lock;
521 	struct callout			ms_cleantimer;
522 	struct callout			ms_gatetimer;
523 	ieee80211_mesh_seq		ms_gateseq;
524 	TAILQ_HEAD(, ieee80211_mesh_gate_route) ms_known_gates;
525 	TAILQ_HEAD(, ieee80211_mesh_route)  ms_routes;
526 	struct ieee80211_mesh_proto_metric *ms_pmetric;
527 	struct ieee80211_mesh_proto_path   *ms_ppath;
528 };
529 void		ieee80211_mesh_attach(struct ieee80211com *);
530 void		ieee80211_mesh_detach(struct ieee80211com *);
531 
532 struct ieee80211_mesh_route *
533 		ieee80211_mesh_rt_find(struct ieee80211vap *,
534 		    const uint8_t [IEEE80211_ADDR_LEN]);
535 struct ieee80211_mesh_route *
536                 ieee80211_mesh_rt_add(struct ieee80211vap *,
537 		    const uint8_t [IEEE80211_ADDR_LEN]);
538 void		ieee80211_mesh_rt_del(struct ieee80211vap *,
539 		    const uint8_t [IEEE80211_ADDR_LEN]);
540 void		ieee80211_mesh_rt_flush(struct ieee80211vap *);
541 void		ieee80211_mesh_rt_flush_peer(struct ieee80211vap *,
542 		    const uint8_t [IEEE80211_ADDR_LEN]);
543 int		ieee80211_mesh_rt_update(struct ieee80211_mesh_route *rt, int);
544 void		ieee80211_mesh_proxy_check(struct ieee80211vap *,
545 		    const uint8_t [IEEE80211_ADDR_LEN]);
546 
547 int		ieee80211_mesh_register_proto_path(const
548 		    struct ieee80211_mesh_proto_path *);
549 int		ieee80211_mesh_register_proto_metric(const
550 		    struct ieee80211_mesh_proto_metric *);
551 
552 uint8_t *	ieee80211_add_meshid(uint8_t *, struct ieee80211vap *);
553 uint8_t *	ieee80211_add_meshconf(uint8_t *, struct ieee80211vap *);
554 uint8_t *	ieee80211_add_meshpeer(uint8_t *, uint8_t, uint16_t, uint16_t,
555 		    uint16_t);
556 uint8_t *	ieee80211_add_meshlmetric(uint8_t *, uint8_t, uint32_t);
557 uint8_t *	ieee80211_add_meshgate(uint8_t *,
558 		    struct ieee80211_meshgann_ie *);
559 
560 void		ieee80211_mesh_node_init(struct ieee80211vap *,
561 		    struct ieee80211_node *);
562 void		ieee80211_mesh_node_cleanup(struct ieee80211_node *);
563 void		ieee80211_parse_meshid(struct ieee80211_node *,
564 		    const uint8_t *);
565 struct ieee80211_scanparams;
566 void		ieee80211_mesh_init_neighbor(struct ieee80211_node *,
567 		   const struct ieee80211_frame *,
568 		   const struct ieee80211_scanparams *);
569 void		ieee80211_mesh_update_beacon(struct ieee80211vap *,
570 		    struct ieee80211_beacon_offsets *);
571 struct ieee80211_mesh_gate_route *
572 		ieee80211_mesh_mark_gate(struct ieee80211vap *,
573 		    const uint8_t *, struct ieee80211_mesh_route *);
574 void		ieee80211_mesh_forward_to_gates(struct ieee80211vap *,
575 		    struct ieee80211_mesh_route *);
576 struct ieee80211_node *
577 		ieee80211_mesh_find_txnode(struct ieee80211vap *,
578 		    const uint8_t [IEEE80211_ADDR_LEN]);
579 
580 /*
581  * Return non-zero if proxy operation is enabled.
582  */
583 static __inline int
584 ieee80211_mesh_isproxyena(struct ieee80211vap *vap)
585 {
586 	struct ieee80211_mesh_state *ms = vap->iv_mesh;
587 	return (ms->ms_flags &
588 	    (IEEE80211_MESHFLAGS_AP | IEEE80211_MESHFLAGS_GATE)) != 0;
589 }
590 
591 /*
592  * Process an outbound frame: if a path is known to the
593  * destination then return a reference to the next hop
594  * for immediate transmission.  Otherwise initiate path
595  * discovery and, if possible queue the packet to be
596  * sent when path discovery completes.
597  */
598 static __inline struct ieee80211_node *
599 ieee80211_mesh_discover(struct ieee80211vap *vap,
600     const uint8_t dest[IEEE80211_ADDR_LEN], struct mbuf *m)
601 {
602 	struct ieee80211_mesh_state *ms = vap->iv_mesh;
603 	return ms->ms_ppath->mpp_discover(vap, dest, m);
604 }
605 
606 #endif /* _KERNEL */
607 #endif /* !_NET80211_IEEE80211_MESH_H_ */
608