Annotation of embedaddon/pimdd/include/freebsd/netinet/ip_mroute.h, revision 1.1

1.1     ! misho       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.2 1998/06/01 22:27:16 kurtw Exp $
        !            39:  */
        !            40: 
        !            41: #ifndef _NETINET_IP_MROUTE_H_
        !            42: #define _NETINET_IP_MROUTE_H_
        !            43: 
        !            44: /*
        !            45:  * Definitions for IP multicast forwarding.
        !            46:  *
        !            47:  * Written by David Waitzman, BBN Labs, August 1988.
        !            48:  * Modified by Steve Deering, Stanford, February 1989.
        !            49:  * Modified by Ajit Thyagarajan, PARC, August 1993.
        !            50:  * Modified by Ajit Thyagarajan, PARC, August 1994.
        !            51:  *
        !            52:  * MROUTING Revision: 3.3.1.3
        !            53:  */
        !            54: 
        !            55: 
        !            56: /*
        !            57:  * Multicast Routing set/getsockopt commands.
        !            58:  */
        !            59: #define        MRT_INIT        100     /* initialize forwarder */
        !            60: #define        MRT_DONE        101     /* shut down forwarder */
        !            61: #define        MRT_ADD_VIF     102     /* create virtual interface */
        !            62: #define        MRT_DEL_VIF     103     /* delete virtual interface */
        !            63: #define MRT_ADD_MFC    104     /* insert forwarding cache entry */
        !            64: #define MRT_DEL_MFC    105     /* delete forwarding cache entry */
        !            65: #define MRT_VERSION    106     /* get kernel version number */
        !            66: #define MRT_ASSERT      107     /* enable assert (wrong iif) processing */
        !            67: 
        !            68: 
        !            69: #define GET_TIME(t)    microtime(&t)
        !            70: 
        !            71: /*
        !            72:  * Types and macros for handling bitmaps with one bit per virtual interface.
        !            73:  */
        !            74: #define        MAXVIFS 32
        !            75: typedef u_long vifbitmap_t;
        !            76: typedef u_short vifi_t;                /* type of a vif index */
        !            77: #define ALL_VIFS (vifi_t)-1
        !            78: 
        !            79: #define        VIFM_SET(n, m)          ((m) |= (1 << (n)))
        !            80: #define        VIFM_CLR(n, m)          ((m) &= ~(1 << (n)))
        !            81: #define        VIFM_ISSET(n, m)        ((m) & (1 << (n)))
        !            82: #define        VIFM_CLRALL(m)          ((m) = 0x00000000)
        !            83: #define        VIFM_COPY(mfrom, mto)   ((mto) = (mfrom))
        !            84: #define        VIFM_SAME(m1, m2)       ((m1) == (m2))
        !            85: 
        !            86: 
        !            87: /*
        !            88:  * Argument structure for MRT_ADD_VIF.
        !            89:  * (MRT_DEL_VIF takes a single vifi_t argument.)
        !            90:  */
        !            91: struct vifctl {
        !            92:        vifi_t  vifc_vifi;              /* the index of the vif to be added */
        !            93:        u_char  vifc_flags;             /* VIFF_ flags defined below */
        !            94:        u_char  vifc_threshold;         /* min ttl required to forward on vif */
        !            95:        u_int   vifc_rate_limit;        /* max rate */
        !            96:        struct  in_addr vifc_lcl_addr;  /* local interface address */
        !            97:        struct  in_addr vifc_rmt_addr;  /* remote address (tunnels only) */
        !            98: };
        !            99: 
        !           100: #define        VIFF_TUNNEL     0x1             /* vif represents a tunnel end-point */
        !           101: #define VIFF_SRCRT     0x2             /* tunnel uses IP source routing     */
        !           102: #define VIFF_REGISTER  0x4             /* vif used for register en/decap    */
        !           103: 
        !           104: /*
        !           105:  * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC
        !           106:  * (mfcc_tos to be added at a future point)
        !           107:  */
        !           108: struct mfcctl {
        !           109:     struct in_addr  mfcc_origin;               /* ip origin of mcasts       */
        !           110:     struct in_addr  mfcc_mcastgrp;             /* multicast group associated*/
        !           111:     vifi_t         mfcc_parent;                /* incoming vif              */
        !           112:     u_char         mfcc_ttls[MAXVIFS];         /* forwarding ttls on vifs   */
        !           113: };
        !           114: 
        !           115: /*
        !           116:  * The kernel's multicast routing statistics.
        !           117:  */
        !           118: struct mrtstat {
        !           119:     u_long     mrts_mfc_lookups;       /* # forw. cache hash table hits   */
        !           120:     u_long     mrts_mfc_misses;        /* # forw. cache hash table misses */
        !           121:     u_long     mrts_upcalls;           /* # calls to mrouted              */
        !           122:     u_long     mrts_no_route;          /* no route for packet's origin    */
        !           123:     u_long     mrts_bad_tunnel;        /* malformed tunnel options        */
        !           124:     u_long     mrts_cant_tunnel;       /* no room for tunnel options      */
        !           125:     u_long     mrts_wrong_if;          /* arrived on wrong interface      */
        !           126:     u_long     mrts_upq_ovflw;         /* upcall Q overflow               */
        !           127:     u_long     mrts_cache_cleanups;    /* # entries with no upcalls       */
        !           128:     u_long     mrts_drop_sel;          /* pkts dropped selectively        */
        !           129:     u_long     mrts_q_overflow;        /* pkts dropped - Q overflow       */
        !           130:     u_long     mrts_pkt2large;         /* pkts dropped - size > BKT SIZE  */
        !           131:     u_long     mrts_upq_sockfull;      /* upcalls dropped - socket full */
        !           132: };
        !           133: 
        !           134: /*
        !           135:  * Argument structure used by mrouted to get src-grp pkt counts
        !           136:  */
        !           137: struct sioc_sg_req {
        !           138:     struct in_addr src;
        !           139:     struct in_addr grp;
        !           140:     u_long pktcnt;
        !           141:     u_long bytecnt;
        !           142:     u_long wrong_if;
        !           143: };
        !           144: 
        !           145: /*
        !           146:  * Argument structure used by mrouted to get vif pkt counts
        !           147:  */
        !           148: struct sioc_vif_req {
        !           149:     vifi_t vifi;               /* vif number                           */
        !           150:     u_long icount;             /* Input packet count on vif            */
        !           151:     u_long ocount;             /* Output packet count on vif           */
        !           152:     u_long ibytes;             /* Input byte count on vif              */
        !           153:     u_long obytes;             /* Output byte count on vif             */
        !           154: };
        !           155:     
        !           156: 
        !           157: /*
        !           158:  * The kernel's virtual-interface structure.
        !           159:  */
        !           160: struct vif {
        !           161:     u_char             v_flags;        /* VIFF_ flags defined above         */
        !           162:     u_char             v_threshold;    /* min ttl required to forward on vif*/
        !           163:     u_int                      v_rate_limit;   /* max rate                          */
        !           164:     struct tbf                *v_tbf;          /* token bucket structure at intf.   */
        !           165:     struct in_addr     v_lcl_addr;     /* local interface address           */
        !           166:     struct in_addr     v_rmt_addr;     /* remote address (tunnels only)     */
        !           167:     struct ifnet       *v_ifp;         /* pointer to interface              */
        !           168:     u_long             v_pkt_in;       /* # pkts in on interface            */
        !           169:     u_long             v_pkt_out;      /* # pkts out on interface           */
        !           170:     u_long             v_bytes_in;     /* # bytes in on interface           */
        !           171:     u_long             v_bytes_out;    /* # bytes out on interface          */
        !           172:     struct route       v_route;        /* cached route if this is a tunnel */
        !           173:     u_int              v_rsvp_on;      /* RSVP listening on this vif */
        !           174:     struct socket      *v_rsvpd;       /* RSVP daemon socket */
        !           175: };
        !           176: 
        !           177: /*
        !           178:  * The kernel's multicast forwarding cache entry structure 
        !           179:  * (A field for the type of service (mfc_tos) is to be added 
        !           180:  * at a future point)
        !           181:  */
        !           182: struct mfc {
        !           183:     struct in_addr  mfc_origin;                        /* IP origin of mcasts   */
        !           184:     struct in_addr  mfc_mcastgrp;              /* multicast group associated*/
        !           185:     vifi_t         mfc_parent;                 /* incoming vif              */
        !           186:     u_char         mfc_ttls[MAXVIFS];          /* forwarding ttls on vifs   */
        !           187:     u_long         mfc_pkt_cnt;                /* pkt count for src-grp     */
        !           188:     u_long         mfc_byte_cnt;               /* byte count for src-grp    */
        !           189:     u_long         mfc_wrong_if;               /* wrong if for src-grp      */
        !           190:     int                    mfc_expire;                 /* time to clean entry up    */
        !           191:     struct timeval  mfc_last_assert;           /* last time I sent an assert*/
        !           192: };
        !           193: 
        !           194: /*
        !           195:  * Struct used to communicate from kernel to multicast router
        !           196:  * note the convenient similarity to an IP packet
        !           197:  */
        !           198: struct igmpmsg {
        !           199:     u_long         unused1;
        !           200:     u_long         unused2;
        !           201:     u_char         im_msgtype;                 /* what type of message     */
        !           202: #define IGMPMSG_NOCACHE                1
        !           203: #define IGMPMSG_WRONGVIF       2
        !           204: #define IGMPMSG_WHOLEPKT       3               /* send the whole packet    */
        !           205:     u_char         im_mbz;                     /* must be zero             */
        !           206:     u_char         im_vif;                     /* vif rec'd on             */
        !           207:     u_char         unused3;
        !           208:     struct in_addr  im_src, im_dst;
        !           209: };
        !           210: 
        !           211: /*
        !           212:  * Argument structure used for pkt info. while upcall is made
        !           213:  */
        !           214: struct rtdetq {
        !           215:     struct mbuf        *m;             /* A copy of the packet             */
        !           216:     struct ifnet       *ifp;           /* Interface pkt came in on         */
        !           217:     vifi_t             xmt_vif;        /* Saved copy of imo_multicast_vif  */
        !           218: #ifdef UPCALL_TIMING
        !           219:     struct timeval     t;              /* Timestamp */
        !           220: #endif /* UPCALL_TIMING */
        !           221: };
        !           222: 
        !           223: #define MFCTBLSIZ      256
        !           224: #if (MFCTBLSIZ & (MFCTBLSIZ - 1)) == 0   /* from sys:route.h */
        !           225: #define MFCHASHMOD(h)  ((h) & (MFCTBLSIZ - 1))
        !           226: #else
        !           227: #define MFCHASHMOD(h)  ((h) % MFCTBLSIZ)
        !           228: #endif
        !           229: 
        !           230: #define MAX_UPQ        4               /* max. no of pkts in upcall Q */
        !           231: 
        !           232: /*
        !           233:  * Token Bucket filter code 
        !           234:  */
        !           235: #define MAX_BKT_SIZE    10000             /* 10K bytes size            */
        !           236: #define MAXQSIZE        10                /* max # of pkts in queue    */
        !           237: 
        !           238: /*
        !           239:  * the token bucket filter at each vif
        !           240:  */
        !           241: struct tbf
        !           242: {
        !           243:     struct timeval tbf_last_pkt_t; /* arr. time of last pkt    */
        !           244:     u_long tbf_n_tok;          /* no of tokens in bucket       */
        !           245:     u_long tbf_q_len;          /* length of queue at this vif  */
        !           246:     u_long tbf_max_q_len;      /* max. queue length            */
        !           247:     struct mbuf *tbf_q;                /* Packet queue                 */
        !           248:     struct mbuf *tbf_t;                /* tail-insertion pointer       */
        !           249: };
        !           250: 
        !           251: #ifdef KERNEL
        !           252: 
        !           253: extern int     (*ip_mrouter_set) __P((int, struct socket *, struct mbuf *));
        !           254: extern int     (*ip_mrouter_get) __P((int, struct socket *, struct mbuf **));
        !           255: extern int     (*ip_mrouter_done) __P((void));
        !           256: #ifdef MROUTING
        !           257: extern int     (*mrt_ioctl) __P((int, caddr_t));
        !           258: #else
        !           259: extern int     (*mrt_ioctl) __P((int, caddr_t, struct proc *));
        !           260: #endif
        !           261: 
        !           262: #endif /* KERNEL */
        !           263: 
        !           264: #endif /* _NETINET_IP_MROUTE_H_ */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>