Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / net / bridge / bridge.h
1 /*
2  * Copyright (c) 1998-2002 Luigi Rizzo
3  *
4  * Work partly supported by: Cisco Systems, Inc. - NSITE lab, RTP, NC
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
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.
14  *
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
25  * SUCH DAMAGE.
26  *
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/bridge/Attic/bridge.h,v 1.2 2003/06/17 04:28:47 dillon Exp $
29  */
30
31 extern int do_bridge;
32
33 /*
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
39  * same cluster).
40  */
41
42 struct cluster_softc;   /* opaque here, defined in bridge.c */
43
44 struct bdg_softc {
45     struct ifnet *ifp ;
46     /* also ((struct arpcom *)ifp)->ac_enaddr is the eth. addr */
47     int flags ;
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;
52 } ;
53
54 extern struct bdg_softc *ifp2sc;
55
56 #define BDG_USED(ifp) (ifp2sc[ifp->if_index].flags & IFF_USED)
57 /*
58  * BDG_ACTIVE(ifp) does all checks to see if bridging is enabled, loaded,
59  * and used on a given interface.
60  */
61 #define BDG_ACTIVE(ifp) (do_bridge && BDG_LOADED && BDG_USED(ifp))
62
63 /*
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.
68  *
69  * These constants are here because they are used in 'netstat'
70  * to show bridge statistics.
71  */
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 )
80
81 /*
82  * Statistics are passed up with the sysctl interface, "netstat -p bdg"
83  * reads them. PF_BDG defines the 'bridge' protocol family.
84  */
85
86 #define PF_BDG 3 /* XXX superhack */
87
88 #define STAT_MAX (int)BDG_FORWARD
89 struct bdg_port_stat {
90     char name[16];
91     u_long collisions;
92     u_long p_in[STAT_MAX+1];
93 } ;
94
95 /* XXX this should be made dynamic */
96 #define BDG_MAX_PORTS 128
97 struct bdg_stats {
98     struct bdg_port_stat s[BDG_MAX_PORTS];
99 } ;
100
101
102 #define BDG_STAT(ifp, type) bdg_stats.s[ifp->if_index].p_in[(uintptr_t)type]++ 
103  
104 #ifdef _KERNEL
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,
108                 struct ifnet *);
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;
113
114 #define BDG_LOADED      (bdgtakeifaces_ptr != NULL)
115 #endif /* KERNEL */