11eaf0ac3Slogwang /*- 2*d4a07e70Sfengbojiang * SPDX-License-Identifier: BSD-3-Clause 3*d4a07e70Sfengbojiang * 41eaf0ac3Slogwang * Copyright (c) 1989 Stephen Deering. 51eaf0ac3Slogwang * Copyright (c) 1992, 1993 61eaf0ac3Slogwang * The Regents of the University of California. All rights reserved. 71eaf0ac3Slogwang * 81eaf0ac3Slogwang * This code is derived from software contributed to Berkeley by 91eaf0ac3Slogwang * Stephen Deering of Stanford University. 101eaf0ac3Slogwang * 111eaf0ac3Slogwang * Redistribution and use in source and binary forms, with or without 121eaf0ac3Slogwang * modification, are permitted provided that the following conditions 131eaf0ac3Slogwang * are met: 141eaf0ac3Slogwang * 1. Redistributions of source code must retain the above copyright 151eaf0ac3Slogwang * notice, this list of conditions and the following disclaimer. 161eaf0ac3Slogwang * 2. Redistributions in binary form must reproduce the above copyright 171eaf0ac3Slogwang * notice, this list of conditions and the following disclaimer in the 181eaf0ac3Slogwang * documentation and/or other materials provided with the distribution. 19*d4a07e70Sfengbojiang * 3. Neither the name of the University nor the names of its contributors 201eaf0ac3Slogwang * may be used to endorse or promote products derived from this software 211eaf0ac3Slogwang * without specific prior written permission. 221eaf0ac3Slogwang * 231eaf0ac3Slogwang * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 241eaf0ac3Slogwang * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 251eaf0ac3Slogwang * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 261eaf0ac3Slogwang * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 271eaf0ac3Slogwang * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 281eaf0ac3Slogwang * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 291eaf0ac3Slogwang * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 301eaf0ac3Slogwang * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 311eaf0ac3Slogwang * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 321eaf0ac3Slogwang * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 331eaf0ac3Slogwang * SUCH DAMAGE. 341eaf0ac3Slogwang * 351eaf0ac3Slogwang * @(#)ip_mroute.h 8.1 (Berkeley) 6/10/93 361eaf0ac3Slogwang * $FreeBSD$ 371eaf0ac3Slogwang */ 381eaf0ac3Slogwang 391eaf0ac3Slogwang #ifndef _NETINET_IP_MROUTE_H_ 401eaf0ac3Slogwang #define _NETINET_IP_MROUTE_H_ 411eaf0ac3Slogwang 421eaf0ac3Slogwang /* 431eaf0ac3Slogwang * Definitions for IP multicast forwarding. 441eaf0ac3Slogwang * 451eaf0ac3Slogwang * Written by David Waitzman, BBN Labs, August 1988. 461eaf0ac3Slogwang * Modified by Steve Deering, Stanford, February 1989. 471eaf0ac3Slogwang * Modified by Ajit Thyagarajan, PARC, August 1993. 481eaf0ac3Slogwang * Modified by Ajit Thyagarajan, PARC, August 1994. 491eaf0ac3Slogwang * Modified by Ahmed Helmy, SGI, June 1996. 501eaf0ac3Slogwang * Modified by Pavlin Radoslavov, ICSI, October 2002. 511eaf0ac3Slogwang * 521eaf0ac3Slogwang * MROUTING Revision: 3.3.1.3 531eaf0ac3Slogwang * and PIM-SMv2 and PIM-DM support, advanced API support, 541eaf0ac3Slogwang * bandwidth metering and signaling. 551eaf0ac3Slogwang */ 561eaf0ac3Slogwang 571eaf0ac3Slogwang /* 581eaf0ac3Slogwang * Multicast Routing set/getsockopt commands. 591eaf0ac3Slogwang */ 601eaf0ac3Slogwang #define MRT_INIT 100 /* initialize forwarder */ 611eaf0ac3Slogwang #define MRT_DONE 101 /* shut down forwarder */ 621eaf0ac3Slogwang #define MRT_ADD_VIF 102 /* create virtual interface */ 631eaf0ac3Slogwang #define MRT_DEL_VIF 103 /* delete virtual interface */ 641eaf0ac3Slogwang #define MRT_ADD_MFC 104 /* insert forwarding cache entry */ 651eaf0ac3Slogwang #define MRT_DEL_MFC 105 /* delete forwarding cache entry */ 661eaf0ac3Slogwang #define MRT_VERSION 106 /* get kernel version number */ 671eaf0ac3Slogwang #define MRT_ASSERT 107 /* enable assert processing */ 681eaf0ac3Slogwang #define MRT_PIM MRT_ASSERT /* enable PIM processing */ 691eaf0ac3Slogwang #define MRT_API_SUPPORT 109 /* supported MRT API */ 701eaf0ac3Slogwang #define MRT_API_CONFIG 110 /* config MRT API */ 711eaf0ac3Slogwang #define MRT_ADD_BW_UPCALL 111 /* create bandwidth monitor */ 721eaf0ac3Slogwang #define MRT_DEL_BW_UPCALL 112 /* delete bandwidth monitor */ 731eaf0ac3Slogwang 741eaf0ac3Slogwang /* 751eaf0ac3Slogwang * Types and macros for handling bitmaps with one bit per virtual interface. 761eaf0ac3Slogwang */ 771eaf0ac3Slogwang #define MAXVIFS 32 781eaf0ac3Slogwang typedef u_long vifbitmap_t; 791eaf0ac3Slogwang typedef u_short vifi_t; /* type of a vif index */ 801eaf0ac3Slogwang #define ALL_VIFS (vifi_t)-1 811eaf0ac3Slogwang 821eaf0ac3Slogwang #define VIFM_SET(n, m) ((m) |= (1 << (n))) 831eaf0ac3Slogwang #define VIFM_CLR(n, m) ((m) &= ~(1 << (n))) 841eaf0ac3Slogwang #define VIFM_ISSET(n, m) ((m) & (1 << (n))) 851eaf0ac3Slogwang #define VIFM_CLRALL(m) ((m) = 0x00000000) 861eaf0ac3Slogwang #define VIFM_COPY(mfrom, mto) ((mto) = (mfrom)) 871eaf0ac3Slogwang #define VIFM_SAME(m1, m2) ((m1) == (m2)) 881eaf0ac3Slogwang 891eaf0ac3Slogwang struct mfc; 901eaf0ac3Slogwang 911eaf0ac3Slogwang /* 921eaf0ac3Slogwang * Argument structure for MRT_ADD_VIF. 931eaf0ac3Slogwang * (MRT_DEL_VIF takes a single vifi_t argument.) 941eaf0ac3Slogwang */ 951eaf0ac3Slogwang struct vifctl { 961eaf0ac3Slogwang vifi_t vifc_vifi; /* the index of the vif to be added */ 971eaf0ac3Slogwang u_char vifc_flags; /* VIFF_ flags defined below */ 981eaf0ac3Slogwang u_char vifc_threshold; /* min ttl required to forward on vif */ 991eaf0ac3Slogwang u_int vifc_rate_limit; /* max rate */ 1001eaf0ac3Slogwang struct in_addr vifc_lcl_addr; /* local interface address */ 1011eaf0ac3Slogwang struct in_addr vifc_rmt_addr; /* remote address (tunnels only) */ 1021eaf0ac3Slogwang }; 1031eaf0ac3Slogwang 1041eaf0ac3Slogwang #define VIFF_TUNNEL 0x1 /* no-op; retained for old source */ 1051eaf0ac3Slogwang #define VIFF_SRCRT 0x2 /* no-op; retained for old source */ 1061eaf0ac3Slogwang #define VIFF_REGISTER 0x4 /* used for PIM Register encap/decap */ 1071eaf0ac3Slogwang 1081eaf0ac3Slogwang /* 1091eaf0ac3Slogwang * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC 1101eaf0ac3Slogwang * XXX if you change this, make sure to change struct mfcctl2 as well. 1111eaf0ac3Slogwang */ 1121eaf0ac3Slogwang struct mfcctl { 1131eaf0ac3Slogwang struct in_addr mfcc_origin; /* ip origin of mcasts */ 1141eaf0ac3Slogwang struct in_addr mfcc_mcastgrp; /* multicast group associated*/ 1151eaf0ac3Slogwang vifi_t mfcc_parent; /* incoming vif */ 1161eaf0ac3Slogwang u_char mfcc_ttls[MAXVIFS]; /* forwarding ttls on vifs */ 1171eaf0ac3Slogwang }; 1181eaf0ac3Slogwang 1191eaf0ac3Slogwang /* 1201eaf0ac3Slogwang * The new argument structure for MRT_ADD_MFC and MRT_DEL_MFC overlays 1211eaf0ac3Slogwang * and extends the old struct mfcctl. 1221eaf0ac3Slogwang */ 1231eaf0ac3Slogwang struct mfcctl2 { 1241eaf0ac3Slogwang /* the mfcctl fields */ 1251eaf0ac3Slogwang struct in_addr mfcc_origin; /* ip origin of mcasts */ 1261eaf0ac3Slogwang struct in_addr mfcc_mcastgrp; /* multicast group associated*/ 1271eaf0ac3Slogwang vifi_t mfcc_parent; /* incoming vif */ 1281eaf0ac3Slogwang u_char mfcc_ttls[MAXVIFS]; /* forwarding ttls on vifs */ 1291eaf0ac3Slogwang 1301eaf0ac3Slogwang /* extension fields */ 1311eaf0ac3Slogwang uint8_t mfcc_flags[MAXVIFS]; /* the MRT_MFC_FLAGS_* flags */ 1321eaf0ac3Slogwang struct in_addr mfcc_rp; /* the RP address */ 1331eaf0ac3Slogwang }; 1341eaf0ac3Slogwang /* 1351eaf0ac3Slogwang * The advanced-API flags. 1361eaf0ac3Slogwang * 1371eaf0ac3Slogwang * The MRT_MFC_FLAGS_XXX API flags are also used as flags 1381eaf0ac3Slogwang * for the mfcc_flags field. 1391eaf0ac3Slogwang */ 1401eaf0ac3Slogwang #define MRT_MFC_FLAGS_DISABLE_WRONGVIF (1 << 0) /* disable WRONGVIF signals */ 1411eaf0ac3Slogwang #define MRT_MFC_FLAGS_BORDER_VIF (1 << 1) /* border vif */ 1421eaf0ac3Slogwang #define MRT_MFC_RP (1 << 8) /* enable RP address */ 1431eaf0ac3Slogwang #define MRT_MFC_BW_UPCALL (1 << 9) /* enable bw upcalls */ 1441eaf0ac3Slogwang #define MRT_MFC_FLAGS_ALL (MRT_MFC_FLAGS_DISABLE_WRONGVIF | \ 1451eaf0ac3Slogwang MRT_MFC_FLAGS_BORDER_VIF) 1461eaf0ac3Slogwang #define MRT_API_FLAGS_ALL (MRT_MFC_FLAGS_ALL | \ 1471eaf0ac3Slogwang MRT_MFC_RP | \ 1481eaf0ac3Slogwang MRT_MFC_BW_UPCALL) 1491eaf0ac3Slogwang 1501eaf0ac3Slogwang /* 1511eaf0ac3Slogwang * Structure for installing or delivering an upcall if the 1521eaf0ac3Slogwang * measured bandwidth is above or below a threshold. 1531eaf0ac3Slogwang * 1541eaf0ac3Slogwang * User programs (e.g. daemons) may have a need to know when the 1551eaf0ac3Slogwang * bandwidth used by some data flow is above or below some threshold. 1561eaf0ac3Slogwang * This interface allows the userland to specify the threshold (in 1571eaf0ac3Slogwang * bytes and/or packets) and the measurement interval. Flows are 1581eaf0ac3Slogwang * all packet with the same source and destination IP address. 1591eaf0ac3Slogwang * At the moment the code is only used for multicast destinations 1601eaf0ac3Slogwang * but there is nothing that prevents its use for unicast. 1611eaf0ac3Slogwang * 1621eaf0ac3Slogwang * The measurement interval cannot be shorter than some Tmin (currently, 3s). 1631eaf0ac3Slogwang * The threshold is set in packets and/or bytes per_interval. 1641eaf0ac3Slogwang * 1651eaf0ac3Slogwang * Measurement works as follows: 1661eaf0ac3Slogwang * 1671eaf0ac3Slogwang * For >= measurements: 1681eaf0ac3Slogwang * The first packet marks the start of a measurement interval. 1691eaf0ac3Slogwang * During an interval we count packets and bytes, and when we 1701eaf0ac3Slogwang * pass the threshold we deliver an upcall and we are done. 1711eaf0ac3Slogwang * The first packet after the end of the interval resets the 1721eaf0ac3Slogwang * count and restarts the measurement. 1731eaf0ac3Slogwang * 1741eaf0ac3Slogwang * For <= measurement: 1751eaf0ac3Slogwang * We start a timer to fire at the end of the interval, and 1761eaf0ac3Slogwang * then for each incoming packet we count packets and bytes. 1771eaf0ac3Slogwang * When the timer fires, we compare the value with the threshold, 1781eaf0ac3Slogwang * schedule an upcall if we are below, and restart the measurement 1791eaf0ac3Slogwang * (reschedule timer and zero counters). 1801eaf0ac3Slogwang */ 1811eaf0ac3Slogwang 1821eaf0ac3Slogwang struct bw_data { 1831eaf0ac3Slogwang struct timeval b_time; 1841eaf0ac3Slogwang uint64_t b_packets; 1851eaf0ac3Slogwang uint64_t b_bytes; 1861eaf0ac3Slogwang }; 1871eaf0ac3Slogwang 1881eaf0ac3Slogwang struct bw_upcall { 1891eaf0ac3Slogwang struct in_addr bu_src; /* source address */ 1901eaf0ac3Slogwang struct in_addr bu_dst; /* destination address */ 1911eaf0ac3Slogwang uint32_t bu_flags; /* misc flags (see below) */ 1921eaf0ac3Slogwang #define BW_UPCALL_UNIT_PACKETS (1 << 0) /* threshold (in packets) */ 1931eaf0ac3Slogwang #define BW_UPCALL_UNIT_BYTES (1 << 1) /* threshold (in bytes) */ 1941eaf0ac3Slogwang #define BW_UPCALL_GEQ (1 << 2) /* upcall if bw >= threshold */ 1951eaf0ac3Slogwang #define BW_UPCALL_LEQ (1 << 3) /* upcall if bw <= threshold */ 1961eaf0ac3Slogwang #define BW_UPCALL_DELETE_ALL (1 << 4) /* delete all upcalls for s,d*/ 1971eaf0ac3Slogwang struct bw_data bu_threshold; /* the bw threshold */ 1981eaf0ac3Slogwang struct bw_data bu_measured; /* the measured bw */ 1991eaf0ac3Slogwang }; 2001eaf0ac3Slogwang 2011eaf0ac3Slogwang /* max. number of upcalls to deliver together */ 2021eaf0ac3Slogwang #define BW_UPCALLS_MAX 128 2031eaf0ac3Slogwang /* min. threshold time interval for bandwidth measurement */ 2041eaf0ac3Slogwang #define BW_UPCALL_THRESHOLD_INTERVAL_MIN_SEC 3 2051eaf0ac3Slogwang #define BW_UPCALL_THRESHOLD_INTERVAL_MIN_USEC 0 2061eaf0ac3Slogwang 2071eaf0ac3Slogwang /* 2081eaf0ac3Slogwang * The kernel's multicast routing statistics. 2091eaf0ac3Slogwang */ 2101eaf0ac3Slogwang struct mrtstat { 2111eaf0ac3Slogwang uint64_t mrts_mfc_lookups; /* # forw. cache hash table hits */ 2121eaf0ac3Slogwang uint64_t mrts_mfc_misses; /* # forw. cache hash table misses */ 2131eaf0ac3Slogwang uint64_t mrts_upcalls; /* # calls to multicast routing daemon */ 2141eaf0ac3Slogwang uint64_t mrts_no_route; /* no route for packet's origin */ 2151eaf0ac3Slogwang uint64_t mrts_bad_tunnel; /* malformed tunnel options */ 2161eaf0ac3Slogwang uint64_t mrts_cant_tunnel; /* no room for tunnel options */ 2171eaf0ac3Slogwang uint64_t mrts_wrong_if; /* arrived on wrong interface */ 2181eaf0ac3Slogwang uint64_t mrts_upq_ovflw; /* upcall Q overflow */ 2191eaf0ac3Slogwang uint64_t mrts_cache_cleanups; /* # entries with no upcalls */ 2201eaf0ac3Slogwang uint64_t mrts_drop_sel; /* pkts dropped selectively */ 2211eaf0ac3Slogwang uint64_t mrts_q_overflow; /* pkts dropped - Q overflow */ 2221eaf0ac3Slogwang uint64_t mrts_pkt2large; /* pkts dropped - size > BKT SIZE */ 2231eaf0ac3Slogwang uint64_t mrts_upq_sockfull; /* upcalls dropped - socket full */ 2241eaf0ac3Slogwang }; 2251eaf0ac3Slogwang 2261eaf0ac3Slogwang #ifdef _KERNEL 2271eaf0ac3Slogwang #define MRTSTAT_ADD(name, val) \ 2281eaf0ac3Slogwang VNET_PCPUSTAT_ADD(struct mrtstat, mrtstat, name, (val)) 2291eaf0ac3Slogwang #define MRTSTAT_INC(name) MRTSTAT_ADD(name, 1) 2301eaf0ac3Slogwang #endif 2311eaf0ac3Slogwang 2321eaf0ac3Slogwang /* 2331eaf0ac3Slogwang * Argument structure used by mrouted to get src-grp pkt counts 2341eaf0ac3Slogwang */ 2351eaf0ac3Slogwang struct sioc_sg_req { 2361eaf0ac3Slogwang struct in_addr src; 2371eaf0ac3Slogwang struct in_addr grp; 2381eaf0ac3Slogwang u_long pktcnt; 2391eaf0ac3Slogwang u_long bytecnt; 2401eaf0ac3Slogwang u_long wrong_if; 2411eaf0ac3Slogwang }; 2421eaf0ac3Slogwang 2431eaf0ac3Slogwang /* 2441eaf0ac3Slogwang * Argument structure used by mrouted to get vif pkt counts 2451eaf0ac3Slogwang */ 2461eaf0ac3Slogwang struct sioc_vif_req { 2471eaf0ac3Slogwang vifi_t vifi; /* vif number */ 2481eaf0ac3Slogwang u_long icount; /* Input packet count on vif */ 2491eaf0ac3Slogwang u_long ocount; /* Output packet count on vif */ 2501eaf0ac3Slogwang u_long ibytes; /* Input byte count on vif */ 2511eaf0ac3Slogwang u_long obytes; /* Output byte count on vif */ 2521eaf0ac3Slogwang }; 2531eaf0ac3Slogwang 2541eaf0ac3Slogwang /* 2551eaf0ac3Slogwang * The kernel's virtual-interface structure. 2561eaf0ac3Slogwang */ 2571eaf0ac3Slogwang struct vif { 2581eaf0ac3Slogwang u_char v_flags; /* VIFF_ flags defined above */ 2591eaf0ac3Slogwang u_char v_threshold; /* min ttl required to forward on vif*/ 2601eaf0ac3Slogwang struct in_addr v_lcl_addr; /* local interface address */ 2611eaf0ac3Slogwang struct in_addr v_rmt_addr; /* remote address (tunnels only) */ 2621eaf0ac3Slogwang struct ifnet *v_ifp; /* pointer to interface */ 2631eaf0ac3Slogwang u_long v_pkt_in; /* # pkts in on interface */ 2641eaf0ac3Slogwang u_long v_pkt_out; /* # pkts out on interface */ 2651eaf0ac3Slogwang u_long v_bytes_in; /* # bytes in on interface */ 2661eaf0ac3Slogwang u_long v_bytes_out; /* # bytes out on interface */ 2671eaf0ac3Slogwang }; 2681eaf0ac3Slogwang 2691eaf0ac3Slogwang #ifdef _KERNEL 2701eaf0ac3Slogwang /* 2711eaf0ac3Slogwang * The kernel's multicast forwarding cache entry structure 2721eaf0ac3Slogwang */ 2731eaf0ac3Slogwang struct mfc { 2741eaf0ac3Slogwang LIST_ENTRY(mfc) mfc_hash; 2751eaf0ac3Slogwang struct in_addr mfc_origin; /* IP origin of mcasts */ 2761eaf0ac3Slogwang struct in_addr mfc_mcastgrp; /* multicast group associated*/ 2771eaf0ac3Slogwang vifi_t mfc_parent; /* incoming vif */ 2781eaf0ac3Slogwang u_char mfc_ttls[MAXVIFS]; /* forwarding ttls on vifs */ 2791eaf0ac3Slogwang u_long mfc_pkt_cnt; /* pkt count for src-grp */ 2801eaf0ac3Slogwang u_long mfc_byte_cnt; /* byte count for src-grp */ 2811eaf0ac3Slogwang u_long mfc_wrong_if; /* wrong if for src-grp */ 2821eaf0ac3Slogwang int mfc_expire; /* time to clean entry up */ 2831eaf0ac3Slogwang struct timeval mfc_last_assert; /* last time I sent an assert*/ 2841eaf0ac3Slogwang uint8_t mfc_flags[MAXVIFS]; /* the MRT_MFC_FLAGS_* flags */ 2851eaf0ac3Slogwang struct in_addr mfc_rp; /* the RP address */ 2861eaf0ac3Slogwang struct bw_meter *mfc_bw_meter; /* list of bandwidth meters */ 2871eaf0ac3Slogwang u_long mfc_nstall; /* # of packets awaiting mfc */ 2881eaf0ac3Slogwang TAILQ_HEAD(, rtdetq) mfc_stall; /* q of packets awaiting mfc */ 2891eaf0ac3Slogwang }; 2901eaf0ac3Slogwang #endif /* _KERNEL */ 2911eaf0ac3Slogwang 2921eaf0ac3Slogwang /* 2931eaf0ac3Slogwang * Struct used to communicate from kernel to multicast router 2941eaf0ac3Slogwang * note the convenient similarity to an IP packet 2951eaf0ac3Slogwang */ 2961eaf0ac3Slogwang struct igmpmsg { 2971eaf0ac3Slogwang uint32_t unused1; 2981eaf0ac3Slogwang uint32_t unused2; 2991eaf0ac3Slogwang u_char im_msgtype; /* what type of message */ 3001eaf0ac3Slogwang #define IGMPMSG_NOCACHE 1 /* no MFC in the kernel */ 3011eaf0ac3Slogwang #define IGMPMSG_WRONGVIF 2 /* packet came from wrong interface */ 3021eaf0ac3Slogwang #define IGMPMSG_WHOLEPKT 3 /* PIM pkt for user level encap. */ 3031eaf0ac3Slogwang #define IGMPMSG_BW_UPCALL 4 /* BW monitoring upcall */ 3041eaf0ac3Slogwang u_char im_mbz; /* must be zero */ 3051eaf0ac3Slogwang u_char im_vif; /* vif rec'd on */ 3061eaf0ac3Slogwang u_char unused3; 3071eaf0ac3Slogwang struct in_addr im_src, im_dst; 3081eaf0ac3Slogwang }; 3091eaf0ac3Slogwang 3101eaf0ac3Slogwang #ifdef _KERNEL 3111eaf0ac3Slogwang /* 3121eaf0ac3Slogwang * Argument structure used for pkt info. while upcall is made 3131eaf0ac3Slogwang */ 3141eaf0ac3Slogwang struct rtdetq { 3151eaf0ac3Slogwang TAILQ_ENTRY(rtdetq) rte_link; 3161eaf0ac3Slogwang struct mbuf *m; /* A copy of the packet */ 3171eaf0ac3Slogwang struct ifnet *ifp; /* Interface pkt came in on */ 3181eaf0ac3Slogwang vifi_t xmt_vif; /* Saved copy of imo_multicast_vif */ 3191eaf0ac3Slogwang }; 3201eaf0ac3Slogwang #define MAX_UPQ 4 /* max. no of pkts in upcall Q */ 3211eaf0ac3Slogwang #endif /* _KERNEL */ 3221eaf0ac3Slogwang 3231eaf0ac3Slogwang /* 3241eaf0ac3Slogwang * Structure for measuring the bandwidth and sending an upcall if the 3251eaf0ac3Slogwang * measured bandwidth is above or below a threshold. 3261eaf0ac3Slogwang */ 3271eaf0ac3Slogwang struct bw_meter { 3281eaf0ac3Slogwang struct bw_meter *bm_mfc_next; /* next bw meter (same mfc) */ 3291eaf0ac3Slogwang struct bw_meter *bm_time_next; /* next bw meter (same time) */ 3301eaf0ac3Slogwang uint32_t bm_time_hash; /* the time hash value */ 3311eaf0ac3Slogwang struct mfc *bm_mfc; /* the corresponding mfc */ 3321eaf0ac3Slogwang uint32_t bm_flags; /* misc flags (see below) */ 3331eaf0ac3Slogwang #define BW_METER_UNIT_PACKETS (1 << 0) /* threshold (in packets) */ 3341eaf0ac3Slogwang #define BW_METER_UNIT_BYTES (1 << 1) /* threshold (in bytes) */ 3351eaf0ac3Slogwang #define BW_METER_GEQ (1 << 2) /* upcall if bw >= threshold */ 3361eaf0ac3Slogwang #define BW_METER_LEQ (1 << 3) /* upcall if bw <= threshold */ 3371eaf0ac3Slogwang #define BW_METER_USER_FLAGS (BW_METER_UNIT_PACKETS | \ 3381eaf0ac3Slogwang BW_METER_UNIT_BYTES | \ 3391eaf0ac3Slogwang BW_METER_GEQ | \ 3401eaf0ac3Slogwang BW_METER_LEQ) 3411eaf0ac3Slogwang 3421eaf0ac3Slogwang #define BW_METER_UPCALL_DELIVERED (1 << 24) /* upcall was delivered */ 3431eaf0ac3Slogwang 3441eaf0ac3Slogwang struct bw_data bm_threshold; /* the upcall threshold */ 3451eaf0ac3Slogwang struct bw_data bm_measured; /* the measured bw */ 3461eaf0ac3Slogwang struct timeval bm_start_time; /* abs. time */ 3471eaf0ac3Slogwang }; 3481eaf0ac3Slogwang 3491eaf0ac3Slogwang #ifdef _KERNEL 3501eaf0ac3Slogwang 3511eaf0ac3Slogwang struct sockopt; 3521eaf0ac3Slogwang 3531eaf0ac3Slogwang extern int (*ip_mrouter_set)(struct socket *, struct sockopt *); 3541eaf0ac3Slogwang extern int (*ip_mrouter_get)(struct socket *, struct sockopt *); 3551eaf0ac3Slogwang extern int (*ip_mrouter_done)(void); 3561eaf0ac3Slogwang extern int (*mrt_ioctl)(u_long, caddr_t, int); 3571eaf0ac3Slogwang 3581eaf0ac3Slogwang #endif /* _KERNEL */ 3591eaf0ac3Slogwang 3601eaf0ac3Slogwang #endif /* _NETINET_IP_MROUTE_H_ */ 361