Annotation of embedaddon/pimd/defs.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:  * Part of this program has been derived from mrouted.
                     32:  * The mrouted program is covered by the license in the accompanying file
                     33:  * named "LICENSE.mrouted".
                     34:  *
                     35:  * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
                     36:  * Leland Stanford Junior University.
                     37:  *
                     38:  */
                     39: #ifndef __PIMD_DEFS_H__
                     40: #define __PIMD_DEFS_H__
                     41: 
                     42: #ifndef __linux__
                     43: # include <sys/cdefs.h>        /* Defines __BSD_VISIBLE, needed for arc4random() etc. */
                     44: #endif
                     45: 
                     46: #include <stdio.h>
                     47: #include <stdlib.h>
                     48: #include <stdint.h>
                     49: #include <unistd.h> 
                     50: #include <ctype.h>
                     51: #include <errno.h>
                     52: #include <syslog.h>
                     53: #include <signal.h> 
                     54: #include <string.h> 
                     55: #include <sys/param.h>
                     56: #include <sys/types.h>
                     57: #include <sys/socket.h>
                     58: #include <sys/ioctl.h>
                     59: #include <fcntl.h>
                     60: #if ((defined(SYSV)) || (defined(__bsdi__)) || ((defined SunOS) && (SunOS < 50)))
                     61: #include <sys/sockio.h>
                     62: #endif /* SYSV || bsdi || SunOS 4.x */
                     63: #include <time.h>
                     64: #include <sys/time.h>
                     65: #include <net/if.h>
                     66: #include <netinet/in.h>
                     67: #include <arpa/inet.h>
                     68: #include <netinet/in_systm.h>
                     69: #include <netinet/ip.h>
                     70: #include <netinet/igmp.h>
                     71: #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
                     72: #include <osreldate.h>
                     73: #endif /* __FreeBSD__ */
                     74: #if defined(__bsdi__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
                     75: #define rtentry kernel_rtentry
                     76: #include <net/route.h>
                     77: #undef rtentry
                     78: #endif /* bsdi or __FreeBSD_version >= 220000 */
                     79: #ifdef __linux__
                     80: #define _LINUX_IN_H             /* For Linux <= 2.6.25 */
                     81: #include <linux/types.h>
                     82: #include <linux/mroute.h>
                     83: #else
                     84: #include <netinet/ip_mroute.h>
                     85: #endif /* __linux__ */
                     86: 
                     87: /* If using any of the BSD distributions of UNIX the configure script
                     88:  * links with -lutil, but on Linux we link with -lite.  All required
                     89:  * APIs are forward declared in lite.h, so we can use it everywhere. */
                     90: #include "libite/lite.h"
                     91: 
                     92: #include <strings.h>
                     93: #ifdef RSRR
                     94: #include <sys/un.h>
                     95: #endif /* RSRR */
                     96: 
                     97: #ifndef BYTE_ORDER
                     98: #if (BSD >= 199103)
                     99: #include <machine/endian.h>
                    100: #else
                    101: #ifdef __linux__
                    102: #include <endian.h>
                    103: #else
                    104: #define LITTLE_ENDIAN  1234    /* least-significant byte first (vax, pc) */
                    105: #define BIG_ENDIAN     4321    /* most-significant byte first (IBM, net) */
                    106: #define PDP_ENDIAN     3412    /* LSB first in word, MSW first in long (pdp) */
                    107: 
                    108: #if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
                    109:     defined(__ia64) || \
                    110:     defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
                    111:     defined(__alpha__) || defined(__alpha)
                    112: #define BYTE_ORDER     LITTLE_ENDIAN
                    113: #endif
                    114: 
                    115: #if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
                    116:     defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
                    117:     defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
                    118:     defined(apollo) || defined(__convex__) || defined(_CRAY) || \
                    119:     defined(__hppa) || defined(__hp9000) || \
                    120:     defined(__hp9000s300) || defined(__hp9000s700) || \
                    121:     defined(BIT_ZERO_ON_LEFT) || defined(m68k)
                    122: #define BYTE_ORDER     BIG_ENDIAN
                    123: #endif
                    124: #endif /* linux */
                    125: #endif /* BSD */
                    126: #endif /* BYTE_ORDER */
                    127: 
                    128: typedef void (*cfunc_t) (void *);
                    129: typedef void (*ihfunc_t) (int, fd_set *);
                    130: 
                    131: #include "dvmrp.h"     /* Added for further compatibility and convenience */
                    132: #include "pimd.h"
                    133: #include "mrt.h"
                    134: #include "igmpv2.h"
                    135: #include "igmpv3.h"
                    136: #include "vif.h"
                    137: #include "debug.h"
                    138: #include "pathnames.h"
                    139: #ifdef RSRR
                    140: #include "rsrr.h"
                    141: #include "rsrr_var.h"
                    142: #endif /* RSRR */
                    143: 
                    144: /*
                    145:  * Miscellaneous constants and macros
                    146:  */
                    147: 
                    148: #define ENABLINGSTR(val)        (val) ? "enabling" : "disabling"
                    149: 
                    150: /*
                    151:  * Various definitions to make it working for different platforms
                    152:  */
                    153: /* The old style sockaddr definition doesn't have sa_len */
                    154: #if defined(_AIX) || (defined(BSD) && (BSD >= 199006)) /* sa_len was added with 4.3-Reno */
                    155: #define HAVE_SA_LEN
                    156: #endif
                    157: 
                    158: /* Versions of Solaris older than 2.6 don't have routing sockets. */
                    159: /* XXX TODO: check FreeBSD version and add all other platforms */
                    160: #if defined(__linux__)    || (defined(SunOS) && SunOS >=56) || \
                    161:     defined (IRIX)        || defined (__bsdi__)             || \
                    162:     defined (__FreeBSD__) || defined(__FreeBSD_kernel__)    || \
                    163:     defined(NetBSD)       || defined(OpenBSD)
                    164: #define HAVE_ROUTING_SOCKETS   1
                    165: #endif
                    166: 
                    167: /* Older versions of UNIX don't really give us true raw sockets.
                    168:  * Instead, they expect ip_len and ip_off in host byte order, and also
                    169:  * provide them to us in that format when receiving raw frames.
                    170:  *
                    171:  * This list could probably be made longer, e.g., SunOS and __bsdi__
                    172:  */
                    173: #if defined(__NetBSD__) ||                                     \
                    174:     (defined(__FreeBSD__) && (__FreeBSD_version < 1100030)) || \
                    175:     (defined(__OpenBSD__) && (OpenBSD < 200311))
                    176: #define HAVE_IP_HDRINCL_BSD_ORDER
                    177: #endif
                    178: 
                    179: #define TRUE                   1
                    180: #define FALSE                  0
                    181: 
                    182: #ifndef MAX
                    183: #define MAX(a,b) (((a) >= (b))? (a) : (b))
                    184: #define MIN(a,b) (((a) <= (b))? (a) : (b))
                    185: #endif /* MAX & MIN */
                    186: 
                    187: #define CREATE                  TRUE
                    188: #define DONT_CREATE             FALSE
                    189: 
                    190: #define MFC_MOVE_FORCE         0x1
                    191: #define MFC_UPDATE_FORCE       0x2
                    192: 
                    193: #define EQUAL(s1, s2)          (strcmp((s1), (s2)) == 0)
                    194: #define ARRAY_LEN(a)            (sizeof((a)) / sizeof((a)[0]))
                    195: 
                    196: #define JAN_1970                2208988800UL    /* 1970 - 1900 in seconds */
                    197: 
                    198: #define MINTTL                 1  /* min TTL in the packets send locally */
                    199: 
                    200: #define MAX_IP_PACKET_LEN       576
                    201: #define MIN_IP_HEADER_LEN       20 /* sizeof(struct ip) */
                    202: #define IP_IGMP_HEADER_LEN      24 /* MIN + Router Alert */
                    203: #define MAX_IP_HEADER_LEN       60
                    204: 
                    205: 
                    206: /*
                    207:  * The IGMPv2 <netinet/in.h> defines INADDR_ALLRTRS_GROUP, but earlier
                    208:  * ones don't, so we define it conditionally here.
                    209:  */
                    210: #ifndef INADDR_ALLRTRS_GROUP
                    211:                                        /* address for multicast mtrace msg */
                    212: #define INADDR_ALLRTRS_GROUP   (uint32_t)0xe0000002    /* 224.0.0.2 */
                    213: #endif
                    214: 
                    215: #ifndef INADDR_ALLRPTS_GROUP
                    216: #define INADDR_ALLRPTS_GROUP    ((in_addr_t)0xe0000016) /* 224.0.0.22, IGMPv3 */
                    217: #endif
                    218: 
                    219: #ifndef INADDR_MAX_LOCAL_GROUP
                    220: #define INADDR_MAX_LOCAL_GROUP (uint32_t)0xe00000ff    /* 224.0.0.255 */
                    221: #endif
                    222: 
                    223: #define INADDR_ANY_N            (uint32_t)0x00000000     /* INADDR_ANY in
                    224:                                                         * network order */
                    225: #define CLASSD_PREFIX           (uint32_t)0xe0000000     /* 224.0.0.0 */
                    226: #define STAR_STAR_RP_MSKLEN     4                       /* Masklen for
                    227:                                                         * 224.0.0.0 :
                    228:                                                         * to encode (*,*,RP)
                    229:                                                         */
                    230: #define ALL_MCAST_GROUPS_ADDR   (uint32_t)0xe0000000     /* 224.0.0.0 */
                    231: #define ALL_MCAST_GROUPS_LEN    4
                    232: 
                    233: /* Used by DVMRP */
                    234: #define DEFAULT_METRIC         1       /* default subnet/tunnel metric     */
                    235: #define DEFAULT_THRESHOLD      1       /* default subnet/tunnel threshold  */
                    236: 
                    237: /* Used if no relaible unicast routing information available */
                    238: #define UCAST_DEFAULT_ROUTE_DISTANCE   101
                    239: #define UCAST_DEFAULT_ROUTE_METRIC     1024
                    240: 
                    241: #define TIMER_INTERVAL         5       /* 5 sec virtual timer granularity  */
                    242: 
                    243: /*
                    244:  * TODO: recalculate the messages sizes, probably with regard to the MTU
                    245:  * TODO: cleanup
                    246:  */
                    247: #define MAX_JP_MESSAGE_SIZE     8192
                    248: #define MAX_JP_MESSAGE_POOL_NUMBER 8
                    249: #define MAX_JOIN_LIST_SIZE      1500
                    250: #define MAX_PRUNE_LIST_SIZE     1500
                    251: 
                    252: 
                    253: #ifdef RSRR
                    254: #define BIT_ZERO(X)            ((X) = 0)
                    255: #define BIT_SET(X,n)           ((X) |= 1 << (n))
                    256: #define BIT_CLR(X,n)           ((X) &= ~(1 << (n)))
                    257: #define BIT_TST(X,n)           ((X) & 1 << (n))
                    258: #endif /* RSRR */
                    259: 
                    260: #ifndef __linux__
                    261: #define RANDOM()                arc4random()
                    262: #else
                    263: #define RANDOM()                (uint32_t)random()
                    264: #endif
                    265: 
                    266: /* NetBSD 6.1, for instance, does not have IPOPT_RA defined. */
                    267: #ifndef IPOPT_RA
                    268: #define IPOPT_RA                148
                    269: #endif
                    270: 
                    271: /*
                    272:  * External declarations for global variables and functions.
                    273:  */
                    274: #define                        SEND_BUF_SIZE (128*1024)  /* Maximum buff size to
                    275:                                                   * send a packet */
                    276: #define                        RECV_BUF_SIZE (128*1024)  /* Maximum buff size to
                    277:                                                   * receive a packet */
                    278: #define                 SO_SEND_BUF_SIZE_MAX (256*1024)
                    279: #define                 SO_SEND_BUF_SIZE_MIN (48*1024)
                    280: #define                 SO_RECV_BUF_SIZE_MAX (256*1024)
                    281: #define                 SO_RECV_BUF_SIZE_MIN (48*1024)
                    282: 
                    283: 
                    284: /*
                    285:  * Global settings, from config.c
                    286:  */
                    287: extern uint16_t         pim_timer_hello_interval;
                    288: extern uint16_t         pim_timer_hello_holdtime;
                    289: 
                    290: /* TODO: describe the variables and clean up */
                    291: extern char            *igmp_recv_buf;
                    292: extern char            *igmp_send_buf;
                    293: extern char            *pim_recv_buf;
                    294: extern char            *pim_send_buf;
                    295: extern int             igmp_socket;
                    296: extern int             pim_socket;
                    297: extern uint32_t                allhosts_group;
                    298: extern uint32_t                allrouters_group;
                    299: extern uint32_t                allreports_group;
                    300: extern uint32_t                allpimrouters_group;
                    301: extern build_jp_message_t *build_jp_message_pool;
                    302: extern int             build_jp_message_pool_counter;
                    303: 
                    304: extern uint32_t                virtual_time;
                    305: extern char           *config_file;
                    306: extern int              haveterminal;
                    307: extern char            *__progname;
                    308: 
                    309: extern struct cand_rp_adv_message_ {
                    310:     uint8_t  *buffer;
                    311:     uint8_t  *insert_data_ptr;
                    312:     uint8_t  *prefix_cnt_ptr;
                    313:     uint16_t  message_size;
                    314: } cand_rp_adv_message;
                    315: 
                    316: extern int disable_all_by_default;
                    317: extern int mrt_table_id;
                    318: 
                    319: /*
                    320:  * Used to contol the switching to the shortest path:
                    321:  */
                    322: typedef enum {
                    323:     SPT_RATE,
                    324:     SPT_PACKETS,
                    325:     SPT_INF
                    326: } spt_mode_t;
                    327: 
                    328: typedef struct {
                    329:     uint8_t   mode;
                    330:     uint32_t  bytes;
                    331:     uint32_t  packets;
                    332:     uint32_t  interval;
                    333: } spt_threshold_t;
                    334: extern spt_threshold_t  spt_threshold;
                    335: 
                    336: extern cand_rp_t        *cand_rp_list;
                    337: extern grp_mask_t       *grp_mask_list;
                    338: extern cand_rp_t        *segmented_cand_rp_list;
                    339: extern grp_mask_t       *segmented_grp_mask_list;
                    340: 
                    341: extern uint16_t          curr_bsr_fragment_tag;
                    342: extern uint8_t           curr_bsr_priority;
                    343: extern uint32_t          curr_bsr_address;
                    344: extern uint32_t          curr_bsr_hash_mask;
                    345: extern uint8_t          cand_bsr_flag;            /* candidate BSR flag */
                    346: extern uint8_t           my_bsr_priority;
                    347: extern uint32_t          my_bsr_address;
                    348: extern uint32_t          my_bsr_hash_mask;
                    349: extern uint8_t           cand_rp_flag;              /* Candidate RP flag */
                    350: extern uint32_t          my_cand_rp_address;
                    351: extern uint8_t           my_cand_rp_priority;
                    352: extern uint16_t          my_cand_rp_holdtime;
                    353: extern uint16_t          my_cand_rp_adv_period;     /* The locally configured
                    354:                                                    * Cand-RP adv. period.
                    355:                                                    */
                    356: extern uint16_t          pim_bootstrap_timer;
                    357: extern uint32_t          rp_my_ipv4_hashmask;
                    358: extern uint16_t          pim_cand_rp_adv_timer;
                    359: 
                    360: /* route.c */
                    361: extern uint32_t                default_route_metric;
                    362: extern uint32_t                default_route_distance;
                    363: 
                    364: /* igmp_proto.c */
                    365: extern uint32_t                igmp_query_interval;
                    366: extern uint32_t                igmp_querier_timeout;
                    367: 
                    368: /* mrt.c */
                    369: extern srcentry_t      *srclist;
                    370: extern grpentry_t      *grplist;
                    371: 
                    372: /* vif.c */
                    373: extern struct uvif     uvifs[MAXVIFS];
                    374: extern vifi_t          numvifs;
                    375: extern int              total_interfaces;
                    376: extern vifi_t          reg_vif_num;
                    377: extern int              phys_vif;
                    378: extern int             udp_socket;
                    379: 
                    380: extern int             vifs_down;
                    381: 
                    382: #define MAX_INET_BUF_LEN 19
                    383: extern char            s1[MAX_INET_BUF_LEN];
                    384: extern char            s2[MAX_INET_BUF_LEN];
                    385: extern char            s3[MAX_INET_BUF_LEN];
                    386: extern char            s4[MAX_INET_BUF_LEN];
                    387: 
                    388: #if !((defined(BSD) && (BSD >= 199103)) || (defined(__linux__)))
                    389: extern int             errno;
                    390: #endif
                    391: 
                    392: 
                    393: #ifndef IGMP_MEMBERSHIP_QUERY
                    394: #define IGMP_MEMBERSHIP_QUERY          IGMP_HOST_MEMBERSHIP_QUERY
                    395: #if !(defined(NetBSD) || defined(OpenBSD) || defined(__FreeBSD__))
                    396: #define IGMP_V1_MEMBERSHIP_REPORT      IGMP_HOST_MEMBERSHIP_REPORT
                    397: #define IGMP_V2_MEMBERSHIP_REPORT      IGMP_HOST_NEW_MEMBERSHIP_REPORT
                    398: #else
                    399: #define IGMP_V1_MEMBERSHIP_REPORT      IGMP_v1_HOST_MEMBERSHIP_REPORT
                    400: #define IGMP_V2_MEMBERSHIP_REPORT      IGMP_v2_HOST_MEMBERSHIP_REPORT
                    401: #endif
                    402: #define IGMP_V2_LEAVE_GROUP            IGMP_HOST_LEAVE_MESSAGE
                    403: #endif
                    404: #if defined(__FreeBSD__)               /* From FreeBSD 8.x */
                    405: #define IGMP_V3_MEMBERSHIP_REPORT       IGMP_v3_HOST_MEMBERSHIP_REPORT
                    406: #else
                    407: #define IGMP_V3_MEMBERSHIP_REPORT      0x22    /* Ver. 3 membership report */
                    408: #endif
                    409: 
                    410: #if defined(NetBSD) || defined(OpenBSD) || defined(__FreeBSD__)
                    411: #define IGMP_MTRACE_RESP               IGMP_MTRACE_REPLY
                    412: #define IGMP_MTRACE                    IGMP_MTRACE_QUERY
                    413: #endif
                    414: 
                    415: /* For timeout. The timers count down */
                    416: #define SET_TIMER(timer, value) (timer) = (value)
                    417: #define RESET_TIMER(timer) (timer) = 0
                    418: #define COPY_TIMER(timer_1, timer_2) (timer_2) = (timer_1)
                    419: #define IF_TIMER_SET(timer) if ((timer) > 0)
                    420: #define IF_TIMER_NOT_SET(timer) if ((timer) <= 0)
                    421: #define FIRE_TIMER(timer)       (timer) = 0
                    422: 
                    423: #define IF_TIMEOUT(timer)              \
                    424:        if (!((timer) -= (MIN(timer, TIMER_INTERVAL))))
                    425: 
                    426: #define IF_NOT_TIMEOUT(timer)          \
                    427:        if ((timer) -= (MIN(timer, TIMER_INTERVAL)))
                    428: 
                    429: #define TIMEOUT(timer)                 \
                    430:        (!((timer) -= (MIN(timer, TIMER_INTERVAL))))
                    431: 
                    432: #define NOT_TIMEOUT(timer)             \
                    433:        ((timer) -= (MIN(timer, TIMER_INTERVAL)))
                    434: 
                    435: #define ELSE else           /* To make emacs cc-mode happy */      
                    436: 
                    437: #define MASK_TO_VAL(x, i) {               \
                    438:        uint32_t _x = ntohl(x);            \
                    439:        (i) = 1;                           \
                    440:        while ((_x) <<= 1)                 \
                    441:            (i)++;                         \
                    442:     };
                    443: 
                    444: #define VAL_TO_MASK(x, i) {                    \
                    445:        x = htonl(~((1 << (32 - (i))) - 1));    \
                    446:     };
                    447: 
                    448: /*
                    449:  * External function definitions
                    450:  */
                    451: 
                    452: /* callout.c */
                    453: extern void    callout_init            (void);
                    454: extern void    free_all_callouts       (void);
                    455: extern void    age_callout_queue       (int);
                    456: extern int     timer_nextTimer         (void);
                    457: extern int     timer_setTimer          (int, cfunc_t, void *);
                    458: extern void    timer_clearTimer        (int);
                    459: extern int     timer_leftTimer         (int);
                    460: 
                    461: /* config.c */
                    462: extern void    config_vifs_from_kernel (void);
                    463: extern void    config_vifs_from_file   (void);
                    464: 
                    465: /* debug.c */
                    466: extern char    *packet_kind            (int proto, int type, int code);
                    467: extern int     debug_kind              (int proto, int type, int code);
                    468: extern void    logit                   (int, int, const char *, ...);
                    469: extern void    dump_frame              (char *desc, void *dump, size_t len);
                    470: extern int     log_level               (int proto, int type, int code);
                    471: extern void    dump                    (int i);
                    472: extern void    fdump                   (int i);
                    473: extern void    cdump                   (int i);
                    474: extern void    dump_vifs               (FILE *fp);
                    475: extern void    dump_pim_mrt            (FILE *fp);
                    476: extern int     dump_rp_set             (FILE *fp);
                    477: 
                    478: /* dvmrp_proto.c */
                    479: extern void    dvmrp_accept_probe      (uint32_t src, uint32_t dst, uint8_t *p, int datalen, uint32_t level);
                    480: extern void    dvmrp_accept_report     (uint32_t src, uint32_t dst, uint8_t *p, int datalen, uint32_t level);
                    481: extern void    dvmrp_accept_info_request (uint32_t src, uint32_t dst, uint8_t *p, int datalen);
                    482: extern void    dvmrp_accept_info_reply (uint32_t src, uint32_t dst, uint8_t *p, int datalen);
                    483: extern void    dvmrp_accept_neighbors  (uint32_t src, uint32_t dst, uint8_t *p, int datalen, uint32_t level);
                    484: extern void    dvmrp_accept_neighbors2 (uint32_t src, uint32_t dst, uint8_t *p, int datalen, uint32_t level);
                    485: extern void    dvmrp_accept_prune      (uint32_t src, uint32_t dst, uint8_t *p, int datalen);
                    486: extern void    dvmrp_accept_graft      (uint32_t src, uint32_t dst, uint8_t *p, int datalen);
                    487: extern void    dvmrp_accept_g_ack      (uint32_t src, uint32_t dst, uint8_t *p, int datalen);
                    488: 
                    489: /* igmp.c */
                    490: extern void    init_igmp               (void);
                    491: extern void    send_igmp               (char *buf, uint32_t src, uint32_t dst, int type, int code, uint32_t group, int datalen);
                    492: 
                    493: /* igmp_proto.c */
                    494: extern void    query_groups            (struct uvif *v);
                    495: extern void    accept_membership_query (uint32_t src, uint32_t dst, uint32_t group, int tmo, int igmp_version);
                    496: extern void    accept_group_report     (uint32_t src, uint32_t dst, uint32_t group, int r_type);
                    497: extern void    accept_leave_message    (uint32_t src, uint32_t dst, uint32_t group);
                    498: extern void     accept_membership_report(uint32_t src, uint32_t dst, struct igmpv3_report *report, ssize_t reportlen);
                    499: 
                    500: /* inet.c */
                    501: extern int     inet_cksum              (uint16_t *addr, u_int len);
                    502: extern int     inet_valid_host         (uint32_t naddr);
                    503: extern int     inet_valid_mask         (uint32_t mask);
                    504: extern int     inet_valid_subnet       (uint32_t nsubnet, uint32_t nmask);
                    505: extern char    *inet_fmt               (uint32_t addr, char *s, size_t len);
                    506: extern char    *netname                (uint32_t addr, uint32_t mask);
                    507: extern uint32_t        inet_parse              (char *s, int n);
                    508: 
                    509: /* kern.c */
                    510: extern void    k_set_sndbuf            (int socket, int bufsize, int minsize);
                    511: extern void    k_set_rcvbuf            (int socket, int bufsize, int minsize);
                    512: extern void    k_hdr_include           (int socket, int val);
                    513: extern void    k_set_ttl               (int socket, int t);
                    514: extern void    k_set_loop              (int socket, int l);
                    515: extern void    k_set_if                (int socket, uint32_t ifa);
                    516: extern void    k_set_router_alert      (int socket);
                    517: extern void    k_join                  (int socket, uint32_t grp, struct uvif *v);
                    518: extern void    k_leave                 (int socket, uint32_t grp, struct uvif *v);
                    519: extern void    k_init_pim              (int socket);
                    520: extern void    k_stop_pim              (int socket);
                    521: extern int     k_del_mfc               (int socket, uint32_t source, uint32_t group);
                    522: extern int     k_chg_mfc               (int socket, uint32_t source, uint32_t group, vifi_t iif, vifbitmap_t oifs,
                    523:                                          uint32_t rp_addr);
                    524: extern void    k_add_vif               (int socket, vifi_t vifi, struct uvif *v);
                    525: extern void    k_del_vif               (int socket, vifi_t vifi, struct uvif *v);
                    526: extern int     k_get_vif_count         (vifi_t vifi, struct vif_count *retval);
                    527: extern int     k_get_sg_cnt            (int socket, uint32_t source, uint32_t group, struct sg_count *retval);
                    528: 
                    529: /* main.c */
                    530: extern int     register_input_handler  (int fd, ihfunc_t func);
                    531: 
                    532: /* mrt.c */
                    533: extern void    init_pim_mrt            (void);
                    534: extern mrtentry_t *find_route          (uint32_t source, uint32_t group, uint16_t flags, char create);
                    535: extern grpentry_t *find_group          (uint32_t group);
                    536: extern srcentry_t *find_source         (uint32_t source);
                    537: extern void    delete_mrtentry         (mrtentry_t *mrtentry_ptr);
                    538: extern void    delete_srcentry         (srcentry_t *srcentry_ptr);
                    539: extern void    delete_grpentry         (grpentry_t *grpentry_ptr);
                    540: extern void    delete_mrtentry_all_kernel_cache (mrtentry_t *mrtentry_ptr);
                    541: extern void    delete_single_kernel_cache (mrtentry_t *mrtentry_ptr, kernel_cache_t *kernel_cache_ptr);
                    542: extern void    delete_single_kernel_cache_addr (mrtentry_t *mrtentry_ptr, uint32_t source, uint32_t group);
                    543: extern void    add_kernel_cache        (mrtentry_t *mrtentry_ptr, uint32_t source, uint32_t group, uint16_t flags);
                    544: /* pim.c */
                    545: extern void    init_pim                (void);
                    546: extern void    send_pim                (char *buf, uint32_t src, uint32_t dst, int type, size_t len);
                    547: extern void    send_pim_unicast        (char *buf, int mtu, uint32_t src, uint32_t dst, int type, size_t len);
                    548: 
                    549: /* pim_proto.c */
                    550: extern int     receive_pim_hello       (uint32_t src, uint32_t dst, char *msg, size_t len);
                    551: extern int     send_pim_hello          (struct uvif *v, uint16_t holdtime);
                    552: extern void    delete_pim_nbr          (pim_nbr_entry_t *nbr_delete);
                    553: extern int     receive_pim_register    (uint32_t src, uint32_t dst, char *msg, size_t len);
                    554: extern int     send_pim_null_register  (mrtentry_t *r);
                    555: extern int     receive_pim_register_stop (uint32_t src, uint32_t dst, char *msg, size_t len);
                    556: extern int     send_pim_register       (char *pkt);
                    557: extern int     receive_pim_join_prune  (uint32_t src, uint32_t dst, char *msg, size_t len);
                    558: extern int     join_or_prune           (mrtentry_t *mrtentry_ptr, pim_nbr_entry_t *upstream_router);
                    559: extern int     receive_pim_assert      (uint32_t src, uint32_t dst, char *msg, size_t len);
                    560: extern int     send_pim_assert         (uint32_t source, uint32_t group, vifi_t vifi, mrtentry_t *mrtentry_ptr);
                    561: extern int     send_periodic_pim_join_prune (vifi_t vifi, pim_nbr_entry_t *pim_nbr, uint16_t holdtime);
                    562: extern int     add_jp_entry            (pim_nbr_entry_t *pim_nbr, uint16_t holdtime, uint32_t group, uint8_t grp_msklen,
                    563:                                          uint32_t source, uint8_t src_msklen,  uint16_t addr_flags, uint8_t join_prune);
                    564: extern void    pack_and_send_jp_message (pim_nbr_entry_t *pim_nbr);
                    565: extern int     receive_pim_cand_rp_adv (uint32_t src, uint32_t dst, char *msg, size_t len);
                    566: extern int     receive_pim_bootstrap   (uint32_t src, uint32_t dst, char *msg, size_t len);
                    567: extern int     send_pim_cand_rp_adv    (void);
                    568: extern void    send_pim_bootstrap      (void);
                    569: 
                    570: /* route.c */
                    571: extern int     set_incoming            (srcentry_t *srcentry_ptr, int srctype);
                    572: extern vifi_t  get_iif                 (uint32_t source);
                    573: extern pim_nbr_entry_t *find_pim_nbr   (uint32_t source);
                    574: extern int     add_sg_oif              (mrtentry_t *mrtentry_ptr, vifi_t vifi, uint16_t holdtime, int update_holdtime);
                    575: extern void    add_leaf                (vifi_t vifi, uint32_t source, uint32_t group);
                    576: extern void    delete_leaf             (vifi_t vifi, uint32_t source, uint32_t group);
                    577: extern int     change_interfaces       (mrtentry_t *mrtentry_ptr,  vifi_t new_iif,
                    578:                                          vifbitmap_t new_joined_oifs_, vifbitmap_t new_pruned_oifs,
                    579:                                          vifbitmap_t new_leaves_, vifbitmap_t new_asserted_oifs, uint16_t flags);
                    580: extern void    calc_oifs               (mrtentry_t *mrtentry_ptr, vifbitmap_t *oifs_ptr);
                    581: extern void    process_kernel_call     (void);
                    582: extern int     delete_vif_from_mrt     (vifi_t vifi);
                    583: extern mrtentry_t *switch_shortest_path        (uint32_t source, uint32_t group);
                    584: 
                    585: /* routesock.c and netlink.c */
                    586: extern int     k_req_incoming          (uint32_t source, struct rpfctl *rpfp);
                    587: extern int     init_routesock          (void);
                    588: extern int     routing_socket;
                    589: 
                    590: /* rp.c */
                    591: extern void    init_rp_and_bsr         (void);
                    592: extern uint16_t        bootstrap_initial_delay (void);
                    593: extern rp_grp_entry_t *add_rp_grp_entry (cand_rp_t  **used_cand_rp_list,
                    594:                                          grp_mask_t **used_grp_mask_list,
                    595:                                          uint32_t rp_addr,
                    596:                                          uint8_t  rp_priority,
                    597:                                          uint16_t rp_holdtime,
                    598:                                          uint32_t group_addr,
                    599:                                          uint32_t group_mask,
                    600:                                          uint32_t bsr_hash_mask,
                    601:                                          uint16_t fragment_tag);
                    602: extern void    delete_rp_grp_entry     (cand_rp_t  **used_cand_rp_list, grp_mask_t **used_grp_mask_list,
                    603:                                          rp_grp_entry_t *rp_grp_entry_delete);
                    604: extern void    delete_grp_mask         (cand_rp_t  **used_cand_rp_list, grp_mask_t **used_grp_mask_list,
                    605:                                          uint32_t group_addr, uint32_t group_mask);
                    606: extern void    delete_rp               (cand_rp_t  **used_cand_rp_list, grp_mask_t **used_grp_mask_list,
                    607:                                          uint32_t rp_addr);
                    608: extern void    delete_rp_list          (cand_rp_t  **used_cand_rp_list, grp_mask_t **used_grp_mask_list);
                    609: extern rpentry_t *rp_match             (uint32_t group);
                    610: extern rp_grp_entry_t *rp_grp_match    (uint32_t group);
                    611: extern rpentry_t *rp_find              (uint32_t rp_address);
                    612: extern int     remap_grpentry          (grpentry_t *grpentry_ptr);
                    613: extern int     create_pim_bootstrap_message (char *send_buff);
                    614: extern int     check_mrtentry_rp       (mrtentry_t *mrtentry_ptr, uint32_t rp_addr);
                    615: 
                    616: #ifdef RSRR
                    617: #ifdef PIM
                    618: #define gtable                         mrtentry
                    619: #endif /* PIM */
                    620: #define RSRR_NOTIFICATION_OK           TRUE
                    621: #define RSRR_NOTIFICATION_FALSE                FALSE
                    622: 
                    623: /* rsrr.c */
                    624: extern void    rsrr_init               (void);
                    625: extern void    rsrr_clean              (void);
                    626: extern void    rsrr_cache_send         (struct gtable *, int);
                    627: extern void    rsrr_cache_clean        (struct gtable *);
                    628: extern void    rsrr_cache_bring_up     (struct gtable *);
                    629: #endif /* RSRR */
                    630: 
                    631: /* timer.c */
                    632: extern void    init_timers             (void);
                    633: extern void    age_vifs                (void);
                    634: extern void    age_routes              (void);
                    635: extern void    age_misc                (void);
                    636: extern int     unicast_routing_changes (srcentry_t *src_ent);
                    637: extern int     clean_srclist           (void);
                    638: 
                    639: /* trace.c */
                    640: /* u_int is promoted uint8_t */
                    641: extern void    accept_mtrace           (uint32_t src, uint32_t dst, uint32_t group, char *data, u_int no, int datalen);
                    642: extern void    accept_neighbor_request (uint32_t src, uint32_t dst);
                    643: extern void    accept_neighbor_request2 (uint32_t src, uint32_t dst);
                    644: 
                    645: /* vif.c */
                    646: extern void    init_vifs               (void);
                    647: extern void    zero_vif                (struct uvif *, int);
                    648: extern void    stop_all_vifs           (void);
                    649: extern void    check_vif_state         (void);
                    650: extern vifi_t  local_address           (uint32_t src);
                    651: extern vifi_t  find_vif_direct         (uint32_t src);
                    652: extern vifi_t  find_vif_direct_local   (uint32_t src);
                    653: extern uint32_t        max_local_address       (void);
                    654: 
                    655: struct rp_hold {
                    656:        struct rp_hold *next;
                    657:        uint32_t        address;
                    658:        uint32_t        group;
                    659:        uint32_t        mask;
                    660:        uint8_t priority;
                    661: };
                    662: 
                    663: #endif /* __PIMD_DEFS_H__ */
                    664: 
                    665: /**
                    666:  * Local Variables:
                    667:  *  version-control: t
                    668:  *  indent-tabs-mode: t
                    669:  *  c-file-style: "ellemtel"
                    670:  *  c-basic-offset: 4
                    671:  * End:
                    672:  */

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