Annotation of embedaddon/pimdd/vif.h, revision 1.1.1.1

1.1       misho       1: /*
                      2:  *  Copyright (c) 1998 by the University of Southern California.
                      3:  *  All rights reserved.
                      4:  *
                      5:  *  Permission to use, copy, modify, and distribute this software and
                      6:  *  its documentation in source and binary forms for lawful
                      7:  *  purposes and without fee is hereby granted, provided
                      8:  *  that the above copyright notice appear in all copies and that both
                      9:  *  the copyright notice and this permission notice appear in supporting
                     10:  *  documentation, and that any documentation, advertising materials,
                     11:  *  and other materials related to such distribution and use acknowledge
                     12:  *  that the software was developed by the University of Southern
                     13:  *  California and/or Information Sciences Institute.
                     14:  *  The name of the University of Southern California may not
                     15:  *  be used to endorse or promote products derived from this software
                     16:  *  without specific prior written permission.
                     17:  *
                     18:  *  THE UNIVERSITY OF SOUTHERN CALIFORNIA DOES NOT MAKE ANY REPRESENTATIONS
                     19:  *  ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE.  THIS SOFTWARE IS
                     20:  *  PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
                     21:  *  INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     22:  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND 
                     23:  *  NON-INFRINGEMENT.
                     24:  *
                     25:  *  IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY
                     26:  *  SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT,
                     27:  *  TORT, OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH,
                     28:  *  THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     29:  *
                     30:  *  Other copyrights might apply to parts of this software and are so
                     31:  *  noted when applicable.
                     32:  */
                     33: /*
                     34:  *  Questions concerning this software should be directed to 
                     35:  *  Pavlin Ivanov Radoslavov (pavlin@catarina.usc.edu)
                     36:  *
                     37:  *  $Id: vif.h,v 1.5 1998/07/06 22:31:15 kurtw Exp $
                     38:  */
                     39: /*
                     40:  * Part of this program has been derived from mrouted.
                     41:  * The mrouted program is covered by the license in the accompanying file
                     42:  * named "LICENSE.mrouted".
                     43:  *
                     44:  * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
                     45:  * Leland Stanford Junior University.
                     46:  *
                     47:  */
                     48: 
                     49: 
                     50: /*
                     51:  * Bitmap handling functions.
                     52:  * These should be fast but generic.  bytes can be slow to zero and compare,
                     53:  * words are hard to make generic.  Thus two sets of macros (yuk).
                     54:  */
                     55: 
                     56: /*
                     57:  * The VIFM_ functions should migrate out of <netinet/ip_mroute.h>, since
                     58:  * the kernel no longer uses vifbitmaps.
                     59:  */
                     60: #ifndef VIFM_SET
                     61: 
                     62: typedef        u_int32 vifbitmap_t;
                     63: 
                     64: #define        VIFM_SET(n, m)                  ((m) |=  (1 << (n)))
                     65: #define        VIFM_CLR(n, m)                  ((m) &= ~(1 << (n)))
                     66: #define        VIFM_ISSET(n, m)                ((m) &   (1 << (n)))
                     67: #define VIFM_CLRALL(m)                 ((m) = 0x00000000)
                     68: #define VIFM_COPY(mfrom, mto)          ((mto) = (mfrom))
                     69: #define VIFM_SAME(m1, m2)              ((m1) == (m2))
                     70: #endif
                     71: /*
                     72:  * And <netinet/ip_mroute.h> was missing some required functions anyway
                     73:  */
                     74: #if !defined(NetBSD)
                     75: #define        VIFM_SETALL(m)                  ((m) = ~0)
                     76: #endif
                     77: #define        VIFM_ISSET_ONLY(n, m)           ((m) == (1 << (n)))
                     78: #define        VIFM_ISEMPTY(m)                 ((m) == 0)
                     79: #define        VIFM_CLR_MASK(m, mask)          ((m) &= ~(mask))
                     80: #define        VIFM_SET_MASK(m, mask)          ((m) |= (mask))
                     81: #define VIFM_MERGE(m1, m2, result)      ((result) = (m1) | (m2))
                     82: 
                     83: /* Check whether I am the forwarder on some LAN */
                     84: #define VIFM_FORWARDER(leaves, oifs)    ((leaves) & (oifs))
                     85: 
                     86: /*
                     87:  * Neighbor bitmaps are, for efficiency, implemented as a struct
                     88:  * containing two variables of a native machine type.  If you
                     89:  * have a native type that's bigger than a long, define it below.
                     90:  */
                     91: #define        NBRTYPE         u_long
                     92: #define NBRBITS                sizeof(NBRTYPE) * 8
                     93: 
                     94: typedef struct {
                     95:     NBRTYPE hi;
                     96:     NBRTYPE lo;
                     97: } nbrbitmap_t;
                     98: #define        MAXNBRS         2 * NBRBITS
                     99: 
                    100: #define        NBRM_SET(n, m)          (((n) < NBRBITS) ? ((m).lo |= (1 << (n))) :  \
                    101:                                      ((m).hi |= (1 << (n - NBRBITS))))
                    102: #define        NBRM_CLR(n, m)          (((n) < NBRBITS) ? ((m).lo &= ~(1 << (n))) : \
                    103:                                      ((m).hi &= ~(1 << (n - NBRBITS))))
                    104: #define        NBRM_ISSET(n, m)        (((n) < NBRBITS) ? ((m).lo & (1 << (n))) :   \
                    105:                                      ((m).hi & (1 << ((n) - NBRBITS))))
                    106: #define        NBRM_CLRALL(m)          ((m).lo = (m).hi = 0)
                    107: #define        NBRM_COPY(mfrom, mto)   ((mto).lo = (mfrom).lo, (mto).hi = (mfrom).hi)
                    108: #define        NBRM_SAME(m1, m2)       (((m1).lo == (m2).lo) && ((m1).hi == (m2).hi))
                    109: #define        NBRM_ISEMPTY(m)         (((m).lo == 0) && ((m).hi == 0))
                    110: #define        NBRM_SETMASK(m, mask)   (((m).lo |= (mask).lo),((m).hi |= (mask).hi))
                    111: #define        NBRM_CLRMASK(m, mask)   (((m).lo &= ~(mask).lo),((m).hi &= ~(mask).hi))
                    112: #define        NBRM_MASK(m, mask)      (((m).lo &= (mask).lo),((m).hi &= (mask).hi))
                    113: #define        NBRM_ISSETMASK(m, mask) (((m).lo & (mask).lo) || ((m).hi & (mask).hi))
                    114: #define        NBRM_ISSETALLMASK(m, mask)\
                    115:                                ((((m).lo & (mask).lo) == (mask).lo) && \
                    116:                                 (((m).hi & (mask).hi) == (mask).hi))
                    117: /*
                    118:  * This macro is TRUE if all the subordinates have been pruned, or if
                    119:  * there are no subordinates on this vif.
                    120:  * The arguments is the map of subordinates, the map of neighbors on the
                    121:  * vif, and the map of received prunes.
                    122:  */
                    123: #define        SUBS_ARE_PRUNED(sub, vifmask, prunes)   \
                    124:     (((sub).lo & (vifmask).lo) == ((prunes).lo & (vifmask).lo & (sub).lo) && \
                    125:      ((sub).hi & (vifmask).hi) == ((prunes).hi & (vifmask).hi & (sub).hi))
                    126: 
                    127: /*
                    128:  * User level Virtual Interface structure
                    129:  *
                    130:  * A "virtual interface" is either a physical, multicast-capable interface
                    131:  * (called a "phyint"), a virtual point-to-point link (called a "tunnel")
                    132:  * or a "register vif" used by PIM. The register vif is used by the
                    133:  * Designated Router (DR) to send encapsulated data packets to the
                    134:  * Rendevous Point (RP) for a particular group. The data packets are 
                    135:  * encapsulated in PIM messages (IPPROTO_PIM = 103) and then unicast to 
                    136:  * the RP.
                    137:  * (Note: all addresses, subnet numbers and masks are kept in NETWORK order.)
                    138:  */
                    139: struct uvif {
                    140:     u_int           uv_flags;      /* VIFF_ flags defined below            */
                    141:     u_char          uv_metric;     /* cost of this vif                     */
                    142:     u_char          uv_admetric;   /* advertised cost of this vif          */
                    143:     u_char          uv_threshold;  /* min ttl required to forward on vif   */
                    144:     u_int           uv_rate_limit; /* rate limit on this vif               */
                    145:     u_int32         uv_lcl_addr;   /* local address of this vif            */
                    146:     u_int32         uv_rmt_addr;   /* remote end-point addr (tunnels only) */
                    147:     u_int32         uv_dst_addr;   /* destination for DVMRP/PIM messages   */
                    148:     u_int32         uv_subnet;     /* subnet number         (phyints only) */
                    149:     u_int32         uv_subnetmask; /* subnet mask           (phyints only) */
                    150:     u_int32         uv_subnetbcast;/* subnet broadcast addr (phyints only) */
                    151:     char            uv_name[IFNAMSIZ]; /* interface name                   */
                    152:     struct listaddr *uv_groups;     /* list of local groups  (phyints only) */
                    153:     struct listaddr *uv_dvmrp_neighbors; /* list of neighboring routers     */
                    154:     nbrbitmap_t             uv_nbrmap;     /* bitmap of active neighboring routers */
                    155:     struct listaddr *uv_querier;    /* IGMP querier on vif                  */
                    156:     int                     uv_igmpv1_warn;/* To rate-limit IGMPv1 warnings        */
                    157:     int                     uv_prune_lifetime; /* Prune lifetime or 0 for default  */
                    158:     struct vif_acl  *uv_acl;       /* access control list of groups        */
                    159:     int                     uv_leaf_timer; /* time until this vif is considrd leaf */
                    160:     struct phaddr   *uv_addrs;     /* Additional subnets on this vif       */
                    161:     struct vif_filter *uv_filter;   /* Route filters on this vif           */
                    162:     u_int16        uv_pim_hello_timer;/* timer for sending PIM hello msgs  */
                    163:     u_int16        uv_gq_timer;    /* Group Query timer                    */
                    164:     int             uv_local_pref;  /* default local preference for assert  */
                    165:     int             uv_local_metric; /* default local metric for assert     */
                    166:     struct pim_nbr_entry *uv_pim_neighbors; /* list of PIM neighbor routers */
                    167: };
                    168: 
                    169: /* TODO: define VIFF_KERNEL_FLAGS */
                    170: #define VIFF_KERNEL_FLAGS      (VIFF_TUNNEL | VIFF_SRCRT)
                    171: #define VIFF_DOWN              0x000100       /* kernel state of interface */
                    172: #define VIFF_DISABLED          0x000200       /* administratively disabled */
                    173: #define VIFF_QUERIER           0x000400       /* I am the subnet's querier */
                    174: #define VIFF_ONEWAY            0x000800       /* Maybe one way interface   */
                    175: #define VIFF_LEAF              0x001000       /* all neighbors are leaves  */
                    176: #define VIFF_IGMPV1            0x002000       /* Act as an IGMPv1 Router   */
                    177: #define        VIFF_REXMIT_PRUNES      0x004000       /* retransmit prunes         */
                    178: #define VIFF_PASSIVE           0x008000       /* passive tunnel            */
                    179: #define        VIFF_ALLOW_NONPRUNERS   0x010000       /* ok to peer with nonprunrs */
                    180: #define VIFF_NOFLOOD           0x020000       /* don't flood on this vif   */
                    181: #define        VIFF_DR                 0x040000       /* designated router         */
                    182: /* TODO: VIFF_NONBRS == VIFF_ONEWAY? */
                    183: #define        VIFF_NONBRS             0x080000       /* no neighbor on vif        */
                    184: #define VIFF_POINT_TO_POINT     0x100000       /* point-to-point link       */
                    185: #define VIFF_PIM_NBR            0x200000       /* PIM neighbor              */
                    186: #define VIFF_DVMRP_NBR          0x400000       /* DVMRP neighbor            */
                    187: 
                    188: struct phaddr {
                    189:     struct phaddr   *pa_next;
                    190:     u_int32         pa_subnet;         /* extra subnet                 */
                    191:     u_int32         pa_subnetmask;     /* netmask of extra subnet      */
                    192:     u_int32         pa_subnetbcast;    /* broadcast of extra subnet    */
                    193: };
                    194: 
                    195: /* The Access Control List (list with scoped addresses) member */
                    196: struct vif_acl {
                    197:     struct vif_acl  *acl_next;     /* next acl member         */
                    198:     u_int32         acl_addr;      /* Group address           */
                    199:     u_int32         acl_mask;      /* Group addr. mask        */
                    200: };
                    201: 
                    202: struct vif_filter {
                    203:     int                        vf_type;
                    204: #define        VFT_ACCEPT      1
                    205: #define        VFT_DENY        2
                    206:     int                        vf_flags;
                    207: #define        VFF_BIDIR       1
                    208:     struct vf_element  *vf_filter;
                    209: };
                    210: 
                    211: struct vf_element {
                    212:     struct vf_element  *vfe_next;
                    213:     u_int32            vfe_addr;
                    214:     u_int32            vfe_mask;
                    215:     int                        vfe_flags;
                    216: #define        VFEF_EXACT      0x0001
                    217: };
                    218: 
                    219: struct listaddr {
                    220:     struct listaddr *al_next;          /* link to next addr, MUST BE FIRST */
                    221:     u_int32         al_addr;           /* local group or neighbor address  */
                    222:     u_long          al_timer;          /* for timing out group or neighbor */
                    223:     time_t          al_ctime;          /* entry creation time              */
                    224:     union {
                    225:        u_int32      alu_genid;         /* generation id for neighbor       */
                    226:        u_int32      alu_reporter;      /* a host which reported membership */
                    227:     } al_alu;
                    228:     u_char          al_pv;             /* router protocol version          */
                    229:     u_char          al_mv;             /* router mrouted version           */
                    230:     u_char          al_old;            /* time since heard old report      */
                    231:     u_char          al_index;          /* neighbor index                   */
                    232:     u_long          al_timerid;        /* timer for group membership       */
                    233:     u_long          al_query;          /* timer for repeated leave query   */
                    234:     u_int16         al_flags;          /* flags related to this neighbor   */
                    235: };
                    236: #define        al_genid        al_alu.alu_genid
                    237: #define        al_reporter     al_alu.alu_reporter
                    238: 
                    239: #define        NBRF_LEAF               0x0001  /* This neighbor is a leaf          */
                    240: #define        NBRF_GENID              0x0100  /* I know this neighbor's genid     */
                    241: #define        NBRF_WAITING            0x0200  /* Waiting for peering to come up   */
                    242: #define        NBRF_ONEWAY             0x0400  /* One-way peering                  */
                    243: #define        NBRF_TOOOLD             0x0800  /* Too old (policy decision)        */
                    244: #define        NBRF_TOOMANYROUTES      0x1000  /* Neighbor is spouting routes      */
                    245: #define        NBRF_NOTPRUNING         0x2000  /* Neighbor doesn't appear to prune */
                    246: 
                    247: /*
                    248:  * Don't peer with neighbors with any of these flags set
                    249:  */
                    250: #define        NBRF_DONTPEER           (NBRF_WAITING|NBRF_ONEWAY|NBRF_TOOOLD| \
                    251:                                 NBRF_TOOMANYROUTES|NBRF_NOTPRUNING)
                    252: 
                    253: #define NO_VIF         ((vifi_t)MAXVIFS)  /* An invalid vif index */
                    254:   
                    255: 
                    256: /*
                    257:  * Used to get the RPF neighbor and IIF info
                    258:  * for a given source from the unicast routing table. 
                    259:  */
                    260: struct rpfctl {
                    261:     struct in_addr source; /* the source for which we want iif and rpfnbr */
                    262:     struct in_addr rpfneighbor;/* next hop towards the source */
                    263:     vifi_t iif; /* the incoming interface to reach the next hop */
                    264: };

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