Annotation of embedaddon/mrouted/defs.h, revision 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: #ifndef __MROUTED_DEFS_H__
        !            10: #define __MROUTED_DEFS_H__
        !            11: 
        !            12: #include <stdio.h>
        !            13: #include <stdlib.h>
        !            14: #include <unistd.h>
        !            15: #include <ctype.h>
        !            16: #include <errno.h>
        !            17: #include <syslog.h>
        !            18: #include <signal.h>
        !            19: #include <string.h>
        !            20: #include <sys/param.h>
        !            21: #include <sys/types.h>
        !            22: #include <sys/socket.h>
        !            23: #include <sys/ioctl.h>
        !            24: #if ((defined(SYSV)) || (defined(__bsdi__)) || ((defined SunOS) && (SunOS < 50)))
        !            25: #include <sys/sockio.h>
        !            26: #endif /* SYSV || bsdi || SunOS 4.x */
        !            27: #include <time.h>
        !            28: #include <sys/time.h>
        !            29: #include <sys/uio.h>
        !            30: #include <net/if.h>
        !            31: #include <netinet/in.h>
        !            32: #include <netinet/in_systm.h>
        !            33: #include <netinet/ip.h>
        !            34: #include <netinet/ip_icmp.h>
        !            35: #include <netinet/igmp.h>
        !            36: #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
        !            37: #include <osreldate.h>
        !            38: #endif /* __FreeBSD__ */
        !            39: #if (defined(__bsdi__)) || (defined(__FreeBSD__) && (__FreeBSD_version >= 220000)) || defined(__FreeBSD_kernel__)
        !            40: #define rtentry kernel_rtentry
        !            41: #include <net/route.h>
        !            42: #undef rtentry
        !            43: #endif /* bsdi or __FreeBSD_version >= 220000 */
        !            44: #ifdef __linux__
        !            45: #define _LINUX_IN_H             /* For Linux <= 2.6.25 */
        !            46: #include <linux/types.h>
        !            47: #include <linux/mroute.h>
        !            48: #else
        !            49: #include <netinet/ip_mroute.h>
        !            50: #endif
        !            51: #if defined(HAVE_STRLCPY)
        !            52: #include <string.h>
        !            53: #endif
        !            54: #if defined(HAVE_STRTONUM)
        !            55: #include <stdlib.h>
        !            56: #endif
        !            57: #if defined(HAVE_PIDFILE)
        !            58: #if defined(OpenBSD) || defined(NetBSD)
        !            59: #include <util.h>
        !            60: #else
        !            61: #include <libutil.h>
        !            62: #endif
        !            63: #endif
        !            64: #ifdef RSRR
        !            65: #include <sys/un.h>
        !            66: #endif /* RSRR */
        !            67: 
        !            68: /*XXX*/
        !            69: typedef u_int u_int32;
        !            70: 
        !            71: typedef void (*cfunc_t) (void*);
        !            72: typedef void (*ihfunc_t) (int, fd_set *);
        !            73: 
        !            74: #include "dvmrp.h"
        !            75: #include "igmpv2.h"
        !            76: #include "vif.h"
        !            77: #include "route.h"
        !            78: #include "prune.h"
        !            79: #include "pathnames.h"
        !            80: #ifdef RSRR
        !            81: #include "rsrr.h"
        !            82: #include "rsrr_var.h"
        !            83: #endif /* RSRR */
        !            84: 
        !            85: /*
        !            86:  * Miscellaneous constants and macros.
        !            87:  */
        !            88: #define FALSE          0
        !            89: #define TRUE           1
        !            90: 
        !            91: #define EQUAL(s1, s2)  (strcmp((s1), (s2)) == 0)
        !            92: #define ARRAY_LEN(a)    (sizeof((a)) / sizeof((a)[0]))
        !            93: 
        !            94: #define TIMER_INTERVAL ROUTE_MAX_REPORT_DELAY
        !            95: 
        !            96: #define PROTOCOL_VERSION 3  /* increment when packet format/content changes */
        !            97: #define MROUTED_VERSION         9  /* not in DVMRP packets at all */
        !            98: 
        !            99: #define        DVMRP_CONSTANT  0x000eff00      /* constant portion of 'group' field */
        !           100: 
        !           101: #define MROUTED_LEVEL  (DVMRP_CONSTANT | PROTOCOL_VERSION)
        !           102:                            /* for IGMP 'group' field of DVMRP messages */
        !           103: 
        !           104: #define LEAF_FLAGS     (( vifs_with_neighbors == 1 ) ? 0x010000 : 0)
        !           105:                            /* more for IGMP 'group' field of DVMRP messages */
        !           106: 
        !           107: #define        DEL_RTE_GROUP           0
        !           108: #define        DEL_ALL_ROUTES          1
        !           109:                            /* for Deleting kernel table entries */
        !           110: 
        !           111: #define JAN_1970       2208988800UL    /* 1970 - 1900 in seconds */
        !           112: 
        !           113: #ifdef RSRR
        !           114: #define BIT_ZERO(X)      ((X) = 0)
        !           115: #define BIT_SET(X,n)     ((X) |= 1 << (n))
        !           116: #define BIT_CLR(X,n)     ((X) &= ~(1 << (n)))
        !           117: #define BIT_TST(X,n)     ((X) & 1 << (n))
        !           118: #endif /* RSRR */
        !           119: 
        !           120: #ifdef SYSV
        !           121: #define setlinebuf(s)  setvbuf(s, NULL, _IOLBF, 0)
        !           122: #endif
        !           123: 
        !           124: #if defined(_AIX) || (defined(BSD) && (BSD >= 199103))
        !           125: #define        HAVE_SA_LEN
        !           126: #endif
        !           127: 
        !           128: /*
        !           129:  * External declarations for global variables and functions.
        !           130:  */
        !           131: #define RECV_BUF_SIZE 8192
        !           132: extern char            *recv_buf;
        !           133: extern char            *send_buf;
        !           134: extern int             igmp_socket;
        !           135: extern u_int32         allhosts_group;
        !           136: extern u_int32         allrtrs_group;
        !           137: extern u_int32         dvmrp_group;
        !           138: extern u_int32         dvmrp_genid;
        !           139: 
        !           140: #define        IF_DEBUG(l)     if (debug && debug & (l))
        !           141: 
        !           142: #define        DEBUG_PKT       0x0001
        !           143: #define        DEBUG_PRUNE     0x0002
        !           144: #define        DEBUG_ROUTE     0x0004
        !           145: #define        DEBUG_PEER      0x0008
        !           146: #define        DEBUG_CACHE     0x0010
        !           147: #define        DEBUG_TIMEOUT   0x0020
        !           148: #define        DEBUG_IF        0x0040
        !           149: #define        DEBUG_MEMBER    0x0080
        !           150: #define        DEBUG_TRACE     0x0100
        !           151: #define        DEBUG_IGMP      0x0200
        !           152: #define        DEBUG_RTDETAIL  0x0400
        !           153: #define        DEBUG_KERN      0x0800
        !           154: #define        DEBUG_RSRR      0x1000
        !           155: #define        DEBUG_ICMP      0x2000
        !           156: 
        !           157: #define        DEFAULT_DEBUG   0x02de  /* default if "-d" given without value */
        !           158: 
        !           159: extern int             debug;
        !           160: extern int             did_final_init;
        !           161: 
        !           162: extern int             routes_changed;
        !           163: extern int             delay_change_reports;
        !           164: extern unsigned                nroutes;
        !           165: 
        !           166: extern struct uvif     uvifs[MAXVIFS];
        !           167: extern vifi_t          numvifs;
        !           168: extern int             vifs_down;
        !           169: extern int             udp_socket;
        !           170: extern int             vifs_with_neighbors;
        !           171: 
        !           172: #define MAX_INET_BUF_LEN 19
        !           173: extern char            s1[MAX_INET_BUF_LEN];
        !           174: extern char            s2[MAX_INET_BUF_LEN];
        !           175: extern char            s3[MAX_INET_BUF_LEN];
        !           176: extern char            s4[MAX_INET_BUF_LEN];
        !           177: 
        !           178: #define MAX_VERSION_LEN 100
        !           179: extern char             versionstring[MAX_VERSION_LEN];
        !           180: 
        !           181: #if !(defined(BSD) && (BSD >= 199103)) && !defined(__linux__)
        !           182: extern int             errno;
        !           183: #endif
        !           184: 
        !           185: #ifdef OLD_KERNEL
        !           186: #define        MRT_INIT        DVMRP_INIT
        !           187: #define        MRT_DONE        DVMRP_DONE
        !           188: #define        MRT_ADD_VIF     DVMRP_ADD_VIF
        !           189: #define        MRT_DEL_VIF     DVMRP_DEL_VIF
        !           190: #define        MRT_ADD_MFC     DVMRP_ADD_MFC
        !           191: #define        MRT_DEL_MFC     DVMRP_DEL_MFC
        !           192: #endif
        !           193: 
        !           194: #ifndef IGMP_PIM
        !           195: #define        IGMP_PIM        0x14
        !           196: #endif
        !           197: #ifndef IPPROTO_IPIP
        !           198: #define        IPPROTO_IPIP    4
        !           199: #endif
        !           200: 
        !           201: /*
        !           202:  * The original multicast releases defined
        !           203:  * IGMP_HOST_{MEMBERSHIP_QUERY,MEMBERSHIP_REPORT,NEW_MEMBERSHIP_REPORT
        !           204:  *   ,LEAVE_MESSAGE}.  Later releases removed the HOST and inserted
        !           205:  * the IGMP version number.  NetBSD inserted the version number in
        !           206:  * a different way.  mrouted uses the new names, so we #define them
        !           207:  * to the old ones if needed.
        !           208:  */
        !           209: #if !defined(IGMP_MEMBERSHIP_QUERY) && defined(IGMP_HOST_MEMBERSHIP_QUERY)
        !           210: #define        IGMP_MEMBERSHIP_QUERY           IGMP_HOST_MEMBERSHIP_QUERY
        !           211: #define        IGMP_V2_LEAVE_GROUP             IGMP_HOST_LEAVE_MESSAGE
        !           212: #endif
        !           213: #ifndef        IGMP_V1_MEMBERSHIP_REPORT
        !           214: #ifdef IGMP_HOST_MEMBERSHIP_REPORT
        !           215: #define        IGMP_V1_MEMBERSHIP_REPORT       IGMP_HOST_MEMBERSHIP_REPORT
        !           216: #define        IGMP_V2_MEMBERSHIP_REPORT       IGMP_HOST_NEW_MEMBERSHIP_REPORT
        !           217: #endif
        !           218: #ifdef IGMP_v1_HOST_MEMBERSHIP_REPORT
        !           219: #define        IGMP_V1_MEMBERSHIP_REPORT       IGMP_v1_HOST_MEMBERSHIP_REPORT
        !           220: #define        IGMP_V2_MEMBERSHIP_REPORT       IGMP_v2_HOST_MEMBERSHIP_REPORT
        !           221: #endif
        !           222: #endif
        !           223: 
        !           224: /*
        !           225:  * NetBSD also renamed the mtrace types.
        !           226:  */
        !           227: #if !defined(IGMP_MTRACE_RESP) && defined(IGMP_MTRACE_REPLY)
        !           228: #define        IGMP_MTRACE_RESP                IGMP_MTRACE_REPLY
        !           229: #define        IGMP_MTRACE                     IGMP_MTRACE_QUERY
        !           230: #endif
        !           231: 
        !           232: /* main.c */
        !           233: extern char *          scaletime(u_long);
        !           234: extern void            logit(int, int, const char *, ...);
        !           235: extern int             register_input_handler(int, ihfunc_t);
        !           236: 
        !           237: /* igmp.c */
        !           238: extern void            init_igmp(void);
        !           239: extern void            accept_igmp(size_t);
        !           240: extern size_t          build_igmp(u_int32, u_int32, int, int, u_int32, int);
        !           241: extern void            send_igmp(u_int32, u_int32, int, int, u_int32, int);
        !           242: extern char *          igmp_packet_kind(u_int, u_int);
        !           243: extern int             igmp_debug_kind(u_int, u_int);
        !           244: 
        !           245: /* icmp.c */
        !           246: extern void            init_icmp(void);
        !           247: 
        !           248: /* ipip.c */
        !           249: extern void            init_ipip(void);
        !           250: extern void            init_ipip_on_vif(struct uvif *);
        !           251: extern void            send_ipip(u_int32, u_int32, int, int, u_int32, int, struct uvif *);
        !           252: 
        !           253: /* callout.c */
        !           254: extern void            callout_init(void);
        !           255: extern void            free_all_callouts(void);
        !           256: extern void            age_callout_queue(int);
        !           257: extern int             timer_nextTimer(void);
        !           258: extern int             timer_setTimer(int, cfunc_t, void *);
        !           259: extern int             timer_clearTimer(int);
        !           260: extern int             timer_leftTimer(int);
        !           261: 
        !           262: /* route.c */
        !           263: extern void            init_routes(void);
        !           264: extern void            start_route_updates(void);
        !           265: extern void            update_route(u_int32, u_int32, u_int, u_int32, vifi_t, struct listaddr *);
        !           266: extern void            age_routes(void);
        !           267: extern void            expire_all_routes(void);
        !           268: extern void            free_all_routes(void);
        !           269: extern void            accept_probe(u_int32, u_int32, char *, size_t, u_int32);
        !           270: extern void            accept_report(u_int32, u_int32, char *, size_t, u_int32);
        !           271: extern struct rtentry *        determine_route(u_int32 src);
        !           272: extern void            report(int, vifi_t, u_int32);
        !           273: extern void            report_to_all_neighbors(int);
        !           274: extern int             report_next_chunk(void);
        !           275: extern void            blaster_alloc(vifi_t);
        !           276: extern void            add_vif_to_routes(vifi_t);
        !           277: extern void            delete_vif_from_routes(vifi_t);
        !           278: extern void            add_neighbor_to_routes(vifi_t, u_int);
        !           279: extern void            delete_neighbor_from_routes(u_int32, vifi_t, u_int);
        !           280: extern void            dump_routes(FILE *fp);
        !           281: 
        !           282: /* vif.c */
        !           283: extern void            init_vifs(void);
        !           284: extern void            zero_vif(struct uvif *, int);
        !           285: extern void            init_installvifs(void);
        !           286: extern void            check_vif_state(void);
        !           287: extern void            send_on_vif(struct uvif *, u_int32, int, size_t);
        !           288: extern vifi_t          find_vif(u_int32, u_int32);
        !           289: extern void            age_vifs(void);
        !           290: extern void            dump_vifs(FILE *);
        !           291: extern void            stop_all_vifs(void);
        !           292: extern struct listaddr *neighbor_info(vifi_t, u_int32);
        !           293: extern void            accept_group_report(u_int32, u_int32, u_int32, int);
        !           294: extern void            query_groups(void);
        !           295: extern void            probe_for_neighbors(void);
        !           296: extern struct listaddr *update_neighbor(vifi_t, u_int32, int, char *, size_t, u_int32);
        !           297: extern void            accept_neighbor_request(u_int32, u_int32);
        !           298: extern void            accept_neighbor_request2(u_int32, u_int32);
        !           299: extern void            accept_info_request(u_int32, u_int32, u_char *, size_t);
        !           300: extern void            accept_info_reply(u_int32, u_int32, u_char *, size_t);
        !           301: extern void            accept_neighbors(u_int32, u_int32, u_char *, size_t, u_int32);
        !           302: extern void            accept_neighbors2(u_int32, u_int32, u_char *, size_t, u_int32);
        !           303: extern void            accept_leave_message(u_int32, u_int32, u_int32);
        !           304: extern void            accept_membership_query(u_int32, u_int32, u_int32, int);
        !           305: 
        !           306: /* config.c */
        !           307: extern void            config_vifs_from_kernel(void);
        !           308: 
        !           309: /* cfparse.y */
        !           310: extern void            config_vifs_from_file(void);
        !           311: 
        !           312: /* inet.c */
        !           313: extern int             inet_valid_host(u_int32);
        !           314: extern int             inet_valid_mask(u_int32);
        !           315: extern int             inet_valid_subnet(u_int32, u_int32);
        !           316: extern char *          inet_fmt(u_int32, char *, size_t);
        !           317: extern char *          inet_fmts(u_int32, u_int32, char *, size_t);
        !           318: extern u_int32         inet_parse(char *, int);
        !           319: extern int             inet_cksum(u_int16_t *, u_int);
        !           320: 
        !           321: /* prune.c */
        !           322: extern unsigned                kroutes;
        !           323: extern void            determine_forwvifs(struct gtable *);
        !           324: extern void            send_prune_or_graft(struct gtable *);
        !           325: extern void            add_table_entry(u_int32, u_int32);
        !           326: extern void            del_table_entry(struct rtentry *,
        !           327:                                        u_int32, u_int);
        !           328: extern void            update_table_entry(struct rtentry *, u_int32);
        !           329: extern int             find_src_grp(u_int32, u_int32, u_int32);
        !           330: extern void            init_ktable(void);
        !           331: extern void            steal_sources(struct rtentry *);
        !           332: extern void            reset_neighbor_state(vifi_t, u_int32);
        !           333: extern int             grplst_mem(vifi_t, u_int32);
        !           334: extern void            free_all_prunes(void);
        !           335: extern void            age_table_entry(void);
        !           336: extern void            dump_cache(FILE *);
        !           337: extern void            update_lclgrp(vifi_t, u_int32);
        !           338: extern void            delete_lclgrp(vifi_t, u_int32);
        !           339: extern void            chkgrp_graft(vifi_t, u_int32);
        !           340: extern void            accept_prune(u_int32, u_int32, char *, size_t);
        !           341: extern void            accept_graft(u_int32, u_int32, char *, size_t);
        !           342: extern void            accept_g_ack(u_int32, u_int32, char *, size_t);
        !           343: /* u_int is promoted u_char */
        !           344: extern void            accept_mtrace(u_int32, u_int32, u_int32, char *, u_int8_t, size_t);
        !           345: 
        !           346: /* kern.c */
        !           347: extern void            k_set_rcvbuf(int, int);
        !           348: extern void            k_hdr_include(int);
        !           349: extern void            k_set_ttl(int);
        !           350: extern void            k_set_loop(int);
        !           351: extern void            k_set_if(u_int32);
        !           352: extern void            k_join(u_int32, u_int32);
        !           353: extern void            k_leave(u_int32, u_int32);
        !           354: extern void            k_init_dvmrp(void);
        !           355: extern void            k_stop_dvmrp(void);
        !           356: extern void            k_add_vif(vifi_t, struct uvif *);
        !           357: extern void            k_del_vif(vifi_t, struct uvif *);
        !           358: extern void            k_add_rg(u_int32, struct gtable *);
        !           359: extern int             k_del_rg(u_int32, struct gtable *);
        !           360: extern int             k_get_version(void);
        !           361: 
        !           362: #ifdef SNMP
        !           363: /* prune.c */
        !           364: extern struct gtable * find_grp(u_int32);
        !           365: extern struct stable * find_grp_src(struct gtable *, u_int32);
        !           366: extern int             next_grp_src_mask(struct gtable **, struct stable **, u_int32, u_int32, u_int32);
        !           367: extern void            refresh_sg(struct sioc_sg_req *, struct gtable *, struct stable *);
        !           368: extern int             next_child(struct gtable **, struct stable **,
        !           369:                                    u_int32, u_int32, u_int32, vifi_t *);
        !           370: 
        !           371: /* route.c */
        !           372: extern struct rtentry * snmp_find_route(u_int32, u_int32);
        !           373: extern int             next_route(struct rtentry **, u_int32, u_int32);
        !           374: extern int             next_route_child(struct rtentry **, u_int32, u_int32, vifi_t *);
        !           375: #endif
        !           376: 
        !           377: #ifdef RSRR
        !           378: /* prune.c */
        !           379: extern struct gtable   *kernel_table;
        !           380: extern struct gtable   *gtp;
        !           381: 
        !           382: /* rsrr.c */
        !           383: extern void            rsrr_init(void);
        !           384: extern void            rsrr_clean(void);
        !           385: extern void            rsrr_cache_send(struct gtable *, int);
        !           386: extern void            rsrr_cache_clean(struct gtable *);
        !           387: #endif /* RSRR */
        !           388: 
        !           389: #ifdef __GNUC__
        !           390: # define UNUSED __attribute__((unused))
        !           391: #else
        !           392: # define UNUSED /*empty*/
        !           393: #endif
        !           394: 
        !           395: #ifndef HAVE_STRLCPY
        !           396: size_t strlcpy(char *dst, const char *src, size_t siz);
        !           397: #endif
        !           398: #ifndef HAVE_STRTONUM
        !           399: long long strtonum(const char *numstr, long long minval, long long maxval, const char **errstrp);
        !           400: #endif
        !           401: #ifndef HAVE_PIDFILE
        !           402: int pidfile(const char *basename);
        !           403: #endif
        !           404: 
        !           405: #endif /* __MROUTED_DEFS_H__ */

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