2  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. 
   4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 
   6  * This file contains Original Code and/or Modifications of Original Code 
   7  * as defined in and that are subject to the Apple Public Source License 
   8  * Version 2.0 (the 'License'). You may not use this file except in 
   9  * compliance with the License. The rights granted to you under the License 
  10  * may not be used to create, or enable the creation or redistribution of, 
  11  * unlawful or unlicensed copies of an Apple operating system, or to 
  12  * circumvent, violate, or enable the circumvention or violation of, any 
  13  * terms of an Apple operating system software license agreement. 
  15  * Please obtain a copy of the License at 
  16  * http://www.opensource.apple.com/apsl/ and read it before using this file. 
  18  * The Original Code and all software distributed under the License are 
  19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
  22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  23  * Please see the License for the specific language governing rights and 
  24  * limitations under the License. 
  26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 
  29  * Copyright (c) 1989 Stephen Deering. 
  30  * Copyright (c) 1992, 1993 
  31  *      The Regents of the University of California.  All rights reserved. 
  33  * This code is derived from software contributed to Berkeley by 
  34  * Stephen Deering of Stanford University. 
  36  * Redistribution and use in source and binary forms, with or without 
  37  * modification, are permitted provided that the following conditions 
  39  * 1. Redistributions of source code must retain the above copyright 
  40  *    notice, this list of conditions and the following disclaimer. 
  41  * 2. Redistributions in binary form must reproduce the above copyright 
  42  *    notice, this list of conditions and the following disclaimer in the 
  43  *    documentation and/or other materials provided with the distribution. 
  44  * 3. All advertising materials mentioning features or use of this software 
  45  *    must display the following acknowledgement: 
  46  *      This product includes software developed by the University of 
  47  *      California, Berkeley and its contributors. 
  48  * 4. Neither the name of the University nor the names of its contributors 
  49  *    may be used to endorse or promote products derived from this software 
  50  *    without specific prior written permission. 
  52  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 
  53  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
  54  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
  55  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 
  56  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
  57  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
  58  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
  59  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
  60  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
  61  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
  64  *      @(#)ip_mroute.h 8.1 (Berkeley) 6/10/93 
  67 #ifndef _NETINET_IP_MROUTE_H_ 
  68 #define _NETINET_IP_MROUTE_H_ 
  69 #include <sys/appleapiopts.h> 
  72  * Definitions for IP multicast forwarding. 
  74  * Written by David Waitzman, BBN Labs, August 1988. 
  75  * Modified by Steve Deering, Stanford, February 1989. 
  76  * Modified by Ajit Thyagarajan, PARC, August 1993. 
  77  * Modified by Ajit Thyagarajan, PARC, August 1994. 
  79  * MROUTING Revision: 3.3.1.3 
  84  * Multicast Routing set/getsockopt commands. 
  86 #define MRT_INIT        100     /* initialize forwarder */ 
  87 #define MRT_DONE        101     /* shut down forwarder */ 
  88 #define MRT_ADD_VIF     102     /* create virtual interface */ 
  89 #define MRT_DEL_VIF     103     /* delete virtual interface */ 
  90 #define MRT_ADD_MFC     104     /* insert forwarding cache entry */ 
  91 #define MRT_DEL_MFC     105     /* delete forwarding cache entry */ 
  92 #define MRT_VERSION     106     /* get kernel version number */ 
  93 #define MRT_ASSERT      107     /* enable PIM assert processing */ 
  97 #define GET_TIME(t)     microtime(&t) 
 100 #ifndef CONFIG_MAXVIFS 
 101 #define CONFIG_MAXVIFS 32  /* 4635538 temp workaround */ 
 104 #ifndef CONFIG_MFCTBLSIZ 
 105 #define CONFIG_MFCTBLSIZ 256  /* 4635538 temp workaround */ 
 109  * Types and macros for handling bitmaps with one bit per virtual interface. 
 111 typedef u_long vifbitmap_t
; 
 112 typedef u_short vifi_t
;         /* type of a vif index */ 
 113 #define ALL_VIFS (vifi_t)-1 
 115 #define VIFM_SET(n, m)          ((m) |= (1 << (n))) 
 116 #define VIFM_CLR(n, m)          ((m) &= ~(1 << (n))) 
 117 #define VIFM_ISSET(n, m)        ((m) & (1 << (n))) 
 118 #define VIFM_CLRALL(m)          ((m) = 0x00000000) 
 119 #define VIFM_COPY(mfrom, mto)   ((mto) = (mfrom)) 
 120 #define VIFM_SAME(m1, m2)       ((m1) == (m2)) 
 124  * Argument structure for MRT_ADD_VIF. 
 125  * (MRT_DEL_VIF takes a single vifi_t argument.) 
 128     vifi_t      vifc_vifi
;              /* the index of the vif to be added */ 
 129     u_char      vifc_flags
;             /* VIFF_ flags defined below */ 
 130     u_char      vifc_threshold
;         /* min ttl required to forward on vif */ 
 131     u_int       vifc_rate_limit
;        /* max rate */ 
 132     struct      in_addr vifc_lcl_addr
;  /* local interface address */ 
 133     struct      in_addr vifc_rmt_addr
;  /* remote address (tunnels only) */ 
 136 #define VIFF_TUNNEL     0x1             /* vif represents a tunnel end-point */ 
 137 #define VIFF_SRCRT      0x2             /* tunnel uses IP source routing */ 
 140  * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC 
 141  * (mfcc_tos to be added at a future point) 
 144     struct in_addr      mfcc_origin
;            /* ip origin of mcasts       */ 
 145     struct in_addr      mfcc_mcastgrp
;          /* multicast group associated*/ 
 146     vifi_t              mfcc_parent
;            /* incoming vif              */ 
 147     u_char              mfcc_ttls
[CONFIG_MAXVIFS
];      /* forwarding ttls on vifs   */ 
 151  * The kernel's multicast routing statistics. 
 154     u_int32_t   mrts_mfc_lookups
;       /* # forw. cache hash table hits   */ 
 155     u_int32_t   mrts_mfc_misses
;        /* # forw. cache hash table misses */ 
 156     u_int32_t   mrts_upcalls
;           /* # calls to mrouted              */ 
 157     u_int32_t   mrts_no_route
;          /* no route for packet's origin    */ 
 158     u_int32_t   mrts_bad_tunnel
;        /* malformed tunnel options        */ 
 159     u_int32_t   mrts_cant_tunnel
;       /* no room for tunnel options      */ 
 160     u_int32_t   mrts_wrong_if
;          /* arrived on wrong interface      */ 
 161     u_int32_t   mrts_upq_ovflw
;         /* upcall Q overflow               */ 
 162     u_int32_t   mrts_cache_cleanups
;    /* # entries with no upcalls       */ 
 163     u_int32_t   mrts_drop_sel
;          /* pkts dropped selectively        */ 
 164     u_int32_t   mrts_q_overflow
;        /* pkts dropped - Q overflow       */ 
 165     u_int32_t   mrts_pkt2large
;         /* pkts dropped - size > BKT SIZE  */ 
 166     u_int32_t   mrts_upq_sockfull
;      /* upcalls dropped - socket full   */ 
 170  * Argument structure used by mrouted to get src-grp pkt counts 
 181  * Argument structure used by mrouted to get vif pkt counts 
 183 struct sioc_vif_req 
{ 
 184     vifi_t              vifi
;           /* vif number                   */ 
 185     u_int32_t           icount
;         /* Input packet count on vif    */ 
 186     u_int32_t           ocount
;         /* Output packet count on vif   */ 
 187     u_int32_t           ibytes
;         /* Input byte count on vif      */ 
 188     u_int32_t           obytes
;         /* Output byte count on vif     */ 
 193  * The kernel's virtual-interface structure. 
 199     u_char              v_flags
;        /* VIFF_ flags defined above         */ 
 200     u_char              v_threshold
;    /* min ttl required to forward on vif*/ 
 201     u_int               v_rate_limit
;   /* max rate                          */ 
 202     struct tbf         
*v_tbf
;          /* token bucket structure at intf.   */ 
 203     struct in_addr      v_lcl_addr
;     /* local interface address           */ 
 204     struct in_addr      v_rmt_addr
;     /* remote address (tunnels only)     */ 
 205     struct ifnet       
*v_ifp
;          /* pointer to interface              */ 
 206     u_long              v_pkt_in
;       /* # pkts in on interface            */ 
 207     u_long              v_pkt_out
;      /* # pkts out on interface           */ 
 208     u_long              v_bytes_in
;     /* # bytes in on interface           */ 
 209     u_long              v_bytes_out
;    /* # bytes out on interface          */ 
 210     struct route        v_route
;        /* cached route if this is a tunnel */ 
 211     u_int               v_rsvp_on
;      /* RSVP listening on this vif */ 
 212     struct socket      
*v_rsvpd
;        /* RSVP daemon socket */ 
 217  * The kernel's multicast forwarding cache entry structure  
 218  * (A field for the type of service (mfc_tos) is to be added  
 222     struct in_addr  mfc_origin
;                 /* IP origin of mcasts   */ 
 223     struct in_addr  mfc_mcastgrp
;               /* multicast group associated*/ 
 224     vifi_t          mfc_parent
;                 /* incoming vif              */ 
 225     u_char          mfc_ttls
[CONFIG_MAXVIFS
];           /* forwarding ttls on vifs   */ 
 226     u_long          mfc_pkt_cnt
;                /* pkt count for src-grp     */ 
 227     u_long          mfc_byte_cnt
;               /* byte count for src-grp    */ 
 228     u_long          mfc_wrong_if
;               /* wrong if for src-grp      */ 
 229     int             mfc_expire
;                 /* time to clean entry up    */ 
 230     struct timeval  mfc_last_assert
;            /* last time I sent an assert*/ 
 231     struct rtdetq  
*mfc_stall
;                  /* q of packets awaiting mfc */ 
 232     struct mfc     
*mfc_next
;                   /* next mfc entry            */ 
 236  * Struct used to communicate from kernel to multicast router 
 237  * note the convenient similarity to an IP packet 
 242     u_char          im_msgtype
;                 /* what type of message     */ 
 243 #define IGMPMSG_NOCACHE         1 
 244 #define IGMPMSG_WRONGVIF        2 
 245     u_char          im_mbz
;                     /* must be zero             */ 
 246     u_char          im_vif
;                     /* vif rec'd on             */ 
 248     struct in_addr  im_src
, im_dst
; 
 251 #define MFCTBLSIZ       CONFIG_MFCTBLSIZ 
 253 #ifdef KERNEL_PRIVATE 
 255  * Argument structure used for pkt info. while upcall is made 
 258     struct mbuf         
*m
;             /* A copy of the packet             */ 
 259     struct ifnet        
*ifp
;           /* Interface pkt came in on         */ 
 260     vifi_t              xmt_vif
;        /* Saved copy of imo_multicast_vif  */ 
 262     struct timeval      t
;              /* Timestamp */ 
 263 #endif /* UPCALL_TIMING */ 
 264     struct rtdetq       
*next
;          /* Next in list of packets          */ 
 267 #if (CONFIG_MFCTBLSIZ & (CONFIG_MFCTBLSIZ - 1)) == 0      /* from sys:route.h */ 
 268 #define MFCHASHMOD(h)   ((h) & (CONFIG_MFCTBLSIZ - 1)) 
 270 #define MFCHASHMOD(h)   ((h) % CONFIG_MFCTBLSIZ) 
 273 #define MAX_UPQ 4               /* max. no of pkts in upcall Q */ 
 276  * Token Bucket filter code  
 278 #define MAX_BKT_SIZE    10000             /* 10K bytes size             */ 
 279 #define MAXQSIZE        10                /* max # of pkts in queue     */ 
 282  * the token bucket filter at each vif 
 286     struct timeval tbf_last_pkt_t
; /* arr. time of last pkt     */ 
 287     u_long tbf_n_tok
;           /* no of tokens in bucket       */ 
 288     u_long tbf_q_len
;           /* length of queue at this vif  */ 
 289     u_long tbf_max_q_len
;       /* max. queue length            */ 
 290     struct mbuf 
*tbf_q
;         /* Packet queue                 */ 
 291     struct mbuf 
*tbf_t
;         /* tail-insertion pointer       */ 
 297 extern int      (*ip_mrouter_set
)(struct socket 
*, struct sockopt 
*); 
 298 extern int      (*ip_mrouter_get
)(struct socket 
*, struct sockopt 
*); 
 299 extern int      (*ip_mrouter_done
)(void); 
 301 extern int      (*mrt_ioctl
)(int, caddr_t
); 
 303 extern int      (*mrt_ioctl
)(int, caddr_t
, struct proc 
*); 
 306 #endif KERNEL_PRIVATE 
 307 #endif /* _NETINET_IP_MROUTE_H_ */