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>
114 * Commands used in the SIOCSDRVSPEC ioctl. Note the lookup of the
115 * bridge interface itself is keyed off the ifdrv structure.
117 #define BRDGADD 0 /* add bridge member (ifbreq) */
118 #define BRDGDEL 1 /* delete bridge member (ifbreq) */
119 #define BRDGGIFFLGS 2 /* get member if flags (ifbreq) */
120 #define BRDGSIFFLGS 3 /* set member if flags (ifbreq) */
121 #define BRDGSCACHE 4 /* set cache size (ifbrparam) */
122 #define BRDGGCACHE 5 /* get cache size (ifbrparam) */
123 #define BRDGGIFS 6 /* get member list (ifbifconf) */
124 #define BRDGRTS 7 /* get address list (ifbaconf) */
125 #define BRDGSADDR 8 /* set static address (ifbareq) */
126 #define BRDGSTO 9 /* set cache timeout (ifbrparam) */
127 #define BRDGGTO 10 /* get cache timeout (ifbrparam) */
128 #define BRDGDADDR 11 /* delete address (ifbareq) */
129 #define BRDGFLUSH 12 /* flush address cache (ifbreq) */
131 #define BRDGGPRI 13 /* get priority (ifbrparam) */
132 #define BRDGSPRI 14 /* set priority (ifbrparam) */
133 #define BRDGGHT 15 /* get hello time (ifbrparam) */
134 #define BRDGSHT 16 /* set hello time (ifbrparam) */
135 #define BRDGGFD 17 /* get forward delay (ifbrparam) */
136 #define BRDGSFD 18 /* set forward delay (ifbrparam) */
137 #define BRDGGMA 19 /* get max age (ifbrparam) */
138 #define BRDGSMA 20 /* set max age (ifbrparam) */
139 #define BRDGSIFPRIO 21 /* set if priority (ifbreq) */
140 #define BRDGSIFCOST 22 /* set if path cost (ifbreq) */
141 #define BRDGGFILT 23 /* get filter flags (ifbrparam) */
142 #define BRDGSFILT 24 /* set filter flags (ifbrparam) */
143 #define BRDGPURGE 25 /* purge address cache for a particular interface (ifbreq) */
144 #define BRDGADDS 26 /* add bridge span member (ifbreq) */
145 #define BRDGDELS 27 /* delete bridge span member (ifbreq) */
146 #define BRDGPARAM 28 /* get bridge STP params (ifbropreq) */
147 #define BRDGGRTE 29 /* get cache drops (ifbrparam) */
148 #define BRDGGIFSSTP 30 /* get member STP params list (ifbpstpconf) */
149 #define BRDGSPROTO 31 /* set protocol (ifbrparam) */
150 #define BRDGSTXHC 32 /* set tx hold count (ifbrparam) */
151 #define BRDGSIFAMAX 33 /* set max interface addrs (ifbreq) */
152 #define BRDGGHOSTFILTER 34 /* set max interface addrs (ifbrhostfilter) */
153 #define BRDGSHOSTFILTER 35 /* set max interface addrs (ifbrhostfilter) */
156 * Generic bridge control request.
161 char ifbr_ifsname
[IFNAMSIZ
]; /* member if name */
162 uint32_t ifbr_ifsflags
; /* member if flags */
163 uint32_t ifbr_stpflags
; /* member if STP flags */
164 uint32_t ifbr_path_cost
; /* member if STP cost */
165 uint8_t ifbr_portno
; /* member if port number */
166 uint8_t ifbr_priority
; /* member if STP priority */
167 uint8_t ifbr_proto
; /* member if STP protocol */
168 uint8_t ifbr_role
; /* member if STP role */
169 uint8_t ifbr_state
; /* member if STP state */
170 uint32_t ifbr_addrcnt
; /* member if addr number */
171 uint32_t ifbr_addrmax
; /* member if addr max */
172 uint32_t ifbr_addrexceeded
; /* member if addr violations */
178 /* BRDGGIFFLAGS, BRDGSIFFLAGS */
179 #define IFBIF_LEARNING 0x0001 /* if can learn */
180 #define IFBIF_DISCOVER 0x0002 /* if sends packets w/ unknown dest. */
181 #define IFBIF_STP 0x0004 /* if participates in spanning tree */
182 #define IFBIF_SPAN 0x0008 /* if is a span port */
183 #define IFBIF_STICKY 0x0010 /* if learned addresses stick */
184 #define IFBIF_BSTP_EDGE 0x0020 /* member stp edge port */
185 #define IFBIF_BSTP_AUTOEDGE 0x0040 /* member stp autoedge enabled */
186 #define IFBIF_BSTP_PTP 0x0080 /* member stp point to point */
187 #define IFBIF_BSTP_AUTOPTP 0x0100 /* member stp autoptp enabled */
188 #define IFBIF_BSTP_ADMEDGE 0x0200 /* member stp admin edge enabled */
189 #define IFBIF_BSTP_ADMCOST 0x0400 /* member stp admin path cost */
190 #define IFBIF_PRIVATE 0x0800 /* if is a private segment */
192 #define IFBIFBITS "\020\001LEARNING\002DISCOVER\003STP\004SPAN" \
193 "\005STICKY\014PRIVATE\006EDGE\007AUTOEDGE\010PTP" \
195 #define IFBIFMASK ~(IFBIF_BSTP_EDGE|IFBIF_BSTP_AUTOEDGE|IFBIF_BSTP_PTP| \
196 IFBIF_BSTP_AUTOPTP|IFBIF_BSTP_ADMEDGE| \
197 IFBIF_BSTP_ADMCOST) /* not saved */
200 #define IFBF_FLUSHDYN 0x00 /* flush learned addresses only */
201 #define IFBF_FLUSHALL 0x01 /* flush all addresses */
204 #define IFBF_FILT_USEIPF 0x00000001 /* run pfil hooks on the bridge
206 #define IFBF_FILT_MEMBER 0x00000002 /* run pfil hooks on the member
208 #define IFBF_FILT_ONLYIP 0x00000004 /* only pass IP[46] packets when
210 #define IFBF_FILT_MASK 0x00000007 /* mask of valid values */
213 /* APPLE MODIFICATION <jhw@apple.com>: Default is to pass non-IP packets. */
214 #define IFBF_FILT_DEFAULT ( IFBF_FILT_USEIPF | IFBF_FILT_MEMBER )
216 #define IFBF_FILT_DEFAULT (IFBF_FILT_USEIPF | \
222 * Interface list structure.
227 #ifndef XNU_KERNEL_PRIVATE
230 uint32_t ifbic_len
; /* buffer size */
233 struct ifbreq
*ifbicu_req
;
234 #define ifbic_buf ifbic_ifbicu.ifbicu_buf
235 #define ifbic_req ifbic_ifbicu.ifbicu_req
239 #else /* XNU_KERNEL_PRIVATE */
242 uint32_t ifbic_len
; /* buffer size */
244 user32_addr_t ifbicu_buf
;
245 user32_addr_t ifbicu_req
;
246 #define ifbic_buf ifbic_ifbicu.ifbicu_buf
247 #define ifbic_req ifbic_ifbicu.ifbicu_req
252 uint32_t ifbic_len
; /* buffer size */
254 user64_addr_t ifbicu_buf
;
255 user64_addr_t ifbicu_req
;
258 #endif /* XNU_KERNEL_PRIVATE */
263 * Bridge address request.
268 #ifndef XNU_KERNEL_PRIVATE
271 char ifba_ifsname
[IFNAMSIZ
]; /* member if name */
272 unsigned long ifba_expire
; /* address expire time */
273 uint8_t ifba_flags
; /* address flags */
274 uint8_t ifba_dst
[ETHER_ADDR_LEN
];/* destination address */
275 uint16_t ifba_vlan
; /* vlan id */
278 #else /* XNU_KERNEL_PRIVATE */
281 char ifba_ifsname
[IFNAMSIZ
]; /* member if name */
282 uint32_t ifba_expire
; /* address expire time */
283 uint8_t ifba_flags
; /* address flags */
284 uint8_t ifba_dst
[ETHER_ADDR_LEN
];/* destination address */
285 uint16_t ifba_vlan
; /* vlan id */
289 char ifba_ifsname
[IFNAMSIZ
]; /* member if name */
290 uint64_t ifba_expire
; /* address expire time */
291 uint8_t ifba_flags
; /* address flags */
292 uint8_t ifba_dst
[ETHER_ADDR_LEN
];/* destination address */
293 uint16_t ifba_vlan
; /* vlan id */
295 #endif /* XNU_KERNEL_PRIVATE */
299 #define IFBAF_TYPEMASK 0x03 /* address type mask */
300 #define IFBAF_DYNAMIC 0x00 /* dynamically learned address */
301 #define IFBAF_STATIC 0x01 /* static address */
302 #define IFBAF_STICKY 0x02 /* sticky address */
304 #define IFBAFBITS "\020\1STATIC\2STICKY"
307 * Address list structure.
312 #ifndef XNU_KERNEL_PRIVATE
315 uint32_t ifbac_len
; /* buffer size */
318 struct ifbareq
*ifbacu_req
;
319 #define ifbac_buf ifbac_ifbacu.ifbacu_buf
320 #define ifbac_req ifbac_ifbacu.ifbacu_req
324 #else /* XNU_KERNEL_PRIVATE */
327 uint32_t ifbac_len
; /* buffer size */
329 user32_addr_t ifbacu_buf
;
330 user32_addr_t ifbacu_req
;
331 #define ifbac_buf ifbac_ifbacu.ifbacu_buf
332 #define ifbac_req ifbac_ifbacu.ifbacu_req
337 uint32_t ifbac_len
; /* buffer size */
339 user64_addr_t ifbacu_buf
;
340 user64_addr_t ifbacu_req
;
343 #endif /* XNU_KERNEL_PRIVATE */
348 * Bridge parameter structure.
355 uint32_t ifbrpu_int32
;
356 uint16_t ifbrpu_int16
;
363 #define ifbrp_csize ifbrp_ifbrpu.ifbrpu_int32 /* cache size */
364 #define ifbrp_ctime ifbrp_ifbrpu.ifbrpu_int32 /* cache time (sec) */
365 #define ifbrp_prio ifbrp_ifbrpu.ifbrpu_int16 /* bridge priority */
366 #define ifbrp_proto ifbrp_ifbrpu.ifbrpu_int8 /* bridge protocol */
367 #define ifbrp_txhc ifbrp_ifbrpu.ifbrpu_int8 /* bpdu tx holdcount */
368 #define ifbrp_hellotime ifbrp_ifbrpu.ifbrpu_int8 /* hello time (sec) */
369 #define ifbrp_fwddelay ifbrp_ifbrpu.ifbrpu_int8 /* fwd time (sec) */
370 #define ifbrp_maxage ifbrp_ifbrpu.ifbrpu_int8 /* max age (sec) */
371 #define ifbrp_cexceeded ifbrp_ifbrpu.ifbrpu_int32 /* # of cache dropped
373 #define ifbrp_filter ifbrp_ifbrpu.ifbrpu_int32 /* filtering flags */
376 * Bridge current operational parameters structure.
381 #ifndef XNU_KERNEL_PRIVATE
384 uint8_t ifbop_holdcount
;
385 uint8_t ifbop_maxage
;
386 uint8_t ifbop_hellotime
;
387 uint8_t ifbop_fwddelay
;
388 uint8_t ifbop_protocol
;
389 uint16_t ifbop_priority
;
390 uint16_t ifbop_root_port
;
391 uint32_t ifbop_root_path_cost
;
392 uint64_t ifbop_bridgeid
;
393 uint64_t ifbop_designated_root
;
394 uint64_t ifbop_designated_bridge
;
395 struct timeval ifbop_last_tc_time
;
398 #else /* XNU_KERNEL_PRIVATE */
401 uint8_t ifbop_holdcount
;
402 uint8_t ifbop_maxage
;
403 uint8_t ifbop_hellotime
;
404 uint8_t ifbop_fwddelay
;
405 uint8_t ifbop_protocol
;
406 uint16_t ifbop_priority
;
407 uint16_t ifbop_root_port
;
408 uint32_t ifbop_root_path_cost
;
409 uint64_t ifbop_bridgeid
;
410 uint64_t ifbop_designated_root
;
411 uint64_t ifbop_designated_bridge
;
412 struct timeval ifbop_last_tc_time
;
416 uint8_t ifbop_holdcount
;
417 uint8_t ifbop_maxage
;
418 uint8_t ifbop_hellotime
;
419 uint8_t ifbop_fwddelay
;
420 uint8_t ifbop_protocol
;
421 uint16_t ifbop_priority
;
422 uint16_t ifbop_root_port
;
423 uint32_t ifbop_root_path_cost
;
424 uint64_t ifbop_bridgeid
;
425 uint64_t ifbop_designated_root
;
426 uint64_t ifbop_designated_bridge
;
427 struct timeval ifbop_last_tc_time
;
435 * Bridge member operational STP params structure.
441 uint8_t ifbp_portno
; /* bp STP port number */
442 uint32_t ifbp_fwd_trans
; /* bp STP fwd transitions */
443 uint32_t ifbp_design_cost
; /* bp STP designated cost */
444 uint32_t ifbp_design_port
; /* bp STP designated port */
445 uint64_t ifbp_design_bridge
; /* bp STP designated bridge */
446 uint64_t ifbp_design_root
; /* bp STP designated root */
452 * Bridge STP ports list structure.
457 #ifndef XNU_KERNEL_PRIVATE
460 uint32_t ifbpstp_len
; /* buffer size */
462 caddr_t ifbpstpu_buf
;
463 struct ifbpstpreq
*ifbpstpu_req
;
465 #define ifbpstp_buf ifbpstp_ifbpstpu.ifbpstpu_buf
466 #define ifbpstp_req ifbpstp_ifbpstpu.ifbpstpu_req
469 #else /* XNU_KERNEL_PRIVATE */
471 struct ifbpstpconf32
{
472 uint32_t ifbpstp_len
; /* buffer size */
474 user32_addr_t ifbpstpu_buf
;
475 user32_addr_t ifbpstpu_req
;
476 #define ifbpstp_buf ifbpstp_ifbpstpu.ifbpstpu_buf
477 #define ifbpstp_req ifbpstp_ifbpstpu.ifbpstpu_req
481 struct ifbpstpconf64
{
482 uint32_t ifbpstp_len
; /* buffer size */
484 user64_addr_t ifbpstpu_buf
;
485 user64_addr_t ifbpstpu_req
;
489 #endif /* XNU_KERNEL_PRIVATE */
494 * Bridge member host filter.
497 #define IFBRHF_ENABLED 0x01
498 #define IFBRHF_HWSRC 0x02 /* Valid with enabled flags */
499 #define IFBRHF_IPSRC 0x04 /* Valid with enabled flags */
503 struct ifbrhostfilter
{
504 uint32_t ifbrhf_flags
; /* flags */
505 char ifbrhf_ifsname
[IFNAMSIZ
]; /* member if name */
506 uint8_t ifbrhf_hwsrca
[ETHER_ADDR_LEN
];
507 uint32_t ifbrhf_ipsrc
;
513 * sysctl net.link.bridge.hostfilterstats
515 struct bridge_hostfilter_stats
{
516 uint64_t brhf_bad_ether_type
;
517 uint64_t brhf_bad_ether_srchw_addr
;
519 uint64_t brhf_ether_too_small
;
520 uint64_t brhf_ether_pullup_failed
;
522 uint64_t brhf_arp_ok
;
523 uint64_t brhf_arp_too_small
;
524 uint64_t brhf_arp_pullup_failed
;
525 uint64_t brhf_arp_bad_hw_type
;
526 uint64_t brhf_arp_bad_pro_type
;
527 uint64_t brhf_arp_bad_hw_len
;
528 uint64_t brhf_arp_bad_pro_len
;
529 uint64_t brhf_arp_bad_op
;
530 uint64_t brhf_arp_bad_sha
;
531 uint64_t brhf_arp_bad_spa
;
534 uint64_t brhf_ip_too_small
;
535 uint64_t brhf_ip_pullup_failed
;
536 uint64_t brhf_ip_bad_srcaddr
;
537 uint64_t brhf_ip_bad_proto
;
539 uint64_t brhf_dhcp_too_small
;
540 uint64_t brhf_dhcp_bad_op
;
541 uint64_t brhf_dhcp_bad_htype
;
542 uint64_t brhf_dhcp_bad_hlen
;
543 uint64_t brhf_dhcp_bad_chaddr
;
544 uint64_t brhf_dhcp_bad_ciaddr
;
547 #ifdef XNU_KERNEL_PRIVATE
549 extern u_int8_t bstp_etheraddr
[ETHER_ADDR_LEN
];
551 int bridgeattach(int);
553 #endif /* XNU_KERNEL_PRIVATE */
555 #endif /* !_NET_IF_BRIDGEVAR_H_ */