2 * Copyright (c) 2004-2014 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 * Copyright 2001 Wasabi Systems, Inc.
31 * All rights reserved.
33 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
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
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.
65 * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net)
66 * All rights reserved.
68 * Redistribution and use in source and binary forms, with or without
69 * modification, are permitted provided that the following conditions
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.
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.
94 * OpenBSD: if_bridge.h,v 1.14 2001/03/22 03:48:29 jason Exp
100 * Data structure and control definitions for bridge interfaces.
103 #ifndef _NET_IF_BRIDGEVAR_H_
104 #define _NET_IF_BRIDGEVAR_H_
108 #include <sys/queue.h>
111 #include <net/ethernet.h>
112 #include <netinet/in.h>
115 * Commands used in the SIOCSDRVSPEC ioctl. Note the lookup of the
116 * bridge interface itself is keyed off the ifdrv structure.
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) */
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 */
159 * Generic bridge control request.
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 */
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 */
196 #define IFBIFBITS "\020\001LEARNING\002DISCOVER\003STP\004SPAN" \
197 "\005STICKY\006EDGE\007AUTOEDGE\010PTP" \
198 "\011AUTOPTP\014PRIVATE" \
201 #define IFBIFMASK ~(IFBIF_BSTP_EDGE|IFBIF_BSTP_AUTOEDGE|IFBIF_BSTP_PTP| \
202 IFBIF_BSTP_AUTOPTP|IFBIF_BSTP_ADMEDGE| \
203 IFBIF_BSTP_ADMCOST) /* not saved */
206 #define IFBF_FLUSHDYN 0x00 /* flush learned addresses only */
207 #define IFBF_FLUSHALL 0x01 /* flush all addresses */
210 #define IFBF_FILT_USEIPF 0x00000001 /* run pf hooks on the bridge
212 #define IFBF_FILT_MEMBER 0x00000002 /* run pf hooks on the member
214 #define IFBF_FILT_ONLYIP 0x00000004 /* only pass IP[46] packets when
216 #define IFBF_FILT_MASK 0x00000007 /* mask of valid values */
219 * Interface list structure.
224 #ifndef XNU_KERNEL_PRIVATE
227 uint32_t ifbic_len
; /* buffer size */
230 struct ifbreq
*ifbicu_req
;
231 #define ifbic_buf ifbic_ifbicu.ifbicu_buf
232 #define ifbic_req ifbic_ifbicu.ifbicu_req
236 #else /* XNU_KERNEL_PRIVATE */
239 uint32_t ifbic_len
; /* buffer size */
241 user32_addr_t ifbicu_buf
;
242 user32_addr_t ifbicu_req
;
243 #define ifbic_buf ifbic_ifbicu.ifbicu_buf
244 #define ifbic_req ifbic_ifbicu.ifbicu_req
249 uint32_t ifbic_len
; /* buffer size */
251 user64_addr_t ifbicu_buf
;
252 user64_addr_t ifbicu_req
;
255 #endif /* XNU_KERNEL_PRIVATE */
260 * Bridge address request.
265 #ifndef XNU_KERNEL_PRIVATE
268 char ifba_ifsname
[IFNAMSIZ
]; /* member if name */
269 unsigned long ifba_expire
; /* address expire time */
270 uint8_t ifba_flags
; /* address flags */
271 uint8_t ifba_dst
[ETHER_ADDR_LEN
];/* destination address */
272 uint16_t ifba_vlan
; /* vlan id */
275 #else /* XNU_KERNEL_PRIVATE */
278 char ifba_ifsname
[IFNAMSIZ
]; /* member if name */
279 uint32_t ifba_expire
; /* address expire time */
280 uint8_t ifba_flags
; /* address flags */
281 uint8_t ifba_dst
[ETHER_ADDR_LEN
];/* destination address */
282 uint16_t ifba_vlan
; /* vlan id */
286 char ifba_ifsname
[IFNAMSIZ
]; /* member if name */
287 uint64_t ifba_expire
; /* address expire time */
288 uint8_t ifba_flags
; /* address flags */
289 uint8_t ifba_dst
[ETHER_ADDR_LEN
];/* destination address */
290 uint16_t ifba_vlan
; /* vlan id */
292 #endif /* XNU_KERNEL_PRIVATE */
296 #define IFBAF_TYPEMASK 0x03 /* address type mask */
297 #define IFBAF_DYNAMIC 0x00 /* dynamically learned address */
298 #define IFBAF_STATIC 0x01 /* static address */
299 #define IFBAF_STICKY 0x02 /* sticky address */
301 #define IFBAFBITS "\020\1STATIC\2STICKY"
304 * Address list structure.
309 #ifndef XNU_KERNEL_PRIVATE
312 uint32_t ifbac_len
; /* buffer size */
315 struct ifbareq
*ifbacu_req
;
316 #define ifbac_buf ifbac_ifbacu.ifbacu_buf
317 #define ifbac_req ifbac_ifbacu.ifbacu_req
321 #else /* XNU_KERNEL_PRIVATE */
324 uint32_t ifbac_len
; /* buffer size */
326 user32_addr_t ifbacu_buf
;
327 user32_addr_t ifbacu_req
;
328 #define ifbac_buf ifbac_ifbacu.ifbacu_buf
329 #define ifbac_req ifbac_ifbacu.ifbacu_req
334 uint32_t ifbac_len
; /* buffer size */
336 user64_addr_t ifbacu_buf
;
337 user64_addr_t ifbacu_req
;
340 #endif /* XNU_KERNEL_PRIVATE */
345 * Bridge parameter structure.
352 uint32_t ifbrpu_int32
;
353 uint16_t ifbrpu_int16
;
360 #define ifbrp_csize ifbrp_ifbrpu.ifbrpu_int32 /* cache size */
361 #define ifbrp_ctime ifbrp_ifbrpu.ifbrpu_int32 /* cache time (sec) */
362 #define ifbrp_prio ifbrp_ifbrpu.ifbrpu_int16 /* bridge priority */
363 #define ifbrp_proto ifbrp_ifbrpu.ifbrpu_int8 /* bridge protocol */
364 #define ifbrp_txhc ifbrp_ifbrpu.ifbrpu_int8 /* bpdu tx holdcount */
365 #define ifbrp_hellotime ifbrp_ifbrpu.ifbrpu_int8 /* hello time (sec) */
366 #define ifbrp_fwddelay ifbrp_ifbrpu.ifbrpu_int8 /* fwd time (sec) */
367 #define ifbrp_maxage ifbrp_ifbrpu.ifbrpu_int8 /* max age (sec) */
368 #define ifbrp_cexceeded ifbrp_ifbrpu.ifbrpu_int32 /* # of cache dropped
370 #define ifbrp_filter ifbrp_ifbrpu.ifbrpu_int32 /* filtering flags */
373 * Bridge current operational parameters structure.
378 #ifndef XNU_KERNEL_PRIVATE
381 uint8_t ifbop_holdcount
;
382 uint8_t ifbop_maxage
;
383 uint8_t ifbop_hellotime
;
384 uint8_t ifbop_fwddelay
;
385 uint8_t ifbop_protocol
;
386 uint16_t ifbop_priority
;
387 uint16_t ifbop_root_port
;
388 uint32_t ifbop_root_path_cost
;
389 uint64_t ifbop_bridgeid
;
390 uint64_t ifbop_designated_root
;
391 uint64_t ifbop_designated_bridge
;
392 struct timeval ifbop_last_tc_time
;
395 #else /* XNU_KERNEL_PRIVATE */
398 uint8_t ifbop_holdcount
;
399 uint8_t ifbop_maxage
;
400 uint8_t ifbop_hellotime
;
401 uint8_t ifbop_fwddelay
;
402 uint8_t ifbop_protocol
;
403 uint16_t ifbop_priority
;
404 uint16_t ifbop_root_port
;
405 uint32_t ifbop_root_path_cost
;
406 uint64_t ifbop_bridgeid
;
407 uint64_t ifbop_designated_root
;
408 uint64_t ifbop_designated_bridge
;
409 struct timeval ifbop_last_tc_time
;
413 uint8_t ifbop_holdcount
;
414 uint8_t ifbop_maxage
;
415 uint8_t ifbop_hellotime
;
416 uint8_t ifbop_fwddelay
;
417 uint8_t ifbop_protocol
;
418 uint16_t ifbop_priority
;
419 uint16_t ifbop_root_port
;
420 uint32_t ifbop_root_path_cost
;
421 uint64_t ifbop_bridgeid
;
422 uint64_t ifbop_designated_root
;
423 uint64_t ifbop_designated_bridge
;
424 struct timeval ifbop_last_tc_time
;
432 * Bridge member operational STP params structure.
438 uint8_t ifbp_portno
; /* bp STP port number */
439 uint32_t ifbp_fwd_trans
; /* bp STP fwd transitions */
440 uint32_t ifbp_design_cost
; /* bp STP designated cost */
441 uint32_t ifbp_design_port
; /* bp STP designated port */
442 uint64_t ifbp_design_bridge
; /* bp STP designated bridge */
443 uint64_t ifbp_design_root
; /* bp STP designated root */
449 * Bridge STP ports list structure.
454 #ifndef XNU_KERNEL_PRIVATE
457 uint32_t ifbpstp_len
; /* buffer size */
459 caddr_t ifbpstpu_buf
;
460 struct ifbpstpreq
*ifbpstpu_req
;
462 #define ifbpstp_buf ifbpstp_ifbpstpu.ifbpstpu_buf
463 #define ifbpstp_req ifbpstp_ifbpstpu.ifbpstpu_req
466 #else /* XNU_KERNEL_PRIVATE */
468 struct ifbpstpconf32
{
469 uint32_t ifbpstp_len
; /* buffer size */
471 user32_addr_t ifbpstpu_buf
;
472 user32_addr_t ifbpstpu_req
;
473 #define ifbpstp_buf ifbpstp_ifbpstpu.ifbpstpu_buf
474 #define ifbpstp_req ifbpstp_ifbpstpu.ifbpstpu_req
478 struct ifbpstpconf64
{
479 uint32_t ifbpstp_len
; /* buffer size */
481 user64_addr_t ifbpstpu_buf
;
482 user64_addr_t ifbpstpu_req
;
486 #endif /* XNU_KERNEL_PRIVATE */
491 * Bridge member host filter.
494 #define IFBRHF_ENABLED 0x01
495 #define IFBRHF_HWSRC 0x02 /* Valid with enabled flags */
496 #define IFBRHF_IPSRC 0x04 /* Valid with enabled flags */
500 struct ifbrhostfilter
{
501 uint32_t ifbrhf_flags
; /* flags */
502 char ifbrhf_ifsname
[IFNAMSIZ
]; /* member if name */
503 uint8_t ifbrhf_hwsrca
[ETHER_ADDR_LEN
];
504 uint32_t ifbrhf_ipsrc
;
510 * sysctl net.link.bridge.hostfilterstats
512 struct bridge_hostfilter_stats
{
513 uint64_t brhf_bad_ether_type
;
514 uint64_t brhf_bad_ether_srchw_addr
;
516 uint64_t brhf_ether_too_small
;
517 uint64_t brhf_ether_pullup_failed
;
519 uint64_t brhf_arp_ok
;
520 uint64_t brhf_arp_too_small
;
521 uint64_t brhf_arp_pullup_failed
;
522 uint64_t brhf_arp_bad_hw_type
;
523 uint64_t brhf_arp_bad_pro_type
;
524 uint64_t brhf_arp_bad_hw_len
;
525 uint64_t brhf_arp_bad_pro_len
;
526 uint64_t brhf_arp_bad_op
;
527 uint64_t brhf_arp_bad_sha
;
528 uint64_t brhf_arp_bad_spa
;
531 uint64_t brhf_ip_too_small
;
532 uint64_t brhf_ip_pullup_failed
;
533 uint64_t brhf_ip_bad_srcaddr
;
534 uint64_t brhf_ip_bad_proto
;
536 uint64_t brhf_dhcp_too_small
;
537 uint64_t brhf_dhcp_bad_op
;
538 uint64_t brhf_dhcp_bad_htype
;
539 uint64_t brhf_dhcp_bad_hlen
;
540 uint64_t brhf_dhcp_bad_chaddr
;
541 uint64_t brhf_dhcp_bad_ciaddr
;
544 #ifdef XNU_KERNEL_PRIVATE
546 extern u_int8_t bstp_etheraddr
[ETHER_ADDR_LEN
];
548 int bridgeattach(int);
550 #endif /* XNU_KERNEL_PRIVATE */
560 struct in_addr ifbrip_addr
;
561 struct in6_addr ifbrip_addr6
;
565 char ifbmne_ifname
[IFNAMSIZ
]; /* member if name */
566 uint64_t ifbmne_expire
; /* expiration time */
567 uint8_t ifbmne_mac
[ETHER_ADDR_LEN
];/* MAC address */
568 uint8_t ifbmne_reserved
;
569 uint8_t ifbmne_af
; /* AF_INET or AF_INET6 */
570 union ifbrip ifbmne_ip
;
572 #define ifbmne_ip_addr ifbmne_ip.ifbrip_addr
573 #define ifbmne_ip6_addr ifbmne_ip.ifbrip_addr6
575 #ifndef XNU_KERNEL_PRIVATE
578 uint32_t ifbml_len
; /* buffer size (multiple of elsize) */
579 uint16_t ifbml_elsize
; /* sizeof(ifbrmacnatent) */
584 #else /* XNU_KERNEL_PRIVATE */
586 struct ifbrmnelist32
{
587 uint32_t ifbml_len
; /* buffer size */
588 uint16_t ifbml_elsize
; /* sizeof(ifbrmacnatent) */
590 user32_addr_t ifbml_buf
;
593 struct ifbrmnelist64
{
594 uint32_t ifbml_len
; /* buffer size */
595 uint16_t ifbml_elsize
; /* sizeof(ifbrmacnatent) */
597 user64_addr_t ifbml_buf
;
600 #endif /* XNU_KERNEL_PRIVATE */
605 #endif /* !_NET_IF_BRIDGEVAR_H_ */