1
2 /*
3 * ng_bridge.h
4 *
5 * Copyright (c) 2000 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and
9 * redistribution of this software, in source or object code forms, with or
10 * without modifications are expressly permitted by Whistle Communications;
11 * provided, however, that:
12 * 1. Any and all reproductions of the source or object code must include the
13 * copyright notice above and the following disclaimer of warranties; and
14 * 2. No rights are granted, in any manner or form, to use Whistle
15 * Communications, Inc. trademarks, including the mark "WHISTLE
16 * COMMUNICATIONS" on advertising, endorsements, or otherwise except as
17 * such appears in the above copyright notice or in the software.
18 *
19 * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
20 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
21 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
22 * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
24 * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
25 * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
26 * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
27 * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
28 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
29 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
30 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
37 * Author: Archie Cobbs <archie@freebsd.org>
38 *
39 * $FreeBSD: releng/5.2/sys/netgraph/ng_bridge.h 97685 2002-05-31 23:48:03Z archie $
40 */
41
42 #ifndef _NETGRAPH_NG_BRIDGE_H_
43 #define _NETGRAPH_NG_BRIDGE_H_
44
45 /* Node type name and magic cookie */
46 #define NG_BRIDGE_NODE_TYPE "bridge"
47 #define NGM_BRIDGE_COOKIE 967239368
48
49 /* Hook names */
50 #define NG_BRIDGE_HOOK_LINK_PREFIX "link" /* append decimal integer */
51 #define NG_BRIDGE_HOOK_LINK_FMT "link%d" /* for use with printf(3) */
52
53 /* Maximum number of supported links */
54 #define NG_BRIDGE_MAX_LINKS 32
55
56 /* Node configuration structure */
57 struct ng_bridge_config {
58 u_char ipfw[NG_BRIDGE_MAX_LINKS]; /* enable ipfw */
59 u_char debugLevel; /* debug level */
60 u_int32_t loopTimeout; /* link loopback mute time */
61 u_int32_t maxStaleness; /* max host age before nuking */
62 u_int32_t minStableAge; /* min time for a stable host */
63 };
64
65 /* Keep this in sync with the above structure definition */
66 #define NG_BRIDGE_CONFIG_TYPE_INFO(ainfo) { \
67 { "ipfw", (ainfo) }, \
68 { "debugLevel", &ng_parse_uint8_type }, \
69 { "loopTimeout", &ng_parse_uint32_type }, \
70 { "maxStaleness", &ng_parse_uint32_type }, \
71 { "minStableAge", &ng_parse_uint32_type }, \
72 { NULL } \
73 }
74
75 /* Statistics structure (one for each link) */
76 struct ng_bridge_link_stats {
77 u_int64_t recvOctets; /* total octets rec'd on link */
78 u_int64_t recvPackets; /* total pkts rec'd on link */
79 u_int64_t recvMulticasts; /* multicast pkts rec'd on link */
80 u_int64_t recvBroadcasts; /* broadcast pkts rec'd on link */
81 u_int64_t recvUnknown; /* pkts rec'd with unknown dest addr */
82 u_int64_t recvRunts; /* pkts rec'd less than 14 bytes */
83 u_int64_t recvInvalid; /* pkts rec'd with bogus source addr */
84 u_int64_t xmitOctets; /* total octets xmit'd on link */
85 u_int64_t xmitPackets; /* total pkts xmit'd on link */
86 u_int64_t xmitMulticasts; /* multicast pkts xmit'd on link */
87 u_int64_t xmitBroadcasts; /* broadcast pkts xmit'd on link */
88 u_int64_t loopDrops; /* pkts dropped due to loopback */
89 u_int64_t loopDetects; /* number of loop detections */
90 u_int64_t memoryFailures; /* times couldn't get mem or mbuf */
91 };
92
93 /* Keep this in sync with the above structure definition */
94 #define NG_BRIDGE_STATS_TYPE_INFO { \
95 { "recvOctets", &ng_parse_uint64_type }, \
96 { "recvPackets", &ng_parse_uint64_type }, \
97 { "recvMulticast", &ng_parse_uint64_type }, \
98 { "recvBroadcast", &ng_parse_uint64_type }, \
99 { "recvUnknown", &ng_parse_uint64_type }, \
100 { "recvRunts", &ng_parse_uint64_type }, \
101 { "recvInvalid", &ng_parse_uint64_type }, \
102 { "xmitOctets", &ng_parse_uint64_type }, \
103 { "xmitPackets", &ng_parse_uint64_type }, \
104 { "xmitMulticasts", &ng_parse_uint64_type }, \
105 { "xmitBroadcasts", &ng_parse_uint64_type }, \
106 { "loopDrops", &ng_parse_uint64_type }, \
107 { "loopDetects", &ng_parse_uint64_type }, \
108 { "memoryFailures", &ng_parse_uint64_type }, \
109 { NULL } \
110 }
111
112 /* Structure describing a single host */
113 struct ng_bridge_host {
114 u_char addr[6]; /* ethernet address */
115 u_int16_t linkNum; /* link where addr can be found */
116 u_int16_t age; /* seconds ago entry was created */
117 u_int16_t staleness; /* seconds ago host last heard from */
118 };
119
120 /* Keep this in sync with the above structure definition */
121 #define NG_BRIDGE_HOST_TYPE_INFO(entype) { \
122 { "addr", (entype) }, \
123 { "linkNum", &ng_parse_uint16_type }, \
124 { "age", &ng_parse_uint16_type }, \
125 { "staleness", &ng_parse_uint16_type }, \
126 { NULL } \
127 }
128
129 /* Structure returned by NGM_BRIDGE_GET_TABLE */
130 struct ng_bridge_host_ary {
131 u_int32_t numHosts;
132 struct ng_bridge_host hosts[0];
133 };
134
135 /* Keep this in sync with the above structure definition */
136 #define NG_BRIDGE_HOST_ARY_TYPE_INFO(harytype) { \
137 { "numHosts", &ng_parse_uint32_type }, \
138 { "hosts", (harytype) }, \
139 { NULL } \
140 }
141
142 /* Netgraph control messages */
143 enum {
144 NGM_BRIDGE_SET_CONFIG = 1, /* set node configuration */
145 NGM_BRIDGE_GET_CONFIG, /* get node configuration */
146 NGM_BRIDGE_RESET, /* reset (forget) all information */
147 NGM_BRIDGE_GET_STATS, /* get link stats */
148 NGM_BRIDGE_CLR_STATS, /* clear link stats */
149 NGM_BRIDGE_GETCLR_STATS, /* atomically get & clear link stats */
150 NGM_BRIDGE_GET_TABLE, /* get link table */
151 };
152
153 #endif /* _NETGRAPH_NG_BRIDGE_H_ */
154
Cache object: c400fcf5b7aa50cbfe6a56cfaf10dbfe
|