]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/netgraph/ng_bridge.h
Add UPDATING entries and bump version
[FreeBSD/FreeBSD.git] / sys / netgraph / ng_bridge.h
1 /*
2  * ng_bridge.h
3  */
4
5 /*-
6  * Copyright (c) 2000 Whistle Communications, Inc.
7  * All rights reserved.
8  * 
9  * Subject to the following obligations and disclaimer of warranty, use and
10  * redistribution of this software, in source or object code forms, with or
11  * without modifications are expressly permitted by Whistle Communications;
12  * provided, however, that:
13  * 1. Any and all reproductions of the source or object code must include the
14  *    copyright notice above and the following disclaimer of warranties; and
15  * 2. No rights are granted, in any manner or form, to use Whistle
16  *    Communications, Inc. trademarks, including the mark "WHISTLE
17  *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
18  *    such appears in the above copyright notice or in the software.
19  * 
20  * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
21  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
22  * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
23  * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
25  * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
26  * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
27  * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
28  * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
29  * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
30  * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
31  * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
32  * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35  * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
36  * OF SUCH DAMAGE.
37  *
38  * Author: Archie Cobbs <archie@freebsd.org>
39  *
40  * $FreeBSD$
41  */
42
43 #ifndef _NETGRAPH_NG_BRIDGE_H_
44 #define _NETGRAPH_NG_BRIDGE_H_
45
46 /*
47  * Support the older ABI based on fixed size tables.
48  * ABI is deprecated, to be removed in releases > 12
49  * Please note: There is no API support!
50  * You canno create new messages using the old API but messages conforming the
51  * old ABI are understood.
52  */
53 #define NGM_BRIDGE_TABLE_ABI
54
55 /* Node type name and magic cookie */
56 #define NG_BRIDGE_NODE_TYPE             "bridge"
57 #define NGM_BRIDGE_COOKIE               1569321993
58
59 #ifdef NGM_BRIDGE_TABLE_ABI
60 #define NGM_BRIDGE_COOKIE_TBL           967239368
61 #define NG_BRIDGE_MAX_LINKS             32
62 #endif /* NGM_BRIDGE_TABLE_ABI */
63
64 /* Hook names */
65 #define NG_BRIDGE_HOOK_LINK_PREFIX      "link"   /* append decimal integer */
66 #define NG_BRIDGE_HOOK_LINK_FMT         "link%d" /* for use with printf(3) */
67 #define NG_BRIDGE_HOOK_UPLINK_PREFIX    "uplink" /* append decimal integer */
68 #define NG_BRIDGE_HOOK_UPLINK_FMT       "uplink%d" /* for use with printf(3) */
69
70 /* Node configuration structure */
71 struct ng_bridge_config {
72         u_char          debugLevel;             /* debug level */
73         u_int32_t       loopTimeout;            /* link loopback mute time */
74         u_int32_t       maxStaleness;           /* max host age before nuking */
75         u_int32_t       minStableAge;           /* min time for a stable host */
76 };
77
78 #ifdef NGM_BRIDGE_TABLE_ABI
79 struct ng_bridge_config_tbl {
80         u_char          ipfw[NG_BRIDGE_MAX_LINKS];
81         struct ng_bridge_config cfg;
82 };
83 #endif /* NGM_BRIDGE_TABLE_ABI */
84
85 /* Keep this in sync with the above structure definition */
86 #define NG_BRIDGE_CONFIG_TYPE_INFO      {                       \
87           { "debugLevel",       &ng_parse_uint8_type    },      \
88           { "loopTimeout",      &ng_parse_uint32_type   },      \
89           { "maxStaleness",     &ng_parse_uint32_type   },      \
90           { "minStableAge",     &ng_parse_uint32_type   },      \
91           { NULL }                                              \
92 }
93
94 /* Statistics structure (one for each link) */
95 struct ng_bridge_link_stats {
96         u_int64_t       recvOctets;     /* total octets rec'd on link */
97         u_int64_t       recvPackets;    /* total pkts rec'd on link */
98         u_int64_t       recvMulticasts; /* multicast pkts rec'd on link */
99         u_int64_t       recvBroadcasts; /* broadcast pkts rec'd on link */
100         u_int64_t       recvUnknown;    /* pkts rec'd with unknown dest addr */
101         u_int64_t       recvRunts;      /* pkts rec'd less than 14 bytes */
102         u_int64_t       recvInvalid;    /* pkts rec'd with bogus source addr */
103         u_int64_t       xmitOctets;     /* total octets xmit'd on link */
104         u_int64_t       xmitPackets;    /* total pkts xmit'd on link */
105         u_int64_t       xmitMulticasts; /* multicast pkts xmit'd on link */
106         u_int64_t       xmitBroadcasts; /* broadcast pkts xmit'd on link */
107         u_int64_t       loopDrops;      /* pkts dropped due to loopback */
108         u_int64_t       loopDetects;    /* number of loop detections */
109         u_int64_t       memoryFailures; /* times couldn't get mem or mbuf */
110 };
111
112 /* Keep this in sync with the above structure definition */
113 #define NG_BRIDGE_STATS_TYPE_INFO       {                       \
114           { "recvOctets",       &ng_parse_uint64_type   },      \
115           { "recvPackets",      &ng_parse_uint64_type   },      \
116           { "recvMulticast",    &ng_parse_uint64_type   },      \
117           { "recvBroadcast",    &ng_parse_uint64_type   },      \
118           { "recvUnknown",      &ng_parse_uint64_type   },      \
119           { "recvRunts",        &ng_parse_uint64_type   },      \
120           { "recvInvalid",      &ng_parse_uint64_type   },      \
121           { "xmitOctets",       &ng_parse_uint64_type   },      \
122           { "xmitPackets",      &ng_parse_uint64_type   },      \
123           { "xmitMulticasts",   &ng_parse_uint64_type   },      \
124           { "xmitBroadcasts",   &ng_parse_uint64_type   },      \
125           { "loopDrops",        &ng_parse_uint64_type   },      \
126           { "loopDetects",      &ng_parse_uint64_type   },      \
127           { "memoryFailures",   &ng_parse_uint64_type   },      \
128           { NULL }                                              \
129 }
130
131 struct ng_bridge_link;
132 typedef struct ng_bridge_link *link_p;
133
134 #ifdef NGM_BRIDGE_TABLE_ABI
135 struct ng_bridge_host_tbl {
136         u_char          addr[6];        /* ethernet address */
137         u_int16_t       linkNum;        /* link where addr can be found */
138         u_int16_t       age;            /* seconds ago entry was created */
139         u_int16_t       staleness;      /* seconds ago host last heard from */
140 };
141 #endif /* NGM_BRIDGE_TABLE_ABI */
142
143 /* external representation of the host */
144 struct ng_bridge_hostent {
145         u_char          addr[6];                /* ethernet address */
146         char            hook[NG_HOOKSIZ];       /* link where addr can be found */
147         u_int16_t       age;                    /* seconds ago entry was created */
148         u_int16_t       staleness;              /* seconds ago host last heard from */
149 };
150
151 /* Keep this in sync with the above structure definition */
152 #define NG_BRIDGE_HOST_TYPE_INFO(entype)        {               \
153           { "addr",             (entype)                },      \
154           { "hook",             &ng_parse_hookbuf_type  },      \
155           { "age",              &ng_parse_uint16_type   },      \
156           { "staleness",        &ng_parse_uint16_type   },      \
157           { NULL }                                              \
158 }
159
160 /* Structure returned by NGM_BRIDGE_GET_TABLE */
161 struct ng_bridge_host_ary {
162         u_int32_t                       numHosts;
163         struct ng_bridge_hostent        hosts[];
164 };
165
166 /* Keep this in sync with the above structure definition */
167 #define NG_BRIDGE_HOST_ARY_TYPE_INFO(harytype)  {               \
168           { "numHosts",         &ng_parse_uint32_type   },      \
169           { "hosts",            (harytype)              },      \
170           { NULL }                                              \
171 }
172
173 #ifdef NGM_BRIDGE_TABLE_ABI
174 struct ng_bridge_hostent_tbl {
175         u_char          addr[6];                /* ethernet address */
176         u_int16_t       linkNum;                /* link where addr can be found */
177         u_int16_t       age;                    /* seconds ago entry was created */
178         u_int16_t       staleness;              /* seconds ago host last heard from */
179 };
180 struct ng_bridge_host_tbl_ary {
181         u_int32_t                       numHosts;
182         struct ng_bridge_hostent_tbl    hosts[];
183 };
184 #endif /* NGM_BRIDGE_TABLE_ABI */
185
186 struct ng_bridge_move_host {
187         u_char          addr[ETHER_ADDR_LEN];   /* ethernet address */
188         char            hook[NG_HOOKSIZ];       /* link where addr can be found */
189 };
190 /* Keep this in sync with the above structure definition */
191 #define NG_BRIDGE_MOVE_HOST_TYPE_INFO(entype)   {               \
192           { "addr",             (entype)                },      \
193           { "hook",             &ng_parse_hookbuf_type  },      \
194 }
195
196 /* Netgraph control messages */
197 enum {
198         NGM_BRIDGE_SET_CONFIG = 1,      /* set node configuration */
199         NGM_BRIDGE_GET_CONFIG,          /* get node configuration */
200         NGM_BRIDGE_RESET,               /* reset (forget) all information */
201         NGM_BRIDGE_GET_STATS,           /* get link stats */
202         NGM_BRIDGE_CLR_STATS,           /* clear link stats */
203         NGM_BRIDGE_GETCLR_STATS,        /* atomically get & clear link stats */
204         NGM_BRIDGE_GET_TABLE,           /* get link table */
205         NGM_BRIDGE_SET_PERSISTENT,      /* set persistent mode */
206         NGM_BRIDGE_MOVE_HOST,           /* move a host to a link */
207 };
208
209 #endif /* _NETGRAPH_NG_BRIDGE_H_ */
210