xorp

igmp_proto.h

00001 /* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */
00002 
00003 /*
00004  * Copyright (c) 2001-2009 XORP, Inc.
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License, Version 2, June
00008  * 1991 as published by the Free Software Foundation. Redistribution
00009  * and/or modification of this program under the terms of any other
00010  * version of the GNU General Public License is not permitted.
00011  * 
00012  * This program is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
00015  * see the GNU General Public License, Version 2, a copy of which can be
00016  * found in the XORP LICENSE.gpl file.
00017  * 
00018  * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
00019  * http://xorp.net
00020  */
00021 
00022 /*
00023  * $XORP: xorp/contrib/mld6igmp_lite/igmp_proto.h,v 1.3 2008/10/02 21:56:31 bms Exp $
00024  */
00025 
00026 #ifndef __MLD6IGMP_IGMP_PROTO_H__
00027 #define __MLD6IGMP_IGMP_PROTO_H__
00028 
00029 
00030 /*
00031  * Internet Group Management Protocol protocol-specific definitions:
00032  * IGMPv1 and IGMPv2 (RFC 2236), and IGMPv3 (RFC 3376).
00033  */
00034 
00035 #ifdef HAVE_NETINET_IN_H
00036 #include <netinet/in.h>
00037 #endif
00038 #ifdef HAVE_NETINET_IGMP_H
00039 #include <netinet/igmp.h>
00040 #endif
00041 
00042 
00043 /*
00044  * Constants definitions
00045  */
00046 #ifndef IPPROTO_IGMP
00047 #define IPPROTO_IGMP                2
00048 #endif
00049 
00050 /* IGMP versions definition */
00051 #define IGMP_V1                 1
00052 #define IGMP_V2                 2
00053 #define IGMP_V3                 3
00054 #define IGMP_VERSION_MIN            IGMP_V1
00055 #define IGMP_VERSION_MAX            IGMP_V3
00056 #define IGMP_VERSION_DEFAULT            IGMP_V2
00057 
00058 /*
00059  * Constants for IGMP Version 2.
00060  * All intervals are in seconds.
00061  * XXX: several of these, especially the robustness variable, should be
00062  * variables and not constants.
00063  * XXX: some of the definitions are copied from mrouted code.
00064  */
00065 #define IGMP_ROBUSTNESS_VARIABLE        2
00066 #define IGMP_QUERY_INTERVAL         125
00067 #define IGMP_QUERY_RESPONSE_INTERVAL        10
00068 #define IGMP_GROUP_MEMBERSHIP_INTERVAL      (IGMP_ROBUSTNESS_VARIABLE     \
00069                         * IGMP_QUERY_INTERVAL         \
00070                         + IGMP_QUERY_RESPONSE_INTERVAL)
00071 #define IGMP_OTHER_QUERIER_PRESENT_INTERVAL (IGMP_ROBUSTNESS_VARIABLE     \
00072                         * IGMP_QUERY_INTERVAL         \
00073                     + IGMP_QUERY_RESPONSE_INTERVAL / 2)
00074 #define IGMP_STARTUP_QUERY_INTERVAL     (IGMP_QUERY_INTERVAL / 4)
00075 #define IGMP_STARTUP_QUERY_COUNT        IGMP_ROBUSTNESS_VARIABLE
00076 #define IGMP_LAST_MEMBER_QUERY_INTERVAL     1
00077 #define IGMP_LAST_MEMBER_QUERY_COUNT        IGMP_ROBUSTNESS_VARIABLE
00078 #define IGMP_VERSION1_ROUTER_PRESENT_TIMEOUT    400
00079 #define IGMP_OLDER_VERSION_HOST_PRESENT_INTERVAL (IGMP_ROBUSTNESS_VARIABLE    \
00080                         * IGMP_QUERY_INTERVAL         \
00081                         + IGMP_QUERY_RESPONSE_INTERVAL)
00082 #ifndef IGMP_TIMER_SCALE
00083 /* the igmp code field is in 10th of seconds */
00084 #define IGMP_TIMER_SCALE            10
00085 #endif
00086 
00087 /*
00088  * DVMRP message types from mrouted/mrinfo
00089  * (carried in the "code" field of an IGMP header)
00090  */
00091 /* TODO: remove the things we don't need */
00092 #define DVMRP_PROBE     1   /* for finding neighbors             */
00093 #define DVMRP_REPORT        2   /* for reporting some or all routes  */
00094 #define DVMRP_ASK_NEIGHBORS 3   /* sent by mapper, asking for a list */
00095                     /* of this router's neighbors.       */
00096 #define DVMRP_NEIGHBORS     4   /* response to such a request        */
00097 #define DVMRP_ASK_NEIGHBORS2    5   /* as above, want new format reply   */
00098 #define DVMRP_NEIGHBORS2    6
00099 #define DVMRP_PRUNE     7   /* prune message             */
00100 #define DVMRP_GRAFT     8   /* graft message             */
00101 #define DVMRP_GRAFT_ACK     9   /* graft acknowledgement         */
00102 #define DVMRP_INFO_REQUEST  10  /* information request           */
00103 #define DVMRP_INFO_REPLY    11  /* information reply             */
00104 
00105 /*
00106  * 'flags' byte values in DVMRP_NEIGHBORS2 reply.
00107  */
00108 #define DVMRP_NF_TUNNEL     0x01    /* neighbors reached via tunnel      */
00109 #define DVMRP_NF_SRCRT      0x02    /* tunnel uses IP source routing     */
00110 #define DVMRP_NF_PIM        0x04    /* neighbor is a PIM neighbor        */
00111 #define DVMRP_NF_DOWN       0x10    /* kernel state of interface         */
00112 #define DVMRP_NF_DISABLED   0x20    /* administratively disabled         */
00113 #define DVMRP_NF_QUERIER    0x40    /* I am the subnet's querier         */
00114 #define DVMRP_NF_LEAF       0x80    /* Neighbor reports that it is a leaf*/
00115 
00116 /*
00117  * Request/reply types for info queries/replies
00118  */
00119 #define DVMRP_INFO_VERSION  1   /* version string            */
00120 #define DVMRP_INFO_NEIGHBORS    2   /* neighbors2 data           */
00121 
00122 /*
00123  * IGMPv1,v2-related missing definitions
00124  */
00125 #ifndef IGMP_MEMBERSHIP_QUERY
00126 #  ifdef IGMP_HOST_MEMBERSHIP_QUERY
00127 #    define IGMP_MEMBERSHIP_QUERY   IGMP_HOST_MEMBERSHIP_QUERY
00128 #  else
00129 #    define IGMP_MEMBERSHIP_QUERY   0x11
00130 #  endif
00131 #endif
00132 
00133 #ifndef IGMP_V1_MEMBERSHIP_REPORT
00134 #  ifdef IGMP_v1_HOST_MEMBERSHIP_REPORT
00135 #    define IGMP_V1_MEMBERSHIP_REPORT   IGMP_v1_HOST_MEMBERSHIP_REPORT
00136 #  else
00137 #    define IGMP_V1_MEMBERSHIP_REPORT   0x12
00138 #  endif
00139 #endif
00140 
00141 #ifndef IGMP_V2_MEMBERSHIP_REPORT
00142 #  ifdef IGMP_v2_HOST_MEMBERSHIP_REPORT
00143 #    define IGMP_V2_MEMBERSHIP_REPORT   IGMP_v2_HOST_MEMBERSHIP_REPORT
00144 #  else
00145 #    define IGMP_V2_MEMBERSHIP_REPORT   0x16
00146 #  endif
00147 #endif
00148 
00149 #ifndef IGMP_V2_LEAVE_GROUP
00150 #  ifdef IGMP_HOST_LEAVE_MESSAGE
00151 #    define IGMP_V2_LEAVE_GROUP     IGMP_HOST_LEAVE_MESSAGE
00152 #  else
00153 #    define IGMP_V2_LEAVE_GROUP     0x17
00154 #  endif
00155 #endif
00156 
00157 #ifndef IGMP_DVMRP
00158 #  define IGMP_DVMRP            0x13
00159 #endif
00160 
00161 #ifndef IGMP_PIM
00162 #  define IGMP_PIM          0x14
00163 #endif
00164 
00165 #ifndef IGMP_MTRACE_RESP
00166 #  ifdef IGMP_MTRACE_REPLY
00167 #    define IGMP_MTRACE_RESP        IGMP_MTRACE_REPLY
00168 #  else
00169 #    define IGMP_MTRACE_RESP        0x1e
00170 #  endif
00171 #endif
00172 
00173 #ifndef IGMP_MTRACE
00174 #  ifdef IGMP_MTRACE_QUERY
00175 #    define IGMP_MTRACE         IGMP_MTRACE_QUERY
00176 #  else
00177 #    define IGMP_MTRACE         0x1f
00178 #  endif
00179 #endif
00180 
00181 #ifndef IGMP_MINLEN
00182 #  define IGMP_MINLEN           8
00183 #endif
00184 
00185 /*
00186  * IGMPv3-related missing definitions
00187  */
00188 #ifndef IGMP_V3_MEMBERSHIP_REPORT
00189 #  ifdef IGMP_v3_HOST_MEMBERSHIP_REPORT
00190 #    define IGMP_V3_MEMBERSHIP_REPORT   IGMP_v3_HOST_MEMBERSHIP_REPORT
00191 #  else
00192 #    define IGMP_V3_MEMBERSHIP_REPORT   0x22
00193 #  endif
00194 #endif
00195 
00196 #ifndef IGMP_MODE_IS_INCLUDE
00197 #  define IGMP_MODE_IS_INCLUDE      1
00198 #endif
00199 
00200 #ifndef IGMP_MODE_IS_EXCLUDE
00201 #  define IGMP_MODE_IS_EXCLUDE      2
00202 #endif
00203 
00204 #ifndef IGMP_CHANGE_TO_INCLUDE_MODE
00205 #  define IGMP_CHANGE_TO_INCLUDE_MODE   3
00206 #endif
00207 
00208 #ifndef IGMP_CHANGE_TO_EXCLUDE_MODE
00209 #  define IGMP_CHANGE_TO_EXCLUDE_MODE   4
00210 #endif
00211 
00212 #ifndef IGMP_ALLOW_NEW_SOURCES
00213 #  define IGMP_ALLOW_NEW_SOURCES    5
00214 #endif
00215 
00216 #ifndef IGMP_BLOCK_OLD_SOURCES
00217 #  define IGMP_BLOCK_OLD_SOURCES    6
00218 #endif
00219 
00220 #ifndef IGMP_V3_QUERY_MINLEN
00221 #  define IGMP_V3_QUERY_MINLEN      12
00222 #endif
00223 
00224 #ifndef IGMP_EXP
00225 #  define IGMP_EXP(x)           (((x) >> 4) & 0x07)
00226 #endif
00227 
00228 #ifndef IGMP_MANT
00229 #  define IGMP_MANT(x)          ((x) & 0x0f)
00230 #endif
00231 
00232 #ifndef IGMP_QRESV
00233 #  define GMP_QRESV(x)          (((x) >> 4) & 0x0f)
00234 #endif
00235 
00236 #ifndef IGMP_SFLAG
00237 #  define IGMP_SFLAG(x)         (((x) >> 3) & 0x01)
00238 #endif
00239 
00240 #ifndef IGMP_QRV
00241 #  define IGMP_QRV(x)           ((x) & 0x07)
00242 #endif
00243 
00244 /*
00245  * Structures, typedefs and macros
00246  */
00247 
00248 /*
00249  * The ASCII names of the IGMP protocol control messages
00250  */
00251 #ifdef IGMP_V3_MEMBERSHIP_REPORT
00252 #define IGMPV3TYPE2ASCII(t)                     \
00253 (((t) == IGMP_V3_MEMBERSHIP_REPORT) ?                   \
00254     "IGMP_V3_MEMBERSHIP_REPORT"                     \
00255     : "IGMP_type_unknown")
00256 #else
00257 #define IGMPV3TYPE2ASCII(t) "IGMP_type_unknown"
00258 #endif
00259 
00260 #define IGMPTYPE2ASCII(t)                       \
00261 (((t) == IGMP_MEMBERSHIP_QUERY) ?                   \
00262     "IGMP_MEMBERSHIP_QUERY"                     \
00263     : ((t) == IGMP_V1_MEMBERSHIP_REPORT) ?              \
00264     "IGMP_V1_MEMBERSHIP_REPORT"                 \
00265     : ((t) == IGMP_V2_MEMBERSHIP_REPORT) ?              \
00266         "IGMP_V2_MEMBERSHIP_REPORT"                 \
00267         : ((t) == IGMP_V2_LEAVE_GROUP) ?                \
00268         "IGMP_V2_LEAVE_GROUP"                   \
00269         : ((t) == IGMP_DVMRP) ?                 \
00270             "IGMP_DVMRP"                    \
00271             : ((t) == IGMP_PIM) ?               \
00272             "IGMP_PIM"                  \
00273             : ((t) == IGMP_MTRACE_RESP) ?           \
00274                 "IGMP_MTRACE_RESP"              \
00275                 : ((t) == IGMP_MTRACE) ?            \
00276                 "IGMP_MTRACE"               \
00277                 : IGMPV3TYPE2ASCII(t))
00278 
00279 /*
00280  * Global variables
00281  */
00282 
00283 /*
00284  * Global functions prototypes
00285  */
00286 __BEGIN_DECLS
00287 
00288 __END_DECLS
00289 
00290 #endif /* __MLD6IGMP_IGMP_PROTO_H__ */
 All Classes Namespaces Functions Variables Typedefs Enumerations