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