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