2 * Copyright (c) 1998-2002 Luigi Rizzo
4 * Work partly supported by: Cisco Systems, Inc. - NSITE lab, RTP, NC
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * $FreeBSD: src/sys/net/bridge.h,v 1.4.2.5 2002/02/15 05:13:58 luigi Exp $
28 * $DragonFly: src/sys/net/oldbridge/Attic/bridge.h,v 1.2 2003/06/17 04:28:47 dillon Exp $
34 * We need additional per-interface info for the bridge, which is
35 * stored in a struct bdg_softc. The ifp2sc[] array provides a pointer
36 * to this struct using the if_index as a mapping key.
37 * bdg_softc has a backpointer to the struct ifnet, the bridge
38 * flags, and a cluster (bridging occurs only between port of the
42 struct cluster_softc; /* opaque here, defined in bridge.c */
46 /* also ((struct arpcom *)ifp)->ac_enaddr is the eth. addr */
48 #define IFF_BDG_PROMISC 0x0001 /* set promisc mode on this if. */
49 #define IFF_MUTE 0x0002 /* mute this if for bridging. */
50 #define IFF_USED 0x0004 /* use this if for bridging. */
51 struct cluster_softc *cluster;
54 extern struct bdg_softc *ifp2sc;
56 #define BDG_USED(ifp) (ifp2sc[ifp->if_index].flags & IFF_USED)
58 * BDG_ACTIVE(ifp) does all checks to see if bridging is enabled, loaded,
59 * and used on a given interface.
61 #define BDG_ACTIVE(ifp) (do_bridge && BDG_LOADED && BDG_USED(ifp))
64 * The following constants are not legal ifnet pointers, and are used
65 * as return values from the classifier, bridge_dst_lookup().
66 * The same values are used as index in the statistics arrays,
67 * with BDG_FORWARD replacing specifically forwarded packets.
69 * These constants are here because they are used in 'netstat'
70 * to show bridge statistics.
72 #define BDG_BCAST ( (struct ifnet *)1 )
73 #define BDG_MCAST ( (struct ifnet *)2 )
74 #define BDG_LOCAL ( (struct ifnet *)3 )
75 #define BDG_DROP ( (struct ifnet *)4 )
76 #define BDG_UNKNOWN ( (struct ifnet *)5 )
77 #define BDG_IN ( (struct ifnet *)7 )
78 #define BDG_OUT ( (struct ifnet *)8 )
79 #define BDG_FORWARD ( (struct ifnet *)9 )
82 * Statistics are passed up with the sysctl interface, "netstat -p bdg"
83 * reads them. PF_BDG defines the 'bridge' protocol family.
86 #define PF_BDG 3 /* XXX superhack */
88 #define STAT_MAX (int)BDG_FORWARD
89 struct bdg_port_stat {
92 u_long p_in[STAT_MAX+1];
95 /* XXX this should be made dynamic */
96 #define BDG_MAX_PORTS 128
98 struct bdg_port_stat s[BDG_MAX_PORTS];
102 #define BDG_STAT(ifp, type) bdg_stats.s[ifp->if_index].p_in[(uintptr_t)type]++
105 typedef struct ifnet *bridge_in_t(struct ifnet *, struct ether_header *);
106 /* bdg_forward frees the mbuf if necessary, returning null */
107 typedef struct mbuf *bdg_forward_t(struct mbuf *, struct ether_header *const,
109 typedef void bdgtakeifaces_t(void);
110 extern bridge_in_t *bridge_in_ptr;
111 extern bdg_forward_t *bdg_forward_ptr;
112 extern bdgtakeifaces_t *bdgtakeifaces_ptr;
114 #define BDG_LOADED (bdgtakeifaces_ptr != NULL)