/*1* ng_bridge.h2*/34/*-5* Copyright (c) 2000 Whistle Communications, Inc.6* All rights reserved.7*8* Subject to the following obligations and disclaimer of warranty, use and9* redistribution of this software, in source or object code forms, with or10* without modifications are expressly permitted by Whistle Communications;11* provided, however, that:12* 1. Any and all reproductions of the source or object code must include the13* copyright notice above and the following disclaimer of warranties; and14* 2. No rights are granted, in any manner or form, to use Whistle15* Communications, Inc. trademarks, including the mark "WHISTLE16* COMMUNICATIONS" on advertising, endorsements, or otherwise except as17* such appears in the above copyright notice or in the software.18*19* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND20* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO21* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,22* INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF23* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.24* WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY25* REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS26* SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.27* IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES28* RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING29* WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,30* PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR31* SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY32* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT33* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF34* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY35* OF SUCH DAMAGE.36*37* Author: Archie Cobbs <[email protected]>38*/3940#ifndef _NETGRAPH_NG_BRIDGE_H_41#define _NETGRAPH_NG_BRIDGE_H_4243/* Node type name and magic cookie */44#define NG_BRIDGE_NODE_TYPE "bridge"45#define NGM_BRIDGE_COOKIE 15693219934647/* Hook names */48#define NG_BRIDGE_HOOK_LINK_PREFIX "link" /* append decimal integer */49#define NG_BRIDGE_HOOK_LINK_FMT "link%d" /* for use with printf(3) */50#define NG_BRIDGE_HOOK_UPLINK_PREFIX "uplink" /* append decimal integer */51#define NG_BRIDGE_HOOK_UPLINK_FMT "uplink%d" /* for use with printf(3) */5253/* Node configuration structure */54struct ng_bridge_config {55u_char debugLevel; /* debug level */56u_int32_t loopTimeout; /* link loopback mute time */57u_int32_t maxStaleness; /* max host age before nuking */58u_int32_t minStableAge; /* min time for a stable host */59};6061/* Keep this in sync with the above structure definition */62#define NG_BRIDGE_CONFIG_TYPE_INFO { \63{ "debugLevel", &ng_parse_uint8_type }, \64{ "loopTimeout", &ng_parse_uint32_type }, \65{ "maxStaleness", &ng_parse_uint32_type }, \66{ "minStableAge", &ng_parse_uint32_type }, \67{ NULL } \68}6970/* Statistics structure (one for each link) */71struct ng_bridge_link_stats {72u_int64_t recvOctets; /* total octets rec'd on link */73u_int64_t recvPackets; /* total pkts rec'd on link */74u_int64_t recvMulticasts; /* multicast pkts rec'd on link */75u_int64_t recvBroadcasts; /* broadcast pkts rec'd on link */76u_int64_t recvUnknown; /* pkts rec'd with unknown dest addr */77u_int64_t recvRunts; /* pkts rec'd less than 14 bytes */78u_int64_t recvInvalid; /* pkts rec'd with bogus source addr */79u_int64_t xmitOctets; /* total octets xmit'd on link */80u_int64_t xmitPackets; /* total pkts xmit'd on link */81u_int64_t xmitMulticasts; /* multicast pkts xmit'd on link */82u_int64_t xmitBroadcasts; /* broadcast pkts xmit'd on link */83u_int64_t loopDrops; /* pkts dropped due to loopback */84u_int64_t loopDetects; /* number of loop detections */85u_int64_t memoryFailures; /* times couldn't get mem or mbuf */86};8788/* Keep this in sync with the above structure definition */89#define NG_BRIDGE_STATS_TYPE_INFO { \90{ "recvOctets", &ng_parse_uint64_type }, \91{ "recvPackets", &ng_parse_uint64_type }, \92{ "recvMulticast", &ng_parse_uint64_type }, \93{ "recvBroadcast", &ng_parse_uint64_type }, \94{ "recvUnknown", &ng_parse_uint64_type }, \95{ "recvRunts", &ng_parse_uint64_type }, \96{ "recvInvalid", &ng_parse_uint64_type }, \97{ "xmitOctets", &ng_parse_uint64_type }, \98{ "xmitPackets", &ng_parse_uint64_type }, \99{ "xmitMulticasts", &ng_parse_uint64_type }, \100{ "xmitBroadcasts", &ng_parse_uint64_type }, \101{ "loopDrops", &ng_parse_uint64_type }, \102{ "loopDetects", &ng_parse_uint64_type }, \103{ "memoryFailures", &ng_parse_uint64_type }, \104{ NULL } \105}106107struct ng_bridge_link;108typedef struct ng_bridge_link *link_p;109110/* external representation of the host */111struct ng_bridge_hostent {112u_char addr[6]; /* ethernet address */113char hook[NG_HOOKSIZ]; /* link where addr can be found */114u_int16_t age; /* seconds ago entry was created */115u_int16_t staleness; /* seconds ago host last heard from */116};117118/* Keep this in sync with the above structure definition */119#define NG_BRIDGE_HOST_TYPE_INFO(entype) { \120{ "addr", (entype) }, \121{ "hook", &ng_parse_hookbuf_type }, \122{ "age", &ng_parse_uint16_type }, \123{ "staleness", &ng_parse_uint16_type }, \124{ NULL } \125}126127/* Structure returned by NGM_BRIDGE_GET_TABLE */128struct ng_bridge_host_ary {129u_int32_t numHosts;130struct ng_bridge_hostent hosts[];131};132133/* Keep this in sync with the above structure definition */134#define NG_BRIDGE_HOST_ARY_TYPE_INFO(harytype) { \135{ "numHosts", &ng_parse_uint32_type }, \136{ "hosts", (harytype) }, \137{ NULL } \138}139140struct ng_bridge_move_host {141u_char addr[ETHER_ADDR_LEN]; /* ethernet address */142char hook[NG_HOOKSIZ]; /* link where addr can be found */143};144/* Keep this in sync with the above structure definition */145#define NG_BRIDGE_MOVE_HOST_TYPE_INFO(entype) { \146{ "addr", (entype) }, \147{ "hook", &ng_parse_hookbuf_type }, \148{ NULL } \149}150151/* Netgraph control messages */152enum {153NGM_BRIDGE_SET_CONFIG = 1, /* set node configuration */154NGM_BRIDGE_GET_CONFIG, /* get node configuration */155NGM_BRIDGE_RESET, /* reset (forget) all information */156NGM_BRIDGE_GET_STATS, /* get link stats */157NGM_BRIDGE_CLR_STATS, /* clear link stats */158NGM_BRIDGE_GETCLR_STATS, /* atomically get & clear link stats */159NGM_BRIDGE_GET_TABLE, /* get link table */160NGM_BRIDGE_SET_PERSISTENT, /* set persistent mode */161NGM_BRIDGE_MOVE_HOST, /* move a host to a link */162};163164#endif /* _NETGRAPH_NG_BRIDGE_H_ */165166167