| 1 | /* | 
|---|
| 2 | * Copyright (c) 2004-2021 Apple Inc. All rights reserved. | 
|---|
| 3 | * | 
|---|
| 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | 
|---|
| 5 | * | 
|---|
| 6 | * This file contains Original Code and/or Modifications of Original Code | 
|---|
| 7 | * as defined in and that are subject to the Apple Public Source License | 
|---|
| 8 | * Version 2.0 (the 'License'). You may not use this file except in | 
|---|
| 9 | * compliance with the License. The rights granted to you under the License | 
|---|
| 10 | * may not be used to create, or enable the creation or redistribution of, | 
|---|
| 11 | * unlawful or unlicensed copies of an Apple operating system, or to | 
|---|
| 12 | * circumvent, violate, or enable the circumvention or violation of, any | 
|---|
| 13 | * terms of an Apple operating system software license agreement. | 
|---|
| 14 | * | 
|---|
| 15 | * Please obtain a copy of the License at | 
|---|
| 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | 
|---|
| 17 | * | 
|---|
| 18 | * The Original Code and all software distributed under the License are | 
|---|
| 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | 
|---|
| 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | 
|---|
| 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | 
|---|
| 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | 
|---|
| 23 | * Please see the License for the specific language governing rights and | 
|---|
| 24 | * limitations under the License. | 
|---|
| 25 | * | 
|---|
| 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | 
|---|
| 27 | */ | 
|---|
| 28 |  | 
|---|
| 29 | /* | 
|---|
| 30 | * Copyright 2001 Wasabi Systems, Inc. | 
|---|
| 31 | * All rights reserved. | 
|---|
| 32 | * | 
|---|
| 33 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | 
|---|
| 34 | * | 
|---|
| 35 | * Redistribution and use in source and binary forms, with or without | 
|---|
| 36 | * modification, are permitted provided that the following conditions | 
|---|
| 37 | * are met: | 
|---|
| 38 | * 1. Redistributions of source code must retain the above copyright | 
|---|
| 39 | *    notice, this list of conditions and the following disclaimer. | 
|---|
| 40 | * 2. Redistributions in binary form must reproduce the above copyright | 
|---|
| 41 | *    notice, this list of conditions and the following disclaimer in the | 
|---|
| 42 | *    documentation and/or other materials provided with the distribution. | 
|---|
| 43 | * 3. All advertising materials mentioning features or use of this software | 
|---|
| 44 | *    must display the following acknowledgement: | 
|---|
| 45 | *	This product includes software developed for the NetBSD Project by | 
|---|
| 46 | *	Wasabi Systems, Inc. | 
|---|
| 47 | * 4. The name of Wasabi Systems, Inc. may not be used to endorse | 
|---|
| 48 | *    or promote products derived from this software without specific prior | 
|---|
| 49 | *    written permission. | 
|---|
| 50 | * | 
|---|
| 51 | * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND | 
|---|
| 52 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 
|---|
| 53 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 
|---|
| 54 | * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC | 
|---|
| 55 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 
|---|
| 56 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 
|---|
| 57 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 
|---|
| 58 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 
|---|
| 59 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 
|---|
| 60 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 
|---|
| 61 | * POSSIBILITY OF SUCH DAMAGE. | 
|---|
| 62 | */ | 
|---|
| 63 |  | 
|---|
| 64 | /* | 
|---|
| 65 | * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) | 
|---|
| 66 | * All rights reserved. | 
|---|
| 67 | * | 
|---|
| 68 | * Redistribution and use in source and binary forms, with or without | 
|---|
| 69 | * modification, are permitted provided that the following conditions | 
|---|
| 70 | * are met: | 
|---|
| 71 | * 1. Redistributions of source code must retain the above copyright | 
|---|
| 72 | *    notice, this list of conditions and the following disclaimer. | 
|---|
| 73 | * 2. Redistributions in binary form must reproduce the above copyright | 
|---|
| 74 | *    notice, this list of conditions and the following disclaimer in the | 
|---|
| 75 | *    documentation and/or other materials provided with the distribution. | 
|---|
| 76 | * 3. All advertising materials mentioning features or use of this software | 
|---|
| 77 | *    must display the following acknowledgement: | 
|---|
| 78 | *	This product includes software developed by Jason L. Wright | 
|---|
| 79 | * 4. The name of the author may not be used to endorse or promote products | 
|---|
| 80 | *    derived from this software without specific prior written permission. | 
|---|
| 81 | * | 
|---|
| 82 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 
|---|
| 83 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 
|---|
| 84 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 
|---|
| 85 | * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | 
|---|
| 86 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 
|---|
| 87 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 
|---|
| 88 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 
|---|
| 89 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 
|---|
| 90 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | 
|---|
| 91 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 
|---|
| 92 | * POSSIBILITY OF SUCH DAMAGE. | 
|---|
| 93 | * | 
|---|
| 94 | * OpenBSD: if_bridge.h,v 1.14 2001/03/22 03:48:29 jason Exp | 
|---|
| 95 | * | 
|---|
| 96 | * $FreeBSD$ | 
|---|
| 97 | */ | 
|---|
| 98 |  | 
|---|
| 99 | /* | 
|---|
| 100 | * Data structure and control definitions for bridge interfaces. | 
|---|
| 101 | */ | 
|---|
| 102 |  | 
|---|
| 103 | #ifndef _NET_IF_BRIDGEVAR_H_ | 
|---|
| 104 | #define _NET_IF_BRIDGEVAR_H_ | 
|---|
| 105 |  | 
|---|
| 106 | #ifdef PRIVATE | 
|---|
| 107 |  | 
|---|
| 108 | #include <sys/queue.h> | 
|---|
| 109 |  | 
|---|
| 110 | #include <net/if.h> | 
|---|
| 111 | #include <net/ethernet.h> | 
|---|
| 112 | #include <netinet/in.h> | 
|---|
| 113 |  | 
|---|
| 114 | /* | 
|---|
| 115 | * Commands used in the SIOCSDRVSPEC ioctl.  Note the lookup of the | 
|---|
| 116 | * bridge interface itself is keyed off the ifdrv structure. | 
|---|
| 117 | */ | 
|---|
| 118 | #define BRDGADD                 0       /* add bridge member (ifbreq) */ | 
|---|
| 119 | #define BRDGDEL                 1       /* delete bridge member (ifbreq) */ | 
|---|
| 120 | #define BRDGGIFFLGS             2       /* get member if flags (ifbreq) */ | 
|---|
| 121 | #define BRDGSIFFLGS             3       /* set member if flags (ifbreq) */ | 
|---|
| 122 | #define BRDGSCACHE              4       /* set cache size (ifbrparam) */ | 
|---|
| 123 | #define BRDGGCACHE              5       /* get cache size (ifbrparam) */ | 
|---|
| 124 | #define BRDGGIFS                6       /* get member list (ifbifconf) */ | 
|---|
| 125 | #define BRDGRTS                 7       /* get address list (ifbaconf) */ | 
|---|
| 126 | #define BRDGSADDR               8       /* set static address (ifbareq) */ | 
|---|
| 127 | #define BRDGSTO                 9       /* set cache timeout (ifbrparam) */ | 
|---|
| 128 | #define BRDGGTO                 10      /* get cache timeout (ifbrparam) */ | 
|---|
| 129 | #define BRDGDADDR               11      /* delete address (ifbareq) */ | 
|---|
| 130 | #define BRDGFLUSH               12      /* flush address cache (ifbreq) */ | 
|---|
| 131 |  | 
|---|
| 132 | #define BRDGGPRI                13      /* get priority (ifbrparam) */ | 
|---|
| 133 | #define BRDGSPRI                14      /* set priority (ifbrparam) */ | 
|---|
| 134 | #define BRDGGHT                 15      /* get hello time (ifbrparam) */ | 
|---|
| 135 | #define BRDGSHT                 16      /* set hello time (ifbrparam) */ | 
|---|
| 136 | #define BRDGGFD                 17      /* get forward delay (ifbrparam) */ | 
|---|
| 137 | #define BRDGSFD                 18      /* set forward delay (ifbrparam) */ | 
|---|
| 138 | #define BRDGGMA                 19      /* get max age (ifbrparam) */ | 
|---|
| 139 | #define BRDGSMA                 20      /* set max age (ifbrparam) */ | 
|---|
| 140 | #define BRDGSIFPRIO             21      /* set if priority (ifbreq) */ | 
|---|
| 141 | #define BRDGSIFCOST             22      /* set if path cost (ifbreq) */ | 
|---|
| 142 | #define BRDGGFILT               23      /* get filter flags (ifbrparam) */ | 
|---|
| 143 | #define BRDGSFILT               24      /* set filter flags (ifbrparam) */ | 
|---|
| 144 | #define BRDGPURGE               25      /* purge address cache for a particular interface (ifbreq) */ | 
|---|
| 145 | #define BRDGADDS                26      /* add bridge span member (ifbreq) */ | 
|---|
| 146 | #define BRDGDELS                27      /* delete bridge span member (ifbreq) */ | 
|---|
| 147 | #define BRDGPARAM               28      /* get bridge STP params (ifbropreq) */ | 
|---|
| 148 | #define BRDGGRTE                29      /* get cache drops (ifbrparam) */ | 
|---|
| 149 | #define BRDGGIFSSTP             30      /* get member STP params list (ifbpstpconf) */ | 
|---|
| 150 | #define BRDGSPROTO              31      /* set protocol (ifbrparam) */ | 
|---|
| 151 | #define BRDGSTXHC               32      /* set tx hold count (ifbrparam) */ | 
|---|
| 152 | #define BRDGSIFAMAX             33      /* set max interface addrs (ifbreq) */ | 
|---|
| 153 | #define BRDGGHOSTFILTER         34      /* get host filter (ifbrhostfilter) */ | 
|---|
| 154 | #define BRDGSHOSTFILTER         35      /* set host filter (ifbrhostfilter) */ | 
|---|
| 155 | #define BRDGGMACNATLIST         36      /* get MAC NAT list (ifbrmnelist) */ | 
|---|
| 156 | #define BRDGGIFSTATS            37      /* member stats (ifbrmreq+ifbrmstats) */ | 
|---|
| 157 |  | 
|---|
| 158 | /* | 
|---|
| 159 | * Generic bridge control request. | 
|---|
| 160 | */ | 
|---|
| 161 | #pragma pack(4) | 
|---|
| 162 |  | 
|---|
| 163 | struct ifbreq { | 
|---|
| 164 | char            ifbr_ifsname[IFNAMSIZ]; /* member if name */ | 
|---|
| 165 | uint32_t        ifbr_ifsflags;          /* member if flags */ | 
|---|
| 166 | uint32_t        ifbr_stpflags;          /* member if STP flags */ | 
|---|
| 167 | uint32_t        ifbr_path_cost;         /* member if STP cost */ | 
|---|
| 168 | uint8_t         ifbr_portno;            /* member if port number */ | 
|---|
| 169 | uint8_t         ifbr_priority;          /* member if STP priority */ | 
|---|
| 170 | uint8_t         ifbr_proto;             /* member if STP protocol */ | 
|---|
| 171 | uint8_t         ifbr_role;              /* member if STP role */ | 
|---|
| 172 | uint8_t         ifbr_state;             /* member if STP state */ | 
|---|
| 173 | uint32_t        ifbr_addrcnt;           /* member if addr number */ | 
|---|
| 174 | uint32_t        ifbr_addrmax;           /* member if addr max */ | 
|---|
| 175 | uint32_t        ifbr_addrexceeded;      /* member if addr violations */ | 
|---|
| 176 | uint8_t         pad[32]; | 
|---|
| 177 | }; | 
|---|
| 178 |  | 
|---|
| 179 | #pragma pack() | 
|---|
| 180 |  | 
|---|
| 181 | /* BRDGGIFFLGS, BRDGSIFFLGS */ | 
|---|
| 182 | #define IFBIF_LEARNING          0x0001  /* if can learn */ | 
|---|
| 183 | #define IFBIF_DISCOVER          0x0002  /* if sends packets w/ unknown dest. */ | 
|---|
| 184 | #define IFBIF_STP               0x0004  /* if participates in spanning tree */ | 
|---|
| 185 | #define IFBIF_SPAN              0x0008  /* if is a span port */ | 
|---|
| 186 | #define IFBIF_STICKY            0x0010  /* if learned addresses stick */ | 
|---|
| 187 | #define IFBIF_BSTP_EDGE         0x0020  /* member stp edge port */ | 
|---|
| 188 | #define IFBIF_BSTP_AUTOEDGE     0x0040  /* member stp autoedge enabled */ | 
|---|
| 189 | #define IFBIF_BSTP_PTP          0x0080  /* member stp point to point */ | 
|---|
| 190 | #define IFBIF_BSTP_AUTOPTP      0x0100  /* member stp autoptp enabled */ | 
|---|
| 191 | #define IFBIF_BSTP_ADMEDGE      0x0200  /* member stp admin edge enabled */ | 
|---|
| 192 | #define IFBIF_BSTP_ADMCOST      0x0400  /* member stp admin path cost */ | 
|---|
| 193 | #define IFBIF_PRIVATE           0x0800  /* if is a private segment */ | 
|---|
| 194 | #define IFBIF_MAC_NAT           0x8000  /* member requires MAC NAT */ | 
|---|
| 195 | #define IFBIF_CHECKSUM_OFFLOAD  0x10000 /* checksum inbound packets, | 
|---|
| 196 | * drop outbound packets with | 
|---|
| 197 | * bad checksum | 
|---|
| 198 | */ | 
|---|
| 199 |  | 
|---|
| 200 | #define IFBIFBITS       "\020\001LEARNING\002DISCOVER\003STP\004SPAN" \ | 
|---|
| 201 | "\005STICKY\006EDGE\007AUTOEDGE\010PTP"                       \ | 
|---|
| 202 | "\011AUTOPTP\014PRIVATE"                                      \ | 
|---|
| 203 | "\020MACNAT\021CSUM" | 
|---|
| 204 |  | 
|---|
| 205 | #define IFBIFMASK       ~(IFBIF_BSTP_EDGE|IFBIF_BSTP_AUTOEDGE|IFBIF_BSTP_PTP| \ | 
|---|
| 206 | IFBIF_BSTP_AUTOPTP|IFBIF_BSTP_ADMEDGE| \ | 
|---|
| 207 | IFBIF_BSTP_ADMCOST)     /* not saved */ | 
|---|
| 208 |  | 
|---|
| 209 | /* BRDGFLUSH */ | 
|---|
| 210 | #define IFBF_FLUSHDYN           0x00    /* flush learned addresses only */ | 
|---|
| 211 | #define IFBF_FLUSHALL           0x01    /* flush all addresses */ | 
|---|
| 212 |  | 
|---|
| 213 | /* BRDGSFILT */ | 
|---|
| 214 | #define IFBF_FILT_USEIPF        0x00000001 /* run pf hooks on the bridge | 
|---|
| 215 | *  interface */ | 
|---|
| 216 | #define IFBF_FILT_MEMBER        0x00000002 /* run pf hooks on the member | 
|---|
| 217 | *  interfaces */ | 
|---|
| 218 | #define IFBF_FILT_ONLYIP        0x00000004 /* only pass IP[46] packets when | 
|---|
| 219 | *  pf is enabled */ | 
|---|
| 220 | #define IFBF_FILT_MASK          0x00000007 /* mask of valid values */ | 
|---|
| 221 |  | 
|---|
| 222 | /* | 
|---|
| 223 | * Interface list structure. | 
|---|
| 224 | */ | 
|---|
| 225 |  | 
|---|
| 226 | #pragma pack(4) | 
|---|
| 227 |  | 
|---|
| 228 | #ifndef XNU_KERNEL_PRIVATE | 
|---|
| 229 |  | 
|---|
| 230 | struct ifbifconf { | 
|---|
| 231 | uint32_t        ifbic_len;      /* buffer size */ | 
|---|
| 232 | union { | 
|---|
| 233 | caddr_t ifbicu_buf; | 
|---|
| 234 | struct ifbreq *ifbicu_req; | 
|---|
| 235 | #define ifbic_buf       ifbic_ifbicu.ifbicu_buf | 
|---|
| 236 | #define ifbic_req       ifbic_ifbicu.ifbicu_req | 
|---|
| 237 | } ifbic_ifbicu; | 
|---|
| 238 | }; | 
|---|
| 239 |  | 
|---|
| 240 | #else /* XNU_KERNEL_PRIVATE */ | 
|---|
| 241 |  | 
|---|
| 242 | struct ifbifconf32 { | 
|---|
| 243 | uint32_t        ifbic_len;      /* buffer size */ | 
|---|
| 244 | union { | 
|---|
| 245 | user32_addr_t   ifbicu_buf; | 
|---|
| 246 | user32_addr_t   ifbicu_req; | 
|---|
| 247 | #define ifbic_buf       ifbic_ifbicu.ifbicu_buf | 
|---|
| 248 | #define ifbic_req       ifbic_ifbicu.ifbicu_req | 
|---|
| 249 | } ifbic_ifbicu; | 
|---|
| 250 | }; | 
|---|
| 251 |  | 
|---|
| 252 | struct ifbifconf64 { | 
|---|
| 253 | uint32_t        ifbic_len;      /* buffer size */ | 
|---|
| 254 | union { | 
|---|
| 255 | user64_addr_t   ifbicu_buf; | 
|---|
| 256 | user64_addr_t   ifbicu_req; | 
|---|
| 257 | } ifbic_ifbicu; | 
|---|
| 258 | }; | 
|---|
| 259 | #endif /* XNU_KERNEL_PRIVATE */ | 
|---|
| 260 |  | 
|---|
| 261 | #pragma pack() | 
|---|
| 262 |  | 
|---|
| 263 | /* | 
|---|
| 264 | * Bridge address request. | 
|---|
| 265 | */ | 
|---|
| 266 |  | 
|---|
| 267 | #pragma pack(4) | 
|---|
| 268 |  | 
|---|
| 269 | #ifndef XNU_KERNEL_PRIVATE | 
|---|
| 270 |  | 
|---|
| 271 | struct ifbareq { | 
|---|
| 272 | char            ifba_ifsname[IFNAMSIZ]; /* member if name */ | 
|---|
| 273 | unsigned long   ifba_expire;            /* address expire time */ | 
|---|
| 274 | uint8_t         ifba_flags;             /* address flags */ | 
|---|
| 275 | uint8_t         ifba_dst[ETHER_ADDR_LEN];/* destination address */ | 
|---|
| 276 | uint16_t        ifba_vlan;              /* vlan id */ | 
|---|
| 277 | }; | 
|---|
| 278 |  | 
|---|
| 279 | #else /* XNU_KERNEL_PRIVATE */ | 
|---|
| 280 |  | 
|---|
| 281 | struct ifbareq32 { | 
|---|
| 282 | char            ifba_ifsname[IFNAMSIZ]; /* member if name */ | 
|---|
| 283 | uint32_t        ifba_expire;            /* address expire time */ | 
|---|
| 284 | uint8_t         ifba_flags;             /* address flags */ | 
|---|
| 285 | uint8_t         ifba_dst[ETHER_ADDR_LEN];/* destination address */ | 
|---|
| 286 | uint16_t        ifba_vlan;              /* vlan id */ | 
|---|
| 287 | }; | 
|---|
| 288 |  | 
|---|
| 289 | struct ifbareq64 { | 
|---|
| 290 | char            ifba_ifsname[IFNAMSIZ]; /* member if name */ | 
|---|
| 291 | uint64_t        ifba_expire;            /* address expire time */ | 
|---|
| 292 | uint8_t         ifba_flags;             /* address flags */ | 
|---|
| 293 | uint8_t         ifba_dst[ETHER_ADDR_LEN];/* destination address */ | 
|---|
| 294 | uint16_t        ifba_vlan;              /* vlan id */ | 
|---|
| 295 | }; | 
|---|
| 296 | #endif /* XNU_KERNEL_PRIVATE */ | 
|---|
| 297 |  | 
|---|
| 298 | #pragma pack() | 
|---|
| 299 |  | 
|---|
| 300 | #define IFBAF_TYPEMASK  0x03    /* address type mask */ | 
|---|
| 301 | #define IFBAF_DYNAMIC   0x00    /* dynamically learned address */ | 
|---|
| 302 | #define IFBAF_STATIC    0x01    /* static address */ | 
|---|
| 303 | #define IFBAF_STICKY    0x02    /* sticky address */ | 
|---|
| 304 |  | 
|---|
| 305 | #define IFBAFBITS       "\020\1STATIC\2STICKY" | 
|---|
| 306 |  | 
|---|
| 307 | /* | 
|---|
| 308 | * Address list structure. | 
|---|
| 309 | */ | 
|---|
| 310 |  | 
|---|
| 311 | #pragma pack(4) | 
|---|
| 312 |  | 
|---|
| 313 | #ifndef XNU_KERNEL_PRIVATE | 
|---|
| 314 |  | 
|---|
| 315 | struct ifbaconf { | 
|---|
| 316 | uint32_t        ifbac_len;      /* buffer size */ | 
|---|
| 317 | union { | 
|---|
| 318 | caddr_t ifbacu_buf; | 
|---|
| 319 | struct ifbareq *ifbacu_req; | 
|---|
| 320 | #define ifbac_buf       ifbac_ifbacu.ifbacu_buf | 
|---|
| 321 | #define ifbac_req       ifbac_ifbacu.ifbacu_req | 
|---|
| 322 | } ifbac_ifbacu; | 
|---|
| 323 | }; | 
|---|
| 324 |  | 
|---|
| 325 | #else /* XNU_KERNEL_PRIVATE */ | 
|---|
| 326 |  | 
|---|
| 327 | struct ifbaconf32 { | 
|---|
| 328 | uint32_t        ifbac_len;      /* buffer size */ | 
|---|
| 329 | union { | 
|---|
| 330 | user32_addr_t   ifbacu_buf; | 
|---|
| 331 | user32_addr_t   ifbacu_req; | 
|---|
| 332 | #define ifbac_buf       ifbac_ifbacu.ifbacu_buf | 
|---|
| 333 | #define ifbac_req       ifbac_ifbacu.ifbacu_req | 
|---|
| 334 | } ifbac_ifbacu; | 
|---|
| 335 | }; | 
|---|
| 336 |  | 
|---|
| 337 | struct ifbaconf64 { | 
|---|
| 338 | uint32_t        ifbac_len;      /* buffer size */ | 
|---|
| 339 | union { | 
|---|
| 340 | user64_addr_t   ifbacu_buf; | 
|---|
| 341 | user64_addr_t   ifbacu_req; | 
|---|
| 342 | } ifbac_ifbacu; | 
|---|
| 343 | }; | 
|---|
| 344 | #endif /* XNU_KERNEL_PRIVATE */ | 
|---|
| 345 |  | 
|---|
| 346 | #pragma pack() | 
|---|
| 347 |  | 
|---|
| 348 | /* | 
|---|
| 349 | * Bridge parameter structure. | 
|---|
| 350 | */ | 
|---|
| 351 |  | 
|---|
| 352 | #pragma pack(4) | 
|---|
| 353 |  | 
|---|
| 354 | struct ifbrparam { | 
|---|
| 355 | union { | 
|---|
| 356 | uint32_t ifbrpu_int32; | 
|---|
| 357 | uint16_t ifbrpu_int16; | 
|---|
| 358 | uint8_t ifbrpu_int8; | 
|---|
| 359 | } ifbrp_ifbrpu; | 
|---|
| 360 | }; | 
|---|
| 361 |  | 
|---|
| 362 | #pragma pack() | 
|---|
| 363 |  | 
|---|
| 364 | #define ifbrp_csize     ifbrp_ifbrpu.ifbrpu_int32       /* cache size */ | 
|---|
| 365 | #define ifbrp_ctime     ifbrp_ifbrpu.ifbrpu_int32       /* cache time (sec) */ | 
|---|
| 366 | #define ifbrp_prio      ifbrp_ifbrpu.ifbrpu_int16       /* bridge priority */ | 
|---|
| 367 | #define ifbrp_proto     ifbrp_ifbrpu.ifbrpu_int8        /* bridge protocol */ | 
|---|
| 368 | #define ifbrp_txhc      ifbrp_ifbrpu.ifbrpu_int8        /* bpdu tx holdcount */ | 
|---|
| 369 | #define ifbrp_hellotime ifbrp_ifbrpu.ifbrpu_int8        /* hello time (sec) */ | 
|---|
| 370 | #define ifbrp_fwddelay  ifbrp_ifbrpu.ifbrpu_int8        /* fwd time (sec) */ | 
|---|
| 371 | #define ifbrp_maxage    ifbrp_ifbrpu.ifbrpu_int8        /* max age (sec) */ | 
|---|
| 372 | #define ifbrp_cexceeded ifbrp_ifbrpu.ifbrpu_int32       /* # of cache dropped | 
|---|
| 373 | * adresses */ | 
|---|
| 374 | #define ifbrp_filter    ifbrp_ifbrpu.ifbrpu_int32       /* filtering flags */ | 
|---|
| 375 |  | 
|---|
| 376 | /* | 
|---|
| 377 | * Bridge current operational parameters structure. | 
|---|
| 378 | */ | 
|---|
| 379 |  | 
|---|
| 380 | #ifndef XNU_KERNEL_PRIVATE | 
|---|
| 381 |  | 
|---|
| 382 | #pragma pack(4) | 
|---|
| 383 |  | 
|---|
| 384 | struct ifbropreq { | 
|---|
| 385 | uint8_t         ifbop_holdcount; | 
|---|
| 386 | uint8_t         ifbop_maxage; | 
|---|
| 387 | uint8_t         ifbop_hellotime; | 
|---|
| 388 | uint8_t         ifbop_fwddelay; | 
|---|
| 389 | uint8_t         ifbop_protocol; | 
|---|
| 390 | uint16_t        ifbop_priority; | 
|---|
| 391 | uint16_t        ifbop_root_port; | 
|---|
| 392 | uint32_t        ifbop_root_path_cost; | 
|---|
| 393 | uint64_t        ifbop_bridgeid; | 
|---|
| 394 | uint64_t        ifbop_designated_root; | 
|---|
| 395 | uint64_t        ifbop_designated_bridge; | 
|---|
| 396 | struct timeval  ifbop_last_tc_time; | 
|---|
| 397 | }; | 
|---|
| 398 |  | 
|---|
| 399 | #pragma pack() | 
|---|
| 400 |  | 
|---|
| 401 | #else /* XNU_KERNEL_PRIVATE */ | 
|---|
| 402 |  | 
|---|
| 403 | #include <sys/_types/_timeval32.h> | 
|---|
| 404 | #include <sys/_types/_timeval64.h> | 
|---|
| 405 |  | 
|---|
| 406 | #pragma pack(4) | 
|---|
| 407 |  | 
|---|
| 408 | struct ifbropreq32 { | 
|---|
| 409 | uint8_t         ifbop_holdcount; | 
|---|
| 410 | uint8_t         ifbop_maxage; | 
|---|
| 411 | uint8_t         ifbop_hellotime; | 
|---|
| 412 | uint8_t         ifbop_fwddelay; | 
|---|
| 413 | uint8_t         ifbop_protocol; | 
|---|
| 414 | uint16_t        ifbop_priority; | 
|---|
| 415 | uint16_t        ifbop_root_port; | 
|---|
| 416 | uint32_t        ifbop_root_path_cost; | 
|---|
| 417 | uint64_t        ifbop_bridgeid; | 
|---|
| 418 | uint64_t        ifbop_designated_root; | 
|---|
| 419 | uint64_t        ifbop_designated_bridge; | 
|---|
| 420 | struct timeval32  ifbop_last_tc_time; | 
|---|
| 421 | }; | 
|---|
| 422 |  | 
|---|
| 423 | struct ifbropreq64 { | 
|---|
| 424 | uint8_t         ifbop_holdcount; | 
|---|
| 425 | uint8_t         ifbop_maxage; | 
|---|
| 426 | uint8_t         ifbop_hellotime; | 
|---|
| 427 | uint8_t         ifbop_fwddelay; | 
|---|
| 428 | uint8_t         ifbop_protocol; | 
|---|
| 429 | uint16_t        ifbop_priority; | 
|---|
| 430 | uint16_t        ifbop_root_port; | 
|---|
| 431 | uint32_t        ifbop_root_path_cost; | 
|---|
| 432 | uint64_t        ifbop_bridgeid; | 
|---|
| 433 | uint64_t        ifbop_designated_root; | 
|---|
| 434 | uint64_t        ifbop_designated_bridge; | 
|---|
| 435 | struct timeval64  ifbop_last_tc_time; | 
|---|
| 436 | }; | 
|---|
| 437 |  | 
|---|
| 438 | #pragma pack() | 
|---|
| 439 |  | 
|---|
| 440 | #endif | 
|---|
| 441 |  | 
|---|
| 442 | /* | 
|---|
| 443 | * Bridge member operational STP params structure. | 
|---|
| 444 | */ | 
|---|
| 445 |  | 
|---|
| 446 | #pragma pack(4) | 
|---|
| 447 |  | 
|---|
| 448 | struct ifbpstpreq { | 
|---|
| 449 | uint8_t         ifbp_portno;            /* bp STP port number */ | 
|---|
| 450 | uint32_t        ifbp_fwd_trans;         /* bp STP fwd transitions */ | 
|---|
| 451 | uint32_t        ifbp_design_cost;       /* bp STP designated cost */ | 
|---|
| 452 | uint32_t        ifbp_design_port;       /* bp STP designated port */ | 
|---|
| 453 | uint64_t        ifbp_design_bridge;     /* bp STP designated bridge */ | 
|---|
| 454 | uint64_t        ifbp_design_root;       /* bp STP designated root */ | 
|---|
| 455 | }; | 
|---|
| 456 |  | 
|---|
| 457 | #pragma pack() | 
|---|
| 458 |  | 
|---|
| 459 | /* | 
|---|
| 460 | * Bridge STP ports list structure. | 
|---|
| 461 | */ | 
|---|
| 462 |  | 
|---|
| 463 | #pragma pack(4) | 
|---|
| 464 |  | 
|---|
| 465 | #ifndef XNU_KERNEL_PRIVATE | 
|---|
| 466 |  | 
|---|
| 467 | struct ifbpstpconf { | 
|---|
| 468 | uint32_t        ifbpstp_len;    /* buffer size */ | 
|---|
| 469 | union { | 
|---|
| 470 | caddr_t ifbpstpu_buf; | 
|---|
| 471 | struct ifbpstpreq *ifbpstpu_req; | 
|---|
| 472 | } ifbpstp_ifbpstpu; | 
|---|
| 473 | #define ifbpstp_buf     ifbpstp_ifbpstpu.ifbpstpu_buf | 
|---|
| 474 | #define ifbpstp_req     ifbpstp_ifbpstpu.ifbpstpu_req | 
|---|
| 475 | }; | 
|---|
| 476 |  | 
|---|
| 477 | #else /* XNU_KERNEL_PRIVATE */ | 
|---|
| 478 |  | 
|---|
| 479 | struct ifbpstpconf32 { | 
|---|
| 480 | uint32_t        ifbpstp_len;    /* buffer size */ | 
|---|
| 481 | union { | 
|---|
| 482 | user32_addr_t   ifbpstpu_buf; | 
|---|
| 483 | user32_addr_t   ifbpstpu_req; | 
|---|
| 484 | #define ifbpstp_buf     ifbpstp_ifbpstpu.ifbpstpu_buf | 
|---|
| 485 | #define ifbpstp_req     ifbpstp_ifbpstpu.ifbpstpu_req | 
|---|
| 486 | } ifbpstp_ifbpstpu; | 
|---|
| 487 | }; | 
|---|
| 488 |  | 
|---|
| 489 | struct ifbpstpconf64 { | 
|---|
| 490 | uint32_t        ifbpstp_len;    /* buffer size */ | 
|---|
| 491 | union { | 
|---|
| 492 | user64_addr_t   ifbpstpu_buf; | 
|---|
| 493 | user64_addr_t   ifbpstpu_req; | 
|---|
| 494 | } ifbpstp_ifbpstpu; | 
|---|
| 495 | }; | 
|---|
| 496 |  | 
|---|
| 497 | #endif /* XNU_KERNEL_PRIVATE */ | 
|---|
| 498 |  | 
|---|
| 499 | #pragma pack() | 
|---|
| 500 |  | 
|---|
| 501 | /* | 
|---|
| 502 | * Bridge member host filter. | 
|---|
| 503 | */ | 
|---|
| 504 |  | 
|---|
| 505 | #define IFBRHF_ENABLED  0x01 | 
|---|
| 506 | #define IFBRHF_HWSRC    0x02    /* Valid with enabled flags */ | 
|---|
| 507 | #define IFBRHF_IPSRC    0x04    /* Valid with enabled flags */ | 
|---|
| 508 |  | 
|---|
| 509 | #pragma pack(4) | 
|---|
| 510 |  | 
|---|
| 511 | struct ifbrhostfilter { | 
|---|
| 512 | uint32_t        ifbrhf_flags;           /* flags */ | 
|---|
| 513 | char            ifbrhf_ifsname[IFNAMSIZ];       /* member if name */ | 
|---|
| 514 | uint8_t         ifbrhf_hwsrca[ETHER_ADDR_LEN]; | 
|---|
| 515 | uint32_t        ifbrhf_ipsrc; | 
|---|
| 516 | }; | 
|---|
| 517 |  | 
|---|
| 518 | #pragma pack() | 
|---|
| 519 |  | 
|---|
| 520 | /* | 
|---|
| 521 | * sysctl net.link.bridge.hostfilterstats | 
|---|
| 522 | */ | 
|---|
| 523 | struct bridge_hostfilter_stats { | 
|---|
| 524 | uint64_t        brhf_bad_ether_type; | 
|---|
| 525 | uint64_t        brhf_bad_ether_srchw_addr; | 
|---|
| 526 |  | 
|---|
| 527 | uint64_t        brhf_ether_too_small; | 
|---|
| 528 | uint64_t        brhf_ether_pullup_failed; | 
|---|
| 529 |  | 
|---|
| 530 | uint64_t        brhf_arp_ok; | 
|---|
| 531 | uint64_t        brhf_arp_too_small; | 
|---|
| 532 | uint64_t        brhf_arp_pullup_failed; | 
|---|
| 533 | uint64_t        brhf_arp_bad_hw_type; | 
|---|
| 534 | uint64_t        brhf_arp_bad_pro_type; | 
|---|
| 535 | uint64_t        brhf_arp_bad_hw_len; | 
|---|
| 536 | uint64_t        brhf_arp_bad_pro_len; | 
|---|
| 537 | uint64_t        brhf_arp_bad_op; | 
|---|
| 538 | uint64_t        brhf_arp_bad_sha; | 
|---|
| 539 | uint64_t        brhf_arp_bad_spa; | 
|---|
| 540 |  | 
|---|
| 541 | uint64_t        brhf_ip_ok; | 
|---|
| 542 | uint64_t        brhf_ip_too_small; | 
|---|
| 543 | uint64_t        brhf_ip_pullup_failed; | 
|---|
| 544 | uint64_t        brhf_ip_bad_srcaddr; | 
|---|
| 545 | uint64_t        brhf_ip_bad_proto; | 
|---|
| 546 |  | 
|---|
| 547 | uint64_t        brhf_dhcp_too_small; | 
|---|
| 548 | uint64_t        brhf_dhcp_bad_op; | 
|---|
| 549 | uint64_t        brhf_dhcp_bad_htype; | 
|---|
| 550 | uint64_t        brhf_dhcp_bad_hlen; | 
|---|
| 551 | uint64_t        brhf_dhcp_bad_chaddr; | 
|---|
| 552 | uint64_t        brhf_dhcp_bad_ciaddr; | 
|---|
| 553 | }; | 
|---|
| 554 |  | 
|---|
| 555 | #ifdef XNU_KERNEL_PRIVATE | 
|---|
| 556 |  | 
|---|
| 557 | extern u_int8_t bstp_etheraddr[ETHER_ADDR_LEN]; | 
|---|
| 558 |  | 
|---|
| 559 | int     bridgeattach(int); | 
|---|
| 560 |  | 
|---|
| 561 | #endif /* XNU_KERNEL_PRIVATE */ | 
|---|
| 562 |  | 
|---|
| 563 |  | 
|---|
| 564 | #pragma pack(4) | 
|---|
| 565 |  | 
|---|
| 566 | /* | 
|---|
| 567 | * MAC NAT entry list | 
|---|
| 568 | */ | 
|---|
| 569 |  | 
|---|
| 570 | union ifbrip { | 
|---|
| 571 | struct in_addr  ifbrip_addr; | 
|---|
| 572 | struct in6_addr ifbrip_addr6; | 
|---|
| 573 | }; | 
|---|
| 574 |  | 
|---|
| 575 | struct ifbrmne { | 
|---|
| 576 | char            ifbmne_ifname[IFNAMSIZ]; /* member if name */ | 
|---|
| 577 | uint64_t        ifbmne_expire;           /* expiration time */ | 
|---|
| 578 | uint8_t         ifbmne_mac[ETHER_ADDR_LEN];/* MAC address */ | 
|---|
| 579 | uint8_t         ifbmne_reserved; | 
|---|
| 580 | uint8_t         ifbmne_af;              /* AF_INET or AF_INET6 */ | 
|---|
| 581 | union ifbrip    ifbmne_ip; | 
|---|
| 582 | }; | 
|---|
| 583 | #define ifbmne_ip_addr  ifbmne_ip.ifbrip_addr | 
|---|
| 584 | #define ifbmne_ip6_addr ifbmne_ip.ifbrip_addr6 | 
|---|
| 585 |  | 
|---|
| 586 | #ifndef XNU_KERNEL_PRIVATE | 
|---|
| 587 |  | 
|---|
| 588 | struct ifbrmnelist { | 
|---|
| 589 | uint32_t        ifbml_len;      /* buffer size (multiple of elsize) */ | 
|---|
| 590 | uint16_t        ifbml_elsize;   /* sizeof(ifbrmne) */ | 
|---|
| 591 | uint16_t        ifbml_pad; | 
|---|
| 592 | caddr_t         ifbml_buf; | 
|---|
| 593 | }; | 
|---|
| 594 |  | 
|---|
| 595 | #else /* XNU_KERNEL_PRIVATE */ | 
|---|
| 596 |  | 
|---|
| 597 | struct ifbrmnelist32 { | 
|---|
| 598 | uint32_t        ifbml_len;      /* buffer size */ | 
|---|
| 599 | uint16_t        ifbml_elsize;   /* sizeof(ifbrmne) */ | 
|---|
| 600 | uint16_t        ifbml_pad; | 
|---|
| 601 | user32_addr_t   ifbml_buf; | 
|---|
| 602 | }; | 
|---|
| 603 |  | 
|---|
| 604 | struct ifbrmnelist64 { | 
|---|
| 605 | uint32_t        ifbml_len;      /* buffer size */ | 
|---|
| 606 | uint16_t        ifbml_elsize;   /* sizeof(ifbrmne) */ | 
|---|
| 607 | uint16_t        ifbml_pad; | 
|---|
| 608 | user64_addr_t   ifbml_buf; | 
|---|
| 609 | }; | 
|---|
| 610 |  | 
|---|
| 611 | #endif /* XNU_KERNEL_PRIVATE */ | 
|---|
| 612 |  | 
|---|
| 613 |  | 
|---|
| 614 | /* | 
|---|
| 615 | * Bridge member-specific request structure | 
|---|
| 616 | */ | 
|---|
| 617 |  | 
|---|
| 618 | #ifndef XNU_KERNEL_PRIVATE | 
|---|
| 619 |  | 
|---|
| 620 | struct ifbrmreq { | 
|---|
| 621 | char            brmr_ifname[IFNAMSIZ]; /* member if name */ | 
|---|
| 622 | uint32_t        brmr_len;      /* buffer size (in/out) */ | 
|---|
| 623 | uint32_t        brmr_elsize;   /* element size (out) */ | 
|---|
| 624 | caddr_t         brmr_buf;      /* buffer */ | 
|---|
| 625 | }; | 
|---|
| 626 |  | 
|---|
| 627 | #else /* XNU_KERNEL_PRIVATE */ | 
|---|
| 628 |  | 
|---|
| 629 | struct ifbrmreq32 { | 
|---|
| 630 | char            brmr_ifname[IFNAMSIZ]; /* member if name */ | 
|---|
| 631 | uint32_t        brmr_len;      /* buffer size (in/out) */ | 
|---|
| 632 | uint32_t        brmr_elsize;   /* element size (out) */ | 
|---|
| 633 | user32_addr_t   brmr_buf;      /* buffer */ | 
|---|
| 634 | }; | 
|---|
| 635 |  | 
|---|
| 636 | struct ifbrmreq64 { | 
|---|
| 637 | char            brmr_ifname[IFNAMSIZ]; /* member if name */ | 
|---|
| 638 | uint32_t        brmr_len;      /* buffer size (in/out) */ | 
|---|
| 639 | uint32_t        brmr_elsize;   /* element size (out) */ | 
|---|
| 640 | user64_addr_t   brmr_buf;      /* buffer */ | 
|---|
| 641 | }; | 
|---|
| 642 |  | 
|---|
| 643 | #endif /* XNU_KERNEL_PRIVATE */ | 
|---|
| 644 |  | 
|---|
| 645 | struct bripstats { | 
|---|
| 646 | uint64_t        bips_ip; | 
|---|
| 647 | uint64_t        bips_ip6; | 
|---|
| 648 | uint64_t        bips_udp; | 
|---|
| 649 | uint64_t        bips_tcp; | 
|---|
| 650 |  | 
|---|
| 651 | uint64_t        bips_bad_ip; | 
|---|
| 652 | uint64_t        bips_bad_ip6; | 
|---|
| 653 | uint64_t        bips_bad_udp; | 
|---|
| 654 | uint64_t        bips_bad_tcp; | 
|---|
| 655 | }; | 
|---|
| 656 |  | 
|---|
| 657 | struct brcsumstats { | 
|---|
| 658 | uint64_t        brcs_ip_checksum; | 
|---|
| 659 | uint64_t        brcs_udp_checksum; | 
|---|
| 660 | uint64_t        brcs_tcp_checksum; | 
|---|
| 661 | }; | 
|---|
| 662 |  | 
|---|
| 663 | /* | 
|---|
| 664 | * Bridge member statistics | 
|---|
| 665 | * - "in" and "out" are from the perspective of the bridge: | 
|---|
| 666 | *      in: packets received from the bridge member | 
|---|
| 667 | *      out: packets destined to the bridge member | 
|---|
| 668 | * - only available when IFBIF_CHECKSUM_OFFLOAD is enabled on the | 
|---|
| 669 | *   interface | 
|---|
| 670 | */ | 
|---|
| 671 | struct ifbrmstats { | 
|---|
| 672 | struct bripstats        brms_in_ip; | 
|---|
| 673 | struct bripstats        brms_out_ip; | 
|---|
| 674 |  | 
|---|
| 675 | struct brcsumstats      brms_in_computed_cksum; | 
|---|
| 676 |  | 
|---|
| 677 | struct brcsumstats      brms_out_cksum_good; | 
|---|
| 678 | struct brcsumstats      brms_out_cksum_good_hw; | 
|---|
| 679 |  | 
|---|
| 680 | struct brcsumstats      brms_out_cksum_bad; | 
|---|
| 681 | struct brcsumstats      brms_out_cksum_bad_hw; | 
|---|
| 682 | }; | 
|---|
| 683 |  | 
|---|
| 684 | #pragma pack() | 
|---|
| 685 |  | 
|---|
| 686 | #endif /* PRIVATE */ | 
|---|
| 687 | #endif /* !_NET_IF_BRIDGEVAR_H_ */ | 
|---|
| 688 |  | 
|---|