1116743Ssam/*
2186904Ssam * ng_one2many.h
3116743Ssam */
4116743Ssam
5116743Ssam/*-
6116743Ssam * Copyright (c) 2000 Whistle Communications, Inc.
7116743Ssam * All rights reserved.
8116743Ssam *
9116743Ssam * Subject to the following obligations and disclaimer of warranty, use and
10116743Ssam * redistribution of this software, in source or object code forms, with or
11116743Ssam * without modifications are expressly permitted by Whistle Communications;
12116743Ssam * provided, however, that:
13116743Ssam * 1. Any and all reproductions of the source or object code must include the
14116743Ssam *    copyright notice above and the following disclaimer of warranties; and
15116743Ssam * 2. No rights are granted, in any manner or form, to use Whistle
16116743Ssam *    Communications, Inc. trademarks, including the mark "WHISTLE
17116743Ssam *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
18116743Ssam *    such appears in the above copyright notice or in the software.
19116743Ssam *
20116743Ssam * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
21116743Ssam * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
22116743Ssam * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
23116743Ssam * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
24116743Ssam * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
25116743Ssam * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
26116743Ssam * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
27116743Ssam * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
28116743Ssam * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
29116743Ssam * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
30116743Ssam * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
31116743Ssam * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
32116743Ssam * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
33116743Ssam * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34116743Ssam * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35116743Ssam * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
36116743Ssam * OF SUCH DAMAGE.
37116743Ssam *
38116743Ssam * Author: Archie Cobbs <archie@freebsd.org>
39116743Ssam *
40116743Ssam * $FreeBSD: releng/11.0/sys/netgraph/ng_one2many.h 219127 2011-03-01 13:10:56Z ae $
41116743Ssam */
42155492Ssam
43138570Ssam#ifndef _NETGRAPH_NG_ONE2MANY_H_
44116743Ssam#define _NETGRAPH_NG_ONE2MANY_H_
45116743Ssam
46116743Ssam/* Node type name and magic cookie */
47138570Ssam#define NG_ONE2MANY_NODE_TYPE		"one2many"
48116743Ssam#define NGM_ONE2MANY_COOKIE		1100897444
49138570Ssam
50116743Ssam/* Hook names */
51116743Ssam#define NG_ONE2MANY_HOOK_ONE		"one"
52116743Ssam#define NG_ONE2MANY_HOOK_MANY_PREFIX	"many"	 /* append decimal integer */
53116743Ssam#define NG_ONE2MANY_HOOK_MANY_FMT	"many%d" /* for use with printf(3) */
54116743Ssam
55116743Ssam/* Maximum number of supported "many" links */
56116743Ssam#define NG_ONE2MANY_MAX_LINKS		64
57116743Ssam
58116743Ssam/* Link number used to indicate the "one" hook */
59116743Ssam#define NG_ONE2MANY_ONE_LINKNUM		(-1)
60116743Ssam
61116743Ssam/* Algorithms for outgoing packet distribution (XXX only one so far) */
62116743Ssam#define NG_ONE2MANY_XMIT_ROUNDROBIN	1	/* round-robin delivery */
63116743Ssam#define NG_ONE2MANY_XMIT_ALL		2	/* send packets to all many hooks */
64116743Ssam#define	NG_ONE2MANY_XMIT_FAILOVER	3	/* send packets to first active "many" */
65116743Ssam
66116743Ssam/* Algorithms for detecting link failure (XXX only one so far) */
67116743Ssam#define NG_ONE2MANY_FAIL_MANUAL		1	/* use enabledLinks[] array */
68116743Ssam#define NG_ONE2MANY_FAIL_NOTIFY		2	/* listen to flow control msgs */
69116743Ssam
70127779Ssam/* Node configuration structure */
71127779Ssamstruct ng_one2many_config {
72170530Ssam	u_int32_t	xmitAlg;		/* how to distribute packets */
73170530Ssam	u_int32_t	failAlg;		/* how to detect link failure */
74116743Ssam	u_char		enabledLinks[NG_ONE2MANY_MAX_LINKS];
75116743Ssam};
76116743Ssam
77116743Ssam/* Keep this in sync with the above structure definition */
78116743Ssam#define NG_ONE2MANY_CONFIG_TYPE_INFO(atype)	{		\
79116743Ssam	  { "xmitAlg",		&ng_parse_uint32_type	},	\
80138570Ssam	  { "failAlg",		&ng_parse_uint32_type	},	\
81116743Ssam	  { "enabledLinks",	(atype)			},	\
82218689Sadrian	  { NULL }						\
83119147Ssam}
84127779Ssam
85138570Ssam/* Statistics structure (one for each link) */
86138570Ssamstruct ng_one2many_link_stats {
87119147Ssam	u_int64_t	recvOctets;	/* total octets rec'd on link */
88138570Ssam	u_int64_t	recvPackets;	/* total pkts rec'd on link */
89138570Ssam	u_int64_t	xmitOctets;	/* total octets xmit'd on link */
90161187Ssam	u_int64_t	xmitPackets;	/* total pkts xmit'd on link */
91138570Ssam	u_int64_t	memoryFailures;	/* times couldn't get mem or mbuf */
92116743Ssam};
93116743Ssam
94116743Ssam/* Keep this in sync with the above structure definition */
95116743Ssam#define NG_ONE2MANY_LINK_STATS_TYPE_INFO	{		\
96116743Ssam	  { "recvOctets",	&ng_parse_uint64_type	},	\
97116743Ssam	  { "recvPackets",	&ng_parse_uint64_type	},	\
98116743Ssam	  { "xmitOctets",	&ng_parse_uint64_type	},	\
99138570Ssam	  { "xmitPackets",	&ng_parse_uint64_type	},	\
100138570Ssam	  { "memoryFailures",	&ng_parse_uint64_type	},	\
101138570Ssam	  { NULL }						\
102138570Ssam}
103159894Ssam
104159894Ssam/* Netgraph control messages */
105160992Ssamenum {
106170530Ssam	NGM_ONE2MANY_SET_CONFIG,	/* set configuration */
107170530Ssam	NGM_ONE2MANY_GET_CONFIG,	/* get configuration */
108170530Ssam	NGM_ONE2MANY_GET_STATS,		/* get link stats */
109170530Ssam	NGM_ONE2MANY_CLR_STATS,		/* clear link stats */
110170530Ssam	NGM_ONE2MANY_GETCLR_STATS,	/* atomically get & clear link stats */
111170530Ssam};
112186904Ssam
113186904Ssam#endif /* _NETGRAPH_NG_ONE2MANY_H_ */
114186904Ssam
115186904Ssam