1 /* $NetBSD: if_bridgevar.h,v 1.4 2003/07/08 07:13:50 itojun Exp $ */
3 * Copyright (c) 2004-2010 Apple Inc. All rights reserved.
5 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. The rights granted to you under the License
11 * may not be used to create, or enable the creation or redistribution of,
12 * unlawful or unlicensed copies of an Apple operating system, or to
13 * circumvent, violate, or enable the circumvention or violation of, any
14 * terms of an Apple operating system software license agreement.
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this file.
19 * The Original Code and all software distributed under the License are
20 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
21 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
22 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
24 * Please see the License for the specific language governing rights and
25 * limitations under the License.
27 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
31 * Copyright 2001 Wasabi Systems, Inc.
32 * All rights reserved.
34 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. All advertising materials mentioning features or use of this software
45 * must display the following acknowledgement:
46 * This product includes software developed for the NetBSD Project by
47 * Wasabi Systems, Inc.
48 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
49 * or promote products derived from this software without specific prior
52 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
54 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
55 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
56 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
57 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
58 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
59 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
60 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
61 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
62 * POSSIBILITY OF SUCH DAMAGE.
66 * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net)
67 * All rights reserved.
69 * Redistribution and use in source and binary forms, with or without
70 * modification, are permitted provided that the following conditions
72 * 1. Redistributions of source code must retain the above copyright
73 * notice, this list of conditions and the following disclaimer.
74 * 2. Redistributions in binary form must reproduce the above copyright
75 * notice, this list of conditions and the following disclaimer in the
76 * documentation and/or other materials provided with the distribution.
77 * 3. All advertising materials mentioning features or use of this software
78 * must display the following acknowledgement:
79 * This product includes software developed by Jason L. Wright
80 * 4. The name of the author may not be used to endorse or promote products
81 * derived from this software without specific prior written permission.
83 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
84 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
85 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
86 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
87 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
88 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
89 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
90 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
91 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
92 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
93 * POSSIBILITY OF SUCH DAMAGE.
95 * OpenBSD: if_bridge.h,v 1.14 2001/03/22 03:48:29 jason Exp
101 * Data structure and control definitions for bridge interfaces.
104 #ifndef _NET_IF_BRIDGEVAR_H_
105 #define _NET_IF_BRIDGEVAR_H_
109 #include <sys/queue.h>
112 #include <net/ethernet.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) */
155 * Generic bridge control request.
160 char ifbr_ifsname
[IFNAMSIZ
]; /* member if name */
161 uint32_t ifbr_ifsflags
; /* member if flags */
162 uint32_t ifbr_stpflags
; /* member if STP flags */
163 uint32_t ifbr_path_cost
; /* member if STP cost */
164 uint8_t ifbr_portno
; /* member if port number */
165 uint8_t ifbr_priority
; /* member if STP priority */
166 uint8_t ifbr_proto
; /* member if STP protocol */
167 uint8_t ifbr_role
; /* member if STP role */
168 uint8_t ifbr_state
; /* member if STP state */
169 uint32_t ifbr_addrcnt
; /* member if addr number */
170 uint32_t ifbr_addrmax
; /* member if addr max */
171 uint32_t ifbr_addrexceeded
; /* member if addr violations */
177 /* BRDGGIFFLAGS, BRDGSIFFLAGS */
178 #define IFBIF_LEARNING 0x0001 /* if can learn */
179 #define IFBIF_DISCOVER 0x0002 /* if sends packets w/ unknown dest. */
180 #define IFBIF_STP 0x0004 /* if participates in spanning tree */
181 #define IFBIF_SPAN 0x0008 /* if is a span port */
182 #define IFBIF_STICKY 0x0010 /* if learned addresses stick */
183 #define IFBIF_BSTP_EDGE 0x0020 /* member stp edge port */
184 #define IFBIF_BSTP_AUTOEDGE 0x0040 /* member stp autoedge enabled */
185 #define IFBIF_BSTP_PTP 0x0080 /* member stp point to point */
186 #define IFBIF_BSTP_AUTOPTP 0x0100 /* member stp autoptp enabled */
187 #define IFBIF_BSTP_ADMEDGE 0x0200 /* member stp admin edge enabled */
188 #define IFBIF_BSTP_ADMCOST 0x0400 /* member stp admin path cost */
189 #define IFBIF_PRIVATE 0x0800 /* if is a private segment */
191 #define IFBIFBITS "\020\001LEARNING\002DISCOVER\003STP\004SPAN" \
192 "\005STICKY\014PRIVATE\006EDGE\007AUTOEDGE\010PTP" \
194 #define IFBIFMASK ~(IFBIF_BSTP_EDGE|IFBIF_BSTP_AUTOEDGE|IFBIF_BSTP_PTP| \
195 IFBIF_BSTP_AUTOPTP|IFBIF_BSTP_ADMEDGE| \
196 IFBIF_BSTP_ADMCOST) /* not saved */
199 #define IFBF_FLUSHDYN 0x00 /* flush learned addresses only */
200 #define IFBF_FLUSHALL 0x01 /* flush all addresses */
203 #define IFBF_FILT_USEIPF 0x00000001 /* run pfil hooks on the bridge
205 #define IFBF_FILT_MEMBER 0x00000002 /* run pfil hooks on the member
207 #define IFBF_FILT_ONLYIP 0x00000004 /* only pass IP[46] packets when
209 #define IFBF_FILT_MASK 0x00000007 /* mask of valid values */
212 /* APPLE MODIFICATION <jhw@apple.com>: Default is to pass non-IP packets. */
213 #define IFBF_FILT_DEFAULT ( IFBF_FILT_USEIPF | IFBF_FILT_MEMBER )
215 #define IFBF_FILT_DEFAULT (IFBF_FILT_USEIPF | \
221 * Interface list structure.
226 #ifndef XNU_KERNEL_PRIVATE
229 uint32_t ifbic_len
; /* buffer size */
232 struct ifbreq
*ifbicu_req
;
233 #define ifbic_buf ifbic_ifbicu.ifbicu_buf
234 #define ifbic_req ifbic_ifbicu.ifbicu_req
238 #else /* XNU_KERNEL_PRIVATE */
241 uint32_t ifbic_len
; /* buffer size */
243 user32_addr_t ifbicu_buf
;
244 user32_addr_t ifbicu_req
;
245 #define ifbic_buf ifbic_ifbicu.ifbicu_buf
246 #define ifbic_req ifbic_ifbicu.ifbicu_req
251 uint32_t ifbic_len
; /* buffer size */
253 user64_addr_t ifbicu_buf
;
254 user64_addr_t ifbicu_req
;
257 #endif /* XNU_KERNEL_PRIVATE */
262 * Bridge address request.
267 #ifndef XNU_KERNEL_PRIVATE
270 char ifba_ifsname
[IFNAMSIZ
]; /* member if name */
271 unsigned long ifba_expire
; /* address expire time */
272 uint8_t ifba_flags
; /* address flags */
273 uint8_t ifba_dst
[ETHER_ADDR_LEN
];/* destination address */
274 uint16_t ifba_vlan
; /* vlan id */
277 #else /* XNU_KERNEL_PRIVATE */
280 char ifba_ifsname
[IFNAMSIZ
]; /* member if name */
281 uint32_t ifba_expire
; /* address expire time */
282 uint8_t ifba_flags
; /* address flags */
283 uint8_t ifba_dst
[ETHER_ADDR_LEN
];/* destination address */
284 uint16_t ifba_vlan
; /* vlan id */
288 char ifba_ifsname
[IFNAMSIZ
]; /* member if name */
289 uint64_t ifba_expire
; /* address expire time */
290 uint8_t ifba_flags
; /* address flags */
291 uint8_t ifba_dst
[ETHER_ADDR_LEN
];/* destination address */
292 uint16_t ifba_vlan
; /* vlan id */
294 #endif /* XNU_KERNEL_PRIVATE */
298 #define IFBAF_TYPEMASK 0x03 /* address type mask */
299 #define IFBAF_DYNAMIC 0x00 /* dynamically learned address */
300 #define IFBAF_STATIC 0x01 /* static address */
301 #define IFBAF_STICKY 0x02 /* sticky address */
303 #define IFBAFBITS "\020\1STATIC\2STICKY"
306 * Address list structure.
311 #ifndef XNU_KERNEL_PRIVATE
314 uint32_t ifbac_len
; /* buffer size */
317 struct ifbareq
*ifbacu_req
;
318 #define ifbac_buf ifbac_ifbacu.ifbacu_buf
319 #define ifbac_req ifbac_ifbacu.ifbacu_req
323 #else /* XNU_KERNEL_PRIVATE */
326 uint32_t ifbac_len
; /* buffer size */
328 user32_addr_t ifbacu_buf
;
329 user32_addr_t ifbacu_req
;
330 #define ifbac_buf ifbac_ifbacu.ifbacu_buf
331 #define ifbac_req ifbac_ifbacu.ifbacu_req
336 uint32_t ifbac_len
; /* buffer size */
338 user64_addr_t ifbacu_buf
;
339 user64_addr_t ifbacu_req
;
342 #endif /* XNU_KERNEL_PRIVATE */
347 * Bridge parameter structure.
354 uint32_t ifbrpu_int32
;
355 uint16_t ifbrpu_int16
;
362 #define ifbrp_csize ifbrp_ifbrpu.ifbrpu_int32 /* cache size */
363 #define ifbrp_ctime ifbrp_ifbrpu.ifbrpu_int32 /* cache time (sec) */
364 #define ifbrp_prio ifbrp_ifbrpu.ifbrpu_int16 /* bridge priority */
365 #define ifbrp_proto ifbrp_ifbrpu.ifbrpu_int8 /* bridge protocol */
366 #define ifbrp_txhc ifbrp_ifbrpu.ifbrpu_int8 /* bpdu tx holdcount */
367 #define ifbrp_hellotime ifbrp_ifbrpu.ifbrpu_int8 /* hello time (sec) */
368 #define ifbrp_fwddelay ifbrp_ifbrpu.ifbrpu_int8 /* fwd time (sec) */
369 #define ifbrp_maxage ifbrp_ifbrpu.ifbrpu_int8 /* max age (sec) */
370 #define ifbrp_cexceeded ifbrp_ifbrpu.ifbrpu_int32 /* # of cache dropped
372 #define ifbrp_filter ifbrp_ifbrpu.ifbrpu_int32 /* filtering flags */
375 * Bridge current operational parameters structure.
380 #ifndef XNU_KERNEL_PRIVATE
383 uint8_t ifbop_holdcount
;
384 uint8_t ifbop_maxage
;
385 uint8_t ifbop_hellotime
;
386 uint8_t ifbop_fwddelay
;
387 uint8_t ifbop_protocol
;
388 uint16_t ifbop_priority
;
389 uint16_t ifbop_root_port
;
390 uint32_t ifbop_root_path_cost
;
391 uint64_t ifbop_bridgeid
;
392 uint64_t ifbop_designated_root
;
393 uint64_t ifbop_designated_bridge
;
394 struct timeval ifbop_last_tc_time
;
397 #else /* XNU_KERNEL_PRIVATE */
400 uint8_t ifbop_holdcount
;
401 uint8_t ifbop_maxage
;
402 uint8_t ifbop_hellotime
;
403 uint8_t ifbop_fwddelay
;
404 uint8_t ifbop_protocol
;
405 uint16_t ifbop_priority
;
406 uint16_t ifbop_root_port
;
407 uint32_t ifbop_root_path_cost
;
408 uint64_t ifbop_bridgeid
;
409 uint64_t ifbop_designated_root
;
410 uint64_t ifbop_designated_bridge
;
411 struct timeval ifbop_last_tc_time
;
415 uint8_t ifbop_holdcount
;
416 uint8_t ifbop_maxage
;
417 uint8_t ifbop_hellotime
;
418 uint8_t ifbop_fwddelay
;
419 uint8_t ifbop_protocol
;
420 uint16_t ifbop_priority
;
421 uint16_t ifbop_root_port
;
422 uint32_t ifbop_root_path_cost
;
423 uint64_t ifbop_bridgeid
;
424 uint64_t ifbop_designated_root
;
425 uint64_t ifbop_designated_bridge
;
426 struct timeval ifbop_last_tc_time
;
434 * Bridge member operational STP params structure.
440 uint8_t ifbp_portno
; /* bp STP port number */
441 uint32_t ifbp_fwd_trans
; /* bp STP fwd transitions */
442 uint32_t ifbp_design_cost
; /* bp STP designated cost */
443 uint32_t ifbp_design_port
; /* bp STP designated port */
444 uint64_t ifbp_design_bridge
; /* bp STP designated bridge */
445 uint64_t ifbp_design_root
; /* bp STP designated root */
451 * Bridge STP ports list structure.
456 #ifndef XNU_KERNEL_PRIVATE
459 uint32_t ifbpstp_len
; /* buffer size */
461 caddr_t ifbpstpu_buf
;
462 struct ifbpstpreq
*ifbpstpu_req
;
464 #define ifbpstp_buf ifbpstp_ifbpstpu.ifbpstpu_buf
465 #define ifbpstp_req ifbpstp_ifbpstpu.ifbpstpu_req
468 #else /* XNU_KERNEL_PRIVATE */
470 struct ifbpstpconf32
{
471 uint32_t ifbpstp_len
; /* buffer size */
473 user32_addr_t ifbpstpu_buf
;
474 user32_addr_t ifbpstpu_req
;
475 #define ifbpstp_buf ifbpstp_ifbpstpu.ifbpstpu_buf
476 #define ifbpstp_req ifbpstp_ifbpstpu.ifbpstpu_req
480 struct ifbpstpconf64
{
481 uint32_t ifbpstp_len
; /* buffer size */
483 user64_addr_t ifbpstpu_buf
;
484 user64_addr_t ifbpstpu_req
;
488 #endif /* XNU_KERNEL_PRIVATE */
493 #ifdef XNU_KERNEL_PRIVATE
495 extern u_int8_t bstp_etheraddr
[ETHER_ADDR_LEN
];
497 int bridgeattach(int);
499 #endif /* XNU_KERNEL_PRIVATE */
501 #endif /* !_NET_IF_BRIDGEVAR_H_ */