165310Sarchie/* 265310Sarchie * ng_bridge.h 3139823Simp */ 4139823Simp 5139823Simp/*- 665310Sarchie * Copyright (c) 2000 Whistle Communications, Inc. 765310Sarchie * All rights reserved. 865310Sarchie * 965310Sarchie * Subject to the following obligations and disclaimer of warranty, use and 1065310Sarchie * redistribution of this software, in source or object code forms, with or 1165310Sarchie * without modifications are expressly permitted by Whistle Communications; 1265310Sarchie * provided, however, that: 1365310Sarchie * 1. Any and all reproductions of the source or object code must include the 1465310Sarchie * copyright notice above and the following disclaimer of warranties; and 1565310Sarchie * 2. No rights are granted, in any manner or form, to use Whistle 1665310Sarchie * Communications, Inc. trademarks, including the mark "WHISTLE 1765310Sarchie * COMMUNICATIONS" on advertising, endorsements, or otherwise except as 1865310Sarchie * such appears in the above copyright notice or in the software. 1965310Sarchie * 2065310Sarchie * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND 2165310Sarchie * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO 2265310Sarchie * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, 2365310Sarchie * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF 2465310Sarchie * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. 2565310Sarchie * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY 2665310Sarchie * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS 2765310Sarchie * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE. 2865310Sarchie * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES 2965310Sarchie * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING 3065310Sarchie * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 3165310Sarchie * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR 3265310Sarchie * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 3365310Sarchie * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3465310Sarchie * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3565310Sarchie * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 3665310Sarchie * OF SUCH DAMAGE. 3765310Sarchie * 3865310Sarchie * Author: Archie Cobbs <archie@freebsd.org> 3965310Sarchie * 4065310Sarchie * $FreeBSD$ 4165310Sarchie */ 4265310Sarchie 4365310Sarchie#ifndef _NETGRAPH_NG_BRIDGE_H_ 4465310Sarchie#define _NETGRAPH_NG_BRIDGE_H_ 4565310Sarchie 4665310Sarchie/* Node type name and magic cookie */ 4765310Sarchie#define NG_BRIDGE_NODE_TYPE "bridge" 4865310Sarchie#define NGM_BRIDGE_COOKIE 967239368 4965310Sarchie 5065310Sarchie/* Hook names */ 5165310Sarchie#define NG_BRIDGE_HOOK_LINK_PREFIX "link" /* append decimal integer */ 5265310Sarchie#define NG_BRIDGE_HOOK_LINK_FMT "link%d" /* for use with printf(3) */ 5365310Sarchie 5465310Sarchie/* Maximum number of supported links */ 5565310Sarchie#define NG_BRIDGE_MAX_LINKS 32 5665310Sarchie 5765310Sarchie/* Node configuration structure */ 5865310Sarchiestruct ng_bridge_config { 5965310Sarchie u_char ipfw[NG_BRIDGE_MAX_LINKS]; /* enable ipfw */ 6065310Sarchie u_char debugLevel; /* debug level */ 6165310Sarchie u_int32_t loopTimeout; /* link loopback mute time */ 6265310Sarchie u_int32_t maxStaleness; /* max host age before nuking */ 6365310Sarchie u_int32_t minStableAge; /* min time for a stable host */ 6465310Sarchie}; 6565310Sarchie 6665310Sarchie/* Keep this in sync with the above structure definition */ 6765310Sarchie#define NG_BRIDGE_CONFIG_TYPE_INFO(ainfo) { \ 6865310Sarchie { "ipfw", (ainfo) }, \ 6965310Sarchie { "debugLevel", &ng_parse_uint8_type }, \ 7065310Sarchie { "loopTimeout", &ng_parse_uint32_type }, \ 7165310Sarchie { "maxStaleness", &ng_parse_uint32_type }, \ 7265310Sarchie { "minStableAge", &ng_parse_uint32_type }, \ 7365310Sarchie { NULL } \ 7465310Sarchie} 7565310Sarchie 7665310Sarchie/* Statistics structure (one for each link) */ 7765310Sarchiestruct ng_bridge_link_stats { 7865310Sarchie u_int64_t recvOctets; /* total octets rec'd on link */ 7965310Sarchie u_int64_t recvPackets; /* total pkts rec'd on link */ 8065310Sarchie u_int64_t recvMulticasts; /* multicast pkts rec'd on link */ 8165310Sarchie u_int64_t recvBroadcasts; /* broadcast pkts rec'd on link */ 8265310Sarchie u_int64_t recvUnknown; /* pkts rec'd with unknown dest addr */ 8365310Sarchie u_int64_t recvRunts; /* pkts rec'd less than 14 bytes */ 8465310Sarchie u_int64_t recvInvalid; /* pkts rec'd with bogus source addr */ 8565310Sarchie u_int64_t xmitOctets; /* total octets xmit'd on link */ 8665310Sarchie u_int64_t xmitPackets; /* total pkts xmit'd on link */ 8765310Sarchie u_int64_t xmitMulticasts; /* multicast pkts xmit'd on link */ 8865310Sarchie u_int64_t xmitBroadcasts; /* broadcast pkts xmit'd on link */ 8965310Sarchie u_int64_t loopDrops; /* pkts dropped due to loopback */ 9065310Sarchie u_int64_t loopDetects; /* number of loop detections */ 9165310Sarchie u_int64_t memoryFailures; /* times couldn't get mem or mbuf */ 9265310Sarchie}; 9365310Sarchie 9465310Sarchie/* Keep this in sync with the above structure definition */ 9565310Sarchie#define NG_BRIDGE_STATS_TYPE_INFO { \ 9665310Sarchie { "recvOctets", &ng_parse_uint64_type }, \ 9765310Sarchie { "recvPackets", &ng_parse_uint64_type }, \ 9865310Sarchie { "recvMulticast", &ng_parse_uint64_type }, \ 9965310Sarchie { "recvBroadcast", &ng_parse_uint64_type }, \ 10065310Sarchie { "recvUnknown", &ng_parse_uint64_type }, \ 10165310Sarchie { "recvRunts", &ng_parse_uint64_type }, \ 10265310Sarchie { "recvInvalid", &ng_parse_uint64_type }, \ 10365310Sarchie { "xmitOctets", &ng_parse_uint64_type }, \ 10465310Sarchie { "xmitPackets", &ng_parse_uint64_type }, \ 10565310Sarchie { "xmitMulticasts", &ng_parse_uint64_type }, \ 10665310Sarchie { "xmitBroadcasts", &ng_parse_uint64_type }, \ 10765310Sarchie { "loopDrops", &ng_parse_uint64_type }, \ 10865310Sarchie { "loopDetects", &ng_parse_uint64_type }, \ 10965310Sarchie { "memoryFailures", &ng_parse_uint64_type }, \ 11065310Sarchie { NULL } \ 11165310Sarchie} 11265310Sarchie 11365310Sarchie/* Structure describing a single host */ 11465310Sarchiestruct ng_bridge_host { 11565310Sarchie u_char addr[6]; /* ethernet address */ 11665310Sarchie u_int16_t linkNum; /* link where addr can be found */ 11765310Sarchie u_int16_t age; /* seconds ago entry was created */ 11865310Sarchie u_int16_t staleness; /* seconds ago host last heard from */ 11965310Sarchie}; 12065310Sarchie 12165310Sarchie/* Keep this in sync with the above structure definition */ 12265310Sarchie#define NG_BRIDGE_HOST_TYPE_INFO(entype) { \ 12365310Sarchie { "addr", (entype) }, \ 12465310Sarchie { "linkNum", &ng_parse_uint16_type }, \ 12565310Sarchie { "age", &ng_parse_uint16_type }, \ 12665310Sarchie { "staleness", &ng_parse_uint16_type }, \ 12765310Sarchie { NULL } \ 12865310Sarchie} 12965310Sarchie 13065310Sarchie/* Structure returned by NGM_BRIDGE_GET_TABLE */ 13165310Sarchiestruct ng_bridge_host_ary { 13265310Sarchie u_int32_t numHosts; 133151800Sru struct ng_bridge_host hosts[]; 13465310Sarchie}; 13565310Sarchie 13665310Sarchie/* Keep this in sync with the above structure definition */ 13765310Sarchie#define NG_BRIDGE_HOST_ARY_TYPE_INFO(harytype) { \ 13865310Sarchie { "numHosts", &ng_parse_uint32_type }, \ 13965310Sarchie { "hosts", (harytype) }, \ 14065310Sarchie { NULL } \ 14165310Sarchie} 14265310Sarchie 14365310Sarchie/* Netgraph control messages */ 14465310Sarchieenum { 14565310Sarchie NGM_BRIDGE_SET_CONFIG = 1, /* set node configuration */ 14665310Sarchie NGM_BRIDGE_GET_CONFIG, /* get node configuration */ 14765310Sarchie NGM_BRIDGE_RESET, /* reset (forget) all information */ 14865310Sarchie NGM_BRIDGE_GET_STATS, /* get link stats */ 14965310Sarchie NGM_BRIDGE_CLR_STATS, /* clear link stats */ 15065310Sarchie NGM_BRIDGE_GETCLR_STATS, /* atomically get & clear link stats */ 15165310Sarchie NGM_BRIDGE_GET_TABLE, /* get link table */ 152207680Szec NGM_BRIDGE_SET_PERSISTENT, /* set persistent mode */ 15365310Sarchie}; 15465310Sarchie 15565310Sarchie#endif /* _NETGRAPH_NG_BRIDGE_H_ */ 15665310Sarchie 157