Home | History | Annotate | Line # | Download | only in netinet
ip_mroute.h revision 1.7
      1  1.7      jtc /*	$NetBSD: ip_mroute.h,v 1.7 1995/03/26 20:32:31 jtc Exp $	*/
      2  1.6      cgd 
      3  1.1  hpeyerl /*
      4  1.1  hpeyerl  * Copyright (c) 1989 Stephen Deering.
      5  1.5   brezak  * Copyright (c) 1992 Regents of the University of California.
      6  1.5   brezak  * All rights reserved.
      7  1.1  hpeyerl  *
      8  1.1  hpeyerl  * This code is derived from software contributed to Berkeley by
      9  1.1  hpeyerl  * Stephen Deering of Stanford University.
     10  1.1  hpeyerl  *
     11  1.1  hpeyerl  * Redistribution and use in source and binary forms, with or without
     12  1.1  hpeyerl  * modification, are permitted provided that the following conditions
     13  1.1  hpeyerl  * are met:
     14  1.1  hpeyerl  * 1. Redistributions of source code must retain the above copyright
     15  1.1  hpeyerl  *    notice, this list of conditions and the following disclaimer.
     16  1.1  hpeyerl  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.1  hpeyerl  *    notice, this list of conditions and the following disclaimer in the
     18  1.1  hpeyerl  *    documentation and/or other materials provided with the distribution.
     19  1.1  hpeyerl  * 3. All advertising materials mentioning features or use of this software
     20  1.1  hpeyerl  *    must display the following acknowledgement:
     21  1.1  hpeyerl  *	This product includes software developed by the University of
     22  1.1  hpeyerl  *	California, Berkeley and its contributors.
     23  1.1  hpeyerl  * 4. Neither the name of the University nor the names of its contributors
     24  1.1  hpeyerl  *    may be used to endorse or promote products derived from this software
     25  1.1  hpeyerl  *    without specific prior written permission.
     26  1.1  hpeyerl  *
     27  1.1  hpeyerl  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     28  1.1  hpeyerl  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     29  1.1  hpeyerl  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     30  1.1  hpeyerl  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     31  1.1  hpeyerl  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     32  1.1  hpeyerl  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     33  1.1  hpeyerl  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     34  1.1  hpeyerl  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     35  1.1  hpeyerl  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     36  1.1  hpeyerl  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     37  1.1  hpeyerl  * SUCH DAMAGE.
     38  1.1  hpeyerl  *
     39  1.6      cgd  *	@(#)ip_mroute.h	7.2 (Berkeley) 7/8/92
     40  1.1  hpeyerl  */
     41  1.1  hpeyerl 
     42  1.1  hpeyerl /*
     43  1.1  hpeyerl  * Definitions for the kernel part of DVMRP,
     44  1.1  hpeyerl  * a Distance-Vector Multicast Routing Protocol.
     45  1.1  hpeyerl  * (See RFC-1075.)
     46  1.1  hpeyerl  *
     47  1.1  hpeyerl  * Written by David Waitzman, BBN Labs, August 1988.
     48  1.1  hpeyerl  * Modified by Steve Deering, Stanford, February 1989.
     49  1.1  hpeyerl  *
     50  1.1  hpeyerl  * MROUTING 1.0
     51  1.1  hpeyerl  */
     52  1.1  hpeyerl 
     53  1.1  hpeyerl 
     54  1.1  hpeyerl /*
     55  1.1  hpeyerl  * DVMRP-specific setsockopt commands.
     56  1.1  hpeyerl  */
     57  1.1  hpeyerl #define	DVMRP_INIT	100
     58  1.1  hpeyerl #define	DVMRP_DONE	101
     59  1.1  hpeyerl #define	DVMRP_ADD_VIF	102
     60  1.1  hpeyerl #define	DVMRP_DEL_VIF	103
     61  1.1  hpeyerl #define	DVMRP_ADD_LGRP	104
     62  1.1  hpeyerl #define	DVMRP_DEL_LGRP	105
     63  1.1  hpeyerl #define	DVMRP_ADD_MRT	106
     64  1.1  hpeyerl #define	DVMRP_DEL_MRT	107
     65  1.1  hpeyerl 
     66  1.1  hpeyerl 
     67  1.1  hpeyerl /*
     68  1.1  hpeyerl  * Types and macros for handling bitmaps with one bit per virtual interface.
     69  1.1  hpeyerl  */
     70  1.1  hpeyerl #define	MAXVIFS 32
     71  1.1  hpeyerl typedef u_long vifbitmap_t;
     72  1.1  hpeyerl typedef u_short vifi_t;		/* type of a vif index */
     73  1.1  hpeyerl 
     74  1.1  hpeyerl #define	VIFM_SET(n, m)		((m) |= (1 << (n)))
     75  1.1  hpeyerl #define	VIFM_CLR(n, m)		((m) &= ~(1 << (n)))
     76  1.1  hpeyerl #define	VIFM_ISSET(n, m)	((m) & (1 << (n)))
     77  1.1  hpeyerl #define	VIFM_CLRALL(m)		((m) = 0x00000000)
     78  1.1  hpeyerl #define	VIFM_COPY(mfrom, mto)	((mto) = (mfrom))
     79  1.1  hpeyerl #define	VIFM_SAME(m1, m2)	((m1) == (m2))
     80  1.1  hpeyerl 
     81  1.1  hpeyerl 
     82  1.1  hpeyerl /*
     83  1.1  hpeyerl  * Agument structure for DVMRP_ADD_VIF.
     84  1.1  hpeyerl  * (DVMRP_DEL_VIF takes a single vifi_t argument.)
     85  1.1  hpeyerl  */
     86  1.1  hpeyerl struct vifctl {
     87  1.1  hpeyerl 	vifi_t	    vifc_vifi;	    	/* the index of the vif to be added */
     88  1.1  hpeyerl 	u_char	    vifc_flags;     	/* VIFF_ flags defined below */
     89  1.1  hpeyerl 	u_char	    vifc_threshold; 	/* min ttl required to forward on vif */
     90  1.1  hpeyerl 	struct	in_addr vifc_lcl_addr;	/* local interface address */
     91  1.1  hpeyerl 	struct	in_addr vifc_rmt_addr;	/* remote address (tunnels only) */
     92  1.1  hpeyerl };
     93  1.1  hpeyerl 
     94  1.1  hpeyerl #define	VIFF_TUNNEL	0x1		/* vif represents a tunnel end-point */
     95  1.5   brezak #define	VIFF_SRCRT	0x2		/* tunnel uses IP src routing */
     96  1.1  hpeyerl 
     97  1.1  hpeyerl 
     98  1.1  hpeyerl /*
     99  1.1  hpeyerl  * Argument structure for DVMRP_ADD_LGRP and DVMRP_DEL_LGRP.
    100  1.1  hpeyerl  */
    101  1.1  hpeyerl struct lgrplctl {
    102  1.1  hpeyerl 	vifi_t	lgc_vifi;
    103  1.1  hpeyerl 	struct	in_addr lgc_gaddr;
    104  1.1  hpeyerl };
    105  1.1  hpeyerl 
    106  1.1  hpeyerl 
    107  1.1  hpeyerl /*
    108  1.1  hpeyerl  * Argument structure for DVMRP_ADD_MRT.
    109  1.1  hpeyerl  * (DVMRP_DEL_MRT takes a single struct in_addr argument, containing origin.)
    110  1.1  hpeyerl  */
    111  1.1  hpeyerl struct mrtctl {
    112  1.1  hpeyerl 	struct	in_addr mrtc_origin;	/* subnet origin of multicasts */
    113  1.1  hpeyerl 	struct	in_addr mrtc_originmask; /* subnet mask for origin */
    114  1.1  hpeyerl 	vifi_t	mrtc_parent;    	/* incoming vif */
    115  1.1  hpeyerl 	vifbitmap_t mrtc_children;	/* outgoing children vifs */
    116  1.1  hpeyerl 	vifbitmap_t mrtc_leaves;	/* subset of outgoing children vifs */
    117  1.1  hpeyerl };
    118  1.1  hpeyerl 
    119  1.1  hpeyerl 
    120  1.7      jtc #ifdef _KERNEL
    121  1.1  hpeyerl 
    122  1.1  hpeyerl /*
    123  1.1  hpeyerl  * The kernel's virtual-interface structure.
    124  1.1  hpeyerl  */
    125  1.1  hpeyerl struct vif {
    126  1.1  hpeyerl 	u_char	v_flags;		/* VIFF_ flags defined above */
    127  1.1  hpeyerl 	u_char	v_threshold;		/* min ttl required to forward on vif */
    128  1.1  hpeyerl 	struct	in_addr v_lcl_addr;	/* local interface address */
    129  1.1  hpeyerl 	struct	in_addr v_rmt_addr;	/* remote address (tunnels only) */
    130  1.1  hpeyerl 	struct	ifnet  *v_ifp;		/* pointer to interface */
    131  1.1  hpeyerl 	struct	in_addr *v_lcl_grps;	/* list of local grps (phyints only) */
    132  1.1  hpeyerl 	int	v_lcl_grps_max;		/* malloc'ed number of v_lcl_grps */
    133  1.1  hpeyerl 	int	v_lcl_grps_n;		/* used number of v_lcl_grps */
    134  1.1  hpeyerl 	u_long	v_cached_group;		/* last grp looked-up (phyints only) */
    135  1.1  hpeyerl 	int	v_cached_result;	/* last look-up result (phyints only) */
    136  1.1  hpeyerl };
    137  1.1  hpeyerl 
    138  1.1  hpeyerl /*
    139  1.1  hpeyerl  * The kernel's multicast route structure.
    140  1.1  hpeyerl  */
    141  1.1  hpeyerl struct mrt {
    142  1.1  hpeyerl 	struct	in_addr mrt_origin;	/* subnet origin of multicasts */
    143  1.1  hpeyerl 	struct	in_addr mrt_originmask;	/* subnet mask for origin */
    144  1.1  hpeyerl 	vifi_t	mrt_parent;    		/* incoming vif */
    145  1.1  hpeyerl 	vifbitmap_t mrt_children;	/* outgoing children vifs */
    146  1.1  hpeyerl 	vifbitmap_t mrt_leaves;		/* subset of outgoing children vifs */
    147  1.1  hpeyerl 	struct	mrt *mrt_next;		/* forward link */
    148  1.1  hpeyerl };
    149  1.1  hpeyerl 
    150  1.1  hpeyerl 
    151  1.5   brezak #define	MRTHASHSIZ	256
    152  1.1  hpeyerl #if (MRTHASHSIZ & (MRTHASHSIZ - 1)) == 0	  /* from sys:route.h */
    153  1.1  hpeyerl #define	MRTHASHMOD(h)	((h) & (MRTHASHSIZ - 1))
    154  1.1  hpeyerl #else
    155  1.1  hpeyerl #define	MRTHASHMOD(h)	((h) % MRTHASHSIZ)
    156  1.1  hpeyerl #endif
    157  1.1  hpeyerl 
    158  1.1  hpeyerl /*
    159  1.1  hpeyerl  * The kernel's multicast routing statistics.
    160  1.1  hpeyerl  */
    161  1.1  hpeyerl struct mrtstat {
    162  1.1  hpeyerl 	u_long	mrts_mrt_lookups;	/* # multicast route lookups */
    163  1.1  hpeyerl 	u_long	mrts_mrt_misses;	/* # multicast route cache misses */
    164  1.1  hpeyerl 	u_long	mrts_grp_lookups;	/* # group address lookups */
    165  1.1  hpeyerl 	u_long	mrts_grp_misses;	/* # group address cache misses */
    166  1.1  hpeyerl 	u_long	mrts_no_route;		/* no route for packet's origin */
    167  1.1  hpeyerl 	u_long	mrts_bad_tunnel;	/* malformed tunnel options */
    168  1.1  hpeyerl 	u_long	mrts_cant_tunnel;	/* no room for tunnel options */
    169  1.5   brezak 	u_long	mrts_wrong_if;		/* arrived on wrong interface */
    170  1.1  hpeyerl };
    171  1.1  hpeyerl 
    172  1.5   brezak int	ip_mforward __P((struct mbuf *, struct ifnet *));
    173  1.1  hpeyerl int	ip_mrouter_cmd __P((int, struct socket *, struct mbuf *));
    174  1.3  mycroft int	ip_mrouter_done __P((void));
    175  1.7      jtc #endif /* _KERNEL */
    176