xref: /freebsd/sys/net80211/ieee80211_mesh.h (revision 6486b015fc84e96725fef22b0e3363351399ae83)
1 /*-
2  * Copyright (c) 2009 The FreeBSD Foundation
3  * All rights reserved.
4  *
5  * This software was developed by Rui Paulo under sponsorship from the
6  * FreeBSD Foundation.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * $FreeBSD$
30  */
31 #ifndef _NET80211_IEEE80211_MESH_H_
32 #define _NET80211_IEEE80211_MESH_H_
33 
34 #define	IEEE80211_MESH_DEFAULT_TTL	31
35 
36 /*
37  * NB: all structures are __packed  so sizeof works on arm, et. al.
38  */
39 /*
40  * 802.11s Information Elements.
41 */
42 /* Mesh Configuration */
43 #define IEEE80211_MESH_CONF_SZ		(7)
44 struct ieee80211_meshconf_ie {
45 	uint8_t		conf_ie;	/* IEEE80211_ELEMID_MESHCONF */
46 	uint8_t		conf_len;
47 	uint8_t		conf_pselid;	/* Active Path Sel. Proto. ID */
48 	uint8_t		conf_pmetid;	/* Active Metric Identifier */
49 	uint8_t		conf_ccid;	/* Congestion Control Mode ID  */
50 	uint8_t		conf_syncid;	/* Sync. Protocol ID */
51 	uint8_t		conf_authid;	/* Auth. Protocol ID */
52 	uint8_t		conf_form;	/* Formation Information */
53 	uint8_t		conf_cap;
54 } __packed;
55 
56 /* Hybrid Wireless Mesh Protocol */
57 enum {
58 	/* 0 reserved */
59 	IEEE80211_MESHCONF_PATH_HWMP		= 1,
60 	/* 2-254 reserved */
61 	IEEE80211_MESHCONF_PATH_VENDOR		= 255,
62 };
63 
64 /* Airtime Link Metric */
65 enum {
66 	/* 0 reserved */
67 	IEEE80211_MESHCONF_METRIC_AIRTIME	= 1,
68 	/* 2-254 reserved */
69 	IEEE80211_MESHCONF_METRIC_VENDOR	= 255,
70 };
71 
72 /* Congestion Control */
73 enum {
74 	IEEE80211_MESHCONF_CC_DISABLED		= 0,
75 	IEEE80211_MESHCONF_CC_SIG		= 1,
76 	/* 2-254 reserved */
77 	IEEE80211_MESHCONF_CC_VENDOR		= 255,
78 };
79 
80 /* Neighbour Offset */
81 enum {
82 	/* 0 reserved */
83 	IEEE80211_MESHCONF_SYNC_NEIGHOFF	= 1,
84 	/* 2-254 rserved */
85 	IEEE80211_MESHCONF_SYNC_VENDOR		= 255,
86 };
87 
88 /* Authentication Protocol Identifier */
89 enum {
90 
91 	IEEE80211_MESHCONF_AUTH_DISABLED	= 0,
92 	/* Simultaneous Authenticaction of Equals */
93 	IEEE80211_MESHCONF_AUTH_SEA		= 1,
94 	IEEE80211_MESHCONF_AUTH_8021X		= 2, /* IEEE 802.1X */
95 	/* 3-254 reserved */
96 	IEEE80211_MESHCONF_AUTH_VENDOR		= 255,
97 };
98 
99 /* Mesh Formation Info */
100 #define	IEEE80211_MESHCONF_FORM_MP	0x01 	/* Connected to Portal */
101 #define	IEEE80211_MESHCONF_FORM_NNEIGH_MASK 0x7E /* Number of Neighbours */
102 #define	IEEE80211_MESHCONF_FORM_SA	0xF0 	/* indicating 802.1X auth */
103 
104 /* Mesh Capability */
105 #define	IEEE80211_MESHCONF_CAP_AP	0x01	/* Accepting Peers */
106 #define	IEEE80211_MESHCONF_CAP_MCCAS	0x02	/* MCCA supported */
107 #define	IEEE80211_MESHCONF_CAP_MCCAE	0x04	/* MCCA enabled */
108 #define	IEEE80211_MESHCONF_CAP_FWRD 	0x08	/* forwarding enabled */
109 #define	IEEE80211_MESHCONF_CAP_BTR	0x10	/* Beacon Timing Report Enab */
110 #define	IEEE80211_MESHCONF_CAP_TBTT	0x20	/* TBTT Adjusting  */
111 #define	IEEE80211_MESHCONF_CAP_PSL	0x40	/* Power Save Level */
112 /* 0x80 reserved */
113 
114 /* Mesh Identifier */
115 struct ieee80211_meshid_ie {
116 	uint8_t		id_ie;		/* IEEE80211_ELEMID_MESHID */
117 	uint8_t		id_len;
118 } __packed;
119 
120 /* Link Metric Report */
121 struct ieee80211_meshlmetric_ie {
122 	uint8_t		lm_ie;	/* IEEE80211_ACTION_MESH_LMETRIC */
123 	uint8_t		lm_len;
124 	uint8_t		lm_flags;
125 #define	IEEE80211_MESH_LMETRIC_FLAGS_REQ	0x01	/* Request */
126 	/*
127 	 * XXX: this field should be variable in size and depend on
128 	 * the active active path selection metric identifier
129 	 */
130 	uint32_t	lm_metric;
131 #define	IEEE80211_MESHLMETRIC_INITIALVAL	0
132 } __packed;
133 
134 /* Congestion Notification */
135 struct ieee80211_meshcngst_ie {
136 	uint8_t		cngst_ie;	/* IEEE80211_ELEMID_MESHCNGST */
137 	uint8_t		cngst_len;
138 	uint16_t	cngst_timer[4];	/* Expiration Timers: AC_BK,
139 					   AC_BE, AC_VI, AC_VO */
140 } __packed;
141 
142 /* Peer Link Management */
143 struct ieee80211_meshpeer_ie {
144 	uint8_t		peer_ie;	/* IEEE80211_ELEMID_MESHPEER */
145 	uint8_t		peer_len;
146 	uint8_t		peer_proto[4];	/* Peer Management Protocol */
147 	uint16_t	peer_llinkid;	/* Local Link ID */
148 	uint16_t	peer_linkid;	/* Peer Link ID */
149 	uint16_t	peer_rcode;
150 } __packed;
151 
152 enum {
153 	IEEE80211_MESH_PEER_LINK_OPEN		= 0,
154 	IEEE80211_MESH_PEER_LINK_CONFIRM	= 1,
155 	IEEE80211_MESH_PEER_LINK_CLOSE		= 2,
156 	/* values 3-255 are reserved */
157 };
158 
159 /* Mesh Peering Management Protocol */
160 #define	IEEE80211_MESH_PEER_PROTO_OUI		0x00, 0x0f, 0xac
161 #define	IEEE80211_MESH_PEER_PROTO_VALUE		0x2a
162 #define	IEEE80211_MESH_PEER_PROTO	{ IEEE80211_MESH_PEER_PROTO_OUI, \
163 					  IEEE80211_MESH_PEER_PROTO_VALUE }
164 /* Abbreviated Handshake Protocol */
165 #define	IEEE80211_MESH_PEER_PROTO_AH_OUI	0x00, 0x0f, 0xac
166 #define	IEEE80211_MESH_PEER_PROTO_AH_VALUE	0x2b
167 #define	IEEE80211_MESH_PEER_PROTO_AH	{ IEEE80211_MESH_PEER_PROTO_AH_OUI, \
168 					  IEEE80211_MESH_PEER_PROTO_AH_VALUE }
169 #ifdef notyet
170 /* Mesh Channel Switch Annoucement */
171 struct ieee80211_meshcsa_ie {
172 	uint8_t		csa_ie;		/* IEEE80211_ELEMID_MESHCSA */
173 	uint8_t		csa_len;
174 	uint8_t		csa_mode;
175 	uint8_t		csa_newclass;	/* New Regulatory Class */
176 	uint8_t		csa_newchan;
177 	uint8_t		csa_precvalue;	/* Precedence Value */
178 	uint8_t		csa_count;
179 } __packed;
180 
181 /* Mesh TIM */
182 /* Equal to the non Mesh version */
183 
184 /* Mesh Awake Window */
185 struct ieee80211_meshawakew_ie {
186 	uint8_t		awakew_ie;		/* IEEE80211_ELEMID_MESHAWAKEW */
187 	uint8_t		awakew_len;
188 	uint8_t		awakew_windowlen;	/* in TUs */
189 } __packed;
190 
191 /* Mesh Beacon Timing */
192 struct ieee80211_meshbeacont_ie {
193 	uint8_t		beacont_ie;		/* IEEE80211_ELEMID_MESHBEACONT */
194 	uint8_t		beacont_len;
195 	struct {
196 		uint8_t		mp_aid;		/* Least Octet of AID */
197 		uint16_t	mp_btime;	/* Beacon Time */
198 		uint16_t	mp_bint;	/* Beacon Interval */
199 	} __packed mp[1];			/* NB: variable size */
200 } __packed;
201 #endif
202 
203 /* Portal (MP) Annoucement */
204 struct ieee80211_meshpann_ie {
205 	uint8_t		pann_ie;		/* IEEE80211_ELEMID_MESHPANN */
206 	uint8_t		pann_len;
207 	uint8_t		pann_flags;
208 	uint8_t		pann_hopcount;
209 	uint8_t		pann_ttl;
210 	uint8_t		pann_addr[IEEE80211_ADDR_LEN];
211 	uint8_t		pann_seq;		/* PANN Sequence Number */
212 } __packed;
213 
214 /* Root (MP) Annoucement */
215 #define	IEEE80211_MESHRANN_BASE_SZ 	(21)
216 struct ieee80211_meshrann_ie {
217 	uint8_t		rann_ie;		/* IEEE80211_ELEMID_MESHRANN */
218 	uint8_t		rann_len;
219 	uint8_t		rann_flags;
220 #define	IEEE80211_MESHRANN_FLAGS_PR	0x01	/* Portal Role */
221 	uint8_t		rann_hopcount;
222 	uint8_t		rann_ttl;
223 	uint8_t		rann_addr[IEEE80211_ADDR_LEN];
224 	uint32_t	rann_seq;		/* HWMP Sequence Number */
225 	uint32_t	rann_interval;
226 	uint32_t	rann_metric;
227 } __packed;
228 
229 /* Mesh Path Request */
230 #define	IEEE80211_MESHPREQ_BASE_SZ 		(26)
231 #define	IEEE80211_MESHPREQ_BASE_SZ_AE 		(32)
232 #define	IEEE80211_MESHPREQ_TRGT_SZ 		(11)
233 #define	IEEE80211_MESHPREQ_TCNT_OFFSET		(27)
234 #define	IEEE80211_MESHPREQ_TCNT_OFFSET_AE	(33)
235 struct ieee80211_meshpreq_ie {
236 	uint8_t		preq_ie;	/* IEEE80211_ELEMID_MESHPREQ */
237 	uint8_t		preq_len;
238 	uint8_t		preq_flags;
239 #define	IEEE80211_MESHPREQ_FLAGS_PR	0x01	/* Portal Role */
240 #define	IEEE80211_MESHPREQ_FLAGS_AM	0x02	/* 0 = ucast / 1 = bcast */
241 #define	IEEE80211_MESHPREQ_FLAGS_PP	0x04	/* Proactive PREP */
242 #define	IEEE80211_MESHPREQ_FLAGS_AE	0x40	/* Address Extension */
243 	uint8_t		preq_hopcount;
244 	uint8_t		preq_ttl;
245 	uint32_t	preq_id;
246 	uint8_t		preq_origaddr[IEEE80211_ADDR_LEN];
247 	uint32_t	preq_origseq;	/* HWMP Sequence Number */
248 	/* NB: may have Originator External Address */
249 	uint8_t		preq_orig_ext_addr[IEEE80211_ADDR_LEN];
250 	uint32_t	preq_lifetime;
251 	uint32_t	preq_metric;
252 	uint8_t		preq_tcount;	/* target count */
253 	struct {
254 		uint8_t		target_flags;
255 #define	IEEE80211_MESHPREQ_TFLAGS_TO	0x01	/* Target Only */
256 #define	IEEE80211_MESHPREQ_TFLAGS_RF	0x02	/* Reply and Forward */
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  */
335 #define	IEEE80211_ACTION_CAT_MESHPEERING	30	/* XXX Linux */
336 /* XXX: these need to be looked into */
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 	IEEE80211_ACTION_MESHPEERING_OPEN	= 0,
346 	IEEE80211_ACTION_MESHPEERING_CONFIRM	= 1,
347 	IEEE80211_ACTION_MESHPEERING_CLOSE	= 2,
348 	/* 3-255 reserved */
349 };
350 
351 /*
352  * Mesh Action code.
353  */
354 enum {
355 	IEEE80211_ACTION_MESH_LMETRIC	= 0,	/* Mesh Link Metric Report */
356 	IEEE80211_ACTION_MESH_HWMP	= 1,	/* HWMP Mesh Path Selection */
357 	IEEE80211_ACTION_MESH_GANN	= 2,	/* Gate Announcement */
358 	IEEE80211_ACTION_MESH_CC	= 3,	/* Congestion Control */
359 	IEEE80211_ACTION_MESH_MCCA_SREQ	= 4,	/* MCCA Setup Request */
360 	IEEE80211_ACTION_MESH_MCCA_SREP	= 5,	/* MCCA Setup Reply */
361 	IEEE80211_ACTION_MESH_MCCA_AREQ	= 6,	/* MCCA Advertisement Req. */
362 	IEEE80211_ACTION_MESH_MCCA_ADVER =7,	/* MCCA Advertisement */
363 	IEEE80211_ACTION_MESH_MCCA_TRDOWN = 8,	/* MCCA Teardown */
364 	IEEE80211_ACTION_MESH_TBTT_REQ	= 9,	/* TBTT Adjustment Request */
365 	IEEE80211_ACTION_MESH_TBTT_RES	= 10,	/* TBTT Adjustment Response */
366 	/* 11-255 reserved */
367 };
368 
369 /*
370  * Mesh Portal Annoucement Action codes.
371  */
372 enum {
373 	IEEE80211_ACTION_MESHPANN	= 0,
374 	/* 1-255 reserved */
375 };
376 
377 /*
378  * Different mesh control structures based on the AE
379  * (Address Extension) bits.
380  */
381 struct ieee80211_meshcntl {
382 	uint8_t		mc_flags;	/* Address Extension 00 */
383 	uint8_t		mc_ttl;		/* TTL */
384 	uint8_t		mc_seq[4];	/* Sequence No. */
385 	/* NB: more addresses may follow */
386 } __packed;
387 
388 struct ieee80211_meshcntl_ae01 {
389 	uint8_t		mc_flags;	/* Address Extension 01 */
390 	uint8_t		mc_ttl;		/* TTL */
391 	uint8_t		mc_seq[4];	/* Sequence No. */
392 	uint8_t		mc_addr4[IEEE80211_ADDR_LEN];
393 } __packed;
394 
395 struct ieee80211_meshcntl_ae10 {
396 	uint8_t		mc_flags;	/* Address Extension 10 */
397 	uint8_t		mc_ttl;		/* TTL */
398 	uint8_t		mc_seq[4];	/* Sequence No. */
399 	uint8_t		mc_addr4[IEEE80211_ADDR_LEN];
400 	uint8_t		mc_addr5[IEEE80211_ADDR_LEN];
401 } __packed;
402 
403 struct ieee80211_meshcntl_ae11 {
404 	uint8_t		mc_flags;	/* Address Extension 11 */
405 	uint8_t		mc_ttl;		/* TTL */
406 	uint8_t		mc_seq[4];	/* Sequence No. */
407 	uint8_t		mc_addr4[IEEE80211_ADDR_LEN];
408 	uint8_t		mc_addr5[IEEE80211_ADDR_LEN];
409 	uint8_t		mc_addr6[IEEE80211_ADDR_LEN];
410 } __packed;
411 
412 #ifdef _KERNEL
413 MALLOC_DECLARE(M_80211_MESH_PREQ);
414 MALLOC_DECLARE(M_80211_MESH_PREP);
415 MALLOC_DECLARE(M_80211_MESH_PERR);
416 
417 MALLOC_DECLARE(M_80211_MESH_RT);
418 struct ieee80211_mesh_route {
419 	TAILQ_ENTRY(ieee80211_mesh_route)	rt_next;
420 	int			rt_crtime;	/* creation time */
421 	uint8_t			rt_dest[IEEE80211_ADDR_LEN];
422 	uint8_t			rt_nexthop[IEEE80211_ADDR_LEN];
423 	uint32_t		rt_metric;	/* path metric */
424 	uint16_t		rt_nhops;	/* number of hops */
425 	uint16_t		rt_flags;
426 #define	IEEE80211_MESHRT_FLAGS_VALID	0x01	/* patch discovery complete */
427 #define	IEEE80211_MESHRT_FLAGS_PROXY	0x02	/* proxy entry */
428 	uint32_t		rt_lifetime;
429 	uint32_t		rt_lastmseq;	/* last seq# seen dest */
430 	void			*rt_priv;	/* private data */
431 };
432 #define	IEEE80211_MESH_ROUTE_PRIV(rt, cast)	((cast *)rt->rt_priv)
433 
434 #define	IEEE80211_MESH_PROTO_DSZ	12	/* description size */
435 /*
436  * Mesh Path Selection Protocol.
437  */
438 enum ieee80211_state;
439 struct ieee80211_mesh_proto_path {
440 	uint8_t		mpp_active;
441 	char 		mpp_descr[IEEE80211_MESH_PROTO_DSZ];
442 	uint8_t		mpp_ie;
443 	struct ieee80211_node *
444 	    		(*mpp_discover)(struct ieee80211vap *,
445 				const uint8_t [IEEE80211_ADDR_LEN],
446 				struct mbuf *);
447 	void		(*mpp_peerdown)(struct ieee80211_node *);
448 	void		(*mpp_vattach)(struct ieee80211vap *);
449 	void		(*mpp_vdetach)(struct ieee80211vap *);
450 	int		(*mpp_newstate)(struct ieee80211vap *,
451 			    enum ieee80211_state, int);
452 	const size_t	mpp_privlen;	/* size required in the routing table
453 					   for private data */
454 	int		mpp_inact;	/* inact. timeout for invalid routes
455 					   (ticks) */
456 };
457 
458 /*
459  * Mesh Link Metric Report Protocol.
460  */
461 struct ieee80211_mesh_proto_metric {
462 	uint8_t		mpm_active;
463 	char		mpm_descr[IEEE80211_MESH_PROTO_DSZ];
464 	uint8_t		mpm_ie;
465 	uint32_t	(*mpm_metric)(struct ieee80211_node *);
466 };
467 
468 #ifdef notyet
469 /*
470  * Mesh Authentication Protocol.
471  */
472 struct ieee80211_mesh_proto_auth {
473 	uint8_t		mpa_ie[4];
474 };
475 
476 struct ieee80211_mesh_proto_congestion {
477 };
478 
479 struct ieee80211_mesh_proto_sync {
480 };
481 #endif
482 
483 typedef uint32_t ieee80211_mesh_seq;
484 #define	IEEE80211_MESH_SEQ_LEQ(a, b)	((int32_t)((a)-(b)) <= 0)
485 #define	IEEE80211_MESH_SEQ_GEQ(a, b)	((int32_t)((a)-(b)) >= 0)
486 
487 struct ieee80211_mesh_state {
488 	int				ms_idlen;
489 	uint8_t				ms_id[IEEE80211_MESHID_LEN];
490 	ieee80211_mesh_seq		ms_seq;	/* seq no for meshcntl */
491 	uint16_t			ms_neighbors;
492 	uint8_t				ms_ttl;	/* mesh ttl set in packets */
493 #define IEEE80211_MESHFLAGS_AP		0x01	/* accept peers */
494 #define IEEE80211_MESHFLAGS_PORTAL	0x02	/* mesh portal role */
495 #define IEEE80211_MESHFLAGS_FWD		0x04	/* forward packets */
496 	uint8_t				ms_flags;
497 	struct mtx			ms_rt_lock;
498 	struct callout			ms_cleantimer;
499 	TAILQ_HEAD(, ieee80211_mesh_route)  ms_routes;
500 	struct ieee80211_mesh_proto_metric *ms_pmetric;
501 	struct ieee80211_mesh_proto_path   *ms_ppath;
502 };
503 void		ieee80211_mesh_attach(struct ieee80211com *);
504 void		ieee80211_mesh_detach(struct ieee80211com *);
505 
506 struct ieee80211_mesh_route *
507 		ieee80211_mesh_rt_find(struct ieee80211vap *,
508 		    const uint8_t [IEEE80211_ADDR_LEN]);
509 struct ieee80211_mesh_route *
510                 ieee80211_mesh_rt_add(struct ieee80211vap *,
511 		    const uint8_t [IEEE80211_ADDR_LEN]);
512 void		ieee80211_mesh_rt_del(struct ieee80211vap *,
513 		    const uint8_t [IEEE80211_ADDR_LEN]);
514 void		ieee80211_mesh_rt_flush(struct ieee80211vap *);
515 void		ieee80211_mesh_rt_flush_peer(struct ieee80211vap *,
516 		    const uint8_t [IEEE80211_ADDR_LEN]);
517 void		ieee80211_mesh_proxy_check(struct ieee80211vap *,
518 		    const uint8_t [IEEE80211_ADDR_LEN]);
519 
520 int		ieee80211_mesh_register_proto_path(const
521 		    struct ieee80211_mesh_proto_path *);
522 int		ieee80211_mesh_register_proto_metric(const
523 		    struct ieee80211_mesh_proto_metric *);
524 
525 uint8_t *	ieee80211_add_meshid(uint8_t *, struct ieee80211vap *);
526 uint8_t *	ieee80211_add_meshconf(uint8_t *, struct ieee80211vap *);
527 uint8_t *	ieee80211_add_meshpeer(uint8_t *, uint8_t, uint16_t, uint16_t,
528 		    uint16_t);
529 uint8_t *	ieee80211_add_meshlmetric(uint8_t *, uint8_t, uint32_t);
530 
531 void		ieee80211_mesh_node_init(struct ieee80211vap *,
532 		    struct ieee80211_node *);
533 void		ieee80211_mesh_node_cleanup(struct ieee80211_node *);
534 void		ieee80211_parse_meshid(struct ieee80211_node *,
535 		    const uint8_t *);
536 struct ieee80211_scanparams;
537 void		ieee80211_mesh_init_neighbor(struct ieee80211_node *,
538 		   const struct ieee80211_frame *,
539 		   const struct ieee80211_scanparams *);
540 void		ieee80211_mesh_update_beacon(struct ieee80211vap *,
541 		    struct ieee80211_beacon_offsets *);
542 
543 /*
544  * Return non-zero if proxy operation is enabled.
545  */
546 static __inline int
547 ieee80211_mesh_isproxyena(struct ieee80211vap *vap)
548 {
549 	struct ieee80211_mesh_state *ms = vap->iv_mesh;
550 	return (ms->ms_flags &
551 	    (IEEE80211_MESHFLAGS_AP | IEEE80211_MESHFLAGS_PORTAL)) != 0;
552 }
553 
554 /*
555  * Process an outbound frame: if a path is known to the
556  * destination then return a reference to the next hop
557  * for immediate transmission.  Otherwise initiate path
558  * discovery and, if possible queue the packet to be
559  * sent when path discovery completes.
560  */
561 static __inline struct ieee80211_node *
562 ieee80211_mesh_discover(struct ieee80211vap *vap,
563     const uint8_t dest[IEEE80211_ADDR_LEN], struct mbuf *m)
564 {
565 	struct ieee80211_mesh_state *ms = vap->iv_mesh;
566 	return ms->ms_ppath->mpp_discover(vap, dest, m);
567 }
568 
569 #endif /* _KERNEL */
570 #endif /* !_NET80211_IEEE80211_MESH_H_ */
571