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