]> git.saurik.com Git - apple/xnu.git/blob - bsd/net/if_bridgevar.h
xnu-2050.24.15.tar.gz
[apple/xnu.git] / bsd / net / if_bridgevar.h
1 /* $NetBSD: if_bridgevar.h,v 1.4 2003/07/08 07:13:50 itojun Exp $ */
2 /*
3 * Copyright (c) 2004-2010 Apple Inc. All rights reserved.
4 *
5 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 *
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.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 *
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.
26 *
27 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 */
29
30 /*
31 * Copyright 2001 Wasabi Systems, Inc.
32 * All rights reserved.
33 *
34 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
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
50 * written permission.
51 *
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.
63 */
64
65 /*
66 * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net)
67 * All rights reserved.
68 *
69 * Redistribution and use in source and binary forms, with or without
70 * modification, are permitted provided that the following conditions
71 * are met:
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.
82 *
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.
94 *
95 * OpenBSD: if_bridge.h,v 1.14 2001/03/22 03:48:29 jason Exp
96 *
97 * $FreeBSD$
98 */
99
100 /*
101 * Data structure and control definitions for bridge interfaces.
102 */
103
104 #ifndef _NET_IF_BRIDGEVAR_H_
105 #define _NET_IF_BRIDGEVAR_H_
106
107 #ifdef PRIVATE
108
109 #include <sys/queue.h>
110
111 #include <net/if.h>
112 #include <net/ethernet.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
154 /*
155 * Generic bridge control request.
156 */
157 #pragma pack(4)
158
159 struct ifbreq {
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 */
172 uint8_t pad[32];
173 };
174
175 #pragma pack()
176
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 */
190
191 #define IFBIFBITS "\020\001LEARNING\002DISCOVER\003STP\004SPAN" \
192 "\005STICKY\014PRIVATE\006EDGE\007AUTOEDGE\010PTP" \
193 "\011AUTOPTP"
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 */
197
198 /* BRDGFLUSH */
199 #define IFBF_FLUSHDYN 0x00 /* flush learned addresses only */
200 #define IFBF_FLUSHALL 0x01 /* flush all addresses */
201
202 /* BRDGSFILT */
203 #define IFBF_FILT_USEIPF 0x00000001 /* run pfil hooks on the bridge
204 interface */
205 #define IFBF_FILT_MEMBER 0x00000002 /* run pfil hooks on the member
206 interfaces */
207 #define IFBF_FILT_ONLYIP 0x00000004 /* only pass IP[46] packets when
208 pfil is enabled */
209 #define IFBF_FILT_MASK 0x00000007 /* mask of valid values */
210
211
212 /* APPLE MODIFICATION <jhw@apple.com>: Default is to pass non-IP packets. */
213 #define IFBF_FILT_DEFAULT ( IFBF_FILT_USEIPF | IFBF_FILT_MEMBER )
214 #if 0
215 #define IFBF_FILT_DEFAULT (IFBF_FILT_USEIPF | \
216 IFBF_FILT_MEMBER | \
217 IFBF_FILT_ONLYIP)
218 #endif
219
220 /*
221 * Interface list structure.
222 */
223
224 #pragma pack(4)
225
226 #ifndef XNU_KERNEL_PRIVATE
227
228 struct ifbifconf {
229 uint32_t ifbic_len; /* buffer size */
230 union {
231 caddr_t ifbicu_buf;
232 struct ifbreq *ifbicu_req;
233 #define ifbic_buf ifbic_ifbicu.ifbicu_buf
234 #define ifbic_req ifbic_ifbicu.ifbicu_req
235 } ifbic_ifbicu;
236 };
237
238 #else /* XNU_KERNEL_PRIVATE */
239
240 struct ifbifconf32 {
241 uint32_t ifbic_len; /* buffer size */
242 union {
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
247 } ifbic_ifbicu;
248 };
249
250 struct ifbifconf64 {
251 uint32_t ifbic_len; /* buffer size */
252 union {
253 user64_addr_t ifbicu_buf;
254 user64_addr_t ifbicu_req;
255 } ifbic_ifbicu;
256 };
257 #endif /* XNU_KERNEL_PRIVATE */
258
259 #pragma pack()
260
261 /*
262 * Bridge address request.
263 */
264
265 #pragma pack(4)
266
267 #ifndef XNU_KERNEL_PRIVATE
268
269 struct ifbareq {
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 */
275 };
276
277 #else /* XNU_KERNEL_PRIVATE */
278
279 struct ifbareq32 {
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 */
285 };
286
287 struct ifbareq64 {
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 */
293 };
294 #endif /* XNU_KERNEL_PRIVATE */
295
296 #pragma pack()
297
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 */
302
303 #define IFBAFBITS "\020\1STATIC\2STICKY"
304
305 /*
306 * Address list structure.
307 */
308
309 #pragma pack(4)
310
311 #ifndef XNU_KERNEL_PRIVATE
312
313 struct ifbaconf {
314 uint32_t ifbac_len; /* buffer size */
315 union {
316 caddr_t ifbacu_buf;
317 struct ifbareq *ifbacu_req;
318 #define ifbac_buf ifbac_ifbacu.ifbacu_buf
319 #define ifbac_req ifbac_ifbacu.ifbacu_req
320 } ifbac_ifbacu;
321 };
322
323 #else /* XNU_KERNEL_PRIVATE */
324
325 struct ifbaconf32 {
326 uint32_t ifbac_len; /* buffer size */
327 union {
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
332 } ifbac_ifbacu;
333 };
334
335 struct ifbaconf64 {
336 uint32_t ifbac_len; /* buffer size */
337 union {
338 user64_addr_t ifbacu_buf;
339 user64_addr_t ifbacu_req;
340 } ifbac_ifbacu;
341 };
342 #endif /* XNU_KERNEL_PRIVATE */
343
344 #pragma pack()
345
346 /*
347 * Bridge parameter structure.
348 */
349
350 #pragma pack(4)
351
352 struct ifbrparam {
353 union {
354 uint32_t ifbrpu_int32;
355 uint16_t ifbrpu_int16;
356 uint8_t ifbrpu_int8;
357 } ifbrp_ifbrpu;
358 };
359
360 #pragma pack()
361
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
371 * adresses */
372 #define ifbrp_filter ifbrp_ifbrpu.ifbrpu_int32 /* filtering flags */
373
374 /*
375 * Bridge current operational parameters structure.
376 */
377
378 #pragma pack(4)
379
380 #ifndef XNU_KERNEL_PRIVATE
381
382 struct ifbropreq {
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;
395 };
396
397 #else /* XNU_KERNEL_PRIVATE */
398
399 struct ifbropreq32 {
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;
412 };
413
414 struct ifbropreq64 {
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;
427 };
428
429 #endif
430
431 #pragma pack()
432
433 /*
434 * Bridge member operational STP params structure.
435 */
436
437 #pragma pack(4)
438
439 struct ifbpstpreq {
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 */
446 };
447
448 #pragma pack()
449
450 /*
451 * Bridge STP ports list structure.
452 */
453
454 #pragma pack(4)
455
456 #ifndef XNU_KERNEL_PRIVATE
457
458 struct ifbpstpconf {
459 uint32_t ifbpstp_len; /* buffer size */
460 union {
461 caddr_t ifbpstpu_buf;
462 struct ifbpstpreq *ifbpstpu_req;
463 } ifbpstp_ifbpstpu;
464 #define ifbpstp_buf ifbpstp_ifbpstpu.ifbpstpu_buf
465 #define ifbpstp_req ifbpstp_ifbpstpu.ifbpstpu_req
466 };
467
468 #else /* XNU_KERNEL_PRIVATE */
469
470 struct ifbpstpconf32 {
471 uint32_t ifbpstp_len; /* buffer size */
472 union {
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
477 } ifbpstp_ifbpstpu;
478 };
479
480 struct ifbpstpconf64 {
481 uint32_t ifbpstp_len; /* buffer size */
482 union {
483 user64_addr_t ifbpstpu_buf;
484 user64_addr_t ifbpstpu_req;
485 } ifbpstp_ifbpstpu;
486 };
487
488 #endif /* XNU_KERNEL_PRIVATE */
489
490 #pragma pack()
491
492
493 #ifdef XNU_KERNEL_PRIVATE
494
495 extern u_int8_t bstp_etheraddr[ETHER_ADDR_LEN];
496
497 int bridgeattach(int);
498
499 #endif /* XNU_KERNEL_PRIVATE */
500 #endif /* PRIVATE */
501 #endif /* !_NET_IF_BRIDGEVAR_H_ */