Home | History | Annotate | Line # | Download | only in netinet6
ip6_mroute.h revision 1.1.2.2
      1  1.1.2.1  itojun /*
      2  1.1.2.1  itojun  * Copyright (C) 1998 WIDE Project.
      3  1.1.2.1  itojun  * All rights reserved.
      4  1.1.2.1  itojun  *
      5  1.1.2.1  itojun  * Redistribution and use in source and binary forms, with or without
      6  1.1.2.1  itojun  * modification, are permitted provided that the following conditions
      7  1.1.2.1  itojun  * are met:
      8  1.1.2.1  itojun  * 1. Redistributions of source code must retain the above copyright
      9  1.1.2.1  itojun  *    notice, this list of conditions and the following disclaimer.
     10  1.1.2.1  itojun  * 2. Redistributions in binary form must reproduce the above copyright
     11  1.1.2.1  itojun  *    notice, this list of conditions and the following disclaimer in the
     12  1.1.2.1  itojun  *    documentation and/or other materials provided with the distribution.
     13  1.1.2.1  itojun  * 3. Neither the name of the project nor the names of its contributors
     14  1.1.2.1  itojun  *    may be used to endorse or promote products derived from this software
     15  1.1.2.1  itojun  *    without specific prior written permission.
     16  1.1.2.1  itojun  *
     17  1.1.2.1  itojun  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
     18  1.1.2.1  itojun  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19  1.1.2.1  itojun  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20  1.1.2.1  itojun  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
     21  1.1.2.1  itojun  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22  1.1.2.1  itojun  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23  1.1.2.1  itojun  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24  1.1.2.1  itojun  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25  1.1.2.1  itojun  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26  1.1.2.1  itojun  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27  1.1.2.1  itojun  * SUCH DAMAGE.
     28  1.1.2.1  itojun  */
     29  1.1.2.1  itojun 
     30  1.1.2.1  itojun /*	BSDI ip_mroute.h,v 2.5 1996/10/11 16:01:48 pjd Exp	*/
     31  1.1.2.1  itojun 
     32  1.1.2.1  itojun /*
     33  1.1.2.1  itojun  * Definitions for IP multicast forwarding.
     34  1.1.2.1  itojun  *
     35  1.1.2.1  itojun  * Written by David Waitzman, BBN Labs, August 1988.
     36  1.1.2.1  itojun  * Modified by Steve Deering, Stanford, February 1989.
     37  1.1.2.1  itojun  * Modified by Ajit Thyagarajan, PARC, August 1993.
     38  1.1.2.1  itojun  * Modified by Ajit Thyagarajan, PARC, August 1994.
     39  1.1.2.1  itojun  * Modified by Ahmed Helmy, USC, September 1996.
     40  1.1.2.1  itojun  *
     41  1.1.2.1  itojun  * MROUTING Revision: 1.2
     42  1.1.2.1  itojun  */
     43  1.1.2.1  itojun 
     44  1.1.2.1  itojun #ifndef _NETINET6_IP6_MROUTE_H_
     45  1.1.2.1  itojun #define _NETINET6_IP6_MROUTE_H_
     46  1.1.2.1  itojun 
     47  1.1.2.1  itojun /*
     48  1.1.2.1  itojun  * Multicast Routing set/getsockopt commands.
     49  1.1.2.1  itojun  */
     50  1.1.2.1  itojun #define MRT6_INIT		100	/* initialize forwarder */
     51  1.1.2.1  itojun #define MRT6_DONE		101	/* shut down forwarder */
     52  1.1.2.1  itojun #define MRT6_ADD_MIF		102	/* add multicast interface */
     53  1.1.2.1  itojun #define MRT6_DEL_MIF		103	/* delete multicast interface */
     54  1.1.2.1  itojun #define MRT6_ADD_MFC		104	/* insert forwarding cache entry */
     55  1.1.2.1  itojun #define MRT6_DEL_MFC		105	/* delete forwarding cache entry */
     56  1.1.2.1  itojun #define MRT6_PIM                107     /* enable pim code */
     57  1.1.2.1  itojun 
     58  1.1.2.1  itojun #if BSD >= 199103
     59  1.1.2.1  itojun #define GET_TIME(t)	microtime(&t)
     60  1.1.2.1  itojun #elif defined(sun)
     61  1.1.2.1  itojun #define GET_TIME(t)	uniqtime(&t)
     62  1.1.2.1  itojun #else
     63  1.1.2.1  itojun #define GET_TIME(t)	((t) = time)
     64  1.1.2.1  itojun #endif
     65  1.1.2.1  itojun 
     66  1.1.2.1  itojun /*
     67  1.1.2.1  itojun  * Types and macros for handling bitmaps with one bit per multicast interface.
     68  1.1.2.1  itojun  */
     69  1.1.2.1  itojun typedef u_short mifi_t;		/* type of a mif index */
     70  1.1.2.1  itojun #define MAXMIFS		64
     71  1.1.2.1  itojun 
     72  1.1.2.1  itojun #ifndef	IF_SETSIZE
     73  1.1.2.1  itojun #define	IF_SETSIZE	256
     74  1.1.2.1  itojun #endif
     75  1.1.2.1  itojun 
     76  1.1.2.1  itojun typedef	long	if_mask;
     77  1.1.2.1  itojun #define	NIFBITS	(sizeof(if_mask) * NBBY)	/* bits per mask */
     78  1.1.2.1  itojun 
     79  1.1.2.1  itojun #ifndef howmany
     80  1.1.2.1  itojun #define	howmany(x, y)	(((x) + ((y) - 1)) / (y))
     81  1.1.2.1  itojun #endif
     82  1.1.2.1  itojun 
     83  1.1.2.1  itojun typedef	struct if_set {
     84  1.1.2.1  itojun 	fd_mask	ifs_bits[howmany(IF_SETSIZE, NIFBITS)];
     85  1.1.2.1  itojun } if_set;
     86  1.1.2.1  itojun 
     87  1.1.2.1  itojun #define	IF_SET(n, p)	((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS)))
     88  1.1.2.1  itojun #define	IF_CLR(n, p)	((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS)))
     89  1.1.2.1  itojun #define	IF_ISSET(n, p)	((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS)))
     90  1.1.2.1  itojun #define	IF_COPY(f, t)	bcopy(f, t, sizeof(*(f)))
     91  1.1.2.1  itojun #define	IF_ZERO(p)	bzero(p, sizeof(*(p)))
     92  1.1.2.1  itojun 
     93  1.1.2.1  itojun /*
     94  1.1.2.1  itojun  * Argument structure for MRT6_ADD_IF.
     95  1.1.2.1  itojun  */
     96  1.1.2.1  itojun struct mif6ctl {
     97  1.1.2.1  itojun 	mifi_t	    mif6c_mifi;	    	/* the index of the mif to be added  */
     98  1.1.2.1  itojun 	u_char	    mif6c_flags;     	/* MIFF_ flags defined below         */
     99  1.1.2.1  itojun 	u_short	    mif6c_pifi;		/* the index of the physical IF */
    100  1.1.2.1  itojun #ifdef notyet
    101  1.1.2.1  itojun 	u_int	    mif6c_rate_limit;    /* max rate           		     */
    102  1.1.2.1  itojun #endif
    103  1.1.2.1  itojun };
    104  1.1.2.1  itojun 
    105  1.1.2.1  itojun #define	MIFF_REGISTER	0x1	/* mif represents a register end-point */
    106  1.1.2.1  itojun 
    107  1.1.2.1  itojun /*
    108  1.1.2.1  itojun  * Argument structure for MRT6_ADD_MFC and MRT6_DEL_MFC
    109  1.1.2.1  itojun  */
    110  1.1.2.1  itojun struct mf6cctl {
    111  1.1.2.1  itojun 	struct sockaddr_in6 mf6cc_origin;	/* IPv6 origin of mcasts */
    112  1.1.2.1  itojun 	struct sockaddr_in6 mf6cc_mcastgrp; /* multicast group associated */
    113  1.1.2.1  itojun 	mifi_t		mf6cc_parent;	/* incoming ifindex */
    114  1.1.2.1  itojun 	struct if_set	mf6cc_ifset;	/* set of forwarding ifs */
    115  1.1.2.1  itojun };
    116  1.1.2.1  itojun 
    117  1.1.2.1  itojun /*
    118  1.1.2.1  itojun  * The kernel's multicast routing statistics.
    119  1.1.2.1  itojun  */
    120  1.1.2.1  itojun struct mrt6stat {
    121  1.1.2.1  itojun 	u_quad_t mrt6s_mfc_lookups;	/* # forw. cache hash table hits   */
    122  1.1.2.1  itojun 	u_quad_t mrt6s_mfc_misses;	/* # forw. cache hash table misses */
    123  1.1.2.1  itojun 	u_quad_t mrt6s_upcalls;		/* # calls to mrouted              */
    124  1.1.2.1  itojun 	u_quad_t mrt6s_no_route;	/* no route for packet's origin    */
    125  1.1.2.1  itojun 	u_quad_t mrt6s_bad_tunnel;	/* malformed tunnel options        */
    126  1.1.2.1  itojun 	u_quad_t mrt6s_cant_tunnel;	/* no room for tunnel options      */
    127  1.1.2.1  itojun 	u_quad_t mrt6s_wrong_if;	/* arrived on wrong interface	   */
    128  1.1.2.1  itojun 	u_quad_t mrt6s_upq_ovflw;	/* upcall Q overflow		   */
    129  1.1.2.1  itojun 	u_quad_t mrt6s_cache_cleanups;	/* # entries with no upcalls 	   */
    130  1.1.2.1  itojun 	u_quad_t mrt6s_drop_sel;     	/* pkts dropped selectively        */
    131  1.1.2.1  itojun 	u_quad_t mrt6s_q_overflow;    	/* pkts dropped - Q overflow       */
    132  1.1.2.1  itojun 	u_quad_t mrt6s_pkt2large;     	/* pkts dropped - size > BKT SIZE  */
    133  1.1.2.1  itojun 	u_quad_t mrt6s_upq_sockfull;	/* upcalls dropped - socket full   */
    134  1.1.2.1  itojun };
    135  1.1.2.1  itojun 
    136  1.1.2.1  itojun /*
    137  1.1.2.1  itojun  * Struct used to communicate from kernel to multicast router
    138  1.1.2.1  itojun  * note the convenient similarity to an IPv6 header.
    139  1.1.2.1  itojun  */
    140  1.1.2.1  itojun struct mrt6msg {
    141  1.1.2.1  itojun 	u_long	    unused1;
    142  1.1.2.1  itojun 	u_char	    im6_msgtype;		/* what type of message	    */
    143  1.1.2.1  itojun #define MRT6MSG_NOCACHE		1
    144  1.1.2.1  itojun #define MRT6MSG_WRONGMIF	2
    145  1.1.2.1  itojun #define MRT6MSG_WHOLEPKT	3		/* used for user level encap*/
    146  1.1.2.1  itojun 	u_char	    im6_mbz;			/* must be zero		    */
    147  1.1.2.1  itojun 	u_char	    im6_mif;			/* mif rec'd on		    */
    148  1.1.2.1  itojun 	u_char	    unused2;
    149  1.1.2.1  itojun 	struct in6_addr  im6_src, im6_dst;
    150  1.1.2.1  itojun };
    151  1.1.2.1  itojun 
    152  1.1.2.1  itojun /*
    153  1.1.2.1  itojun  * Argument structure used by mrouted to get src-grp pkt counts
    154  1.1.2.1  itojun  */
    155  1.1.2.1  itojun struct sioc6_sg_req {
    156  1.1.2.2  itojun 	struct in6_addr src;
    157  1.1.2.2  itojun 	struct in6_addr grp;
    158  1.1.2.2  itojun 	u_quad_t pktcnt;
    159  1.1.2.2  itojun 	u_quad_t bytecnt;
    160  1.1.2.2  itojun 	u_quad_t wrong_if;
    161  1.1.2.1  itojun };
    162  1.1.2.1  itojun 
    163  1.1.2.1  itojun /*
    164  1.1.2.1  itojun  * Argument structure used by multicast routing daemon to get src-grp
    165  1.1.2.1  itojun  * packet counts
    166  1.1.2.1  itojun  */
    167  1.1.2.1  itojun struct sioc_sg_req6 {
    168  1.1.2.1  itojun 	struct sockaddr_in6 src;
    169  1.1.2.1  itojun 	struct sockaddr_in6 grp;
    170  1.1.2.2  itojun 	u_quad_t pktcnt;
    171  1.1.2.2  itojun 	u_quad_t bytecnt;
    172  1.1.2.2  itojun 	u_quad_t wrong_if;
    173  1.1.2.1  itojun };
    174  1.1.2.1  itojun 
    175  1.1.2.1  itojun /*
    176  1.1.2.1  itojun  * Argument structure used by mrouted to get mif pkt counts
    177  1.1.2.1  itojun  */
    178  1.1.2.1  itojun struct sioc_mif_req6 {
    179  1.1.2.1  itojun 	mifi_t mifi;		/* mif number				*/
    180  1.1.2.2  itojun 	u_quad_t icount;	/* Input packet count on mif		*/
    181  1.1.2.2  itojun 	u_quad_t ocount;	/* Output packet count on mif		*/
    182  1.1.2.2  itojun 	u_quad_t ibytes;	/* Input byte count on mif		*/
    183  1.1.2.2  itojun 	u_quad_t obytes;	/* Output byte count on mif		*/
    184  1.1.2.1  itojun };
    185  1.1.2.1  itojun 
    186  1.1.2.2  itojun #if defined(_KERNEL) || defined(KERNEL)
    187  1.1.2.1  itojun /*
    188  1.1.2.1  itojun  * The kernel's multicast-interface structure.
    189  1.1.2.1  itojun  */
    190  1.1.2.1  itojun struct mif6 {
    191  1.1.2.1  itojun         u_char   	m6_flags;     	/* MIFF_ flags defined above         */
    192  1.1.2.1  itojun 	u_int      	m6_rate_limit; 	/* max rate			     */
    193  1.1.2.1  itojun #ifdef notyet
    194  1.1.2.1  itojun 	struct tbf      *m6_tbf;      	/* token bucket structure at intf.   */
    195  1.1.2.1  itojun #endif
    196  1.1.2.1  itojun 	struct in6_addr	m6_lcl_addr;   	/* local interface address           */
    197  1.1.2.1  itojun 	struct ifnet    *m6_ifp;     	/* pointer to interface              */
    198  1.1.2.2  itojun 	u_quad_t	m6_pkt_in;	/* # pkts in on interface            */
    199  1.1.2.2  itojun 	u_quad_t	m6_pkt_out;	/* # pkts out on interface           */
    200  1.1.2.2  itojun 	u_quad_t	m6_bytes_in;	/* # bytes in on interface	     */
    201  1.1.2.2  itojun 	u_quad_t	m6_bytes_out;	/* # bytes out on interface	     */
    202  1.1.2.1  itojun 	struct route_in6 m6_route;/* cached route if this is a tunnel */
    203  1.1.2.1  itojun #ifdef notyet
    204  1.1.2.1  itojun 	u_int		m6_rsvp_on;	/* RSVP listening on this vif */
    205  1.1.2.1  itojun 	struct socket   *m6_rsvpd;	/* RSVP daemon socket */
    206  1.1.2.1  itojun #endif
    207  1.1.2.1  itojun };
    208  1.1.2.1  itojun 
    209  1.1.2.1  itojun /*
    210  1.1.2.1  itojun  * The kernel's multicast forwarding cache entry structure
    211  1.1.2.1  itojun  */
    212  1.1.2.1  itojun struct mf6c {
    213  1.1.2.1  itojun 	struct sockaddr_in6  mf6c_origin;	/* IPv6 origin of mcasts     */
    214  1.1.2.1  itojun 	struct sockaddr_in6  mf6c_mcastgrp;	/* multicast group associated*/
    215  1.1.2.1  itojun 	mifi_t	    	 mf6c_parent; 		/* incoming IF               */
    216  1.1.2.1  itojun 	struct if_set	 mf6c_ifset;		/* set of outgoing IFs */
    217  1.1.2.1  itojun 
    218  1.1.2.2  itojun 	u_quad_t    	mf6c_pkt_cnt;		/* pkt count for src-grp     */
    219  1.1.2.2  itojun 	u_quad_t    	mf6c_byte_cnt;		/* byte count for src-grp    */
    220  1.1.2.2  itojun 	u_quad_t    	mf6c_wrong_if;		/* wrong if for src-grp	     */
    221  1.1.2.1  itojun 	int	    	mf6c_expire;		/* time to clean entry up    */
    222  1.1.2.1  itojun 	struct timeval  mf6c_last_assert;	/* last time I sent an assert*/
    223  1.1.2.1  itojun 	struct rtdetq  *mf6c_stall;		/* pkts waiting for route */
    224  1.1.2.1  itojun 	struct mf6c    *mf6c_next;		/* hash table linkage */
    225  1.1.2.1  itojun };
    226  1.1.2.1  itojun 
    227  1.1.2.1  itojun #define MF6C_INCOMPLETE_PARENT ((mifi_t)-1)
    228  1.1.2.1  itojun 
    229  1.1.2.1  itojun /*
    230  1.1.2.1  itojun  * Argument structure used for pkt info. while upcall is made
    231  1.1.2.1  itojun  */
    232  1.1.2.1  itojun #ifndef _NETINET_IP_MROUTE_H_
    233  1.1.2.1  itojun struct rtdetq {		/* XXX: rtdetq is also defined in ip_mroute.h */
    234  1.1.2.1  itojun     struct mbuf 	*m;		/* A copy of the packet	    	    */
    235  1.1.2.1  itojun     struct ifnet	*ifp;		/* Interface pkt came in on 	    */
    236  1.1.2.1  itojun #ifdef UPCALL_TIMING
    237  1.1.2.1  itojun     struct timeval	t;		/* Timestamp */
    238  1.1.2.1  itojun #endif /* UPCALL_TIMING */
    239  1.1.2.1  itojun     struct rtdetq	*next;
    240  1.1.2.1  itojun };
    241  1.1.2.1  itojun #endif /* _NETINET_IP_MROUTE_H_ */
    242  1.1.2.1  itojun 
    243  1.1.2.1  itojun #define MF6CTBLSIZ	256
    244  1.1.2.1  itojun #if (MF6CTBLSIZ & (MF6CTBLSIZ - 1)) == 0	  /* from sys:route.h */
    245  1.1.2.1  itojun #define MF6CHASHMOD(h)	((h) & (MF6CTBLSIZ - 1))
    246  1.1.2.1  itojun #else
    247  1.1.2.1  itojun #define MF6CHASHMOD(h)	((h) % MF6CTBLSIZ)
    248  1.1.2.1  itojun #endif
    249  1.1.2.1  itojun 
    250  1.1.2.1  itojun #define MAX_UPQ6	4		/* max. no of pkts in upcall Q */
    251  1.1.2.1  itojun 
    252  1.1.2.2  itojun #if defined(__FreeBSD__) && __FreeBSD__ >= 3
    253  1.1.2.2  itojun int	ip6_mrouter_set __P((struct socket *so, struct sockopt *sopt));
    254  1.1.2.2  itojun int	ip6_mrouter_get __P((struct socket *so, struct sockopt *sopt));
    255  1.1.2.2  itojun #else
    256  1.1.2.1  itojun int	ip6_mrouter_set __P((int, struct socket *, struct mbuf *));
    257  1.1.2.1  itojun int	ip6_mrouter_get __P((int, struct socket *, struct mbuf **));
    258  1.1.2.2  itojun #endif
    259  1.1.2.1  itojun int	ip6_mrouter_done __P((void));
    260  1.1.2.1  itojun int	mrt6_ioctl __P((int, caddr_t));
    261  1.1.2.2  itojun #endif /* _KERNEL */
    262  1.1.2.1  itojun 
    263  1.1.2.1  itojun #endif /* !_NETINET6_IP6_MROUTE_H_ */
    264