168810Sarchie/*
268810Sarchie * ng_one2many.h
3139823Simp */
4139823Simp
5139823Simp/*-
668810Sarchie * Copyright (c) 2000 Whistle Communications, Inc.
768810Sarchie * All rights reserved.
868810Sarchie *
968810Sarchie * Subject to the following obligations and disclaimer of warranty, use and
1068810Sarchie * redistribution of this software, in source or object code forms, with or
1168810Sarchie * without modifications are expressly permitted by Whistle Communications;
1268810Sarchie * provided, however, that:
1368810Sarchie * 1. Any and all reproductions of the source or object code must include the
1468810Sarchie *    copyright notice above and the following disclaimer of warranties; and
1568810Sarchie * 2. No rights are granted, in any manner or form, to use Whistle
1668810Sarchie *    Communications, Inc. trademarks, including the mark "WHISTLE
1768810Sarchie *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
1868810Sarchie *    such appears in the above copyright notice or in the software.
1968810Sarchie *
2068810Sarchie * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
2168810Sarchie * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
2268810Sarchie * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
2368810Sarchie * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
2468810Sarchie * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
2568810Sarchie * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
2668810Sarchie * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
2768810Sarchie * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
2868810Sarchie * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
2968810Sarchie * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
3068810Sarchie * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
3168810Sarchie * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
3268810Sarchie * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
3368810Sarchie * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3468810Sarchie * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3568810Sarchie * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
3668810Sarchie * OF SUCH DAMAGE.
3768810Sarchie *
3868810Sarchie * Author: Archie Cobbs <archie@freebsd.org>
3968810Sarchie *
4068810Sarchie * $FreeBSD$
4168810Sarchie */
4268810Sarchie
4368810Sarchie#ifndef _NETGRAPH_NG_ONE2MANY_H_
4468810Sarchie#define _NETGRAPH_NG_ONE2MANY_H_
4568810Sarchie
4668810Sarchie/* Node type name and magic cookie */
4768810Sarchie#define NG_ONE2MANY_NODE_TYPE		"one2many"
48138010Sglebius#define NGM_ONE2MANY_COOKIE		1100897444
4968810Sarchie
5068810Sarchie/* Hook names */
5168810Sarchie#define NG_ONE2MANY_HOOK_ONE		"one"
5268810Sarchie#define NG_ONE2MANY_HOOK_MANY_PREFIX	"many"	 /* append decimal integer */
5368810Sarchie#define NG_ONE2MANY_HOOK_MANY_FMT	"many%d" /* for use with printf(3) */
5468810Sarchie
5568810Sarchie/* Maximum number of supported "many" links */
5668810Sarchie#define NG_ONE2MANY_MAX_LINKS		64
5768810Sarchie
5868810Sarchie/* Link number used to indicate the "one" hook */
5968810Sarchie#define NG_ONE2MANY_ONE_LINKNUM		(-1)
6068810Sarchie
6168810Sarchie/* Algorithms for outgoing packet distribution (XXX only one so far) */
6268810Sarchie#define NG_ONE2MANY_XMIT_ROUNDROBIN	1	/* round-robin delivery */
6371738Sjulian#define NG_ONE2MANY_XMIT_ALL		2	/* send packets to all many hooks */
64219127Sae#define	NG_ONE2MANY_XMIT_FAILOVER	3	/* send packets to first active "many" */
6568810Sarchie
66126035Spjd/* Algorithms for detecting link failure (XXX only one so far) */
6768810Sarchie#define NG_ONE2MANY_FAIL_MANUAL		1	/* use enabledLinks[] array */
68138010Sglebius#define NG_ONE2MANY_FAIL_NOTIFY		2	/* listen to flow control msgs */
6968810Sarchie
7068810Sarchie/* Node configuration structure */
7168810Sarchiestruct ng_one2many_config {
7268810Sarchie	u_int32_t	xmitAlg;		/* how to distribute packets */
7368810Sarchie	u_int32_t	failAlg;		/* how to detect link failure */
7468810Sarchie	u_char		enabledLinks[NG_ONE2MANY_MAX_LINKS];
7568810Sarchie};
7668810Sarchie
7768810Sarchie/* Keep this in sync with the above structure definition */
7868810Sarchie#define NG_ONE2MANY_CONFIG_TYPE_INFO(atype)	{		\
7969938Sarchie	  { "xmitAlg",		&ng_parse_uint32_type	},	\
8069938Sarchie	  { "failAlg",		&ng_parse_uint32_type	},	\
8168810Sarchie	  { "enabledLinks",	(atype)			},	\
8268810Sarchie	  { NULL }						\
8368810Sarchie}
8468810Sarchie
8568810Sarchie/* Statistics structure (one for each link) */
8668810Sarchiestruct ng_one2many_link_stats {
8768810Sarchie	u_int64_t	recvOctets;	/* total octets rec'd on link */
8868810Sarchie	u_int64_t	recvPackets;	/* total pkts rec'd on link */
8968810Sarchie	u_int64_t	xmitOctets;	/* total octets xmit'd on link */
9068810Sarchie	u_int64_t	xmitPackets;	/* total pkts xmit'd on link */
9171738Sjulian	u_int64_t	memoryFailures;	/* times couldn't get mem or mbuf */
9268810Sarchie};
9368810Sarchie
9468810Sarchie/* Keep this in sync with the above structure definition */
9568810Sarchie#define NG_ONE2MANY_LINK_STATS_TYPE_INFO	{		\
9668810Sarchie	  { "recvOctets",	&ng_parse_uint64_type	},	\
9768810Sarchie	  { "recvPackets",	&ng_parse_uint64_type	},	\
9868810Sarchie	  { "xmitOctets",	&ng_parse_uint64_type	},	\
9968810Sarchie	  { "xmitPackets",	&ng_parse_uint64_type	},	\
10071738Sjulian	  { "memoryFailures",	&ng_parse_uint64_type	},	\
10168810Sarchie	  { NULL }						\
10268810Sarchie}
10368810Sarchie
10468810Sarchie/* Netgraph control messages */
10568810Sarchieenum {
10668810Sarchie	NGM_ONE2MANY_SET_CONFIG,	/* set configuration */
10768810Sarchie	NGM_ONE2MANY_GET_CONFIG,	/* get configuration */
10868810Sarchie	NGM_ONE2MANY_GET_STATS,		/* get link stats */
10968810Sarchie	NGM_ONE2MANY_CLR_STATS,		/* clear link stats */
11068810Sarchie	NGM_ONE2MANY_GETCLR_STATS,	/* atomically get & clear link stats */
11168810Sarchie};
11268810Sarchie
11368810Sarchie#endif /* _NETGRAPH_NG_ONE2MANY_H_ */
11468810Sarchie
115