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 IEEE80211_MESHCONF_AUTH_DISABLED = 0, 94 /* Simultaneous Authenticaction of Equals */ 95 IEEE80211_MESHCONF_AUTH_SEA = 1, 96 IEEE80211_MESHCONF_AUTH_8021X = 2, /* IEEE 802.1X */ 97 /* 3-254 reserved */ 98 IEEE80211_MESHCONF_AUTH_VENDOR = 255, 99 }; 100 101 /* Mesh Formation Info */ 102 #define IEEE80211_MESHCONF_FORM_GATE 0x01 /* Connected to Gate */ 103 #define IEEE80211_MESHCONF_FORM_NNEIGH_MASK 0x7E /* Number of Neighbours */ 104 #define IEEE80211_MESHCONF_FORM_SA 0xF0 /* indicating 802.1X auth */ 105 106 /* Mesh Capability */ 107 #define IEEE80211_MESHCONF_CAP_AP 0x01 /* Accepting Peers */ 108 #define IEEE80211_MESHCONF_CAP_MCCAS 0x02 /* MCCA supported */ 109 #define IEEE80211_MESHCONF_CAP_MCCAE 0x04 /* MCCA enabled */ 110 #define IEEE80211_MESHCONF_CAP_FWRD 0x08 /* forwarding enabled */ 111 #define IEEE80211_MESHCONF_CAP_BTR 0x10 /* Beacon Timing Report Enab */ 112 #define IEEE80211_MESHCONF_CAP_TBTT 0x20 /* TBTT Adjusting */ 113 #define IEEE80211_MESHCONF_CAP_PSL 0x40 /* Power Save Level */ 114 /* 0x80 reserved */ 115 116 /* Mesh Identifier */ 117 struct ieee80211_meshid_ie { 118 uint8_t id_ie; /* IEEE80211_ELEMID_MESHID */ 119 uint8_t id_len; 120 } __packed; 121 122 /* Link Metric Report */ 123 struct ieee80211_meshlmetric_ie { 124 uint8_t lm_ie; /* IEEE80211_ACTION_MESH_LMETRIC */ 125 uint8_t lm_len; 126 uint8_t lm_flags; 127 #define IEEE80211_MESH_LMETRIC_FLAGS_REQ 0x01 /* Request */ 128 /* 129 * XXX: this field should be variable in size and depend on 130 * the active active path selection metric identifier 131 */ 132 uint32_t lm_metric; 133 #define IEEE80211_MESHLMETRIC_INITIALVAL 0 134 } __packed; 135 136 /* Congestion Notification */ 137 struct ieee80211_meshcngst_ie { 138 uint8_t cngst_ie; /* IEEE80211_ELEMID_MESHCNGST */ 139 uint8_t cngst_len; 140 uint16_t cngst_timer[4]; /* Expiration Timers: AC_BK, 141 AC_BE, AC_VI, AC_VO */ 142 } __packed; 143 144 /* Peer Link Management */ 145 #define IEEE80211_MPM_BASE_SZ (4) 146 #define IEEE80211_MPM_MAX_SZ (8) 147 struct ieee80211_meshpeer_ie { 148 uint8_t peer_ie; /* IEEE80211_ELEMID_MESHPEER */ 149 uint8_t peer_len; 150 uint16_t peer_proto; /* Peer Management Protocol */ 151 uint16_t peer_llinkid; /* Local Link ID */ 152 uint16_t peer_linkid; /* Peer Link ID */ 153 uint16_t peer_rcode; 154 } __packed; 155 156 /* Mesh Peering Protocol Identifier field value */ 157 enum { 158 IEEE80211_MPPID_MPM = 0, /* Mesh peering management */ 159 IEEE80211_MPPID_AUTH_MPM = 1, /* Auth. mesh peering exchange */ 160 /* 2-65535 reserved */ 161 }; 162 163 #ifdef notyet 164 /* Mesh Channel Switch Annoucement */ 165 struct ieee80211_meshcsa_ie { 166 uint8_t csa_ie; /* IEEE80211_ELEMID_MESHCSA */ 167 uint8_t csa_len; 168 uint8_t csa_mode; 169 uint8_t csa_newclass; /* New Regulatory Class */ 170 uint8_t csa_newchan; 171 uint8_t csa_precvalue; /* Precedence Value */ 172 uint8_t csa_count; 173 } __packed; 174 175 /* Mesh TIM */ 176 /* Equal to the non Mesh version */ 177 178 /* Mesh Awake Window */ 179 struct ieee80211_meshawakew_ie { 180 uint8_t awakew_ie; /* IEEE80211_ELEMID_MESHAWAKEW */ 181 uint8_t awakew_len; 182 uint8_t awakew_windowlen; /* in TUs */ 183 } __packed; 184 185 /* Mesh Beacon Timing */ 186 struct ieee80211_meshbeacont_ie { 187 uint8_t beacont_ie; /* IEEE80211_ELEMID_MESHBEACONT */ 188 uint8_t beacont_len; 189 struct { 190 uint8_t mp_aid; /* Least Octet of AID */ 191 uint16_t mp_btime; /* Beacon Time */ 192 uint16_t mp_bint; /* Beacon Interval */ 193 } __packed mp[1]; /* NB: variable size */ 194 } __packed; 195 #endif 196 197 /* Gate (GANN) Annoucement */ 198 /* 199 * NB: these macros used for the length in the IEs does not include 2 bytes 200 * for _ie and _len fields as is defined by the standard. 201 */ 202 #define IEEE80211_MESHGANN_BASE_SZ (15) 203 struct ieee80211_meshgann_ie { 204 uint8_t gann_ie; /* IEEE80211_ELEMID_MESHGANN */ 205 uint8_t gann_len; 206 uint8_t gann_flags; 207 uint8_t gann_hopcount; 208 uint8_t gann_ttl; 209 uint8_t gann_addr[IEEE80211_ADDR_LEN]; 210 uint32_t gann_seq; /* GANN Sequence Number */ 211 uint16_t gann_interval; /* GANN Interval */ 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_GATE 0x01 /* Mesh Gate */ 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_GATE 0x01 /* Mesh Gate */ 240 #define IEEE80211_MESHPREQ_FLAGS_AM 0x02 /* 0 = bcast / 1 = ucast */ 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_USN 0x04 /* Unknown HWMP seq number */ 257 uint8_t target_addr[IEEE80211_ADDR_LEN]; 258 uint32_t target_seq; /* HWMP Sequence Number */ 259 } __packed preq_targets[1]; /* NB: variable size */ 260 } __packed; 261 262 /* Mesh Path Reply */ 263 #define IEEE80211_MESHPREP_BASE_SZ (31) 264 #define IEEE80211_MESHPREP_BASE_SZ_AE (37) 265 struct ieee80211_meshprep_ie { 266 uint8_t prep_ie; /* IEEE80211_ELEMID_MESHPREP */ 267 uint8_t prep_len; 268 uint8_t prep_flags; 269 #define IEEE80211_MESHPREP_FLAGS_AE 0x40 /* Address Extension */ 270 uint8_t prep_hopcount; 271 uint8_t prep_ttl; 272 uint8_t prep_targetaddr[IEEE80211_ADDR_LEN]; 273 uint32_t prep_targetseq; 274 /* NB: May have Target External Address */ 275 uint8_t prep_target_ext_addr[IEEE80211_ADDR_LEN]; 276 uint32_t prep_lifetime; 277 uint32_t prep_metric; 278 uint8_t prep_origaddr[IEEE80211_ADDR_LEN]; 279 uint32_t prep_origseq; /* HWMP Sequence Number */ 280 } __packed; 281 282 /* Mesh Path Error */ 283 #define IEEE80211_MESHPERR_MAXDEST (19) 284 #define IEEE80211_MESHPERR_NDEST_OFFSET (3) 285 #define IEEE80211_MESHPERR_BASE_SZ (2) 286 #define IEEE80211_MESHPERR_DEST_SZ (13) 287 #define IEEE80211_MESHPERR_DEST_SZ_AE (19) 288 struct ieee80211_meshperr_ie { 289 uint8_t perr_ie; /* IEEE80211_ELEMID_MESHPERR */ 290 uint8_t perr_len; 291 uint8_t perr_ttl; 292 uint8_t perr_ndests; /* Number of Destinations */ 293 struct { 294 uint8_t dest_flags; 295 #define IEEE80211_MESHPERR_DFLAGS_USN 0x01 /* XXX: not part of standard */ 296 #define IEEE80211_MESHPERR_DFLAGS_RC 0x02 /* XXX: not part of standard */ 297 #define IEEE80211_MESHPERR_FLAGS_AE 0x40 /* Address Extension */ 298 uint8_t dest_addr[IEEE80211_ADDR_LEN]; 299 uint32_t dest_seq; /* HWMP Sequence Number */ 300 /* NB: May have Destination External Address */ 301 uint8_t dest_ext_addr[IEEE80211_ADDR_LEN]; 302 uint16_t dest_rcode; 303 } __packed perr_dests[1]; /* NB: variable size */ 304 } __packed; 305 306 #ifdef notyet 307 /* Mesh Proxy Update */ 308 struct ieee80211_meshpu_ie { 309 uint8_t pu_ie; /* IEEE80211_ELEMID_MESHPU */ 310 uint8_t pu_len; 311 uint8_t pu_flags; 312 #define IEEE80211_MESHPU_FLAGS_MASK 0x1 313 #define IEEE80211_MESHPU_FLAGS_DEL 0x0 314 #define IEEE80211_MESHPU_FLAGS_ADD 0x1 315 uint8_t pu_seq; /* PU Sequence Number */ 316 uint8_t pu_addr[IEEE80211_ADDR_LEN]; 317 uint8_t pu_naddr; /* Number of Proxied Addresses */ 318 /* NB: proxied address follows */ 319 } __packed; 320 321 /* Mesh Proxy Update Confirmation */ 322 struct ieee80211_meshpuc_ie { 323 uint8_t puc_ie; /* IEEE80211_ELEMID_MESHPUC */ 324 uint8_t puc_len; 325 uint8_t puc_flags; 326 uint8_t puc_seq; /* PU Sequence Number */ 327 uint8_t puc_daddr[IEEE80211_ADDR_LEN]; 328 } __packed; 329 #endif 330 331 /* 332 * 802.11s Action Frames 333 * XXX: these are wrong, and some of them should be 334 * under MESH category while PROXY is under MULTIHOP category. 335 */ 336 #define IEEE80211_ACTION_CAT_INTERWORK 15 337 #define IEEE80211_ACTION_CAT_RESOURCE 16 338 #define IEEE80211_ACTION_CAT_PROXY 17 339 340 /* 341 * Mesh Peering Action codes. 342 */ 343 enum { 344 /* 0 reserved */ 345 IEEE80211_ACTION_MESHPEERING_OPEN = 1, 346 IEEE80211_ACTION_MESHPEERING_CONFIRM = 2, 347 IEEE80211_ACTION_MESHPEERING_CLOSE = 3, 348 /* 4-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 * Different mesh control structures based on the AE 371 * (Address Extension) bits. 372 */ 373 struct ieee80211_meshcntl { 374 uint8_t mc_flags; /* Address Extension 00 */ 375 uint8_t mc_ttl; /* TTL */ 376 uint8_t mc_seq[4]; /* Sequence No. */ 377 /* NB: more addresses may follow */ 378 } __packed; 379 380 struct ieee80211_meshcntl_ae01 { 381 uint8_t mc_flags; /* Address Extension 01 */ 382 uint8_t mc_ttl; /* TTL */ 383 uint8_t mc_seq[4]; /* Sequence No. */ 384 uint8_t mc_addr4[IEEE80211_ADDR_LEN]; 385 } __packed; 386 387 struct ieee80211_meshcntl_ae10 { 388 uint8_t mc_flags; /* Address Extension 10 */ 389 uint8_t mc_ttl; /* TTL */ 390 uint8_t mc_seq[4]; /* Sequence No. */ 391 uint8_t mc_addr5[IEEE80211_ADDR_LEN]; 392 uint8_t mc_addr6[IEEE80211_ADDR_LEN]; 393 } __packed; 394 395 #define IEEE80211_MESH_AE_MASK 0x03 396 enum { 397 IEEE80211_MESH_AE_00 = 0, /* MC has no AE subfield */ 398 IEEE80211_MESH_AE_01 = 1, /* MC contain addr4 */ 399 IEEE80211_MESH_AE_10 = 2, /* MC contain addr5 & addr6 */ 400 IEEE80211_MESH_AE_11 = 3, /* RESERVED */ 401 }; 402 403 #ifdef _KERNEL 404 MALLOC_DECLARE(M_80211_MESH_PREQ); 405 MALLOC_DECLARE(M_80211_MESH_PREP); 406 MALLOC_DECLARE(M_80211_MESH_PERR); 407 408 MALLOC_DECLARE(M_80211_MESH_RT); 409 MALLOC_DECLARE(M_80211_MESH_GT_RT); 410 /* 411 * Basic forwarding information: 412 * o Destination MAC 413 * o Next-hop MAC 414 * o Precursor list (not implemented yet) 415 * o Path timeout 416 * The rest is part of the active Mesh path selection protocol. 417 * XXX: to be moved out later. 418 */ 419 struct ieee80211_mesh_route { 420 TAILQ_ENTRY(ieee80211_mesh_route) rt_next; 421 struct ieee80211vap *rt_vap; 422 ieee80211_rte_lock_t rt_lock; /* fine grained route lock */ 423 struct callout rt_discovery; /* discovery timeout */ 424 int rt_updtime; /* last update time */ 425 uint8_t rt_dest[IEEE80211_ADDR_LEN]; 426 uint8_t rt_mesh_gate[IEEE80211_ADDR_LEN]; /* meshDA */ 427 uint8_t rt_nexthop[IEEE80211_ADDR_LEN]; 428 uint32_t rt_metric; /* path metric */ 429 uint16_t rt_nhops; /* number of hops */ 430 uint16_t rt_flags; 431 #define IEEE80211_MESHRT_FLAGS_DISCOVER 0x01 /* path discovery */ 432 #define IEEE80211_MESHRT_FLAGS_VALID 0x02 /* path discovery complete */ 433 #define IEEE80211_MESHRT_FLAGS_PROXY 0x04 /* proxy entry */ 434 #define IEEE80211_MESHRT_FLAGS_GATE 0x08 /* mesh gate entry */ 435 uint32_t rt_lifetime; /* route timeout */ 436 uint32_t rt_lastmseq; /* last seq# seen dest */ 437 uint32_t rt_ext_seq; /* proxy seq number */ 438 void *rt_priv; /* private data */ 439 }; 440 #define IEEE80211_MESH_ROUTE_PRIV(rt, cast) ((cast *)rt->rt_priv) 441 442 /* 443 * Stored information about known mesh gates. 444 */ 445 struct ieee80211_mesh_gate_route { 446 TAILQ_ENTRY(ieee80211_mesh_gate_route) gr_next; 447 uint8_t gr_addr[IEEE80211_ADDR_LEN]; 448 uint32_t gr_lastseq; 449 struct ieee80211_mesh_route *gr_route; 450 }; 451 452 #define IEEE80211_MESH_PROTO_DSZ 12 /* description size */ 453 /* 454 * Mesh Path Selection Protocol. 455 */ 456 enum ieee80211_state; 457 struct ieee80211_mesh_proto_path { 458 uint8_t mpp_active; 459 char mpp_descr[IEEE80211_MESH_PROTO_DSZ]; 460 uint8_t mpp_ie; 461 struct ieee80211_node * 462 (*mpp_discover)(struct ieee80211vap *, 463 const uint8_t [IEEE80211_ADDR_LEN], 464 struct mbuf *); 465 void (*mpp_peerdown)(struct ieee80211_node *); 466 void (*mpp_senderror)(struct ieee80211vap *, 467 const uint8_t [IEEE80211_ADDR_LEN], 468 struct ieee80211_mesh_route *, int); 469 void (*mpp_vattach)(struct ieee80211vap *); 470 void (*mpp_vdetach)(struct ieee80211vap *); 471 int (*mpp_newstate)(struct ieee80211vap *, 472 enum ieee80211_state, int); 473 const size_t mpp_privlen; /* size required in the routing table 474 for private data */ 475 int mpp_inact; /* inact. timeout for invalid routes 476 (ticks) */ 477 }; 478 479 /* 480 * Mesh Link Metric Report Protocol. 481 */ 482 struct ieee80211_mesh_proto_metric { 483 uint8_t mpm_active; 484 char mpm_descr[IEEE80211_MESH_PROTO_DSZ]; 485 uint8_t mpm_ie; 486 uint32_t (*mpm_metric)(struct ieee80211_node *); 487 }; 488 489 #ifdef notyet 490 /* 491 * Mesh Authentication Protocol. 492 */ 493 struct ieee80211_mesh_proto_auth { 494 uint8_t mpa_ie[4]; 495 }; 496 497 struct ieee80211_mesh_proto_congestion { 498 }; 499 500 struct ieee80211_mesh_proto_sync { 501 }; 502 #endif 503 504 typedef uint32_t ieee80211_mesh_seq; 505 #define IEEE80211_MESH_SEQ_LEQ(a, b) ((int32_t)((a)-(b)) <= 0) 506 #define IEEE80211_MESH_SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0) 507 508 struct ieee80211_mesh_state { 509 int ms_idlen; 510 uint8_t ms_id[IEEE80211_MESHID_LEN]; 511 ieee80211_mesh_seq ms_seq; /* seq no for meshcntl */ 512 uint16_t ms_neighbors; 513 uint8_t ms_ttl; /* mesh ttl set in packets */ 514 #define IEEE80211_MESHFLAGS_AP 0x01 /* accept peers */ 515 #define IEEE80211_MESHFLAGS_GATE 0x02 /* mesh gate role */ 516 #define IEEE80211_MESHFLAGS_FWD 0x04 /* forward packets */ 517 #define IEEE80211_MESHFLAGS_ROOT 0x08 /* configured as root */ 518 uint8_t ms_flags; 519 ieee80211_rt_lock_t ms_rt_lock; 520 struct callout ms_cleantimer; 521 struct callout ms_gatetimer; 522 ieee80211_mesh_seq ms_gateseq; 523 TAILQ_HEAD(, ieee80211_mesh_gate_route) ms_known_gates; 524 TAILQ_HEAD(, ieee80211_mesh_route) ms_routes; 525 struct ieee80211_mesh_proto_metric *ms_pmetric; 526 struct ieee80211_mesh_proto_path *ms_ppath; 527 }; 528 void ieee80211_mesh_attach(struct ieee80211com *); 529 void ieee80211_mesh_detach(struct ieee80211com *); 530 531 struct ieee80211_mesh_route * 532 ieee80211_mesh_rt_find(struct ieee80211vap *, 533 const uint8_t [IEEE80211_ADDR_LEN]); 534 struct ieee80211_mesh_route * 535 ieee80211_mesh_rt_add(struct ieee80211vap *, 536 const uint8_t [IEEE80211_ADDR_LEN]); 537 void ieee80211_mesh_rt_del(struct ieee80211vap *, 538 const uint8_t [IEEE80211_ADDR_LEN]); 539 void ieee80211_mesh_rt_flush(struct ieee80211vap *); 540 void ieee80211_mesh_rt_flush_peer(struct ieee80211vap *, 541 const uint8_t [IEEE80211_ADDR_LEN]); 542 int ieee80211_mesh_rt_update(struct ieee80211_mesh_route *rt, int); 543 void ieee80211_mesh_proxy_check(struct ieee80211vap *, 544 const uint8_t [IEEE80211_ADDR_LEN]); 545 546 int ieee80211_mesh_register_proto_path(const 547 struct ieee80211_mesh_proto_path *); 548 int ieee80211_mesh_register_proto_metric(const 549 struct ieee80211_mesh_proto_metric *); 550 551 uint8_t * ieee80211_add_meshid(uint8_t *, struct ieee80211vap *); 552 uint8_t * ieee80211_add_meshconf(uint8_t *, struct ieee80211vap *); 553 uint8_t * ieee80211_add_meshpeer(uint8_t *, uint8_t, uint16_t, uint16_t, 554 uint16_t); 555 uint8_t * ieee80211_add_meshlmetric(uint8_t *, uint8_t, uint32_t); 556 uint8_t * ieee80211_add_meshgate(uint8_t *, 557 struct ieee80211_meshgann_ie *); 558 559 void ieee80211_mesh_node_init(struct ieee80211vap *, 560 struct ieee80211_node *); 561 void ieee80211_mesh_node_cleanup(struct ieee80211_node *); 562 void ieee80211_parse_meshid(struct ieee80211_node *, 563 const uint8_t *); 564 struct ieee80211_scanparams; 565 void ieee80211_mesh_init_neighbor(struct ieee80211_node *, 566 const struct ieee80211_frame *, 567 const struct ieee80211_scanparams *); 568 void ieee80211_mesh_update_beacon(struct ieee80211vap *, 569 struct ieee80211_beacon_offsets *); 570 struct ieee80211_mesh_gate_route * 571 ieee80211_mesh_mark_gate(struct ieee80211vap *, 572 const uint8_t *, struct ieee80211_mesh_route *); 573 void ieee80211_mesh_forward_to_gates(struct ieee80211vap *, 574 struct ieee80211_mesh_route *); 575 struct ieee80211_node * 576 ieee80211_mesh_find_txnode(struct ieee80211vap *, 577 const uint8_t [IEEE80211_ADDR_LEN]); 578 579 /* 580 * Return non-zero if proxy operation is enabled. 581 */ 582 static __inline int 583 ieee80211_mesh_isproxyena(struct ieee80211vap *vap) 584 { 585 struct ieee80211_mesh_state *ms = vap->iv_mesh; 586 return (ms->ms_flags & 587 (IEEE80211_MESHFLAGS_AP | IEEE80211_MESHFLAGS_GATE)) != 0; 588 } 589 590 /* 591 * Process an outbound frame: if a path is known to the 592 * destination then return a reference to the next hop 593 * for immediate transmission. Otherwise initiate path 594 * discovery and, if possible queue the packet to be 595 * sent when path discovery completes. 596 */ 597 static __inline struct ieee80211_node * 598 ieee80211_mesh_discover(struct ieee80211vap *vap, 599 const uint8_t dest[IEEE80211_ADDR_LEN], struct mbuf *m) 600 { 601 struct ieee80211_mesh_state *ms = vap->iv_mesh; 602 return ms->ms_ppath->mpp_discover(vap, dest, m); 603 } 604 605 #endif /* _KERNEL */ 606 #endif /* !_NET80211_IEEE80211_MESH_H_ */ 607