1 /* 2 * Copyright (c) 1989 Stephen Deering. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Stephen Deering of Stanford University. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by the University of 20 * California, Berkeley and its contributors. 21 * 4. Neither the name of the University nor the names of its contributors 22 * may be used to endorse or promote products derived from this software 23 * without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * @(#)ip_mroute.h 8.1 (Berkeley) 6/10/93 38 * $Id: ip_mroute.h,v 1.4 1994/09/06 22:42:23 wollman Exp $ 39 */ 40 41 #ifndef _NETINET_IP_MROUTE_H_ 42 #define _NETINET_IP_MROUTE_H_ 43 44 /* 45 * Definitions for the kernel part of DVMRP, 46 * a Distance-Vector Multicast Routing Protocol. 47 * (See RFC-1075.) 48 * 49 * Written by David Waitzman, BBN Labs, August 1988. 50 * Modified by Steve Deering, Stanford, February 1989. 51 * Modified by Ajit Thyagarajan, PARC, August 1993. 52 * Modified by Ajit Thyagarajan, PARC, August 1994. 53 * 54 * MROUTING 1.5 55 */ 56 57 58 /* 59 * DVMRP-specific setsockopt commands. 60 */ 61 #define DVMRP_INIT 100 /* initialize forwarder */ 62 #define DVMRP_DONE 101 /* shut down forwarder */ 63 #define DVMRP_ADD_VIF 102 /* create virtual interface */ 64 #define DVMRP_DEL_VIF 103 /* delete virtual interface */ 65 #define DVMRP_ADD_MFC 104 /* insert forwarding cache entry */ 66 #define DVMRP_DEL_MFC 105 /* delete forwarding cache entry */ 67 68 #define GET_TIME(t) microtime(&t) 69 70 /* 71 * Types and macros for handling bitmaps with one bit per virtual interface. 72 */ 73 #define MAXVIFS 32 74 typedef u_long vifbitmap_t; 75 typedef u_short vifi_t; /* type of a vif index */ 76 77 #define VIFM_SET(n, m) ((m) |= (1 << (n))) 78 #define VIFM_CLR(n, m) ((m) &= ~(1 << (n))) 79 #define VIFM_ISSET(n, m) ((m) & (1 << (n))) 80 #define VIFM_CLRALL(m) ((m) = 0x00000000) 81 #define VIFM_COPY(mfrom, mto) ((mto) = (mfrom)) 82 #define VIFM_SAME(m1, m2) ((m1) == (m2)) 83 84 85 /* 86 * Argument structure for DVMRP_ADD_VIF. 87 * (DVMRP_DEL_VIF takes a single vifi_t argument.) 88 */ 89 struct vifctl { 90 vifi_t vifc_vifi; /* the index of the vif to be added */ 91 u_char vifc_flags; /* VIFF_ flags defined below */ 92 u_char vifc_threshold; /* min ttl required to forward on vif */ 93 u_int vifc_rate_limit; /* max tate */ 94 struct in_addr vifc_lcl_addr; /* local interface address */ 95 struct in_addr vifc_rmt_addr; /* remote address (tunnels only) */ 96 }; 97 98 #define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */ 99 #define VIFF_SRCRT 0x2 /* tunnel uses IP source routing */ 100 101 /* 102 * Argument structure for DVMRP_ADD_MFC 103 * (mfcc_tos to be added at a future point) 104 */ 105 struct mfcctl { 106 struct in_addr mfcc_origin; /* subnet origin of mcasts */ 107 struct in_addr mfcc_mcastgrp; /* multicast group associated*/ 108 struct in_addr mfcc_originmask; /* subnet mask for origin */ 109 vifi_t mfcc_parent; /* incoming vif */ 110 u_char mfcc_ttls[MAXVIFS]; /* forwarding ttls on vifs */ 111 }; 112 113 /* 114 * Argument structure for DVMRP_DEL_MFC 115 */ 116 struct delmfcctl { 117 struct in_addr mfcc_origin; /* subnet origin of multicasts */ 118 struct in_addr mfcc_mcastgrp; /* multicast group assoc. w/ origin */ 119 }; 120 121 /* 122 * Argument structure used by RSVP daemon to get vif information 123 */ 124 struct vif_req { 125 u_char v_flags; /* VIFF_ flags defined above */ 126 u_char v_threshold; /* min ttl required to forward on vif */ 127 struct in_addr v_lcl_addr; /* local interface address */ 128 struct in_addr v_rmt_addr; 129 char v_if_name[IFNAMSIZ]; /* if name */ 130 }; 131 132 struct vif_conf { 133 u_int vifc_len; 134 u_int vifc_num; 135 struct vif_req *vifc_req; 136 }; 137 138 /* 139 * The kernel's multicast routing statistics. 140 */ 141 struct mrtstat { 142 u_long mrts_mfc_lookups; /* # forw. cache hash table hits */ 143 u_long mrts_mfc_misses; /* # forw. cache hash table misses */ 144 u_long mrts_upcalls; /* # calls to mrouted */ 145 u_long mrts_no_route; /* no route for packet's origin */ 146 u_long mrts_bad_tunnel; /* malformed tunnel options */ 147 u_long mrts_cant_tunnel; /* no room for tunnel options */ 148 u_long mrts_wrong_if; /* arrived on wrong interface */ 149 u_long mrts_upq_ovflw; /* upcall Q overflow */ 150 u_long mrts_cache_cleanups; /* # entries with no upcalls */ 151 u_long mrts_drop_sel; /* pkts dropped selectively */ 152 u_long mrts_q_overflow; /* pkts dropped - Q overflow */ 153 u_long mrts_pkt2large; /* pkts dropped - size > BKT SIZE */ 154 }; 155 156 /* 157 * Argument structure used by mrouted to get src-grp pkt counts 158 */ 159 struct sioc_sg_req { 160 struct in_addr src; 161 struct in_addr grp; 162 u_long count; 163 }; 164 165 /* 166 * Argument structure used by mrouted to get vif pkt counts 167 */ 168 struct sioc_vif_req { 169 vifi_t vifi; 170 u_long icount; 171 u_long ocount; 172 }; 173 174 175 #ifdef KERNEL 176 177 struct vif { 178 u_char v_flags; /* VIFF_ flags defined above */ 179 u_char v_threshold; /* min ttl required to forward on vif*/ 180 u_int v_rate_limit; /* max rate */ 181 struct tbf *v_tbf; /* token bucket structure at intf. */ 182 struct in_addr v_lcl_addr; /* local interface address */ 183 struct in_addr v_rmt_addr; /* remote address (tunnels only) */ 184 struct ifnet *v_ifp; /* pointer to interface */ 185 u_long v_pkt_in; /* # pkts in on interface */ 186 u_long v_pkt_out; /* # pkts out on interface */ 187 }; 188 189 /* 190 * The kernel's multicast forwarding cache entry structure 191 * (A field for the type of service (mfc_tos) is to be added 192 * at a future point) 193 */ 194 struct mfc { 195 struct in_addr mfc_origin; /* subnet origin of mcasts */ 196 struct in_addr mfc_mcastgrp; /* multicast group associated*/ 197 struct in_addr mfc_originmask; /* subnet mask for origin */ 198 vifi_t mfc_parent; /* incoming vif */ 199 u_char mfc_ttls[MAXVIFS]; /* forwarding ttls on vifs */ 200 u_long mfc_pkt_cnt; /* pkt count for src-grp */ 201 }; 202 203 /* 204 * Argument structure used for pkt info. while upcall is made 205 */ 206 struct rtdetq { 207 struct mbuf *m; 208 struct ifnet *ifp; 209 u_long tunnel_src; 210 struct ip_moptions *imo; 211 }; 212 213 #define MFCTBLSIZ 256 214 #if (MFCTBLSIZ & (MFCTBLSIZ - 1)) == 0 /* from sys:route.h */ 215 #define MFCHASHMOD(h) ((h) & (MFCTBLSIZ - 1)) 216 #else 217 #define MFCHASHMOD(h) ((h) % MFCTBLSIZ) 218 #endif 219 220 #define MAX_UPQ 4 /* max. no of pkts in upcall Q */ 221 222 /* 223 * Token Bucket filter code 224 */ 225 #define MAX_BKT_SIZE 10000 /* 10K bytes size */ 226 #define MAXQSIZE 10 /* max # of pkts in queue */ 227 228 /* 229 * queue structure at each vif 230 */ 231 struct pkt_queue 232 { 233 u_long pkt_len; /* length of packet in queue */ 234 struct mbuf *pkt_m; /* pointer to packet mbuf */ 235 struct ip *pkt_ip; /* pointer to ip header */ 236 struct ip_moptions *pkt_imo; /* IP multicast options assoc. with pkt */ 237 }; 238 239 /* 240 * the token bucket filter at each vif 241 */ 242 struct tbf 243 { 244 u_long last_pkt_t; /* arr. time of last pkt */ 245 u_long n_tok; /* no of tokens in bucket */ 246 u_long q_len; /* length of queue at this vif */ 247 }; 248 249 extern int (*ip_mrouter_cmd) __P((int, struct socket *, struct mbuf *)); 250 extern int (*ip_mrouter_done) __P((void)); 251 252 #endif /* KERNEL */ 253 254 #endif /* _NETINET_IP_MROUTE_H_ */ 255