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

1.1       misho       1: /*
                      2:  * The mrouted program is covered by the license in the accompanying file
                      3:  * named "LICENSE".  Use of the mrouted program represents acceptance of
                      4:  * the terms and conditions listed in that file.
                      5:  *
                      6:  * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
                      7:  * Leland Stanford Junior University.
                      8:  *
                      9:  *
                     10:  * vif.h,v 3.8.4.26 1998/01/14 21:21:19 fenner Exp
                     11:  */
                     12: 
                     13: 
                     14: /*
                     15:  * Bitmap handling functions.
                     16:  * These should be fast but generic.  bytes can be slow to zero and compare,
                     17:  * words are hard to make generic.  Thus two sets of macros (yuk).
                     18:  */
                     19: 
                     20: /*
                     21:  * The VIFM_ functions should migrate out of <netinet/ip_mroute.h>, since
                     22:  * the kernel no longer uses vifbitmaps.
                     23:  */
                     24: #ifndef VIFM_SET
                     25: 
                     26: typedef        u_int32 vifbitmap_t;
                     27: 
                     28: #define        VIFM_SET(n, m)                  ((m) |=  (1 << (n)))
                     29: #define        VIFM_CLR(n, m)                  ((m) &= ~(1 << (n)))
                     30: #define        VIFM_ISSET(n, m)                ((m) &   (1 << (n)))
                     31: #define VIFM_CLRALL(m)                 ((m) = 0x00000000)
                     32: #define VIFM_COPY(mfrom, mto)          ((mto) = (mfrom))
                     33: #define VIFM_SAME(m1, m2)              ((m1) == (m2))
                     34: #endif
                     35: /*
                     36:  * And <netinet/ip_mroute.h> was missing some required functions anyway
                     37:  */
                     38: #if !defined(VIFM_SETALL)
                     39: #define        VIFM_SETALL(m)                  ((m) = ~0)
                     40: #endif
                     41: #define        VIFM_ISSET_ONLY(n, m)           ((m) == (1 << (n)))
                     42: #define        VIFM_ISEMPTY(m)                 ((m) == 0)
                     43: #define        VIFM_CLR_MASK(m, mask)          ((m) &= ~(mask))
                     44: #define        VIFM_SET_MASK(m, mask)          ((m) |= (mask))
                     45: 
                     46: /*
                     47:  * Neighbor bitmaps are, for efficiency, implemented as a struct
                     48:  * containing two variables of a native machine type.  If you
                     49:  * have a native type that's bigger than a long, define it below.
                     50:  */
                     51: #define        NBRTYPE         u_long
                     52: #define NBRBITS                sizeof(NBRTYPE) * 8
                     53: 
                     54: typedef struct {
                     55:     NBRTYPE hi;
                     56:     NBRTYPE lo;
                     57: } nbrbitmap_t;
                     58: #define        MAXNBRS         2 * NBRBITS
                     59: #define        NO_NBR          MAXNBRS
                     60: 
                     61: #define        NBRM_SET(n, m)          (((n) < NBRBITS) ? ((m).lo |= (1 << (n))) :  \
                     62:                                      ((m).hi |= (1 << (n - NBRBITS))))
                     63: #define        NBRM_CLR(n, m)          (((n) < NBRBITS) ? ((m).lo &= ~(1 << (n))) : \
                     64:                                      ((m).hi &= ~(1 << (n - NBRBITS))))
                     65: #define        NBRM_ISSET(n, m)        (((n) < NBRBITS) ? ((m).lo & (1 << (n))) :   \
                     66:                                      ((m).hi & (1 << ((n) - NBRBITS))))
                     67: #define        NBRM_CLRALL(m)          ((m).lo = (m).hi = 0)
                     68: #define        NBRM_COPY(mfrom, mto)   ((mto).lo = (mfrom).lo, (mto).hi = (mfrom).hi)
                     69: #define        NBRM_SAME(m1, m2)       (((m1).lo == (m2).lo) && ((m1).hi == (m2).hi))
                     70: #define        NBRM_ISEMPTY(m)         (((m).lo == 0) && ((m).hi == 0))
                     71: #define        NBRM_SETMASK(m, mask)   (((m).lo |= (mask).lo),((m).hi |= (mask).hi))
                     72: #define        NBRM_CLRMASK(m, mask)   (((m).lo &= ~(mask).lo),((m).hi &= ~(mask).hi))
                     73: #define        NBRM_MASK(m, mask)      (((m).lo &= (mask).lo),((m).hi &= (mask).hi))
                     74: #define        NBRM_ISSETMASK(m, mask) (((m).lo & (mask).lo) || ((m).hi & (mask).hi))
                     75: #define        NBRM_ISSETALLMASK(m, mask)\
                     76:                                ((((m).lo & (mask).lo) == (mask).lo) && \
                     77:                                 (((m).hi & (mask).hi) == (mask).hi))
                     78: /*
                     79:  * This macro is TRUE if all the subordinates have been pruned, or if
                     80:  * there are no subordinates on this vif.
                     81:  * The arguments is the map of subordinates, the map of neighbors on the
                     82:  * vif, and the map of received prunes.
                     83:  */
                     84: #define        SUBS_ARE_PRUNED(sub, vifmask, prunes)   \
                     85:     (((sub).lo & (vifmask).lo) == ((prunes).lo & (vifmask).lo & (sub).lo) && \
                     86:      ((sub).hi & (vifmask).hi) == ((prunes).hi & (vifmask).hi & (sub).hi))
                     87: 
                     88: struct blastinfo {
                     89:     char *          bi_buf;        /* Pointer to malloced storage          */
                     90:     char *          bi_cur;        /* The update to process next           */
                     91:     char *          bi_end;        /* The place to put the next update     */
                     92:     int                     bi_len;        /* Size of malloced storage             */
                     93:     int                     bi_timer;      /* Timer to run process_blaster_report  */
                     94: };
                     95: 
                     96: /*
                     97:  * User level Virtual Interface structure
                     98:  *
                     99:  * A "virtual interface" is either a physical, multicast-capable interface
                    100:  * (called a "phyint") or a virtual point-to-point link (called a "tunnel").
                    101:  * (Note: all addresses, subnet numbers and masks are kept in NETWORK order.)
                    102:  */
                    103: struct uvif {
                    104:     u_int           uv_flags;      /* VIFF_ flags defined below            */
                    105:     u_char          uv_metric;     /* cost of this vif                     */
                    106:     u_char          uv_admetric;   /* advertised cost of this vif          */
                    107:     u_char          uv_threshold;  /* min ttl required to forward on vif   */
                    108:     u_int           uv_rate_limit; /* rate limit on this vif               */
                    109:     u_int32         uv_lcl_addr;   /* local address of this vif            */
                    110:     u_int32         uv_rmt_addr;   /* remote end-point addr (tunnels only) */
                    111:     u_int32         uv_dst_addr;   /* destination for DVMRP/PIM messages   */
                    112:     u_int32         uv_subnet;     /* subnet number         (phyints only) */
                    113:     u_int32         uv_subnetmask; /* subnet mask           (phyints only) */
                    114:     u_int32         uv_subnetbcast;/* subnet broadcast addr (phyints only) */
                    115:     char            uv_name[IFNAMSIZ]; /* interface name                   */
                    116:     struct listaddr *uv_groups;     /* list of local groups  (phyints only) */
                    117:     struct listaddr *uv_neighbors;  /* list of neighboring routers          */
                    118:     nbrbitmap_t             uv_nbrmap;     /* bitmap of active neighboring routers */
                    119:     struct listaddr *uv_querier;    /* IGMP querier on vif                  */
                    120:     int                     uv_igmpv1_warn;/* To rate-limit IGMPv1 warnings        */
                    121:     int                     uv_prune_lifetime; /* Prune lifetime or 0 for default  */
                    122:     struct vif_acl  *uv_acl;       /* access control list of groups        */
                    123:     int                     uv_leaf_timer; /* time until this vif is considrd leaf */
                    124:     struct phaddr   *uv_addrs;     /* Additional subnets on this vif       */
                    125:     struct vif_filter *uv_filter;   /* Route filters on this vif           */
                    126:     struct blastinfo uv_blaster;    /* Info about route blasters           */
                    127:     int                     uv_nbrup;      /* Counter for neighbor up events       */
                    128:     int                     uv_icmp_warn;  /* To rate-limit ICMP warnings          */
                    129:     u_int           uv_nroutes;    /* # of routes with this vif as parent  */
                    130:     struct ip      *uv_encap_hdr;  /* Pre-formed header to encapsulate msgs*/
                    131: };
                    132: 
                    133: #define uv_blasterbuf  uv_blaster.bi_buf
                    134: #define        uv_blastercur   uv_blaster.bi_cur
                    135: #define        uv_blasterend   uv_blaster.bi_end
                    136: #define uv_blasterlen  uv_blaster.bi_len
                    137: #define uv_blastertimer        uv_blaster.bi_timer
                    138: 
                    139: #define VIFF_KERNEL_FLAGS      (VIFF_TUNNEL|VIFF_SRCRT)
                    140: #define VIFF_DOWN              0x000100        /* kernel state of interface */
                    141: #define VIFF_DISABLED          0x000200        /* administratively disabled */
                    142: #define VIFF_QUERIER           0x000400        /* I am the subnet's querier */
                    143: #define VIFF_ONEWAY            0x000800        /* Maybe one way interface   */
                    144: #define VIFF_LEAF              0x001000        /* all neighbors are leaves  */
                    145: #define VIFF_IGMPV1            0x002000        /* Act as an IGMPv1 Router   */
                    146: #define        VIFF_REXMIT_PRUNES      0x004000        /* retransmit prunes         */
                    147: #define VIFF_PASSIVE           0x008000        /* passive tunnel            */
                    148: #define        VIFF_ALLOW_NONPRUNERS   0x010000        /* ok to peer with nonprunrs */
                    149: #define VIFF_NOFLOOD           0x020000        /* don't flood on this vif   */
                    150: #define        VIFF_NOTRANSIT          0x040000        /* don't transit these vifs  */
                    151: #define        VIFF_BLASTER            0x080000        /* nbr on vif blasts routes  */
                    152: #define        VIFF_FORCE_LEAF         0x100000        /* ignore nbrs on this vif   */
                    153: #define        VIFF_OTUNNEL            0x200000        /* DVMRP msgs "beside" tunnel*/
                    154: 
                    155: #define        AVOID_TRANSIT(v, r)     \
                    156:                (((r)->rt_parent != NO_VIF) && \
                    157:                 ((r)->rt_gateway != 0) && \
                    158:                 (uvifs[(v)].uv_flags & VIFF_NOTRANSIT) && \
                    159:                 (uvifs[(r)->rt_parent].uv_flags & VIFF_NOTRANSIT))
                    160: 
                    161: struct phaddr {
                    162:     struct phaddr   *pa_next;
                    163:     u_int32         pa_subnet;         /* extra subnet                 */
                    164:     u_int32         pa_subnetmask;     /* netmask of extra subnet      */
                    165:     u_int32         pa_subnetbcast;    /* broadcast of extra subnet    */
                    166: };
                    167: 
                    168: /* The Access Control List (list with scoped addresses) member */
                    169: struct vif_acl {
                    170:     struct vif_acl  *acl_next;     /* next acl member         */
                    171:     u_int32         acl_addr;      /* Group address           */
                    172:     u_int32         acl_mask;      /* Group addr. mask        */
                    173: };
                    174: 
                    175: struct vif_filter {
                    176:     int                        vf_type;
                    177: #define        VFT_ACCEPT      1
                    178: #define        VFT_DENY        2
                    179:     int                        vf_flags;
                    180: #define        VFF_BIDIR       1
                    181:     struct vf_element  *vf_filter;
                    182: };
                    183: 
                    184: struct vf_element {
                    185:     struct vf_element  *vfe_next;
                    186:     u_int32            vfe_addr;
                    187:     u_int32            vfe_mask;
                    188:     int                        vfe_flags;
                    189: #define        VFEF_EXACT      0x0001
                    190: };
                    191: 
                    192: struct listaddr {
                    193:     struct listaddr *al_next;          /* link to next addr, MUST BE FIRST */
                    194:     u_int32         al_addr;           /* local group or neighbor address  */
                    195:     u_long          al_timer;          /* for timing out group or neighbor */
                    196:     time_t          al_ctime;          /* entry creation time              */
                    197:     union {
                    198:        struct {
                    199:            u_int32  alur_genid;        /* generation id for neighbor       */
                    200:            u_int    alur_nroutes;      /* # of routes w/ nbr as parent     */
                    201:            u_char   alur_pv;           /* router protocol version          */
                    202:            u_char   alur_mv;           /* router mrouted version           */
                    203:            u_char   alur_index;        /* neighbor index                   */
                    204:        } alu_router;
                    205:        struct {
                    206:            u_int32  alug_reporter;     /* a host which reported membership */
                    207:            u_long   alug_timerid;      /* timer for group membership       */
                    208:            u_long   alug_query;        /* timer for repeated leave query   */
                    209:            u_char   alug_old;          /* time since heard old report      */
                    210:        } alu_group;
                    211:     } al_alu;
                    212:     u_int16_t       al_flags;          /* flags related to this neighbor   */
                    213: };
                    214: #define        al_genid        al_alu.alu_router.alur_genid
                    215: #define        al_nroutes      al_alu.alu_router.alur_nroutes
                    216: #define al_pv          al_alu.alu_router.alur_pv
                    217: #define al_mv          al_alu.alu_router.alur_mv
                    218: #define        al_index        al_alu.alu_router.alur_index
                    219: #define        al_reporter     al_alu.alu_group.alug_reporter
                    220: #define        al_old          al_alu.alu_group.alug_old
                    221: #define        al_timerid      al_alu.alu_group.alug_timerid
                    222: #define        al_query        al_alu.alu_group.alug_query
                    223: 
                    224: #define        NBRF_LEAF               0x0001  /* This neighbor is a leaf          */
                    225: #define        NBRF_GENID              0x0100  /* I know this neighbor's genid     */
                    226: #define        NBRF_WAITING            0x0200  /* Waiting for peering to come up   */
                    227: #define        NBRF_ONEWAY             0x0400  /* One-way peering                  */
                    228: #define        NBRF_TOOOLD             0x0800  /* Too old (policy decision)        */
                    229: #define        NBRF_TOOMANYROUTES      0x1000  /* Neighbor is spouting routes      */
                    230: #define        NBRF_NOTPRUNING         0x2000  /* Neighbor doesn't appear to prune */
                    231: 
                    232: /*
                    233:  * Don't peer with neighbors with any of these flags set
                    234:  */
                    235: #define        NBRF_DONTPEER           (NBRF_WAITING|NBRF_ONEWAY|NBRF_TOOOLD| \
                    236:                                 NBRF_TOOMANYROUTES|NBRF_NOTPRUNING)
                    237: 
                    238: #define NO_VIF         ((vifi_t)MAXVIFS)  /* An invalid vif index */

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