Annotation of embedaddon/pimd/mrt.h, revision 1.1.1.1

1.1       misho       1: /*
                      2:  * Copyright (c) 1998-2001
                      3:  * University of Southern California/Information Sciences Institute.
                      4:  * All rights reserved.
                      5:  *
                      6:  * Redistribution and use in source and binary forms, with or without
                      7:  * modification, are permitted provided that the following conditions
                      8:  * are met:
                      9:  * 1. Redistributions of source code must retain the above copyright
                     10:  *    notice, this list of conditions and the following disclaimer.
                     11:  * 2. Redistributions in binary form must reproduce the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer in the
                     13:  *    documentation and/or other materials provided with the distribution.
                     14:  * 3. Neither the name of the project nor the names of its contributors
                     15:  *    may be used to endorse or promote products derived from this software
                     16:  *    without specific prior written permission.
                     17:  *
                     18:  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
                     19:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     20:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     21:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
                     22:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     23:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     24:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     25:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     26:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     27:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     28:  * SUCH DAMAGE.
                     29:  */
                     30: /*
                     31:  *  $Id: mrt.h,v 1.16 2001/09/10 20:31:36 pavlin Exp $
                     32:  */
                     33: 
                     34: #define MRTF_SPT               0x0001  /* iif toward source                */
                     35: #define MRTF_WC                        0x0002  /* (*,G) entry                      */
                     36: #define MRTF_RP                        0x0004  /* iif toward RP                    */
                     37: #define MRTF_NEW               0x0008  /* new created routing entry        */
                     38: #define MRTF_IIF_REGISTER      0x0020  /* ???                              */
                     39: #define MRTF_REGISTER          0x0080  /* ???                              */
                     40: #define MRTF_KERNEL_CACHE      0x0200  /* a mirror for the kernel cache    */
                     41: #define MRTF_NULL_OIF          0x0400  /* null oif cache..     ???         */
                     42: #define MRTF_REG_SUPP          0x0800  /* register suppress    ???         */
                     43: #define MRTF_ASSERTED          0x1000  /* upstream is not that of src ???  */
                     44: #define MRTF_SG                        0x2000  /* (S,G) pure, not hanging off of (*,G)*/
                     45: #define MRTF_PMBR              0x4000  /* (*,*,RP) entry (for interop)     */
                     46: #define MRTF_MFC_CLONE_SG      0x8000  /* clone (S,G) MFC from (*,G) or (*,*,RP) */
                     47: 
                     48: /* Macro to duplicate oif info (oif bits, timers) */
                     49: #define VOIF_COPY(from, to)                                            \
                     50:     do {                                                               \
                     51:        VIFM_COPY((from)->joined_oifs, (to)->joined_oifs);              \
                     52:        VIFM_COPY((from)->oifs, (to)->oifs);                            \
                     53:        VIFM_COPY((from)->leaves, (to)->leaves);                        \
                     54:        VIFM_COPY((from)->pruned_oifs, (to)->pruned_oifs);              \
                     55:        VIFM_COPY((from)->asserted_oifs, (to)->asserted_oifs);          \
                     56:        memcpy((to)->vif_timers, (from)->vif_timers,                    \
                     57:               numvifs * sizeof((from)->vif_timers[0]));                \
                     58:        memcpy((to)->vif_deletion_delay, (from)->vif_deletion_delay,    \
                     59:               numvifs * sizeof((from)->vif_deletion_delay[0]));        \
                     60:     } while (0)
                     61: 
                     62: #define FREE_MRTENTRY(mrtentry_ptr)                            \
                     63:     do {                                                       \
                     64:        kernel_cache_t *curr;                                   \
                     65:        kernel_cache_t *next;                                   \
                     66:                                                                \
                     67:        if ((mrtentry_ptr)->vif_timers)                         \
                     68:            free((mrtentry_ptr)->vif_timers);                   \
                     69:        if ((mrtentry_ptr)->vif_deletion_delay)                 \
                     70:            free((mrtentry_ptr)->vif_deletion_delay);           \
                     71:        curr = (mrtentry_ptr)->kernel_cache;                    \
                     72:        while (curr) {                                          \
                     73:            next = curr->next;                                  \
                     74:            free(curr);                                         \
                     75:            curr = next;                                        \
                     76:        }                                                       \
                     77:        free(mrtentry_ptr);                                     \
                     78:     } while (0)
                     79: 
                     80: 
                     81: /*
                     82:  * The complicated structure used by the more complicated Join/Prune
                     83:  * message building
                     84:  */
                     85: typedef struct build_jp_message_ {
                     86:     struct build_jp_message_ *next; /* Used to chain the free entries       */
                     87:     uint8_t *jp_message;       /* The Join/Prune message                     */
                     88:     uint32_t jp_message_size;  /* Size of the Join/Prune message (in bytes)  */
                     89:     uint16_t holdtime;       /* Join/Prune message holdtime field          */
                     90:     uint32_t curr_group;             /* Current group address                      */
                     91:     uint8_t  curr_group_msklen;/* Current group masklen                            */
                     92:     uint8_t *join_list;              /* The working area for the join addresses    */
                     93:     uint32_t join_list_size;   /* The size of the join_list (in bytes)       */
                     94:     uint16_t join_addr_number; /* Number of the join addresses in join_list  */
                     95:     uint8_t *prune_list;       /* The working area for the prune addresses   */
                     96:     uint32_t prune_list_size;  /* The size of the prune_list (in bytes)      */
                     97:     uint16_t prune_addr_number;/* Number of the prune addresses in prune_list*/
                     98:     uint8_t *rp_list_join;     /* The working area for RP join addresses     */
                     99:     uint32_t rp_list_join_size;/* The size of the rp_list_join (in bytes)    */
                    100:     uint16_t rp_list_join_number;/* Number of RP addresses in rp_list_join   */
                    101:     uint8_t *rp_list_prune;     /* The working area for RP prune addresses   */
                    102:     uint32_t rp_list_prune_size;/* The size of the rp_list_prune (in bytes)  */
                    103:     uint16_t rp_list_prune_number;/* Number of RP addresses in rp_list_prune */
                    104:     uint8_t *num_groups_ptr;   /* Pointer to number_of_groups in jp_message  */
                    105: } build_jp_message_t;
                    106: 
                    107: 
                    108: typedef struct pim_nbr_entry {
                    109:     struct pim_nbr_entry *next;                  /* link to next neighbor          */
                    110:     struct pim_nbr_entry *prev;                  /* link to prev neighbor          */
                    111:     uint32_t             address;        /* neighbor address               */
                    112:     int8_t                dr_prio_present;/* If set, this neighbor has prio */
                    113:     uint32_t              dr_prio;       /* DR priority: 1 (default)       */
                    114:     uint32_t              genid;         /* Cached generation ID           */
                    115:     vifi_t               vifi;           /* which interface                */
                    116:     uint16_t             timer;          /* for timing out neighbor        */
                    117:     build_jp_message_t *build_jp_message; /* A structure for fairly
                    118:                                           * complicated Join/Prune
                    119:                                           * message construction.
                    120:                                           */
                    121: } pim_nbr_entry_t;
                    122: 
                    123: 
                    124: typedef struct srcentry {
                    125:     struct srcentry     *next;         /* link to next entry               */
                    126:     struct srcentry     *prev;         /* link to prev entry               */
                    127:     uint32_t             address;      /* source or RP address             */
                    128:     struct mrtentry     *mrtlink;      /* link to routing entries          */
                    129:     vifi_t               incoming;     /* incoming vif                     */
                    130:     struct pim_nbr_entry *upstream;    /* upstream router                  */
                    131:     uint32_t             metric;       /* Unicast Routing Metric to the source */
                    132:     uint32_t             preference;   /* The metric preference (for assers)*/
                    133:     uint16_t             timer;        /* Entry timer??? Delete?           */
                    134:     struct cand_rp      *cand_rp;      /* Used if this is rpentry_t        */
                    135: } srcentry_t;
                    136: typedef srcentry_t rpentry_t;
                    137: 
                    138: 
                    139: /* (RP<->group) matching table related structures */
                    140: typedef struct cand_rp {
                    141:     struct cand_rp     *next;         /* Next candidate RP                 */
                    142:     struct cand_rp     *prev;         /* Previous candidate RP             */
                    143:     struct rp_grp_entry *rp_grp_next;  /* The rp_grp_entry chain for that RP*/
                    144:     rpentry_t          *rpentry;      /* Pointer to the RP entry           */
                    145: } cand_rp_t;
                    146: 
                    147: typedef struct grp_mask {
                    148:     struct grp_mask    *next;
                    149:     struct grp_mask    *prev;
                    150:     struct rp_grp_entry *grp_rp_next;
                    151:     uint32_t            group_addr;
                    152:     uint32_t            group_mask;
                    153:     uint32_t            hash_mask;
                    154:     uint16_t            fragment_tag;    /* Used for garbage collection    */
                    155:     uint8_t             group_rp_number; /* Used when assembling segments  */
                    156: } grp_mask_t;
                    157: 
                    158: typedef struct rp_grp_entry {
                    159:     struct rp_grp_entry *rp_grp_next; /* Next entry for same RP                 */
                    160:     struct rp_grp_entry *rp_grp_prev; /* Prev entry for same RP                 */
                    161:     struct rp_grp_entry *grp_rp_next; /* Next entry for same grp prefix         */
                    162:     struct rp_grp_entry *grp_rp_prev; /* Prev entry for same grp prefix         */
                    163:     struct grpentry    *grplink;     /* Link to all grps via this entry */
                    164:     uint16_t            holdtime;    /* The RP holdtime                 */
                    165:     uint16_t            fragment_tag; /* The fragment tag from the
                    166:                                        * received BSR message           */
                    167:     uint8_t             priority;    /* The RP priority                 */
                    168:     grp_mask_t         *group;       /* Pointer to (group,mask) entry   */
                    169:     cand_rp_t          *rp;          /* Pointer to the RP               */
                    170: } rp_grp_entry_t;
                    171: 
                    172: 
                    173: typedef struct grpentry {
                    174:     struct grpentry    *next;         /* link to next entry                */
                    175:     struct grpentry    *prev;         /* link to prev entry                */
                    176:     struct grpentry    *rpnext;       /* next grp for the same RP          */
                    177:     struct grpentry    *rpprev;       /* prev grp for the same RP          */
                    178:     uint32_t            group;        /* subnet group of multicasts        */
                    179:     uint32_t            rpaddr;       /* The IP address of the RP          */
                    180:     struct mrtentry    *mrtlink;      /* link to (S,G) routing entries     */
                    181:     rp_grp_entry_t     *active_rp_grp;/* Pointer to the active rp_grp entry*/
                    182:     struct mrtentry    *grp_route;    /* Pointer to the (*,G) routing entry*/
                    183: } grpentry_t;
                    184: 
                    185: typedef struct mrtentry {
                    186:     struct mrtentry      *grpnext;     /* next entry of same group         */
                    187:     struct mrtentry      *grpprev;     /* prev entry of same group         */
                    188:     struct mrtentry      *srcnext;     /* next entry of same source        */
                    189:     struct mrtentry      *srcprev;     /* prev entry of same source        */
                    190:     struct grpentry      *group;       /* pointer to group entry           */
                    191:     struct srcentry      *source;      /* pointer to source entry (or RP)  */
                    192:     vifi_t               incoming;     /* the iif (either toward S or RP)  */
                    193:     vifbitmap_t                  oifs;         /* The current result oifs          */
                    194:     vifbitmap_t                  joined_oifs;  /* The joined oifs (Join received)  */
                    195:     vifbitmap_t                  pruned_oifs;  /* The pruned oifs (Prune received) */
                    196:     vifbitmap_t                  asserted_oifs;/* The asserted oifs (lost Assert)  */
                    197:     vifbitmap_t                  leaves;       /* Has directly connected members   */
                    198:     struct pim_nbr_entry *upstream;    /* upstream router, needed because
                    199:                                         * of the asserts it may be different
                    200:                                         * than the source (or RP) upstream
                    201:                                         * router.
                    202:                                         */
                    203:     uint32_t            metric;        /* Routing Metric for this entry    */
                    204:     uint32_t            preference;    /* The metric preference value      */
                    205:     uint32_t            pmbr_addr;     /* The PMBR address (for interop)   */
                    206:     uint16_t           *vif_timers;    /* vifs timer list                  */
                    207:     uint16_t           *vif_deletion_delay; /* vifs deletion delay list    */
                    208:     uint16_t            flags;         /* The MRTF_* flags                 */
                    209:     uint16_t            timer;         /* entry timer                      */
                    210:     uint16_t            jp_timer;      /* The Join/Prune timer             */
                    211:     uint16_t            rs_timer;      /* Register-Suppression Timer       */
                    212:     u_int               assert_timer;
                    213:     u_int               assert_rate_timer;
                    214:     struct kernel_cache *kernel_cache; /* List of the kernel cache entries */
                    215: #ifdef RSRR
                    216:     struct rsrr_cache  *rsrr_cache;    /* Used to save RSRR requests for
                    217:                                         * route change notification. */
                    218: #endif /* RSRR */
                    219: } mrtentry_t;
                    220: 
                    221: 
                    222: /*
                    223:  * Used to get forwarded data related counts (number of packet, number of
                    224:  * bits, etc)
                    225:  */
                    226: struct sg_count {
                    227:     uint32_t  pktcnt;     /*  Number of packets for (s,g) */
                    228:     uint32_t  bytecnt;    /*  Number of bytes for (s,g)   */
                    229:     uint32_t  wrong_if;   /*  Number of packets received on wrong iif for (s,g) */
                    230: };
                    231: 
                    232: struct vif_count {
                    233:     uint32_t  icount;     /* Input packet count on vif    */
                    234:     uint32_t  ocount;     /* Output packet count on vif   */
                    235:     uint32_t  ibytes;     /* Input byte count on vif      */
                    236:     uint32_t  obytes;     /* Output byte count on vif     */
                    237: };
                    238: 
                    239: /*
                    240:  * Structure to keep track of existing (S,G) MFC entries in the kernel
                    241:  * for particular (*,G) or (*,*,RP) entry. We must keep track for
                    242:  * each active source which doesn't have (S,G) entry in the daemon's
                    243:  * routing table. We need to keep track of such sources for two reasons:
                    244:  *
                    245:  *    (1) If the kernel does not support (*,G) MFC entries (currently, the
                    246:  * "official" mcast code doesn't), we must know all installed (s,G) entries
                    247:  * in the kernel and modify them if the iif or oif for the (*,G) changes.
                    248:  *
                    249:  *    (2) By checking periodically the traffic coming from the shared tree,
                    250:  * we can either delete the idle sources or switch to the shortest path.
                    251:  *
                    252:  * Note that even if we have (*,G) implemented in the kernel, we still
                    253:  * need to have this structure because of (2)
                    254:  */
                    255: typedef struct kernel_cache {
                    256:     struct kernel_cache *next;
                    257:     struct kernel_cache *prev;
                    258:     uint32_t            source;
                    259:     uint32_t            group;
                    260:     struct sg_count      sg_count; /* The (s,g) data retated counters (see above) */
                    261: } kernel_cache_t;
                    262: 
                    263: /**
                    264:  * Local Variables:
                    265:  *  version-control: t
                    266:  *  indent-tabs-mode: t
                    267:  *  c-file-style: "ellemtel"
                    268:  *  c-basic-offset: 4
                    269:  * End:
                    270:  */

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