1*119de7c2SNuno Antunes /* 2*119de7c2SNuno Antunes * ng_one2many.h 3*119de7c2SNuno Antunes */ 4*119de7c2SNuno Antunes 5*119de7c2SNuno Antunes /*- 6*119de7c2SNuno Antunes * Copyright (c) 2000 Whistle Communications, Inc. 7*119de7c2SNuno Antunes * All rights reserved. 8*119de7c2SNuno Antunes * 9*119de7c2SNuno Antunes * Subject to the following obligations and disclaimer of warranty, use and 10*119de7c2SNuno Antunes * redistribution of this software, in source or object code forms, with or 11*119de7c2SNuno Antunes * without modifications are expressly permitted by Whistle Communications; 12*119de7c2SNuno Antunes * provided, however, that: 13*119de7c2SNuno Antunes * 1. Any and all reproductions of the source or object code must include the 14*119de7c2SNuno Antunes * copyright notice above and the following disclaimer of warranties; and 15*119de7c2SNuno Antunes * 2. No rights are granted, in any manner or form, to use Whistle 16*119de7c2SNuno Antunes * Communications, Inc. trademarks, including the mark "WHISTLE 17*119de7c2SNuno Antunes * COMMUNICATIONS" on advertising, endorsements, or otherwise except as 18*119de7c2SNuno Antunes * such appears in the above copyright notice or in the software. 19*119de7c2SNuno Antunes * 20*119de7c2SNuno Antunes * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND 21*119de7c2SNuno Antunes * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO 22*119de7c2SNuno Antunes * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, 23*119de7c2SNuno Antunes * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF 24*119de7c2SNuno Antunes * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. 25*119de7c2SNuno Antunes * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY 26*119de7c2SNuno Antunes * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS 27*119de7c2SNuno Antunes * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE. 28*119de7c2SNuno Antunes * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES 29*119de7c2SNuno Antunes * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING 30*119de7c2SNuno Antunes * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 31*119de7c2SNuno Antunes * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR 32*119de7c2SNuno Antunes * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 33*119de7c2SNuno Antunes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34*119de7c2SNuno Antunes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 35*119de7c2SNuno Antunes * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 36*119de7c2SNuno Antunes * OF SUCH DAMAGE. 37*119de7c2SNuno Antunes * 38*119de7c2SNuno Antunes * Author: Archie Cobbs <archie@freebsd.org> 39*119de7c2SNuno Antunes * 40*119de7c2SNuno Antunes * $FreeBSD: src/sys/netgraph/ng_one2many.h,v 1.8 2005/01/07 01:45:39 imp Exp $ 41*119de7c2SNuno Antunes * $DragonFly: src/sys/netgraph7/ng_one2many.h,v 1.2 2008/06/26 23:05:35 dillon Exp $ 42*119de7c2SNuno Antunes */ 43*119de7c2SNuno Antunes 44*119de7c2SNuno Antunes #ifndef _NETGRAPH_NG_ONE2MANY_H_ 45*119de7c2SNuno Antunes #define _NETGRAPH_NG_ONE2MANY_H_ 46*119de7c2SNuno Antunes 47*119de7c2SNuno Antunes /* Node type name and magic cookie */ 48*119de7c2SNuno Antunes #define NG_ONE2MANY_NODE_TYPE "one2many" 49*119de7c2SNuno Antunes #define NGM_ONE2MANY_COOKIE 1100897444 50*119de7c2SNuno Antunes 51*119de7c2SNuno Antunes /* Hook names */ 52*119de7c2SNuno Antunes #define NG_ONE2MANY_HOOK_ONE "one" 53*119de7c2SNuno Antunes #define NG_ONE2MANY_HOOK_MANY_PREFIX "many" /* append decimal integer */ 54*119de7c2SNuno Antunes #define NG_ONE2MANY_HOOK_MANY_FMT "many%d" /* for use with printf(3) */ 55*119de7c2SNuno Antunes 56*119de7c2SNuno Antunes /* Maximum number of supported "many" links */ 57*119de7c2SNuno Antunes #define NG_ONE2MANY_MAX_LINKS 64 58*119de7c2SNuno Antunes 59*119de7c2SNuno Antunes /* Link number used to indicate the "one" hook */ 60*119de7c2SNuno Antunes #define NG_ONE2MANY_ONE_LINKNUM (-1) 61*119de7c2SNuno Antunes 62*119de7c2SNuno Antunes /* Algorithms for outgoing packet distribution (XXX only one so far) */ 63*119de7c2SNuno Antunes #define NG_ONE2MANY_XMIT_ROUNDROBIN 1 /* round-robin delivery */ 64*119de7c2SNuno Antunes #define NG_ONE2MANY_XMIT_ALL 2 /* send packets to all many hooks */ 65*119de7c2SNuno Antunes 66*119de7c2SNuno Antunes /* Algorithms for detecting link failure (XXX only one so far) */ 67*119de7c2SNuno Antunes #define NG_ONE2MANY_FAIL_MANUAL 1 /* use enabledLinks[] array */ 68*119de7c2SNuno Antunes #define NG_ONE2MANY_FAIL_NOTIFY 2 /* listen to flow control msgs */ 69*119de7c2SNuno Antunes 70*119de7c2SNuno Antunes /* Node configuration structure */ 71*119de7c2SNuno Antunes struct ng_one2many_config { 72*119de7c2SNuno Antunes u_int32_t xmitAlg; /* how to distribute packets */ 73*119de7c2SNuno Antunes u_int32_t failAlg; /* how to detect link failure */ 74*119de7c2SNuno Antunes u_char enabledLinks[NG_ONE2MANY_MAX_LINKS]; 75*119de7c2SNuno Antunes }; 76*119de7c2SNuno Antunes 77*119de7c2SNuno Antunes /* Keep this in sync with the above structure definition */ 78*119de7c2SNuno Antunes #define NG_ONE2MANY_CONFIG_TYPE_INFO(atype) { \ 79*119de7c2SNuno Antunes { "xmitAlg", &ng_parse_uint32_type }, \ 80*119de7c2SNuno Antunes { "failAlg", &ng_parse_uint32_type }, \ 81*119de7c2SNuno Antunes { "enabledLinks", (atype) }, \ 82*119de7c2SNuno Antunes { NULL } \ 83*119de7c2SNuno Antunes } 84*119de7c2SNuno Antunes 85*119de7c2SNuno Antunes /* Statistics structure (one for each link) */ 86*119de7c2SNuno Antunes struct ng_one2many_link_stats { 87*119de7c2SNuno Antunes u_int64_t recvOctets; /* total octets rec'd on link */ 88*119de7c2SNuno Antunes u_int64_t recvPackets; /* total pkts rec'd on link */ 89*119de7c2SNuno Antunes u_int64_t xmitOctets; /* total octets xmit'd on link */ 90*119de7c2SNuno Antunes u_int64_t xmitPackets; /* total pkts xmit'd on link */ 91*119de7c2SNuno Antunes u_int64_t memoryFailures; /* times couldn't get mem or mbuf */ 92*119de7c2SNuno Antunes }; 93*119de7c2SNuno Antunes 94*119de7c2SNuno Antunes /* Keep this in sync with the above structure definition */ 95*119de7c2SNuno Antunes #define NG_ONE2MANY_LINK_STATS_TYPE_INFO { \ 96*119de7c2SNuno Antunes { "recvOctets", &ng_parse_uint64_type }, \ 97*119de7c2SNuno Antunes { "recvPackets", &ng_parse_uint64_type }, \ 98*119de7c2SNuno Antunes { "xmitOctets", &ng_parse_uint64_type }, \ 99*119de7c2SNuno Antunes { "xmitPackets", &ng_parse_uint64_type }, \ 100*119de7c2SNuno Antunes { "memoryFailures", &ng_parse_uint64_type }, \ 101*119de7c2SNuno Antunes { NULL } \ 102*119de7c2SNuno Antunes } 103*119de7c2SNuno Antunes 104*119de7c2SNuno Antunes /* Netgraph control messages */ 105*119de7c2SNuno Antunes enum { 106*119de7c2SNuno Antunes NGM_ONE2MANY_SET_CONFIG, /* set configuration */ 107*119de7c2SNuno Antunes NGM_ONE2MANY_GET_CONFIG, /* get configuration */ 108*119de7c2SNuno Antunes NGM_ONE2MANY_GET_STATS, /* get link stats */ 109*119de7c2SNuno Antunes NGM_ONE2MANY_CLR_STATS, /* clear link stats */ 110*119de7c2SNuno Antunes NGM_ONE2MANY_GETCLR_STATS, /* atomically get & clear link stats */ 111*119de7c2SNuno Antunes }; 112*119de7c2SNuno Antunes 113*119de7c2SNuno Antunes #endif /* _NETGRAPH_NG_ONE2MANY_H_ */ 114*119de7c2SNuno Antunes 115