ng_one2many.h revision 68810
138494Sobrien 238494Sobrien/* 338494Sobrien * ng_one2many.h 438494Sobrien * 538494Sobrien * Copyright (c) 2000 Whistle Communications, Inc. 638494Sobrien * All rights reserved. 738494Sobrien * 838494Sobrien * Subject to the following obligations and disclaimer of warranty, use and 938494Sobrien * redistribution of this software, in source or object code forms, with or 1038494Sobrien * without modifications are expressly permitted by Whistle Communications; 1138494Sobrien * provided, however, that: 1238494Sobrien * 1. Any and all reproductions of the source or object code must include the 1338494Sobrien * copyright notice above and the following disclaimer of warranties; and 1438494Sobrien * 2. No rights are granted, in any manner or form, to use Whistle 1538494Sobrien * Communications, Inc. trademarks, including the mark "WHISTLE 1638494Sobrien * COMMUNICATIONS" on advertising, endorsements, or otherwise except as 1738494Sobrien * such appears in the above copyright notice or in the software. 1838494Sobrien * 1938494Sobrien * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND 2042629Sobrien * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO 2138494Sobrien * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, 2238494Sobrien * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF 2338494Sobrien * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. 2438494Sobrien * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY 2538494Sobrien * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS 2638494Sobrien * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE. 2738494Sobrien * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES 2838494Sobrien * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING 2938494Sobrien * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 3038494Sobrien * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR 3138494Sobrien * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 3238494Sobrien * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3338494Sobrien * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3438494Sobrien * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 3538494Sobrien * OF SUCH DAMAGE. 3638494Sobrien * 3738494Sobrien * Author: Archie Cobbs <archie@freebsd.org> 3838494Sobrien * 3938494Sobrien * $FreeBSD: head/sys/netgraph/ng_one2many.h 68810 2000-11-16 05:58:33Z archie $ 4038494Sobrien */ 4142629Sobrien 4238494Sobrien#ifndef _NETGRAPH_NG_ONE2MANY_H_ 4338494Sobrien#define _NETGRAPH_NG_ONE2MANY_H_ 4438494Sobrien 4538494Sobrien/* Node type name and magic cookie */ 4638494Sobrien#define NG_ONE2MANY_NODE_TYPE "one2many" 4738494Sobrien#define NGM_ONE2MANY_COOKIE 971111383 4838494Sobrien 4938494Sobrien/* Hook names */ 5038494Sobrien#define NG_ONE2MANY_HOOK_ONE "one" 5138494Sobrien#define NG_ONE2MANY_HOOK_MANY_PREFIX "many" /* append decimal integer */ 5238494Sobrien#define NG_ONE2MANY_HOOK_MANY_FMT "many%d" /* for use with printf(3) */ 5338494Sobrien 5438494Sobrien/* Maximum number of supported "many" links */ 5538494Sobrien#define NG_ONE2MANY_MAX_LINKS 64 5638494Sobrien 5738494Sobrien/* Link number used to indicate the "one" hook */ 5838494Sobrien#define NG_ONE2MANY_ONE_LINKNUM (-1) 5938494Sobrien 6038494Sobrien/* Algorithms for outgoing packet distribution (XXX only one so far) */ 6138494Sobrien#define NG_ONE2MANY_XMIT_ROUNDROBIN 1 /* round-robin delivery */ 6238494Sobrien 6338494Sobrien/* Algorithms for detecting link failure (XXX only one so far) */ 6438494Sobrien#define NG_ONE2MANY_FAIL_MANUAL 1 /* use enabledLinks[] array */ 6538494Sobrien 6638494Sobrien/* Node configuration structure */ 6738494Sobrienstruct ng_one2many_config { 6838494Sobrien u_int32_t xmitAlg; /* how to distribute packets */ 6938494Sobrien u_int32_t failAlg; /* how to detect link failure */ 7038494Sobrien u_char enabledLinks[NG_ONE2MANY_MAX_LINKS]; 7138494Sobrien}; 7238494Sobrien 7338494Sobrien/* Keep this in sync with the above structure definition */ 7438494Sobrien#define NG_ONE2MANY_CONFIG_TYPE_INFO(atype) { \ 7538494Sobrien { \ 7638494Sobrien { "xmitAlg", &ng_parse_uint64_type }, \ 7738494Sobrien { "failAlg", &ng_parse_uint64_type }, \ 7838494Sobrien { "enabledLinks", (atype) }, \ 7938494Sobrien { NULL } \ 8038494Sobrien } \ 8138494Sobrien} 8238494Sobrien 8338494Sobrien/* Statistics structure (one for each link) */ 8438494Sobrienstruct ng_one2many_link_stats { 8538494Sobrien u_int64_t recvOctets; /* total octets rec'd on link */ 8638494Sobrien u_int64_t recvPackets; /* total pkts rec'd on link */ 8738494Sobrien u_int64_t xmitOctets; /* total octets xmit'd on link */ 8838494Sobrien u_int64_t xmitPackets; /* total pkts xmit'd on link */ 8938494Sobrien}; 9038494Sobrien 9138494Sobrien/* Keep this in sync with the above structure definition */ 9238494Sobrien#define NG_ONE2MANY_LINK_STATS_TYPE_INFO { \ 9338494Sobrien { \ 9438494Sobrien { "recvOctets", &ng_parse_uint64_type }, \ 9538494Sobrien { "recvPackets", &ng_parse_uint64_type }, \ 9638494Sobrien { "xmitOctets", &ng_parse_uint64_type }, \ 9738494Sobrien { "xmitPackets", &ng_parse_uint64_type }, \ 9838494Sobrien { NULL } \ 9938494Sobrien } \ 10038494Sobrien} 10138494Sobrien 10238494Sobrien/* Netgraph control messages */ 10338494Sobrienenum { 10438494Sobrien NGM_ONE2MANY_SET_CONFIG, /* set configuration */ 10538494Sobrien NGM_ONE2MANY_GET_CONFIG, /* get configuration */ 10638494Sobrien NGM_ONE2MANY_GET_STATS, /* get link stats */ 10738494Sobrien NGM_ONE2MANY_CLR_STATS, /* clear link stats */ 10838494Sobrien NGM_ONE2MANY_GETCLR_STATS, /* atomically get & clear link stats */ 10938494Sobrien}; 11038494Sobrien 11138494Sobrien#endif /* _NETGRAPH_NG_ONE2MANY_H_ */ 11238494Sobrien 11338494Sobrien